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,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticObjectLiteral
|
|
3
|
+
* An object literal type with LLM-powered semantic understanding
|
|
4
|
+
*
|
|
5
|
+
* Implements shared interfaces for:
|
|
6
|
+
* - Semantic equality comparison with property mappings
|
|
7
|
+
* - Schema inference
|
|
8
|
+
* - Domain detection
|
|
9
|
+
* - Semantic property search
|
|
10
|
+
* - Sensitive data detection
|
|
11
|
+
* - Key transformation
|
|
12
|
+
* - Interface generation
|
|
13
|
+
*/
|
|
14
|
+
import type { LLMClient } from '../../llm/client.ts';
|
|
15
|
+
import type { SemanticEqualsResultWithMappings, InferSchemaResult, SensitiveResult } from '../../shared/types.ts';
|
|
16
|
+
export type { SemanticEqualsResultWithMappings, InferSchemaResult, SensitiveResult, } from '../../shared/types.ts';
|
|
17
|
+
/** Result of validation against semantic rules */
|
|
18
|
+
export interface ObjectLiteralValidateResult {
|
|
19
|
+
valid: boolean;
|
|
20
|
+
violations: {
|
|
21
|
+
rule: string;
|
|
22
|
+
field?: string;
|
|
23
|
+
reason: string;
|
|
24
|
+
}[];
|
|
25
|
+
}
|
|
26
|
+
/** Result of domain detection */
|
|
27
|
+
export interface DetectDomainResult {
|
|
28
|
+
domain: string;
|
|
29
|
+
confidence: number;
|
|
30
|
+
suggestedInterface?: string;
|
|
31
|
+
}
|
|
32
|
+
/** Result of property search */
|
|
33
|
+
export interface PropertySearchResult {
|
|
34
|
+
key: string;
|
|
35
|
+
value: unknown;
|
|
36
|
+
relevance: number;
|
|
37
|
+
}
|
|
38
|
+
/** Suggestion for missing property */
|
|
39
|
+
export interface MissingPropertySuggestion {
|
|
40
|
+
property: string;
|
|
41
|
+
type: string;
|
|
42
|
+
reason: string;
|
|
43
|
+
}
|
|
44
|
+
/** Key naming conventions */
|
|
45
|
+
export type KeyConvention = 'camelCase' | 'snake_case' | 'PascalCase' | 'kebab-case';
|
|
46
|
+
/**
|
|
47
|
+
* SemanticObjectLiteral - Object literal with LLM-powered semantic understanding
|
|
48
|
+
*
|
|
49
|
+
* Unlike SemanticObject which wraps general objects, SemanticObjectLiteral
|
|
50
|
+
* focuses on ad-hoc data shapes with schema inference and domain detection.
|
|
51
|
+
*
|
|
52
|
+
* @template T - The type of the underlying object
|
|
53
|
+
*/
|
|
54
|
+
export declare class SemanticObjectLiteral<T extends object = object> {
|
|
55
|
+
private readonly data;
|
|
56
|
+
private readonly context?;
|
|
57
|
+
private readonly client;
|
|
58
|
+
private constructor();
|
|
59
|
+
/**
|
|
60
|
+
* Create a SemanticObjectLiteral from a plain object.
|
|
61
|
+
*
|
|
62
|
+
* @param obj - Object literal
|
|
63
|
+
* @param context - Optional context about the object's purpose
|
|
64
|
+
* @returns SemanticObjectLiteral instance
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* SemanticObjectLiteral.from({ name: "John", age: 30 }, "user data")
|
|
68
|
+
*/
|
|
69
|
+
static from<T extends object>(obj: T, context?: string, client?: LLMClient): SemanticObjectLiteral<T>;
|
|
70
|
+
/**
|
|
71
|
+
* Get the underlying object value.
|
|
72
|
+
*
|
|
73
|
+
* @returns Plain object
|
|
74
|
+
*/
|
|
75
|
+
valueOf(): T;
|
|
76
|
+
/**
|
|
77
|
+
* Check if two object literals are semantically equivalent.
|
|
78
|
+
* Handles property name synonyms and structural variations.
|
|
79
|
+
*
|
|
80
|
+
* @param other - Object to compare
|
|
81
|
+
* @returns Equivalence result with property mappings
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* obj1.semanticallyEquals({ firstName: "John" })
|
|
85
|
+
* // { equivalent: true, mappings: { "name": "firstName" }, confidence: 0.9 }
|
|
86
|
+
*/
|
|
87
|
+
semanticallyEquals(other: SemanticObjectLiteral<T> | object): Promise<SemanticEqualsResultWithMappings>;
|
|
88
|
+
/**
|
|
89
|
+
* Infer the schema/type of this object.
|
|
90
|
+
*
|
|
91
|
+
* @returns Inferred schema with name, properties, required/optional fields
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* obj.inferSchema()
|
|
95
|
+
* // {
|
|
96
|
+
* // name: "User",
|
|
97
|
+
* // properties: { name: "string", age: "number" },
|
|
98
|
+
* // required: ["name"],
|
|
99
|
+
* // optional: ["age"],
|
|
100
|
+
* // confidence: 0.92
|
|
101
|
+
* // }
|
|
102
|
+
*/
|
|
103
|
+
inferSchema(): Promise<InferSchemaResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Validate the object against semantic rules.
|
|
106
|
+
*
|
|
107
|
+
* @param rules - Natural language validation rules
|
|
108
|
+
* @returns Validation result with violations
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* user.validateWithRules([
|
|
112
|
+
* "email must be valid",
|
|
113
|
+
* "age must be reasonable for a human"
|
|
114
|
+
* ])
|
|
115
|
+
*/
|
|
116
|
+
validateWithRules(rules: string[]): Promise<ObjectLiteralValidateResult>;
|
|
117
|
+
/**
|
|
118
|
+
* Detect what domain/entity this object represents.
|
|
119
|
+
*
|
|
120
|
+
* @returns Domain detection result
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* obj.detectDomain()
|
|
124
|
+
* // { domain: "user-profile", confidence: 0.92, suggestedInterface: "interface User { ... }" }
|
|
125
|
+
*/
|
|
126
|
+
detectDomain(): Promise<DetectDomainResult>;
|
|
127
|
+
/**
|
|
128
|
+
* Find properties matching a semantic description.
|
|
129
|
+
*
|
|
130
|
+
* @param description - What to look for
|
|
131
|
+
* @returns Matching properties with relevance scores
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* obj.findProperties("contact information")
|
|
135
|
+
* // [{ key: "email", value: "...", relevance: 0.95 }]
|
|
136
|
+
*/
|
|
137
|
+
findProperties(description: string): Promise<PropertySearchResult[]>;
|
|
138
|
+
/**
|
|
139
|
+
* Suggest missing properties based on the object's apparent purpose.
|
|
140
|
+
*
|
|
141
|
+
* @returns Suggested properties
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* user.suggestMissingProperties()
|
|
145
|
+
* // [{ property: "createdAt", type: "Date", reason: "Common in user records" }]
|
|
146
|
+
*/
|
|
147
|
+
suggestMissingProperties(): Promise<MissingPropertySuggestion[]>;
|
|
148
|
+
/**
|
|
149
|
+
* Check if a property contains sensitive data.
|
|
150
|
+
*
|
|
151
|
+
* @param propertyPath - Property to check
|
|
152
|
+
* @returns Sensitivity assessment
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* obj.isSensitive("ssn")
|
|
156
|
+
* // { sensitive: true, type: "PII", recommendation: "encrypt" }
|
|
157
|
+
*/
|
|
158
|
+
isSensitive(propertyPath: string): Promise<SensitiveResult>;
|
|
159
|
+
/**
|
|
160
|
+
* Transform property names to a naming convention.
|
|
161
|
+
*
|
|
162
|
+
* @param convention - Target convention
|
|
163
|
+
* @returns Transformed object literal
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* obj.transformKeys("snake_case")
|
|
167
|
+
*/
|
|
168
|
+
transformKeys(convention: KeyConvention): Promise<SemanticObjectLiteral>;
|
|
169
|
+
/**
|
|
170
|
+
* Generate a TypeScript interface for this object.
|
|
171
|
+
*
|
|
172
|
+
* @param name - Interface name
|
|
173
|
+
* @returns TypeScript interface code
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* obj.generateInterface("User")
|
|
177
|
+
* // "interface User { name: string; age?: number; }"
|
|
178
|
+
*/
|
|
179
|
+
generateInterface(name: string): Promise<string>;
|
|
180
|
+
/**
|
|
181
|
+
* Summarize the object contents.
|
|
182
|
+
*
|
|
183
|
+
* @returns Human-readable summary
|
|
184
|
+
*/
|
|
185
|
+
summarize(): Promise<string>;
|
|
186
|
+
/**
|
|
187
|
+
* Get all keys of the object
|
|
188
|
+
*/
|
|
189
|
+
keys(): string[];
|
|
190
|
+
/**
|
|
191
|
+
* Get all values of the object
|
|
192
|
+
*/
|
|
193
|
+
values(): unknown[];
|
|
194
|
+
/**
|
|
195
|
+
* Get all entries of the object
|
|
196
|
+
*/
|
|
197
|
+
entries(): [string, unknown][];
|
|
198
|
+
/**
|
|
199
|
+
* Check if object has a property (exact match)
|
|
200
|
+
*/
|
|
201
|
+
has(key: string): boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Get a property value (exact match)
|
|
204
|
+
*/
|
|
205
|
+
get<K extends keyof T>(key: K): T[K];
|
|
206
|
+
/**
|
|
207
|
+
* Get the context string if provided
|
|
208
|
+
*/
|
|
209
|
+
getContext(): string | undefined;
|
|
210
|
+
/**
|
|
211
|
+
* Convert to string
|
|
212
|
+
*/
|
|
213
|
+
toString(): string;
|
|
214
|
+
/**
|
|
215
|
+
* Convert to JSON
|
|
216
|
+
*/
|
|
217
|
+
toJSON(): T;
|
|
218
|
+
/**
|
|
219
|
+
* Helper to get nested value by dot-notation path
|
|
220
|
+
*/
|
|
221
|
+
private getNestedValue;
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=object-literal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-literal.d.ts","sourceRoot":"","sources":["../../../src/types/object-literal/object-literal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EACV,gCAAgC,EAChC,iBAAiB,EACjB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAe/B,YAAY,EACV,gCAAgC,EAChC,iBAAiB,EACjB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAE/B,kDAAkD;AAClD,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAChE;AAED,iCA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AAC,2BAA2B,CAAC;IAgB9E;;;;;;;;OAQG;IACG,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC;IA2BjD;;;;;;;;;OASG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAqB1E;;;;;;;;OAQG;IACG,wBAAwB,IAAI,OAAO,CAAC,yBAAyB,EAAE,CAAC;IAqBtE;;;;;;;;;OASG;IACG,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA4BjE;;;;;;;;OAQG;IACG,aAAa,CACjB,UAAU,EAAE,aAAa,GACxB,OAAO,CAAC,qBAAqB,CAAC;IAqBjC;;;;;;;;;OASG;IACG,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAqBtD;;;;OAIG;IACG,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAqBlC;;OAEG;IACH,IAAI,IAAI,MAAM,EAAE;IAIhB;;OAEG;IACH,MAAM,IAAI,OAAO,EAAE;IAInB;;OAEG;IACH,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IAI9B;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB;;OAEG;IACH,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAIpC;;OAEG;IACH,UAAU,IAAI,MAAM,GAAG,SAAS;IAIhC;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,MAAM,IAAI,CAAC;IAIX;;OAEG;IACH,OAAO,CAAC,cAAc;CAgBvB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts for SemanticObjectLiteral LLM operations
|
|
3
|
+
* These prompts enable semantic operations on object literal data structures
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* System prompt for object literal semantic operations
|
|
7
|
+
*/
|
|
8
|
+
export declare const OBJECT_LITERAL_SYSTEM_PROMPT = "You are a semantic object literal analyzer. Your task is to analyze ad-hoc object structures and their properties to provide semantic understanding.\n\nYou must respond with valid JSON only, no additional text or explanation.\n\nGuidelines:\n- Consider property names, values, and their semantic meanings\n- Understand common naming conventions (camelCase, snake_case, etc.)\n- Recognize synonymous property names (e.g., \"email\" and \"emailAddress\")\n- Detect patterns that indicate domain/entity types\n- Provide confidence scores from 0.0 to 1.0\n- Be precise and consistent in your analysis";
|
|
9
|
+
/**
|
|
10
|
+
* Prompt for semantic equality comparison with property mappings
|
|
11
|
+
*/
|
|
12
|
+
export declare function createSemanticallyEqualsPrompt(obj1: object, obj2: object): string;
|
|
13
|
+
/**
|
|
14
|
+
* Prompt for schema inference
|
|
15
|
+
*/
|
|
16
|
+
export declare function createInferSchemaPrompt(obj: object): string;
|
|
17
|
+
/**
|
|
18
|
+
* Prompt for validation against semantic rules
|
|
19
|
+
*/
|
|
20
|
+
export declare function createValidateWithRulesPrompt(obj: object, rules: string[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* Prompt for domain/entity detection
|
|
23
|
+
*/
|
|
24
|
+
export declare function createDetectDomainPrompt(obj: object): string;
|
|
25
|
+
/**
|
|
26
|
+
* Prompt for finding properties by semantic description
|
|
27
|
+
*/
|
|
28
|
+
export declare function createFindPropertiesPrompt(obj: object, description: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Prompt for suggesting missing properties
|
|
31
|
+
*/
|
|
32
|
+
export declare function createSuggestMissingPropertiesPrompt(obj: object): string;
|
|
33
|
+
/**
|
|
34
|
+
* Prompt for sensitive data detection
|
|
35
|
+
*/
|
|
36
|
+
export declare function createIsSensitivePrompt(obj: object, propertyPath: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Prompt for key transformation
|
|
39
|
+
*/
|
|
40
|
+
export declare function createTransformKeysPrompt(obj: object, convention: 'camelCase' | 'snake_case' | 'PascalCase' | 'kebab-case'): string;
|
|
41
|
+
/**
|
|
42
|
+
* Prompt for TypeScript interface generation
|
|
43
|
+
*/
|
|
44
|
+
export declare function createGenerateInterfacePrompt(obj: object, name: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Prompt for summarization
|
|
47
|
+
*/
|
|
48
|
+
export declare function createSummarizePrompt(obj: object): string;
|
|
49
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/object-literal/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,4BAA4B,ylBAUI,CAAC;AAE9C;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAoBjF;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAoB3D;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAgBlF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAgB5D;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAoBnF;AAED;;GAEG;AACH,wBAAgB,oCAAoC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAmBxE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAmBjF;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,WAAW,GAAG,YAAY,GAAG,YAAY,GAAG,YAAY,GACnE,MAAM,CAkBR;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAiB/E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAezD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticPromise module
|
|
3
|
+
* LLM-enhanced Promise type with semantic understanding
|
|
4
|
+
*/
|
|
5
|
+
export { SemanticPromise, type PromiseState, type PromiseStatus, type InferredOperation, type RetryOptions, type ValidationResult, type SemanticErrorAnalysis, type SemanticEqualsResult, } from './promise.ts';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/promise/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticPromise
|
|
3
|
+
* A Promise type with LLM-powered semantic understanding
|
|
4
|
+
*
|
|
5
|
+
* Implements:
|
|
6
|
+
* - Comparable<Promise<unknown>, SemanticEqualsResult> - Semantic equality comparison
|
|
7
|
+
* - Explainable - Operation descriptions
|
|
8
|
+
* - Extended Promise functionality with semantic retry, transform, validate, and fallback
|
|
9
|
+
*/
|
|
10
|
+
import type { LLMClient } from '../../llm/client.ts';
|
|
11
|
+
import type { SemanticEqualsResult } from '../../shared/types.ts';
|
|
12
|
+
import { SemanticError } from '../error/error.ts';
|
|
13
|
+
export type { SemanticEqualsResult } from '../../shared/types.ts';
|
|
14
|
+
/** Promise state */
|
|
15
|
+
export type PromiseState = 'pending' | 'fulfilled' | 'rejected';
|
|
16
|
+
/** Status information for a promise */
|
|
17
|
+
export interface PromiseStatus {
|
|
18
|
+
state: PromiseState;
|
|
19
|
+
description: string;
|
|
20
|
+
elapsed?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Inferred operation details */
|
|
23
|
+
export interface InferredOperation {
|
|
24
|
+
operation: string;
|
|
25
|
+
resource?: string;
|
|
26
|
+
action?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Retry options */
|
|
29
|
+
export interface RetryOptions {
|
|
30
|
+
maxAttempts: number;
|
|
31
|
+
when?: string;
|
|
32
|
+
backoff?: 'linear' | 'exponential' | 'fixed';
|
|
33
|
+
}
|
|
34
|
+
/** Validation result */
|
|
35
|
+
export interface ValidationResult {
|
|
36
|
+
valid: boolean;
|
|
37
|
+
violations: string[];
|
|
38
|
+
confidence: number;
|
|
39
|
+
}
|
|
40
|
+
/** Semantic error analysis result */
|
|
41
|
+
export interface SemanticErrorAnalysis {
|
|
42
|
+
explanation: string;
|
|
43
|
+
rootCause: string;
|
|
44
|
+
suggestedFixes: string[];
|
|
45
|
+
isRetryable: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* SemanticPromise - Promise with LLM-powered semantic understanding
|
|
49
|
+
*
|
|
50
|
+
* Wraps a native Promise and adds intelligent error handling,
|
|
51
|
+
* meaningful timeout messages, and operation descriptions.
|
|
52
|
+
*/
|
|
53
|
+
export declare class SemanticPromise<T> implements PromiseLike<T> {
|
|
54
|
+
readonly [Symbol.toStringTag] = "SemanticPromise";
|
|
55
|
+
private readonly _promise;
|
|
56
|
+
private readonly _description?;
|
|
57
|
+
private readonly _client;
|
|
58
|
+
private readonly _startTime;
|
|
59
|
+
private _state;
|
|
60
|
+
private _resolvedValue?;
|
|
61
|
+
private constructor();
|
|
62
|
+
/**
|
|
63
|
+
* Create a SemanticPromise from a regular Promise.
|
|
64
|
+
*
|
|
65
|
+
* @param promise - Promise to wrap
|
|
66
|
+
* @param description - Description of what the promise does
|
|
67
|
+
* @param client - Optional LLM client
|
|
68
|
+
* @returns SemanticPromise instance
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* SemanticPromise.from(fetch(url), "fetching user data")
|
|
72
|
+
*/
|
|
73
|
+
static from<T>(promise: Promise<T>, description?: string, client?: LLMClient): SemanticPromise<T>;
|
|
74
|
+
/**
|
|
75
|
+
* Create a resolved SemanticPromise.
|
|
76
|
+
*
|
|
77
|
+
* @param value - Value to resolve with
|
|
78
|
+
* @param description - Description of the value
|
|
79
|
+
* @param client - Optional LLM client
|
|
80
|
+
*/
|
|
81
|
+
static resolve<T>(value: T, description?: string, client?: LLMClient): SemanticPromise<T>;
|
|
82
|
+
/**
|
|
83
|
+
* Create a rejected SemanticPromise.
|
|
84
|
+
*
|
|
85
|
+
* @param reason - Rejection reason
|
|
86
|
+
* @param description - Description of the operation
|
|
87
|
+
* @param client - Optional LLM client
|
|
88
|
+
*/
|
|
89
|
+
static reject<T = never>(reason: unknown, description?: string, client?: LLMClient): SemanticPromise<T>;
|
|
90
|
+
/**
|
|
91
|
+
* Implementation of PromiseLike.then for compatibility with native Promise
|
|
92
|
+
*/
|
|
93
|
+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): SemanticPromise<TResult1 | TResult2>;
|
|
94
|
+
/**
|
|
95
|
+
* Implementation of Promise.catch for compatibility
|
|
96
|
+
*/
|
|
97
|
+
catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): SemanticPromise<T | TResult>;
|
|
98
|
+
/**
|
|
99
|
+
* Implementation of Promise.finally for compatibility
|
|
100
|
+
*/
|
|
101
|
+
finally(onfinally?: (() => void) | null): SemanticPromise<T>;
|
|
102
|
+
/**
|
|
103
|
+
* Check if two promises resolve to semantically equivalent values.
|
|
104
|
+
*
|
|
105
|
+
* @param other - Promise to compare
|
|
106
|
+
* @returns Equivalence result (after both resolve)
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* promise1.semanticallyEquals(promise2)
|
|
110
|
+
* // { equivalent: true, confidence: 0.9 }
|
|
111
|
+
*/
|
|
112
|
+
semanticallyEquals(other: Promise<unknown>): Promise<SemanticEqualsResult>;
|
|
113
|
+
/**
|
|
114
|
+
* Add timeout with meaningful error message.
|
|
115
|
+
*
|
|
116
|
+
* @param ms - Timeout in milliseconds
|
|
117
|
+
* @param context - Context for error message
|
|
118
|
+
* @returns Promise that rejects with semantic error on timeout
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* apiCall.timeout(5000, "database connection")
|
|
122
|
+
*/
|
|
123
|
+
timeout(ms: number, context?: string): SemanticPromise<T>;
|
|
124
|
+
/**
|
|
125
|
+
* Handle errors with semantic understanding.
|
|
126
|
+
*
|
|
127
|
+
* @param handler - Error handler with semantic error
|
|
128
|
+
* @returns Promise with error handling
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* promise.catchSemantic(async (error) => {
|
|
132
|
+
* console.log(error.explanation);
|
|
133
|
+
* return defaultValue;
|
|
134
|
+
* })
|
|
135
|
+
*/
|
|
136
|
+
catchSemantic<U>(handler: (error: SemanticError, analysis: SemanticErrorAnalysis) => U | Promise<U>): SemanticPromise<T | U>;
|
|
137
|
+
/**
|
|
138
|
+
* Explain what operation this promise represents.
|
|
139
|
+
*
|
|
140
|
+
* @returns Operation description
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* promise.explain()
|
|
144
|
+
* // "Fetching user profile from /api/users/123"
|
|
145
|
+
*/
|
|
146
|
+
explain(): string;
|
|
147
|
+
/**
|
|
148
|
+
* Get the current status with semantic description.
|
|
149
|
+
*
|
|
150
|
+
* @returns Status information
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* promise.status()
|
|
154
|
+
* // { state: "pending", description: "Waiting for API response", elapsed: "2.3s" }
|
|
155
|
+
*/
|
|
156
|
+
status(): PromiseStatus;
|
|
157
|
+
/**
|
|
158
|
+
* Add semantic retry logic.
|
|
159
|
+
*
|
|
160
|
+
* @param options - Retry options
|
|
161
|
+
* @returns Promise with retry behavior
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* apiCall.retry({
|
|
165
|
+
* maxAttempts: 3,
|
|
166
|
+
* when: "network error or timeout",
|
|
167
|
+
* backoff: "exponential"
|
|
168
|
+
* })
|
|
169
|
+
*/
|
|
170
|
+
retry(options: RetryOptions): SemanticPromise<T>;
|
|
171
|
+
private executeWithRetry;
|
|
172
|
+
/**
|
|
173
|
+
* Transform the result with semantic understanding.
|
|
174
|
+
*
|
|
175
|
+
* @param instruction - Natural language transformation
|
|
176
|
+
* @returns Transformed promise
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* userPromise.transform("extract just the name and email")
|
|
180
|
+
*/
|
|
181
|
+
transform<U>(instruction: string): SemanticPromise<U>;
|
|
182
|
+
/**
|
|
183
|
+
* Validate the result against semantic rules.
|
|
184
|
+
*
|
|
185
|
+
* @param rules - Validation rules
|
|
186
|
+
* @returns Promise that rejects if validation fails
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* response.validateResult(["should contain user data", "email must be valid"])
|
|
190
|
+
*/
|
|
191
|
+
validateResult(rules: string[]): SemanticPromise<T>;
|
|
192
|
+
/**
|
|
193
|
+
* Provide a fallback with semantic matching.
|
|
194
|
+
*
|
|
195
|
+
* @param fallbackValue - Fallback value or function
|
|
196
|
+
* @param when - When to use fallback
|
|
197
|
+
* @returns Promise with fallback
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* userPromise.fallback(defaultUser, "when user not found")
|
|
201
|
+
*/
|
|
202
|
+
fallback<U>(fallbackValue: U | (() => U), when?: string): SemanticPromise<T | U>;
|
|
203
|
+
/**
|
|
204
|
+
* Log progress with semantic descriptions.
|
|
205
|
+
*
|
|
206
|
+
* @param logger - Logger function
|
|
207
|
+
* @returns Same promise with logging
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* promise.withLogging(console.log)
|
|
211
|
+
* // Logs: "Starting: fetch user data"
|
|
212
|
+
* // Logs: "Completed: fetch user data (245ms)"
|
|
213
|
+
*/
|
|
214
|
+
withLogging(logger: (message: string) => void): SemanticPromise<T>;
|
|
215
|
+
private generateLogMessage;
|
|
216
|
+
/**
|
|
217
|
+
* Infer what this promise is likely doing.
|
|
218
|
+
*
|
|
219
|
+
* @returns Inferred operation type
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* promise.inferOperation()
|
|
223
|
+
* // { operation: "api-call", resource: "user", action: "read" }
|
|
224
|
+
*/
|
|
225
|
+
inferOperation(): InferredOperation;
|
|
226
|
+
/**
|
|
227
|
+
* Asynchronously infer operation with LLM assistance.
|
|
228
|
+
*/
|
|
229
|
+
inferOperationAsync(): Promise<InferredOperation>;
|
|
230
|
+
private inferFromDescription;
|
|
231
|
+
/**
|
|
232
|
+
* Get the underlying promise.
|
|
233
|
+
*/
|
|
234
|
+
toPromise(): Promise<T>;
|
|
235
|
+
/**
|
|
236
|
+
* Get the description of this promise.
|
|
237
|
+
*/
|
|
238
|
+
getDescription(): string | undefined;
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=promise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../src/types/promise/promise.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAclD,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE,oBAAoB;A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AqBvD,OAAO,CAAC,oBAAoB;IA0C5B;;OAEG;IACH,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC;IAIvB;;OAEG;IACH,cAAc,IAAI,MAAM,GAAG,SAAS;CAGrC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts for SemanticPromise LLM operations
|
|
3
|
+
* These prompts enable intelligent error handling, result transformation, and operation inference
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* System prompt for promise analysis tasks
|
|
7
|
+
*/
|
|
8
|
+
export declare const PROMISE_SYSTEM_PROMPT = "You are an expert at analyzing asynchronous operations, understanding promise behaviors, and providing semantic insights about async code.\n\nYou must respond with valid JSON only, no additional text or explanation.\n\nGuidelines:\n- Analyze promise descriptions, values, and errors to understand their semantics\n- Consider common async patterns in software development\n- Provide meaningful, contextual responses\n- Be precise with confidence scores based on available information";
|
|
9
|
+
/**
|
|
10
|
+
* Prompt template for semantic equality comparison between promise results
|
|
11
|
+
*/
|
|
12
|
+
export declare function createSemanticallyEqualsPrompt(value1: unknown, value2: unknown, description1?: string, description2?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Prompt template for generating timeout error messages
|
|
15
|
+
*/
|
|
16
|
+
export declare function createTimeoutErrorPrompt(ms: number, context?: string, description?: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Prompt template for semantic error analysis
|
|
19
|
+
*/
|
|
20
|
+
export declare function createCatchSemanticPrompt(error: Error, description?: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Prompt template for determining if error matches retry conditions
|
|
23
|
+
*/
|
|
24
|
+
export declare function createShouldRetryPrompt(error: Error, whenCondition: string, attemptNumber: number): string;
|
|
25
|
+
/**
|
|
26
|
+
* Prompt template for transforming promise results
|
|
27
|
+
*/
|
|
28
|
+
export declare function createTransformPrompt(value: unknown, instruction: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Prompt template for validating promise results
|
|
31
|
+
*/
|
|
32
|
+
export declare function createValidateResultPrompt(value: unknown, rules: string[]): string;
|
|
33
|
+
/**
|
|
34
|
+
* Prompt template for determining if fallback should be used
|
|
35
|
+
*/
|
|
36
|
+
export declare function createShouldUseFallbackPrompt(error: Error, whenCondition: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Prompt template for inferring what a promise operation does
|
|
39
|
+
*/
|
|
40
|
+
export declare function createInferOperationPrompt(description?: string, resolvedValue?: unknown): string;
|
|
41
|
+
/**
|
|
42
|
+
* Prompt template for generating logging messages
|
|
43
|
+
*/
|
|
44
|
+
export declare function createLoggingMessagePrompt(phase: 'start' | 'complete' | 'error', description?: string, elapsed?: number, error?: Error): string;
|
|
45
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/promise/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB,ueAQiC,CAAC;AAEpE;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,OAAO,EACf,YAAY,CAAC,EAAE,MAAM,EACrB,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAqBR;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CAgBR;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,KAAK,EACZ,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CAqBR;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GACpB,MAAM,CAqBR;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,EACd,WAAW,EAAE,MAAM,GAClB,MAAM,CAgBR;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,EAAE,GACd,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,MAAM,GACpB,MAAM,CAoBR;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,CAAC,EAAE,MAAM,EACpB,aAAa,CAAC,EAAE,OAAO,GACtB,MAAM,CA6BR;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,EACrC,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,KAAK,GACZ,MAAM,CA2BR"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticRecord - Record type with LLM-powered semantic understanding
|
|
3
|
+
*/
|
|
4
|
+
export { SemanticRecord, type RecordSemanticEqualsResult, type ValidateKeysResult, type ValidateValuesResult, type InvalidEntry, type RecordInferPurposeResult, type SemanticGetResult, type MissingSuggestion, } from './record.ts';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/record/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,cAAc,EACd,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts for SemanticRecord LLM operations
|
|
3
|
+
* These prompts enable semantic operations on Record key-value collections
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* System prompt for record semantic operations
|
|
7
|
+
*/
|
|
8
|
+
export declare const RECORD_SYSTEM_PROMPT = "You are a semantic record analyzer. Your task is to analyze Record key-value pairs to provide semantic understanding of keys, values, and their relationships.\n\nYou must respond with valid JSON only, no additional text or explanation.\n\nGuidelines:\n- Consider key meanings, synonyms, and naming conventions\n- Understand value relationships and patterns\n- Provide confidence scores from 0.0 to 1.0\n- Be precise and consistent in your analysis\n- Handle both primitive and complex object values\n- Records are uniform dictionaries where keys follow consistent patterns";
|
|
9
|
+
/**
|
|
10
|
+
* Prompt for semantic key lookup
|
|
11
|
+
*/
|
|
12
|
+
export declare function createSemanticGetPrompt(keys: string[], query: string, context?: Record<string, unknown>): string;
|
|
13
|
+
/**
|
|
14
|
+
* Prompt for semantic equality comparison
|
|
15
|
+
*/
|
|
16
|
+
export declare function createSemanticallyEqualsPrompt(record1Entries: [string, unknown][], record2Entries: [string, unknown][]): string;
|
|
17
|
+
/**
|
|
18
|
+
* Prompt for validating keys
|
|
19
|
+
*/
|
|
20
|
+
export declare function createValidateKeysPrompt(keys: string[], rules: string[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* Prompt for validating values
|
|
23
|
+
*/
|
|
24
|
+
export declare function createValidateValuesPrompt(entries: [string, unknown][], rules: string[]): string;
|
|
25
|
+
/**
|
|
26
|
+
* Prompt for inferring record purpose
|
|
27
|
+
*/
|
|
28
|
+
export declare function createInferPurposePrompt(entries: [string, unknown][]): string;
|
|
29
|
+
/**
|
|
30
|
+
* Prompt for semantic filtering
|
|
31
|
+
*/
|
|
32
|
+
export declare function createSemanticFilterPrompt(entries: [string, unknown][], criteria: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Prompt for suggesting missing keys
|
|
35
|
+
*/
|
|
36
|
+
export declare function createSuggestMissingKeysPrompt(entries: [string, unknown][]): string;
|
|
37
|
+
/**
|
|
38
|
+
* Prompt for grouping entries
|
|
39
|
+
*/
|
|
40
|
+
export declare function createGroupByPrompt(entries: [string, unknown][], criteria: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Prompt for summarization
|
|
43
|
+
*/
|
|
44
|
+
export declare function createSummarizePrompt(entries: [string, unknown][], recordSize: number): string;
|
|
45
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/record/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB,ikBAUwC,CAAC;AAE1E;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,MAAM,CA2BR;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACnC,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAClC,MAAM,CAmBR;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,MAAM,EAAE,GACd,MAAM,CAgBR;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC5B,KAAK,EAAE,MAAM,EAAE,GACd,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,CAiB7E;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC5B,QAAQ,EAAE,MAAM,GACf,MAAM,CAeR;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC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