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,126 @@
1
+ /**
2
+ * SemanticHeaders - LLM-enhanced Headers type with semantic understanding
3
+ *
4
+ * Wraps the native Headers with semantic operations including:
5
+ * - Intelligent header comparison
6
+ * - Validation for common issues
7
+ * - Header suggestions
8
+ * - Human-readable explanations
9
+ */
10
+ import type { LLMConfig, Message } from '../../llm/types.ts';
11
+ /** Result of semantic headers equality */
12
+ export interface HeadersSemanticEqualsResult {
13
+ equivalent: boolean;
14
+ differences: string[];
15
+ }
16
+ /** Individual header issue */
17
+ export interface HeaderIssue {
18
+ header: string;
19
+ issue: string;
20
+ }
21
+ /** Result of headers validation */
22
+ export interface HeadersValidateResult {
23
+ valid: boolean;
24
+ issues: HeaderIssue[];
25
+ }
26
+ /** Suggested header */
27
+ export interface HeaderSuggestion {
28
+ header: string;
29
+ value: string;
30
+ reason: string;
31
+ }
32
+ /** LLM client interface for dependency injection */
33
+ export interface HeadersLLMClientInterface {
34
+ chat(options: {
35
+ messages: Message[];
36
+ systemPrompt?: string;
37
+ } & LLMConfig): Promise<{
38
+ content: string;
39
+ }>;
40
+ }
41
+ /**
42
+ * SemanticHeaders class
43
+ * Wraps Headers with LLM-powered semantic operations
44
+ */
45
+ export declare class SemanticHeaders {
46
+ private readonly _headers;
47
+ private readonly _llmClient;
48
+ private readonly _llmConfig?;
49
+ /**
50
+ * Create a SemanticHeaders instance
51
+ * @param headers - The Headers to wrap
52
+ * @param llmClient - Optional LLM client for dependency injection
53
+ * @param llmConfig - Optional LLM configuration
54
+ */
55
+ constructor(headers: Headers, llmClient?: HeadersLLMClientInterface, llmConfig?: LLMConfig);
56
+ /**
57
+ * Create SemanticHeaders from header init object.
58
+ *
59
+ * @param init - Headers initialization value
60
+ * @param llmClient - Optional LLM client for dependency injection
61
+ * @param llmConfig - Optional LLM configuration
62
+ * @returns SemanticHeaders instance
63
+ */
64
+ static from(init: Headers | Record<string, string> | [string, string][], llmClient?: HeadersLLMClientInterface, llmConfig?: LLMConfig): SemanticHeaders;
65
+ /**
66
+ * Get headers as a plain object
67
+ */
68
+ private _getHeadersObject;
69
+ /**
70
+ * Check if two header sets are semantically equivalent.
71
+ *
72
+ * @param other - Headers to compare
73
+ * @returns Equivalence result
74
+ */
75
+ semanticallyEquals(other: Headers | SemanticHeaders): Promise<HeadersSemanticEqualsResult>;
76
+ /**
77
+ * Validate headers for common issues.
78
+ *
79
+ * @returns Validation result
80
+ */
81
+ validate(): Promise<HeadersValidateResult>;
82
+ /**
83
+ * Suggest missing headers for the context.
84
+ *
85
+ * @param context - Request context (e.g., "API request", "file upload")
86
+ * @returns Suggested headers
87
+ */
88
+ suggest(context?: string): Promise<HeaderSuggestion[]>;
89
+ /**
90
+ * Explain what these headers do.
91
+ *
92
+ * @returns Human-readable explanation
93
+ */
94
+ explain(): Promise<string>;
95
+ /**
96
+ * Get the underlying Headers object
97
+ */
98
+ valueOf(): Headers;
99
+ /** Append a value to an existing header, or add the header if it doesn't exist */
100
+ append(name: string, value: string): void;
101
+ /** Delete a header */
102
+ delete(name: string): void;
103
+ /** Get the value of a header */
104
+ get(name: string): string | null;
105
+ /** Get all values of a header */
106
+ getSetCookie(): string[];
107
+ /** Check if a header exists */
108
+ has(name: string): boolean;
109
+ /** Set the value of a header */
110
+ set(name: string, value: string): void;
111
+ /** Iterate over all headers */
112
+ forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: unknown): void;
113
+ /** Get an iterator of header entries */
114
+ entries(): IterableIterator<[string, string]>;
115
+ /** Get an iterator of header keys */
116
+ keys(): IterableIterator<string>;
117
+ /** Get an iterator of header values */
118
+ values(): IterableIterator<string>;
119
+ /** Make the object iterable */
120
+ [Symbol.iterator](): IterableIterator<[string, string]>;
121
+ /** Convert to plain object */
122
+ toObject(): Record<string, string>;
123
+ /** Convert to string representation */
124
+ toString(): string;
125
+ }
126
+ //# sourceMappingURL=headers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../../src/types/fetch/headers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAY7D,0CAA0C;AAC1C,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,8BAA8B;AAC9B,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,mCAAmC;AACnC,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,uBAAuB;AACvB,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,oDAAoD;AACpD,MA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IAAI,EAAE,MAAM,GAAG,IAAI;IAI1B,gCAAgC;IAChC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIhC,iCAAiC;IACjC,YAAY,IAAI,MAAM,EAAE;IAIxB,+BAA+B;IAC/B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,gCAAgC;IAChC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAItC,+BAA+B;IAC/B,OAAO,CACL,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,EACjE,OAAO,CAAC,EAAE,OAAO,GAChB,IAAI;IAMP,wCAAwC;IACvC,OAAO,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAU9C,qCAAqC;IACpC,IAAI,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAUjC,uCAAuC;IACtC,MAAM,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAUnC,+BAA+B;IAC9B,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAUxD,8BAA8B;IAC9B,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIlC,uCAAuC;IACvC,QAAQ,IAAI,MAAM;CAInB"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * SemanticFetch Module
3
+ * LLM-enhanced Request, Response, and Headers types with semantic understanding
4
+ */
5
+ export { SemanticRequest, type RequestSemanticEqualsResult, type RequestFilter, type RequestIntentResult, type RequestSecurityResult, type RequestLLMClientInterface, } from './request.ts';
6
+ export { SemanticResponse, type ResponseAnalysisResult, type ResponseContract, type ErrorInterpretationResult, type ResponseLLMClientInterface, } from './response.ts';
7
+ export { SemanticHeaders, type HeadersSemanticEqualsResult, type HeaderIssue, type HeadersValidateResult, type HeaderSuggestion, type HeadersLLMClientInterface, } from './headers.ts';
8
+ export type { SemanticEqualsResult, ValidateResult, } from '../../shared/types.ts';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/fetch/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,eAAe,EACf,KAAK,2BAA2B,EAChC,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,GAC/B,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,GAChC,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,eAAe,EACf,KAAK,2BAA2B,EAChC,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,GAC/B,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,oBAAoB,EACpB,cAAc,GACf,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Prompts for SemanticFetch LLM operations
3
+ * These prompts are used for semantic Request, Response, and Headers operations
4
+ */
5
+ /**
6
+ * System prompt for semantic request equality comparison
7
+ */
8
+ export declare const REQUEST_SEMANTIC_EQUALS_SYSTEM = "You are an HTTP request comparison assistant. Your task is to determine if two requests are semantically equivalent.\n\nConsider these factors when comparing:\n- HTTP method differences (case-insensitive)\n- URL path differences (query parameter order, trailing slashes)\n- Header differences (case-insensitive keys, common defaults)\n- Body content differences (JSON key order, whitespace)\n- Authentication mechanisms\n\nAlways respond with valid JSON only.";
9
+ /**
10
+ * User prompt template for semantic request equality
11
+ */
12
+ export declare function requestSemanticEqualsPrompt(req1: {
13
+ method: string;
14
+ url: string;
15
+ headers: Record<string, string>;
16
+ body?: string;
17
+ }, req2: {
18
+ method: string;
19
+ url: string;
20
+ headers: Record<string, string>;
21
+ body?: string;
22
+ }): string;
23
+ /**
24
+ * System prompt for request intent analysis
25
+ */
26
+ export declare const ANALYZE_INTENT_SYSTEM = "You are an HTTP request analyzer. Your task is to understand the intent behind HTTP requests.\n\nConsider:\n- HTTP method semantics (GET=read, POST=create, PUT/PATCH=update, DELETE=delete)\n- URL path patterns for resource identification\n- Query parameters for filtering/pagination\n- Request body for data payloads\n\nAlways respond with valid JSON only.";
27
+ /**
28
+ * User prompt template for intent analysis
29
+ */
30
+ export declare function analyzeIntentPrompt(method: string, url: string, headers: Record<string, string>, body?: string): string;
31
+ /**
32
+ * System prompt for request validation
33
+ */
34
+ export declare const REQUEST_VALIDATE_SYSTEM = "You are an HTTP request validator. Your task is to validate requests against semantic rules.\n\nCommon validation rules to consider:\n- Authentication headers present when required\n- Content-Type matches body format\n- Required headers for specific operations\n- Valid JSON body structure\n- Appropriate HTTP method for operation\n\nAlways respond with valid JSON only.";
35
+ /**
36
+ * User prompt template for request validation
37
+ */
38
+ export declare function requestValidatePrompt(method: string, url: string, headers: Record<string, string>, body: string | undefined, rules: string[]): string;
39
+ /**
40
+ * System prompt for request explanation
41
+ */
42
+ export declare const REQUEST_EXPLAIN_SYSTEM = "You are an HTTP request explainer. Your task is to explain HTTP requests in human-readable terms.\n\nAdjust your explanation based on the target audience:\n- technical: Use proper HTTP terminology, mention headers, methods, etc.\n- non-technical: Focus on the action being performed in plain language\n\nAlways respond with valid JSON only.";
43
+ /**
44
+ * User prompt template for request explanation
45
+ */
46
+ export declare function requestExplainPrompt(method: string, url: string, headers: Record<string, string>, body: string | undefined, audience: 'technical' | 'non-technical'): string;
47
+ /**
48
+ * System prompt for request security validation
49
+ */
50
+ export declare const REQUEST_SECURITY_SYSTEM = "You are an HTTP security analyst. Your task is to assess the security of HTTP requests.\n\nCheck for:\n- Use of HTTPS vs HTTP\n- Sensitive data in URLs (passwords, tokens in query strings)\n- Missing authentication headers for sensitive operations\n- CORS-related headers\n- Content security issues\n- Injection vulnerabilities in parameters\n\nSeverity levels:\n- Issues: Critical security problems that should be fixed\n- Warnings: Potential concerns that should be reviewed\n\nAlways respond with valid JSON only.";
51
+ /**
52
+ * User prompt template for security validation
53
+ */
54
+ export declare function requestSecurityPrompt(method: string, url: string, headers: Record<string, string>, body?: string): string;
55
+ /**
56
+ * System prompt for semantic response equality comparison
57
+ */
58
+ export declare const RESPONSE_SEMANTIC_EQUALS_SYSTEM = "You are an HTTP response comparison assistant. Your task is to determine if two responses are semantically equivalent.\n\nConsider these factors when comparing:\n- Status code equivalence (e.g., 200 and 201 may be equivalent for success)\n- Header differences (ignore timestamps, request IDs)\n- Body content differences (JSON key order, formatting)\n- Semantic meaning of the data\n\nAlways respond with valid JSON only.";
59
+ /**
60
+ * User prompt template for semantic response equality
61
+ */
62
+ export declare function responseSemanticEqualsPrompt(resp1: {
63
+ status: number;
64
+ headers: Record<string, string>;
65
+ body: string;
66
+ }, resp2: {
67
+ status: number;
68
+ headers: Record<string, string>;
69
+ body: string;
70
+ }): string;
71
+ /**
72
+ * System prompt for response analysis
73
+ */
74
+ export declare const ANALYZE_RESPONSE_SYSTEM = "You are an HTTP response analyzer. Your task is to analyze the content and structure of HTTP responses.\n\nIdentify:\n- Data type (single object, collection/array, primitive, error)\n- Entity type (User, Product, Order, etc.)\n- Count of items (for collections)\n- Pagination indicators (hasMore, nextPage, total)\n\nAlways respond with valid JSON only.";
75
+ /**
76
+ * User prompt template for response analysis
77
+ */
78
+ export declare function analyzeResponsePrompt(status: number, headers: Record<string, string>, body: string): string;
79
+ /**
80
+ * System prompt for response summarization
81
+ */
82
+ export declare const SUMMARIZE_RESPONSE_SYSTEM = "You are an HTTP response summarizer. Your task is to provide a concise, human-readable summary of HTTP response content.\n\nFocus on:\n- What data is being returned\n- Key information in the response\n- Status and success/failure indication\n- Relevant metadata\n\nAlways respond with valid JSON only.";
83
+ /**
84
+ * User prompt template for response summarization
85
+ */
86
+ export declare function summarizeResponsePrompt(status: number, headers: Record<string, string>, body: string): string;
87
+ /**
88
+ * System prompt for contract validation
89
+ */
90
+ export declare const VALIDATE_CONTRACT_SYSTEM = "You are an API contract validator. Your task is to validate HTTP responses against expected contracts.\n\nCheck:\n- Status codes match expected values\n- Required headers are present\n- Body structure matches schema description\n- Data types are correct\n\nAlways respond with valid JSON only.";
91
+ /**
92
+ * User prompt template for contract validation
93
+ */
94
+ export declare function validateContractPrompt(status: number, headers: Record<string, string>, body: string, contract: {
95
+ status?: number[];
96
+ schema?: string;
97
+ requiredHeaders?: string[];
98
+ }): string;
99
+ /**
100
+ * System prompt for error interpretation
101
+ */
102
+ export declare const INTERPRET_ERROR_SYSTEM = "You are an HTTP error interpreter. Your task is to interpret error responses and provide actionable guidance.\n\nConsider:\n- HTTP status code meaning\n- Error message in body\n- Common error patterns\n- Potential causes and solutions\n\nError categories:\n- authentication: Auth/permission issues\n- validation: Invalid input/parameters\n- not_found: Resource doesn't exist\n- rate_limit: Too many requests\n- server_error: Server-side issues\n- network: Connection issues\n\nAlways respond with valid JSON only.";
103
+ /**
104
+ * User prompt template for error interpretation
105
+ */
106
+ export declare function interpretErrorPrompt(status: number, headers: Record<string, string>, body: string): string;
107
+ /**
108
+ * System prompt for semantic headers equality comparison
109
+ */
110
+ export declare const HEADERS_SEMANTIC_EQUALS_SYSTEM = "You are an HTTP headers comparison assistant. Your task is to determine if two sets of headers are semantically equivalent.\n\nConsider:\n- Header names are case-insensitive\n- Common default values\n- Order doesn't matter\n- Timestamps and request IDs may differ\n- Some headers are semantically equivalent (e.g., different cache directives)\n\nAlways respond with valid JSON only.";
111
+ /**
112
+ * User prompt template for semantic headers equality
113
+ */
114
+ export declare function headersSemanticEqualsPrompt(headers1: Record<string, string>, headers2: Record<string, string>): string;
115
+ /**
116
+ * System prompt for headers validation
117
+ */
118
+ export declare const HEADERS_VALIDATE_SYSTEM = "You are an HTTP headers validator. Your task is to validate headers for common issues.\n\nCheck for:\n- Invalid or malformed header values\n- Conflicting headers\n- Security issues (missing security headers)\n- Content-Type mismatches\n- Deprecated headers\n- Missing required headers for certain operations\n\nAlways respond with valid JSON only.";
119
+ /**
120
+ * User prompt template for headers validation
121
+ */
122
+ export declare function headersValidatePrompt(headers: Record<string, string>): string;
123
+ /**
124
+ * System prompt for headers suggestions
125
+ */
126
+ export declare const HEADERS_SUGGEST_SYSTEM = "You are an HTTP headers advisor. Your task is to suggest missing or recommended headers based on context.\n\nConsider suggesting:\n- Security headers (Content-Security-Policy, X-Frame-Options, etc.)\n- Caching headers (Cache-Control, ETag)\n- Content negotiation headers\n- CORS headers if needed\n- Authentication headers\n- Compression headers\n\nAlways respond with valid JSON only.";
127
+ /**
128
+ * User prompt template for headers suggestions
129
+ */
130
+ export declare function headersSuggestPrompt(headers: Record<string, string>, context?: string): string;
131
+ /**
132
+ * System prompt for headers explanation
133
+ */
134
+ export declare const HEADERS_EXPLAIN_SYSTEM = "You are an HTTP headers explainer. Your task is to explain what a set of headers does in plain language.\n\nCover:\n- Purpose of each significant header\n- How they affect the request/response\n- Security implications\n- Caching behavior\n- Content handling\n\nAlways respond with valid JSON only.";
135
+ /**
136
+ * User prompt template for headers explanation
137
+ */
138
+ export declare function headersExplainPrompt(headers: Record<string, string>): string;
139
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/fetch/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;GAEG;AACH,eAAO,MAAM,8BAA8B,gdASN,CAAC;AAEtC;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EACrF,IAAI,EAAE;IAAE,MAAM,EAAE,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AO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,EAAE,MAAM,GACX,MAAM,CASR;AAMD;;GAEG;AACH,eAAO,MAAM,8BAA8B,mYASN,CAAC;AAEtC;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,MAAM,CAQR;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,gWAUC,CAAC;AAEtC;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAO7E;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,sYAUE,CAAC;AAEtC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAQR;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,8SASE,CAAC;AAEtC;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAO5E"}
@@ -0,0 +1,188 @@
1
+ /**
2
+ * SemanticRequest - LLM-enhanced Request type with semantic understanding
3
+ *
4
+ * Wraps the native Request with semantic operations including:
5
+ * - Intelligent request comparison
6
+ * - Intent analysis
7
+ * - Validation against semantic rules
8
+ * - Human-readable explanations
9
+ * - Security assessment
10
+ */
11
+ import type { LLMConfig, Message } from '../../llm/types.ts';
12
+ import type { SemanticEqualsResult, ValidateResult } from '../../shared/types.ts';
13
+ /** Extended semantic equals result with note */
14
+ export interface RequestSemanticEqualsResult extends SemanticEqualsResult {
15
+ note?: string;
16
+ }
17
+ /** Filter criteria from request analysis */
18
+ export interface RequestFilter {
19
+ field: string;
20
+ value: unknown;
21
+ }
22
+ /** Result of request intent analysis */
23
+ export interface RequestIntentResult {
24
+ intent: string;
25
+ operation: 'CREATE' | 'READ' | 'UPDATE' | 'DELETE';
26
+ resource: string;
27
+ filters?: RequestFilter[];
28
+ }
29
+ /** Result of request security validation */
30
+ export interface RequestSecurityResult {
31
+ safe: boolean;
32
+ issues: string[];
33
+ warnings: string[];
34
+ }
35
+ /** LLM client interface for dependency injection */
36
+ export interface RequestLLMClientInterface {
37
+ chat(options: {
38
+ messages: Message[];
39
+ systemPrompt?: string;
40
+ } & LLMConfig): Promise<{
41
+ content: string;
42
+ }>;
43
+ }
44
+ /**
45
+ * SemanticRequest class
46
+ * Wraps a Request with LLM-powered semantic operations
47
+ */
48
+ export declare class SemanticRequest {
49
+ private readonly _request;
50
+ private readonly _llmClient;
51
+ private readonly _llmConfig?;
52
+ private _cachedBody?;
53
+ /**
54
+ * Create a SemanticRequest instance
55
+ * @param request - The Request to wrap
56
+ * @param llmClient - Optional LLM client for dependency injection
57
+ * @param llmConfig - Optional LLM configuration
58
+ */
59
+ constructor(request: Request, llmClient?: RequestLLMClientInterface, llmConfig?: LLMConfig);
60
+ /**
61
+ * Create a SemanticRequest from URL or request options.
62
+ *
63
+ * @param input - URL string or Request object
64
+ * @param init - Optional RequestInit options
65
+ * @param llmClient - Optional LLM client for dependency injection
66
+ * @param llmConfig - Optional LLM configuration
67
+ * @returns SemanticRequest instance
68
+ *
69
+ * @example
70
+ * SemanticRequest.from("/api/users?role=admin", { method: "GET" })
71
+ * SemanticRequest.from(existingRequest)
72
+ */
73
+ static from(input: string | URL | Request, init?: RequestInit, llmClient?: RequestLLMClientInterface, llmConfig?: LLMConfig): SemanticRequest;
74
+ /**
75
+ * Get headers as a plain object
76
+ */
77
+ private _getHeadersObject;
78
+ /**
79
+ * Get the request body as text (cached)
80
+ */
81
+ private _getBodyText;
82
+ /**
83
+ * Check if two requests are semantically equivalent.
84
+ *
85
+ * @param other - Request to compare
86
+ * @returns Equivalence result
87
+ *
88
+ * @example
89
+ * req1.semanticallyEquals(req2)
90
+ * // { equivalent: true, note: "Same params, different order", confidence: 0.95 }
91
+ */
92
+ semanticallyEquals(other: Request | SemanticRequest): Promise<RequestSemanticEqualsResult>;
93
+ /**
94
+ * Analyze the intent of this request.
95
+ *
96
+ * @returns Request intent analysis
97
+ *
98
+ * @example
99
+ * request.analyzeIntent()
100
+ * // {
101
+ * // intent: "fetch paginated users",
102
+ * // operation: "READ",
103
+ * // resource: "users",
104
+ * // filters: [{ field: "role", value: "admin" }]
105
+ * // }
106
+ */
107
+ analyzeIntent(): Promise<RequestIntentResult>;
108
+ /**
109
+ * Validate the request against semantic rules.
110
+ *
111
+ * @param rules - Validation rules (optional, uses defaults if not provided)
112
+ * @returns Validation result
113
+ *
114
+ * @example
115
+ * request.validate(["must include authentication", "body must be valid JSON"])
116
+ */
117
+ validate(rules?: string[]): Promise<ValidateResult>;
118
+ /**
119
+ * Explain what this request does.
120
+ *
121
+ * @param audience - Target audience (defaults to "technical")
122
+ * @returns Human-readable explanation
123
+ *
124
+ * @example
125
+ * request.explain("non-technical")
126
+ * // "Fetching the list of admin users"
127
+ */
128
+ explain(audience?: 'technical' | 'non-technical'): Promise<string>;
129
+ /**
130
+ * Check if the request is safe (no security issues).
131
+ *
132
+ * @returns Security assessment
133
+ *
134
+ * @example
135
+ * request.validateSecurity()
136
+ * // { safe: true, issues: [], warnings: ["Consider using HTTPS"] }
137
+ */
138
+ validateSecurity(): Promise<RequestSecurityResult>;
139
+ /**
140
+ * Get the underlying Request object
141
+ */
142
+ valueOf(): Request;
143
+ /** Get the request method */
144
+ get method(): string;
145
+ /** Get the request URL */
146
+ get url(): string;
147
+ /** Get the request headers */
148
+ get headers(): Headers;
149
+ /** Get the request body (ReadableStream) */
150
+ get body(): ReadableStream<Uint8Array> | null;
151
+ /** Check if body has been used */
152
+ get bodyUsed(): boolean;
153
+ /** Get the request cache mode */
154
+ get cache(): string;
155
+ /** Get the request credentials mode */
156
+ get credentials(): string;
157
+ /** Get the request destination */
158
+ get destination(): string;
159
+ /** Get the request integrity */
160
+ get integrity(): string;
161
+ /** Get the request keepalive flag */
162
+ get keepalive(): boolean;
163
+ /** Get the request mode */
164
+ get mode(): string;
165
+ /** Get the request redirect mode */
166
+ get redirect(): string;
167
+ /** Get the request referrer */
168
+ get referrer(): string;
169
+ /** Get the request referrer policy */
170
+ get referrerPolicy(): string;
171
+ /** Get the abort signal */
172
+ get signal(): AbortSignal;
173
+ /** Clone the request */
174
+ clone(): SemanticRequest;
175
+ /** Get body as ArrayBuffer */
176
+ arrayBuffer(): Promise<ArrayBuffer>;
177
+ /** Get body as Blob */
178
+ blob(): Promise<Blob>;
179
+ /** Get body as FormData */
180
+ formData(): Promise<FormData>;
181
+ /** Get body as JSON */
182
+ json(): Promise<unknown>;
183
+ /** Get body as text */
184
+ text(): Promise<string>;
185
+ /** Convert to string representation */
186
+ toString(): string;
187
+ }
188
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/types/fetch/request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAclF,gDAAgD;AAChD,MAAM,WAAW,2BAA4B,SAAQ,oBAAoB;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB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AQ,IAAI,OAAO,CAAC,QAAQ,CAAC;IAI7B,uBAAuB;IACvB,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAIxB,uBAAuB;IACvB,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAIvB,uCAAuC;IACvC,QAAQ,IAAI,MAAM;CAGnB"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * SemanticResponse - LLM-enhanced Response type with semantic understanding
3
+ *
4
+ * Wraps the native Response with semantic operations including:
5
+ * - Intelligent response comparison
6
+ * - Content analysis
7
+ * - Response summarization
8
+ * - Contract validation
9
+ * - Error interpretation
10
+ */
11
+ import type { LLMConfig, Message } from '../../llm/types.ts';
12
+ import type { SemanticEqualsResult, ValidateResult } from '../../shared/types.ts';
13
+ /** Result of response analysis */
14
+ export interface ResponseAnalysisResult {
15
+ dataType: string;
16
+ entityType?: string;
17
+ count?: number;
18
+ pagination?: {
19
+ hasMore: boolean;
20
+ };
21
+ }
22
+ /** Contract for response validation */
23
+ export interface ResponseContract {
24
+ status?: number[];
25
+ schema?: string;
26
+ requiredHeaders?: string[];
27
+ }
28
+ /** Result of error interpretation */
29
+ export interface ErrorInterpretationResult {
30
+ category: string;
31
+ message: string;
32
+ suggestedAction: string;
33
+ retryable: boolean;
34
+ }
35
+ /** LLM client interface for dependency injection */
36
+ export interface ResponseLLMClientInterface {
37
+ chat(options: {
38
+ messages: Message[];
39
+ systemPrompt?: string;
40
+ } & LLMConfig): Promise<{
41
+ content: string;
42
+ }>;
43
+ }
44
+ /**
45
+ * SemanticResponse class
46
+ * Wraps a Response with LLM-powered semantic operations
47
+ */
48
+ export declare class SemanticResponse {
49
+ private readonly _response;
50
+ private readonly _llmClient;
51
+ private readonly _llmConfig?;
52
+ private _cachedBody?;
53
+ /**
54
+ * Create a SemanticResponse instance
55
+ * @param response - The Response to wrap
56
+ * @param llmClient - Optional LLM client for dependency injection
57
+ * @param llmConfig - Optional LLM configuration
58
+ */
59
+ constructor(response: Response, llmClient?: ResponseLLMClientInterface, llmConfig?: LLMConfig);
60
+ /**
61
+ * Wrap a Response with semantic capabilities.
62
+ *
63
+ * @param response - Response to wrap
64
+ * @param llmClient - Optional LLM client for dependency injection
65
+ * @param llmConfig - Optional LLM configuration
66
+ * @returns SemanticResponse instance
67
+ */
68
+ static from(response: Response, llmClient?: ResponseLLMClientInterface, llmConfig?: LLMConfig): SemanticResponse;
69
+ /**
70
+ * Get headers as a plain object
71
+ */
72
+ private _getHeadersObject;
73
+ /**
74
+ * Get the response body as text (cached)
75
+ */
76
+ private _getBodyText;
77
+ /**
78
+ * Check if two responses are semantically equivalent.
79
+ *
80
+ * @param other - Response to compare
81
+ * @returns Equivalence result
82
+ */
83
+ semanticallyEquals(other: Response | SemanticResponse): Promise<SemanticEqualsResult>;
84
+ /**
85
+ * Analyze the response content.
86
+ *
87
+ * @returns Response analysis
88
+ *
89
+ * @example
90
+ * response.analyze()
91
+ * // {
92
+ * // dataType: "collection",
93
+ * // entityType: "User",
94
+ * // count: 25,
95
+ * // pagination: { hasMore: true }
96
+ * // }
97
+ */
98
+ analyze(): Promise<ResponseAnalysisResult>;
99
+ /**
100
+ * Summarize the response body.
101
+ *
102
+ * @returns Human-readable summary
103
+ */
104
+ summarize(): Promise<string>;
105
+ /**
106
+ * Validate response against expected contract.
107
+ *
108
+ * @param contract - Expected response shape
109
+ * @returns Validation result
110
+ */
111
+ validateContract(contract: ResponseContract): Promise<ValidateResult>;
112
+ /**
113
+ * Interpret error responses with context.
114
+ *
115
+ * @returns Error interpretation
116
+ */
117
+ interpretError(): Promise<ErrorInterpretationResult>;
118
+ /**
119
+ * Get the underlying Response object
120
+ */
121
+ valueOf(): Response;
122
+ /** Get the response status code */
123
+ get status(): number;
124
+ /** Get the response status text */
125
+ get statusText(): string;
126
+ /** Get the response headers */
127
+ get headers(): Headers;
128
+ /** Check if response is OK (status 200-299) */
129
+ get ok(): boolean;
130
+ /** Check if response was redirected */
131
+ get redirected(): boolean;
132
+ /** Get the response type */
133
+ get type(): string;
134
+ /** Get the response URL */
135
+ get url(): string;
136
+ /** Get the response body (ReadableStream) */
137
+ get body(): ReadableStream<Uint8Array> | null;
138
+ /** Check if body has been used */
139
+ get bodyUsed(): boolean;
140
+ /** Clone the response */
141
+ clone(): SemanticResponse;
142
+ /** Get body as ArrayBuffer */
143
+ arrayBuffer(): Promise<ArrayBuffer>;
144
+ /** Get body as Blob */
145
+ blob(): Promise<Blob>;
146
+ /** Get body as FormData */
147
+ formData(): Promise<FormData>;
148
+ /** Get body as JSON */
149
+ json(): Promise<unknown>;
150
+ /** Get body as text */
151
+ text(): Promise<string>;
152
+ /** Convert to string representation */
153
+ toString(): string;
154
+ }
155
+ //# sourceMappingURL=response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../src/types/fetch/response.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAclF,kCAAkC;AAClC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CACnC;AAED,uCAAuC;AACvC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,qCAAqC;AACrC,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAA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