universal-agent-memory 1.0.17 → 1.0.18

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.
@@ -0,0 +1,370 @@
1
+ /**
2
+ * Multi-Model Architecture Types
3
+ *
4
+ * Defines types for the two-tier agentic architecture:
5
+ * - Tier 1 (Planner): High-level reasoning and task decomposition
6
+ * - Tier 2 (Executor): Concrete implementation following planner specs
7
+ */
8
+ import { z } from 'zod';
9
+ export type ModelProvider = 'anthropic' | 'deepseek' | 'openai' | 'zhipu' | 'ollama' | 'custom';
10
+ export type ModelRole = 'planner' | 'executor' | 'reviewer' | 'fallback';
11
+ export type TaskComplexity = 'low' | 'medium' | 'high' | 'critical';
12
+ /**
13
+ * Model configuration for a specific provider/model combination
14
+ */
15
+ export declare const ModelConfigSchemaModels: z.ZodObject<{
16
+ id: z.ZodString;
17
+ name: z.ZodString;
18
+ provider: z.ZodEnum<["anthropic", "deepseek", "openai", "zhipu", "ollama", "custom"]>;
19
+ apiModel: z.ZodString;
20
+ endpoint: z.ZodOptional<z.ZodString>;
21
+ apiKeyEnvVar: z.ZodOptional<z.ZodString>;
22
+ maxContextTokens: z.ZodDefault<z.ZodNumber>;
23
+ costPer1MInput: z.ZodOptional<z.ZodNumber>;
24
+ costPer1MOutput: z.ZodOptional<z.ZodNumber>;
25
+ capabilities: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
26
+ }, "strip", z.ZodTypeAny, {
27
+ provider: "custom" | "anthropic" | "deepseek" | "openai" | "zhipu" | "ollama";
28
+ name: string;
29
+ maxContextTokens: number;
30
+ id: string;
31
+ apiModel: string;
32
+ capabilities: string[];
33
+ endpoint?: string | undefined;
34
+ apiKeyEnvVar?: string | undefined;
35
+ costPer1MInput?: number | undefined;
36
+ costPer1MOutput?: number | undefined;
37
+ }, {
38
+ provider: "custom" | "anthropic" | "deepseek" | "openai" | "zhipu" | "ollama";
39
+ name: string;
40
+ id: string;
41
+ apiModel: string;
42
+ endpoint?: string | undefined;
43
+ maxContextTokens?: number | undefined;
44
+ apiKeyEnvVar?: string | undefined;
45
+ costPer1MInput?: number | undefined;
46
+ costPer1MOutput?: number | undefined;
47
+ capabilities?: string[] | undefined;
48
+ }>;
49
+ export type ModelConfig = z.infer<typeof ModelConfigSchemaModels>;
50
+ /**
51
+ * Pre-defined model presets for common configurations
52
+ */
53
+ export declare const ModelPresets: Record<string, ModelConfig>;
54
+ export type ModelPresetId = keyof typeof ModelPresets;
55
+ /**
56
+ * Role assignment configuration - maps roles to models
57
+ */
58
+ export declare const RoleAssignmentSchema: z.ZodObject<{
59
+ role: z.ZodEnum<["planner", "executor", "reviewer", "fallback"]>;
60
+ modelId: z.ZodString;
61
+ maxTokensPerRequest: z.ZodOptional<z.ZodNumber>;
62
+ timeout: z.ZodDefault<z.ZodNumber>;
63
+ }, "strip", z.ZodTypeAny, {
64
+ role: "planner" | "executor" | "reviewer" | "fallback";
65
+ modelId: string;
66
+ timeout: number;
67
+ maxTokensPerRequest?: number | undefined;
68
+ }, {
69
+ role: "planner" | "executor" | "reviewer" | "fallback";
70
+ modelId: string;
71
+ maxTokensPerRequest?: number | undefined;
72
+ timeout?: number | undefined;
73
+ }>;
74
+ export type RoleAssignment = z.infer<typeof RoleAssignmentSchema>;
75
+ /**
76
+ * Routing rule for task-to-model mapping
77
+ */
78
+ export declare const RoutingRuleSchema: z.ZodObject<{
79
+ complexity: z.ZodOptional<z.ZodEnum<["low", "medium", "high", "critical"]>>;
80
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
81
+ taskType: z.ZodOptional<z.ZodEnum<["planning", "coding", "refactoring", "bug-fix", "review", "documentation"]>>;
82
+ targetRole: z.ZodEnum<["planner", "executor", "reviewer", "fallback"]>;
83
+ priority: z.ZodDefault<z.ZodNumber>;
84
+ }, "strip", z.ZodTypeAny, {
85
+ targetRole: "planner" | "executor" | "reviewer" | "fallback";
86
+ priority: number;
87
+ complexity?: "low" | "medium" | "high" | "critical" | undefined;
88
+ keywords?: string[] | undefined;
89
+ taskType?: "planning" | "coding" | "refactoring" | "bug-fix" | "review" | "documentation" | undefined;
90
+ }, {
91
+ targetRole: "planner" | "executor" | "reviewer" | "fallback";
92
+ complexity?: "low" | "medium" | "high" | "critical" | undefined;
93
+ keywords?: string[] | undefined;
94
+ taskType?: "planning" | "coding" | "refactoring" | "bug-fix" | "review" | "documentation" | undefined;
95
+ priority?: number | undefined;
96
+ }>;
97
+ export type RoutingRule = z.infer<typeof RoutingRuleSchema>;
98
+ /**
99
+ * Multi-Model Architecture configuration schema for .uam.json
100
+ */
101
+ export declare const MultiModelConfigSchema: z.ZodObject<{
102
+ enabled: z.ZodDefault<z.ZodBoolean>;
103
+ models: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
104
+ id: z.ZodString;
105
+ name: z.ZodString;
106
+ provider: z.ZodEnum<["anthropic", "deepseek", "openai", "zhipu", "ollama", "custom"]>;
107
+ apiModel: z.ZodString;
108
+ endpoint: z.ZodOptional<z.ZodString>;
109
+ apiKeyEnvVar: z.ZodOptional<z.ZodString>;
110
+ maxContextTokens: z.ZodDefault<z.ZodNumber>;
111
+ costPer1MInput: z.ZodOptional<z.ZodNumber>;
112
+ costPer1MOutput: z.ZodOptional<z.ZodNumber>;
113
+ capabilities: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
114
+ }, "strip", z.ZodTypeAny, {
115
+ provider: "custom" | "anthropic" | "deepseek" | "openai" | "zhipu" | "ollama";
116
+ name: string;
117
+ maxContextTokens: number;
118
+ id: string;
119
+ apiModel: string;
120
+ capabilities: string[];
121
+ endpoint?: string | undefined;
122
+ apiKeyEnvVar?: string | undefined;
123
+ costPer1MInput?: number | undefined;
124
+ costPer1MOutput?: number | undefined;
125
+ }, {
126
+ provider: "custom" | "anthropic" | "deepseek" | "openai" | "zhipu" | "ollama";
127
+ name: string;
128
+ id: string;
129
+ apiModel: string;
130
+ endpoint?: string | undefined;
131
+ maxContextTokens?: number | undefined;
132
+ apiKeyEnvVar?: string | undefined;
133
+ costPer1MInput?: number | undefined;
134
+ costPer1MOutput?: number | undefined;
135
+ capabilities?: string[] | undefined;
136
+ }>]>, "many">>;
137
+ roles: z.ZodOptional<z.ZodObject<{
138
+ planner: z.ZodDefault<z.ZodString>;
139
+ executor: z.ZodDefault<z.ZodString>;
140
+ reviewer: z.ZodOptional<z.ZodString>;
141
+ fallback: z.ZodDefault<z.ZodString>;
142
+ }, "strip", z.ZodTypeAny, {
143
+ planner: string;
144
+ executor: string;
145
+ fallback: string;
146
+ reviewer?: string | undefined;
147
+ }, {
148
+ planner?: string | undefined;
149
+ executor?: string | undefined;
150
+ reviewer?: string | undefined;
151
+ fallback?: string | undefined;
152
+ }>>;
153
+ routing: z.ZodOptional<z.ZodArray<z.ZodObject<{
154
+ complexity: z.ZodOptional<z.ZodEnum<["low", "medium", "high", "critical"]>>;
155
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
156
+ taskType: z.ZodOptional<z.ZodEnum<["planning", "coding", "refactoring", "bug-fix", "review", "documentation"]>>;
157
+ targetRole: z.ZodEnum<["planner", "executor", "reviewer", "fallback"]>;
158
+ priority: z.ZodDefault<z.ZodNumber>;
159
+ }, "strip", z.ZodTypeAny, {
160
+ targetRole: "planner" | "executor" | "reviewer" | "fallback";
161
+ priority: number;
162
+ complexity?: "low" | "medium" | "high" | "critical" | undefined;
163
+ keywords?: string[] | undefined;
164
+ taskType?: "planning" | "coding" | "refactoring" | "bug-fix" | "review" | "documentation" | undefined;
165
+ }, {
166
+ targetRole: "planner" | "executor" | "reviewer" | "fallback";
167
+ complexity?: "low" | "medium" | "high" | "critical" | undefined;
168
+ keywords?: string[] | undefined;
169
+ taskType?: "planning" | "coding" | "refactoring" | "bug-fix" | "review" | "documentation" | undefined;
170
+ priority?: number | undefined;
171
+ }>, "many">>;
172
+ costOptimization: z.ZodOptional<z.ZodObject<{
173
+ enabled: z.ZodDefault<z.ZodBoolean>;
174
+ targetReduction: z.ZodDefault<z.ZodNumber>;
175
+ maxPerformanceDegradation: z.ZodDefault<z.ZodNumber>;
176
+ fallbackThreshold: z.ZodDefault<z.ZodNumber>;
177
+ }, "strip", z.ZodTypeAny, {
178
+ enabled: boolean;
179
+ targetReduction: number;
180
+ maxPerformanceDegradation: number;
181
+ fallbackThreshold: number;
182
+ }, {
183
+ enabled?: boolean | undefined;
184
+ targetReduction?: number | undefined;
185
+ maxPerformanceDegradation?: number | undefined;
186
+ fallbackThreshold?: number | undefined;
187
+ }>>;
188
+ routingStrategy: z.ZodDefault<z.ZodEnum<["cost-optimized", "performance-first", "balanced", "adaptive"]>>;
189
+ plannerSettings: z.ZodOptional<z.ZodObject<{
190
+ complexityThreshold: z.ZodDefault<z.ZodEnum<["low", "medium", "high"]>>;
191
+ maxPlanningTokens: z.ZodDefault<z.ZodNumber>;
192
+ enableDecomposition: z.ZodDefault<z.ZodBoolean>;
193
+ }, "strip", z.ZodTypeAny, {
194
+ complexityThreshold: "low" | "medium" | "high";
195
+ maxPlanningTokens: number;
196
+ enableDecomposition: boolean;
197
+ }, {
198
+ complexityThreshold?: "low" | "medium" | "high" | undefined;
199
+ maxPlanningTokens?: number | undefined;
200
+ enableDecomposition?: boolean | undefined;
201
+ }>>;
202
+ executorSettings: z.ZodOptional<z.ZodObject<{
203
+ retryWithFallback: z.ZodDefault<z.ZodBoolean>;
204
+ maxRetries: z.ZodDefault<z.ZodNumber>;
205
+ stepTimeout: z.ZodDefault<z.ZodNumber>;
206
+ }, "strip", z.ZodTypeAny, {
207
+ retryWithFallback: boolean;
208
+ maxRetries: number;
209
+ stepTimeout: number;
210
+ }, {
211
+ retryWithFallback?: boolean | undefined;
212
+ maxRetries?: number | undefined;
213
+ stepTimeout?: number | undefined;
214
+ }>>;
215
+ }, "strip", z.ZodTypeAny, {
216
+ enabled: boolean;
217
+ models: (string | {
218
+ provider: "custom" | "anthropic" | "deepseek" | "openai" | "zhipu" | "ollama";
219
+ name: string;
220
+ maxContextTokens: number;
221
+ id: string;
222
+ apiModel: string;
223
+ capabilities: string[];
224
+ endpoint?: string | undefined;
225
+ apiKeyEnvVar?: string | undefined;
226
+ costPer1MInput?: number | undefined;
227
+ costPer1MOutput?: number | undefined;
228
+ })[];
229
+ routingStrategy: "cost-optimized" | "performance-first" | "balanced" | "adaptive";
230
+ roles?: {
231
+ planner: string;
232
+ executor: string;
233
+ fallback: string;
234
+ reviewer?: string | undefined;
235
+ } | undefined;
236
+ routing?: {
237
+ targetRole: "planner" | "executor" | "reviewer" | "fallback";
238
+ priority: number;
239
+ complexity?: "low" | "medium" | "high" | "critical" | undefined;
240
+ keywords?: string[] | undefined;
241
+ taskType?: "planning" | "coding" | "refactoring" | "bug-fix" | "review" | "documentation" | undefined;
242
+ }[] | undefined;
243
+ costOptimization?: {
244
+ enabled: boolean;
245
+ targetReduction: number;
246
+ maxPerformanceDegradation: number;
247
+ fallbackThreshold: number;
248
+ } | undefined;
249
+ plannerSettings?: {
250
+ complexityThreshold: "low" | "medium" | "high";
251
+ maxPlanningTokens: number;
252
+ enableDecomposition: boolean;
253
+ } | undefined;
254
+ executorSettings?: {
255
+ retryWithFallback: boolean;
256
+ maxRetries: number;
257
+ stepTimeout: number;
258
+ } | undefined;
259
+ }, {
260
+ enabled?: boolean | undefined;
261
+ models?: (string | {
262
+ provider: "custom" | "anthropic" | "deepseek" | "openai" | "zhipu" | "ollama";
263
+ name: string;
264
+ id: string;
265
+ apiModel: string;
266
+ endpoint?: string | undefined;
267
+ maxContextTokens?: number | undefined;
268
+ apiKeyEnvVar?: string | undefined;
269
+ costPer1MInput?: number | undefined;
270
+ costPer1MOutput?: number | undefined;
271
+ capabilities?: string[] | undefined;
272
+ })[] | undefined;
273
+ roles?: {
274
+ planner?: string | undefined;
275
+ executor?: string | undefined;
276
+ reviewer?: string | undefined;
277
+ fallback?: string | undefined;
278
+ } | undefined;
279
+ routing?: {
280
+ targetRole: "planner" | "executor" | "reviewer" | "fallback";
281
+ complexity?: "low" | "medium" | "high" | "critical" | undefined;
282
+ keywords?: string[] | undefined;
283
+ taskType?: "planning" | "coding" | "refactoring" | "bug-fix" | "review" | "documentation" | undefined;
284
+ priority?: number | undefined;
285
+ }[] | undefined;
286
+ routingStrategy?: "cost-optimized" | "performance-first" | "balanced" | "adaptive" | undefined;
287
+ costOptimization?: {
288
+ enabled?: boolean | undefined;
289
+ targetReduction?: number | undefined;
290
+ maxPerformanceDegradation?: number | undefined;
291
+ fallbackThreshold?: number | undefined;
292
+ } | undefined;
293
+ plannerSettings?: {
294
+ complexityThreshold?: "low" | "medium" | "high" | undefined;
295
+ maxPlanningTokens?: number | undefined;
296
+ enableDecomposition?: boolean | undefined;
297
+ } | undefined;
298
+ executorSettings?: {
299
+ retryWithFallback?: boolean | undefined;
300
+ maxRetries?: number | undefined;
301
+ stepTimeout?: number | undefined;
302
+ } | undefined;
303
+ }>;
304
+ export type MultiModelConfig = z.infer<typeof MultiModelConfigSchema>;
305
+ /**
306
+ * Task classification result from the router
307
+ */
308
+ export interface TaskClassificationResult {
309
+ complexity: TaskComplexity;
310
+ taskType: 'planning' | 'coding' | 'refactoring' | 'bug-fix' | 'review' | 'documentation';
311
+ keywords: string[];
312
+ estimatedTokens: number;
313
+ requiresPlanning: boolean;
314
+ suggestedModel: string;
315
+ fallbackModel: string;
316
+ reasoning: string;
317
+ }
318
+ /**
319
+ * Execution plan from the planner
320
+ */
321
+ export interface ExecutionPlan {
322
+ id: string;
323
+ originalTask: string;
324
+ subtasks: Subtask[];
325
+ dependencies: Map<string, string[]>;
326
+ modelAssignments: Map<string, string>;
327
+ estimatedCost: number;
328
+ estimatedDuration: number;
329
+ created: Date;
330
+ }
331
+ export interface Subtask {
332
+ id: string;
333
+ title: string;
334
+ description: string;
335
+ type: 'planning' | 'coding' | 'refactoring' | 'bug-fix' | 'review' | 'documentation';
336
+ complexity: TaskComplexity;
337
+ inputs: string[];
338
+ outputs: string[];
339
+ constraints: string[];
340
+ }
341
+ /**
342
+ * Execution result for tracking
343
+ */
344
+ export interface ExecutionResult {
345
+ planId: string;
346
+ subtaskId: string;
347
+ modelUsed: string;
348
+ success: boolean;
349
+ output: string;
350
+ error?: string;
351
+ tokensUsed: {
352
+ input: number;
353
+ output: number;
354
+ };
355
+ cost: number;
356
+ duration: number;
357
+ retryCount: number;
358
+ }
359
+ /**
360
+ * Model selection result from the router
361
+ */
362
+ export interface ModelSelection {
363
+ model: ModelConfig;
364
+ fallback?: ModelConfig;
365
+ role: ModelRole;
366
+ reasoning: string;
367
+ estimatedCost: number;
368
+ }
369
+ export declare const DEFAULT_ROUTING_RULES: RoutingRule[];
370
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/models/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAGhG,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;AAGzE,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWlC,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAwDpD,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,YAAY,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;EAM/B,CAAC;AAEH,MAAM,M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a,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,IAAI,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,eAAe,CAAC;IACrF,UAAU,EAAE,cAAc,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAGD,eAAO,MAAM,qBAAqB,EAAE,WAAW,EAqB9C,CAAC"}
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Multi-Model Architecture Types
3
+ *
4
+ * Defines types for the two-tier agentic architecture:
5
+ * - Tier 1 (Planner): High-level reasoning and task decomposition
6
+ * - Tier 2 (Executor): Concrete implementation following planner specs
7
+ */
8
+ import { z } from 'zod';
9
+ /**
10
+ * Model configuration for a specific provider/model combination
11
+ */
12
+ export const ModelConfigSchemaModels = z.object({
13
+ id: z.string(),
14
+ name: z.string(),
15
+ provider: z.enum(['anthropic', 'deepseek', 'openai', 'zhipu', 'ollama', 'custom']),
16
+ apiModel: z.string(),
17
+ endpoint: z.string().optional(),
18
+ apiKeyEnvVar: z.string().optional(),
19
+ maxContextTokens: z.number().default(128000),
20
+ costPer1MInput: z.number().optional(),
21
+ costPer1MOutput: z.number().optional(),
22
+ capabilities: z.array(z.string()).default([]),
23
+ });
24
+ /**
25
+ * Pre-defined model presets for common configurations
26
+ */
27
+ export const ModelPresets = {
28
+ 'opus-4.5': {
29
+ id: 'opus-4.5',
30
+ name: 'Claude Opus 4.5',
31
+ provider: 'anthropic',
32
+ apiModel: 'claude-opus-4-5-20251101',
33
+ apiKeyEnvVar: 'ANTHROPIC_API_KEY',
34
+ maxContextTokens: 200000,
35
+ costPer1MInput: 5.0,
36
+ costPer1MOutput: 25.0,
37
+ capabilities: ['planning', 'complex-reasoning', 'code-generation', 'review'],
38
+ },
39
+ 'deepseek-v3.2': {
40
+ id: 'deepseek-v3.2',
41
+ name: 'DeepSeek V3.2 Speciale',
42
+ provider: 'deepseek',
43
+ apiModel: 'deepseek-chat',
44
+ apiKeyEnvVar: 'DEEPSEEK_API_KEY',
45
+ maxContextTokens: 164000,
46
+ costPer1MInput: 0.25,
47
+ costPer1MOutput: 0.38,
48
+ capabilities: ['planning', 'code-generation', 'complex-reasoning'],
49
+ },
50
+ 'deepseek-v3.2-exp': {
51
+ id: 'deepseek-v3.2-exp',
52
+ name: 'DeepSeek V3.2 Experimental',
53
+ provider: 'deepseek',
54
+ apiModel: 'deepseek-coder',
55
+ apiKeyEnvVar: 'DEEPSEEK_API_KEY',
56
+ maxContextTokens: 164000,
57
+ costPer1MInput: 0.21,
58
+ costPer1MOutput: 0.32,
59
+ capabilities: ['code-generation', 'execution'],
60
+ },
61
+ 'glm-4.7': {
62
+ id: 'glm-4.7',
63
+ name: 'GLM 4.7',
64
+ provider: 'zhipu',
65
+ apiModel: 'glm-4.7',
66
+ apiKeyEnvVar: 'ZHIPU_API_KEY',
67
+ maxContextTokens: 128000,
68
+ costPer1MInput: 1.0,
69
+ costPer1MOutput: 2.0,
70
+ capabilities: ['code-generation', 'execution', 'simple-tasks'],
71
+ },
72
+ 'gpt-5.2': {
73
+ id: 'gpt-5.2',
74
+ name: 'GPT 5.2',
75
+ provider: 'openai',
76
+ apiModel: 'gpt-5.2',
77
+ apiKeyEnvVar: 'OPENAI_API_KEY',
78
+ maxContextTokens: 128000,
79
+ costPer1MInput: 2.5,
80
+ costPer1MOutput: 10.0,
81
+ capabilities: ['planning', 'code-generation', 'complex-reasoning'],
82
+ },
83
+ };
84
+ /**
85
+ * Role assignment configuration - maps roles to models
86
+ */
87
+ export const RoleAssignmentSchema = z.object({
88
+ role: z.enum(['planner', 'executor', 'reviewer', 'fallback']),
89
+ modelId: z.string(),
90
+ // Optional constraints for this role
91
+ maxTokensPerRequest: z.number().optional(),
92
+ timeout: z.number().default(300000), // 5 min default
93
+ });
94
+ /**
95
+ * Routing rule for task-to-model mapping
96
+ */
97
+ export const RoutingRuleSchema = z.object({
98
+ // Condition matching
99
+ complexity: z.enum(['low', 'medium', 'high', 'critical']).optional(),
100
+ keywords: z.array(z.string()).optional(),
101
+ taskType: z.enum(['planning', 'coding', 'refactoring', 'bug-fix', 'review', 'documentation']).optional(),
102
+ // Target model
103
+ targetRole: z.enum(['planner', 'executor', 'reviewer', 'fallback']),
104
+ // Priority (higher = evaluated first)
105
+ priority: z.number().default(0),
106
+ });
107
+ /**
108
+ * Multi-Model Architecture configuration schema for .uam.json
109
+ */
110
+ export const MultiModelConfigSchema = z.object({
111
+ enabled: z.boolean().default(false),
112
+ // Model definitions (can use presets or custom)
113
+ models: z.array(z.union([
114
+ z.string(), // Preset ID like 'opus-4.5'
115
+ ModelConfigSchemaModels, // Full custom config
116
+ ])).default(['opus-4.5']),
117
+ // Role assignments
118
+ roles: z.object({
119
+ planner: z.string().default('opus-4.5'),
120
+ executor: z.string().default('glm-4.7'),
121
+ reviewer: z.string().optional(),
122
+ fallback: z.string().default('opus-4.5'),
123
+ }).optional(),
124
+ // Routing rules (optional - uses defaults if not specified)
125
+ routing: z.array(RoutingRuleSchema).optional(),
126
+ // Cost optimization settings
127
+ costOptimization: z.object({
128
+ enabled: z.boolean().default(true),
129
+ // Target cost reduction percentage
130
+ targetReduction: z.number().default(90),
131
+ // Max performance degradation allowed
132
+ maxPerformanceDegradation: z.number().default(20),
133
+ // Auto-fallback threshold (failures before escalating)
134
+ fallbackThreshold: z.number().default(3),
135
+ }).optional(),
136
+ // Routing behavior
137
+ routingStrategy: z.enum([
138
+ 'cost-optimized', // Minimize cost, use cheapest capable model
139
+ 'performance-first', // Maximize quality, use best model
140
+ 'balanced', // Balance cost and performance
141
+ 'adaptive', // Learn from task results
142
+ ]).default('balanced'),
143
+ // Planner-specific settings
144
+ plannerSettings: z.object({
145
+ // When to invoke planner vs direct execution
146
+ complexityThreshold: z.enum(['low', 'medium', 'high']).default('medium'),
147
+ // Max tokens for planning phase
148
+ maxPlanningTokens: z.number().default(10000),
149
+ // Decompose tasks into subtasks
150
+ enableDecomposition: z.boolean().default(true),
151
+ }).optional(),
152
+ // Executor settings
153
+ executorSettings: z.object({
154
+ // Retry failed executions with fallback model
155
+ retryWithFallback: z.boolean().default(true),
156
+ // Max retries before escalating
157
+ maxRetries: z.number().default(2),
158
+ // Timeout per execution step
159
+ stepTimeout: z.number().default(120000), // 2 min
160
+ }).optional(),
161
+ });
162
+ // Default routing rules
163
+ export const DEFAULT_ROUTING_RULES = [
164
+ // Critical tasks always use planner + fallback
165
+ { complexity: 'critical', targetRole: 'planner', priority: 100 },
166
+ { keywords: ['security', 'authentication', 'deployment', 'migration'], targetRole: 'planner', priority: 90 },
167
+ // High complexity uses planner
168
+ { complexity: 'high', targetRole: 'planner', priority: 80 },
169
+ { keywords: ['architecture', 'design', 'refactor'], targetRole: 'planner', priority: 70 },
170
+ { taskType: 'planning', targetRole: 'planner', priority: 70 },
171
+ // Medium complexity can go to executor directly
172
+ { complexity: 'medium', targetRole: 'executor', priority: 50 },
173
+ { taskType: 'coding', targetRole: 'executor', priority: 50 },
174
+ { taskType: 'bug-fix', targetRole: 'executor', priority: 50 },
175
+ // Low complexity always executor
176
+ { complexity: 'low', targetRole: 'executor', priority: 30 },
177
+ { taskType: 'documentation', targetRole: 'executor', priority: 30 },
178
+ // Review tasks use reviewer or planner
179
+ { taskType: 'review', targetRole: 'reviewer', priority: 60 },
180
+ ];
181
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/models/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAClF,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IAC5C,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACrC,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAA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