@kairos-sdk/core 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -67,6 +67,7 @@ interface CredentialRequirement {
67
67
  interface BuildResult {
68
68
  workflowId: string | null;
69
69
  name: string;
70
+ workflow: N8nWorkflow;
70
71
  credentialsNeeded: CredentialRequirement[];
71
72
  activationRequired: boolean;
72
73
  generationAttempts: number;
@@ -108,10 +109,42 @@ interface ILogger {
108
109
  }
109
110
  declare const nullLogger: ILogger;
110
111
 
112
+ interface FailurePattern {
113
+ rule: number;
114
+ message: string;
115
+ occurrences: number;
116
+ }
117
+ type SourceKind = 'organic' | 'n8n-template' | 'imported';
118
+ type TrustLevel = 'safe' | 'review' | 'blocked';
111
119
  interface WorkflowMetadataInput {
112
120
  description: string;
113
121
  tags?: string[];
114
122
  platform?: string;
123
+ failurePatterns?: Array<{
124
+ rule: number;
125
+ message: string;
126
+ }>;
127
+ sourceWorkflowIds?: string[];
128
+ generationMode?: 'direct' | 'reference' | 'scratch';
129
+ topMatchScore?: number;
130
+ generationAttempts?: number;
131
+ credentialsNeeded?: CredentialRequirement[];
132
+ sourceKind?: SourceKind;
133
+ sourceId?: string;
134
+ sourceUrl?: string;
135
+ trustLevel?: TrustLevel;
136
+ }
137
+ interface OutcomeData {
138
+ attempts: number;
139
+ firstTryPass: boolean;
140
+ failedRules: number[];
141
+ mode: 'direct' | 'reference';
142
+ }
143
+ interface OutcomeStats {
144
+ totalUses: number;
145
+ totalAttempts: number;
146
+ firstTryPasses: number;
147
+ failedRules: Record<string, number>;
115
148
  }
116
149
  interface StoredWorkflow {
117
150
  id: string;
@@ -122,6 +155,20 @@ interface StoredWorkflow {
122
155
  deployCount: number;
123
156
  createdAt: string;
124
157
  lastDeployedAt?: string;
158
+ failurePatterns?: FailurePattern[];
159
+ sourceWorkflowIds?: string[];
160
+ generationMode?: 'direct' | 'reference' | 'scratch';
161
+ topMatchScore?: number;
162
+ generationAttempts?: number;
163
+ credentialsNeeded?: CredentialRequirement[];
164
+ sourceKind?: SourceKind;
165
+ sourceId?: string;
166
+ sourceUrl?: string;
167
+ trustLevel?: TrustLevel;
168
+ timesRetrieved?: number;
169
+ timesUsedAsDirect?: number;
170
+ timesUsedAsReference?: number;
171
+ outcomeStats?: OutcomeStats;
125
172
  }
126
173
  interface WorkflowMatch {
127
174
  workflow: StoredWorkflow;
@@ -141,14 +188,15 @@ interface IWorkflowLibrary {
141
188
  search(description: string, options?: SearchOptions): Promise<WorkflowMatch[]>;
142
189
  save(workflow: N8nWorkflow, metadata: WorkflowMetadataInput): Promise<string>;
143
190
  recordDeployment(id: string): Promise<void>;
191
+ recordOutcome(id: string, outcome: OutcomeData): Promise<void>;
144
192
  get(id: string): Promise<StoredWorkflow | null>;
145
193
  list(filters?: LibraryFilters): Promise<StoredWorkflow[]>;
146
194
  }
147
195
 
148
196
  interface ClientOptions {
149
197
  anthropicApiKey: string;
150
- n8nBaseUrl: string;
151
- n8nApiKey: string;
198
+ n8nBaseUrl?: string;
199
+ n8nApiKey?: string;
152
200
  model?: string;
153
201
  logger?: ILogger;
154
202
  library?: IWorkflowLibrary;
@@ -175,10 +223,18 @@ declare class Kairos {
175
223
  private readonly library;
176
224
  private readonly logger;
177
225
  private readonly telemetry;
226
+ private readonly telemetryReader;
178
227
  private readonly model;
228
+ private saveQueue;
179
229
  constructor(options: ClientOptions);
230
+ private requireProvider;
231
+ private validateDescription;
180
232
  build(description: string, options?: BuildOptions): Promise<BuildResult>;
181
- update(id: string, description: string): Promise<BuildResult>;
233
+ replace(id: string, description: string): Promise<BuildResult>;
234
+ drain(): Promise<void>;
235
+ private emitAttemptTelemetry;
236
+ private recordDeploy;
237
+ private saveToLibrary;
182
238
  get(id: string): Promise<N8nWorkflow>;
183
239
  list(): Promise<WorkflowListItem[]>;
184
240
  activate(id: string): Promise<void>;
@@ -234,6 +290,7 @@ declare class N8nApiClient {
234
290
  private readonly logger;
235
291
  constructor(baseUrl: string, apiKey: string, logger: ILogger);
236
292
  private request;
293
+ private singleRequest;
237
294
  createWorkflow(workflow: N8nWorkflow): Promise<N8nWorkflowResponse>;
238
295
  updateWorkflow(id: string, workflow: N8nWorkflow): Promise<N8nWorkflowResponse>;
239
296
  getWorkflow(id: string): Promise<N8nWorkflowResponse>;
@@ -281,25 +338,66 @@ declare class NullLibrary implements IWorkflowLibrary {
281
338
  search(_description: string, _options?: SearchOptions): Promise<WorkflowMatch[]>;
282
339
  save(_workflow: N8nWorkflow, _metadata: WorkflowMetadataInput): Promise<string>;
283
340
  recordDeployment(_id: string): Promise<void>;
341
+ recordOutcome(_id: string, _outcome: OutcomeData): Promise<void>;
284
342
  get(_id: string): Promise<StoredWorkflow | null>;
285
343
  list(_filters?: LibraryFilters): Promise<StoredWorkflow[]>;
286
344
  }
287
345
 
346
+ declare function tokenize(text: string): string[];
347
+ declare function buildSearchCorpus(w: StoredWorkflow): string;
288
348
  declare class FileLibrary implements IWorkflowLibrary {
289
349
  private readonly dir;
290
350
  private workflows;
291
- private initialized;
351
+ private initPromise;
352
+ private writeQueue;
292
353
  constructor(dir?: string);
293
354
  initialize(): Promise<void>;
355
+ private doInitialize;
294
356
  search(description: string, options?: SearchOptions): Promise<WorkflowMatch[]>;
295
357
  save(workflow: N8nWorkflow, metadata: WorkflowMetadataInput): Promise<string>;
296
358
  recordDeployment(id: string): Promise<void>;
359
+ recordOutcome(id: string, outcome: OutcomeData): Promise<void>;
360
+ drain(): Promise<void>;
297
361
  get(id: string): Promise<StoredWorkflow | null>;
298
362
  list(filters?: LibraryFilters): Promise<StoredWorkflow[]>;
363
+ private deduplicateFailurePatterns;
299
364
  private persist;
300
365
  }
301
366
 
302
- interface ValidationIssue$1 {
367
+ interface ScoredEntry {
368
+ workflow: StoredWorkflow;
369
+ score: number;
370
+ signals: {
371
+ tfidf: number;
372
+ nodeFingerprint: number;
373
+ outcome: number;
374
+ deploy: number;
375
+ };
376
+ }
377
+ declare function hybridScore(queryTokens: string[], queryDescription: string, workflows: StoredWorkflow[], docTokenArrays: string[][], idf: Map<string, number>): ScoredEntry[];
378
+
379
+ interface WorkflowCluster {
380
+ pattern: string;
381
+ fingerprint: string[];
382
+ members: StoredWorkflow[];
383
+ avgFirstTryPassRate: number;
384
+ avgAttempts: number;
385
+ commonFailedRules: Array<{
386
+ rule: number;
387
+ frequency: number;
388
+ }>;
389
+ }
390
+ declare function clusterWorkflows(workflows: StoredWorkflow[]): WorkflowCluster[];
391
+ declare function rerank(candidates: Array<{
392
+ workflow: StoredWorkflow;
393
+ score: number;
394
+ }>, clusters: WorkflowCluster[]): Array<{
395
+ workflow: StoredWorkflow;
396
+ score: number;
397
+ clusterPattern?: string;
398
+ }>;
399
+
400
+ interface ValidationIssue {
303
401
  rule: number;
304
402
  severity: 'error' | 'warn';
305
403
  message: string;
@@ -307,7 +405,7 @@ interface ValidationIssue$1 {
307
405
  }
308
406
  interface ValidationResult {
309
407
  valid: boolean;
310
- issues: ValidationIssue$1[];
408
+ issues: ValidationIssue[];
311
409
  }
312
410
 
313
411
  interface NodeDefinition {
@@ -323,7 +421,9 @@ declare class NodeRegistry {
323
421
  constructor(definitions?: NodeDefinition[]);
324
422
  get(type: string): NodeDefinition | undefined;
325
423
  isTrigger(type: string): boolean;
424
+ isKnown(type: string): boolean;
326
425
  isVersionSafe(type: string, version: number): boolean;
426
+ getRequiredParams(type: string): string[];
327
427
  }
328
428
 
329
429
  declare class N8nValidator {
@@ -352,6 +452,10 @@ declare class N8nValidator {
352
452
  private checkRule17;
353
453
  private checkRule18;
354
454
  private checkRule19;
455
+ private checkRule20;
456
+ private checkRule22;
457
+ private checkRule23;
458
+ private checkRule21;
355
459
  }
356
460
 
357
461
  declare class KairosError extends Error {
@@ -359,12 +463,6 @@ declare class KairosError extends Error {
359
463
  constructor(message: string, cause?: unknown | undefined);
360
464
  }
361
465
 
362
- interface ValidationIssue {
363
- rule: number;
364
- severity: 'error' | 'warn';
365
- message: string;
366
- nodeId?: string;
367
- }
368
466
  declare class ValidationError extends KairosError {
369
467
  readonly issues: ValidationIssue[];
370
468
  constructor(message: string, issues: ValidationIssue[]);
@@ -391,7 +489,33 @@ declare class GuardError extends KairosError {
391
489
  constructor(message: string);
392
490
  }
393
491
 
492
+ interface SyncProgress {
493
+ total: number;
494
+ processed: number;
495
+ saved: number;
496
+ skippedPaid: number;
497
+ skippedDuplicate: number;
498
+ blocked: number;
499
+ reviewed: number;
500
+ }
501
+
502
+ interface SyncOptions {
503
+ maxTemplates?: number;
504
+ onProgress?: (progress: SyncProgress) => void;
505
+ }
506
+ declare class TemplateSyncer {
507
+ private readonly library;
508
+ private readonly validator;
509
+ private readonly logger;
510
+ constructor(library: IWorkflowLibrary, logger: ILogger);
511
+ sync(options?: SyncOptions): Promise<SyncProgress>;
512
+ private fetchTemplateIds;
513
+ private processTemplate;
514
+ private cleanDescription;
515
+ }
516
+
394
517
  interface TelemetryEvent {
518
+ schemaVersion: number;
395
519
  timestamp: string;
396
520
  sessionId: string;
397
521
  eventType: 'build_start' | 'generation_attempt' | 'build_complete';
@@ -410,8 +534,25 @@ interface AttemptMetadata {
410
534
  declare class TelemetryCollector {
411
535
  private readonly dir;
412
536
  readonly sessionId: string;
537
+ private dirReady;
413
538
  constructor(dir?: string);
414
539
  emit(eventType: TelemetryEvent['eventType'], data: Record<string, unknown>): Promise<void>;
415
540
  }
416
541
 
417
- export { ApiError, type AttemptMetadata, type BuildOptions, type BuildResult, type ClientOptions, type CredentialRequirement, DEFAULT_REGISTRY, type DeleteOptions, type DeployResult, type ExecutionDetail, type ExecutionFilter, type ExecutionSummary, FileLibrary, GenerationError, GuardError, type ILogger, type IProvider, type IWorkflowLibrary, Kairos, KairosError, N8nApiClient, type N8nConnections, N8nFieldStripper, type N8nNode, N8nProvider, type N8nSettings, N8nValidator, type N8nWorkflow, NodeRegistry, NullLibrary, ProviderError, ResponseParseError, type StoredWorkflow, type Tag, TelemetryCollector, type TelemetryEvent, ValidationError, type ValidationIssue, type ValidationResult, type WorkflowListItem, type WorkflowMatch, nullLogger };
542
+ interface RuleFailureRate {
543
+ rule: number;
544
+ failureCount: number;
545
+ totalBuilds: number;
546
+ rate: number;
547
+ commonMessage: string;
548
+ }
549
+ declare class TelemetryReader {
550
+ private readonly dir;
551
+ private cache;
552
+ private cacheTime;
553
+ constructor(dir?: string);
554
+ getFailureRates(days?: number): Promise<RuleFailureRate[]>;
555
+ private readRecentEvents;
556
+ }
557
+
558
+ export { ApiError, type AttemptMetadata, type BuildOptions, type BuildResult, type ClientOptions, type CredentialRequirement, DEFAULT_REGISTRY, type DeleteOptions, type DeployResult, type ExecutionDetail, type ExecutionFilter, type ExecutionSummary, type FailurePattern, FileLibrary, GenerationError, GuardError, type ILogger, type IProvider, type IWorkflowLibrary, Kairos, KairosError, N8nApiClient, type N8nConnections, N8nFieldStripper, type N8nNode, N8nProvider, type N8nSettings, N8nValidator, type N8nWorkflow, NodeRegistry, NullLibrary, type OutcomeData, type OutcomeStats, ProviderError, ResponseParseError, type RuleFailureRate, type ScoredEntry, type SourceKind, type StoredWorkflow, type SyncProgress, type Tag, TelemetryCollector, type TelemetryEvent, TelemetryReader, TemplateSyncer, type TrustLevel, ValidationError, type ValidationIssue, type ValidationResult, type WorkflowCluster, type WorkflowListItem, type WorkflowMatch, type WorkflowMetadataInput, buildSearchCorpus, clusterWorkflows, hybridScore, nullLogger, rerank, tokenize };
package/dist/index.d.ts CHANGED
@@ -67,6 +67,7 @@ interface CredentialRequirement {
67
67
  interface BuildResult {
68
68
  workflowId: string | null;
69
69
  name: string;
70
+ workflow: N8nWorkflow;
70
71
  credentialsNeeded: CredentialRequirement[];
71
72
  activationRequired: boolean;
72
73
  generationAttempts: number;
@@ -108,10 +109,42 @@ interface ILogger {
108
109
  }
109
110
  declare const nullLogger: ILogger;
110
111
 
112
+ interface FailurePattern {
113
+ rule: number;
114
+ message: string;
115
+ occurrences: number;
116
+ }
117
+ type SourceKind = 'organic' | 'n8n-template' | 'imported';
118
+ type TrustLevel = 'safe' | 'review' | 'blocked';
111
119
  interface WorkflowMetadataInput {
112
120
  description: string;
113
121
  tags?: string[];
114
122
  platform?: string;
123
+ failurePatterns?: Array<{
124
+ rule: number;
125
+ message: string;
126
+ }>;
127
+ sourceWorkflowIds?: string[];
128
+ generationMode?: 'direct' | 'reference' | 'scratch';
129
+ topMatchScore?: number;
130
+ generationAttempts?: number;
131
+ credentialsNeeded?: CredentialRequirement[];
132
+ sourceKind?: SourceKind;
133
+ sourceId?: string;
134
+ sourceUrl?: string;
135
+ trustLevel?: TrustLevel;
136
+ }
137
+ interface OutcomeData {
138
+ attempts: number;
139
+ firstTryPass: boolean;
140
+ failedRules: number[];
141
+ mode: 'direct' | 'reference';
142
+ }
143
+ interface OutcomeStats {
144
+ totalUses: number;
145
+ totalAttempts: number;
146
+ firstTryPasses: number;
147
+ failedRules: Record<string, number>;
115
148
  }
116
149
  interface StoredWorkflow {
117
150
  id: string;
@@ -122,6 +155,20 @@ interface StoredWorkflow {
122
155
  deployCount: number;
123
156
  createdAt: string;
124
157
  lastDeployedAt?: string;
158
+ failurePatterns?: FailurePattern[];
159
+ sourceWorkflowIds?: string[];
160
+ generationMode?: 'direct' | 'reference' | 'scratch';
161
+ topMatchScore?: number;
162
+ generationAttempts?: number;
163
+ credentialsNeeded?: CredentialRequirement[];
164
+ sourceKind?: SourceKind;
165
+ sourceId?: string;
166
+ sourceUrl?: string;
167
+ trustLevel?: TrustLevel;
168
+ timesRetrieved?: number;
169
+ timesUsedAsDirect?: number;
170
+ timesUsedAsReference?: number;
171
+ outcomeStats?: OutcomeStats;
125
172
  }
126
173
  interface WorkflowMatch {
127
174
  workflow: StoredWorkflow;
@@ -141,14 +188,15 @@ interface IWorkflowLibrary {
141
188
  search(description: string, options?: SearchOptions): Promise<WorkflowMatch[]>;
142
189
  save(workflow: N8nWorkflow, metadata: WorkflowMetadataInput): Promise<string>;
143
190
  recordDeployment(id: string): Promise<void>;
191
+ recordOutcome(id: string, outcome: OutcomeData): Promise<void>;
144
192
  get(id: string): Promise<StoredWorkflow | null>;
145
193
  list(filters?: LibraryFilters): Promise<StoredWorkflow[]>;
146
194
  }
147
195
 
148
196
  interface ClientOptions {
149
197
  anthropicApiKey: string;
150
- n8nBaseUrl: string;
151
- n8nApiKey: string;
198
+ n8nBaseUrl?: string;
199
+ n8nApiKey?: string;
152
200
  model?: string;
153
201
  logger?: ILogger;
154
202
  library?: IWorkflowLibrary;
@@ -175,10 +223,18 @@ declare class Kairos {
175
223
  private readonly library;
176
224
  private readonly logger;
177
225
  private readonly telemetry;
226
+ private readonly telemetryReader;
178
227
  private readonly model;
228
+ private saveQueue;
179
229
  constructor(options: ClientOptions);
230
+ private requireProvider;
231
+ private validateDescription;
180
232
  build(description: string, options?: BuildOptions): Promise<BuildResult>;
181
- update(id: string, description: string): Promise<BuildResult>;
233
+ replace(id: string, description: string): Promise<BuildResult>;
234
+ drain(): Promise<void>;
235
+ private emitAttemptTelemetry;
236
+ private recordDeploy;
237
+ private saveToLibrary;
182
238
  get(id: string): Promise<N8nWorkflow>;
183
239
  list(): Promise<WorkflowListItem[]>;
184
240
  activate(id: string): Promise<void>;
@@ -234,6 +290,7 @@ declare class N8nApiClient {
234
290
  private readonly logger;
235
291
  constructor(baseUrl: string, apiKey: string, logger: ILogger);
236
292
  private request;
293
+ private singleRequest;
237
294
  createWorkflow(workflow: N8nWorkflow): Promise<N8nWorkflowResponse>;
238
295
  updateWorkflow(id: string, workflow: N8nWorkflow): Promise<N8nWorkflowResponse>;
239
296
  getWorkflow(id: string): Promise<N8nWorkflowResponse>;
@@ -281,25 +338,66 @@ declare class NullLibrary implements IWorkflowLibrary {
281
338
  search(_description: string, _options?: SearchOptions): Promise<WorkflowMatch[]>;
282
339
  save(_workflow: N8nWorkflow, _metadata: WorkflowMetadataInput): Promise<string>;
283
340
  recordDeployment(_id: string): Promise<void>;
341
+ recordOutcome(_id: string, _outcome: OutcomeData): Promise<void>;
284
342
  get(_id: string): Promise<StoredWorkflow | null>;
285
343
  list(_filters?: LibraryFilters): Promise<StoredWorkflow[]>;
286
344
  }
287
345
 
346
+ declare function tokenize(text: string): string[];
347
+ declare function buildSearchCorpus(w: StoredWorkflow): string;
288
348
  declare class FileLibrary implements IWorkflowLibrary {
289
349
  private readonly dir;
290
350
  private workflows;
291
- private initialized;
351
+ private initPromise;
352
+ private writeQueue;
292
353
  constructor(dir?: string);
293
354
  initialize(): Promise<void>;
355
+ private doInitialize;
294
356
  search(description: string, options?: SearchOptions): Promise<WorkflowMatch[]>;
295
357
  save(workflow: N8nWorkflow, metadata: WorkflowMetadataInput): Promise<string>;
296
358
  recordDeployment(id: string): Promise<void>;
359
+ recordOutcome(id: string, outcome: OutcomeData): Promise<void>;
360
+ drain(): Promise<void>;
297
361
  get(id: string): Promise<StoredWorkflow | null>;
298
362
  list(filters?: LibraryFilters): Promise<StoredWorkflow[]>;
363
+ private deduplicateFailurePatterns;
299
364
  private persist;
300
365
  }
301
366
 
302
- interface ValidationIssue$1 {
367
+ interface ScoredEntry {
368
+ workflow: StoredWorkflow;
369
+ score: number;
370
+ signals: {
371
+ tfidf: number;
372
+ nodeFingerprint: number;
373
+ outcome: number;
374
+ deploy: number;
375
+ };
376
+ }
377
+ declare function hybridScore(queryTokens: string[], queryDescription: string, workflows: StoredWorkflow[], docTokenArrays: string[][], idf: Map<string, number>): ScoredEntry[];
378
+
379
+ interface WorkflowCluster {
380
+ pattern: string;
381
+ fingerprint: string[];
382
+ members: StoredWorkflow[];
383
+ avgFirstTryPassRate: number;
384
+ avgAttempts: number;
385
+ commonFailedRules: Array<{
386
+ rule: number;
387
+ frequency: number;
388
+ }>;
389
+ }
390
+ declare function clusterWorkflows(workflows: StoredWorkflow[]): WorkflowCluster[];
391
+ declare function rerank(candidates: Array<{
392
+ workflow: StoredWorkflow;
393
+ score: number;
394
+ }>, clusters: WorkflowCluster[]): Array<{
395
+ workflow: StoredWorkflow;
396
+ score: number;
397
+ clusterPattern?: string;
398
+ }>;
399
+
400
+ interface ValidationIssue {
303
401
  rule: number;
304
402
  severity: 'error' | 'warn';
305
403
  message: string;
@@ -307,7 +405,7 @@ interface ValidationIssue$1 {
307
405
  }
308
406
  interface ValidationResult {
309
407
  valid: boolean;
310
- issues: ValidationIssue$1[];
408
+ issues: ValidationIssue[];
311
409
  }
312
410
 
313
411
  interface NodeDefinition {
@@ -323,7 +421,9 @@ declare class NodeRegistry {
323
421
  constructor(definitions?: NodeDefinition[]);
324
422
  get(type: string): NodeDefinition | undefined;
325
423
  isTrigger(type: string): boolean;
424
+ isKnown(type: string): boolean;
326
425
  isVersionSafe(type: string, version: number): boolean;
426
+ getRequiredParams(type: string): string[];
327
427
  }
328
428
 
329
429
  declare class N8nValidator {
@@ -352,6 +452,10 @@ declare class N8nValidator {
352
452
  private checkRule17;
353
453
  private checkRule18;
354
454
  private checkRule19;
455
+ private checkRule20;
456
+ private checkRule22;
457
+ private checkRule23;
458
+ private checkRule21;
355
459
  }
356
460
 
357
461
  declare class KairosError extends Error {
@@ -359,12 +463,6 @@ declare class KairosError extends Error {
359
463
  constructor(message: string, cause?: unknown | undefined);
360
464
  }
361
465
 
362
- interface ValidationIssue {
363
- rule: number;
364
- severity: 'error' | 'warn';
365
- message: string;
366
- nodeId?: string;
367
- }
368
466
  declare class ValidationError extends KairosError {
369
467
  readonly issues: ValidationIssue[];
370
468
  constructor(message: string, issues: ValidationIssue[]);
@@ -391,7 +489,33 @@ declare class GuardError extends KairosError {
391
489
  constructor(message: string);
392
490
  }
393
491
 
492
+ interface SyncProgress {
493
+ total: number;
494
+ processed: number;
495
+ saved: number;
496
+ skippedPaid: number;
497
+ skippedDuplicate: number;
498
+ blocked: number;
499
+ reviewed: number;
500
+ }
501
+
502
+ interface SyncOptions {
503
+ maxTemplates?: number;
504
+ onProgress?: (progress: SyncProgress) => void;
505
+ }
506
+ declare class TemplateSyncer {
507
+ private readonly library;
508
+ private readonly validator;
509
+ private readonly logger;
510
+ constructor(library: IWorkflowLibrary, logger: ILogger);
511
+ sync(options?: SyncOptions): Promise<SyncProgress>;
512
+ private fetchTemplateIds;
513
+ private processTemplate;
514
+ private cleanDescription;
515
+ }
516
+
394
517
  interface TelemetryEvent {
518
+ schemaVersion: number;
395
519
  timestamp: string;
396
520
  sessionId: string;
397
521
  eventType: 'build_start' | 'generation_attempt' | 'build_complete';
@@ -410,8 +534,25 @@ interface AttemptMetadata {
410
534
  declare class TelemetryCollector {
411
535
  private readonly dir;
412
536
  readonly sessionId: string;
537
+ private dirReady;
413
538
  constructor(dir?: string);
414
539
  emit(eventType: TelemetryEvent['eventType'], data: Record<string, unknown>): Promise<void>;
415
540
  }
416
541
 
417
- export { ApiError, type AttemptMetadata, type BuildOptions, type BuildResult, type ClientOptions, type CredentialRequirement, DEFAULT_REGISTRY, type DeleteOptions, type DeployResult, type ExecutionDetail, type ExecutionFilter, type ExecutionSummary, FileLibrary, GenerationError, GuardError, type ILogger, type IProvider, type IWorkflowLibrary, Kairos, KairosError, N8nApiClient, type N8nConnections, N8nFieldStripper, type N8nNode, N8nProvider, type N8nSettings, N8nValidator, type N8nWorkflow, NodeRegistry, NullLibrary, ProviderError, ResponseParseError, type StoredWorkflow, type Tag, TelemetryCollector, type TelemetryEvent, ValidationError, type ValidationIssue, type ValidationResult, type WorkflowListItem, type WorkflowMatch, nullLogger };
542
+ interface RuleFailureRate {
543
+ rule: number;
544
+ failureCount: number;
545
+ totalBuilds: number;
546
+ rate: number;
547
+ commonMessage: string;
548
+ }
549
+ declare class TelemetryReader {
550
+ private readonly dir;
551
+ private cache;
552
+ private cacheTime;
553
+ constructor(dir?: string);
554
+ getFailureRates(days?: number): Promise<RuleFailureRate[]>;
555
+ private readRecentEvents;
556
+ }
557
+
558
+ export { ApiError, type AttemptMetadata, type BuildOptions, type BuildResult, type ClientOptions, type CredentialRequirement, DEFAULT_REGISTRY, type DeleteOptions, type DeployResult, type ExecutionDetail, type ExecutionFilter, type ExecutionSummary, type FailurePattern, FileLibrary, GenerationError, GuardError, type ILogger, type IProvider, type IWorkflowLibrary, Kairos, KairosError, N8nApiClient, type N8nConnections, N8nFieldStripper, type N8nNode, N8nProvider, type N8nSettings, N8nValidator, type N8nWorkflow, NodeRegistry, NullLibrary, type OutcomeData, type OutcomeStats, ProviderError, ResponseParseError, type RuleFailureRate, type ScoredEntry, type SourceKind, type StoredWorkflow, type SyncProgress, type Tag, TelemetryCollector, type TelemetryEvent, TelemetryReader, TemplateSyncer, type TrustLevel, ValidationError, type ValidationIssue, type ValidationResult, type WorkflowCluster, type WorkflowListItem, type WorkflowMatch, type WorkflowMetadataInput, buildSearchCorpus, clusterWorkflows, hybridScore, nullLogger, rerank, tokenize };