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,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticRecord
|
|
3
|
+
* A Record type with LLM-powered semantic understanding
|
|
4
|
+
*
|
|
5
|
+
* Implements shared interfaces:
|
|
6
|
+
* - Semantic<Record<K, V>> - Base semantic wrapper
|
|
7
|
+
* - Comparable<SemanticRecord<K, V>> - Semantic equality comparison
|
|
8
|
+
* - Validatable - Validation against semantic rules
|
|
9
|
+
* - Summarizable - Content summarization
|
|
10
|
+
* - SemanticAccessible - Semantic key lookup
|
|
11
|
+
* - SemanticGroupable - Semantic grouping
|
|
12
|
+
* - SemanticFilterable - Semantic filtering
|
|
13
|
+
* - PurposeInferable - Purpose inference
|
|
14
|
+
*/
|
|
15
|
+
import type { LLMClient } from '../../llm/client.ts';
|
|
16
|
+
import type { SemanticGetResult, MissingSuggestion } from '../../shared/types.ts';
|
|
17
|
+
import type { Semantic, Comparable } from '../../shared/interfaces.ts';
|
|
18
|
+
export type { SemanticGetResult, MissingSuggestion, } from '../../shared/types.ts';
|
|
19
|
+
/** Result of semantic equality comparison for records */
|
|
20
|
+
export interface RecordSemanticEqualsResult {
|
|
21
|
+
equivalent: boolean;
|
|
22
|
+
keyMappings?: Record<string, string>;
|
|
23
|
+
confidence: number;
|
|
24
|
+
}
|
|
25
|
+
/** Result of key validation */
|
|
26
|
+
export interface ValidateKeysResult {
|
|
27
|
+
valid: boolean;
|
|
28
|
+
invalidKeys: string[];
|
|
29
|
+
reasons: string[];
|
|
30
|
+
}
|
|
31
|
+
/** Invalid entry for value validation */
|
|
32
|
+
export interface InvalidEntry<K, V> {
|
|
33
|
+
key: K;
|
|
34
|
+
value: V;
|
|
35
|
+
reason: string;
|
|
36
|
+
}
|
|
37
|
+
/** Result of value validation */
|
|
38
|
+
export interface ValidateValuesResult<K, V> {
|
|
39
|
+
valid: boolean;
|
|
40
|
+
invalidEntries: InvalidEntry<K, V>[];
|
|
41
|
+
}
|
|
42
|
+
/** Result of purpose inference for records */
|
|
43
|
+
export interface RecordInferPurposeResult {
|
|
44
|
+
purpose: string;
|
|
45
|
+
keyType: string;
|
|
46
|
+
valueType: string;
|
|
47
|
+
confidence: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* SemanticRecord - Record with LLM-powered semantic understanding
|
|
51
|
+
*
|
|
52
|
+
* Unlike traditional records that only support exact key matching,
|
|
53
|
+
* semantic records can look up values using natural language queries,
|
|
54
|
+
* find semantically equivalent keys, and understand key-value relationships.
|
|
55
|
+
*
|
|
56
|
+
* @template K - The type of keys in the record (extends string | number | symbol)
|
|
57
|
+
* @template V - The type of values in the record
|
|
58
|
+
*/
|
|
59
|
+
export declare class SemanticRecord<K extends string | number | symbol, V> implements Semantic<Record<K, V>>, Comparable<SemanticRecord<K, V> | Record<K, V>, RecordSemanticEqualsResult> {
|
|
60
|
+
private readonly internalRecord;
|
|
61
|
+
private readonly client;
|
|
62
|
+
private readonly context?;
|
|
63
|
+
private constructor();
|
|
64
|
+
/**
|
|
65
|
+
* Create a SemanticRecord from an existing Record object
|
|
66
|
+
*/
|
|
67
|
+
static from<K extends string | number | symbol, V>(record: Record<K, V>, context?: string, client?: LLMClient): SemanticRecord<K, V>;
|
|
68
|
+
/**
|
|
69
|
+
* Create an empty SemanticRecord
|
|
70
|
+
*/
|
|
71
|
+
static empty<K extends string | number | symbol, V>(client?: LLMClient): SemanticRecord<K, V>;
|
|
72
|
+
/**
|
|
73
|
+
* Get the underlying Record value
|
|
74
|
+
*/
|
|
75
|
+
valueOf(): Record<K, V>;
|
|
76
|
+
/**
|
|
77
|
+
* Get all keys
|
|
78
|
+
*/
|
|
79
|
+
keys(): K[];
|
|
80
|
+
/**
|
|
81
|
+
* Get all values
|
|
82
|
+
*/
|
|
83
|
+
values(): V[];
|
|
84
|
+
/**
|
|
85
|
+
* Get all entries
|
|
86
|
+
*/
|
|
87
|
+
entries(): [K, V][];
|
|
88
|
+
/**
|
|
89
|
+
* Get the number of entries
|
|
90
|
+
*/
|
|
91
|
+
get size(): number;
|
|
92
|
+
/**
|
|
93
|
+
* Get a value by exact key
|
|
94
|
+
*/
|
|
95
|
+
get(key: K): V | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Check if record has exact key
|
|
98
|
+
*/
|
|
99
|
+
has(key: K): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Get a value using semantic key matching.
|
|
102
|
+
* Finds the key that best matches the query, not just exact matches.
|
|
103
|
+
*
|
|
104
|
+
* @param query - Key or semantic query
|
|
105
|
+
* @param context - Optional context for matching
|
|
106
|
+
* @returns Value if found with match confidence
|
|
107
|
+
*/
|
|
108
|
+
semanticGet(query: string, context?: Record<string, unknown>): Promise<SemanticGetResult<K, V>>;
|
|
109
|
+
/**
|
|
110
|
+
* Check if two records are semantically equivalent.
|
|
111
|
+
*
|
|
112
|
+
* @param other - Record to compare with
|
|
113
|
+
* @returns Equivalence result with key mappings
|
|
114
|
+
*/
|
|
115
|
+
semanticallyEquals(other: SemanticRecord<K, V> | Record<K, V>): Promise<RecordSemanticEqualsResult>;
|
|
116
|
+
/**
|
|
117
|
+
* Validate keys against semantic rules.
|
|
118
|
+
*
|
|
119
|
+
* @param rules - Validation rules for keys
|
|
120
|
+
* @returns Validation result
|
|
121
|
+
*/
|
|
122
|
+
validateKeys(rules: string[]): Promise<ValidateKeysResult>;
|
|
123
|
+
/**
|
|
124
|
+
* Validate values against semantic rules.
|
|
125
|
+
*
|
|
126
|
+
* @param rules - Validation rules for values
|
|
127
|
+
* @returns Validation result
|
|
128
|
+
*/
|
|
129
|
+
validateValues(rules: string[]): Promise<ValidateValuesResult<K, V>>;
|
|
130
|
+
/**
|
|
131
|
+
* Infer the semantic purpose of this record.
|
|
132
|
+
*
|
|
133
|
+
* @returns Inferred purpose with key and value types
|
|
134
|
+
*/
|
|
135
|
+
inferPurpose(): Promise<RecordInferPurposeResult>;
|
|
136
|
+
/**
|
|
137
|
+
* Filter entries by semantic criteria.
|
|
138
|
+
*
|
|
139
|
+
* @param criteria - Natural language filter
|
|
140
|
+
* @returns Filtered record
|
|
141
|
+
*/
|
|
142
|
+
semanticFilter(criteria: string): Promise<SemanticRecord<K, V>>;
|
|
143
|
+
/**
|
|
144
|
+
* Suggest missing keys based on patterns.
|
|
145
|
+
*
|
|
146
|
+
* @returns Suggested keys with rationale
|
|
147
|
+
*/
|
|
148
|
+
suggestMissingKeys(): Promise<MissingSuggestion[]>;
|
|
149
|
+
/**
|
|
150
|
+
* Group entries by semantic criteria.
|
|
151
|
+
*
|
|
152
|
+
* @param criteria - Grouping criteria
|
|
153
|
+
* @returns Object of groups
|
|
154
|
+
*/
|
|
155
|
+
groupBy(criteria: string): Promise<Record<string, SemanticRecord<K, V>>>;
|
|
156
|
+
/**
|
|
157
|
+
* Summarize the record contents.
|
|
158
|
+
*
|
|
159
|
+
* @returns Human-readable summary
|
|
160
|
+
*/
|
|
161
|
+
summarize(): Promise<string>;
|
|
162
|
+
/**
|
|
163
|
+
* Convert to string representation
|
|
164
|
+
*/
|
|
165
|
+
toString(): string;
|
|
166
|
+
/**
|
|
167
|
+
* Convert to JSON
|
|
168
|
+
*/
|
|
169
|
+
toJSON(): Record<K, V>;
|
|
170
|
+
/**
|
|
171
|
+
* Iterator support
|
|
172
|
+
*/
|
|
173
|
+
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
174
|
+
/**
|
|
175
|
+
* Execute a function for each entry
|
|
176
|
+
*/
|
|
177
|
+
forEach(callback: (value: V, key: K) => void): void;
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../src/types/record/record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EACV,iBAAiB,EAC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+
*/
|
|
5
|
+
export { SemanticRegExp, type FromOptions, type TestWithExplanationResult, type SimplifyResult } from './regexp.ts';
|
|
6
|
+
export type { SemanticEqualsResult, ImprovementSuggestion, RegExpTestCases, ValidateResultWithWarnings, RelatedSuggestion, InferTypeResult, } from '../../shared/types.ts';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/regexp/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,KAAK,yBAAyB,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAGpH,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,iBAAiB,EACjB,eAAe,GAChB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts for SemanticRegExp LLM operations
|
|
3
|
+
* These prompts enable semantic understanding and manipulation of regular expressions
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* System prompt for regex semantic operations
|
|
7
|
+
*/
|
|
8
|
+
export declare const REGEXP_SYSTEM_PROMPT = "You are an expert regular expression analyzer and generator. Your task is to help users understand, create, and improve regular expressions.\n\nYou must respond with valid JSON only, no additional text, markdown formatting, or code blocks.\n\nGuidelines:\n- Provide accurate regex patterns that work in JavaScript/TypeScript\n- Consider edge cases and common variations\n- Be precise about what patterns match and don't match\n- Provide confidence scores from 0.0 to 1.0\n- When generating regex, prefer readability over cleverness when possible";
|
|
9
|
+
/**
|
|
10
|
+
* Prompt for creating regex from natural language description
|
|
11
|
+
*/
|
|
12
|
+
export declare function createFromPrompt(description: string, options?: {
|
|
13
|
+
flags?: string;
|
|
14
|
+
strict?: boolean;
|
|
15
|
+
}): string;
|
|
16
|
+
/**
|
|
17
|
+
* Prompt for semantic equality comparison between regexes
|
|
18
|
+
*/
|
|
19
|
+
export declare function createSemanticallyEqualsPrompt(pattern1: string, flags1: string, pattern2: string, flags2: string, testStrings?: string[]): string;
|
|
20
|
+
/**
|
|
21
|
+
* Prompt for explaining what a regex matches
|
|
22
|
+
*/
|
|
23
|
+
export declare function createExplainPrompt(pattern: string, flags: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Prompt for testing a string with explanation
|
|
26
|
+
*/
|
|
27
|
+
export declare function createTestWithExplanationPrompt(pattern: string, flags: string, input: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Prompt for suggesting regex improvements
|
|
30
|
+
*/
|
|
31
|
+
export declare function createSuggestImprovementsPrompt(pattern: string, flags: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Prompt for generating test cases
|
|
34
|
+
*/
|
|
35
|
+
export declare function createGenerateTestCasesPrompt(pattern: string, flags: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Prompt for validating regex for issues
|
|
38
|
+
*/
|
|
39
|
+
export declare function createValidatePrompt(pattern: string, flags: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Prompt for converting regex to readable format
|
|
42
|
+
*/
|
|
43
|
+
export declare function createToReadablePrompt(pattern: string, flags: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Prompt for suggesting related patterns
|
|
46
|
+
*/
|
|
47
|
+
export declare function createSuggestRelatedPrompt(pattern: string, flags: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Prompt for inferring data type matched by regex
|
|
50
|
+
*/
|
|
51
|
+
export declare function createInferDataTypePrompt(pattern: string, flags: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Prompt for simplifying regex
|
|
54
|
+
*/
|
|
55
|
+
export declare function createSimplifyPrompt(pattern: string, flags: string): string;
|
|
56
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/regexp/prompts.ts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AAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,MAAM,CAgBR;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAqB3E"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticRegExp
|
|
3
|
+
* A RegExp type with LLM-powered semantic understanding
|
|
4
|
+
*
|
|
5
|
+
* Provides semantic operations on regular expressions:
|
|
6
|
+
* - Natural language pattern creation
|
|
7
|
+
* - Human-readable explanation
|
|
8
|
+
* - Test case generation
|
|
9
|
+
* - Pattern validation and improvement suggestions
|
|
10
|
+
* - Data type inference
|
|
11
|
+
*/
|
|
12
|
+
import type { LLMClient } from '../../llm/client.ts';
|
|
13
|
+
import type { SemanticEqualsResult, ImprovementSuggestion, RegExpTestCases, ValidateResultWithWarnings, RelatedSuggestion, InferTypeResult } from '../../shared/types.ts';
|
|
14
|
+
import type { Semantic, Explainable, TypeInferable } from '../../shared/interfaces.ts';
|
|
15
|
+
/** Options for creating regex from natural language */
|
|
16
|
+
export interface FromOptions {
|
|
17
|
+
flags?: string;
|
|
18
|
+
strict?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** Result of testWithExplanation */
|
|
21
|
+
export interface TestWithExplanationResult {
|
|
22
|
+
matches: boolean;
|
|
23
|
+
reason: string;
|
|
24
|
+
matchedPart?: string;
|
|
25
|
+
}
|
|
26
|
+
/** Result of simplify operation */
|
|
27
|
+
export interface SimplifyResult {
|
|
28
|
+
regex: SemanticRegExp;
|
|
29
|
+
explanation: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* SemanticRegExp - Regular expression with LLM-powered semantic understanding
|
|
33
|
+
*
|
|
34
|
+
* Extends native RegExp functionality with semantic operations like
|
|
35
|
+
* natural language pattern creation, explanation, and intelligent analysis.
|
|
36
|
+
*/
|
|
37
|
+
export declare class SemanticRegExp implements Semantic<RegExp>, Explainable, TypeInferable {
|
|
38
|
+
private readonly regex;
|
|
39
|
+
private readonly client;
|
|
40
|
+
private constructor();
|
|
41
|
+
/**
|
|
42
|
+
* Create a SemanticRegExp from an existing RegExp
|
|
43
|
+
*/
|
|
44
|
+
static fromRegExp(regex: RegExp, client?: LLMClient): SemanticRegExp;
|
|
45
|
+
/**
|
|
46
|
+
* Create a SemanticRegExp from a pattern string
|
|
47
|
+
*/
|
|
48
|
+
static fromPattern(pattern: string, flags?: string, client?: LLMClient): SemanticRegExp;
|
|
49
|
+
/**
|
|
50
|
+
* Create a regex from natural language description using LLM
|
|
51
|
+
*
|
|
52
|
+
* @param description - Natural language pattern description
|
|
53
|
+
* @param options - Creation options
|
|
54
|
+
* @param client - Optional LLM client
|
|
55
|
+
* @returns SemanticRegExp instance
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* SemanticRegExp.from("email addresses")
|
|
59
|
+
* SemanticRegExp.from("phone numbers in US format")
|
|
60
|
+
* SemanticRegExp.from("URLs starting with https")
|
|
61
|
+
*/
|
|
62
|
+
static from(description: string, options?: FromOptions, client?: LLMClient): Promise<SemanticRegExp>;
|
|
63
|
+
/**
|
|
64
|
+
* Get the underlying RegExp value
|
|
65
|
+
*/
|
|
66
|
+
valueOf(): RegExp;
|
|
67
|
+
/**
|
|
68
|
+
* Get the regex source pattern
|
|
69
|
+
*/
|
|
70
|
+
get source(): string;
|
|
71
|
+
/**
|
|
72
|
+
* Get the regex flags
|
|
73
|
+
*/
|
|
74
|
+
get flags(): string;
|
|
75
|
+
/**
|
|
76
|
+
* Test if a string matches the regex
|
|
77
|
+
*/
|
|
78
|
+
test(input: string): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Execute the regex on a string
|
|
81
|
+
*/
|
|
82
|
+
exec(input: string): RegExpExecArray | null;
|
|
83
|
+
/**
|
|
84
|
+
* Check if two regexes match the same patterns semantically
|
|
85
|
+
*
|
|
86
|
+
* @param other - RegExp to compare
|
|
87
|
+
* @param testStrings - Optional strings to test against
|
|
88
|
+
* @returns Equivalence result with confidence
|
|
89
|
+
*/
|
|
90
|
+
semanticallyEquals(other: RegExp | SemanticRegExp, testStrings?: string[]): Promise<SemanticEqualsResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Explain what the regex matches in plain language
|
|
93
|
+
*
|
|
94
|
+
* @param context - Optional context for more relevant explanation
|
|
95
|
+
* @returns Human-readable explanation
|
|
96
|
+
*/
|
|
97
|
+
explain(context?: string): Promise<string>;
|
|
98
|
+
/**
|
|
99
|
+
* Test a string and explain why it matched or didn't
|
|
100
|
+
*
|
|
101
|
+
* @param input - String to test
|
|
102
|
+
* @returns Match result with explanation
|
|
103
|
+
*/
|
|
104
|
+
testWithExplanation(input: string): Promise<TestWithExplanationResult>;
|
|
105
|
+
/**
|
|
106
|
+
* Suggest improvements to the regex
|
|
107
|
+
*
|
|
108
|
+
* @returns Suggested improvements
|
|
109
|
+
*/
|
|
110
|
+
suggestImprovements(): Promise<ImprovementSuggestion[]>;
|
|
111
|
+
/**
|
|
112
|
+
* Generate test cases for the regex
|
|
113
|
+
*
|
|
114
|
+
* @returns Test cases with strings that should and shouldn't match
|
|
115
|
+
*/
|
|
116
|
+
generateTestCases(): Promise<RegExpTestCases>;
|
|
117
|
+
/**
|
|
118
|
+
* Validate the regex for common issues
|
|
119
|
+
*
|
|
120
|
+
* @returns Validation result with issues and warnings
|
|
121
|
+
*/
|
|
122
|
+
validate(): Promise<ValidateResultWithWarnings>;
|
|
123
|
+
/**
|
|
124
|
+
* Convert to a more readable format
|
|
125
|
+
*
|
|
126
|
+
* @returns Readable regex representation
|
|
127
|
+
*/
|
|
128
|
+
toReadable(): Promise<string>;
|
|
129
|
+
/**
|
|
130
|
+
* Find similar patterns that might also be needed
|
|
131
|
+
*
|
|
132
|
+
* @returns Related patterns with reasons
|
|
133
|
+
*/
|
|
134
|
+
suggestRelated(): Promise<RelatedSuggestion[]>;
|
|
135
|
+
/**
|
|
136
|
+
* Detect what type of data this regex is designed to match
|
|
137
|
+
*
|
|
138
|
+
* @returns Inferred data type with confidence
|
|
139
|
+
*/
|
|
140
|
+
inferDataType(): Promise<InferTypeResult>;
|
|
141
|
+
/**
|
|
142
|
+
* Alias for inferDataType to match TypeInferable interface
|
|
143
|
+
*/
|
|
144
|
+
inferType(): Promise<InferTypeResult>;
|
|
145
|
+
/**
|
|
146
|
+
* Simplify the regex if possible
|
|
147
|
+
*
|
|
148
|
+
* @returns Simplified version with explanation, or null if not simplifiable
|
|
149
|
+
*/
|
|
150
|
+
simplify(): Promise<SimplifyResult | null>;
|
|
151
|
+
/**
|
|
152
|
+
* Convert to string representation
|
|
153
|
+
*/
|
|
154
|
+
toString(): string;
|
|
155
|
+
/**
|
|
156
|
+
* String tag for type identification
|
|
157
|
+
*/
|
|
158
|
+
readonly [Symbol.toStringTag] = "SemanticRegExp";
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=regexp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regexp.d.ts","sourceRoot":"","sources":["../../../src/types/regexp/regexp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,iBAAiB,EACjB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAgBvF,uDAAuD;AACvD,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,oCAAoC;AACpC,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAA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E,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAgB5E;;;;OAIG;IACG,mBAAmB,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAoB7D;;;;OAIG;IACG,iBAAiB,IAAI,OAAO,CAAC,eAAe,CAAC;IAwBnD;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,0BAA0B,CAAC;IAuBrD;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAkBnC;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAwBpD;;;;OAIG;IACG,aAAa,IAAI,OAAO,CAAC,eAAe,CAAC;IAwB/C;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,eAAe,CAAC;IAI3C;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IA8BhD;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,oBAAoB;CAClD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticSet module
|
|
3
|
+
* A set type with LLM-powered semantic understanding
|
|
4
|
+
*/
|
|
5
|
+
export { SemanticSet, type SemanticHasResult, type SemanticAddResult, type SetSemanticEqualsResult, type SetSummarizeOptions, type SetValidateResult, type InferThemeResult, } from './set.ts';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/set/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,WAAW,EACX,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts for SemanticSet LLM operations
|
|
3
|
+
* These prompts enable semantic operations on set collections
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* System prompt for set semantic operations
|
|
7
|
+
*/
|
|
8
|
+
export declare const SET_SYSTEM_PROMPT = "You are a semantic set analyzer. Your task is to analyze sets and their elements to provide semantic understanding.\n\nYou must respond with valid JSON only, no additional text or explanation.\n\nGuidelines:\n- Consider element meanings, relationships, and uniqueness\n- Provide confidence scores from 0.0 to 1.0\n- Be precise and consistent in your analysis\n- Understand that sets represent unique value collections\n- Focus on semantic equivalence beyond exact string matching";
|
|
9
|
+
/**
|
|
10
|
+
* Prompt for semantic has (membership check)
|
|
11
|
+
*/
|
|
12
|
+
export declare function createSemanticHasPrompt(setValues: unknown[], query: unknown): string;
|
|
13
|
+
/**
|
|
14
|
+
* Prompt for semantic add (conditional add based on semantic equivalence)
|
|
15
|
+
*/
|
|
16
|
+
export declare function createSemanticAddPrompt(setValues: unknown[], value: unknown): string;
|
|
17
|
+
/**
|
|
18
|
+
* Prompt for semantic equality comparison between sets
|
|
19
|
+
*/
|
|
20
|
+
export declare function createSemanticallyEqualsPrompt(set1Values: unknown[], set2Values: unknown[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* Prompt for semantic intersection
|
|
23
|
+
*/
|
|
24
|
+
export declare function createSemanticIntersectionPrompt(set1Values: unknown[], set2Values: unknown[]): string;
|
|
25
|
+
/**
|
|
26
|
+
* Prompt for semantic union
|
|
27
|
+
*/
|
|
28
|
+
export declare function createSemanticUnionPrompt(set1Values: unknown[], set2Values: unknown[]): string;
|
|
29
|
+
/**
|
|
30
|
+
* Prompt for semantic difference
|
|
31
|
+
*/
|
|
32
|
+
export declare function createSemanticDifferencePrompt(set1Values: unknown[], set2Values: unknown[]): string;
|
|
33
|
+
/**
|
|
34
|
+
* Prompt for semantic filtering
|
|
35
|
+
*/
|
|
36
|
+
export declare function createSemanticFilterPrompt(setValues: unknown[], criteria: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Prompt for grouping set values
|
|
39
|
+
*/
|
|
40
|
+
export declare function createGroupByPrompt(setValues: unknown[], criteria: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Prompt for summarization
|
|
43
|
+
*/
|
|
44
|
+
export declare function createSummarizePrompt(setValues: unknown[], options?: {
|
|
45
|
+
maxLength?: number;
|
|
46
|
+
focus?: string;
|
|
47
|
+
}): string;
|
|
48
|
+
/**
|
|
49
|
+
* Prompt for suggesting related values
|
|
50
|
+
*/
|
|
51
|
+
export declare function createSuggestRelatedPrompt(setValues: unknown[]): string;
|
|
52
|
+
/**
|
|
53
|
+
* Prompt for validation against rules
|
|
54
|
+
*/
|
|
55
|
+
export declare function createValidatePrompt(setValues: unknown[], rules: string[]): string;
|
|
56
|
+
/**
|
|
57
|
+
* Prompt for inferring the theme of a set
|
|
58
|
+
*/
|
|
59
|
+
export declare function createInferThemePrompt(setValues: unknown[]): string;
|
|
60
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/set/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB,oeAS+B,CAAC;AAE9D;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,OAAO,EAAE,EACpB,KAAK,EAAE,OAAO,GACb,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,OAAO,EAAE,EACpB,KAAK,EAAE,OAAO,GACb,MAAM,CAkBR;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,OAAO,EAAE,EACrB,UAAU,EAAE,OAAO,EAAE,GACpB,MAAM,CAuBR;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,OAAO,EAAE,EACr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