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,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts for SemanticArray LLM operations
|
|
3
|
+
* These prompts enable semantic operations on array collections
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* System prompt for array semantic operations
|
|
7
|
+
*/
|
|
8
|
+
export declare const ARRAY_SYSTEM_PROMPT = "You are a semantic array analyzer. Your task is to analyze arrays 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 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 arrays";
|
|
9
|
+
/**
|
|
10
|
+
* Prompt for semantic equality comparison
|
|
11
|
+
*/
|
|
12
|
+
export declare function createSemanticallyEqualsPrompt(array1: unknown[], array2: unknown[], options?: {
|
|
13
|
+
orderMatters?: boolean;
|
|
14
|
+
threshold?: number;
|
|
15
|
+
}): string;
|
|
16
|
+
/**
|
|
17
|
+
* Prompt for semantic filtering
|
|
18
|
+
*/
|
|
19
|
+
export declare function createSemanticFilterPrompt(array: unknown[], criteria: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Prompt for semantic grouping
|
|
22
|
+
*/
|
|
23
|
+
export declare function createSemanticGroupPrompt(array: unknown[], criteria: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Prompt for semantic sorting
|
|
26
|
+
*/
|
|
27
|
+
export declare function createSemanticSortPrompt(array: unknown[], criteria: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Prompt for semantic search
|
|
30
|
+
*/
|
|
31
|
+
export declare function createSemanticSearchPrompt(array: unknown[], criteria: string, options?: {
|
|
32
|
+
limit?: number;
|
|
33
|
+
}): string;
|
|
34
|
+
/**
|
|
35
|
+
* Prompt for pattern detection
|
|
36
|
+
*/
|
|
37
|
+
export declare function createDetectPatternsPrompt(array: unknown[]): string;
|
|
38
|
+
/**
|
|
39
|
+
* Prompt for summarization
|
|
40
|
+
*/
|
|
41
|
+
export declare function createSummarizePrompt(array: unknown[], options?: {
|
|
42
|
+
maxLength?: number;
|
|
43
|
+
focus?: string;
|
|
44
|
+
}): string;
|
|
45
|
+
/**
|
|
46
|
+
* Prompt for semantic unique (deduplication)
|
|
47
|
+
*/
|
|
48
|
+
export declare function createSemanticUniquePrompt(array: unknown[], options?: {
|
|
49
|
+
threshold?: number;
|
|
50
|
+
}): string;
|
|
51
|
+
/**
|
|
52
|
+
* Prompt for validation
|
|
53
|
+
*/
|
|
54
|
+
export declare function createValidatePrompt(array: unknown[], rules: string[]): string;
|
|
55
|
+
/**
|
|
56
|
+
* Prompt for enrichment
|
|
57
|
+
*/
|
|
58
|
+
export declare function createEnrichPrompt(array: unknown[], enrichments: Record<string, string>): string;
|
|
59
|
+
/**
|
|
60
|
+
* Prompt for inferring element type
|
|
61
|
+
*/
|
|
62
|
+
export declare function createInferElementTypePrompt(array: unknown[]): string;
|
|
63
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/array/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB,gaAQkB,CAAC;AAEnD;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,OAAO,EAAE,EACjB,MAAM,EAAE,OAAO,EAAE,EACjB,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACvD,MAAM,CAwBR;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EAAE,EAChB,QAAQ,EAAE,MAAM,GACf,MAAM,CAeR;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,EAAE,EAChB,QAAQ,EAAE,MAAM,GACf,MAAM,CAkBR;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,EAAE,EAChB,QAAQ,EAAE,MAAM,GACf,MAAM,CAeR;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EAAE,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3B,MAAM,CAqBR;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,CAoBnE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,EAAE,EAChB,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/C,MAAM,CA2BR;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EAAE,EAChB,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/B,MAAM,CAqBR;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EAAE,EAChB,KAAK,EAAE,MAAM,EAAE,GACd,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EAAE,EAChB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAClC,MAAM,CAuBR;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,CAkBrE"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticBlob - LLM-enhanced Blob type with semantic understanding
|
|
3
|
+
*
|
|
4
|
+
* Extends the native Blob with semantic operations including:
|
|
5
|
+
* - Content type detection beyond MIME headers
|
|
6
|
+
* - Semantic equivalence comparison
|
|
7
|
+
* - Content analysis and validation
|
|
8
|
+
* - Safety assessment
|
|
9
|
+
*
|
|
10
|
+
* Implements shared interfaces:
|
|
11
|
+
* - Semantic<Blob> - Base semantic wrapper
|
|
12
|
+
* - Comparable<Blob> - Semantic equality comparison
|
|
13
|
+
* - Explainable - Human-readable explanations
|
|
14
|
+
*/
|
|
15
|
+
import type { LLMConfig, Message } from '../../llm/types.ts';
|
|
16
|
+
import type { SemanticEqualsResult } from '../../shared/types.ts';
|
|
17
|
+
import type { Semantic, Comparable, Explainable } from '../../shared/interfaces.ts';
|
|
18
|
+
export type { SemanticEqualsResult } from '../../shared/types.ts';
|
|
19
|
+
/** Extended semantic equals result with note */
|
|
20
|
+
export interface BlobSemanticEqualsResult extends SemanticEqualsResult {
|
|
21
|
+
note?: string;
|
|
22
|
+
}
|
|
23
|
+
/** Result of content type detection */
|
|
24
|
+
export interface ContentTypeResult {
|
|
25
|
+
type: string;
|
|
26
|
+
declaredType: string;
|
|
27
|
+
mismatch: boolean;
|
|
28
|
+
confidence: number;
|
|
29
|
+
}
|
|
30
|
+
/** Result of blob analysis */
|
|
31
|
+
export interface AnalyzeResult {
|
|
32
|
+
type: string;
|
|
33
|
+
details: Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
/** Result of validation for a use case */
|
|
36
|
+
export interface ValidateForResult {
|
|
37
|
+
valid: boolean;
|
|
38
|
+
reason?: string;
|
|
39
|
+
suggestions?: string[];
|
|
40
|
+
}
|
|
41
|
+
/** Result of safety assessment */
|
|
42
|
+
export interface SafetyResult {
|
|
43
|
+
safe: boolean;
|
|
44
|
+
warnings: string[];
|
|
45
|
+
scanned: string[];
|
|
46
|
+
}
|
|
47
|
+
/** LLM client interface for dependency injection */
|
|
48
|
+
export interface BlobLLMClientInterface {
|
|
49
|
+
chat(options: {
|
|
50
|
+
messages: Message[];
|
|
51
|
+
systemPrompt?: string;
|
|
52
|
+
} & LLMConfig): Promise<{
|
|
53
|
+
content: string;
|
|
54
|
+
}>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* SemanticBlob class
|
|
58
|
+
* Wraps a Blob value with LLM-powered semantic operations
|
|
59
|
+
*
|
|
60
|
+
* Implements:
|
|
61
|
+
* - Semantic<Blob> - valueOf() returns the Blob value
|
|
62
|
+
* - Comparable<Blob> - semanticallyEquals() for comparison
|
|
63
|
+
* - Explainable - explain() for human-readable explanations
|
|
64
|
+
*/
|
|
65
|
+
export declare class SemanticBlob implements Semantic<Blob>, Comparable<Blob, BlobSemanticEqualsResult>, Explainable {
|
|
66
|
+
protected readonly _value: Blob;
|
|
67
|
+
protected readonly _llmClient: BlobLLMClientInterface;
|
|
68
|
+
protected readonly _llmConfig?: LLMConfig;
|
|
69
|
+
/**
|
|
70
|
+
* Create a SemanticBlob instance
|
|
71
|
+
* @param value - The Blob value to wrap
|
|
72
|
+
* @param llmClient - Optional LLM client for dependency injection (useful for testing)
|
|
73
|
+
* @param llmConfig - Optional LLM configuration
|
|
74
|
+
*/
|
|
75
|
+
constructor(value: Blob, llmClient?: BlobLLMClientInterface, llmConfig?: LLMConfig);
|
|
76
|
+
/**
|
|
77
|
+
* Create a SemanticBlob from existing Blob or data.
|
|
78
|
+
*
|
|
79
|
+
* @param data - Blob, ArrayBuffer, or string
|
|
80
|
+
* @param options - Blob options
|
|
81
|
+
* @param llmClient - Optional LLM client for dependency injection
|
|
82
|
+
* @param llmConfig - Optional LLM configuration
|
|
83
|
+
* @returns SemanticBlob instance
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* SemanticBlob.from(arrayBuffer, { type: "image/png" })
|
|
87
|
+
*/
|
|
88
|
+
static from(data: Blob | ArrayBuffer | Uint8Array | string, options?: BlobPropertyBag, llmClient?: BlobLLMClientInterface, llmConfig?: LLMConfig): SemanticBlob;
|
|
89
|
+
/**
|
|
90
|
+
* Get a preview of the blob content as hex
|
|
91
|
+
*/
|
|
92
|
+
protected getPreview(maxBytes?: number): Promise<string>;
|
|
93
|
+
/**
|
|
94
|
+
* Check if two blobs are semantically equivalent.
|
|
95
|
+
*
|
|
96
|
+
* @param other - Blob to compare
|
|
97
|
+
* @returns Equivalence result
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* blob1.semanticallyEquals(blob2)
|
|
101
|
+
* // { equivalent: true, note: "Same image, different compression", confidence: 0.9 }
|
|
102
|
+
*/
|
|
103
|
+
semanticallyEquals(other: Blob, _options?: Record<string, unknown>): Promise<BlobSemanticEqualsResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Detect the actual content type (not just MIME header).
|
|
106
|
+
*
|
|
107
|
+
* @returns Content detection result
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* blob.detectContentType()
|
|
111
|
+
* // { type: "image/png", declaredType: "application/octet-stream", mismatch: true }
|
|
112
|
+
*/
|
|
113
|
+
detectContentType(): Promise<ContentTypeResult>;
|
|
114
|
+
/**
|
|
115
|
+
* Analyze the blob contents.
|
|
116
|
+
*
|
|
117
|
+
* @returns Content analysis
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* imageBlob.analyze()
|
|
121
|
+
* // { type: "image", details: { format: "PNG", hasTransparency: true } }
|
|
122
|
+
*/
|
|
123
|
+
analyze(): Promise<AnalyzeResult>;
|
|
124
|
+
/**
|
|
125
|
+
* Validate the blob for a specific use case.
|
|
126
|
+
*
|
|
127
|
+
* @param useCase - Intended use
|
|
128
|
+
* @returns Validation result
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* blob.validateFor("profile picture")
|
|
132
|
+
* // { valid: false, reason: "Image dimensions too small (min 200x200)" }
|
|
133
|
+
*/
|
|
134
|
+
validateFor(useCase: string): Promise<ValidateForResult>;
|
|
135
|
+
/**
|
|
136
|
+
* Check if the blob is safe (no malicious content).
|
|
137
|
+
*
|
|
138
|
+
* @returns Safety assessment
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* blob.isSafe()
|
|
142
|
+
* // { safe: true, warnings: [], scanned: ["magic-bytes", "extension-match"] }
|
|
143
|
+
*/
|
|
144
|
+
isSafe(): Promise<SafetyResult>;
|
|
145
|
+
/**
|
|
146
|
+
* Explain what this blob contains.
|
|
147
|
+
*
|
|
148
|
+
* @param _context - Optional context (unused, for interface compatibility)
|
|
149
|
+
* @returns Human-readable explanation
|
|
150
|
+
*/
|
|
151
|
+
explain(_context?: string): Promise<string>;
|
|
152
|
+
/**
|
|
153
|
+
* Get a summary of blob metadata.
|
|
154
|
+
*
|
|
155
|
+
* @returns Metadata summary
|
|
156
|
+
*/
|
|
157
|
+
getMetadata(): Promise<Record<string, unknown>>;
|
|
158
|
+
/**
|
|
159
|
+
* Get the raw Blob value
|
|
160
|
+
* @returns The underlying Blob
|
|
161
|
+
*/
|
|
162
|
+
valueOf(): Blob;
|
|
163
|
+
/**
|
|
164
|
+
* Get the MIME type
|
|
165
|
+
*/
|
|
166
|
+
get type(): string;
|
|
167
|
+
/**
|
|
168
|
+
* Get the size in bytes
|
|
169
|
+
*/
|
|
170
|
+
get size(): number;
|
|
171
|
+
/**
|
|
172
|
+
* Slice the blob
|
|
173
|
+
*/
|
|
174
|
+
slice(start?: number, end?: number, contentType?: string): Blob;
|
|
175
|
+
/**
|
|
176
|
+
* Get the blob as ArrayBuffer
|
|
177
|
+
*/
|
|
178
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
179
|
+
/**
|
|
180
|
+
* Get the blob as text
|
|
181
|
+
*/
|
|
182
|
+
text(): Promise<string>;
|
|
183
|
+
/**
|
|
184
|
+
* Get a stream of the blob
|
|
185
|
+
*/
|
|
186
|
+
stream(): ReadableStream<Uint8Array>;
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=blob.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../../src/types/blob-file/blob.ts"],"names":[],"mappings":"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,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAuBrD;;;OAGG;IACH,OAAO,IAAI,IAAI;IAMf;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAI/D;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IAInC;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAIvB;;OAEG;IACH,MAAM,IAAI,cAAc,CAAC,UAAU,CAAC;CAGrC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticFile - LLM-enhanced File type with semantic understanding
|
|
3
|
+
*
|
|
4
|
+
* Extends SemanticBlob with file-specific semantic operations including:
|
|
5
|
+
* - Filename validation
|
|
6
|
+
* - Extension matching
|
|
7
|
+
* - Category inference
|
|
8
|
+
* - Filename suggestions
|
|
9
|
+
*
|
|
10
|
+
* Implements shared interfaces:
|
|
11
|
+
* - Semantic<File> - Base semantic wrapper
|
|
12
|
+
* - Comparable<File> - Semantic equality comparison
|
|
13
|
+
* - Explainable - Human-readable explanations
|
|
14
|
+
*/
|
|
15
|
+
import type { LLMConfig } from '../../llm/types.ts';
|
|
16
|
+
import { SemanticBlob, type BlobLLMClientInterface } from './blob.ts';
|
|
17
|
+
import { SemanticDate } from '../date/date.ts';
|
|
18
|
+
export type { BlobSemanticEqualsResult, ContentTypeResult, AnalyzeResult, ValidateForResult, SafetyResult, BlobLLMClientInterface, } from './blob.ts';
|
|
19
|
+
/** Result of filename validation */
|
|
20
|
+
export interface FilenameValidationResult {
|
|
21
|
+
valid: boolean;
|
|
22
|
+
issues: string[];
|
|
23
|
+
suggestions: string[];
|
|
24
|
+
}
|
|
25
|
+
/** Result of extension validation */
|
|
26
|
+
export interface ExtensionValidationResult {
|
|
27
|
+
matches: boolean;
|
|
28
|
+
actualType: string;
|
|
29
|
+
expectedType: string;
|
|
30
|
+
}
|
|
31
|
+
/** Result of category inference */
|
|
32
|
+
export interface CategoryResult {
|
|
33
|
+
category: string;
|
|
34
|
+
subcategory?: string;
|
|
35
|
+
confidence: number;
|
|
36
|
+
}
|
|
37
|
+
/** Result of filename suggestion */
|
|
38
|
+
export interface FilenameSuggestionResult {
|
|
39
|
+
suggested: string;
|
|
40
|
+
reason: string;
|
|
41
|
+
}
|
|
42
|
+
/** LLM client interface for dependency injection */
|
|
43
|
+
export type FileLLMClientInterface = BlobLLMClientInterface;
|
|
44
|
+
/**
|
|
45
|
+
* SemanticFile class
|
|
46
|
+
* Wraps a File value with LLM-powered semantic operations
|
|
47
|
+
*
|
|
48
|
+
* Extends SemanticBlob with file-specific capabilities:
|
|
49
|
+
* - validateFilename() for filename rule validation
|
|
50
|
+
* - validateExtension() for extension/content matching
|
|
51
|
+
* - inferCategory() for file categorization
|
|
52
|
+
* - suggestFilename() for better naming suggestions
|
|
53
|
+
* - getLastModified() for semantic date access
|
|
54
|
+
*/
|
|
55
|
+
export declare class SemanticFile extends SemanticBlob {
|
|
56
|
+
protected readonly _file: File;
|
|
57
|
+
protected readonly _filename: string;
|
|
58
|
+
protected readonly _lastModified: number;
|
|
59
|
+
/**
|
|
60
|
+
* Create a SemanticFile instance
|
|
61
|
+
* @param file - The File value to wrap
|
|
62
|
+
* @param llmClient - Optional LLM client for dependency injection (useful for testing)
|
|
63
|
+
* @param llmConfig - Optional LLM configuration
|
|
64
|
+
*/
|
|
65
|
+
constructor(file: File, llmClient?: FileLLMClientInterface, llmConfig?: LLMConfig);
|
|
66
|
+
/**
|
|
67
|
+
* Create a SemanticFile from File or Blob.
|
|
68
|
+
*
|
|
69
|
+
* @param file - File or Blob with name
|
|
70
|
+
* @param filename - Optional filename override
|
|
71
|
+
* @param llmClient - Optional LLM client for dependency injection
|
|
72
|
+
* @param llmConfig - Optional LLM configuration
|
|
73
|
+
* @returns SemanticFile instance
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* SemanticFile.fromFile(inputElement.files[0])
|
|
77
|
+
*/
|
|
78
|
+
static fromFile(file: File | Blob, filename?: string, llmClient?: FileLLMClientInterface, llmConfig?: LLMConfig): SemanticFile;
|
|
79
|
+
/**
|
|
80
|
+
* Validate the filename.
|
|
81
|
+
*
|
|
82
|
+
* @param rules - Filename validation rules
|
|
83
|
+
* @returns Validation result
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* file.validateFilename(["no spaces", "lowercase only"])
|
|
87
|
+
* // { valid: false, issues: ["contains spaces"], suggestions: ["use-kebab-case.pdf"] }
|
|
88
|
+
*/
|
|
89
|
+
validateFilename(rules?: string[]): Promise<FilenameValidationResult>;
|
|
90
|
+
/**
|
|
91
|
+
* Check if file extension matches content.
|
|
92
|
+
*
|
|
93
|
+
* @returns Match result
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* file.validateExtension()
|
|
97
|
+
* // { matches: false, actualType: "image/png", expectedType: "image/jpeg" }
|
|
98
|
+
*/
|
|
99
|
+
validateExtension(): Promise<ExtensionValidationResult>;
|
|
100
|
+
/**
|
|
101
|
+
* Infer the file category.
|
|
102
|
+
*
|
|
103
|
+
* @returns File category
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* file.inferCategory()
|
|
107
|
+
* // { category: "document", subcategory: "spreadsheet", confidence: 0.95 }
|
|
108
|
+
*/
|
|
109
|
+
inferCategory(): Promise<CategoryResult>;
|
|
110
|
+
/**
|
|
111
|
+
* Suggest a better filename.
|
|
112
|
+
*
|
|
113
|
+
* @returns Suggested filename
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* file.suggestFilename()
|
|
117
|
+
* // { suggested: "invoice-2024-01.pdf", reason: "Based on document content" }
|
|
118
|
+
*/
|
|
119
|
+
suggestFilename(): Promise<FilenameSuggestionResult>;
|
|
120
|
+
/**
|
|
121
|
+
* Get the file's modification timestamp as SemanticDate.
|
|
122
|
+
*
|
|
123
|
+
* @returns Last modified date with semantic capabilities
|
|
124
|
+
*/
|
|
125
|
+
getLastModified(): SemanticDate;
|
|
126
|
+
/**
|
|
127
|
+
* Get the raw File value
|
|
128
|
+
* @returns The underlying File
|
|
129
|
+
*/
|
|
130
|
+
valueOf(): File;
|
|
131
|
+
/**
|
|
132
|
+
* Get the filename
|
|
133
|
+
*/
|
|
134
|
+
get name(): string;
|
|
135
|
+
/**
|
|
136
|
+
* Get the last modified timestamp
|
|
137
|
+
*/
|
|
138
|
+
get lastModified(): number;
|
|
139
|
+
/**
|
|
140
|
+
* Get the webkitRelativePath (if available)
|
|
141
|
+
*/
|
|
142
|
+
get webkitRelativePath(): string;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/types/blob-file/file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAW,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,KAAK,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAa/C,YAAY,EACV,wBAAwB,EACxB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,sBAAsB,GACvB,MAAM,WAAW,CAAC;AAEnB,oCAAoC;AACpC,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,qCAAqC;AACrC,MAAM,WAAW,yBAAyB;IACxC,OAAO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e,IAAI,YAAY;IAI/B;;;OAGG;IACM,OAAO,IAAI,IAAI;IAMxB;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED;;OAEG;IACH,IAAI,kBAAkB,IAAI,MAAM,CAE/B;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticBlob and SemanticFile Module
|
|
3
|
+
* LLM-enhanced Blob and File types with semantic understanding
|
|
4
|
+
*/
|
|
5
|
+
export { SemanticBlob, type BlobSemanticEqualsResult, type ContentTypeResult, type AnalyzeResult, type ValidateForResult, type SafetyResult, type BlobLLMClientInterface, } from './blob.ts';
|
|
6
|
+
export { SemanticFile, type FilenameValidationResult, type ExtensionValidationResult, type CategoryResult, type FilenameSuggestionResult, type FileLLMClientInterface, } from './file.ts';
|
|
7
|
+
export type { SemanticEqualsResult } from '../../shared/types.ts';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/blob-file/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,YAAY,EACZ,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,sBAAsB,GAC5B,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,YAAY,EACZ,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,GAC5B,MAAM,WAAW,CAAC;AAGnB,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts for SemanticBlob and SemanticFile LLM operations
|
|
3
|
+
* These prompts are used for various semantic blob/file operations that require LLM understanding
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* System prompt for semantic blob equality comparison
|
|
7
|
+
*/
|
|
8
|
+
export declare const SEMANTIC_EQUALS_SYSTEM = "You are a binary data comparison assistant. Your task is to determine if two blobs are semantically equivalent.\n\nConsider these factors when comparing:\n- Content type and MIME types\n- Binary signatures and magic bytes\n- Content structure similarity\n- Whether content represents the same data in different formats/compressions\n- Size differences and their implications\n\nAlways respond with valid JSON only.";
|
|
9
|
+
/**
|
|
10
|
+
* User prompt template for semantic blob equality
|
|
11
|
+
*/
|
|
12
|
+
export declare function semanticEqualsPrompt(blob1Info: {
|
|
13
|
+
type: string;
|
|
14
|
+
size: number;
|
|
15
|
+
preview: string;
|
|
16
|
+
}, blob2Info: {
|
|
17
|
+
type: string;
|
|
18
|
+
size: number;
|
|
19
|
+
preview: string;
|
|
20
|
+
}): string;
|
|
21
|
+
/**
|
|
22
|
+
* System prompt for content type detection
|
|
23
|
+
*/
|
|
24
|
+
export declare const DETECT_CONTENT_TYPE_SYSTEM = "You are a file type detection assistant. Your task is to detect the actual content type of binary data based on magic bytes and content signatures.\n\nCommon magic byte patterns:\n- PNG: 89 50 4E 47 0D 0A 1A 0A\n- JPEG: FF D8 FF\n- GIF: 47 49 46 38\n- PDF: 25 50 44 46\n- ZIP: 50 4B 03 04\n- MP3: 49 44 33 or FF FB\n- MP4: various (ftyp signature)\n- HTML/XML: text patterns\n- JSON: starts with { or [\n\nAlways respond with valid JSON only.";
|
|
25
|
+
/**
|
|
26
|
+
* User prompt template for content type detection
|
|
27
|
+
*/
|
|
28
|
+
export declare function detectContentTypePrompt(declaredType: string, magicBytes: string, size: number): string;
|
|
29
|
+
/**
|
|
30
|
+
* System prompt for blob analysis
|
|
31
|
+
*/
|
|
32
|
+
export declare const ANALYZE_BLOB_SYSTEM = "You are a binary data analysis assistant. Your task is to analyze blob contents and provide detailed information about the data.\n\nFor images, consider: dimensions, color depth, transparency, compression\nFor documents: format, potential content type\nFor audio/video: format, potential duration, codec hints\nFor text-based: encoding, structure\n\nAlways respond with valid JSON only.";
|
|
33
|
+
/**
|
|
34
|
+
* User prompt template for blob analysis
|
|
35
|
+
*/
|
|
36
|
+
export declare function analyzeBlobPrompt(type: string, size: number, preview: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* System prompt for use case validation
|
|
39
|
+
*/
|
|
40
|
+
export declare const VALIDATE_FOR_SYSTEM = "You are a file validation assistant. Your task is to validate if a blob is suitable for a specific use case.\n\nConsider:\n- Content type appropriateness\n- Size constraints for the use case\n- Format compatibility\n- Quality requirements\n- Security considerations\n\nAlways respond with valid JSON only.";
|
|
41
|
+
/**
|
|
42
|
+
* User prompt template for use case validation
|
|
43
|
+
*/
|
|
44
|
+
export declare function validateForPrompt(useCase: string, type: string, size: number, preview: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* System prompt for safety assessment
|
|
47
|
+
*/
|
|
48
|
+
export declare const IS_SAFE_SYSTEM = "You are a file safety assessment assistant. Your task is to assess whether a blob is safe (no malicious content indicators).\n\nSafety checks to consider:\n- Magic byte validation (type matches declared type)\n- Suspicious patterns (embedded scripts, polyglot files)\n- Known malicious signatures\n- Extension/type mismatches\n- Unusual size characteristics\n\nAlways respond with valid JSON only.";
|
|
49
|
+
/**
|
|
50
|
+
* User prompt template for safety assessment
|
|
51
|
+
*/
|
|
52
|
+
export declare function isSafePrompt(declaredType: string, detectedType: string, size: number, magicBytes: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* System prompt for blob explanation
|
|
55
|
+
*/
|
|
56
|
+
export declare const EXPLAIN_BLOB_SYSTEM = "You are a file description assistant. Your task is to explain what a blob contains in human-readable terms.\n\nProvide a clear, concise description that a non-technical user could understand.\n\nAlways respond with valid JSON only.";
|
|
57
|
+
/**
|
|
58
|
+
* User prompt template for blob explanation
|
|
59
|
+
*/
|
|
60
|
+
export declare function explainBlobPrompt(type: string, size: number, preview: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* System prompt for metadata extraction
|
|
63
|
+
*/
|
|
64
|
+
export declare const GET_METADATA_SYSTEM = "You are a file metadata extraction assistant. Your task is to extract and infer metadata from blob data.\n\nExtract information like:\n- Content type and format\n- Size information\n- Structural characteristics\n- Format-specific metadata hints\n\nAlways respond with valid JSON only.";
|
|
65
|
+
/**
|
|
66
|
+
* User prompt template for metadata extraction
|
|
67
|
+
*/
|
|
68
|
+
export declare function getMetadataPrompt(type: string, size: number, preview: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* System prompt for filename validation
|
|
71
|
+
*/
|
|
72
|
+
export declare const VALIDATE_FILENAME_SYSTEM = "You are a filename validation assistant. Your task is to validate filenames against specified rules.\n\nCommon filename rules:\n- no spaces: filename should not contain spaces\n- lowercase only: all characters should be lowercase\n- alphanumeric: only letters, numbers, and allowed separators\n- no special characters: avoid special characters\n- max length: reasonable filename length\n- valid extension: extension matches content\n\nAlways respond with valid JSON only.";
|
|
73
|
+
/**
|
|
74
|
+
* User prompt template for filename validation
|
|
75
|
+
*/
|
|
76
|
+
export declare function validateFilenamePrompt(filename: string, rules: string[]): string;
|
|
77
|
+
/**
|
|
78
|
+
* System prompt for extension validation
|
|
79
|
+
*/
|
|
80
|
+
export declare const VALIDATE_EXTENSION_SYSTEM = "You are a file extension validation assistant. Your task is to check if a file's extension matches its actual content type.\n\nConsider:\n- Common extension mappings\n- MIME type to extension relationships\n- Content detection results\n\nAlways respond with valid JSON only.";
|
|
81
|
+
/**
|
|
82
|
+
* User prompt template for extension validation
|
|
83
|
+
*/
|
|
84
|
+
export declare function validateExtensionPrompt(filename: string, actualType: string, detectedType: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* System prompt for category inference
|
|
87
|
+
*/
|
|
88
|
+
export declare const INFER_CATEGORY_SYSTEM = "You are a file categorization assistant. Your task is to infer the category of a file based on its name, type, and content.\n\nCategories to consider:\n- document (subcategories: text, spreadsheet, presentation, pdf)\n- image (subcategories: photo, icon, vector, screenshot)\n- video (subcategories: movie, clip, animation)\n- audio (subcategories: music, voice, sound-effect)\n- archive (subcategories: compressed, backup)\n- code (subcategories: source, config, script)\n- data (subcategories: database, dataset, export)\n\nAlways respond with valid JSON only.";
|
|
89
|
+
/**
|
|
90
|
+
* User prompt template for category inference
|
|
91
|
+
*/
|
|
92
|
+
export declare function inferCategoryPrompt(filename: string, type: string, size: number): string;
|
|
93
|
+
/**
|
|
94
|
+
* System prompt for filename suggestion
|
|
95
|
+
*/
|
|
96
|
+
export declare const SUGGEST_FILENAME_SYSTEM = "You are a filename suggestion assistant. Your task is to suggest a better, more descriptive filename based on file content and context.\n\nConsider:\n- Content type and format\n- Descriptive naming conventions\n- Date/timestamp inclusion if appropriate\n- Proper extension\n- Clean, readable format\n\nAlways respond with valid JSON only.";
|
|
97
|
+
/**
|
|
98
|
+
* User prompt template for filename suggestion
|
|
99
|
+
*/
|
|
100
|
+
export declare function suggestFilenamePrompt(currentFilename: string, type: string, contentHints: string): string;
|
|
101
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/blob-file/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;GAEG;AACH,eAAO,MAAM,sBAAsB,maASE,CAAC;AAEtC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAC1D,SAAS,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACzD,MAAM,CAeR;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B,+bAaF,CAAC;AAEtC;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,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