@riotprompt/riotprompt 0.0.7 → 0.0.9

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.
Files changed (52) hide show
  1. package/.kodrdriv-test-cache.json +6 -0
  2. package/README.md +2 -2
  3. package/dist/builder.d.ts +3 -15
  4. package/dist/builder.js +3 -0
  5. package/dist/builder.js.map +1 -1
  6. package/dist/context-manager.d.ts +135 -0
  7. package/dist/context-manager.js +220 -0
  8. package/dist/context-manager.js.map +1 -0
  9. package/dist/conversation-logger.d.ts +283 -0
  10. package/dist/conversation-logger.js +454 -0
  11. package/dist/conversation-logger.js.map +1 -0
  12. package/dist/conversation.d.ts +271 -0
  13. package/dist/conversation.js +622 -0
  14. package/dist/conversation.js.map +1 -0
  15. package/dist/formatter.d.ts +27 -57
  16. package/dist/formatter.js +2 -2
  17. package/dist/formatter.js.map +1 -1
  18. package/dist/items/parameters.d.ts +1 -1
  19. package/dist/items/section.d.ts +2 -12
  20. package/dist/items/weighted.d.ts +3 -15
  21. package/dist/iteration-strategy.d.ts +231 -0
  22. package/dist/iteration-strategy.js +486 -0
  23. package/dist/iteration-strategy.js.map +1 -0
  24. package/dist/loader.d.ts +3 -11
  25. package/dist/loader.js +3 -0
  26. package/dist/loader.js.map +1 -1
  27. package/dist/message-builder.d.ts +156 -0
  28. package/dist/message-builder.js +254 -0
  29. package/dist/message-builder.js.map +1 -0
  30. package/dist/override.d.ts +3 -13
  31. package/dist/override.js +3 -0
  32. package/dist/override.js.map +1 -1
  33. package/dist/parser.d.ts +2 -8
  34. package/dist/recipes.d.ts +70 -268
  35. package/dist/recipes.js +189 -4
  36. package/dist/recipes.js.map +1 -1
  37. package/dist/reflection.d.ts +250 -0
  38. package/dist/reflection.js +416 -0
  39. package/dist/reflection.js.map +1 -0
  40. package/dist/riotprompt.cjs +3551 -220
  41. package/dist/riotprompt.cjs.map +1 -1
  42. package/dist/riotprompt.d.ts +18 -2
  43. package/dist/riotprompt.js +9 -1
  44. package/dist/riotprompt.js.map +1 -1
  45. package/dist/token-budget.d.ts +177 -0
  46. package/dist/token-budget.js +404 -0
  47. package/dist/token-budget.js.map +1 -0
  48. package/dist/tools.d.ts +239 -0
  49. package/dist/tools.js +324 -0
  50. package/dist/tools.js.map +1 -0
  51. package/package.json +35 -36
  52. package/.cursor/rules/focus-on-prompt.mdc +0 -5
package/dist/recipes.d.ts CHANGED
@@ -1,326 +1,117 @@
1
1
  import { z } from 'zod';
2
+ import { Model } from './chat';
3
+ import { ConversationBuilder } from './conversation';
2
4
  import { Prompt } from './riotprompt';
3
- declare const ContentItemSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
5
+ import { TokenBudgetConfig } from './token-budget';
6
+ import { Tool, ToolRegistry } from './tools';
7
+ import { IterationStrategy, LLMClient, StrategyResult } from './iteration-strategy';
8
+ declare const ContentItemSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
4
9
  content: z.ZodString;
5
10
  title: z.ZodOptional<z.ZodString>;
6
11
  weight: z.ZodOptional<z.ZodNumber>;
7
- }, "strip", z.ZodTypeAny, {
8
- content: string;
9
- weight?: number | undefined;
10
- title?: string | undefined;
11
- }, {
12
- content: string;
13
- weight?: number | undefined;
14
- title?: string | undefined;
15
- }>, z.ZodObject<{
12
+ }, z.core.$strip>, z.ZodObject<{
16
13
  path: z.ZodString;
17
14
  title: z.ZodOptional<z.ZodString>;
18
15
  weight: z.ZodOptional<z.ZodNumber>;
19
- }, "strip", z.ZodTypeAny, {
20
- path: string;
21
- weight?: number | undefined;
22
- title?: string | undefined;
23
- }, {
24
- path: string;
25
- weight?: number | undefined;
26
- title?: string | undefined;
27
- }>, z.ZodObject<{
28
- directories: z.ZodArray<z.ZodString, "many">;
16
+ }, z.core.$strip>, z.ZodObject<{
17
+ directories: z.ZodArray<z.ZodString>;
29
18
  title: z.ZodOptional<z.ZodString>;
30
19
  weight: z.ZodOptional<z.ZodNumber>;
31
- }, "strip", z.ZodTypeAny, {
32
- directories: string[];
33
- weight?: number | undefined;
34
- title?: string | undefined;
35
- }, {
36
- directories: string[];
37
- weight?: number | undefined;
38
- title?: string | undefined;
39
- }>]>;
20
+ }, z.core.$strip>]>;
40
21
  declare const RecipeConfigSchema: z.ZodObject<{
41
22
  basePath: z.ZodString;
42
23
  logger: z.ZodDefault<z.ZodOptional<z.ZodAny>>;
43
- overridePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
24
+ overridePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
44
25
  overrides: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
45
- parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>>>;
46
- persona: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
26
+ parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
27
+ persona: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
47
28
  content: z.ZodString;
48
29
  title: z.ZodOptional<z.ZodString>;
49
30
  weight: z.ZodOptional<z.ZodNumber>;
50
- }, "strip", z.ZodTypeAny, {
51
- content: string;
52
- weight?: number | undefined;
53
- title?: string | undefined;
54
- }, {
55
- content: string;
56
- weight?: number | undefined;
57
- title?: string | undefined;
58
- }>, z.ZodObject<{
31
+ }, z.core.$strip>, z.ZodObject<{
59
32
  path: z.ZodString;
60
33
  title: z.ZodOptional<z.ZodString>;
61
34
  weight: z.ZodOptional<z.ZodNumber>;
62
- }, "strip", z.ZodTypeAny, {
63
- path: string;
64
- weight?: number | undefined;
65
- title?: string | undefined;
66
- }, {
67
- path: string;
68
- weight?: number | undefined;
69
- title?: string | undefined;
70
- }>, z.ZodObject<{
71
- directories: z.ZodArray<z.ZodString, "many">;
35
+ }, z.core.$strip>, z.ZodObject<{
36
+ directories: z.ZodArray<z.ZodString>;
72
37
  title: z.ZodOptional<z.ZodString>;
73
38
  weight: z.ZodOptional<z.ZodNumber>;
74
- }, "strip", z.ZodTypeAny, {
75
- directories: string[];
76
- weight?: number | undefined;
77
- title?: string | undefined;
78
- }, {
79
- directories: string[];
80
- weight?: number | undefined;
81
- title?: string | undefined;
82
- }>]>>;
83
- instructions: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
39
+ }, z.core.$strip>]>>;
40
+ instructions: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
84
41
  content: z.ZodString;
85
42
  title: z.ZodOptional<z.ZodString>;
86
43
  weight: z.ZodOptional<z.ZodNumber>;
87
- }, "strip", z.ZodTypeAny, {
88
- content: string;
89
- weight?: number | undefined;
90
- title?: string | undefined;
91
- }, {
92
- content: string;
93
- weight?: number | undefined;
94
- title?: string | undefined;
95
- }>, z.ZodObject<{
44
+ }, z.core.$strip>, z.ZodObject<{
96
45
  path: z.ZodString;
97
46
  title: z.ZodOptional<z.ZodString>;
98
47
  weight: z.ZodOptional<z.ZodNumber>;
99
- }, "strip", z.ZodTypeAny, {
100
- path: string;
101
- weight?: number | undefined;
102
- title?: string | undefined;
103
- }, {
104
- path: string;
105
- weight?: number | undefined;
106
- title?: string | undefined;
107
- }>, z.ZodObject<{
108
- directories: z.ZodArray<z.ZodString, "many">;
48
+ }, z.core.$strip>, z.ZodObject<{
49
+ directories: z.ZodArray<z.ZodString>;
109
50
  title: z.ZodOptional<z.ZodString>;
110
51
  weight: z.ZodOptional<z.ZodNumber>;
111
- }, "strip", z.ZodTypeAny, {
112
- directories: string[];
113
- weight?: number | undefined;
114
- title?: string | undefined;
115
- }, {
116
- directories: string[];
117
- weight?: number | undefined;
118
- title?: string | undefined;
119
- }>]>, "many">>>;
120
- content: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
52
+ }, z.core.$strip>]>>>>;
53
+ content: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
121
54
  content: z.ZodString;
122
55
  title: z.ZodOptional<z.ZodString>;
123
56
  weight: z.ZodOptional<z.ZodNumber>;
124
- }, "strip", z.ZodTypeAny, {
125
- content: string;
126
- weight?: number | undefined;
127
- title?: string | undefined;
128
- }, {
129
- content: string;
130
- weight?: number | undefined;
131
- title?: string | undefined;
132
- }>, z.ZodObject<{
57
+ }, z.core.$strip>, z.ZodObject<{
133
58
  path: z.ZodString;
134
59
  title: z.ZodOptional<z.ZodString>;
135
60
  weight: z.ZodOptional<z.ZodNumber>;
136
- }, "strip", z.ZodTypeAny, {
137
- path: string;
138
- weight?: number | undefined;
139
- title?: string | undefined;
140
- }, {
141
- path: string;
142
- weight?: number | undefined;
143
- title?: string | undefined;
144
- }>, z.ZodObject<{
145
- directories: z.ZodArray<z.ZodString, "many">;
61
+ }, z.core.$strip>, z.ZodObject<{
62
+ directories: z.ZodArray<z.ZodString>;
146
63
  title: z.ZodOptional<z.ZodString>;
147
64
  weight: z.ZodOptional<z.ZodNumber>;
148
- }, "strip", z.ZodTypeAny, {
149
- directories: string[];
150
- weight?: number | undefined;
151
- title?: string | undefined;
152
- }, {
153
- directories: string[];
154
- weight?: number | undefined;
155
- title?: string | undefined;
156
- }>]>, "many">>>;
157
- context: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
65
+ }, z.core.$strip>]>>>>;
66
+ context: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
158
67
  content: z.ZodString;
159
68
  title: z.ZodOptional<z.ZodString>;
160
69
  weight: z.ZodOptional<z.ZodNumber>;
161
- }, "strip", z.ZodTypeAny, {
162
- content: string;
163
- weight?: number | undefined;
164
- title?: string | undefined;
165
- }, {
166
- content: string;
167
- weight?: number | undefined;
168
- title?: string | undefined;
169
- }>, z.ZodObject<{
70
+ }, z.core.$strip>, z.ZodObject<{
170
71
  path: z.ZodString;
171
72
  title: z.ZodOptional<z.ZodString>;
172
73
  weight: z.ZodOptional<z.ZodNumber>;
173
- }, "strip", z.ZodTypeAny, {
174
- path: string;
175
- weight?: number | undefined;
176
- title?: string | undefined;
177
- }, {
178
- path: string;
179
- weight?: number | undefined;
180
- title?: string | undefined;
181
- }>, z.ZodObject<{
182
- directories: z.ZodArray<z.ZodString, "many">;
74
+ }, z.core.$strip>, z.ZodObject<{
75
+ directories: z.ZodArray<z.ZodString>;
183
76
  title: z.ZodOptional<z.ZodString>;
184
77
  weight: z.ZodOptional<z.ZodNumber>;
185
- }, "strip", z.ZodTypeAny, {
186
- directories: string[];
187
- weight?: number | undefined;
188
- title?: string | undefined;
189
- }, {
190
- directories: string[];
191
- weight?: number | undefined;
192
- title?: string | undefined;
193
- }>]>, "many">>>;
78
+ }, z.core.$strip>]>>>>;
194
79
  extends: z.ZodOptional<z.ZodString>;
195
80
  template: z.ZodOptional<z.ZodString>;
196
- }, "strip", z.ZodTypeAny, {
197
- parameters: Record<string, string | number | boolean | (string | number | boolean)[]>;
198
- instructions: (string | {
199
- content: string;
200
- weight?: number | undefined;
201
- title?: string | undefined;
202
- } | {
203
- path: string;
204
- weight?: number | undefined;
205
- title?: string | undefined;
206
- } | {
207
- directories: string[];
208
- weight?: number | undefined;
209
- title?: string | undefined;
210
- })[];
211
- overrides: boolean;
212
- basePath: string;
213
- overridePaths: string[];
214
- content: (string | {
215
- content: string;
216
- weight?: number | undefined;
217
- title?: string | undefined;
218
- } | {
219
- path: string;
220
- weight?: number | undefined;
221
- title?: string | undefined;
222
- } | {
223
- directories: string[];
224
- weight?: number | undefined;
225
- title?: string | undefined;
226
- })[];
227
- context: (string | {
228
- content: string;
229
- weight?: number | undefined;
230
- title?: string | undefined;
231
- } | {
232
- path: string;
233
- weight?: number | undefined;
234
- title?: string | undefined;
235
- } | {
236
- directories: string[];
237
- weight?: number | undefined;
238
- title?: string | undefined;
239
- })[];
240
- persona?: string | {
241
- content: string;
242
- weight?: number | undefined;
243
- title?: string | undefined;
244
- } | {
245
- path: string;
246
- weight?: number | undefined;
247
- title?: string | undefined;
248
- } | {
249
- directories: string[];
250
- weight?: number | undefined;
251
- title?: string | undefined;
252
- } | undefined;
253
- logger?: any;
254
- extends?: string | undefined;
255
- template?: string | undefined;
256
- }, {
257
- basePath: string;
258
- parameters?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
259
- persona?: string | {
260
- content: string;
261
- weight?: number | undefined;
262
- title?: string | undefined;
263
- } | {
264
- path: string;
265
- weight?: number | undefined;
266
- title?: string | undefined;
267
- } | {
268
- directories: string[];
269
- weight?: number | undefined;
270
- title?: string | undefined;
271
- } | undefined;
272
- instructions?: (string | {
273
- content: string;
274
- weight?: number | undefined;
275
- title?: string | undefined;
276
- } | {
277
- path: string;
278
- weight?: number | undefined;
279
- title?: string | undefined;
280
- } | {
281
- directories: string[];
282
- weight?: number | undefined;
283
- title?: string | undefined;
284
- })[] | undefined;
285
- logger?: any;
286
- overrides?: boolean | undefined;
287
- overridePaths?: string[] | undefined;
288
- content?: (string | {
289
- content: string;
290
- weight?: number | undefined;
291
- title?: string | undefined;
292
- } | {
293
- path: string;
294
- weight?: number | undefined;
295
- title?: string | undefined;
296
- } | {
297
- directories: string[];
298
- weight?: number | undefined;
299
- title?: string | undefined;
300
- })[] | undefined;
301
- context?: (string | {
302
- content: string;
303
- weight?: number | undefined;
304
- title?: string | undefined;
305
- } | {
306
- path: string;
307
- weight?: number | undefined;
308
- title?: string | undefined;
309
- } | {
310
- directories: string[];
311
- weight?: number | undefined;
312
- title?: string | undefined;
313
- })[] | undefined;
314
- extends?: string | undefined;
315
- template?: string | undefined;
316
- }>;
81
+ tools: z.ZodOptional<z.ZodAny>;
82
+ toolGuidance: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
83
+ auto: "auto";
84
+ minimal: "minimal";
85
+ detailed: "detailed";
86
+ }>, z.ZodObject<{
87
+ strategy: z.ZodEnum<{
88
+ adaptive: "adaptive";
89
+ minimal: "minimal";
90
+ prescriptive: "prescriptive";
91
+ }>;
92
+ includeExamples: z.ZodOptional<z.ZodBoolean>;
93
+ explainWhenToUse: z.ZodOptional<z.ZodBoolean>;
94
+ includeCategories: z.ZodOptional<z.ZodBoolean>;
95
+ customInstructions: z.ZodOptional<z.ZodString>;
96
+ }, z.core.$strip>]>>;
97
+ toolCategories: z.ZodOptional<z.ZodArray<z.ZodString>>;
98
+ }, z.core.$strip>;
317
99
  type RecipeConfig = z.infer<typeof RecipeConfigSchema>;
318
100
  type ContentItem = z.infer<typeof ContentItemSchema>;
101
+ export interface ToolGuidanceConfig {
102
+ strategy: 'adaptive' | 'prescriptive' | 'minimal';
103
+ includeExamples?: boolean;
104
+ explainWhenToUse?: boolean;
105
+ includeCategories?: boolean;
106
+ customInstructions?: string;
107
+ }
319
108
  export interface TemplateConfig {
320
109
  persona?: ContentItem;
321
110
  instructions?: ContentItem[];
322
111
  content?: ContentItem[];
323
112
  context?: ContentItem[];
113
+ tools?: Tool[] | ToolRegistry;
114
+ toolGuidance?: Partial<ToolGuidanceConfig> | 'auto' | 'minimal' | 'detailed';
324
115
  }
325
116
  /**
326
117
  * Register custom templates with the recipes system
@@ -349,6 +140,10 @@ export declare const getTemplates: () => Record<string, TemplateConfig>;
349
140
  * Clear all registered templates
350
141
  */
351
142
  export declare const clearTemplates: () => void;
143
+ /**
144
+ * Generate tool guidance instructions based on strategy
145
+ */
146
+ export declare const generateToolGuidance: (tools: Tool[], guidance: ToolGuidanceConfig | "auto" | "minimal" | "detailed") => string;
352
147
  export declare const cook: (config: Partial<RecipeConfig> & {
353
148
  basePath: string;
354
149
  }) => Promise<Prompt>;
@@ -362,6 +157,13 @@ export declare const recipe: (basePath: string) => {
362
157
  parameters: (parameters: any) => /*elided*/ any;
363
158
  overrides: (enabled: boolean) => /*elided*/ any;
364
159
  overridePaths: (paths: string[]) => /*elided*/ any;
160
+ tools: (tools: Tool[] | ToolRegistry) => /*elided*/ any;
161
+ toolRegistry: (registry: ToolRegistry) => /*elided*/ any;
162
+ toolGuidance: (guidance: ToolGuidanceConfig | "auto" | "minimal" | "detailed") => /*elided*/ any;
163
+ toolCategories: (categories: string[]) => /*elided*/ any;
365
164
  cook: () => Promise<Prompt>;
165
+ buildConversation: (model: Model, tokenBudget?: TokenBudgetConfig) => Promise<ConversationBuilder>;
166
+ getToolRegistry: () => ToolRegistry | undefined;
167
+ executeWith: (llm: LLMClient, strategy: IterationStrategy, tokenBudget?: TokenBudgetConfig) => Promise<StrategyResult>;
366
168
  };
367
169
  export type { RecipeConfig, ContentItem };
package/dist/recipes.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import path__default from 'path';
2
2
  import { z } from 'zod';
3
+ import { ConversationBuilder } from './conversation.js';
3
4
  import { ParametersSchema } from './items/parameters.js';
4
5
  import { DEFAULT_LOGGER, wrapLogger } from './logger.js';
5
6
  import './items/weighted.js';
@@ -10,6 +11,9 @@ import { create } from './parser.js';
10
11
  import { create as create$2 } from './loader.js';
11
12
  import { create as create$1 } from './override.js';
12
13
  import './builder.js';
14
+ import 'tiktoken';
15
+ import { ToolRegistry } from './tools.js';
16
+ import { StrategyExecutor } from './iteration-strategy.js';
13
17
 
14
18
  // ===== CONFIGURATION SCHEMAS =====
15
19
  const ContentItemSchema = z.union([
@@ -46,13 +50,34 @@ const RecipeConfigSchema = z.object({
46
50
  context: z.array(ContentItemSchema).optional().default([]),
47
51
  // Templates and inheritance
48
52
  extends: z.string().optional(),
49
- template: z.string().optional()
53
+ template: z.string().optional(),
54
+ // Tool integration
55
+ tools: z.any().optional(),
56
+ toolGuidance: z.union([
57
+ z.enum([
58
+ 'auto',
59
+ 'minimal',
60
+ 'detailed'
61
+ ]),
62
+ z.object({
63
+ strategy: z.enum([
64
+ 'adaptive',
65
+ 'prescriptive',
66
+ 'minimal'
67
+ ]),
68
+ includeExamples: z.boolean().optional(),
69
+ explainWhenToUse: z.boolean().optional(),
70
+ includeCategories: z.boolean().optional(),
71
+ customInstructions: z.string().optional()
72
+ })
73
+ ]).optional(),
74
+ toolCategories: z.array(z.string()).optional()
50
75
  });
51
76
  // User-customizable template registry
52
77
  let TEMPLATES = {};
53
78
  /**
54
79
  * Register custom templates with the recipes system
55
- *
80
+ *
56
81
  * @example
57
82
  * ```typescript
58
83
  * // Register your own templates
@@ -83,6 +108,99 @@ let TEMPLATES = {};
83
108
  */ const clearTemplates = ()=>{
84
109
  TEMPLATES = {};
85
110
  };
111
+ // ===== TOOL GUIDANCE GENERATION =====
112
+ /**
113
+ * Generate tool guidance instructions based on strategy
114
+ */ const generateToolGuidance = (tools, guidance)=>{
115
+ if (tools.length === 0) {
116
+ return '';
117
+ }
118
+ // Normalize guidance config
119
+ let config;
120
+ if (typeof guidance === 'string') {
121
+ switch(guidance){
122
+ case 'auto':
123
+ case 'detailed':
124
+ config = {
125
+ strategy: 'adaptive',
126
+ includeExamples: true,
127
+ explainWhenToUse: true
128
+ };
129
+ break;
130
+ case 'minimal':
131
+ config = {
132
+ strategy: 'minimal',
133
+ includeExamples: false,
134
+ explainWhenToUse: false
135
+ };
136
+ break;
137
+ default:
138
+ config = {
139
+ strategy: 'adaptive'
140
+ };
141
+ }
142
+ } else {
143
+ config = guidance;
144
+ }
145
+ let output = '## Available Tools\n\n';
146
+ if (config.customInstructions) {
147
+ output += config.customInstructions + '\n\n';
148
+ }
149
+ // Group by category if enabled
150
+ if (config.includeCategories) {
151
+ const categorized = new Map();
152
+ tools.forEach((tool)=>{
153
+ const category = tool.category || 'General';
154
+ if (!categorized.has(category)) {
155
+ categorized.set(category, []);
156
+ }
157
+ categorized.get(category).push(tool);
158
+ });
159
+ categorized.forEach((categoryTools, category)=>{
160
+ output += `### ${category}\n\n`;
161
+ categoryTools.forEach((tool)=>{
162
+ output += formatToolGuidance(tool, config);
163
+ });
164
+ });
165
+ } else {
166
+ tools.forEach((tool)=>{
167
+ output += formatToolGuidance(tool, config);
168
+ });
169
+ }
170
+ return output;
171
+ };
172
+ const formatToolGuidance = (tool, config)=>{
173
+ let output = `**${tool.name}**`;
174
+ if (tool.cost) {
175
+ output += ` _(${tool.cost})_`;
176
+ }
177
+ output += `\n${tool.description}\n\n`;
178
+ if (config.strategy !== 'minimal') {
179
+ // Parameters
180
+ const required = tool.parameters.required || [];
181
+ const paramList = Object.entries(tool.parameters.properties).map(([name, param])=>{
182
+ const isRequired = required.includes(name);
183
+ return `- \`${name}\`${isRequired ? ' (required)' : ''}: ${param.description}`;
184
+ }).join('\n');
185
+ if (paramList) {
186
+ output += 'Parameters:\n' + paramList + '\n\n';
187
+ }
188
+ // When to use (adaptive and prescriptive)
189
+ if (config.explainWhenToUse && (config.strategy === 'adaptive' || config.strategy === 'prescriptive')) {
190
+ output += `**When to use:** ${tool.description}\n\n`;
191
+ }
192
+ // Examples
193
+ if (config.includeExamples && tool.examples && tool.examples.length > 0) {
194
+ output += '**Examples:**\n';
195
+ tool.examples.forEach((example)=>{
196
+ output += `- ${example.scenario}: \`${tool.name}(${JSON.stringify(example.params)})\`\n`;
197
+ });
198
+ output += '\n';
199
+ }
200
+ }
201
+ output += '---\n\n';
202
+ return output;
203
+ };
86
204
  // ===== CORE RECIPE ENGINE =====
87
205
  const cook = async (config)=>{
88
206
  // Parse and validate configuration with defaults
@@ -168,6 +286,19 @@ const cook = async (config)=>{
168
286
  loader: loader$1,
169
287
  parameters: finalConfig.parameters});
170
288
  }
289
+ // Generate tool guidance if tools are provided
290
+ if (finalConfig.tools) {
291
+ const tools = Array.isArray(finalConfig.tools) ? finalConfig.tools : finalConfig.tools.getAll();
292
+ // Filter by categories if specified
293
+ const filteredTools = finalConfig.toolCategories ? tools.filter((tool)=>finalConfig.toolCategories.includes(tool.category || '')) : tools;
294
+ if (filteredTools.length > 0 && finalConfig.toolGuidance) {
295
+ const guidance = generateToolGuidance(filteredTools, finalConfig.toolGuidance);
296
+ const toolSection = await parser$1.parse(guidance, {
297
+ parameters: finalConfig.parameters
298
+ });
299
+ instructionSection.add(toolSection);
300
+ }
301
+ }
171
302
  // Process content
172
303
  for (const item of finalConfig.content || []){
173
304
  await processContentItem(item, contentSection, 'content', {
@@ -284,10 +415,64 @@ const recipe = (basePath)=>{
284
415
  config.overridePaths = paths;
285
416
  return builder;
286
417
  },
287
- cook: ()=>cook(config)
418
+ tools: (tools)=>{
419
+ config.tools = tools;
420
+ return builder;
421
+ },
422
+ toolRegistry: (registry)=>{
423
+ config.tools = registry;
424
+ return builder;
425
+ },
426
+ toolGuidance: (guidance)=>{
427
+ config.toolGuidance = guidance;
428
+ return builder;
429
+ },
430
+ toolCategories: (categories)=>{
431
+ config.toolCategories = categories;
432
+ return builder;
433
+ },
434
+ cook: ()=>cook(config),
435
+ buildConversation: async (model, tokenBudget)=>{
436
+ const prompt = await cook(config);
437
+ const conversation = ConversationBuilder.create({
438
+ model
439
+ }, config.logger);
440
+ conversation.fromPrompt(prompt, model);
441
+ // Apply token budget if provided
442
+ if (tokenBudget) {
443
+ conversation.withTokenBudget(tokenBudget);
444
+ }
445
+ return conversation;
446
+ },
447
+ getToolRegistry: ()=>{
448
+ if (config.tools instanceof ToolRegistry) {
449
+ return config.tools;
450
+ } else if (Array.isArray(config.tools)) {
451
+ const registry = ToolRegistry.create({}, config.logger);
452
+ registry.registerAll(config.tools);
453
+ return registry;
454
+ }
455
+ return undefined;
456
+ },
457
+ executeWith: async (llm, strategy, tokenBudget)=>{
458
+ const prompt = await cook(config);
459
+ const conversation = ConversationBuilder.create({
460
+ model: 'gpt-4o'
461
+ }, config.logger);
462
+ conversation.fromPrompt(prompt, 'gpt-4o');
463
+ if (tokenBudget) {
464
+ conversation.withTokenBudget(tokenBudget);
465
+ }
466
+ const registry = builder.getToolRegistry();
467
+ if (!registry) {
468
+ throw new Error('Tools must be configured to use executeWith');
469
+ }
470
+ const executor = new StrategyExecutor(llm, config.logger);
471
+ return executor.execute(conversation, registry, strategy);
472
+ }
288
473
  };
289
474
  return builder;
290
475
  };
291
476
 
292
- export { clearTemplates, cook, getTemplates, recipe, registerTemplates };
477
+ export { clearTemplates, cook, generateToolGuidance, getTemplates, recipe, registerTemplates };
293
478
  //# sourceMappingURL=recipes.js.map