@riotprompt/riotprompt 0.0.12 → 0.0.14
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/LICENSE +1 -1
- package/README.md +136 -33
- package/dist/builder.js +3 -0
- package/dist/builder.js.map +1 -1
- package/dist/chat.d.ts +2 -0
- package/dist/chat.js +2 -0
- package/dist/chat.js.map +1 -1
- package/dist/cli.cjs +1617 -0
- package/dist/cli.d.ts +8 -0
- package/dist/config.d.ts +7 -0
- package/dist/conversation-logger.js +6 -1
- package/dist/conversation-logger.js.map +1 -1
- package/dist/execution/anthropic.d.ts +5 -0
- package/dist/execution/anthropic.js +70 -0
- package/dist/execution/anthropic.js.map +1 -0
- package/dist/execution/gemini.d.ts +5 -0
- package/dist/execution/gemini.js +122 -0
- package/dist/execution/gemini.js.map +1 -0
- package/dist/execution/index.d.ts +10 -0
- package/dist/execution/index.js +53 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/openai.d.ts +5 -0
- package/dist/execution/openai.js +45 -0
- package/dist/execution/openai.js.map +1 -0
- package/dist/execution/provider.d.ts +18 -0
- package/dist/formatter.js +42 -14
- package/dist/formatter.js.map +1 -1
- package/dist/loader.js +3 -0
- package/dist/loader.js.map +1 -1
- package/dist/model-config.d.ts +1 -0
- package/dist/model-config.js +19 -18
- package/dist/model-config.js.map +1 -1
- package/dist/override.js +3 -0
- package/dist/override.js.map +1 -1
- package/dist/prompt.d.ts +19 -1
- package/dist/prompt.js +11 -2
- package/dist/prompt.js.map +1 -1
- package/dist/recipes.d.ts +108 -0
- package/dist/recipes.js +198 -30
- package/dist/recipes.js.map +1 -1
- package/dist/riotprompt.cjs +930 -123
- package/dist/riotprompt.cjs.map +1 -1
- package/dist/riotprompt.d.ts +3 -0
- package/dist/riotprompt.js +6 -0
- package/dist/riotprompt.js.map +1 -1
- package/dist/serializer.d.ts +5 -0
- package/dist/serializer.js +220 -0
- package/dist/serializer.js.map +1 -0
- package/dist/writer.d.ts +2 -0
- package/dist/writer.js +91 -0
- package/dist/writer.js.map +1 -0
- package/guide/architecture.md +51 -0
- package/guide/configuration.md +51 -0
- package/guide/development.md +62 -0
- package/guide/index.md +55 -0
- package/guide/usage.md +99 -0
- package/package.json +15 -3
- package/vite.config.cli.ts +49 -0
- package/BUG-ANALYSIS.md +0 -523
- package/CODE-REVIEW-SUMMARY.md +0 -330
- package/FIXES-APPLIED.md +0 -437
package/dist/recipes.d.ts
CHANGED
|
@@ -76,6 +76,98 @@ declare const RecipeConfigSchema: z.ZodObject<{
|
|
|
76
76
|
title: z.ZodOptional<z.ZodString>;
|
|
77
77
|
weight: z.ZodOptional<z.ZodNumber>;
|
|
78
78
|
}, z.core.$strip>]>>>>;
|
|
79
|
+
constraints: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
80
|
+
content: z.ZodString;
|
|
81
|
+
title: z.ZodOptional<z.ZodString>;
|
|
82
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
84
|
+
path: z.ZodString;
|
|
85
|
+
title: z.ZodOptional<z.ZodString>;
|
|
86
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
87
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
88
|
+
directories: z.ZodArray<z.ZodString>;
|
|
89
|
+
title: z.ZodOptional<z.ZodString>;
|
|
90
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
91
|
+
}, z.core.$strip>]>>>>;
|
|
92
|
+
tone: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
93
|
+
content: z.ZodString;
|
|
94
|
+
title: z.ZodOptional<z.ZodString>;
|
|
95
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
97
|
+
path: z.ZodString;
|
|
98
|
+
title: z.ZodOptional<z.ZodString>;
|
|
99
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
101
|
+
directories: z.ZodArray<z.ZodString>;
|
|
102
|
+
title: z.ZodOptional<z.ZodString>;
|
|
103
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
104
|
+
}, z.core.$strip>]>>>>;
|
|
105
|
+
examples: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
106
|
+
content: z.ZodString;
|
|
107
|
+
title: z.ZodOptional<z.ZodString>;
|
|
108
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
109
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
110
|
+
path: z.ZodString;
|
|
111
|
+
title: z.ZodOptional<z.ZodString>;
|
|
112
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
113
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
114
|
+
directories: z.ZodArray<z.ZodString>;
|
|
115
|
+
title: z.ZodOptional<z.ZodString>;
|
|
116
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
117
|
+
}, z.core.$strip>]>>>>;
|
|
118
|
+
reasoning: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
119
|
+
content: z.ZodString;
|
|
120
|
+
title: z.ZodOptional<z.ZodString>;
|
|
121
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
122
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
123
|
+
path: z.ZodString;
|
|
124
|
+
title: z.ZodOptional<z.ZodString>;
|
|
125
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
126
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
127
|
+
directories: z.ZodArray<z.ZodString>;
|
|
128
|
+
title: z.ZodOptional<z.ZodString>;
|
|
129
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
130
|
+
}, z.core.$strip>]>>>>;
|
|
131
|
+
responseFormat: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
132
|
+
content: z.ZodString;
|
|
133
|
+
title: z.ZodOptional<z.ZodString>;
|
|
134
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
135
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
136
|
+
path: z.ZodString;
|
|
137
|
+
title: z.ZodOptional<z.ZodString>;
|
|
138
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
139
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
140
|
+
directories: z.ZodArray<z.ZodString>;
|
|
141
|
+
title: z.ZodOptional<z.ZodString>;
|
|
142
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
143
|
+
}, z.core.$strip>]>>>>;
|
|
144
|
+
recap: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
145
|
+
content: z.ZodString;
|
|
146
|
+
title: z.ZodOptional<z.ZodString>;
|
|
147
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
148
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
149
|
+
path: z.ZodString;
|
|
150
|
+
title: z.ZodOptional<z.ZodString>;
|
|
151
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
152
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
153
|
+
directories: z.ZodArray<z.ZodString>;
|
|
154
|
+
title: z.ZodOptional<z.ZodString>;
|
|
155
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
156
|
+
}, z.core.$strip>]>>>>;
|
|
157
|
+
safeguards: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
158
|
+
content: z.ZodString;
|
|
159
|
+
title: z.ZodOptional<z.ZodString>;
|
|
160
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
162
|
+
path: z.ZodString;
|
|
163
|
+
title: z.ZodOptional<z.ZodString>;
|
|
164
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
165
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
166
|
+
directories: z.ZodArray<z.ZodString>;
|
|
167
|
+
title: z.ZodOptional<z.ZodString>;
|
|
168
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
169
|
+
}, z.core.$strip>]>>>>;
|
|
170
|
+
schema: z.ZodOptional<z.ZodAny>;
|
|
79
171
|
extends: z.ZodOptional<z.ZodString>;
|
|
80
172
|
template: z.ZodOptional<z.ZodString>;
|
|
81
173
|
tools: z.ZodOptional<z.ZodAny>;
|
|
@@ -110,6 +202,14 @@ export interface TemplateConfig {
|
|
|
110
202
|
instructions?: ContentItem[];
|
|
111
203
|
content?: ContentItem[];
|
|
112
204
|
context?: ContentItem[];
|
|
205
|
+
constraints?: ContentItem[];
|
|
206
|
+
tone?: ContentItem[];
|
|
207
|
+
examples?: ContentItem[];
|
|
208
|
+
reasoning?: ContentItem[];
|
|
209
|
+
responseFormat?: ContentItem[];
|
|
210
|
+
recap?: ContentItem[];
|
|
211
|
+
safeguards?: ContentItem[];
|
|
212
|
+
schema?: string | Record<string, any> | z.ZodType<any>;
|
|
113
213
|
tools?: Tool[] | ToolRegistry;
|
|
114
214
|
toolGuidance?: Partial<ToolGuidanceConfig> | 'auto' | 'minimal' | 'detailed';
|
|
115
215
|
}
|
|
@@ -154,6 +254,14 @@ export declare const recipe: (basePath: string) => {
|
|
|
154
254
|
instructions: (...instructions: ContentItem[]) => /*elided*/ any;
|
|
155
255
|
content: (...content: ContentItem[]) => /*elided*/ any;
|
|
156
256
|
context: (...context: ContentItem[]) => /*elided*/ any;
|
|
257
|
+
constraints: (...constraints: ContentItem[]) => /*elided*/ any;
|
|
258
|
+
tone: (...tone: ContentItem[]) => /*elided*/ any;
|
|
259
|
+
examples: (...examples: ContentItem[]) => /*elided*/ any;
|
|
260
|
+
reasoning: (...reasoning: ContentItem[]) => /*elided*/ any;
|
|
261
|
+
responseFormat: (...responseFormat: ContentItem[]) => /*elided*/ any;
|
|
262
|
+
recap: (...recap: ContentItem[]) => /*elided*/ any;
|
|
263
|
+
safeguards: (...safeguards: ContentItem[]) => /*elided*/ any;
|
|
264
|
+
schema: (schema: string | Record<string, any> | z.ZodType<any>) => /*elided*/ any;
|
|
157
265
|
parameters: (parameters: any) => /*elided*/ any;
|
|
158
266
|
overrides: (enabled: boolean) => /*elided*/ any;
|
|
159
267
|
overridePaths: (paths: string[]) => /*elided*/ any;
|
package/dist/recipes.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import path__default from 'path';
|
|
2
|
+
import fs__default from 'fs/promises';
|
|
2
3
|
import { z } from 'zod';
|
|
4
|
+
import zodToJsonSchema from 'zod-to-json-schema';
|
|
3
5
|
import { ConversationBuilder } from './conversation.js';
|
|
4
6
|
import { ParametersSchema } from './items/parameters.js';
|
|
5
7
|
import { DEFAULT_LOGGER, wrapLogger } from './logger.js';
|
|
@@ -14,6 +16,9 @@ import './builder.js';
|
|
|
14
16
|
import 'tiktoken';
|
|
15
17
|
import { ToolRegistry } from './tools.js';
|
|
16
18
|
import { StrategyExecutor } from './iteration-strategy.js';
|
|
19
|
+
import 'openai';
|
|
20
|
+
import '@anthropic-ai/sdk';
|
|
21
|
+
import '@google/generative-ai';
|
|
17
22
|
|
|
18
23
|
// ===== CONFIGURATION SCHEMAS =====
|
|
19
24
|
const ContentItemSchema = z.union([
|
|
@@ -48,6 +53,15 @@ const RecipeConfigSchema = z.object({
|
|
|
48
53
|
instructions: z.array(ContentItemSchema).optional().default([]),
|
|
49
54
|
content: z.array(ContentItemSchema).optional().default([]),
|
|
50
55
|
context: z.array(ContentItemSchema).optional().default([]),
|
|
56
|
+
// Advanced prompting sections
|
|
57
|
+
constraints: z.array(ContentItemSchema).optional().default([]),
|
|
58
|
+
tone: z.array(ContentItemSchema).optional().default([]),
|
|
59
|
+
examples: z.array(ContentItemSchema).optional().default([]),
|
|
60
|
+
reasoning: z.array(ContentItemSchema).optional().default([]),
|
|
61
|
+
responseFormat: z.array(ContentItemSchema).optional().default([]),
|
|
62
|
+
recap: z.array(ContentItemSchema).optional().default([]),
|
|
63
|
+
safeguards: z.array(ContentItemSchema).optional().default([]),
|
|
64
|
+
schema: z.any().optional(),
|
|
51
65
|
// Templates and inheritance
|
|
52
66
|
extends: z.string().optional(),
|
|
53
67
|
template: z.string().optional(),
|
|
@@ -213,6 +227,13 @@ const cook = async (config)=>{
|
|
|
213
227
|
instructions: [],
|
|
214
228
|
content: [],
|
|
215
229
|
context: [],
|
|
230
|
+
constraints: [],
|
|
231
|
+
tone: [],
|
|
232
|
+
examples: [],
|
|
233
|
+
reasoning: [],
|
|
234
|
+
responseFormat: [],
|
|
235
|
+
recap: [],
|
|
236
|
+
safeguards: [],
|
|
216
237
|
...config
|
|
217
238
|
});
|
|
218
239
|
// Handle template inheritance
|
|
@@ -236,7 +257,36 @@ const cook = async (config)=>{
|
|
|
236
257
|
context: [
|
|
237
258
|
...template.context || [],
|
|
238
259
|
...validatedConfig.context || []
|
|
239
|
-
]
|
|
260
|
+
],
|
|
261
|
+
constraints: [
|
|
262
|
+
...template.constraints || [],
|
|
263
|
+
...validatedConfig.constraints || []
|
|
264
|
+
],
|
|
265
|
+
tone: [
|
|
266
|
+
...template.tone || [],
|
|
267
|
+
...validatedConfig.tone || []
|
|
268
|
+
],
|
|
269
|
+
examples: [
|
|
270
|
+
...template.examples || [],
|
|
271
|
+
...validatedConfig.examples || []
|
|
272
|
+
],
|
|
273
|
+
reasoning: [
|
|
274
|
+
...template.reasoning || [],
|
|
275
|
+
...validatedConfig.reasoning || []
|
|
276
|
+
],
|
|
277
|
+
responseFormat: [
|
|
278
|
+
...template.responseFormat || [],
|
|
279
|
+
...validatedConfig.responseFormat || []
|
|
280
|
+
],
|
|
281
|
+
recap: [
|
|
282
|
+
...template.recap || [],
|
|
283
|
+
...validatedConfig.recap || []
|
|
284
|
+
],
|
|
285
|
+
safeguards: [
|
|
286
|
+
...template.safeguards || [],
|
|
287
|
+
...validatedConfig.safeguards || []
|
|
288
|
+
],
|
|
289
|
+
schema: validatedConfig.schema || template.schema
|
|
240
290
|
};
|
|
241
291
|
}
|
|
242
292
|
}
|
|
@@ -268,6 +318,39 @@ const cook = async (config)=>{
|
|
|
268
318
|
const contextSection = create$3({
|
|
269
319
|
title: "Context"
|
|
270
320
|
});
|
|
321
|
+
// Advanced sections
|
|
322
|
+
const constraintSection = create$3({
|
|
323
|
+
title: "Constraints"
|
|
324
|
+
});
|
|
325
|
+
const toneSection = create$3({
|
|
326
|
+
title: "Tone"
|
|
327
|
+
});
|
|
328
|
+
const exampleSection = create$3({
|
|
329
|
+
title: "Examples"
|
|
330
|
+
});
|
|
331
|
+
const reasoningSection = create$3({
|
|
332
|
+
title: "Reasoning"
|
|
333
|
+
});
|
|
334
|
+
const responseFormatSection = create$3({
|
|
335
|
+
title: "Response Format"
|
|
336
|
+
});
|
|
337
|
+
const recapSection = create$3({
|
|
338
|
+
title: "Recap"
|
|
339
|
+
});
|
|
340
|
+
const safeguardSection = create$3({
|
|
341
|
+
title: "Safeguards"
|
|
342
|
+
});
|
|
343
|
+
// Helper for processing list items
|
|
344
|
+
const processList = async (items, section, type)=>{
|
|
345
|
+
for (const item of items){
|
|
346
|
+
await processContentItem(item, section, type, {
|
|
347
|
+
basePath: finalConfig.basePath,
|
|
348
|
+
parser: parser$1,
|
|
349
|
+
override: override$1,
|
|
350
|
+
loader: loader$1,
|
|
351
|
+
parameters: finalConfig.parameters});
|
|
352
|
+
}
|
|
353
|
+
};
|
|
271
354
|
// Process persona
|
|
272
355
|
if (finalConfig.persona) {
|
|
273
356
|
await processContentItem(finalConfig.persona, personaSection, 'persona', {
|
|
@@ -277,15 +360,18 @@ const cook = async (config)=>{
|
|
|
277
360
|
loader: loader$1,
|
|
278
361
|
parameters: finalConfig.parameters});
|
|
279
362
|
}
|
|
280
|
-
// Process
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
363
|
+
// Process standard sections
|
|
364
|
+
await processList(finalConfig.instructions || [], instructionSection, 'instruction');
|
|
365
|
+
await processList(finalConfig.content || [], contentSection, 'content');
|
|
366
|
+
await processList(finalConfig.context || [], contextSection, 'context');
|
|
367
|
+
// Process advanced sections
|
|
368
|
+
await processList(finalConfig.constraints || [], constraintSection, 'instruction');
|
|
369
|
+
await processList(finalConfig.tone || [], toneSection, 'instruction');
|
|
370
|
+
await processList(finalConfig.examples || [], exampleSection, 'content');
|
|
371
|
+
await processList(finalConfig.reasoning || [], reasoningSection, 'instruction');
|
|
372
|
+
await processList(finalConfig.responseFormat || [], responseFormatSection, 'instruction');
|
|
373
|
+
await processList(finalConfig.recap || [], recapSection, 'instruction');
|
|
374
|
+
await processList(finalConfig.safeguards || [], safeguardSection, 'instruction');
|
|
289
375
|
// Generate tool guidance if tools are provided
|
|
290
376
|
if (finalConfig.tools) {
|
|
291
377
|
const tools = Array.isArray(finalConfig.tools) ? finalConfig.tools : finalConfig.tools.getAll();
|
|
@@ -299,30 +385,59 @@ const cook = async (config)=>{
|
|
|
299
385
|
instructionSection.add(toolSection);
|
|
300
386
|
}
|
|
301
387
|
}
|
|
302
|
-
// Process
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
388
|
+
// Process schema
|
|
389
|
+
let schema = finalConfig.schema;
|
|
390
|
+
let validator = undefined;
|
|
391
|
+
if (schema instanceof z.ZodType) {
|
|
392
|
+
var _jsonSchema_definitions;
|
|
393
|
+
// It's a Zod schema!
|
|
394
|
+
validator = schema;
|
|
395
|
+
const jsonSchema = zodToJsonSchema(schema, "response");
|
|
396
|
+
// Wrap in OpenAI Structured Output format
|
|
397
|
+
// zod-to-json-schema returns { "$schema": "...", "definitions": { "response": { ... } }, "$ref": "#/definitions/response" }
|
|
398
|
+
// We need to extract the schema part.
|
|
399
|
+
// Simpler usage for OpenAI: just get the schema object.
|
|
400
|
+
// Actually, zod-to-json-schema produces a full JSON schema object.
|
|
401
|
+
// OpenAI expects: { type: "json_schema", json_schema: { name: "...", schema: ... } }
|
|
402
|
+
// Let's create a clean schema object
|
|
403
|
+
// NOTE: OpenAI requires strict: true and additionalProperties: false
|
|
404
|
+
// zod-to-json-schema generally produces compatible schemas but strictness might need tweaking if required by OpenAI.
|
|
405
|
+
// For now, let's assume "response" as the name.
|
|
406
|
+
// We'll define a simpler conversion if possible, or trust the user to configure Zod strictly if they want strict mode.
|
|
407
|
+
// Extract the definition if it exists
|
|
408
|
+
const actualSchema = ((_jsonSchema_definitions = jsonSchema.definitions) === null || _jsonSchema_definitions === void 0 ? void 0 : _jsonSchema_definitions.response) || jsonSchema;
|
|
409
|
+
schema = {
|
|
410
|
+
type: "json_schema",
|
|
411
|
+
json_schema: {
|
|
412
|
+
name: "response",
|
|
413
|
+
schema: actualSchema,
|
|
414
|
+
strict: true // Try to enable strict mode for OpenAI
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
} else if (typeof schema === 'string') {
|
|
418
|
+
const schemaPath = path__default.resolve(finalConfig.basePath, schema);
|
|
419
|
+
try {
|
|
420
|
+
const schemaContent = await fs__default.readFile(schemaPath, 'utf-8');
|
|
421
|
+
schema = JSON.parse(schemaContent);
|
|
422
|
+
} catch (e) {
|
|
423
|
+
throw new Error(`Failed to load schema from ${schemaPath}: ${e.message}`);
|
|
424
|
+
}
|
|
319
425
|
}
|
|
320
426
|
// Build and return prompt
|
|
321
427
|
return create$4({
|
|
322
|
-
persona: personaSection,
|
|
428
|
+
persona: personaSection.items.length > 0 ? personaSection : undefined,
|
|
323
429
|
instructions: instructionSection,
|
|
324
|
-
contents: contentSection,
|
|
325
|
-
contexts: contextSection
|
|
430
|
+
contents: contentSection.items.length > 0 ? contentSection : undefined,
|
|
431
|
+
contexts: contextSection.items.length > 0 ? contextSection : undefined,
|
|
432
|
+
constraints: constraintSection.items.length > 0 ? constraintSection : undefined,
|
|
433
|
+
tone: toneSection.items.length > 0 ? toneSection : undefined,
|
|
434
|
+
examples: exampleSection.items.length > 0 ? exampleSection : undefined,
|
|
435
|
+
reasoning: reasoningSection.items.length > 0 ? reasoningSection : undefined,
|
|
436
|
+
responseFormat: responseFormatSection.items.length > 0 ? responseFormatSection : undefined,
|
|
437
|
+
recap: recapSection.items.length > 0 ? recapSection : undefined,
|
|
438
|
+
safeguards: safeguardSection.items.length > 0 ? safeguardSection : undefined,
|
|
439
|
+
schema,
|
|
440
|
+
validator
|
|
326
441
|
});
|
|
327
442
|
};
|
|
328
443
|
const processContentItem = async (item, section, type, ctx)=>{
|
|
@@ -400,6 +515,59 @@ const recipe = (basePath)=>{
|
|
|
400
515
|
];
|
|
401
516
|
return builder;
|
|
402
517
|
},
|
|
518
|
+
constraints: (...constraints)=>{
|
|
519
|
+
config.constraints = [
|
|
520
|
+
...config.constraints || [],
|
|
521
|
+
...constraints
|
|
522
|
+
];
|
|
523
|
+
return builder;
|
|
524
|
+
},
|
|
525
|
+
tone: (...tone)=>{
|
|
526
|
+
config.tone = [
|
|
527
|
+
...config.tone || [],
|
|
528
|
+
...tone
|
|
529
|
+
];
|
|
530
|
+
return builder;
|
|
531
|
+
},
|
|
532
|
+
examples: (...examples)=>{
|
|
533
|
+
config.examples = [
|
|
534
|
+
...config.examples || [],
|
|
535
|
+
...examples
|
|
536
|
+
];
|
|
537
|
+
return builder;
|
|
538
|
+
},
|
|
539
|
+
reasoning: (...reasoning)=>{
|
|
540
|
+
config.reasoning = [
|
|
541
|
+
...config.reasoning || [],
|
|
542
|
+
...reasoning
|
|
543
|
+
];
|
|
544
|
+
return builder;
|
|
545
|
+
},
|
|
546
|
+
responseFormat: (...responseFormat)=>{
|
|
547
|
+
config.responseFormat = [
|
|
548
|
+
...config.responseFormat || [],
|
|
549
|
+
...responseFormat
|
|
550
|
+
];
|
|
551
|
+
return builder;
|
|
552
|
+
},
|
|
553
|
+
recap: (...recap)=>{
|
|
554
|
+
config.recap = [
|
|
555
|
+
...config.recap || [],
|
|
556
|
+
...recap
|
|
557
|
+
];
|
|
558
|
+
return builder;
|
|
559
|
+
},
|
|
560
|
+
safeguards: (...safeguards)=>{
|
|
561
|
+
config.safeguards = [
|
|
562
|
+
...config.safeguards || [],
|
|
563
|
+
...safeguards
|
|
564
|
+
];
|
|
565
|
+
return builder;
|
|
566
|
+
},
|
|
567
|
+
schema: (schema)=>{
|
|
568
|
+
config.schema = schema;
|
|
569
|
+
return builder;
|
|
570
|
+
},
|
|
403
571
|
parameters: (parameters)=>{
|
|
404
572
|
config.parameters = {
|
|
405
573
|
...config.parameters,
|
package/dist/recipes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipes.js","sources":["../src/recipes.ts"],"sourcesContent":["import path from \"path\";\nimport { z } from \"zod\";\nimport { Model } from \"./chat\";\nimport { ConversationBuilder } from \"./conversation\";\nimport { ParametersSchema } from \"./items/parameters\";\nimport { SectionOptions } from \"./items/section\";\nimport { DEFAULT_LOGGER, wrapLogger } from \"./logger\";\nimport { Content, Context, createPrompt, createSection, Instruction, Loader, Override, Parser, Prompt, Section, Weighted } from \"./riotprompt\";\nimport { type TokenBudgetConfig } from \"./token-budget\";\nimport { Tool, ToolRegistry } from \"./tools\";\nimport { StrategyExecutor, type IterationStrategy, type LLMClient, type StrategyResult } from \"./iteration-strategy\";\n\n// ===== CONFIGURATION SCHEMAS =====\n\nconst ContentItemSchema = z.union([\n z.string(), // Simple string content\n z.object({\n content: z.string(),\n title: z.string().optional(),\n weight: z.number().optional(),\n }),\n z.object({\n path: z.string(),\n title: z.string().optional(),\n weight: z.number().optional(),\n }),\n z.object({\n directories: z.array(z.string()),\n title: z.string().optional(),\n weight: z.number().optional(),\n })\n]);\n\nconst RecipeConfigSchema = z.object({\n // Core settings\n basePath: z.string(),\n logger: z.any().optional().default(DEFAULT_LOGGER),\n overridePaths: z.array(z.string()).optional().default([\"./\"]),\n overrides: z.boolean().optional().default(false),\n parameters: ParametersSchema.optional().default({}),\n\n // Content sections\n persona: ContentItemSchema.optional(),\n instructions: z.array(ContentItemSchema).optional().default([]),\n content: z.array(ContentItemSchema).optional().default([]),\n context: z.array(ContentItemSchema).optional().default([]),\n\n // Templates and inheritance\n extends: z.string().optional(), // Extend another recipe\n template: z.string().optional(), // Generic template name\n\n // Tool integration\n tools: z.any().optional(), // Tool[] | ToolRegistry\n toolGuidance: z.union([\n z.enum(['auto', 'minimal', 'detailed']),\n z.object({\n strategy: z.enum(['adaptive', 'prescriptive', 'minimal']),\n includeExamples: z.boolean().optional(),\n explainWhenToUse: z.boolean().optional(),\n includeCategories: z.boolean().optional(),\n customInstructions: z.string().optional(),\n })\n ]).optional(),\n toolCategories: z.array(z.string()).optional(),\n});\n\ntype RecipeConfig = z.infer<typeof RecipeConfigSchema>;\ntype ContentItem = z.infer<typeof ContentItemSchema>;\n\n// ===== CONFIGURABLE TEMPLATE SYSTEM =====\n\nexport interface ToolGuidanceConfig {\n strategy: 'adaptive' | 'prescriptive' | 'minimal';\n includeExamples?: boolean;\n explainWhenToUse?: boolean;\n includeCategories?: boolean;\n customInstructions?: string;\n}\n\nexport interface TemplateConfig {\n persona?: ContentItem;\n instructions?: ContentItem[];\n content?: ContentItem[];\n context?: ContentItem[];\n tools?: Tool[] | ToolRegistry;\n toolGuidance?: Partial<ToolGuidanceConfig> | 'auto' | 'minimal' | 'detailed';\n}\n\n// User-customizable template registry\nlet TEMPLATES: Record<string, TemplateConfig> = {};\n\n/**\n * Register custom templates with the recipes system\n *\n * @example\n * ```typescript\n * // Register your own templates\n * registerTemplates({\n * myWorkflow: {\n * persona: { path: \"personas/my-persona.md\" },\n * instructions: [{ path: \"instructions/my-instructions.md\" }]\n * },\n * anotherTemplate: {\n * persona: { content: \"You are a helpful assistant\" },\n * instructions: [{ content: \"Follow these steps...\" }]\n * }\n * });\n * ```\n */\nexport const registerTemplates = (templates: Record<string, TemplateConfig>): void => {\n TEMPLATES = { ...TEMPLATES, ...templates };\n};\n\n/**\n * Get currently registered templates\n */\nexport const getTemplates = (): Record<string, TemplateConfig> => ({ ...TEMPLATES });\n\n/**\n * Clear all registered templates\n */\nexport const clearTemplates = (): void => {\n TEMPLATES = {};\n};\n\n// ===== TOOL GUIDANCE GENERATION =====\n\n/**\n * Generate tool guidance instructions based on strategy\n */\nexport const generateToolGuidance = (\n tools: Tool[],\n guidance: ToolGuidanceConfig | 'auto' | 'minimal' | 'detailed'\n): string => {\n if (tools.length === 0) {\n return '';\n }\n\n // Normalize guidance config\n let config: ToolGuidanceConfig;\n if (typeof guidance === 'string') {\n switch (guidance) {\n case 'auto':\n case 'detailed':\n config = { strategy: 'adaptive', includeExamples: true, explainWhenToUse: true };\n break;\n case 'minimal':\n config = { strategy: 'minimal', includeExamples: false, explainWhenToUse: false };\n break;\n default:\n config = { strategy: 'adaptive' };\n }\n } else {\n config = guidance;\n }\n\n let output = '## Available Tools\\n\\n';\n\n if (config.customInstructions) {\n output += config.customInstructions + '\\n\\n';\n }\n\n // Group by category if enabled\n if (config.includeCategories) {\n const categorized = new Map<string, Tool[]>();\n tools.forEach(tool => {\n const category = tool.category || 'General';\n if (!categorized.has(category)) {\n categorized.set(category, []);\n }\n categorized.get(category)!.push(tool);\n });\n\n categorized.forEach((categoryTools, category) => {\n output += `### ${category}\\n\\n`;\n categoryTools.forEach(tool => {\n output += formatToolGuidance(tool, config);\n });\n });\n } else {\n tools.forEach(tool => {\n output += formatToolGuidance(tool, config);\n });\n }\n\n return output;\n};\n\nconst formatToolGuidance = (tool: Tool, config: ToolGuidanceConfig): string => {\n let output = `**${tool.name}**`;\n\n if (tool.cost) {\n output += ` _(${tool.cost})_`;\n }\n\n output += `\\n${tool.description}\\n\\n`;\n\n if (config.strategy !== 'minimal') {\n // Parameters\n const required = tool.parameters.required || [];\n const paramList = Object.entries(tool.parameters.properties)\n .map(([name, param]) => {\n const isRequired = required.includes(name);\n return `- \\`${name}\\`${isRequired ? ' (required)' : ''}: ${param.description}`;\n })\n .join('\\n');\n\n if (paramList) {\n output += 'Parameters:\\n' + paramList + '\\n\\n';\n }\n\n // When to use (adaptive and prescriptive)\n if (config.explainWhenToUse && (config.strategy === 'adaptive' || config.strategy === 'prescriptive')) {\n output += `**When to use:** ${tool.description}\\n\\n`;\n }\n\n // Examples\n if (config.includeExamples && tool.examples && tool.examples.length > 0) {\n output += '**Examples:**\\n';\n tool.examples.forEach(example => {\n output += `- ${example.scenario}: \\`${tool.name}(${JSON.stringify(example.params)})\\`\\n`;\n });\n output += '\\n';\n }\n }\n\n output += '---\\n\\n';\n\n return output;\n};\n\n// ===== CORE RECIPE ENGINE =====\n\nexport const cook = async (config: Partial<RecipeConfig> & { basePath: string }): Promise<Prompt> => {\n // Parse and validate configuration with defaults\n const validatedConfig = RecipeConfigSchema.parse({\n overridePaths: [\"./\"],\n overrides: false,\n parameters: {},\n instructions: [],\n content: [],\n context: [],\n ...config\n });\n\n // Handle template inheritance\n let finalConfig = { ...validatedConfig };\n if (validatedConfig.template) {\n const template = TEMPLATES[validatedConfig.template];\n if (template) {\n finalConfig = {\n ...validatedConfig,\n persona: validatedConfig.persona || template.persona,\n instructions: [\n ...(template.instructions || []),\n ...(validatedConfig.instructions || [])\n ],\n content: [\n ...(template.content || []),\n ...(validatedConfig.content || [])\n ],\n context: [\n ...(template.context || []),\n ...(validatedConfig.context || [])\n ],\n };\n }\n }\n\n // Setup internal services\n const logger = wrapLogger(finalConfig.logger, 'Recipe');\n const parser = Parser.create({ logger });\n const override = Override.create({\n logger,\n configDirs: finalConfig.overridePaths || [\"./\"],\n overrides: finalConfig.overrides || false\n });\n const loader = Loader.create({ logger });\n\n // Create sections\n const personaSection: Section<Instruction> = createSection({ title: \"Persona\" });\n const instructionSection: Section<Instruction> = createSection({ title: \"Instruction\" });\n const contentSection: Section<Content> = createSection({ title: \"Content\" });\n const contextSection: Section<Context> = createSection({ title: \"Context\" });\n\n // Process persona\n if (finalConfig.persona) {\n await processContentItem(finalConfig.persona, personaSection, 'persona', {\n basePath: finalConfig.basePath,\n parser,\n override,\n loader,\n parameters: finalConfig.parameters,\n logger\n });\n }\n\n // Process instructions\n for (const item of finalConfig.instructions || []) {\n await processContentItem(item, instructionSection, 'instruction', {\n basePath: finalConfig.basePath,\n parser,\n override,\n loader,\n parameters: finalConfig.parameters,\n logger\n });\n }\n\n // Generate tool guidance if tools are provided\n if (finalConfig.tools) {\n const tools: Tool[] = Array.isArray(finalConfig.tools)\n ? finalConfig.tools\n : finalConfig.tools.getAll();\n\n // Filter by categories if specified\n const filteredTools: Tool[] = finalConfig.toolCategories\n ? tools.filter((tool: Tool) => tool.category && finalConfig.toolCategories!.includes(tool.category))\n : tools;\n\n if (filteredTools.length > 0 && finalConfig.toolGuidance) {\n const guidance = generateToolGuidance(filteredTools, finalConfig.toolGuidance);\n const toolSection = await parser.parse(guidance, { parameters: finalConfig.parameters });\n instructionSection.add(toolSection);\n }\n }\n\n // Process content\n for (const item of finalConfig.content || []) {\n await processContentItem(item, contentSection, 'content', {\n basePath: finalConfig.basePath,\n parser,\n override,\n loader,\n parameters: finalConfig.parameters,\n logger\n });\n }\n\n // Process context\n for (const item of finalConfig.context || []) {\n await processContentItem(item, contextSection, 'context', {\n basePath: finalConfig.basePath,\n parser,\n override,\n loader,\n parameters: finalConfig.parameters,\n logger\n });\n }\n\n // Build and return prompt\n return createPrompt({\n persona: personaSection,\n instructions: instructionSection,\n contents: contentSection,\n contexts: contextSection\n });\n};\n\n// ===== CONTENT PROCESSING =====\n\ninterface ProcessingContext {\n basePath: string;\n parser: any;\n override: any;\n loader: any;\n parameters: any;\n logger: any;\n}\n\nconst processContentItem = async <T extends Weighted>(\n item: ContentItem,\n section: Section<T>,\n type: 'persona' | 'instruction' | 'content' | 'context',\n ctx: ProcessingContext\n): Promise<void> => {\n const sectionOptions: SectionOptions = {\n parameters: ctx.parameters,\n };\n\n if (typeof item === 'string') {\n // Simple string content\n const parsedSection = await ctx.parser.parse(item, sectionOptions);\n section.add(parsedSection);\n } else if ('content' in item) {\n // Inline content with options\n const parsedSection = await ctx.parser.parse(item.content, {\n ...sectionOptions,\n title: item.title,\n weight: item.weight,\n });\n section.add(parsedSection);\n } else if ('path' in item) {\n // File path\n const fullPath = path.join(ctx.basePath, item.path);\n const parsedSection = await ctx.parser.parseFile(fullPath, {\n ...sectionOptions,\n title: item.title,\n weight: item.weight,\n });\n const overrideSection = await ctx.override.customize(item.path, parsedSection, sectionOptions);\n section.add(overrideSection);\n } else if ('directories' in item) {\n // Directory loading\n const sections = await ctx.loader.load(item.directories, {\n ...sectionOptions,\n title: item.title,\n weight: item.weight,\n });\n section.add(sections);\n }\n};\n\n// ===== FLUENT RECIPE BUILDER =====\n\nexport const recipe = (basePath: string) => {\n const config: Partial<RecipeConfig> & { basePath: string } = { basePath };\n\n const builder = {\n template: (name: string) => {\n config.template = name;\n return builder;\n },\n with: (partialConfig: Partial<RecipeConfig>) => {\n Object.assign(config, partialConfig);\n return builder;\n },\n persona: (persona: ContentItem) => {\n config.persona = persona;\n return builder;\n },\n instructions: (...instructions: ContentItem[]) => {\n config.instructions = [...(config.instructions || []), ...instructions];\n return builder;\n },\n content: (...content: ContentItem[]) => {\n config.content = [...(config.content || []), ...content];\n return builder;\n },\n context: (...context: ContentItem[]) => {\n config.context = [...(config.context || []), ...context];\n return builder;\n },\n parameters: (parameters: any) => {\n config.parameters = { ...config.parameters, ...parameters };\n return builder;\n },\n overrides: (enabled: boolean) => {\n config.overrides = enabled;\n return builder;\n },\n overridePaths: (paths: string[]) => {\n config.overridePaths = paths;\n return builder;\n },\n tools: (tools: Tool[] | ToolRegistry) => {\n config.tools = tools;\n return builder;\n },\n toolRegistry: (registry: ToolRegistry) => {\n config.tools = registry;\n return builder;\n },\n toolGuidance: (guidance: ToolGuidanceConfig | 'auto' | 'minimal' | 'detailed') => {\n config.toolGuidance = guidance as any;\n return builder;\n },\n toolCategories: (categories: string[]) => {\n config.toolCategories = categories;\n return builder;\n },\n cook: () => cook(config),\n buildConversation: async (model: Model, tokenBudget?: TokenBudgetConfig) => {\n const prompt = await cook(config);\n const conversation = ConversationBuilder.create({ model }, config.logger);\n conversation.fromPrompt(prompt, model);\n\n // Apply token budget if provided\n if (tokenBudget) {\n conversation.withTokenBudget(tokenBudget);\n }\n\n return conversation;\n },\n getToolRegistry: (): ToolRegistry | undefined => {\n if (config.tools instanceof ToolRegistry) {\n return config.tools;\n } else if (Array.isArray(config.tools)) {\n const registry = ToolRegistry.create({}, config.logger);\n registry.registerAll(config.tools);\n return registry;\n }\n return undefined;\n },\n executeWith: async (\n llm: LLMClient,\n strategy: IterationStrategy,\n model: Model = 'gpt-4o',\n tokenBudget?: TokenBudgetConfig\n ): Promise<StrategyResult> => {\n const prompt = await cook(config);\n const conversation = ConversationBuilder.create({ model }, config.logger);\n conversation.fromPrompt(prompt, model);\n\n if (tokenBudget) {\n conversation.withTokenBudget(tokenBudget);\n }\n\n const registry = builder.getToolRegistry();\n if (!registry) {\n throw new Error('Tools must be configured to use executeWith');\n }\n\n const executor = new StrategyExecutor(llm, config.logger);\n return executor.execute(conversation, registry, strategy);\n },\n };\n\n return builder;\n};\n\n// Export types for external use\nexport type { RecipeConfig, ContentItem };\n"],"names":["ContentItemSchema","z","union","string","object","content","title","optional","weight","number","path","directories","array","RecipeConfigSchema","basePath","logger","any","default","DEFAULT_LOGGER","overridePaths","overrides","boolean","parameters","ParametersSchema","persona","instructions","context","extends","template","tools","toolGuidance","enum","strategy","includeExamples","explainWhenToUse","includeCategories","customInstructions","toolCategories","TEMPLATES","registerTemplates","templates","getTemplates","clearTemplates","generateToolGuidance","guidance","length","config","output","categorized","Map","forEach","tool","category","has","set","get","push","categoryTools","formatToolGuidance","name","cost","description","required","paramList","Object","entries","properties","map","param","isRequired","includes","join","examples","example","scenario","JSON","stringify","params","cook","validatedConfig","parse","finalConfig","wrapLogger","parser","Parser","override","Override","configDirs","loader","Loader","personaSection","createSection","instructionSection","contentSection","contextSection","processContentItem","item","Array","isArray","getAll","filteredTools","filter","toolSection","add","createPrompt","contents","contexts","section","type","ctx","sectionOptions","parsedSection","fullPath","parseFile","overrideSection","customize","sections","load","recipe","builder","with","partialConfig","assign","enabled","paths","toolRegistry","registry","categories","buildConversation","model","tokenBudget","prompt","conversation","ConversationBuilder","create","fromPrompt","withTokenBudget","getToolRegistry","ToolRegistry","registerAll","undefined","executeWith","llm","Error","executor","StrategyExecutor","execute"],"mappings":";;;;;;;;;;;;;;;;;AAYA;AAEA,MAAMA,iBAAAA,GAAoBC,CAAAA,CAAEC,KAAK,CAAC;AAC9BD,IAAAA,CAAAA,CAAEE,MAAM,EAAA;AACRF,IAAAA,CAAAA,CAAEG,MAAM,CAAC;AACLC,QAAAA,OAAAA,EAASJ,EAAEE,MAAM,EAAA;QACjBG,KAAAA,EAAOL,CAAAA,CAAEE,MAAM,EAAA,CAAGI,QAAQ,EAAA;QAC1BC,MAAAA,EAAQP,CAAAA,CAAEQ,MAAM,EAAA,CAAGF,QAAQ;AAC/B,KAAA,CAAA;AACAN,IAAAA,CAAAA,CAAEG,MAAM,CAAC;AACLM,QAAAA,IAAAA,EAAMT,EAAEE,MAAM,EAAA;QACdG,KAAAA,EAAOL,CAAAA,CAAEE,MAAM,EAAA,CAAGI,QAAQ,EAAA;QAC1BC,MAAAA,EAAQP,CAAAA,CAAEQ,MAAM,EAAA,CAAGF,QAAQ;AAC/B,KAAA,CAAA;AACAN,IAAAA,CAAAA,CAAEG,MAAM,CAAC;AACLO,QAAAA,WAAAA,EAAaV,CAAAA,CAAEW,KAAK,CAACX,CAAAA,CAAEE,MAAM,EAAA,CAAA;QAC7BG,KAAAA,EAAOL,CAAAA,CAAEE,MAAM,EAAA,CAAG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CAACpD,MAAAA,CAAOjB,KAAK,CAAA,EAAG;AACpC,gBAAA,MAAMiG,WAAWY,YAAAA,CAAaJ,MAAM,CAAC,EAAC,EAAGxF,OAAO/B,MAAM,CAAA;gBACtD+G,QAAAA,CAASa,WAAW,CAAC7F,MAAAA,CAAOjB,KAAK,CAAA;gBACjC,OAAOiG,QAAAA;AACX,YAAA;YACA,OAAOc,SAAAA;AACX,QAAA,CAAA;AACAC,QAAAA,WAAAA,EAAa,OACTC,GAAAA,EACA9G,QAAAA,EACAiG,KAAAA,GAAe,QAAQ,EACvBC,WAAAA,GAAAA;YAEA,MAAMC,MAAAA,GAAS,MAAMrD,IAAAA,CAAKhC,MAAAA,CAAAA;YAC1B,MAAMsF,YAAAA,GAAeC,mBAAAA,CAAoBC,MAAM,CAAC;AAAEL,gBAAAA;AAAM,aAAA,EAAGnF,OAAO/B,MAAM,CAAA;YACxEqH,YAAAA,CAAaG,UAAU,CAACJ,MAAAA,EAAQF,KAAAA,CAAAA;AAEhC,YAAA,IAAIC,WAAAA,EAAa;AACbE,gBAAAA,YAAAA,CAAaI,eAAe,CAACN,WAAAA,CAAAA;AACjC,YAAA;YAEA,MAAMJ,QAAAA,GAAWP,QAAQkB,eAAe,EAAA;AACxC,YAAA,IAAI,CAACX,QAAAA,EAAU;AACX,gBAAA,MAAM,IAAIiB,KAAAA,CAAM,6CAAA,CAAA;AACpB,YAAA;AAEA,YAAA,MAAMC,QAAAA,GAAW,IAAIC,gBAAAA,CAAiBH,GAAAA,EAAKhG,OAAO/B,MAAM,CAAA;AACxD,YAAA,OAAOiI,QAAAA,CAASE,OAAO,CAACd,YAAAA,EAAcN,QAAAA,EAAU9F,QAAAA,CAAAA;AACpD,QAAA;AACJ,KAAA;IAEA,OAAOuF,OAAAA;AACX;;;;"}
|
|
1
|
+
{"version":3,"file":"recipes.js","sources":["../src/recipes.ts"],"sourcesContent":["import path from \"path\";\nimport fs from \"fs/promises\";\nimport { z } from \"zod\";\nimport zodToJsonSchema from \"zod-to-json-schema\";\nimport { Model } from \"./chat\";\nimport { ConversationBuilder } from \"./conversation\";\nimport { ParametersSchema } from \"./items/parameters\";\nimport { SectionOptions } from \"./items/section\";\nimport { DEFAULT_LOGGER, wrapLogger } from \"./logger\";\nimport { Content, Context, createPrompt, createSection, Instruction, Loader, Override, Parser, Prompt, Section, Weighted } from \"./riotprompt\";\nimport { type TokenBudgetConfig } from \"./token-budget\";\nimport { Tool, ToolRegistry } from \"./tools\";\nimport { StrategyExecutor, type IterationStrategy, type LLMClient, type StrategyResult } from \"./iteration-strategy\";\n\n// ===== CONFIGURATION SCHEMAS =====\n\nconst ContentItemSchema = z.union([\n z.string(), // Simple string content\n z.object({\n content: z.string(),\n title: z.string().optional(),\n weight: z.number().optional(),\n }),\n z.object({\n path: z.string(),\n title: z.string().optional(),\n weight: z.number().optional(),\n }),\n z.object({\n directories: z.array(z.string()),\n title: z.string().optional(),\n weight: z.number().optional(),\n })\n]);\n\nconst RecipeConfigSchema = z.object({\n // Core settings\n basePath: z.string(),\n logger: z.any().optional().default(DEFAULT_LOGGER),\n overridePaths: z.array(z.string()).optional().default([\"./\"]),\n overrides: z.boolean().optional().default(false),\n parameters: ParametersSchema.optional().default({}),\n\n // Content sections\n persona: ContentItemSchema.optional(),\n instructions: z.array(ContentItemSchema).optional().default([]),\n content: z.array(ContentItemSchema).optional().default([]),\n context: z.array(ContentItemSchema).optional().default([]),\n\n // Advanced prompting sections\n constraints: z.array(ContentItemSchema).optional().default([]),\n tone: z.array(ContentItemSchema).optional().default([]),\n examples: z.array(ContentItemSchema).optional().default([]),\n reasoning: z.array(ContentItemSchema).optional().default([]),\n responseFormat: z.array(ContentItemSchema).optional().default([]),\n recap: z.array(ContentItemSchema).optional().default([]),\n safeguards: z.array(ContentItemSchema).optional().default([]),\n schema: z.any().optional(), // Can be string path, JSON object, or Zod schema\n\n // Templates and inheritance\n extends: z.string().optional(), // Extend another recipe\n template: z.string().optional(), // Generic template name\n\n // Tool integration\n tools: z.any().optional(), // Tool[] | ToolRegistry\n toolGuidance: z.union([\n z.enum(['auto', 'minimal', 'detailed']),\n z.object({\n strategy: z.enum(['adaptive', 'prescriptive', 'minimal']),\n includeExamples: z.boolean().optional(),\n explainWhenToUse: z.boolean().optional(),\n includeCategories: z.boolean().optional(),\n customInstructions: z.string().optional(),\n })\n ]).optional(),\n toolCategories: z.array(z.string()).optional(),\n});\n\ntype RecipeConfig = z.infer<typeof RecipeConfigSchema>;\ntype ContentItem = z.infer<typeof ContentItemSchema>;\n\n// ===== CONFIGURABLE TEMPLATE SYSTEM =====\n\nexport interface ToolGuidanceConfig {\n strategy: 'adaptive' | 'prescriptive' | 'minimal';\n includeExamples?: boolean;\n explainWhenToUse?: boolean;\n includeCategories?: boolean;\n customInstructions?: string;\n}\n\nexport interface TemplateConfig {\n persona?: ContentItem;\n instructions?: ContentItem[];\n content?: ContentItem[];\n context?: ContentItem[];\n constraints?: ContentItem[];\n tone?: ContentItem[];\n examples?: ContentItem[];\n reasoning?: ContentItem[];\n responseFormat?: ContentItem[];\n recap?: ContentItem[];\n safeguards?: ContentItem[];\n schema?: string | Record<string, any> | z.ZodType<any>;\n tools?: Tool[] | ToolRegistry;\n toolGuidance?: Partial<ToolGuidanceConfig> | 'auto' | 'minimal' | 'detailed';\n}\n\n// User-customizable template registry\nlet TEMPLATES: Record<string, TemplateConfig> = {};\n\n/**\n * Register custom templates with the recipes system\n *\n * @example\n * ```typescript\n * // Register your own templates\n * registerTemplates({\n * myWorkflow: {\n * persona: { path: \"personas/my-persona.md\" },\n * instructions: [{ path: \"instructions/my-instructions.md\" }]\n * },\n * anotherTemplate: {\n * persona: { content: \"You are a helpful assistant\" },\n * instructions: [{ content: \"Follow these steps...\" }]\n * }\n * });\n * ```\n */\nexport const registerTemplates = (templates: Record<string, TemplateConfig>): void => {\n TEMPLATES = { ...TEMPLATES, ...templates };\n};\n\n/**\n * Get currently registered templates\n */\nexport const getTemplates = (): Record<string, TemplateConfig> => ({ ...TEMPLATES });\n\n/**\n * Clear all registered templates\n */\nexport const clearTemplates = (): void => {\n TEMPLATES = {};\n};\n\n// ===== TOOL GUIDANCE GENERATION =====\n\n/**\n * Generate tool guidance instructions based on strategy\n */\nexport const generateToolGuidance = (\n tools: Tool[],\n guidance: ToolGuidanceConfig | 'auto' | 'minimal' | 'detailed'\n): string => {\n if (tools.length === 0) {\n return '';\n }\n\n // Normalize guidance config\n let config: ToolGuidanceConfig;\n if (typeof guidance === 'string') {\n switch (guidance) {\n case 'auto':\n case 'detailed':\n config = { strategy: 'adaptive', includeExamples: true, explainWhenToUse: true };\n break;\n case 'minimal':\n config = { strategy: 'minimal', includeExamples: false, explainWhenToUse: false };\n break;\n default:\n config = { strategy: 'adaptive' };\n }\n } else {\n config = guidance;\n }\n\n let output = '## Available Tools\\n\\n';\n\n if (config.customInstructions) {\n output += config.customInstructions + '\\n\\n';\n }\n\n // Group by category if enabled\n if (config.includeCategories) {\n const categorized = new Map<string, Tool[]>();\n tools.forEach(tool => {\n const category = tool.category || 'General';\n if (!categorized.has(category)) {\n categorized.set(category, []);\n }\n categorized.get(category)!.push(tool);\n });\n\n categorized.forEach((categoryTools, category) => {\n output += `### ${category}\\n\\n`;\n categoryTools.forEach(tool => {\n output += formatToolGuidance(tool, config);\n });\n });\n } else {\n tools.forEach(tool => {\n output += formatToolGuidance(tool, config);\n });\n }\n\n return output;\n};\n\nconst formatToolGuidance = (tool: Tool, config: ToolGuidanceConfig): string => {\n let output = `**${tool.name}**`;\n\n if (tool.cost) {\n output += ` _(${tool.cost})_`;\n }\n\n output += `\\n${tool.description}\\n\\n`;\n\n if (config.strategy !== 'minimal') {\n // Parameters\n const required = tool.parameters.required || [];\n const paramList = Object.entries(tool.parameters.properties)\n .map(([name, param]) => {\n const isRequired = required.includes(name);\n return `- \\`${name}\\`${isRequired ? ' (required)' : ''}: ${param.description}`;\n })\n .join('\\n');\n\n if (paramList) {\n output += 'Parameters:\\n' + paramList + '\\n\\n';\n }\n\n // When to use (adaptive and prescriptive)\n if (config.explainWhenToUse && (config.strategy === 'adaptive' || config.strategy === 'prescriptive')) {\n output += `**When to use:** ${tool.description}\\n\\n`;\n }\n\n // Examples\n if (config.includeExamples && tool.examples && tool.examples.length > 0) {\n output += '**Examples:**\\n';\n tool.examples.forEach(example => {\n output += `- ${example.scenario}: \\`${tool.name}(${JSON.stringify(example.params)})\\`\\n`;\n });\n output += '\\n';\n }\n }\n\n output += '---\\n\\n';\n\n return output;\n};\n\n// ===== CORE RECIPE ENGINE =====\n\nexport const cook = async (config: Partial<RecipeConfig> & { basePath: string }): Promise<Prompt> => {\n // Parse and validate configuration with defaults\n const validatedConfig = RecipeConfigSchema.parse({\n overridePaths: [\"./\"],\n overrides: false,\n parameters: {},\n instructions: [],\n content: [],\n context: [],\n constraints: [],\n tone: [],\n examples: [],\n reasoning: [],\n responseFormat: [],\n recap: [],\n safeguards: [],\n ...config\n });\n\n // Handle template inheritance\n let finalConfig = { ...validatedConfig };\n if (validatedConfig.template) {\n const template = TEMPLATES[validatedConfig.template];\n if (template) {\n finalConfig = {\n ...validatedConfig,\n persona: validatedConfig.persona || template.persona,\n instructions: [\n ...(template.instructions || []),\n ...(validatedConfig.instructions || [])\n ],\n content: [\n ...(template.content || []),\n ...(validatedConfig.content || [])\n ],\n context: [\n ...(template.context || []),\n ...(validatedConfig.context || [])\n ],\n constraints: [\n ...(template.constraints || []),\n ...(validatedConfig.constraints || [])\n ],\n tone: [\n ...(template.tone || []),\n ...(validatedConfig.tone || [])\n ],\n examples: [\n ...(template.examples || []),\n ...(validatedConfig.examples || [])\n ],\n reasoning: [\n ...(template.reasoning || []),\n ...(validatedConfig.reasoning || [])\n ],\n responseFormat: [\n ...(template.responseFormat || []),\n ...(validatedConfig.responseFormat || [])\n ],\n recap: [\n ...(template.recap || []),\n ...(validatedConfig.recap || [])\n ],\n safeguards: [\n ...(template.safeguards || []),\n ...(validatedConfig.safeguards || [])\n ],\n schema: validatedConfig.schema || template.schema,\n };\n }\n }\n\n // Setup internal services\n const logger = wrapLogger(finalConfig.logger, 'Recipe');\n const parser = Parser.create({ logger });\n const override = Override.create({\n logger,\n configDirs: finalConfig.overridePaths || [\"./\"],\n overrides: finalConfig.overrides || false\n });\n const loader = Loader.create({ logger });\n\n // Create sections\n const personaSection: Section<Instruction> = createSection({ title: \"Persona\" });\n const instructionSection: Section<Instruction> = createSection({ title: \"Instruction\" });\n const contentSection: Section<Content> = createSection({ title: \"Content\" });\n const contextSection: Section<Context> = createSection({ title: \"Context\" });\n \n // Advanced sections\n const constraintSection: Section<Instruction> = createSection({ title: \"Constraints\" });\n const toneSection: Section<Instruction> = createSection({ title: \"Tone\" });\n const exampleSection: Section<Content> = createSection({ title: \"Examples\" });\n const reasoningSection: Section<Instruction> = createSection({ title: \"Reasoning\" });\n const responseFormatSection: Section<Instruction> = createSection({ title: \"Response Format\" });\n const recapSection: Section<Instruction> = createSection({ title: \"Recap\" });\n const safeguardSection: Section<Instruction> = createSection({ title: \"Safeguards\" });\n\n // Helper for processing list items\n const processList = async <T extends Weighted>(\n items: ContentItem[],\n section: Section<T>,\n type: 'persona' | 'instruction' | 'content' | 'context'\n ) => {\n for (const item of items) {\n await processContentItem(item, section, type, {\n basePath: finalConfig.basePath,\n parser,\n override,\n loader,\n parameters: finalConfig.parameters,\n logger\n });\n }\n };\n\n // Process persona\n if (finalConfig.persona) {\n await processContentItem(finalConfig.persona, personaSection, 'persona', {\n basePath: finalConfig.basePath,\n parser,\n override,\n loader,\n parameters: finalConfig.parameters,\n logger\n });\n }\n\n // Process standard sections\n await processList(finalConfig.instructions || [], instructionSection, 'instruction');\n await processList(finalConfig.content || [], contentSection, 'content');\n await processList(finalConfig.context || [], contextSection, 'context');\n\n // Process advanced sections\n await processList(finalConfig.constraints || [], constraintSection, 'instruction');\n await processList(finalConfig.tone || [], toneSection, 'instruction');\n await processList(finalConfig.examples || [], exampleSection, 'content');\n await processList(finalConfig.reasoning || [], reasoningSection, 'instruction');\n await processList(finalConfig.responseFormat || [], responseFormatSection, 'instruction');\n await processList(finalConfig.recap || [], recapSection, 'instruction');\n await processList(finalConfig.safeguards || [], safeguardSection, 'instruction');\n\n // Generate tool guidance if tools are provided\n if (finalConfig.tools) {\n const tools: Tool[] = Array.isArray(finalConfig.tools)\n ? finalConfig.tools\n : finalConfig.tools.getAll();\n\n // Filter by categories if specified\n const filteredTools: Tool[] = finalConfig.toolCategories\n ? tools.filter((tool: Tool) => tool.category && finalConfig.toolCategories!.includes(tool.category))\n : tools;\n\n if (filteredTools.length > 0 && finalConfig.toolGuidance) {\n const guidance = generateToolGuidance(filteredTools, finalConfig.toolGuidance);\n const toolSection = await parser.parse(guidance, { parameters: finalConfig.parameters });\n instructionSection.add(toolSection);\n }\n }\n\n // Process schema\n let schema = finalConfig.schema;\n let validator: any = undefined;\n\n if (schema instanceof z.ZodType) {\n // It's a Zod schema!\n validator = schema;\n const jsonSchema = zodToJsonSchema(schema as any, \"response\");\n \n // Wrap in OpenAI Structured Output format\n // zod-to-json-schema returns { \"$schema\": \"...\", \"definitions\": { \"response\": { ... } }, \"$ref\": \"#/definitions/response\" }\n // We need to extract the schema part.\n \n // Simpler usage for OpenAI: just get the schema object.\n // Actually, zod-to-json-schema produces a full JSON schema object.\n // OpenAI expects: { type: \"json_schema\", json_schema: { name: \"...\", schema: ... } }\n \n // Let's create a clean schema object\n // NOTE: OpenAI requires strict: true and additionalProperties: false\n // zod-to-json-schema generally produces compatible schemas but strictness might need tweaking if required by OpenAI.\n // For now, let's assume \"response\" as the name.\n \n // We'll define a simpler conversion if possible, or trust the user to configure Zod strictly if they want strict mode.\n \n // Extract the definition if it exists\n const actualSchema = (jsonSchema as any).definitions?.response || jsonSchema;\n \n schema = {\n type: \"json_schema\",\n json_schema: {\n name: \"response\",\n schema: actualSchema,\n strict: true // Try to enable strict mode for OpenAI\n }\n };\n } else if (typeof schema === 'string') {\n const schemaPath = path.resolve(finalConfig.basePath, schema);\n try {\n const schemaContent = await fs.readFile(schemaPath, 'utf-8');\n schema = JSON.parse(schemaContent);\n } catch (e: any) {\n throw new Error(`Failed to load schema from ${schemaPath}: ${e.message}`);\n }\n }\n\n // Build and return prompt\n return createPrompt({\n persona: personaSection.items.length > 0 ? personaSection : undefined,\n instructions: instructionSection,\n contents: contentSection.items.length > 0 ? contentSection : undefined,\n contexts: contextSection.items.length > 0 ? contextSection : undefined,\n constraints: constraintSection.items.length > 0 ? constraintSection : undefined,\n tone: toneSection.items.length > 0 ? toneSection : undefined,\n examples: exampleSection.items.length > 0 ? exampleSection : undefined,\n reasoning: reasoningSection.items.length > 0 ? reasoningSection : undefined,\n responseFormat: responseFormatSection.items.length > 0 ? responseFormatSection : undefined,\n recap: recapSection.items.length > 0 ? recapSection : undefined,\n safeguards: safeguardSection.items.length > 0 ? safeguardSection : undefined,\n schema,\n validator,\n });\n};\n\n// ===== CONTENT PROCESSING =====\n\ninterface ProcessingContext {\n basePath: string;\n parser: any;\n override: any;\n loader: any;\n parameters: any;\n logger: any;\n}\n\nconst processContentItem = async <T extends Weighted>(\n item: ContentItem,\n section: Section<T>,\n type: 'persona' | 'instruction' | 'content' | 'context',\n ctx: ProcessingContext\n): Promise<void> => {\n const sectionOptions: SectionOptions = {\n parameters: ctx.parameters,\n };\n\n if (typeof item === 'string') {\n // Simple string content\n const parsedSection = await ctx.parser.parse(item, sectionOptions);\n section.add(parsedSection);\n } else if ('content' in item) {\n // Inline content with options\n const parsedSection = await ctx.parser.parse(item.content, {\n ...sectionOptions,\n title: item.title,\n weight: item.weight,\n });\n section.add(parsedSection);\n } else if ('path' in item) {\n // File path\n const fullPath = path.join(ctx.basePath, item.path);\n const parsedSection = await ctx.parser.parseFile(fullPath, {\n ...sectionOptions,\n title: item.title,\n weight: item.weight,\n });\n const overrideSection = await ctx.override.customize(item.path, parsedSection, sectionOptions);\n section.add(overrideSection);\n } else if ('directories' in item) {\n // Directory loading\n const sections = await ctx.loader.load(item.directories, {\n ...sectionOptions,\n title: item.title,\n weight: item.weight,\n });\n section.add(sections);\n }\n};\n\n// ===== FLUENT RECIPE BUILDER =====\n\nexport const recipe = (basePath: string) => {\n const config: Partial<RecipeConfig> & { basePath: string } = { basePath };\n\n const builder = {\n template: (name: string) => {\n config.template = name;\n return builder;\n },\n with: (partialConfig: Partial<RecipeConfig>) => {\n Object.assign(config, partialConfig);\n return builder;\n },\n persona: (persona: ContentItem) => {\n config.persona = persona;\n return builder;\n },\n instructions: (...instructions: ContentItem[]) => {\n config.instructions = [...(config.instructions || []), ...instructions];\n return builder;\n },\n content: (...content: ContentItem[]) => {\n config.content = [...(config.content || []), ...content];\n return builder;\n },\n context: (...context: ContentItem[]) => {\n config.context = [...(config.context || []), ...context];\n return builder;\n },\n constraints: (...constraints: ContentItem[]) => {\n config.constraints = [...(config.constraints || []), ...constraints];\n return builder;\n },\n tone: (...tone: ContentItem[]) => {\n config.tone = [...(config.tone || []), ...tone];\n return builder;\n },\n examples: (...examples: ContentItem[]) => {\n config.examples = [...(config.examples || []), ...examples];\n return builder;\n },\n reasoning: (...reasoning: ContentItem[]) => {\n config.reasoning = [...(config.reasoning || []), ...reasoning];\n return builder;\n },\n responseFormat: (...responseFormat: ContentItem[]) => {\n config.responseFormat = [...(config.responseFormat || []), ...responseFormat];\n return builder;\n },\n recap: (...recap: ContentItem[]) => {\n config.recap = [...(config.recap || []), ...recap];\n return builder;\n },\n safeguards: (...safeguards: ContentItem[]) => {\n config.safeguards = [...(config.safeguards || []), ...safeguards];\n return builder;\n },\n schema: (schema: string | Record<string, any> | z.ZodType<any>) => {\n config.schema = schema;\n return builder;\n },\n parameters: (parameters: any) => {\n config.parameters = { ...config.parameters, ...parameters };\n return builder;\n },\n overrides: (enabled: boolean) => {\n config.overrides = enabled;\n return builder;\n },\n overridePaths: (paths: string[]) => {\n config.overridePaths = paths;\n return builder;\n },\n tools: (tools: Tool[] | ToolRegistry) => {\n config.tools = tools;\n return builder;\n },\n toolRegistry: (registry: ToolRegistry) => {\n config.tools = registry;\n return builder;\n },\n toolGuidance: (guidance: ToolGuidanceConfig | 'auto' | 'minimal' | 'detailed') => {\n config.toolGuidance = guidance as any;\n return builder;\n },\n toolCategories: (categories: string[]) => {\n config.toolCategories = categories;\n return builder;\n },\n cook: () => cook(config),\n buildConversation: async (model: Model, tokenBudget?: TokenBudgetConfig) => {\n const prompt = await cook(config);\n const conversation = ConversationBuilder.create({ model }, config.logger);\n conversation.fromPrompt(prompt, model);\n\n // Apply token budget if provided\n if (tokenBudget) {\n conversation.withTokenBudget(tokenBudget);\n }\n\n return conversation;\n },\n getToolRegistry: (): ToolRegistry | undefined => {\n if (config.tools instanceof ToolRegistry) {\n return config.tools;\n } else if (Array.isArray(config.tools)) {\n const registry = ToolRegistry.create({}, config.logger);\n registry.registerAll(config.tools);\n return registry;\n }\n return undefined;\n },\n executeWith: async (\n llm: LLMClient,\n strategy: IterationStrategy,\n model: Model = 'gpt-4o',\n tokenBudget?: TokenBudgetConfig\n ): Promise<StrategyResult> => {\n const prompt = await cook(config);\n const conversation = ConversationBuilder.create({ model }, config.logger);\n conversation.fromPrompt(prompt, model);\n\n if (tokenBudget) {\n conversation.withTokenBudget(tokenBudget);\n }\n\n const registry = builder.getToolRegistry();\n if (!registry) {\n throw new Error('Tools must be configured to use executeWith');\n }\n\n const executor = new StrategyExecutor(llm, config.logger);\n return executor.execute(conversation, registry, strategy);\n },\n };\n\n return builder;\n};\n\n// Export types for external use\nexport type { RecipeConfig, ContentItem };\n"],"names":["ContentItemSchema","z","union","string","object","content","title","optional","weight","number","path","directories","array","RecipeConfigSchema","basePath","logger","any","default","DEFAULT_LOGGER","overridePaths","overrides","boolean","parameters","ParametersSchema","persona","instructions","context","constraints","tone","examples","reasoning","responseFormat","recap","safeguards","schema","extends","template","tools","toolGuidance","enum","strategy","includeExamples","explainWhenToUse","includeCategories","customInstructions","toolCategories","TEMPLATES","registerTemplates","templates","getTemplates","clearTemplates","generateToolGuidance","guidance","length","config","output","categorized","Map","forEach","tool","category","has","set","get","push","categoryTools","formatToolGuidance","name","cost","description","required","paramList","Object","entries","properties","map","param","isRequired","includes","join","example","scenario","JSON","stringify","params","cook","validatedConfig","parse","finalConfig","wrapLogger","parser","Parser","override","Override","configDirs","loader","Loader","personaSection","createSection","instructionSection","contentSection","contextSection","constraintSection","toneSection","exampleSection","reasoningSection","responseFormatSection","recapSection","safeguardSection","processList","items","section","type","item","processContentItem","Array","isArray","getAll","filteredTools","filter","toolSection","add","validator","undefined","ZodType","jsonSchema","zodToJsonSchema","actualSchema","definitions","response","json_schema","strict","schemaPath","resolve","schemaContent","fs","readFile","e","Error","message","createPrompt","contents","contexts","ctx","sectionOptions","parsedSection","fullPath","parseFile","overrideSection","customize","sections","load","recipe","builder","with","partialConfig","assign","enabled","paths","toolRegistry","registry","categories","buildConversation","model","tokenBudget","prompt","conversation","ConversationBuilder","create","fromPrompt","withTokenBudget","getToolRegistry","ToolRegistry","registerAll","executeWith","llm","executor","StrategyExecutor","execute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAcA;AAEA,MAAMA,iBAAAA,GAAoBC,CAAAA,CAAEC,KAAK,CAAC;AAC9BD,IAAAA,CAAAA,CAAEE,MAAM,EAAA;AACRF,IAAAA,CAAAA,CAAEG,MAAM,CAAC;AACLC,QAAAA,OAAAA,EAASJ,EAAEE,MAAM,EAAA;QACjBG,KAAAA,EAAOL,CAAAA,CAAEE,MAAM,EAAA,CAAGI,QAAQ,EAAA;QAC1BC,MAAAA,EAAQP,CAAAA,CAAEQ,MAAM,EAAA,CAAGF,QAAQ;AAC/B,KAAA,CAAA;AACAN,IAAAA,CAAAA,CAAEG,MAAM,CAAC;AACLM,QAAAA,IAAAA,EAAMT,EAAEE,MAAM,EAAA;QACdG,KAAAA,EAAOL,CAAAA,CAAEE,MAAM,EAAA,CAAGI,QAAQ,EAAA;QAC1BC,MAAAA,EAAQP,CAAAA,CAAEQ,MAAM,EAAA,CAAGF,QAAQ;AAC/B,KAAA,CAAA;AACAN,IAAAA,CAAAA,CAAEG,MAAM,CAAC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