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,799 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared interfaces for semantic primitives
|
|
3
|
+
*
|
|
4
|
+
* This file defines the core abstractions used across all semantic types:
|
|
5
|
+
* - Base interfaces for all semantic wrappers
|
|
6
|
+
* - Capability mixin interfaces (composable behaviors)
|
|
7
|
+
* - Category-specific interfaces
|
|
8
|
+
* - LLM client abstraction
|
|
9
|
+
*/
|
|
10
|
+
import type { SemanticEqualsResult, SemanticEqualsResultWithReason, SemanticEqualsResultWithMappings, ValidateResult, ClassifyResult, InferTypeResult, InferPurposeResult, ReasonableResult, SearchResult, MissingSuggestion, ImprovementSuggestion, SafetyResult, InferReasonResult } from './types.ts';
|
|
11
|
+
/**
|
|
12
|
+
* Interface for LLM client implementations.
|
|
13
|
+
* All semantic operations that require AI capabilities depend on this interface.
|
|
14
|
+
*/
|
|
15
|
+
export interface LLMClientInterface {
|
|
16
|
+
/**
|
|
17
|
+
* Send a completion request to the LLM.
|
|
18
|
+
*
|
|
19
|
+
* @param options - Request options including messages and temperature
|
|
20
|
+
* @returns Promise resolving to the LLM response content
|
|
21
|
+
*/
|
|
22
|
+
complete(options: LLMCompletionOptions): Promise<string>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Options for LLM completion requests.
|
|
26
|
+
*/
|
|
27
|
+
export interface LLMCompletionOptions {
|
|
28
|
+
/** System prompt setting the context for the LLM */
|
|
29
|
+
systemPrompt?: string;
|
|
30
|
+
/** User message/prompt for the completion */
|
|
31
|
+
userPrompt: string;
|
|
32
|
+
/** Temperature for response randomness (0-1, lower = more deterministic) */
|
|
33
|
+
temperature?: number;
|
|
34
|
+
/** Maximum tokens in the response */
|
|
35
|
+
maxTokens?: number;
|
|
36
|
+
/** Expected response format */
|
|
37
|
+
responseFormat?: 'text' | 'json';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Base interface for all semantic type wrappers.
|
|
41
|
+
* Every semantic type must be able to return its underlying value.
|
|
42
|
+
*
|
|
43
|
+
* @template T - The underlying native type being wrapped
|
|
44
|
+
*
|
|
45
|
+
* Used by: All 26 semantic types
|
|
46
|
+
*/
|
|
47
|
+
export interface Semantic<T> {
|
|
48
|
+
/**
|
|
49
|
+
* Get the underlying native value.
|
|
50
|
+
* @returns The wrapped primitive or object value
|
|
51
|
+
*/
|
|
52
|
+
valueOf(): T;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Base interface for semantic types that can be constructed with context.
|
|
56
|
+
* Provides the common factory method pattern.
|
|
57
|
+
*
|
|
58
|
+
* @template T - The semantic type being created
|
|
59
|
+
* @template TInput - The input type(s) accepted
|
|
60
|
+
*
|
|
61
|
+
* Used by: SemanticString, SemanticNumber, SemanticBoolean, SemanticBigInt,
|
|
62
|
+
* SemanticDate, SemanticError, SemanticURL, SemanticRegExp, SemanticPromise,
|
|
63
|
+
* SemanticFunction, SemanticArray, SemanticObject, SemanticMap, SemanticSet,
|
|
64
|
+
* SemanticTuple, SemanticRecord, SemanticCallable, SemanticConstructable,
|
|
65
|
+
* SemanticObjectLiteral, SemanticAny, SemanticUnknown
|
|
66
|
+
*/
|
|
67
|
+
export interface SemanticFactory<T, TInput = unknown> {
|
|
68
|
+
/**
|
|
69
|
+
* Create a semantic wrapper from input value.
|
|
70
|
+
*
|
|
71
|
+
* @param input - The value to wrap
|
|
72
|
+
* @param context - Optional context for interpretation
|
|
73
|
+
* @param client - Optional LLM client for dependency injection
|
|
74
|
+
* @returns The semantic wrapper instance
|
|
75
|
+
*/
|
|
76
|
+
from(input: TInput, context?: string | Record<string, unknown>, client?: LLMClientInterface): T;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Capability for semantic equality comparison.
|
|
80
|
+
* Types implementing this can be compared for semantic equivalence.
|
|
81
|
+
*
|
|
82
|
+
* @template T - The type being compared
|
|
83
|
+
* @template TResult - The comparison result type
|
|
84
|
+
*
|
|
85
|
+
* Used by: 24 of 26 semantic types (all except SemanticPromise, SemanticNever)
|
|
86
|
+
*/
|
|
87
|
+
export interface Comparable<T, TResult extends SemanticEqualsResult = SemanticEqualsResult> {
|
|
88
|
+
/**
|
|
89
|
+
* Check if this value is semantically equivalent to another.
|
|
90
|
+
*
|
|
91
|
+
* @param other - The value to compare with
|
|
92
|
+
* @param options - Optional comparison options
|
|
93
|
+
* @returns Equivalence result with confidence score (sync or async)
|
|
94
|
+
*/
|
|
95
|
+
semanticallyEquals(other: T, options?: Record<string, unknown>): TResult | Promise<TResult>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Capability for generating human-readable explanations.
|
|
99
|
+
* Types implementing this can explain themselves in natural language.
|
|
100
|
+
*
|
|
101
|
+
* Used by: SemanticString, SemanticNumber, SemanticBigInt, SemanticDate,
|
|
102
|
+
* SemanticError, SemanticURL, SemanticPromise, SemanticFunction,
|
|
103
|
+
* SemanticSymbol, SemanticTuple, SemanticCallable, SemanticConstructable,
|
|
104
|
+
* SemanticNull, SemanticUndefined, SemanticAny, SemanticUnknown
|
|
105
|
+
*/
|
|
106
|
+
export interface Explainable {
|
|
107
|
+
/**
|
|
108
|
+
* Generate a human-readable explanation.
|
|
109
|
+
*
|
|
110
|
+
* @param context - Optional context for more relevant explanation
|
|
111
|
+
* @returns Human-readable description (sync or async)
|
|
112
|
+
*/
|
|
113
|
+
explain(context?: string): string | Promise<string>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Extended explainable with describe method.
|
|
117
|
+
*
|
|
118
|
+
* Used by: SemanticNumber, SemanticBigInt, SemanticDate, SemanticSymbol
|
|
119
|
+
*/
|
|
120
|
+
export interface Describable extends Explainable {
|
|
121
|
+
/**
|
|
122
|
+
* Describe the value in context.
|
|
123
|
+
*
|
|
124
|
+
* @param context - Optional context for description
|
|
125
|
+
* @returns Human-readable description (sync or async)
|
|
126
|
+
*/
|
|
127
|
+
describe(context?: string): string | Promise<string>;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Capability for validation against semantic rules.
|
|
131
|
+
* Types implementing this can validate their values using natural language rules.
|
|
132
|
+
*
|
|
133
|
+
* @template TResult - The validation result type
|
|
134
|
+
*
|
|
135
|
+
* Used by: SemanticString, SemanticArray, SemanticObject, SemanticMap,
|
|
136
|
+
* SemanticSet, SemanticSymbol, SemanticRegExp, SemanticFunction,
|
|
137
|
+
* SemanticTuple, SemanticRecord, SemanticCallable, SemanticConstructable
|
|
138
|
+
*/
|
|
139
|
+
export interface Validatable<TResult extends ValidateResult = ValidateResult> {
|
|
140
|
+
/**
|
|
141
|
+
* Validate the value against semantic rules.
|
|
142
|
+
*
|
|
143
|
+
* @param rules - Natural language validation rules
|
|
144
|
+
* @returns Validation result with issues (sync or async)
|
|
145
|
+
*/
|
|
146
|
+
validate(rules: string[]): TResult | Promise<TResult>;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Capability for context-aware reasonableness checks.
|
|
150
|
+
* Types implementing this can assess if their value is reasonable for a given context.
|
|
151
|
+
*
|
|
152
|
+
* Used by: SemanticNumber, SemanticBigInt, SemanticDate
|
|
153
|
+
*/
|
|
154
|
+
export interface ContextValidatable {
|
|
155
|
+
/**
|
|
156
|
+
* Check if the value is reasonable for a given context.
|
|
157
|
+
*
|
|
158
|
+
* @param context - The context to validate against
|
|
159
|
+
* @returns Reasonableness assessment with explanation (sync or async)
|
|
160
|
+
*/
|
|
161
|
+
isReasonable(context: string): ReasonableResult | Promise<ReasonableResult>;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Capability for purpose/use-case validation.
|
|
165
|
+
*
|
|
166
|
+
* Used by: SemanticURL, SemanticSymbol, SemanticVoid
|
|
167
|
+
*/
|
|
168
|
+
export interface PurposeValidatable {
|
|
169
|
+
/**
|
|
170
|
+
* Validate the value for a specific purpose.
|
|
171
|
+
*
|
|
172
|
+
* @param purpose - The intended use case
|
|
173
|
+
* @returns Validation result
|
|
174
|
+
*/
|
|
175
|
+
validateFor?(purpose: string): {
|
|
176
|
+
valid: boolean;
|
|
177
|
+
reason?: string;
|
|
178
|
+
warnings?: string[];
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Check if appropriate for a use case.
|
|
182
|
+
*
|
|
183
|
+
* @param useCase - The intended use case
|
|
184
|
+
* @returns Appropriateness assessment
|
|
185
|
+
*/
|
|
186
|
+
isAppropriateFor?(useCase: string): {
|
|
187
|
+
appropriate: boolean;
|
|
188
|
+
reason: string;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Capability for type inference.
|
|
193
|
+
* Types implementing this can infer semantic type information.
|
|
194
|
+
*
|
|
195
|
+
* Used by: SemanticObject, SemanticArray, SemanticSet, SemanticRegExp,
|
|
196
|
+
* SemanticUnknown, SemanticAny
|
|
197
|
+
*/
|
|
198
|
+
export interface TypeInferable {
|
|
199
|
+
/**
|
|
200
|
+
* Infer the semantic type of this value.
|
|
201
|
+
*
|
|
202
|
+
* @returns Inferred type with confidence (sync or async)
|
|
203
|
+
*/
|
|
204
|
+
inferType(): InferTypeResult | Promise<InferTypeResult>;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Capability for purpose inference.
|
|
208
|
+
*
|
|
209
|
+
* Used by: SemanticFunction, SemanticMap, SemanticRecord, SemanticCallable
|
|
210
|
+
*/
|
|
211
|
+
export interface PurposeInferable {
|
|
212
|
+
/**
|
|
213
|
+
* Infer the purpose of this value.
|
|
214
|
+
*
|
|
215
|
+
* @returns Inferred purpose with confidence (sync or async)
|
|
216
|
+
*/
|
|
217
|
+
inferPurpose(): InferPurposeResult | Promise<InferPurposeResult>;
|
|
218
|
+
}
|
|
219
|
+
/** Schema inference result type */
|
|
220
|
+
export interface InferSchemaResultType {
|
|
221
|
+
type?: string;
|
|
222
|
+
name?: string;
|
|
223
|
+
properties?: Record<string, string | {
|
|
224
|
+
type: string;
|
|
225
|
+
purpose?: string;
|
|
226
|
+
}>;
|
|
227
|
+
fields?: Record<string, {
|
|
228
|
+
type: string;
|
|
229
|
+
purpose: string;
|
|
230
|
+
format?: string;
|
|
231
|
+
}>;
|
|
232
|
+
required?: string[];
|
|
233
|
+
optional?: string[];
|
|
234
|
+
confidence: number;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Capability for schema inference.
|
|
238
|
+
*
|
|
239
|
+
* Used by: SemanticObject, SemanticObjectLiteral
|
|
240
|
+
*/
|
|
241
|
+
export interface SchemaInferable {
|
|
242
|
+
/**
|
|
243
|
+
* Infer the schema of this value.
|
|
244
|
+
*
|
|
245
|
+
* @returns Inferred schema with field descriptions (sync or async)
|
|
246
|
+
*/
|
|
247
|
+
inferSchema(): InferSchemaResultType | Promise<InferSchemaResultType>;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Capability for classification into categories.
|
|
251
|
+
*
|
|
252
|
+
* Used by: SemanticString, SemanticSymbol, SemanticURL, SemanticError,
|
|
253
|
+
* SemanticNull, SemanticUndefined
|
|
254
|
+
*/
|
|
255
|
+
export interface Classifiable<TResult extends ClassifyResult = ClassifyResult> {
|
|
256
|
+
/**
|
|
257
|
+
* Classify the value into a category.
|
|
258
|
+
*
|
|
259
|
+
* @returns Classification result (sync or async)
|
|
260
|
+
*/
|
|
261
|
+
classify(...args: unknown[]): TResult | Promise<TResult>;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Capability for pattern detection.
|
|
265
|
+
*
|
|
266
|
+
* Used by: SemanticArray, SemanticTuple, SemanticConstructable
|
|
267
|
+
*/
|
|
268
|
+
export interface PatternDetectable {
|
|
269
|
+
/**
|
|
270
|
+
* Detect patterns in the value.
|
|
271
|
+
*
|
|
272
|
+
* @returns Detected patterns
|
|
273
|
+
*/
|
|
274
|
+
detectPatterns?(): {
|
|
275
|
+
patterns: string[];
|
|
276
|
+
anomalies?: {
|
|
277
|
+
index: number;
|
|
278
|
+
reason: string;
|
|
279
|
+
}[];
|
|
280
|
+
confidence?: number;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Detect single pattern.
|
|
284
|
+
*
|
|
285
|
+
* @returns Detected pattern
|
|
286
|
+
*/
|
|
287
|
+
detectPattern?(): {
|
|
288
|
+
pattern: string;
|
|
289
|
+
confidence: number;
|
|
290
|
+
suggestedType?: string;
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Capability for suggesting improvements or additions.
|
|
295
|
+
*
|
|
296
|
+
* Used by: SemanticObject, SemanticMap, SemanticSet, SemanticRecord,
|
|
297
|
+
* SemanticFunction, SemanticRegExp, SemanticCallable, SemanticConstructable
|
|
298
|
+
*/
|
|
299
|
+
export interface Suggestible {
|
|
300
|
+
/**
|
|
301
|
+
* Suggest improvements for this value.
|
|
302
|
+
*
|
|
303
|
+
* @returns Suggested improvements
|
|
304
|
+
*/
|
|
305
|
+
suggestImprovements?(): ImprovementSuggestion[];
|
|
306
|
+
/**
|
|
307
|
+
* Suggest missing fields/keys.
|
|
308
|
+
*
|
|
309
|
+
* @returns Suggested additions
|
|
310
|
+
*/
|
|
311
|
+
suggestMissingFields?(): MissingSuggestion[];
|
|
312
|
+
suggestMissingKeys?(): MissingSuggestion[];
|
|
313
|
+
/**
|
|
314
|
+
* Suggest related items.
|
|
315
|
+
*
|
|
316
|
+
* @returns Related suggestions
|
|
317
|
+
*/
|
|
318
|
+
suggestRelated?(): {
|
|
319
|
+
value?: string;
|
|
320
|
+
url?: string;
|
|
321
|
+
pattern?: string;
|
|
322
|
+
reason: string;
|
|
323
|
+
}[];
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Capability for summarization.
|
|
327
|
+
*
|
|
328
|
+
* Used by: SemanticString, SemanticArray, SemanticObject, SemanticMap,
|
|
329
|
+
* SemanticSet, SemanticRecord, SemanticObjectLiteral
|
|
330
|
+
*/
|
|
331
|
+
export interface Summarizable {
|
|
332
|
+
/**
|
|
333
|
+
* Generate a summary of the value.
|
|
334
|
+
*
|
|
335
|
+
* @param options - Optional summarization options (or maxLength for backwards compatibility)
|
|
336
|
+
* @returns Human-readable summary (sync or async)
|
|
337
|
+
*/
|
|
338
|
+
summarize(options?: {
|
|
339
|
+
maxLength?: number;
|
|
340
|
+
focus?: string;
|
|
341
|
+
} | number): string | Promise<string>;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Capability for safety assessment.
|
|
345
|
+
*
|
|
346
|
+
* Used by: SemanticURL, SemanticFunction, SemanticCallable, SemanticAny
|
|
347
|
+
*/
|
|
348
|
+
export interface SafetyAssessable {
|
|
349
|
+
/**
|
|
350
|
+
* Check if the value is safe for a given context.
|
|
351
|
+
*
|
|
352
|
+
* @param context - Optional context for safety check
|
|
353
|
+
* @returns Safety assessment
|
|
354
|
+
*/
|
|
355
|
+
isSafe?(context?: string): SafetyResult;
|
|
356
|
+
/**
|
|
357
|
+
* Check if safe to call with arguments.
|
|
358
|
+
*
|
|
359
|
+
* @param args - Arguments to check
|
|
360
|
+
* @returns Safety assessment
|
|
361
|
+
*/
|
|
362
|
+
isSafeToCall?(args: unknown[]): SafetyResult;
|
|
363
|
+
/**
|
|
364
|
+
* Check if safe for specific use.
|
|
365
|
+
*
|
|
366
|
+
* @param context - Use context
|
|
367
|
+
* @returns Safety assessment
|
|
368
|
+
*/
|
|
369
|
+
isSafeFor?(context: string): SafetyResult;
|
|
370
|
+
}
|
|
371
|
+
/** Sensitivity assessment result */
|
|
372
|
+
export interface SensitivityAssessment {
|
|
373
|
+
sensitive?: boolean;
|
|
374
|
+
hasSensitive?: boolean;
|
|
375
|
+
types?: string[];
|
|
376
|
+
type?: string;
|
|
377
|
+
recommendation?: string;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Capability for sensitivity detection.
|
|
381
|
+
*
|
|
382
|
+
* Used by: SemanticString, SemanticObject, SemanticObjectLiteral
|
|
383
|
+
*/
|
|
384
|
+
export interface SensitivityDetectable {
|
|
385
|
+
/**
|
|
386
|
+
* Check for sensitive data.
|
|
387
|
+
*
|
|
388
|
+
* @param field - Optional field to check
|
|
389
|
+
* @returns Sensitivity assessment (sync or async)
|
|
390
|
+
*/
|
|
391
|
+
isSensitive?(field?: string): SensitivityAssessment | Promise<SensitivityAssessment>;
|
|
392
|
+
/**
|
|
393
|
+
* Check if value contains sensitive information.
|
|
394
|
+
*
|
|
395
|
+
* @returns Sensitivity assessment (sync or async)
|
|
396
|
+
*/
|
|
397
|
+
containsSensitive?(): {
|
|
398
|
+
hasSensitive: boolean;
|
|
399
|
+
types: string[];
|
|
400
|
+
} | Promise<{
|
|
401
|
+
hasSensitive: boolean;
|
|
402
|
+
types: string[];
|
|
403
|
+
}>;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Capability for semantic filtering.
|
|
407
|
+
*
|
|
408
|
+
* @template TSelf - The collection type (for return type)
|
|
409
|
+
*
|
|
410
|
+
* Used by: SemanticArray, SemanticSet, SemanticRecord
|
|
411
|
+
*/
|
|
412
|
+
export interface SemanticFilterable<TSelf> {
|
|
413
|
+
/**
|
|
414
|
+
* Filter elements using natural language criteria.
|
|
415
|
+
*
|
|
416
|
+
* @param criteria - Natural language filter condition
|
|
417
|
+
* @returns Filtered collection
|
|
418
|
+
*/
|
|
419
|
+
semanticFilter(criteria: string): TSelf;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Capability for semantic sorting.
|
|
423
|
+
*
|
|
424
|
+
* @template TSelf - The collection type (for return type)
|
|
425
|
+
*
|
|
426
|
+
* Used by: SemanticArray
|
|
427
|
+
*/
|
|
428
|
+
export interface SemanticSortable<TSelf> {
|
|
429
|
+
/**
|
|
430
|
+
* Sort elements using semantic understanding.
|
|
431
|
+
*
|
|
432
|
+
* @param criteria - Natural language sort criteria
|
|
433
|
+
* @returns Sorted collection
|
|
434
|
+
*/
|
|
435
|
+
semanticSort(criteria: string): TSelf;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Capability for semantic grouping.
|
|
439
|
+
*
|
|
440
|
+
* @template TSelf - The collection type (for group values)
|
|
441
|
+
*
|
|
442
|
+
* Used by: SemanticArray, SemanticSet, SemanticMap, SemanticRecord
|
|
443
|
+
*/
|
|
444
|
+
export interface SemanticGroupable<TSelf> {
|
|
445
|
+
/**
|
|
446
|
+
* Group elements by semantic criteria.
|
|
447
|
+
*
|
|
448
|
+
* @param criteria - Grouping criteria
|
|
449
|
+
* @returns Map of groups
|
|
450
|
+
*/
|
|
451
|
+
semanticGroup?(criteria: string): Map<string, TSelf>;
|
|
452
|
+
groupBy?(criteria: string): Map<string, TSelf>;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Capability for semantic search.
|
|
456
|
+
*
|
|
457
|
+
* @template T - The element type
|
|
458
|
+
*
|
|
459
|
+
* Used by: SemanticArray, SemanticMap, SemanticRecord
|
|
460
|
+
*/
|
|
461
|
+
export interface SemanticSearchable<T> {
|
|
462
|
+
/**
|
|
463
|
+
* Find elements matching semantic criteria.
|
|
464
|
+
*
|
|
465
|
+
* @param criteria - Natural language search criteria
|
|
466
|
+
* @param options - Search options
|
|
467
|
+
* @returns Matching elements with relevance scores
|
|
468
|
+
*/
|
|
469
|
+
semanticSearch(criteria: string, options?: {
|
|
470
|
+
limit?: number;
|
|
471
|
+
}): SearchResult<T>[];
|
|
472
|
+
}
|
|
473
|
+
/** Semantic get result type */
|
|
474
|
+
export interface SemanticGetResultType<K, V> {
|
|
475
|
+
value: V | undefined;
|
|
476
|
+
matchedKey: K | undefined;
|
|
477
|
+
confidence: number;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Capability for semantic key-based access.
|
|
481
|
+
*
|
|
482
|
+
* @template K - The key type
|
|
483
|
+
* @template V - The value type
|
|
484
|
+
*
|
|
485
|
+
* Used by: SemanticObject, SemanticMap, SemanticRecord
|
|
486
|
+
*/
|
|
487
|
+
export interface SemanticAccessible<K, V> {
|
|
488
|
+
/**
|
|
489
|
+
* Get a value using semantic key matching.
|
|
490
|
+
*
|
|
491
|
+
* @param query - Key or semantic query
|
|
492
|
+
* @param context - Optional context
|
|
493
|
+
* @returns Value with match confidence (sync or async)
|
|
494
|
+
*/
|
|
495
|
+
semanticGet(query: string, context?: Record<string, unknown>): SemanticGetResultType<K, V> | Promise<SemanticGetResultType<K, V>>;
|
|
496
|
+
/**
|
|
497
|
+
* Check if key semantically exists.
|
|
498
|
+
*
|
|
499
|
+
* @param query - Key or semantic query
|
|
500
|
+
* @returns Whether a matching key exists (sync or async)
|
|
501
|
+
*/
|
|
502
|
+
semanticHas?(query: string): boolean | Promise<boolean>;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Capability for semantic set operations.
|
|
506
|
+
*
|
|
507
|
+
* @template TSelf - The set type
|
|
508
|
+
*
|
|
509
|
+
* Used by: SemanticSet
|
|
510
|
+
*/
|
|
511
|
+
export interface SemanticSetOperations<TSelf> {
|
|
512
|
+
/**
|
|
513
|
+
* Semantic intersection with another set.
|
|
514
|
+
*/
|
|
515
|
+
semanticIntersection(other: unknown): TSelf;
|
|
516
|
+
/**
|
|
517
|
+
* Semantic union with another set.
|
|
518
|
+
*/
|
|
519
|
+
semanticUnion(other: unknown): TSelf;
|
|
520
|
+
/**
|
|
521
|
+
* Semantic difference from another set.
|
|
522
|
+
*/
|
|
523
|
+
semanticDifference(other: unknown): TSelf;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Capability for semantic merging.
|
|
527
|
+
*
|
|
528
|
+
* @template TSelf - The collection type
|
|
529
|
+
*
|
|
530
|
+
* Used by: SemanticObject, SemanticMap
|
|
531
|
+
*/
|
|
532
|
+
export interface SemanticMergeable<TSelf> {
|
|
533
|
+
/**
|
|
534
|
+
* Merge with another collection using semantic key matching.
|
|
535
|
+
*
|
|
536
|
+
* @param other - Collection to merge
|
|
537
|
+
* @param options - Merge options
|
|
538
|
+
* @returns Merged collection
|
|
539
|
+
*/
|
|
540
|
+
semanticMerge(other: unknown, options?: {
|
|
541
|
+
conflictResolution?: 'prefer-this' | 'prefer-other' | 'combine';
|
|
542
|
+
}): TSelf;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Interface for semantic types representing absence (null, undefined).
|
|
546
|
+
*
|
|
547
|
+
* @template T - The absence type (null or undefined)
|
|
548
|
+
*
|
|
549
|
+
* Used by: SemanticNull, SemanticUndefined
|
|
550
|
+
*/
|
|
551
|
+
export interface SemanticAbsence<T extends null | undefined> extends Semantic<T> {
|
|
552
|
+
/**
|
|
553
|
+
* Create with context about why the value is absent.
|
|
554
|
+
*
|
|
555
|
+
* @param reason - Reason for absence
|
|
556
|
+
* @returns Semantic absence instance
|
|
557
|
+
*/
|
|
558
|
+
/**
|
|
559
|
+
* Get the reason for absence, if provided.
|
|
560
|
+
*
|
|
561
|
+
* @returns The reason string or undefined
|
|
562
|
+
*/
|
|
563
|
+
getReason(): string | undefined;
|
|
564
|
+
/**
|
|
565
|
+
* Classify the type of absence.
|
|
566
|
+
*
|
|
567
|
+
* @returns Classification result (sync or async)
|
|
568
|
+
*/
|
|
569
|
+
classify(): {
|
|
570
|
+
type: 'not-set' | 'not-applicable' | 'unknown';
|
|
571
|
+
canBeProvided: boolean;
|
|
572
|
+
} | Promise<{
|
|
573
|
+
type: 'not-set' | 'not-applicable' | 'unknown';
|
|
574
|
+
canBeProvided: boolean;
|
|
575
|
+
}>;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Static factory methods for absence types.
|
|
579
|
+
*
|
|
580
|
+
* Used by: SemanticNull, SemanticUndefined
|
|
581
|
+
*/
|
|
582
|
+
export interface SemanticAbsenceFactory<T> {
|
|
583
|
+
/**
|
|
584
|
+
* Create with reason for absence.
|
|
585
|
+
*/
|
|
586
|
+
because(reason: string, client?: LLMClientInterface): T;
|
|
587
|
+
/**
|
|
588
|
+
* Infer reason for absence from context.
|
|
589
|
+
*/
|
|
590
|
+
inferReason(fieldOrPath: string, context?: Record<string, unknown>): InferReasonResult;
|
|
591
|
+
/**
|
|
592
|
+
* Check if absence is appropriate for field/context.
|
|
593
|
+
*/
|
|
594
|
+
isAppropriate(fieldName: string, context?: {
|
|
595
|
+
required?: boolean;
|
|
596
|
+
schema?: unknown;
|
|
597
|
+
}): {
|
|
598
|
+
appropriate: boolean;
|
|
599
|
+
reason: string;
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Interface for semantic collection types.
|
|
604
|
+
* Combines common collection capabilities.
|
|
605
|
+
*
|
|
606
|
+
* @template T - The element type
|
|
607
|
+
* @template TSelf - The collection type itself
|
|
608
|
+
*
|
|
609
|
+
* Used by: SemanticArray, SemanticSet
|
|
610
|
+
*/
|
|
611
|
+
export interface SemanticCollection<T, TSelf> extends Semantic<T[]>, Comparable<T[]>, Validatable, Summarizable, SemanticFilterable<TSelf>, SemanticGroupable<TSelf> {
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Interface for semantic key-value collection types.
|
|
615
|
+
*
|
|
616
|
+
* @template K - The key type
|
|
617
|
+
* @template V - The value type
|
|
618
|
+
* @template TSelf - The collection type itself
|
|
619
|
+
*
|
|
620
|
+
* Used by: SemanticObject, SemanticMap, SemanticRecord
|
|
621
|
+
*/
|
|
622
|
+
export interface SemanticKeyValueCollection<K, V, TSelf> extends Semantic<Record<string, V> | Map<K, V>>, Comparable<unknown, SemanticEqualsResultWithMappings>, Validatable, Summarizable, SemanticAccessible<K, V>, SemanticMergeable<TSelf>, Suggestible {
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Interface for callable semantic types.
|
|
626
|
+
*
|
|
627
|
+
* @template TFn - The function type
|
|
628
|
+
*
|
|
629
|
+
* Used by: SemanticFunction, SemanticCallable
|
|
630
|
+
*/
|
|
631
|
+
export interface SemanticCallableType<TFn extends (...args: unknown[]) => unknown> extends Semantic<TFn>, Comparable<TFn>, Explainable, Validatable, Suggestible, SafetyAssessable {
|
|
632
|
+
/**
|
|
633
|
+
* Validate function arguments.
|
|
634
|
+
*/
|
|
635
|
+
validateArgs(args: unknown[], rules?: string[]): ValidateResult;
|
|
636
|
+
/**
|
|
637
|
+
* Generate test cases for the function.
|
|
638
|
+
*/
|
|
639
|
+
generateTests(): {
|
|
640
|
+
input?: unknown[];
|
|
641
|
+
inputs?: unknown[];
|
|
642
|
+
expectedOutput?: unknown;
|
|
643
|
+
description: string;
|
|
644
|
+
}[];
|
|
645
|
+
/**
|
|
646
|
+
* Call the underlying function.
|
|
647
|
+
*/
|
|
648
|
+
call(...args: Parameters<TFn>): ReturnType<TFn>;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Capability for key/property transformation.
|
|
652
|
+
*
|
|
653
|
+
* Used by: SemanticObject, SemanticObjectLiteral
|
|
654
|
+
*/
|
|
655
|
+
export interface KeyTransformable<TSelf> {
|
|
656
|
+
/**
|
|
657
|
+
* Transform property names to a different convention.
|
|
658
|
+
*
|
|
659
|
+
* @param convention - Target naming convention
|
|
660
|
+
* @returns Transformed instance
|
|
661
|
+
*/
|
|
662
|
+
transformKeys(convention: 'camelCase' | 'snake_case' | 'PascalCase' | 'kebab-case'): TSelf;
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Capability for unit conversion.
|
|
666
|
+
*
|
|
667
|
+
* Used by: SemanticNumber
|
|
668
|
+
*/
|
|
669
|
+
export interface UnitConvertible<TSelf> {
|
|
670
|
+
/**
|
|
671
|
+
* Convert to a different unit.
|
|
672
|
+
*
|
|
673
|
+
* @param toUnit - Target unit
|
|
674
|
+
* @param fromUnit - Source unit (optional, can be inferred)
|
|
675
|
+
* @returns Converted value (sync or async)
|
|
676
|
+
*/
|
|
677
|
+
convert(toUnit: string, fromUnit?: string): TSelf | Promise<TSelf>;
|
|
678
|
+
/**
|
|
679
|
+
* Infer the unit of this value.
|
|
680
|
+
*
|
|
681
|
+
* @param context - Context for inference
|
|
682
|
+
* @returns Inferred unit with confidence (sync or async)
|
|
683
|
+
*/
|
|
684
|
+
inferUnit(context: string): {
|
|
685
|
+
unit: string;
|
|
686
|
+
confidence: number;
|
|
687
|
+
} | Promise<{
|
|
688
|
+
unit: string;
|
|
689
|
+
confidence: number;
|
|
690
|
+
}>;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Capability for generating test cases.
|
|
694
|
+
*
|
|
695
|
+
* Used by: SemanticFunction, SemanticCallable, SemanticRegExp
|
|
696
|
+
*/
|
|
697
|
+
export interface TestGeneratable<TInput = unknown[], TOutput = unknown> {
|
|
698
|
+
/**
|
|
699
|
+
* Generate test cases for this value/function.
|
|
700
|
+
*
|
|
701
|
+
* @returns Generated test cases
|
|
702
|
+
*/
|
|
703
|
+
generateTests(): {
|
|
704
|
+
input?: TInput;
|
|
705
|
+
inputs?: TInput;
|
|
706
|
+
expectedOutput?: TOutput;
|
|
707
|
+
description: string;
|
|
708
|
+
}[];
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Test case generation for regex.
|
|
712
|
+
*
|
|
713
|
+
* Used by: SemanticRegExp
|
|
714
|
+
*/
|
|
715
|
+
export interface RegExpTestGeneratable {
|
|
716
|
+
/**
|
|
717
|
+
* Generate test strings for the regex.
|
|
718
|
+
*
|
|
719
|
+
* @returns Test cases with expected match results
|
|
720
|
+
*/
|
|
721
|
+
generateTestCases(): {
|
|
722
|
+
shouldMatch: string[];
|
|
723
|
+
shouldNotMatch: string[];
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Interface for semantic error types.
|
|
728
|
+
*
|
|
729
|
+
* Used by: SemanticError
|
|
730
|
+
*/
|
|
731
|
+
export interface SemanticErrorType extends Comparable<Error, SemanticEqualsResultWithReason>, Explainable, Classifiable {
|
|
732
|
+
/**
|
|
733
|
+
* Suggest fixes for the error.
|
|
734
|
+
*/
|
|
735
|
+
suggestFixes(): {
|
|
736
|
+
fix: string;
|
|
737
|
+
confidence: number;
|
|
738
|
+
code?: string;
|
|
739
|
+
}[] | Promise<{
|
|
740
|
+
fix: string;
|
|
741
|
+
confidence: number;
|
|
742
|
+
code?: string;
|
|
743
|
+
}[]>;
|
|
744
|
+
/**
|
|
745
|
+
* Infer the root cause.
|
|
746
|
+
*/
|
|
747
|
+
inferRootCause(): {
|
|
748
|
+
cause: string;
|
|
749
|
+
confidence: number;
|
|
750
|
+
} | Promise<{
|
|
751
|
+
cause: string;
|
|
752
|
+
confidence: number;
|
|
753
|
+
}>;
|
|
754
|
+
/**
|
|
755
|
+
* Get recovery strategy.
|
|
756
|
+
*/
|
|
757
|
+
recoveryStrategy(): {
|
|
758
|
+
strategy: 'retry' | 'fallback' | 'abort' | 'ignore';
|
|
759
|
+
maxAttempts?: number;
|
|
760
|
+
backoff?: string;
|
|
761
|
+
} | Promise<{
|
|
762
|
+
strategy: 'retry' | 'fallback' | 'abort' | 'ignore';
|
|
763
|
+
maxAttempts?: number;
|
|
764
|
+
backoff?: string;
|
|
765
|
+
}>;
|
|
766
|
+
/**
|
|
767
|
+
* Get severity level.
|
|
768
|
+
*/
|
|
769
|
+
getSeverity(): 'critical' | 'error' | 'warning' | 'info' | Promise<'critical' | 'error' | 'warning' | 'info'>;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Core capabilities shared by most semantic primitives.
|
|
773
|
+
*
|
|
774
|
+
* @template T - The underlying type
|
|
775
|
+
*
|
|
776
|
+
* Used by: SemanticString, SemanticNumber, SemanticBoolean, SemanticBigInt,
|
|
777
|
+
* SemanticSymbol
|
|
778
|
+
*/
|
|
779
|
+
export interface SemanticPrimitiveCapabilities<T> extends Semantic<T>, Comparable<T>, Explainable {
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* Extended capabilities for richer semantic primitives.
|
|
783
|
+
*
|
|
784
|
+
* @template T - The underlying type
|
|
785
|
+
*
|
|
786
|
+
* Used by: SemanticString, SemanticNumber, SemanticBigInt
|
|
787
|
+
*/
|
|
788
|
+
export interface SemanticPrimitiveExtended<T> extends SemanticPrimitiveCapabilities<T>, Describable, Validatable {
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Capabilities for semantic wrappers of reference types.
|
|
792
|
+
*
|
|
793
|
+
* @template T - The underlying type
|
|
794
|
+
*
|
|
795
|
+
* Used by: SemanticDate, SemanticURL, SemanticRegExp
|
|
796
|
+
*/
|
|
797
|
+
export interface SemanticReferenceCapabilities<T> extends Semantic<T>, Comparable<T>, Explainable, Validatable {
|
|
798
|
+
}
|
|
799
|
+
//# sourceMappingURL=interfaces.d.ts.map
|