@weaveintel/core 0.0.1

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 (266) hide show
  1. package/README.md +91 -0
  2. package/dist/a2a.d.ts +304 -0
  3. package/dist/a2a.d.ts.map +1 -0
  4. package/dist/a2a.js +68 -0
  5. package/dist/a2a.js.map +1 -0
  6. package/dist/admin-capabilities.d.ts +60 -0
  7. package/dist/admin-capabilities.d.ts.map +1 -0
  8. package/dist/admin-capabilities.js +31 -0
  9. package/dist/admin-capabilities.js.map +1 -0
  10. package/dist/agents.d.ts +214 -0
  11. package/dist/agents.d.ts.map +1 -0
  12. package/dist/agents.js +12 -0
  13. package/dist/agents.js.map +1 -0
  14. package/dist/artifacts.d.ts +70 -0
  15. package/dist/artifacts.d.ts.map +1 -0
  16. package/dist/artifacts.js +5 -0
  17. package/dist/artifacts.js.map +1 -0
  18. package/dist/cache.d.ts +177 -0
  19. package/dist/cache.d.ts.map +1 -0
  20. package/dist/cache.js +9 -0
  21. package/dist/cache.js.map +1 -0
  22. package/dist/callables.d.ts +34 -0
  23. package/dist/callables.d.ts.map +1 -0
  24. package/dist/callables.js +35 -0
  25. package/dist/callables.js.map +1 -0
  26. package/dist/capabilities.d.ts +77 -0
  27. package/dist/capabilities.d.ts.map +1 -0
  28. package/dist/capabilities.js +82 -0
  29. package/dist/capabilities.js.map +1 -0
  30. package/dist/capability-policy.d.ts +41 -0
  31. package/dist/capability-policy.d.ts.map +1 -0
  32. package/dist/capability-policy.js +34 -0
  33. package/dist/capability-policy.js.map +1 -0
  34. package/dist/collaboration.d.ts +45 -0
  35. package/dist/collaboration.d.ts.map +1 -0
  36. package/dist/collaboration.js +5 -0
  37. package/dist/collaboration.js.map +1 -0
  38. package/dist/compliance.d.ts +71 -0
  39. package/dist/compliance.d.ts.map +1 -0
  40. package/dist/compliance.js +5 -0
  41. package/dist/compliance.js.map +1 -0
  42. package/dist/connectors.d.ts +109 -0
  43. package/dist/connectors.d.ts.map +1 -0
  44. package/dist/connectors.js +24 -0
  45. package/dist/connectors.js.map +1 -0
  46. package/dist/context.d.ts +52 -0
  47. package/dist/context.d.ts.map +1 -0
  48. package/dist/context.js +70 -0
  49. package/dist/context.js.map +1 -0
  50. package/dist/contracts.d.ts +70 -0
  51. package/dist/contracts.d.ts.map +1 -0
  52. package/dist/contracts.js +5 -0
  53. package/dist/contracts.js.map +1 -0
  54. package/dist/documents.d.ts +55 -0
  55. package/dist/documents.d.ts.map +1 -0
  56. package/dist/documents.js +9 -0
  57. package/dist/documents.js.map +1 -0
  58. package/dist/error-classifier.d.ts +67 -0
  59. package/dist/error-classifier.d.ts.map +1 -0
  60. package/dist/error-classifier.js +129 -0
  61. package/dist/error-classifier.js.map +1 -0
  62. package/dist/errors.d.ts +27 -0
  63. package/dist/errors.d.ts.map +1 -0
  64. package/dist/errors.js +63 -0
  65. package/dist/errors.js.map +1 -0
  66. package/dist/evals.d.ts +55 -0
  67. package/dist/evals.d.ts.map +1 -0
  68. package/dist/evals.js +9 -0
  69. package/dist/evals.js.map +1 -0
  70. package/dist/events.d.ts +60 -0
  71. package/dist/events.d.ts.map +1 -0
  72. package/dist/events.js +108 -0
  73. package/dist/events.js.map +1 -0
  74. package/dist/extraction.d.ts +71 -0
  75. package/dist/extraction.d.ts.map +1 -0
  76. package/dist/extraction.js +5 -0
  77. package/dist/extraction.js.map +1 -0
  78. package/dist/files.d.ts +39 -0
  79. package/dist/files.d.ts.map +1 -0
  80. package/dist/files.js +9 -0
  81. package/dist/files.js.map +1 -0
  82. package/dist/finetuning.d.ts +58 -0
  83. package/dist/finetuning.d.ts.map +1 -0
  84. package/dist/finetuning.js +9 -0
  85. package/dist/finetuning.js.map +1 -0
  86. package/dist/graph.d.ts +70 -0
  87. package/dist/graph.d.ts.map +1 -0
  88. package/dist/graph.js +5 -0
  89. package/dist/graph.js.map +1 -0
  90. package/dist/guardrails.d.ts +221 -0
  91. package/dist/guardrails.d.ts.map +1 -0
  92. package/dist/guardrails.js +2 -0
  93. package/dist/guardrails.js.map +1 -0
  94. package/dist/hardened-fetch.d.ts +80 -0
  95. package/dist/hardened-fetch.d.ts.map +1 -0
  96. package/dist/hardened-fetch.js +251 -0
  97. package/dist/hardened-fetch.js.map +1 -0
  98. package/dist/human-tasks.d.ts +141 -0
  99. package/dist/human-tasks.d.ts.map +1 -0
  100. package/dist/human-tasks.js +5 -0
  101. package/dist/human-tasks.js.map +1 -0
  102. package/dist/identity.d.ts +53 -0
  103. package/dist/identity.d.ts.map +1 -0
  104. package/dist/identity.js +5 -0
  105. package/dist/identity.js.map +1 -0
  106. package/dist/index.d.ts +66 -0
  107. package/dist/index.d.ts.map +1 -0
  108. package/dist/index.js +163 -0
  109. package/dist/index.js.map +1 -0
  110. package/dist/json-patch.d.ts +72 -0
  111. package/dist/json-patch.d.ts.map +1 -0
  112. package/dist/json-patch.js +239 -0
  113. package/dist/json-patch.js.map +1 -0
  114. package/dist/logger.d.ts +29 -0
  115. package/dist/logger.d.ts.map +1 -0
  116. package/dist/logger.js +74 -0
  117. package/dist/logger.js.map +1 -0
  118. package/dist/managed-vectorstore.d.ts +88 -0
  119. package/dist/managed-vectorstore.d.ts.map +1 -0
  120. package/dist/managed-vectorstore.js +10 -0
  121. package/dist/managed-vectorstore.js.map +1 -0
  122. package/dist/mcp.d.ts +195 -0
  123. package/dist/mcp.d.ts.map +1 -0
  124. package/dist/mcp.js +9 -0
  125. package/dist/mcp.js.map +1 -0
  126. package/dist/memory.d.ts +152 -0
  127. package/dist/memory.d.ts.map +1 -0
  128. package/dist/memory.js +10 -0
  129. package/dist/memory.js.map +1 -0
  130. package/dist/middleware.d.ts +40 -0
  131. package/dist/middleware.d.ts.map +1 -0
  132. package/dist/middleware.js +79 -0
  133. package/dist/middleware.js.map +1 -0
  134. package/dist/models.d.ts +279 -0
  135. package/dist/models.d.ts.map +1 -0
  136. package/dist/models.js +12 -0
  137. package/dist/models.js.map +1 -0
  138. package/dist/moderation.d.ts +39 -0
  139. package/dist/moderation.d.ts.map +1 -0
  140. package/dist/moderation.js +10 -0
  141. package/dist/moderation.js.map +1 -0
  142. package/dist/net-guard.d.ts +60 -0
  143. package/dist/net-guard.d.ts.map +1 -0
  144. package/dist/net-guard.js +250 -0
  145. package/dist/net-guard.js.map +1 -0
  146. package/dist/notifications.d.ts +121 -0
  147. package/dist/notifications.d.ts.map +1 -0
  148. package/dist/notifications.js +12 -0
  149. package/dist/notifications.js.map +1 -0
  150. package/dist/observability-runtime.d.ts +16 -0
  151. package/dist/observability-runtime.d.ts.map +1 -0
  152. package/dist/observability-runtime.js +34 -0
  153. package/dist/observability-runtime.js.map +1 -0
  154. package/dist/observability.d.ts +130 -0
  155. package/dist/observability.d.ts.map +1 -0
  156. package/dist/observability.js +9 -0
  157. package/dist/observability.js.map +1 -0
  158. package/dist/plugins.d.ts +46 -0
  159. package/dist/plugins.d.ts.map +1 -0
  160. package/dist/plugins.js +5 -0
  161. package/dist/plugins.js.map +1 -0
  162. package/dist/prompts.d.ts +219 -0
  163. package/dist/prompts.d.ts.map +1 -0
  164. package/dist/prompts.js +5 -0
  165. package/dist/prompts.js.map +1 -0
  166. package/dist/registry.d.ts +31 -0
  167. package/dist/registry.d.ts.map +1 -0
  168. package/dist/registry.js +34 -0
  169. package/dist/registry.js.map +1 -0
  170. package/dist/reliability.d.ts +68 -0
  171. package/dist/reliability.d.ts.map +1 -0
  172. package/dist/reliability.js +5 -0
  173. package/dist/reliability.js.map +1 -0
  174. package/dist/replay.d.ts +91 -0
  175. package/dist/replay.d.ts.map +1 -0
  176. package/dist/replay.js +5 -0
  177. package/dist/replay.js.map +1 -0
  178. package/dist/responses.d.ts +273 -0
  179. package/dist/responses.d.ts.map +1 -0
  180. package/dist/responses.js +11 -0
  181. package/dist/responses.js.map +1 -0
  182. package/dist/routing.d.ts +171 -0
  183. package/dist/routing.d.ts.map +1 -0
  184. package/dist/routing.js +5 -0
  185. package/dist/routing.js.map +1 -0
  186. package/dist/run-events.d.ts +199 -0
  187. package/dist/run-events.d.ts.map +1 -0
  188. package/dist/run-events.js +88 -0
  189. package/dist/run-events.js.map +1 -0
  190. package/dist/run-journal.d.ts +66 -0
  191. package/dist/run-journal.d.ts.map +1 -0
  192. package/dist/run-journal.js +153 -0
  193. package/dist/run-journal.js.map +1 -0
  194. package/dist/run-registry.d.ts +49 -0
  195. package/dist/run-registry.d.ts.map +1 -0
  196. package/dist/run-registry.js +154 -0
  197. package/dist/run-registry.js.map +1 -0
  198. package/dist/run-substrate-contract.d.ts +48 -0
  199. package/dist/run-substrate-contract.d.ts.map +1 -0
  200. package/dist/run-substrate-contract.js +124 -0
  201. package/dist/run-substrate-contract.js.map +1 -0
  202. package/dist/runs.d.ts +94 -0
  203. package/dist/runs.d.ts.map +1 -0
  204. package/dist/runs.js +12 -0
  205. package/dist/runs.js.map +1 -0
  206. package/dist/runtime.d.ts +665 -0
  207. package/dist/runtime.d.ts.map +1 -0
  208. package/dist/runtime.js +436 -0
  209. package/dist/runtime.js.map +1 -0
  210. package/dist/sandbox.d.ts +50 -0
  211. package/dist/sandbox.d.ts.map +1 -0
  212. package/dist/sandbox.js +5 -0
  213. package/dist/sandbox.js.map +1 -0
  214. package/dist/secrets.d.ts +34 -0
  215. package/dist/secrets.d.ts.map +1 -0
  216. package/dist/secrets.js +68 -0
  217. package/dist/secrets.js.map +1 -0
  218. package/dist/security.d.ts +97 -0
  219. package/dist/security.d.ts.map +1 -0
  220. package/dist/security.js +9 -0
  221. package/dist/security.js.map +1 -0
  222. package/dist/sse-parser.d.ts +67 -0
  223. package/dist/sse-parser.d.ts.map +1 -0
  224. package/dist/sse-parser.js +156 -0
  225. package/dist/sse-parser.js.map +1 -0
  226. package/dist/sse-writer.d.ts +63 -0
  227. package/dist/sse-writer.d.ts.map +1 -0
  228. package/dist/sse-writer.js +87 -0
  229. package/dist/sse-writer.js.map +1 -0
  230. package/dist/surface-catalog.d.ts +68 -0
  231. package/dist/surface-catalog.d.ts.map +1 -0
  232. package/dist/surface-catalog.js +13 -0
  233. package/dist/surface-catalog.js.map +1 -0
  234. package/dist/tenancy.d.ts +67 -0
  235. package/dist/tenancy.d.ts.map +1 -0
  236. package/dist/tenancy.js +5 -0
  237. package/dist/tenancy.js.map +1 -0
  238. package/dist/tool-lifecycle.d.ts +118 -0
  239. package/dist/tool-lifecycle.d.ts.map +1 -0
  240. package/dist/tool-lifecycle.js +5 -0
  241. package/dist/tool-lifecycle.js.map +1 -0
  242. package/dist/tools.d.ts +96 -0
  243. package/dist/tools.d.ts.map +1 -0
  244. package/dist/tools.js +71 -0
  245. package/dist/tools.js.map +1 -0
  246. package/dist/triggers.d.ts +48 -0
  247. package/dist/triggers.d.ts.map +1 -0
  248. package/dist/triggers.js +5 -0
  249. package/dist/triggers.js.map +1 -0
  250. package/dist/ui-events.d.ts +96 -0
  251. package/dist/ui-events.d.ts.map +1 -0
  252. package/dist/ui-events.js +5 -0
  253. package/dist/ui-events.js.map +1 -0
  254. package/dist/uuid.d.ts +27 -0
  255. package/dist/uuid.d.ts.map +1 -0
  256. package/dist/uuid.js +54 -0
  257. package/dist/uuid.js.map +1 -0
  258. package/dist/vectorstore.d.ts +76 -0
  259. package/dist/vectorstore.d.ts.map +1 -0
  260. package/dist/vectorstore.js +9 -0
  261. package/dist/vectorstore.js.map +1 -0
  262. package/dist/workflows.d.ts +554 -0
  263. package/dist/workflows.d.ts.map +1 -0
  264. package/dist/workflows.js +29 -0
  265. package/dist/workflows.js.map +1 -0
  266. package/package.json +33 -0
@@ -0,0 +1,279 @@
1
+ /**
2
+ * @weaveintel/core — Model contracts
3
+ *
4
+ * Why: Model interfaces define what any LLM provider must implement.
5
+ * We use capability composition, not class hierarchies. A model declares
6
+ * its capabilities and consumers check them at runtime.
7
+ *
8
+ * The contracts split input/output types from the model interface itself,
9
+ * so structured output, streaming, and tool calling are composable features.
10
+ */
11
+ import type { CapabilityId, HasCapabilities } from './capabilities.js';
12
+ import type { ExecutionContext } from './context.js';
13
+ export type Role = 'system' | 'user' | 'assistant' | 'tool';
14
+ export interface TextContent {
15
+ readonly type: 'text';
16
+ readonly text: string;
17
+ }
18
+ export interface ImageContent {
19
+ readonly type: 'image';
20
+ readonly url?: string;
21
+ readonly base64?: string;
22
+ readonly mimeType?: string;
23
+ }
24
+ export interface AudioContent {
25
+ readonly type: 'audio';
26
+ readonly url?: string;
27
+ readonly base64?: string;
28
+ readonly mimeType?: string;
29
+ }
30
+ export interface FileContent {
31
+ readonly type: 'file';
32
+ readonly url?: string;
33
+ readonly base64?: string;
34
+ readonly mimeType?: string;
35
+ readonly filename?: string;
36
+ }
37
+ export type ContentPart = TextContent | ImageContent | AudioContent | FileContent;
38
+ export interface Message {
39
+ readonly role: Role;
40
+ readonly content: string | ContentPart[];
41
+ readonly name?: string;
42
+ readonly toolCallId?: string;
43
+ readonly toolCalls?: readonly ToolCall[];
44
+ }
45
+ export interface ToolDefinition {
46
+ readonly name: string;
47
+ readonly description: string;
48
+ readonly parameters: JsonSchema;
49
+ readonly strict?: boolean;
50
+ }
51
+ export interface ToolCall {
52
+ readonly id: string;
53
+ readonly name: string;
54
+ readonly arguments: string;
55
+ }
56
+ export interface ToolResult {
57
+ readonly toolCallId: string;
58
+ readonly content: string;
59
+ readonly isError?: boolean;
60
+ }
61
+ export type JsonSchema = {
62
+ readonly type?: string;
63
+ readonly properties?: Record<string, JsonSchema>;
64
+ readonly required?: readonly string[];
65
+ readonly items?: JsonSchema;
66
+ readonly description?: string;
67
+ readonly enum?: readonly unknown[];
68
+ readonly [key: string]: unknown;
69
+ };
70
+ export interface ResponseFormat {
71
+ readonly type: 'json_object' | 'json_schema';
72
+ readonly schema?: JsonSchema;
73
+ readonly name?: string;
74
+ readonly strict?: boolean;
75
+ }
76
+ export interface ModelRequest {
77
+ readonly messages: readonly Message[];
78
+ readonly tools?: readonly ToolDefinition[];
79
+ readonly toolChoice?: 'auto' | 'none' | 'required' | {
80
+ name: string;
81
+ };
82
+ readonly responseFormat?: ResponseFormat;
83
+ readonly temperature?: number;
84
+ readonly maxTokens?: number;
85
+ readonly topP?: number;
86
+ readonly stop?: readonly string[];
87
+ readonly stream?: boolean;
88
+ readonly metadata?: Record<string, unknown>;
89
+ /**
90
+ * Provider-native prompt caching hint. When set, the provider caches the
91
+ * stable prefix (tools + system) so repeated requests sharing that prefix pay
92
+ * the discounted cache-read rate (~90% off input on Anthropic).
93
+ *
94
+ * - Anthropic: applies an explicit `cache_control: ephemeral` breakpoint to
95
+ * the system block (covering tools + system in render order).
96
+ * - OpenAI / Gemini: caching is automatic/implicit, so this is a no-op hint —
97
+ * the benefit comes from a stable, static-first prefix.
98
+ *
99
+ * `ttl` selects the cache lifetime where the provider supports it
100
+ * (`'5m'` default, `'1h'` extended).
101
+ */
102
+ readonly promptCache?: {
103
+ readonly ttl?: '5m' | '1h';
104
+ };
105
+ }
106
+ export interface ModelResponse {
107
+ readonly id: string;
108
+ readonly content: string;
109
+ readonly toolCalls?: readonly ToolCall[];
110
+ readonly finishReason: 'stop' | 'tool_calls' | 'length' | 'content_filter' | 'error';
111
+ readonly usage: TokenUsage;
112
+ readonly model: string;
113
+ readonly reasoning?: string;
114
+ readonly metadata?: Record<string, unknown>;
115
+ }
116
+ export interface TokenUsage {
117
+ readonly promptTokens: number;
118
+ readonly completionTokens: number;
119
+ readonly totalTokens: number;
120
+ readonly reasoningTokens?: number;
121
+ /**
122
+ * Input tokens served from the provider's prompt cache at the discounted
123
+ * read rate (Anthropic `cache_read_input_tokens`, OpenAI
124
+ * `prompt_tokens_details.cached_tokens`, Gemini `cachedContentTokenCount`).
125
+ * Present and > 0 indicates a prompt-cache hit. Included within `promptTokens`.
126
+ */
127
+ readonly cacheReadTokens?: number;
128
+ /**
129
+ * Input tokens written to the provider's prompt cache at the write rate on a
130
+ * cache miss (Anthropic `cache_creation_input_tokens`). Included within
131
+ * `promptTokens`.
132
+ */
133
+ readonly cacheWriteTokens?: number;
134
+ }
135
+ export interface StreamChunk {
136
+ readonly type: 'text' | 'tool_call' | 'reasoning' | 'usage' | 'done';
137
+ readonly text?: string;
138
+ readonly toolCall?: Partial<ToolCall>;
139
+ readonly reasoning?: string;
140
+ readonly usage?: TokenUsage;
141
+ }
142
+ export type ModelStream = AsyncIterable<StreamChunk>;
143
+ export interface ModelInfo {
144
+ readonly provider: string;
145
+ readonly modelId: string;
146
+ readonly displayName?: string;
147
+ readonly capabilities: ReadonlySet<CapabilityId>;
148
+ readonly maxContextTokens?: number;
149
+ readonly maxOutputTokens?: number;
150
+ readonly supportedModalities?: readonly string[];
151
+ readonly costPerInputToken?: number;
152
+ readonly costPerOutputToken?: number;
153
+ readonly rateLimitRpm?: number;
154
+ readonly rateLimitTpm?: number;
155
+ }
156
+ export interface Model extends HasCapabilities {
157
+ readonly info: ModelInfo;
158
+ generate(ctx: ExecutionContext, request: ModelRequest): Promise<ModelResponse>;
159
+ stream?(ctx: ExecutionContext, request: ModelRequest): ModelStream;
160
+ }
161
+ export interface EmbeddingRequest {
162
+ readonly input: readonly string[];
163
+ readonly dimensions?: number;
164
+ }
165
+ export interface EmbeddingResponse {
166
+ readonly embeddings: readonly number[][];
167
+ readonly model: string;
168
+ readonly usage: {
169
+ readonly totalTokens: number;
170
+ };
171
+ }
172
+ export interface EmbeddingModel extends HasCapabilities {
173
+ readonly info: ModelInfo;
174
+ embed(ctx: ExecutionContext, request: EmbeddingRequest): Promise<EmbeddingResponse>;
175
+ }
176
+ export interface RerankRequest {
177
+ readonly query: string;
178
+ readonly documents: readonly string[];
179
+ readonly topK?: number;
180
+ }
181
+ export interface RerankResult {
182
+ readonly index: number;
183
+ readonly score: number;
184
+ readonly document: string;
185
+ }
186
+ export interface RerankResponse {
187
+ readonly results: readonly RerankResult[];
188
+ readonly model: string;
189
+ }
190
+ export interface RerankerModel extends HasCapabilities {
191
+ readonly info: ModelInfo;
192
+ rerank(ctx: ExecutionContext, request: RerankRequest): Promise<RerankResponse>;
193
+ }
194
+ export interface ImageGenerationRequest {
195
+ readonly prompt: string;
196
+ /** e.g. '1024x1024' | '1536x1024' | '1024x1536' | 'auto' (GPT Image); '1024x1792' etc. (DALL·E 3). */
197
+ readonly size?: string;
198
+ /** GPT Image: 'low' | 'medium' | 'high' | 'auto'. DALL·E 3: 'standard' | 'hd'. */
199
+ readonly quality?: string;
200
+ /** DALL·E 3 only: 'vivid' | 'natural'. (GPT Image ignores this.) */
201
+ readonly style?: string;
202
+ readonly n?: number;
203
+ /** GPT Image only: 'transparent' | 'opaque' | 'auto'. */
204
+ readonly background?: string;
205
+ /** GPT Image only: returned image format 'png' | 'jpeg' | 'webp' (default png). */
206
+ readonly outputFormat?: string;
207
+ /** GPT Image only: 0-100 compression level for 'jpeg'/'webp' output. */
208
+ readonly outputCompression?: number;
209
+ /** GPT Image only: content-moderation strictness 'low' | 'auto'. */
210
+ readonly moderation?: string;
211
+ }
212
+ export interface GeneratedImage {
213
+ readonly url?: string;
214
+ readonly base64?: string;
215
+ readonly revisedPrompt?: string;
216
+ }
217
+ export interface ImageGenerationResponse {
218
+ readonly images: readonly GeneratedImage[];
219
+ readonly model: string;
220
+ /** Token usage (GPT Image models report this; DALL·E does not). */
221
+ readonly usage?: Readonly<Record<string, unknown>>;
222
+ }
223
+ export interface ImageModel extends HasCapabilities {
224
+ readonly info: ModelInfo;
225
+ generateImage(ctx: ExecutionContext, request: ImageGenerationRequest): Promise<ImageGenerationResponse>;
226
+ }
227
+ export interface SpeechRequest {
228
+ readonly input: string;
229
+ readonly voice?: string;
230
+ readonly speed?: number;
231
+ readonly responseFormat?: string;
232
+ /** Optional cancellation signal (Phase 7: chained pipeline barge-in). */
233
+ readonly signal?: AbortSignal;
234
+ }
235
+ export interface TranscriptionRequest {
236
+ readonly audio: Buffer | Uint8Array;
237
+ readonly language?: string;
238
+ readonly prompt?: string;
239
+ /** Optional model override (e.g. 'whisper-1', 'gpt-4o-transcribe'). Provider default when omitted. */
240
+ readonly model?: string;
241
+ /** MIME type / container hint for the audio bytes (e.g. 'audio/webm', 'audio/wav', 'audio/mp3'). */
242
+ readonly mimeType?: string;
243
+ /** Request timestamped segments (verbose transcription). Used by `transcribeDetailed`. */
244
+ readonly segments?: boolean;
245
+ }
246
+ /** One timestamped chunk of a transcript (seconds from the start of the audio). */
247
+ export interface TranscriptSegment {
248
+ readonly start: number;
249
+ readonly end: number;
250
+ readonly text: string;
251
+ /** Optional speaker label when diarization is available. */
252
+ readonly speaker?: string;
253
+ }
254
+ /** A rich transcription result: the full text plus timestamped segments + metadata. */
255
+ export interface TranscriptionResult {
256
+ readonly text: string;
257
+ readonly language?: string;
258
+ /** Total audio duration in seconds, when the provider reports it. */
259
+ readonly duration?: number;
260
+ readonly segments: TranscriptSegment[];
261
+ }
262
+ export interface AudioModel extends HasCapabilities {
263
+ readonly info: ModelInfo;
264
+ speak?(ctx: ExecutionContext, request: SpeechRequest): Promise<Buffer>;
265
+ /**
266
+ * Streaming TTS — yields audio chunks as the provider generates them.
267
+ * Callers should begin playback on the first chunk rather than waiting
268
+ * for the full buffer. Falls back to `speak()` if not implemented.
269
+ */
270
+ speakStream?(ctx: ExecutionContext, request: SpeechRequest): AsyncIterable<Buffer>;
271
+ transcribe?(ctx: ExecutionContext, request: TranscriptionRequest): Promise<string>;
272
+ /**
273
+ * Rich transcription: returns the text PLUS timestamped segments (and language/duration when
274
+ * available). Enables transcript-anchored features (meeting notes with clickable citations).
275
+ * Optional — callers should fall back to `transcribe()` (text-only) when a provider lacks it.
276
+ */
277
+ transcribeDetailed?(ctx: ExecutionContext, request: TranscriptionRequest): Promise<TranscriptionResult>;
278
+ }
279
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIrD,MAAM,MAAM,IAA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AI,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,uFAAuF;AACvF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;CACxC;AAED,MAAM,WAAW,UAAW,SAAQ,eAAe;IACjD,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,KAAK,CAAC,CAAC,GAAG,EAAE,gBAAgB,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvE;;;;OAIG;IACH,WAAW,CAAC,CAAC,GAAG,EAAE,gBAAgB,EAAE,OAAO,EAAE,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACnF,UAAU,CAAC,CAAC,GAAG,EAAE,gBAAgB,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnF;;;;OAIG;IACH,kBAAkB,CAAC,CAAC,GAAG,EAAE,gBAAgB,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACzG"}
package/dist/models.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @weaveintel/core — Model contracts
3
+ *
4
+ * Why: Model interfaces define what any LLM provider must implement.
5
+ * We use capability composition, not class hierarchies. A model declares
6
+ * its capabilities and consumers check them at runtime.
7
+ *
8
+ * The contracts split input/output types from the model interface itself,
9
+ * so structured output, streaming, and tool calling are composable features.
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @weaveintel/core — Content moderation contracts
3
+ *
4
+ * Why: Content moderation is a first-class capability distinct from
5
+ * classification. It provides category-level flagging with confidence scores,
6
+ * input type tracking, and is provider-agnostic so any moderation service
7
+ * (OpenAI, Azure, custom) can implement the same contract.
8
+ */
9
+ import type { ExecutionContext } from './context.js';
10
+ export interface ModerationRequest {
11
+ readonly input: string | ModerationInput[];
12
+ readonly model?: string;
13
+ }
14
+ export type ModerationInput = {
15
+ readonly type: 'text';
16
+ readonly text: string;
17
+ } | {
18
+ readonly type: 'image_url';
19
+ readonly imageUrl: string;
20
+ };
21
+ export interface ModerationCategory {
22
+ readonly category: string;
23
+ readonly flagged: boolean;
24
+ readonly score: number;
25
+ readonly appliedInputTypes?: readonly string[];
26
+ }
27
+ export interface ModerationResult {
28
+ readonly id: string;
29
+ readonly model: string;
30
+ readonly flagged: boolean;
31
+ readonly categories: readonly ModerationCategory[];
32
+ }
33
+ export interface ModerationResponse {
34
+ readonly results: readonly ModerationResult[];
35
+ }
36
+ export interface ModerationModel {
37
+ moderate(ctx: ExecutionContext, request: ModerationRequest): Promise<ModerationResponse>;
38
+ }
39
+ //# sourceMappingURL=moderation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moderation.d.ts","sourceRoot":"","sources":["../src/moderation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIrD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,EAAE,CAAC;IAC3C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAChD;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACpD;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;CAC/C;AAID,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,gBAAgB,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC1F"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @weaveintel/core — Content moderation contracts
3
+ *
4
+ * Why: Content moderation is a first-class capability distinct from
5
+ * classification. It provides category-level flagging with confidence scores,
6
+ * input type tracking, and is provider-agnostic so any moderation service
7
+ * (OpenAI, Azure, custom) can implement the same contract.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=moderation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moderation.js","sourceRoot":"","sources":["../src/moderation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Shared outbound-network safety guard.
3
+ *
4
+ * Protects every package that calls `fetch()` from SSRF via:
5
+ * - HTTPS-only enforcement (loopback http:// allowed for local dev / tests)
6
+ * - cloud-metadata hostname blocklist (AWS / GCP / Azure / link-local)
7
+ * - private-network IP literal block (RFC1918 / loopback / link-local / ULA / IPv4-mapped-IPv6)
8
+ * - DNS resolution re-check (catches DNS rebinding to private IPs)
9
+ *
10
+ * Plus `followRedirectsSafely()` which manually walks 3xx responses
11
+ * (`redirect:'manual'` on the initial fetch) and revalidates each `Location`
12
+ * so a vendor cannot trick a hardened client into a metadata endpoint via a
13
+ * crafted 302.
14
+ *
15
+ * No vendor / runtime deps beyond `node:dns` + `node:net`.
16
+ */
17
+ export interface OutboundUrlPolicy {
18
+ /** Allow http://localhost / 127.0.0.1 / ::1. Default: true. */
19
+ allowLoopback?: boolean;
20
+ /** Allow any private/RFC1918/link-local destination. Default: false. */
21
+ allowPrivateNetwork?: boolean;
22
+ /** Extra hostnames to block (exact or suffix match). */
23
+ blockedHostnames?: string[];
24
+ /** Optional allow-list of hostnames (suffix match). */
25
+ allowedHosts?: string[];
26
+ /** Optional block-list of hostnames (suffix match). */
27
+ blockedHosts?: string[];
28
+ /** Tag inserted into error messages so callers can identify the package. Default: 'net'. */
29
+ errorTag?: string;
30
+ }
31
+ /**
32
+ * Validate a URL before making any outbound request.
33
+ *
34
+ * Throws on any violation. Returns the parsed URL on success.
35
+ *
36
+ * MUST be awaited — performs DNS resolution to catch DNS rebinding.
37
+ */
38
+ export declare function assertSafeOutboundUrl(rawUrl: string, policy?: OutboundUrlPolicy): Promise<URL>;
39
+ /**
40
+ * Validate a single already-resolved IP address against the SSRF policy.
41
+ * Intended for use inside custom DNS lookup hooks (e.g. undici's
42
+ * `connect.lookup`) so the check happens at connection time — closing the
43
+ * TOCTOU window between `assertSafeOutboundUrl` (which resolves once at
44
+ * validation time) and the actual `fetch` call (which re-resolves on its own).
45
+ *
46
+ * Throws with the same error shape as `assertSafeOutboundUrl` on violation.
47
+ * Returns the address unchanged on success so callers can pass it through.
48
+ */
49
+ export declare function validateResolvedAddress(address: string, policy?: OutboundUrlPolicy): string;
50
+ /**
51
+ * Follow 3xx redirects manually, re-validating each `Location` with
52
+ * `assertSafeOutboundUrl`. Pass the response you got from a fetch invoked
53
+ * with `redirect: 'manual'`.
54
+ *
55
+ * Caps at `maxHops` (default 5). Returns the final non-redirect response.
56
+ */
57
+ export declare function followRedirectsSafely(initial: Response, init: RequestInit | undefined, signal: AbortSignal | undefined, policy?: OutboundUrlPolicy & {
58
+ maxHops?: number;
59
+ }): Promise<Response>;
60
+ //# sourceMappingURL=net-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"net-guard.d.ts","sourceRoot":"","sources":["../src/net-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wEAAwE;IACxE,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,wDAAwD;IACxD,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAsED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,GAAG,CAAC,CA+Ed;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,iBAAsB,GAAG,MAAM,CAU/F;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,MAAM,GAAE,iBAAiB,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GACpD,OAAO,CAAC,QAAQ,CAAC,CA6CnB"}