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.
Files changed (238) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +449 -0
  3. package/dist/index.d.ts +8 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +25016 -0
  6. package/dist/llm/client.d.ts +82 -0
  7. package/dist/llm/client.d.ts.map +1 -0
  8. package/dist/llm/index.d.ts +11 -0
  9. package/dist/llm/index.d.ts.map +1 -0
  10. package/dist/llm/providers/anthropic.d.ts +13 -0
  11. package/dist/llm/providers/anthropic.d.ts.map +1 -0
  12. package/dist/llm/providers/google.d.ts +13 -0
  13. package/dist/llm/providers/google.d.ts.map +1 -0
  14. package/dist/llm/providers/index.d.ts +7 -0
  15. package/dist/llm/providers/index.d.ts.map +1 -0
  16. package/dist/llm/providers/openai.d.ts +13 -0
  17. package/dist/llm/providers/openai.d.ts.map +1 -0
  18. package/dist/llm/types.d.ts +91 -0
  19. package/dist/llm/types.d.ts.map +1 -0
  20. package/dist/primitives/bigint/bigint.d.ts +197 -0
  21. package/dist/primitives/bigint/bigint.d.ts.map +1 -0
  22. package/dist/primitives/bigint/index.d.ts +7 -0
  23. package/dist/primitives/bigint/index.d.ts.map +1 -0
  24. package/dist/primitives/bigint/prompts.d.ts +37 -0
  25. package/dist/primitives/bigint/prompts.d.ts.map +1 -0
  26. package/dist/primitives/boolean/boolean.d.ts +194 -0
  27. package/dist/primitives/boolean/boolean.d.ts.map +1 -0
  28. package/dist/primitives/boolean/evals/from.evals.d.ts +7 -0
  29. package/dist/primitives/boolean/evals/from.evals.d.ts.map +1 -0
  30. package/dist/primitives/boolean/evals/index.d.ts +5 -0
  31. package/dist/primitives/boolean/evals/index.d.ts.map +1 -0
  32. package/dist/primitives/boolean/index.d.ts +6 -0
  33. package/dist/primitives/boolean/index.d.ts.map +1 -0
  34. package/dist/primitives/boolean/prompts.d.ts +29 -0
  35. package/dist/primitives/boolean/prompts.d.ts.map +1 -0
  36. package/dist/primitives/index.d.ts +14 -0
  37. package/dist/primitives/index.d.ts.map +1 -0
  38. package/dist/primitives/null/index.d.ts +6 -0
  39. package/dist/primitives/null/index.d.ts.map +1 -0
  40. package/dist/primitives/null/null.d.ts +181 -0
  41. package/dist/primitives/null/null.d.ts.map +1 -0
  42. package/dist/primitives/null/prompts.d.ts +39 -0
  43. package/dist/primitives/null/prompts.d.ts.map +1 -0
  44. package/dist/primitives/number/index.d.ts +6 -0
  45. package/dist/primitives/number/index.d.ts.map +1 -0
  46. package/dist/primitives/number/number.d.ts +154 -0
  47. package/dist/primitives/number/number.d.ts.map +1 -0
  48. package/dist/primitives/number/number.prompts.d.ts +53 -0
  49. package/dist/primitives/number/number.prompts.d.ts.map +1 -0
  50. package/dist/primitives/string/evals/classify.evals.d.ts +7 -0
  51. package/dist/primitives/string/evals/classify.evals.d.ts.map +1 -0
  52. package/dist/primitives/string/evals/index.d.ts +6 -0
  53. package/dist/primitives/string/evals/index.d.ts.map +1 -0
  54. package/dist/primitives/string/evals/semanticallyEquals.evals.d.ts +7 -0
  55. package/dist/primitives/string/evals/semanticallyEquals.evals.d.ts.map +1 -0
  56. package/dist/primitives/string/index.d.ts +206 -0
  57. package/dist/primitives/string/index.d.ts.map +1 -0
  58. package/dist/primitives/string/string.prompts.d.ts +45 -0
  59. package/dist/primitives/string/string.prompts.d.ts.map +1 -0
  60. package/dist/primitives/symbol/index.d.ts +6 -0
  61. package/dist/primitives/symbol/index.d.ts.map +1 -0
  62. package/dist/primitives/symbol/symbol.d.ts +176 -0
  63. package/dist/primitives/symbol/symbol.d.ts.map +1 -0
  64. package/dist/primitives/symbol/symbol.prompts.d.ts +53 -0
  65. package/dist/primitives/symbol/symbol.prompts.d.ts.map +1 -0
  66. package/dist/primitives/undefined/index.d.ts +5 -0
  67. package/dist/primitives/undefined/index.d.ts.map +1 -0
  68. package/dist/primitives/undefined/prompts.d.ts +40 -0
  69. package/dist/primitives/undefined/prompts.d.ts.map +1 -0
  70. package/dist/primitives/undefined/undefined.d.ts +216 -0
  71. package/dist/primitives/undefined/undefined.d.ts.map +1 -0
  72. package/dist/primitives/void/index.d.ts +5 -0
  73. package/dist/primitives/void/index.d.ts.map +1 -0
  74. package/dist/primitives/void/prompts.d.ts +37 -0
  75. package/dist/primitives/void/prompts.d.ts.map +1 -0
  76. package/dist/primitives/void/void.d.ts +172 -0
  77. package/dist/primitives/void/void.d.ts.map +1 -0
  78. package/dist/shared/base-classes.d.ts +331 -0
  79. package/dist/shared/base-classes.d.ts.map +1 -0
  80. package/dist/shared/eval-types.d.ts +82 -0
  81. package/dist/shared/eval-types.d.ts.map +1 -0
  82. package/dist/shared/index.d.ts +25 -0
  83. package/dist/shared/index.d.ts.map +1 -0
  84. package/dist/shared/interfaces.d.ts +799 -0
  85. package/dist/shared/interfaces.d.ts.map +1 -0
  86. package/dist/shared/types.d.ts +335 -0
  87. package/dist/shared/types.d.ts.map +1 -0
  88. package/dist/types/array/array.d.ts +250 -0
  89. package/dist/types/array/array.d.ts.map +1 -0
  90. package/dist/types/array/index.d.ts +6 -0
  91. package/dist/types/array/index.d.ts.map +1 -0
  92. package/dist/types/array/prompts.d.ts +63 -0
  93. package/dist/types/array/prompts.d.ts.map +1 -0
  94. package/dist/types/blob-file/blob.d.ts +188 -0
  95. package/dist/types/blob-file/blob.d.ts.map +1 -0
  96. package/dist/types/blob-file/file.d.ts +144 -0
  97. package/dist/types/blob-file/file.d.ts.map +1 -0
  98. package/dist/types/blob-file/index.d.ts +8 -0
  99. package/dist/types/blob-file/index.d.ts.map +1 -0
  100. package/dist/types/blob-file/prompts.d.ts +101 -0
  101. package/dist/types/blob-file/prompts.d.ts.map +1 -0
  102. package/dist/types/bun/bun.d.ts +266 -0
  103. package/dist/types/bun/bun.d.ts.map +1 -0
  104. package/dist/types/bun/index.d.ts +7 -0
  105. package/dist/types/bun/index.d.ts.map +1 -0
  106. package/dist/types/bun/prompts.d.ts +93 -0
  107. package/dist/types/bun/prompts.d.ts.map +1 -0
  108. package/dist/types/callable/callable.d.ts +200 -0
  109. package/dist/types/callable/callable.d.ts.map +1 -0
  110. package/dist/types/callable/index.d.ts +6 -0
  111. package/dist/types/callable/index.d.ts.map +1 -0
  112. package/dist/types/callable/prompts.d.ts +45 -0
  113. package/dist/types/callable/prompts.d.ts.map +1 -0
  114. package/dist/types/constructable/constructable.d.ts +150 -0
  115. package/dist/types/constructable/constructable.d.ts.map +1 -0
  116. package/dist/types/constructable/index.d.ts +5 -0
  117. package/dist/types/constructable/index.d.ts.map +1 -0
  118. package/dist/types/constructable/prompts.d.ts +41 -0
  119. package/dist/types/constructable/prompts.d.ts.map +1 -0
  120. package/dist/types/date/date.d.ts +258 -0
  121. package/dist/types/date/date.d.ts.map +1 -0
  122. package/dist/types/date/index.d.ts +6 -0
  123. package/dist/types/date/index.d.ts.map +1 -0
  124. package/dist/types/date/prompts.d.ts +93 -0
  125. package/dist/types/date/prompts.d.ts.map +1 -0
  126. package/dist/types/error/error.d.ts +191 -0
  127. package/dist/types/error/error.d.ts.map +1 -0
  128. package/dist/types/error/index.d.ts +6 -0
  129. package/dist/types/error/index.d.ts.map +1 -0
  130. package/dist/types/error/prompts.d.ts +49 -0
  131. package/dist/types/error/prompts.d.ts.map +1 -0
  132. package/dist/types/event-emitter/event-emitter.d.ts +230 -0
  133. package/dist/types/event-emitter/event-emitter.d.ts.map +1 -0
  134. package/dist/types/event-emitter/index.d.ts +6 -0
  135. package/dist/types/event-emitter/index.d.ts.map +1 -0
  136. package/dist/types/event-emitter/prompts.d.ts +51 -0
  137. package/dist/types/event-emitter/prompts.d.ts.map +1 -0
  138. package/dist/types/fetch/headers.d.ts +126 -0
  139. package/dist/types/fetch/headers.d.ts.map +1 -0
  140. package/dist/types/fetch/index.d.ts +9 -0
  141. package/dist/types/fetch/index.d.ts.map +1 -0
  142. package/dist/types/fetch/prompts.d.ts +139 -0
  143. package/dist/types/fetch/prompts.d.ts.map +1 -0
  144. package/dist/types/fetch/request.d.ts +188 -0
  145. package/dist/types/fetch/request.d.ts.map +1 -0
  146. package/dist/types/fetch/response.d.ts +155 -0
  147. package/dist/types/fetch/response.d.ts.map +1 -0
  148. package/dist/types/form-data/form-data.d.ts +277 -0
  149. package/dist/types/form-data/form-data.d.ts.map +1 -0
  150. package/dist/types/form-data/index.d.ts +7 -0
  151. package/dist/types/form-data/index.d.ts.map +1 -0
  152. package/dist/types/form-data/prompts.d.ts +80 -0
  153. package/dist/types/form-data/prompts.d.ts.map +1 -0
  154. package/dist/types/index.d.ts +29 -0
  155. package/dist/types/index.d.ts.map +1 -0
  156. package/dist/types/map/index.d.ts +6 -0
  157. package/dist/types/map/index.d.ts.map +1 -0
  158. package/dist/types/map/map.d.ts +204 -0
  159. package/dist/types/map/map.d.ts.map +1 -0
  160. package/dist/types/map/prompts.d.ts +56 -0
  161. package/dist/types/map/prompts.d.ts.map +1 -0
  162. package/dist/types/never/index.d.ts +5 -0
  163. package/dist/types/never/index.d.ts.map +1 -0
  164. package/dist/types/never/never.d.ts +220 -0
  165. package/dist/types/never/never.d.ts.map +1 -0
  166. package/dist/types/never/prompts.d.ts +50 -0
  167. package/dist/types/never/prompts.d.ts.map +1 -0
  168. package/dist/types/object/index.d.ts +6 -0
  169. package/dist/types/object/index.d.ts.map +1 -0
  170. package/dist/types/object/object.d.ts +162 -0
  171. package/dist/types/object/object.d.ts.map +1 -0
  172. package/dist/types/object/prompts.d.ts +55 -0
  173. package/dist/types/object/prompts.d.ts.map +1 -0
  174. package/dist/types/object-literal/index.d.ts +6 -0
  175. package/dist/types/object-literal/index.d.ts.map +1 -0
  176. package/dist/types/object-literal/object-literal.d.ts +223 -0
  177. package/dist/types/object-literal/object-literal.d.ts.map +1 -0
  178. package/dist/types/object-literal/prompts.d.ts +49 -0
  179. package/dist/types/object-literal/prompts.d.ts.map +1 -0
  180. package/dist/types/promise/index.d.ts +6 -0
  181. package/dist/types/promise/index.d.ts.map +1 -0
  182. package/dist/types/promise/promise.d.ts +240 -0
  183. package/dist/types/promise/promise.d.ts.map +1 -0
  184. package/dist/types/promise/prompts.d.ts +45 -0
  185. package/dist/types/promise/prompts.d.ts.map +1 -0
  186. package/dist/types/record/index.d.ts +5 -0
  187. package/dist/types/record/index.d.ts.map +1 -0
  188. package/dist/types/record/prompts.d.ts +45 -0
  189. package/dist/types/record/prompts.d.ts.map +1 -0
  190. package/dist/types/record/record.d.ts +179 -0
  191. package/dist/types/record/record.d.ts.map +1 -0
  192. package/dist/types/regexp/index.d.ts +7 -0
  193. package/dist/types/regexp/index.d.ts.map +1 -0
  194. package/dist/types/regexp/prompts.d.ts +56 -0
  195. package/dist/types/regexp/prompts.d.ts.map +1 -0
  196. package/dist/types/regexp/regexp.d.ts +160 -0
  197. package/dist/types/regexp/regexp.d.ts.map +1 -0
  198. package/dist/types/set/index.d.ts +6 -0
  199. package/dist/types/set/index.d.ts.map +1 -0
  200. package/dist/types/set/prompts.d.ts +60 -0
  201. package/dist/types/set/prompts.d.ts.map +1 -0
  202. package/dist/types/set/set.d.ts +261 -0
  203. package/dist/types/set/set.d.ts.map +1 -0
  204. package/dist/types/streams/index.d.ts +8 -0
  205. package/dist/types/streams/index.d.ts.map +1 -0
  206. package/dist/types/streams/prompts.d.ts +53 -0
  207. package/dist/types/streams/prompts.d.ts.map +1 -0
  208. package/dist/types/streams/readable-stream.d.ts +148 -0
  209. package/dist/types/streams/readable-stream.d.ts.map +1 -0
  210. package/dist/types/streams/transform-stream.d.ts +67 -0
  211. package/dist/types/streams/transform-stream.d.ts.map +1 -0
  212. package/dist/types/streams/writable-stream.d.ts +111 -0
  213. package/dist/types/streams/writable-stream.d.ts.map +1 -0
  214. package/dist/types/text-codec/index.d.ts +12 -0
  215. package/dist/types/text-codec/index.d.ts.map +1 -0
  216. package/dist/types/text-codec/prompts.d.ts +79 -0
  217. package/dist/types/text-codec/prompts.d.ts.map +1 -0
  218. package/dist/types/text-codec/text-codec.d.ts +305 -0
  219. package/dist/types/text-codec/text-codec.d.ts.map +1 -0
  220. package/dist/types/tuple/index.d.ts +6 -0
  221. package/dist/types/tuple/index.d.ts.map +1 -0
  222. package/dist/types/tuple/prompts.d.ts +41 -0
  223. package/dist/types/tuple/prompts.d.ts.map +1 -0
  224. package/dist/types/tuple/tuple.d.ts +221 -0
  225. package/dist/types/tuple/tuple.d.ts.map +1 -0
  226. package/dist/types/unknown/index.d.ts +5 -0
  227. package/dist/types/unknown/index.d.ts.map +1 -0
  228. package/dist/types/unknown/prompts.d.ts +45 -0
  229. package/dist/types/unknown/prompts.d.ts.map +1 -0
  230. package/dist/types/unknown/unknown.d.ts +220 -0
  231. package/dist/types/unknown/unknown.d.ts.map +1 -0
  232. package/dist/types/url/index.d.ts +7 -0
  233. package/dist/types/url/index.d.ts.map +1 -0
  234. package/dist/types/url/prompts.d.ts +93 -0
  235. package/dist/types/url/prompts.d.ts.map +1 -0
  236. package/dist/types/url/url.d.ts +270 -0
  237. package/dist/types/url/url.d.ts.map +1 -0
  238. package/package.json +73 -0
@@ -0,0 +1,12 @@
1
+ /**
2
+ * SemanticTextCodec module exports
3
+ *
4
+ * Provides LLM-enhanced text encoding/decoding capabilities:
5
+ * - SemanticTextEncoder: Enhanced TextEncoder with analysis
6
+ * - SemanticTextDecoder: Enhanced TextDecoder with detection and repair
7
+ * - SemanticTextCodec: Static utility methods for encoding operations
8
+ */
9
+ export { SemanticTextEncoder, SemanticTextDecoder, SemanticTextCodec, } from './text-codec.ts';
10
+ export type { TextCodecLLMClientInterface, EncodeWithAnalysisResult, CanEncodeResult, DetectEncodingResult, DecodeWithAnalysisResult, RepairMojibakeResult, AreEquivalentResult, TranscodeResult, EncodingIssue, ValidateEncodingResult, SuggestEncodingResult, ExplainErrorResult, } from './text-codec.ts';
11
+ export type { ConfidenceResult } from '../../shared/types.ts';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/text-codec/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,2BAA2B,EAC3B,wBAAwB,EACxB,eAAe,EACf,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Prompts for SemanticTextCodec LLM operations
3
+ * These prompts are used for encoding detection, mojibake repair, and other text codec operations
4
+ */
5
+ /**
6
+ * System prompt for encoding detection
7
+ */
8
+ export declare const DETECT_ENCODING_SYSTEM = "You are a text encoding detection specialist. Your task is to analyze byte patterns and determine the most likely character encoding.\n\nConsider these common encodings and their characteristics:\n- UTF-8: Variable-width, ASCII-compatible, most common for web content\n- UTF-16LE/BE: Fixed 2+ bytes per character, often has BOM\n- ISO-8859-1 (Latin-1): Single-byte Western European encoding\n- Windows-1252: Superset of ISO-8859-1 with extra characters\n- Shift-JIS: Japanese encoding, variable-width\n- EUC-JP: Japanese encoding, variable-width\n- GB2312/GBK/GB18030: Chinese encodings\n- EUC-KR: Korean encoding\n- KOI8-R: Russian encoding\n\nLook for patterns like:\n- Byte Order Marks (BOM)\n- Invalid byte sequences for certain encodings\n- Statistical distribution of byte values\n- Multi-byte sequence patterns\n\nAlways respond with valid JSON only.";
9
+ /**
10
+ * User prompt for encoding detection
11
+ */
12
+ export declare function detectEncodingPrompt(bytePreview: string, byteLength: number): string;
13
+ /**
14
+ * System prompt for mojibake repair
15
+ */
16
+ export declare const REPAIR_MOJIBAKE_SYSTEM = "You are a text encoding corruption repair specialist. Your task is to detect and repair mojibake - text that has been decoded with the wrong encoding.\n\nCommon mojibake patterns:\n- UTF-8 decoded as ISO-8859-1/Windows-1252: \"\u00C3\u00A9\" instead of \"\u00E9\", \"\u00C3\u00A8\" instead of \"\u00E8\"\n- Double-encoded UTF-8: Text encoded to UTF-8 twice\n- UTF-8 decoded as Shift-JIS: Japanese characters appearing as garbage\n- Windows-1252 decoded as UTF-8: Replacement characters appearing\n\nSteps to repair:\n1. Identify the corruption pattern\n2. Determine the original encoding\n3. Determine the incorrect decoding path\n4. Suggest the repaired text\n\nAlways respond with valid JSON only.";
17
+ /**
18
+ * User prompt for mojibake repair
19
+ */
20
+ export declare function repairMojibakePrompt(text: string): string;
21
+ /**
22
+ * System prompt for encoding validation
23
+ */
24
+ export declare const VALIDATE_ENCODING_SYSTEM = "You are a text encoding validation specialist. Your task is to verify if byte sequences are valid for a specified encoding.\n\nFor each encoding, check:\n- UTF-8: Valid multi-byte sequences, proper continuation bytes\n- UTF-16: Valid surrogate pairs, proper byte order\n- ISO-8859-1: All single bytes are valid (0x00-0xFF)\n- Windows-1252: Valid character positions (0x80-0x9F has specific mappings)\n- Shift-JIS: Valid lead/trail byte combinations\n- Other encodings: Encoding-specific validation rules\n\nReport specific issues with byte positions.\n\nAlways respond with valid JSON only.";
25
+ /**
26
+ * User prompt for encoding validation
27
+ */
28
+ export declare function validateEncodingPrompt(bytePreview: string, encoding: string, byteLength: number): string;
29
+ /**
30
+ * System prompt for encoding suggestion
31
+ */
32
+ export declare const SUGGEST_ENCODING_SYSTEM = "You are a text encoding recommendation specialist. Your task is to suggest the best encoding for text content based on its characters and any constraints.\n\nConsider these factors:\n- Character coverage: What characters need to be encoded?\n- Compatibility: Legacy systems, email, URLs, etc.\n- Efficiency: Byte size for the content\n- Standards: Modern standards prefer UTF-8\n- Interoperability: Cross-platform compatibility\n\nCommon recommendations:\n- For web content: UTF-8 (universal, widely supported)\n- For email: UTF-8 with proper MIME headers, or ASCII with encoding\n- For legacy Windows apps: Windows-1252\n- For Japanese: UTF-8, or Shift-JIS for legacy\n- For Chinese: UTF-8, or GB18030 for legacy\n\nAlways respond with valid JSON only.";
33
+ /**
34
+ * User prompt for encoding suggestion
35
+ */
36
+ export declare function suggestEncodingPrompt(text: string, constraints?: {
37
+ compatibility?: string;
38
+ }): string;
39
+ /**
40
+ * System prompt for encoding error explanation
41
+ */
42
+ export declare const EXPLAIN_ERROR_SYSTEM = "You are a text encoding error diagnosis specialist. Your task is to explain encoding errors in plain language and suggest solutions.\n\nCommon encoding errors:\n- \"Invalid byte sequence\": Data doesn't match expected encoding\n- \"Unmappable character\": Character can't be represented in target encoding\n- \"Truncated multi-byte sequence\": Incomplete UTF-8 or other multi-byte character\n- \"Invalid UTF-8 continuation byte\": Byte sequence violates UTF-8 rules\n- \"BOM mismatch\": Byte Order Mark doesn't match declared encoding\n\nFor each error:\n1. Explain what went wrong in simple terms\n2. Identify the likely cause\n3. Suggest a practical solution\n\nAlways respond with valid JSON only.";
43
+ /**
44
+ * User prompt for error explanation
45
+ */
46
+ export declare function explainErrorPrompt(errorMessage: string, contextHex?: string): string;
47
+ /**
48
+ * System prompt for checking if text can be encoded
49
+ */
50
+ export declare const CAN_ENCODE_SYSTEM = "You are a text encoding compatibility specialist. Your task is to determine if text can be encoded in a specific encoding without data loss.\n\nCheck for:\n- Characters outside the encoding's repertoire\n- Characters that would require substitution or escaping\n- Unicode normalization issues\n\nFor each problematic character, explain why it can't be encoded.\n\nAlways respond with valid JSON only.";
51
+ /**
52
+ * User prompt for can encode check
53
+ */
54
+ export declare function canEncodePrompt(text: string, encoding: string): string;
55
+ /**
56
+ * System prompt for checking buffer equivalence
57
+ */
58
+ export declare const ARE_EQUIVALENT_SYSTEM = "You are a text encoding equivalence specialist. Your task is to determine if two encoded byte buffers represent the same text, even if they use different encodings.\n\nConsider:\n- Different encodings of the same text\n- Byte Order Marks (BOM) differences\n- Unicode normalization differences (NFC vs NFD)\n- Line ending differences (CRLF vs LF)\n\nDetermine if the buffers are semantically equivalent (represent the same text content).\n\nAlways respond with valid JSON only.";
59
+ /**
60
+ * User prompt for buffer equivalence
61
+ */
62
+ export declare function areEquivalentPrompt(bytes1Hex: string, bytes2Hex: string, decoded1: string, decoded2: string): string;
63
+ /**
64
+ * System prompt for decode analysis
65
+ */
66
+ export declare const DECODE_WITH_ANALYSIS_SYSTEM = "You are a text decoding analysis specialist. Your task is to analyze decoded text and identify any issues or repairs that were made.\n\nLook for:\n- Replacement characters (U+FFFD) indicating decoding errors\n- Signs of mojibake that might need repair\n- Encoding mismatches between declared and actual encoding\n- Invalid character sequences that were sanitized\n\nReport all issues found during decoding.\n\nAlways respond with valid JSON only.";
67
+ /**
68
+ * User prompt for decode analysis
69
+ */
70
+ export declare function decodeWithAnalysisPrompt(text: string, declaredEncoding: string, detectedEncoding: string): string;
71
+ /**
72
+ * System prompt for encode analysis
73
+ */
74
+ export declare const ENCODE_WITH_ANALYSIS_SYSTEM = "You are a text encoding analysis specialist. Your task is to analyze text that will be encoded and identify potential issues.\n\nCheck for:\n- Non-ASCII characters that might cause issues in some systems\n- Characters that might be normalized differently\n- Potential encoding compatibility issues\n- Characters that might need escaping\n\nProvide warnings for any potential issues.\n\nAlways respond with valid JSON only.";
75
+ /**
76
+ * User prompt for encode analysis
77
+ */
78
+ export declare function encodeWithAnalysisPrompt(text: string, encoding: string): string;
79
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/text-codec/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;GAEG;AACH,eAAO,MAAM,sBAAsB,81BAmBE,CAAC;AAEtC;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAQpF;AAMD;;GAEG;AACH,eAAO,MAAM,sBAAsB,gsBAcE,CAAC;AAEtC;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASzD;AAMD;;GAEG;AACH,eAAO,M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
+ /**
2
+ * SemanticTextCodec - LLM-enhanced text encoding/decoding types
3
+ *
4
+ * Provides semantic wrappers for TextEncoder and TextDecoder with:
5
+ * - Intelligent encoding detection
6
+ * - Mojibake (encoding corruption) repair
7
+ * - Cross-encoding operations
8
+ * - Validation and suggestions
9
+ *
10
+ * Includes three classes:
11
+ * - SemanticTextEncoder: Enhanced TextEncoder with analysis capabilities
12
+ * - SemanticTextDecoder: Enhanced TextDecoder with detection and repair
13
+ * - SemanticTextCodec: Static utility methods for encoding operations
14
+ */
15
+ import type { LLMConfig, Message } from '../../llm/types.ts';
16
+ import type { ConfidenceResult } from '../../shared/types.ts';
17
+ type BufferSourceType = ArrayBuffer | Uint8Array | DataView;
18
+ /** LLM client interface for dependency injection */
19
+ export interface TextCodecLLMClientInterface {
20
+ chat(options: {
21
+ messages: Message[];
22
+ systemPrompt?: string;
23
+ } & LLMConfig): Promise<{
24
+ content: string;
25
+ }>;
26
+ }
27
+ /** Result of encoding with analysis */
28
+ export interface EncodeWithAnalysisResult {
29
+ bytes: Uint8Array;
30
+ warnings: string[];
31
+ hasNonAscii: boolean;
32
+ byteLength: number;
33
+ }
34
+ /** Result of checking if text can be encoded */
35
+ export interface CanEncodeResult {
36
+ canEncode: boolean;
37
+ problematicChars: string[];
38
+ suggestedEncoding?: string;
39
+ }
40
+ /** Result of encoding detection */
41
+ export interface DetectEncodingResult extends ConfidenceResult {
42
+ encoding: string;
43
+ alternatives: string[];
44
+ }
45
+ /** Result of decoding with analysis */
46
+ export interface DecodeWithAnalysisResult {
47
+ text: string;
48
+ detectedEncoding: string;
49
+ repaired: boolean;
50
+ issues: string[];
51
+ }
52
+ /** Result of mojibake repair */
53
+ export interface RepairMojibakeResult extends ConfidenceResult {
54
+ repaired: string;
55
+ corruptionPath: string[];
56
+ }
57
+ /** Result of buffer equivalence check */
58
+ export interface AreEquivalentResult extends ConfidenceResult {
59
+ equivalent: boolean;
60
+ note?: string;
61
+ }
62
+ /** Result of transcoding */
63
+ export interface TranscodeResult {
64
+ bytes: Uint8Array;
65
+ fromEncoding: string;
66
+ lossless: boolean;
67
+ substitutions: {
68
+ char: string;
69
+ replacement: string;
70
+ }[];
71
+ }
72
+ /** Encoding validation issue */
73
+ export interface EncodingIssue {
74
+ position: number;
75
+ issue: string;
76
+ }
77
+ /** Result of encoding validation */
78
+ export interface ValidateEncodingResult {
79
+ valid: boolean;
80
+ issues: EncodingIssue[];
81
+ }
82
+ /** Result of encoding suggestion */
83
+ export interface SuggestEncodingResult {
84
+ encoding: string;
85
+ reason: string;
86
+ alternatives: string[];
87
+ }
88
+ /** Result of error explanation */
89
+ export interface ExplainErrorResult {
90
+ explanation: string;
91
+ likelyCause: string;
92
+ solution: string;
93
+ }
94
+ /**
95
+ * SemanticTextEncoder - Enhanced TextEncoder with analysis capabilities
96
+ *
97
+ * Extends TextEncoder functionality with:
98
+ * - Encoding analysis and warnings
99
+ * - Character compatibility checking
100
+ * - LLM-powered encoding recommendations
101
+ */
102
+ export declare class SemanticTextEncoder {
103
+ private readonly _encoder;
104
+ private readonly _encoding;
105
+ private readonly _llmClient;
106
+ private readonly _llmConfig?;
107
+ /**
108
+ * Create a SemanticTextEncoder instance
109
+ *
110
+ * @param encoding - Target encoding (defaults to UTF-8, the only encoding TextEncoder supports)
111
+ * @param llmClient - Optional LLM client for dependency injection
112
+ * @param llmConfig - Optional LLM configuration
113
+ */
114
+ constructor(encoding?: string, llmClient?: TextCodecLLMClientInterface, llmConfig?: LLMConfig);
115
+ /**
116
+ * Create a SemanticTextEncoder with optional encoding validation.
117
+ *
118
+ * @param encoding - Target encoding (defaults to UTF-8)
119
+ * @param llmClient - Optional LLM client for dependency injection
120
+ * @param llmConfig - Optional LLM configuration
121
+ * @returns SemanticTextEncoder instance
122
+ */
123
+ static create(encoding?: string, llmClient?: TextCodecLLMClientInterface, llmConfig?: LLMConfig): SemanticTextEncoder;
124
+ /**
125
+ * Encode text to bytes (delegates to native TextEncoder)
126
+ *
127
+ * @param text - Text to encode
128
+ * @returns Encoded bytes
129
+ */
130
+ encode(text: string): Uint8Array;
131
+ /**
132
+ * Encode text into an existing buffer (delegates to native TextEncoder)
133
+ *
134
+ * @param text - Text to encode
135
+ * @param destination - Destination buffer
136
+ * @returns Result with read and written counts
137
+ */
138
+ encodeInto(text: string, destination: Uint8Array): {
139
+ read: number;
140
+ written: number;
141
+ };
142
+ /**
143
+ * Encode text with validation and warnings.
144
+ *
145
+ * @param text - Text to encode
146
+ * @returns Encoded bytes with metadata
147
+ */
148
+ encodeWithAnalysis(text: string): EncodeWithAnalysisResult;
149
+ /**
150
+ * Check if text can be encoded without loss.
151
+ * Uses LLM for intelligent analysis of encoding compatibility.
152
+ *
153
+ * @param text - Text to check
154
+ * @param encoding - Target encoding (defaults to instance encoding)
155
+ * @returns Analysis result
156
+ */
157
+ canEncode(text: string, encoding?: string): Promise<CanEncodeResult>;
158
+ /**
159
+ * Get the encoding name
160
+ */
161
+ get encoding(): string;
162
+ }
163
+ /**
164
+ * SemanticTextDecoder - Enhanced TextDecoder with detection and repair capabilities
165
+ *
166
+ * Extends TextDecoder functionality with:
167
+ * - Automatic encoding detection
168
+ * - Mojibake (encoding corruption) repair
169
+ * - Decoding analysis and issue reporting
170
+ */
171
+ export declare class SemanticTextDecoder {
172
+ private readonly _decoder;
173
+ private readonly _encoding;
174
+ private readonly _autoDetect;
175
+ private readonly _llmClient;
176
+ private readonly _llmConfig?;
177
+ /**
178
+ * Create a SemanticTextDecoder instance
179
+ *
180
+ * @param encoding - Encoding or "auto" for detection
181
+ * @param llmClient - Optional LLM client for dependency injection
182
+ * @param llmConfig - Optional LLM configuration
183
+ */
184
+ constructor(encoding?: string, llmClient?: TextCodecLLMClientInterface, llmConfig?: LLMConfig);
185
+ /**
186
+ * Create a SemanticTextDecoder with auto-detection capability.
187
+ *
188
+ * @param encoding - Encoding or "auto" for detection
189
+ * @param llmClient - Optional LLM client for dependency injection
190
+ * @param llmConfig - Optional LLM configuration
191
+ * @returns SemanticTextDecoder instance
192
+ */
193
+ static create(encoding?: string, llmClient?: TextCodecLLMClientInterface, llmConfig?: LLMConfig): SemanticTextDecoder;
194
+ /**
195
+ * Decode bytes to text (delegates to native TextDecoder)
196
+ *
197
+ * @param bytes - Bytes to decode
198
+ * @returns Decoded text
199
+ */
200
+ decode(bytes?: BufferSourceType): string;
201
+ /**
202
+ * Detect the encoding of a byte buffer using LLM analysis.
203
+ *
204
+ * @param bytes - Bytes to analyze
205
+ * @param llmClient - Optional LLM client for dependency injection
206
+ * @param llmConfig - Optional LLM configuration
207
+ * @returns Encoding detection result
208
+ */
209
+ static detectEncoding(bytes: BufferSourceType, llmClient?: TextCodecLLMClientInterface, llmConfig?: LLMConfig): Promise<DetectEncodingResult>;
210
+ /**
211
+ * Decode with encoding detection and repair.
212
+ *
213
+ * @param bytes - Bytes to decode
214
+ * @returns Decoded text with metadata
215
+ */
216
+ decodeWithAnalysis(bytes: BufferSourceType): Promise<DecodeWithAnalysisResult>;
217
+ /**
218
+ * Detect and repair mojibake (encoding corruption).
219
+ *
220
+ * @param text - Potentially corrupted text
221
+ * @param llmClient - Optional LLM client for dependency injection
222
+ * @param llmConfig - Optional LLM configuration
223
+ * @returns Repair result
224
+ */
225
+ static repairMojibake(text: string, llmClient?: TextCodecLLMClientInterface, llmConfig?: LLMConfig): Promise<RepairMojibakeResult>;
226
+ /**
227
+ * Get the encoding name
228
+ */
229
+ get encoding(): string;
230
+ /**
231
+ * Check if auto-detection is enabled
232
+ */
233
+ get isAutoDetect(): boolean;
234
+ }
235
+ /**
236
+ * SemanticTextCodec - Static utility methods for encoding operations
237
+ *
238
+ * Provides LLM-enhanced encoding utilities:
239
+ * - Cross-encoding equivalence checking
240
+ * - Transcoding with smart fallbacks
241
+ * - Encoding validation
242
+ * - Encoding suggestions
243
+ * - Error explanation
244
+ */
245
+ export declare class SemanticTextCodec {
246
+ /** Private constructor to prevent instantiation */
247
+ private constructor();
248
+ /**
249
+ * Check if two encoded buffers represent the same text.
250
+ *
251
+ * @param bytes1 - First buffer
252
+ * @param bytes2 - Second buffer
253
+ * @param llmClient - Optional LLM client for dependency injection
254
+ * @param llmConfig - Optional LLM configuration
255
+ * @returns Equivalence result
256
+ */
257
+ static areEquivalent(bytes1: BufferSourceType, bytes2: BufferSourceType, llmClient?: TextCodecLLMClientInterface, llmConfig?: LLMConfig): Promise<AreEquivalentResult>;
258
+ /**
259
+ * Transcode between encodings with smart fallbacks.
260
+ *
261
+ * @param bytes - Source bytes
262
+ * @param options - Transcode options
263
+ * @param llmClient - Optional LLM client for dependency injection
264
+ * @param llmConfig - Optional LLM configuration
265
+ * @returns Transcoded bytes
266
+ */
267
+ static transcode(bytes: BufferSourceType, options: {
268
+ from?: string;
269
+ to: string;
270
+ }, llmClient?: TextCodecLLMClientInterface, llmConfig?: LLMConfig): Promise<TranscodeResult>;
271
+ /**
272
+ * Validate text encoding integrity.
273
+ *
274
+ * @param bytes - Bytes to validate
275
+ * @param expectedEncoding - Expected encoding
276
+ * @param llmClient - Optional LLM client for dependency injection
277
+ * @param llmConfig - Optional LLM configuration
278
+ * @returns Validation result
279
+ */
280
+ static validateEncoding(bytes: BufferSourceType, expectedEncoding: string, llmClient?: TextCodecLLMClientInterface, llmConfig?: LLMConfig): Promise<ValidateEncodingResult>;
281
+ /**
282
+ * Suggest the best encoding for text content.
283
+ *
284
+ * @param text - Text to analyze
285
+ * @param constraints - Constraints on encoding choice
286
+ * @param llmClient - Optional LLM client for dependency injection
287
+ * @param llmConfig - Optional LLM configuration
288
+ * @returns Encoding recommendation
289
+ */
290
+ static suggestEncoding(text: string, constraints?: {
291
+ compatibility?: string;
292
+ }, llmClient?: TextCodecLLMClientInterface, llmConfig?: LLMConfig): Promise<SuggestEncodingResult>;
293
+ /**
294
+ * Explain encoding issues in plain language.
295
+ *
296
+ * @param error - Encoding error or issue
297
+ * @param context - Additional context
298
+ * @param llmClient - Optional LLM client for dependency injection
299
+ * @param llmConfig - Optional LLM configuration
300
+ * @returns Human-readable explanation
301
+ */
302
+ static explainError(error: Error, context?: BufferSourceType, llmClient?: TextCodecLLMClientInterface, llmConfig?: LLMConfig): Promise<ExplainErrorResult>;
303
+ }
304
+ export {};
305
+ //# sourceMappingURL=text-codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-codec.d.ts","sourceRoot":"","sources":["../../../src/types/text-codec/text-codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAqB9D,KAAK,gBAAgB,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;AAM5D,oDAAoD;AACpD,MAAM,WAAW,2BAA2B;IAC1C,IAAI,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACzG;AAED,uCAAuC;AACvC,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,mCAAmC;AACnC,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,uCAAuC;AACvC,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,g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B,EAAE,MAAM,EACxB,SAAS,CAAC,EAAE,2BAA2B,EACvC,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,sBAAsB,CAAC;IAuFlC;;;;;;;;OAQG;WACU,eAAe,CAC1B,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,EACxC,SAAS,CAAC,EAAE,2BAA2B,EACvC,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,qBAAqB,CAAC;IAmBjC;;;;;;;;OAQG;WACU,YAAY,CACvB,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,gBAAgB,EAC1B,SAAS,CAAC,EAAE,2BAA2B,EACvC,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,kBAAkB,CAAC;CAoB/B"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * SemanticTuple module
3
+ * LLM-enhanced tuple type with semantic understanding
4
+ */
5
+ export { SemanticTuple, type PositionalMeaning, type InferPositionalMeaningResult, type ValidateRelationshipResult, type ToObjectResult, type GetByLabelResult, type StructureIssue, type ValidateStructureResult, type SemanticEqualsResultWithReason, type DetectPatternResult, } from './tuple.ts';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/tuple/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAC/B,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Prompts for SemanticTuple LLM operations
3
+ * These prompts enable semantic operations on tuple types
4
+ */
5
+ /**
6
+ * System prompt for tuple semantic operations
7
+ */
8
+ export declare const TUPLE_SYSTEM_PROMPT = "You are a semantic tuple analyzer. Your task is to analyze tuples (fixed-length heterogeneous sequences) and understand their positional meaning.\n\nYou must respond with valid JSON only, no additional text or explanation.\n\nGuidelines:\n- Tuples have fixed length and each position typically has a specific meaning\n- Consider common tuple patterns: coordinates (lat/lng), ranges (start/end), RGB colors, key-value pairs, etc.\n- Analyze the relationship between elements at different positions\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
11
+ */
12
+ export declare function createSemanticallyEqualsPrompt(tuple1: unknown[], tuple2: unknown[], labels1?: string[], labels2?: string[]): string;
13
+ /**
14
+ * Prompt for inferring positional meaning
15
+ */
16
+ export declare function createInferPositionalMeaningPrompt(tuple: unknown[], labels?: string[], context?: string): string;
17
+ /**
18
+ * Prompt for validating relationships between elements
19
+ */
20
+ export declare function createValidateRelationshipPrompt(tuple: unknown[], rules: string[], labels?: string[]): string;
21
+ /**
22
+ * Prompt for detecting tuple pattern
23
+ */
24
+ export declare function createDetectPatternPrompt(tuple: unknown[], labels?: string[]): string;
25
+ /**
26
+ * Prompt for converting tuple to labeled object
27
+ */
28
+ export declare function createToObjectPrompt(tuple: unknown[], partialLabels?: string[]): string;
29
+ /**
30
+ * Prompt for getting element by semantic label
31
+ */
32
+ export declare function createGetByLabelPrompt(tuple: unknown[], label: string, existingLabels?: string[]): string;
33
+ /**
34
+ * Prompt for validating tuple structure
35
+ */
36
+ export declare function createValidateStructurePrompt(tuple: unknown[], expectedTypes: string[], labels?: string[]): string;
37
+ /**
38
+ * Prompt for explaining tuple
39
+ */
40
+ export declare function createExplainPrompt(tuple: unknown[], labels?: string[], context?: string): string;
41
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/tuple/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GA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