semantic-primitives 0.1.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/LICENSE +201 -0
- package/README.md +449 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25016 -0
- package/dist/llm/client.d.ts +82 -0
- package/dist/llm/client.d.ts.map +1 -0
- package/dist/llm/index.d.ts +11 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/providers/anthropic.d.ts +13 -0
- package/dist/llm/providers/anthropic.d.ts.map +1 -0
- package/dist/llm/providers/google.d.ts +13 -0
- package/dist/llm/providers/google.d.ts.map +1 -0
- package/dist/llm/providers/index.d.ts +7 -0
- package/dist/llm/providers/index.d.ts.map +1 -0
- package/dist/llm/providers/openai.d.ts +13 -0
- package/dist/llm/providers/openai.d.ts.map +1 -0
- package/dist/llm/types.d.ts +91 -0
- package/dist/llm/types.d.ts.map +1 -0
- package/dist/primitives/bigint/bigint.d.ts +197 -0
- package/dist/primitives/bigint/bigint.d.ts.map +1 -0
- package/dist/primitives/bigint/index.d.ts +7 -0
- package/dist/primitives/bigint/index.d.ts.map +1 -0
- package/dist/primitives/bigint/prompts.d.ts +37 -0
- package/dist/primitives/bigint/prompts.d.ts.map +1 -0
- package/dist/primitives/boolean/boolean.d.ts +194 -0
- package/dist/primitives/boolean/boolean.d.ts.map +1 -0
- package/dist/primitives/boolean/evals/from.evals.d.ts +7 -0
- package/dist/primitives/boolean/evals/from.evals.d.ts.map +1 -0
- package/dist/primitives/boolean/evals/index.d.ts +5 -0
- package/dist/primitives/boolean/evals/index.d.ts.map +1 -0
- package/dist/primitives/boolean/index.d.ts +6 -0
- package/dist/primitives/boolean/index.d.ts.map +1 -0
- package/dist/primitives/boolean/prompts.d.ts +29 -0
- package/dist/primitives/boolean/prompts.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +14 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/null/index.d.ts +6 -0
- package/dist/primitives/null/index.d.ts.map +1 -0
- package/dist/primitives/null/null.d.ts +181 -0
- package/dist/primitives/null/null.d.ts.map +1 -0
- package/dist/primitives/null/prompts.d.ts +39 -0
- package/dist/primitives/null/prompts.d.ts.map +1 -0
- package/dist/primitives/number/index.d.ts +6 -0
- package/dist/primitives/number/index.d.ts.map +1 -0
- package/dist/primitives/number/number.d.ts +154 -0
- package/dist/primitives/number/number.d.ts.map +1 -0
- package/dist/primitives/number/number.prompts.d.ts +53 -0
- package/dist/primitives/number/number.prompts.d.ts.map +1 -0
- package/dist/primitives/string/evals/classify.evals.d.ts +7 -0
- package/dist/primitives/string/evals/classify.evals.d.ts.map +1 -0
- package/dist/primitives/string/evals/index.d.ts +6 -0
- package/dist/primitives/string/evals/index.d.ts.map +1 -0
- package/dist/primitives/string/evals/semanticallyEquals.evals.d.ts +7 -0
- package/dist/primitives/string/evals/semanticallyEquals.evals.d.ts.map +1 -0
- package/dist/primitives/string/index.d.ts +206 -0
- package/dist/primitives/string/index.d.ts.map +1 -0
- package/dist/primitives/string/string.prompts.d.ts +45 -0
- package/dist/primitives/string/string.prompts.d.ts.map +1 -0
- package/dist/primitives/symbol/index.d.ts +6 -0
- package/dist/primitives/symbol/index.d.ts.map +1 -0
- package/dist/primitives/symbol/symbol.d.ts +176 -0
- package/dist/primitives/symbol/symbol.d.ts.map +1 -0
- package/dist/primitives/symbol/symbol.prompts.d.ts +53 -0
- package/dist/primitives/symbol/symbol.prompts.d.ts.map +1 -0
- package/dist/primitives/undefined/index.d.ts +5 -0
- package/dist/primitives/undefined/index.d.ts.map +1 -0
- package/dist/primitives/undefined/prompts.d.ts +40 -0
- package/dist/primitives/undefined/prompts.d.ts.map +1 -0
- package/dist/primitives/undefined/undefined.d.ts +216 -0
- package/dist/primitives/undefined/undefined.d.ts.map +1 -0
- package/dist/primitives/void/index.d.ts +5 -0
- package/dist/primitives/void/index.d.ts.map +1 -0
- package/dist/primitives/void/prompts.d.ts +37 -0
- package/dist/primitives/void/prompts.d.ts.map +1 -0
- package/dist/primitives/void/void.d.ts +172 -0
- package/dist/primitives/void/void.d.ts.map +1 -0
- package/dist/shared/base-classes.d.ts +331 -0
- package/dist/shared/base-classes.d.ts.map +1 -0
- package/dist/shared/eval-types.d.ts +82 -0
- package/dist/shared/eval-types.d.ts.map +1 -0
- package/dist/shared/index.d.ts +25 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/interfaces.d.ts +799 -0
- package/dist/shared/interfaces.d.ts.map +1 -0
- package/dist/shared/types.d.ts +335 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/types/array/array.d.ts +250 -0
- package/dist/types/array/array.d.ts.map +1 -0
- package/dist/types/array/index.d.ts +6 -0
- package/dist/types/array/index.d.ts.map +1 -0
- package/dist/types/array/prompts.d.ts +63 -0
- package/dist/types/array/prompts.d.ts.map +1 -0
- package/dist/types/blob-file/blob.d.ts +188 -0
- package/dist/types/blob-file/blob.d.ts.map +1 -0
- package/dist/types/blob-file/file.d.ts +144 -0
- package/dist/types/blob-file/file.d.ts.map +1 -0
- package/dist/types/blob-file/index.d.ts +8 -0
- package/dist/types/blob-file/index.d.ts.map +1 -0
- package/dist/types/blob-file/prompts.d.ts +101 -0
- package/dist/types/blob-file/prompts.d.ts.map +1 -0
- package/dist/types/bun/bun.d.ts +266 -0
- package/dist/types/bun/bun.d.ts.map +1 -0
- package/dist/types/bun/index.d.ts +7 -0
- package/dist/types/bun/index.d.ts.map +1 -0
- package/dist/types/bun/prompts.d.ts +93 -0
- package/dist/types/bun/prompts.d.ts.map +1 -0
- package/dist/types/callable/callable.d.ts +200 -0
- package/dist/types/callable/callable.d.ts.map +1 -0
- package/dist/types/callable/index.d.ts +6 -0
- package/dist/types/callable/index.d.ts.map +1 -0
- package/dist/types/callable/prompts.d.ts +45 -0
- package/dist/types/callable/prompts.d.ts.map +1 -0
- package/dist/types/constructable/constructable.d.ts +150 -0
- package/dist/types/constructable/constructable.d.ts.map +1 -0
- package/dist/types/constructable/index.d.ts +5 -0
- package/dist/types/constructable/index.d.ts.map +1 -0
- package/dist/types/constructable/prompts.d.ts +41 -0
- package/dist/types/constructable/prompts.d.ts.map +1 -0
- package/dist/types/date/date.d.ts +258 -0
- package/dist/types/date/date.d.ts.map +1 -0
- package/dist/types/date/index.d.ts +6 -0
- package/dist/types/date/index.d.ts.map +1 -0
- package/dist/types/date/prompts.d.ts +93 -0
- package/dist/types/date/prompts.d.ts.map +1 -0
- package/dist/types/error/error.d.ts +191 -0
- package/dist/types/error/error.d.ts.map +1 -0
- package/dist/types/error/index.d.ts +6 -0
- package/dist/types/error/index.d.ts.map +1 -0
- package/dist/types/error/prompts.d.ts +49 -0
- package/dist/types/error/prompts.d.ts.map +1 -0
- package/dist/types/event-emitter/event-emitter.d.ts +230 -0
- package/dist/types/event-emitter/event-emitter.d.ts.map +1 -0
- package/dist/types/event-emitter/index.d.ts +6 -0
- package/dist/types/event-emitter/index.d.ts.map +1 -0
- package/dist/types/event-emitter/prompts.d.ts +51 -0
- package/dist/types/event-emitter/prompts.d.ts.map +1 -0
- package/dist/types/fetch/headers.d.ts +126 -0
- package/dist/types/fetch/headers.d.ts.map +1 -0
- package/dist/types/fetch/index.d.ts +9 -0
- package/dist/types/fetch/index.d.ts.map +1 -0
- package/dist/types/fetch/prompts.d.ts +139 -0
- package/dist/types/fetch/prompts.d.ts.map +1 -0
- package/dist/types/fetch/request.d.ts +188 -0
- package/dist/types/fetch/request.d.ts.map +1 -0
- package/dist/types/fetch/response.d.ts +155 -0
- package/dist/types/fetch/response.d.ts.map +1 -0
- package/dist/types/form-data/form-data.d.ts +277 -0
- package/dist/types/form-data/form-data.d.ts.map +1 -0
- package/dist/types/form-data/index.d.ts +7 -0
- package/dist/types/form-data/index.d.ts.map +1 -0
- package/dist/types/form-data/prompts.d.ts +80 -0
- package/dist/types/form-data/prompts.d.ts.map +1 -0
- package/dist/types/index.d.ts +29 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/map/index.d.ts +6 -0
- package/dist/types/map/index.d.ts.map +1 -0
- package/dist/types/map/map.d.ts +204 -0
- package/dist/types/map/map.d.ts.map +1 -0
- package/dist/types/map/prompts.d.ts +56 -0
- package/dist/types/map/prompts.d.ts.map +1 -0
- package/dist/types/never/index.d.ts +5 -0
- package/dist/types/never/index.d.ts.map +1 -0
- package/dist/types/never/never.d.ts +220 -0
- package/dist/types/never/never.d.ts.map +1 -0
- package/dist/types/never/prompts.d.ts +50 -0
- package/dist/types/never/prompts.d.ts.map +1 -0
- package/dist/types/object/index.d.ts +6 -0
- package/dist/types/object/index.d.ts.map +1 -0
- package/dist/types/object/object.d.ts +162 -0
- package/dist/types/object/object.d.ts.map +1 -0
- package/dist/types/object/prompts.d.ts +55 -0
- package/dist/types/object/prompts.d.ts.map +1 -0
- package/dist/types/object-literal/index.d.ts +6 -0
- package/dist/types/object-literal/index.d.ts.map +1 -0
- package/dist/types/object-literal/object-literal.d.ts +223 -0
- package/dist/types/object-literal/object-literal.d.ts.map +1 -0
- package/dist/types/object-literal/prompts.d.ts +49 -0
- package/dist/types/object-literal/prompts.d.ts.map +1 -0
- package/dist/types/promise/index.d.ts +6 -0
- package/dist/types/promise/index.d.ts.map +1 -0
- package/dist/types/promise/promise.d.ts +240 -0
- package/dist/types/promise/promise.d.ts.map +1 -0
- package/dist/types/promise/prompts.d.ts +45 -0
- package/dist/types/promise/prompts.d.ts.map +1 -0
- package/dist/types/record/index.d.ts +5 -0
- package/dist/types/record/index.d.ts.map +1 -0
- package/dist/types/record/prompts.d.ts +45 -0
- package/dist/types/record/prompts.d.ts.map +1 -0
- package/dist/types/record/record.d.ts +179 -0
- package/dist/types/record/record.d.ts.map +1 -0
- package/dist/types/regexp/index.d.ts +7 -0
- package/dist/types/regexp/index.d.ts.map +1 -0
- package/dist/types/regexp/prompts.d.ts +56 -0
- package/dist/types/regexp/prompts.d.ts.map +1 -0
- package/dist/types/regexp/regexp.d.ts +160 -0
- package/dist/types/regexp/regexp.d.ts.map +1 -0
- package/dist/types/set/index.d.ts +6 -0
- package/dist/types/set/index.d.ts.map +1 -0
- package/dist/types/set/prompts.d.ts +60 -0
- package/dist/types/set/prompts.d.ts.map +1 -0
- package/dist/types/set/set.d.ts +261 -0
- package/dist/types/set/set.d.ts.map +1 -0
- package/dist/types/streams/index.d.ts +8 -0
- package/dist/types/streams/index.d.ts.map +1 -0
- package/dist/types/streams/prompts.d.ts +53 -0
- package/dist/types/streams/prompts.d.ts.map +1 -0
- package/dist/types/streams/readable-stream.d.ts +148 -0
- package/dist/types/streams/readable-stream.d.ts.map +1 -0
- package/dist/types/streams/transform-stream.d.ts +67 -0
- package/dist/types/streams/transform-stream.d.ts.map +1 -0
- package/dist/types/streams/writable-stream.d.ts +111 -0
- package/dist/types/streams/writable-stream.d.ts.map +1 -0
- package/dist/types/text-codec/index.d.ts +12 -0
- package/dist/types/text-codec/index.d.ts.map +1 -0
- package/dist/types/text-codec/prompts.d.ts +79 -0
- package/dist/types/text-codec/prompts.d.ts.map +1 -0
- package/dist/types/text-codec/text-codec.d.ts +305 -0
- package/dist/types/text-codec/text-codec.d.ts.map +1 -0
- package/dist/types/tuple/index.d.ts +6 -0
- package/dist/types/tuple/index.d.ts.map +1 -0
- package/dist/types/tuple/prompts.d.ts +41 -0
- package/dist/types/tuple/prompts.d.ts.map +1 -0
- package/dist/types/tuple/tuple.d.ts +221 -0
- package/dist/types/tuple/tuple.d.ts.map +1 -0
- package/dist/types/unknown/index.d.ts +5 -0
- package/dist/types/unknown/index.d.ts.map +1 -0
- package/dist/types/unknown/prompts.d.ts +45 -0
- package/dist/types/unknown/prompts.d.ts.map +1 -0
- package/dist/types/unknown/unknown.d.ts +220 -0
- package/dist/types/unknown/unknown.d.ts.map +1 -0
- package/dist/types/url/index.d.ts +7 -0
- package/dist/types/url/index.d.ts.map +1 -0
- package/dist/types/url/prompts.d.ts +93 -0
- package/dist/types/url/prompts.d.ts.map +1 -0
- package/dist/types/url/url.d.ts +270 -0
- package/dist/types/url/url.d.ts.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticError
|
|
3
|
+
* An error type with LLM-powered semantic understanding
|
|
4
|
+
*
|
|
5
|
+
* Implements shared interfaces:
|
|
6
|
+
* - Comparable<Error, SemanticEqualsResultWithReason> - Semantic equality comparison
|
|
7
|
+
* - Explainable - Human-readable explanations
|
|
8
|
+
* - Classifiable - Error classification
|
|
9
|
+
* - SemanticErrorType - Error-specific methods
|
|
10
|
+
*/
|
|
11
|
+
import type { LLMClient } from '../../llm/client.ts';
|
|
12
|
+
import type { SemanticEqualsResultWithReason, ClassifyResult, RootCauseResult, SuggestedFix, RecoveryStrategy, ErrorSeverityLevel } from '../../shared/types.ts';
|
|
13
|
+
import type { Comparable, Explainable, Classifiable, SemanticErrorType } from '../../shared/interfaces.ts';
|
|
14
|
+
export type { SemanticEqualsResultWithReason, ClassifyResult, RootCauseResult, SuggestedFix, RecoveryStrategy, ErrorSeverityLevel, } from '../../shared/types.ts';
|
|
15
|
+
/** Result of error classification with extended fields */
|
|
16
|
+
export interface ErrorClassifyResult extends ClassifyResult {
|
|
17
|
+
subcategory?: string;
|
|
18
|
+
severity: 'critical' | 'recoverable' | 'warning';
|
|
19
|
+
retryable: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** Resource suggestion */
|
|
22
|
+
export interface ResourceSuggestion {
|
|
23
|
+
title: string;
|
|
24
|
+
type: string;
|
|
25
|
+
url?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Report recommendation */
|
|
28
|
+
export interface ReportRecommendation {
|
|
29
|
+
report: boolean;
|
|
30
|
+
reason: string;
|
|
31
|
+
priority?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* SemanticError - Error with LLM-powered semantic understanding
|
|
35
|
+
*
|
|
36
|
+
* Extends the native JavaScript Error with intelligent error classification,
|
|
37
|
+
* fix suggestions, and human-readable explanations.
|
|
38
|
+
*
|
|
39
|
+
* Implements:
|
|
40
|
+
* - Comparable<Error, SemanticEqualsResultWithReason> - semanticallyEquals() for comparison
|
|
41
|
+
* - Explainable - explain() for human-readable explanations
|
|
42
|
+
* - Classifiable<ErrorClassifyResult> - classify() for categorization
|
|
43
|
+
* - SemanticErrorType - Full error-specific interface
|
|
44
|
+
*/
|
|
45
|
+
export declare class SemanticError extends Error implements Comparable<Error, SemanticEqualsResultWithReason>, Explainable, Classifiable<ErrorClassifyResult>, SemanticErrorType {
|
|
46
|
+
private readonly client;
|
|
47
|
+
private readonly context;
|
|
48
|
+
private cachedClassification?;
|
|
49
|
+
private constructor();
|
|
50
|
+
/**
|
|
51
|
+
* Create a SemanticError from any error-like value.
|
|
52
|
+
*
|
|
53
|
+
* @param error - Error object, string, or unknown value
|
|
54
|
+
* @param context - Additional context
|
|
55
|
+
* @param client - Optional LLM client
|
|
56
|
+
* @returns SemanticError instance
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* SemanticError.from(caughtError)
|
|
60
|
+
* SemanticError.from("Connection failed", { service: "database" })
|
|
61
|
+
*/
|
|
62
|
+
static from(error: unknown, context?: Record<string, unknown>, client?: LLMClient): SemanticError;
|
|
63
|
+
/**
|
|
64
|
+
* Check if two errors are semantically equivalent.
|
|
65
|
+
* Same root cause despite different messages.
|
|
66
|
+
*
|
|
67
|
+
* @param other - Error to compare
|
|
68
|
+
* @returns Equivalence result
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* error1.semanticallyEquals(error2)
|
|
72
|
+
* // { equivalent: true, reason: "Both are network timeout errors", confidence: 0.85 }
|
|
73
|
+
*/
|
|
74
|
+
semanticallyEquals(other: Error): Promise<SemanticEqualsResultWithReason>;
|
|
75
|
+
/**
|
|
76
|
+
* Classify the error into a category.
|
|
77
|
+
*
|
|
78
|
+
* @returns Error classification
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* error.classify()
|
|
82
|
+
* // {
|
|
83
|
+
* // category: "network",
|
|
84
|
+
* // subcategory: "timeout",
|
|
85
|
+
* // severity: "recoverable",
|
|
86
|
+
* // retryable: true,
|
|
87
|
+
* // confidence: 0.9
|
|
88
|
+
* // }
|
|
89
|
+
*/
|
|
90
|
+
classify(): Promise<ErrorClassifyResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Explain the error in plain language.
|
|
93
|
+
*
|
|
94
|
+
* @param audience - Target audience
|
|
95
|
+
* @returns Human-readable explanation
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* error.explain("end-user")
|
|
99
|
+
* // "We couldn't connect to the server. Please check your internet connection."
|
|
100
|
+
*
|
|
101
|
+
* error.explain("developer")
|
|
102
|
+
* // "ECONNREFUSED on port 5432. The PostgreSQL server may not be running."
|
|
103
|
+
*/
|
|
104
|
+
explain(audience?: 'end-user' | 'developer' | 'support'): Promise<string>;
|
|
105
|
+
/**
|
|
106
|
+
* Suggest fixes for the error.
|
|
107
|
+
*
|
|
108
|
+
* @returns Suggested fixes
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* error.suggestFixes()
|
|
112
|
+
* // [
|
|
113
|
+
* // { fix: "Check database connection string", confidence: 0.9 },
|
|
114
|
+
* // { fix: "Ensure PostgreSQL service is running", confidence: 0.85 }
|
|
115
|
+
* // ]
|
|
116
|
+
*/
|
|
117
|
+
suggestFixes(): Promise<SuggestedFix[]>;
|
|
118
|
+
/**
|
|
119
|
+
* Infer the root cause of the error.
|
|
120
|
+
*
|
|
121
|
+
* @returns Root cause analysis
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* error.inferRootCause()
|
|
125
|
+
* // { cause: "Database connection pool exhausted", confidence: 0.87 }
|
|
126
|
+
*/
|
|
127
|
+
inferRootCause(): Promise<RootCauseResult>;
|
|
128
|
+
/**
|
|
129
|
+
* Check if this error matches a known pattern.
|
|
130
|
+
*
|
|
131
|
+
* @param pattern - Error pattern to check
|
|
132
|
+
* @returns Match result
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* error.matches("network-related") // true
|
|
136
|
+
* error.matches("authentication-failure") // false
|
|
137
|
+
*/
|
|
138
|
+
matches(pattern: string): Promise<boolean>;
|
|
139
|
+
/**
|
|
140
|
+
* Get related documentation or resources.
|
|
141
|
+
*
|
|
142
|
+
* @returns Related resources
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* error.getResources()
|
|
146
|
+
* // [{ title: "Troubleshooting Connection Issues", type: "docs" }]
|
|
147
|
+
*/
|
|
148
|
+
getResources(): Promise<ResourceSuggestion[]>;
|
|
149
|
+
/**
|
|
150
|
+
* Determine if this error should be reported/logged.
|
|
151
|
+
*
|
|
152
|
+
* @returns Reporting recommendation
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* error.shouldReport()
|
|
156
|
+
* // { report: true, reason: "Unexpected server error", priority: "high" }
|
|
157
|
+
*/
|
|
158
|
+
shouldReport(): Promise<ReportRecommendation>;
|
|
159
|
+
/**
|
|
160
|
+
* Get a recovery strategy for this error.
|
|
161
|
+
*
|
|
162
|
+
* @returns Recovery strategy
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* error.recoveryStrategy()
|
|
166
|
+
* // { strategy: "retry", maxAttempts: 3, backoff: "exponential" }
|
|
167
|
+
*/
|
|
168
|
+
recoveryStrategy(): Promise<RecoveryStrategy>;
|
|
169
|
+
/**
|
|
170
|
+
* Get the semantic severity level.
|
|
171
|
+
*
|
|
172
|
+
* @returns Severity assessment
|
|
173
|
+
*/
|
|
174
|
+
getSeverity(): Promise<ErrorSeverityLevel>;
|
|
175
|
+
/**
|
|
176
|
+
* Get the context associated with this error.
|
|
177
|
+
*
|
|
178
|
+
* @returns Error context
|
|
179
|
+
*/
|
|
180
|
+
getContext(): Record<string, unknown>;
|
|
181
|
+
/**
|
|
182
|
+
* Convert to JSON representation
|
|
183
|
+
*/
|
|
184
|
+
toJSON(): {
|
|
185
|
+
name: string;
|
|
186
|
+
message: string;
|
|
187
|
+
stack?: string;
|
|
188
|
+
context: Record<string, unknown>;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/types/error/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EACV,8BAA8B,EAC9B,cAAc,EACd,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAepC,YAAY,EACV,8BAA8B,EAC9B,cAAc,EACd,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAE/B,0DAA0D;AAC1D,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,UAAU,GAAG,aAAa,GAAG,SAAS,CAAC;IACjD,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,0BAA0B;AAC1B,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,4BAA4B;AAC5B,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,aACX,SAAQ,KACR,YACE,UAAU,CAAC,KAAK,EAAE,8BAA8B,CAAC,EACjD,WAAW,EACX,YAA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R,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC;CAQF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticError module
|
|
3
|
+
* LLM-enhanced error type with semantic understanding
|
|
4
|
+
*/
|
|
5
|
+
export { SemanticError, type ErrorClassifyResult, type ResourceSuggestion, type ReportRecommendation, type SemanticEqualsResultWithReason, type ClassifyResult, type RootCauseResult, type SuggestedFix, type RecoveryStrategy, type ErrorSeverityLevel, } from './error.ts';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/error/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,8BAA8B,EACnC,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,GACxB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts for SemanticError LLM operations
|
|
3
|
+
* These prompts enable intelligent error classification, explanation, and fix suggestions
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* System prompt for error analysis tasks
|
|
7
|
+
*/
|
|
8
|
+
export declare const ERROR_SYSTEM_PROMPT = "You are an expert error analyst and debugger. Your task is to analyze errors, classify them, suggest fixes, and provide helpful explanations.\n\nYou must respond with valid JSON only, no additional text or explanation.\n\nGuidelines:\n- Analyze error messages, stack traces, and context to understand root causes\n- Consider common error patterns in software development\n- Provide actionable, specific suggestions for fixes\n- Adjust explanations based on the target audience (developer, end-user, support)\n- Be precise with confidence scores based on available information";
|
|
9
|
+
/**
|
|
10
|
+
* Prompt template for semantic equality comparison between errors
|
|
11
|
+
*/
|
|
12
|
+
export declare function createSemanticallyEqualsPrompt(error1Message: string, error1Stack: string | undefined, error2Message: string, error2Stack: string | undefined): string;
|
|
13
|
+
/**
|
|
14
|
+
* Prompt template for error classification
|
|
15
|
+
*/
|
|
16
|
+
export declare function createClassifyPrompt(errorMessage: string, errorStack: string | undefined, context?: Record<string, unknown>): string;
|
|
17
|
+
/**
|
|
18
|
+
* Prompt template for generating human-readable explanations
|
|
19
|
+
*/
|
|
20
|
+
export declare function createExplainPrompt(errorMessage: string, errorStack: string | undefined, audience: 'end-user' | 'developer' | 'support'): string;
|
|
21
|
+
/**
|
|
22
|
+
* Prompt template for suggesting fixes
|
|
23
|
+
*/
|
|
24
|
+
export declare function createSuggestFixesPrompt(errorMessage: string, errorStack: string | undefined, context?: Record<string, unknown>): string;
|
|
25
|
+
/**
|
|
26
|
+
* Prompt template for inferring root cause
|
|
27
|
+
*/
|
|
28
|
+
export declare function createInferRootCausePrompt(errorMessage: string, errorStack: string | undefined, context?: Record<string, unknown>): string;
|
|
29
|
+
/**
|
|
30
|
+
* Prompt template for pattern matching
|
|
31
|
+
*/
|
|
32
|
+
export declare function createMatchesPatternPrompt(errorMessage: string, errorStack: string | undefined, pattern: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Prompt template for getting resources
|
|
35
|
+
*/
|
|
36
|
+
export declare function createGetResourcesPrompt(errorMessage: string, errorStack: string | undefined): string;
|
|
37
|
+
/**
|
|
38
|
+
* Prompt template for determining if error should be reported
|
|
39
|
+
*/
|
|
40
|
+
export declare function createShouldReportPrompt(errorMessage: string, errorStack: string | undefined, context?: Record<string, unknown>): string;
|
|
41
|
+
/**
|
|
42
|
+
* Prompt template for determining recovery strategy
|
|
43
|
+
*/
|
|
44
|
+
export declare function createRecoveryStrategyPrompt(errorMessage: string, errorStack: string | undefined, category?: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Prompt template for getting severity level
|
|
47
|
+
*/
|
|
48
|
+
export declare function createGetSeverityPrompt(errorMessage: string, errorStack: string | undefined, context?: Record<string, unknown>): string;
|
|
49
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/error/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB,okBASmC,CAAC;AAEpE;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,MAAM,CAsBR;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,MAAM,CAgCR;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,EAAE,UAAU,GAAG,WAAW,GAAG,SAAS,GAC7C,MAAM,CAkBR;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,MAAM,CA0BR;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,MAAM,CAqBR;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,MAAM,GACd,MAAM,CAqBR;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,MAAM,CA0BR;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CA0BR;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,MAAM,CAwBR"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticEventEmitter
|
|
3
|
+
* An EventEmitter wrapper with LLM-powered semantic understanding
|
|
4
|
+
*
|
|
5
|
+
* Implements intelligent event handling, pattern detection, and event flow analysis.
|
|
6
|
+
*/
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
import type { LLMClient } from '../../llm/client.ts';
|
|
9
|
+
/** Result of event classification */
|
|
10
|
+
export interface EventClassifyResult {
|
|
11
|
+
category: string;
|
|
12
|
+
severity?: 'low' | 'medium' | 'high';
|
|
13
|
+
recoverable?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Result of handler validation */
|
|
16
|
+
export interface ValidateHandlersResult {
|
|
17
|
+
valid: boolean;
|
|
18
|
+
issues: string[];
|
|
19
|
+
suggestions: string[];
|
|
20
|
+
}
|
|
21
|
+
/** Result of event name validation */
|
|
22
|
+
export interface ValidateEventNameResult {
|
|
23
|
+
valid: boolean;
|
|
24
|
+
suggestions: string[];
|
|
25
|
+
}
|
|
26
|
+
/** Handler suggestion */
|
|
27
|
+
export interface HandlerSuggestion {
|
|
28
|
+
event: string;
|
|
29
|
+
reason: string;
|
|
30
|
+
example: string;
|
|
31
|
+
}
|
|
32
|
+
/** Event flow analysis result */
|
|
33
|
+
export interface AnalyzeFlowResult {
|
|
34
|
+
events: Record<string, number>;
|
|
35
|
+
patterns: string[];
|
|
36
|
+
anomalies: string[];
|
|
37
|
+
}
|
|
38
|
+
/** Monitoring options */
|
|
39
|
+
export interface MonitorOptions {
|
|
40
|
+
reportInterval?: number;
|
|
41
|
+
onIssue?: (issue: string) => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* SemanticEventEmitter - EventEmitter with LLM-powered semantic understanding
|
|
45
|
+
*
|
|
46
|
+
* Wraps a native EventEmitter and adds intelligent event handling,
|
|
47
|
+
* pattern detection, and event flow analysis capabilities.
|
|
48
|
+
*/
|
|
49
|
+
export declare class SemanticEventEmitter {
|
|
50
|
+
readonly [Symbol.toStringTag] = "SemanticEventEmitter";
|
|
51
|
+
private readonly _emitter;
|
|
52
|
+
private readonly _context?;
|
|
53
|
+
private readonly _client;
|
|
54
|
+
private readonly _eventRecords;
|
|
55
|
+
private readonly _semanticHandlers;
|
|
56
|
+
private _isMonitoring;
|
|
57
|
+
private constructor();
|
|
58
|
+
/**
|
|
59
|
+
* Wrap an EventEmitter with semantic capabilities.
|
|
60
|
+
*
|
|
61
|
+
* @param emitter - EventEmitter to wrap
|
|
62
|
+
* @param context - Context about the emitter's purpose
|
|
63
|
+
* @param client - Optional LLM client
|
|
64
|
+
* @returns SemanticEventEmitter instance
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* SemanticEventEmitter.from(server, "HTTP server events")
|
|
68
|
+
*/
|
|
69
|
+
static from(emitter: EventEmitter, context?: string, client?: LLMClient): SemanticEventEmitter;
|
|
70
|
+
/**
|
|
71
|
+
* Get the underlying EventEmitter.
|
|
72
|
+
*/
|
|
73
|
+
get emitter(): EventEmitter;
|
|
74
|
+
/**
|
|
75
|
+
* Get the context description.
|
|
76
|
+
*/
|
|
77
|
+
get context(): string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Get all event names that have listeners.
|
|
80
|
+
*/
|
|
81
|
+
eventNames(): (string | symbol)[];
|
|
82
|
+
/**
|
|
83
|
+
* Get the listener count for an event.
|
|
84
|
+
*/
|
|
85
|
+
listenerCount(eventName: string | symbol): number;
|
|
86
|
+
/**
|
|
87
|
+
* Add a listener for an event.
|
|
88
|
+
*/
|
|
89
|
+
on(eventName: string | symbol, listener: (...args: unknown[]) => void): this;
|
|
90
|
+
/**
|
|
91
|
+
* Add a one-time listener for an event.
|
|
92
|
+
*/
|
|
93
|
+
once(eventName: string | symbol, listener: (...args: unknown[]) => void): this;
|
|
94
|
+
/**
|
|
95
|
+
* Remove a listener for an event.
|
|
96
|
+
*/
|
|
97
|
+
off(eventName: string | symbol, listener: (...args: unknown[]) => void): this;
|
|
98
|
+
/**
|
|
99
|
+
* Remove a listener for an event (alias for off).
|
|
100
|
+
*/
|
|
101
|
+
removeListener(eventName: string | symbol, listener: (...args: unknown[]) => void): this;
|
|
102
|
+
/**
|
|
103
|
+
* Remove all listeners for an event.
|
|
104
|
+
*/
|
|
105
|
+
removeAllListeners(eventName?: string | symbol): this;
|
|
106
|
+
/**
|
|
107
|
+
* Emit an event.
|
|
108
|
+
*/
|
|
109
|
+
emit(eventName: string | symbol, ...args: unknown[]): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Listen for events matching semantic criteria.
|
|
112
|
+
*
|
|
113
|
+
* @param criteria - Natural language description of events to listen for
|
|
114
|
+
* @param handler - Event handler
|
|
115
|
+
* @returns this (for chaining)
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* emitter.onSemantic("any error event", (event, data) => console.log(data))
|
|
119
|
+
*/
|
|
120
|
+
onSemantic(criteria: string, handler: (event: string, data: unknown) => void): this;
|
|
121
|
+
/**
|
|
122
|
+
* Remove a semantic handler.
|
|
123
|
+
*/
|
|
124
|
+
offSemantic(criteria: string, handler: (event: string, data: unknown) => void): this;
|
|
125
|
+
/**
|
|
126
|
+
* Analyze the event flow of this emitter.
|
|
127
|
+
*
|
|
128
|
+
* @param duration - Time to analyze (ms)
|
|
129
|
+
* @returns Event flow analysis
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* emitter.analyzeFlow(60000)
|
|
133
|
+
* // {
|
|
134
|
+
* // events: { "request": 150, "error": 3 },
|
|
135
|
+
* // patterns: ["request always followed by response"],
|
|
136
|
+
* // anomalies: ["error spike at minute 3"]
|
|
137
|
+
* // }
|
|
138
|
+
*/
|
|
139
|
+
analyzeFlow(duration: number): Promise<AnalyzeFlowResult>;
|
|
140
|
+
/**
|
|
141
|
+
* Validate event handlers are properly set up.
|
|
142
|
+
*
|
|
143
|
+
* @returns Validation result
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* emitter.validateHandlers()
|
|
147
|
+
* // { valid: false, issues: ["error event has no handler"] }
|
|
148
|
+
*/
|
|
149
|
+
validateHandlers(): ValidateHandlersResult;
|
|
150
|
+
/**
|
|
151
|
+
* Validate event handlers asynchronously with LLM analysis.
|
|
152
|
+
*/
|
|
153
|
+
validateHandlersAsync(): Promise<ValidateHandlersResult>;
|
|
154
|
+
/**
|
|
155
|
+
* Explain what events this emitter handles.
|
|
156
|
+
*
|
|
157
|
+
* @returns Human-readable explanation
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* emitter.explain()
|
|
161
|
+
* // "HTTP server emitter with request, response, error, and close events"
|
|
162
|
+
*/
|
|
163
|
+
explain(): string;
|
|
164
|
+
/**
|
|
165
|
+
* Explain with LLM-powered semantic analysis.
|
|
166
|
+
*/
|
|
167
|
+
explainAsync(): Promise<string>;
|
|
168
|
+
/**
|
|
169
|
+
* Detect the category/purpose of an event.
|
|
170
|
+
*
|
|
171
|
+
* @param eventName - Event name to analyze
|
|
172
|
+
* @returns Event classification
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* emitter.classifyEvent("connection_error")
|
|
176
|
+
* // { category: "error", severity: "high", recoverable: true }
|
|
177
|
+
*/
|
|
178
|
+
classifyEvent(eventName: string): EventClassifyResult;
|
|
179
|
+
/**
|
|
180
|
+
* Classify event with LLM-powered semantic analysis.
|
|
181
|
+
*/
|
|
182
|
+
classifyEventAsync(eventName: string): Promise<EventClassifyResult>;
|
|
183
|
+
/**
|
|
184
|
+
* Suggest event handlers based on registered events.
|
|
185
|
+
*
|
|
186
|
+
* @returns Suggested handlers
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* emitter.suggestHandlers()
|
|
190
|
+
* // [{ event: "error", reason: "Unhandled errors will crash the process" }]
|
|
191
|
+
*/
|
|
192
|
+
suggestHandlers(): HandlerSuggestion[];
|
|
193
|
+
/**
|
|
194
|
+
* Suggest handlers with LLM-powered analysis.
|
|
195
|
+
*/
|
|
196
|
+
suggestHandlersAsync(): Promise<HandlerSuggestion[]>;
|
|
197
|
+
/**
|
|
198
|
+
* Check if an event name follows naming conventions.
|
|
199
|
+
*
|
|
200
|
+
* @param eventName - Event name to validate
|
|
201
|
+
* @returns Validation result
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* emitter.validateEventName("USER_LOGIN")
|
|
205
|
+
* // { valid: true, suggestions: ["Consider using camelCase: userLogin"] }
|
|
206
|
+
*/
|
|
207
|
+
validateEventName(eventName: string): ValidateEventNameResult;
|
|
208
|
+
/**
|
|
209
|
+
* Validate event name with LLM-powered analysis.
|
|
210
|
+
*/
|
|
211
|
+
validateEventNameAsync(eventName: string): Promise<ValidateEventNameResult>;
|
|
212
|
+
/**
|
|
213
|
+
* Generate documentation for all registered events.
|
|
214
|
+
*
|
|
215
|
+
* @returns Event documentation
|
|
216
|
+
*/
|
|
217
|
+
generateDocs(): string;
|
|
218
|
+
/**
|
|
219
|
+
* Generate documentation with LLM-powered descriptions.
|
|
220
|
+
*/
|
|
221
|
+
generateDocsAsync(): Promise<string>;
|
|
222
|
+
/**
|
|
223
|
+
* Monitor events and report issues.
|
|
224
|
+
*
|
|
225
|
+
* @param options - Monitoring options
|
|
226
|
+
* @returns Cleanup function
|
|
227
|
+
*/
|
|
228
|
+
monitor(options?: MonitorOptions): () => void;
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=event-emitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-emitter.d.ts","sourceRoot":"","sources":["../../../src/types/event-emitter/event-emitter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAcrD,qCAAqC;AACrC,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,mCAAmC;AACnC,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,sCAAsC;AACtC,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,yBAAyB;AACzB,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,iCAAiC;AACjC,M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SAAS,EAAE,MAAM,GAAG,mBAAmB;IA6CrD;;OAEG;IACG,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAwBzE;;;;;;;;OAQG;IACH,eAAe,IAAI,iBAAiB,EAAE;IAgCtC;;OAEG;IACG,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IA4B1D;;;;;;;;;OASG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB;IAwC7D;;OAEG;IACG,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAoBjF;;;;OAIG;IACH,YAAY,IAAI,MAAM;IA8BtB;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAiC1C;;;;;OAKG;IACH,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM,IAAI;CA2E9C"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticEventEmitter module
|
|
3
|
+
* LLM-enhanced EventEmitter type with semantic understanding
|
|
4
|
+
*/
|
|
5
|
+
export { SemanticEventEmitter, type EventClassifyResult, type ValidateHandlersResult, type ValidateEventNameResult, type HandlerSuggestion, type AnalyzeFlowResult, type MonitorOptions, } from './event-emitter.ts';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/event-emitter/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts for SemanticEventEmitter LLM operations
|
|
3
|
+
* These prompts enable intelligent event handling, pattern detection, and event flow analysis
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* System prompt for event emitter analysis tasks
|
|
7
|
+
*/
|
|
8
|
+
export declare const EVENT_EMITTER_SYSTEM_PROMPT = "You are an expert at analyzing event-driven architectures, understanding event emitter patterns, and providing semantic insights about pub/sub communication.\n\nYou must respond with valid JSON only, no additional text or explanation.\n\nGuidelines:\n- Analyze event names, patterns, and flows to understand their semantics\n- Consider common event-driven patterns in Node.js and browser environments\n- Provide meaningful, contextual responses about event handling\n- Be precise with classifications and recommendations";
|
|
9
|
+
/**
|
|
10
|
+
* Prompt template for classifying an event based on its name
|
|
11
|
+
*/
|
|
12
|
+
export declare function createClassifyEventPrompt(eventName: string, context?: string, registeredEvents?: string[]): string;
|
|
13
|
+
/**
|
|
14
|
+
* Prompt template for matching events against semantic criteria
|
|
15
|
+
*/
|
|
16
|
+
export declare function createMatchEventCriteriaPrompt(eventName: string, criteria: string, eventData?: unknown): string;
|
|
17
|
+
/**
|
|
18
|
+
* Prompt template for validating event handlers
|
|
19
|
+
*/
|
|
20
|
+
export declare function createValidateHandlersPrompt(registeredEvents: string[], listenerCounts: Record<string, number>, context?: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Prompt template for suggesting event handlers
|
|
23
|
+
*/
|
|
24
|
+
export declare function createSuggestHandlersPrompt(registeredEvents: string[], existingHandlers: string[], context?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Prompt template for validating event names
|
|
27
|
+
*/
|
|
28
|
+
export declare function createValidateEventNamePrompt(eventName: string, existingEvents?: string[]): string;
|
|
29
|
+
/**
|
|
30
|
+
* Prompt template for generating event documentation
|
|
31
|
+
*/
|
|
32
|
+
export declare function createGenerateDocsPrompt(registeredEvents: string[], listenerCounts: Record<string, number>, context?: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Prompt template for explaining what the emitter handles
|
|
35
|
+
*/
|
|
36
|
+
export declare function createExplainEmitterPrompt(registeredEvents: string[], listenerCounts: Record<string, number>, context?: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Prompt template for analyzing event flow patterns
|
|
39
|
+
*/
|
|
40
|
+
export declare function createAnalyzeFlowPrompt(eventCounts: Record<string, number>, eventSequence: {
|
|
41
|
+
event: string;
|
|
42
|
+
timestamp: number;
|
|
43
|
+
}[], duration: number, context?: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Prompt template for detecting monitoring issues
|
|
46
|
+
*/
|
|
47
|
+
export declare function createDetectIssuePrompt(event: string, eventCounts: Record<string, number>, recentEvents: {
|
|
48
|
+
event: string;
|
|
49
|
+
timestamp: number;
|
|
50
|
+
}[], context?: string): string;
|
|
51
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/event-emitter/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,2BAA2B,6gBAQc,CAAC;AAEvD;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,MAAM,EAChB,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAC1B,MAAM,CAyBR;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,OAAO,GAClB,MAAM,CAmBR;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,gBAAgB,EAAE,MAAM,EAAE,EAC1B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACtC,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAmBR;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,MAAM,EAAE,EAC1B,gBAAgB,EAAE,MAAM,EAAE,EA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