cognitive-modules-cli 2.2.0 → 2.2.1

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/src/types.ts CHANGED
@@ -53,6 +53,90 @@ export type EnumStrategy = 'strict' | 'extensible';
53
53
  /** Risk aggregation rule */
54
54
  export type RiskRule = 'max_changes_risk' | 'max_issues_risk' | 'explicit';
55
55
 
56
+ // =============================================================================
57
+ // Composition Types (v2.2)
58
+ // =============================================================================
59
+
60
+ /** Composition pattern types */
61
+ export type CompositionPattern = 'sequential' | 'parallel' | 'conditional' | 'iterative';
62
+
63
+ /** Aggregation strategy for combining multiple outputs */
64
+ export type AggregationStrategy = 'merge' | 'array' | 'first' | 'custom';
65
+
66
+ /** Semver-like version matching pattern */
67
+ export type VersionPattern = string; // e.g., ">=1.0.0", "^1.0.0", "~1.0.0", "*"
68
+
69
+ /** Dependency declaration for composition.requires */
70
+ export interface DependencyDeclaration {
71
+ /** Module name */
72
+ name: string;
73
+ /** Semver version pattern */
74
+ version?: VersionPattern;
75
+ /** Whether dependency is optional */
76
+ optional?: boolean;
77
+ /** Fallback module if unavailable */
78
+ fallback?: string | null;
79
+ /** Per-module timeout (ms) */
80
+ timeout_ms?: number;
81
+ }
82
+
83
+ /** Dataflow mapping expression */
84
+ export interface DataflowMapping {
85
+ [key: string]: string; // target_field: "$.source.path"
86
+ }
87
+
88
+ /** Dataflow step configuration */
89
+ export interface DataflowStep {
90
+ /** Source of data: 'input' or 'module-name.output' */
91
+ from: string | string[];
92
+ /** Destination: module name or 'output' */
93
+ to: string | string[];
94
+ /** Field mapping expressions */
95
+ mapping?: DataflowMapping;
96
+ /** Condition for execution */
97
+ condition?: string;
98
+ /** Aggregation strategy when from is an array */
99
+ aggregate?: AggregationStrategy;
100
+ /** Custom aggregation function name */
101
+ aggregator?: string;
102
+ }
103
+
104
+ /** Conditional routing rule */
105
+ export interface RoutingRule {
106
+ /** Condition expression */
107
+ condition: string;
108
+ /** Next module to execute (null means use current result) */
109
+ next: string | null;
110
+ }
111
+
112
+ /** Iteration configuration */
113
+ export interface IterationConfig {
114
+ /** Maximum iterations */
115
+ max_iterations?: number;
116
+ /** Condition to continue iterating */
117
+ continue_condition?: string;
118
+ /** Condition to stop iterating */
119
+ stop_condition?: string;
120
+ }
121
+
122
+ /** Full composition configuration (from module.yaml) */
123
+ export interface CompositionConfig {
124
+ /** Composition pattern */
125
+ pattern: CompositionPattern;
126
+ /** Required dependencies */
127
+ requires?: DependencyDeclaration[];
128
+ /** Dataflow configuration */
129
+ dataflow?: DataflowStep[];
130
+ /** Conditional routing rules */
131
+ routing?: RoutingRule[];
132
+ /** Maximum composition depth */
133
+ max_depth?: number;
134
+ /** Total timeout for composition (ms) */
135
+ timeout_ms?: number;
136
+ /** Iteration configuration */
137
+ iteration?: IterationConfig;
138
+ }
139
+
56
140
  // =============================================================================
57
141
  // Module Configuration (v2.2)
58
142
  // =============================================================================
@@ -100,6 +184,9 @@ export interface CognitiveModule {
100
184
  // v2.2: Meta configuration (including risk_rule)
101
185
  metaConfig?: MetaConfig;
102
186
 
187
+ // v2.2: Composition configuration
188
+ composition?: CompositionConfig;
189
+
103
190
  // Execution context
104
191
  context?: 'fork' | 'main';
105
192
 
@@ -223,9 +310,30 @@ export interface EnvelopeMeta {
223
310
  latency_ms?: number;
224
311
  }
225
312
 
313
+ /**
314
+ * Enhanced error structure with retry and recovery info (v2.2.1).
315
+ */
316
+ export interface EnvelopeError {
317
+ /** Error code (e.g., "INVALID_INPUT", "PARSE_ERROR") */
318
+ code: string;
319
+
320
+ /** Human-readable error message */
321
+ message: string;
322
+
323
+ /** Whether the error can be retried */
324
+ recoverable?: boolean;
325
+
326
+ /** Suggested wait time before retry (in milliseconds) */
327
+ retry_after_ms?: number;
328
+
329
+ /** Additional error context */
330
+ details?: Record<string, unknown>;
331
+ }
332
+
226
333
  /** Success response in v2.2 envelope format */
227
334
  export interface EnvelopeSuccessV22<T = unknown> {
228
335
  ok: true;
336
+ version?: string; // Envelope version (e.g., "2.2")
229
337
  meta: EnvelopeMeta;
230
338
  data: T;
231
339
  }
@@ -233,11 +341,9 @@ export interface EnvelopeSuccessV22<T = unknown> {
233
341
  /** Error response in v2.2 envelope format */
234
342
  export interface EnvelopeErrorV22 {
235
343
  ok: false;
344
+ version?: string; // Envelope version (e.g., "2.2")
236
345
  meta: EnvelopeMeta;
237
- error: {
238
- code: string;
239
- message: string;
240
- };
346
+ error: EnvelopeError;
241
347
  partial_data?: unknown;
242
348
  }
243
349
 
@@ -318,12 +424,10 @@ export interface ModuleResultData {
318
424
  /** v2.2 module result with meta and data separation */
319
425
  export interface ModuleResultV22 {
320
426
  ok: boolean;
427
+ version?: string; // Envelope version (e.g., "2.2")
321
428
  meta: EnvelopeMeta;
322
429
  data?: ModuleResultData;
323
- error?: {
324
- code: string;
325
- message: string;
326
- };
430
+ error?: EnvelopeError;
327
431
  partial_data?: unknown;
328
432
  raw?: string;
329
433
  }
package/tsconfig.json CHANGED
@@ -13,5 +13,5 @@
13
13
  "resolveJsonModule": true
14
14
  },
15
15
  "include": ["src/**/*"],
16
- "exclude": ["node_modules", "dist"]
16
+ "exclude": ["node_modules", "dist", "**/*.test.ts"]
17
17
  }