@loomwork/llm 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +80 -2
- package/dist/assembleStream.d.ts +95 -0
- package/dist/assembleStream.d.ts.map +1 -0
- package/dist/assembleStream.js +180 -0
- package/dist/assembleStream.js.map +1 -0
- package/dist/capabilities.d.ts +43 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +77 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/createLlmEffect.d.ts +110 -0
- package/dist/createLlmEffect.d.ts.map +1 -0
- package/dist/createLlmEffect.js +177 -0
- package/dist/createLlmEffect.js.map +1 -0
- package/dist/errors.d.ts +96 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +280 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -0
- package/dist/parts.d.ts +220 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +231 -0
- package/dist/parts.js.map +1 -0
- package/dist/providers/AnthropicProvider.d.ts +53 -0
- package/dist/providers/AnthropicProvider.d.ts.map +1 -0
- package/dist/providers/AnthropicProvider.js +443 -0
- package/dist/providers/AnthropicProvider.js.map +1 -0
- package/dist/providers/GeminiProvider.d.ts +66 -0
- package/dist/providers/GeminiProvider.d.ts.map +1 -0
- package/dist/providers/GeminiProvider.js +281 -0
- package/dist/providers/GeminiProvider.js.map +1 -0
- package/dist/providers/OpenAiProvider.d.ts +56 -0
- package/dist/providers/OpenAiProvider.d.ts.map +1 -0
- package/dist/providers/OpenAiProvider.js +402 -0
- package/dist/providers/OpenAiProvider.js.map +1 -0
- package/dist/providers/extraHeaders.d.ts +7 -0
- package/dist/providers/extraHeaders.d.ts.map +1 -0
- package/dist/providers/extraHeaders.js +40 -0
- package/dist/providers/extraHeaders.js.map +1 -0
- package/dist/providers/systemPrompt.d.ts +10 -0
- package/dist/providers/systemPrompt.d.ts.map +1 -0
- package/dist/providers/systemPrompt.js +22 -0
- package/dist/providers/systemPrompt.js.map +1 -0
- package/dist/reasoning.d.ts +154 -0
- package/dist/reasoning.d.ts.map +1 -0
- package/dist/reasoning.js +256 -0
- package/dist/reasoning.js.map +1 -0
- package/dist/resolveContent.d.ts +74 -0
- package/dist/resolveContent.d.ts.map +1 -0
- package/dist/resolveContent.js +335 -0
- package/dist/resolveContent.js.map +1 -0
- package/dist/types.d.ts +152 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/untrusted.d.ts +91 -0
- package/dist/untrusted.d.ts.map +1 -0
- package/dist/untrusted.js +385 -0
- package/dist/untrusted.js.map +1 -0
- package/package.json +54 -3
- package/src/assembleStream.ts +219 -0
- package/src/capabilities.ts +96 -0
- package/src/createLlmEffect.ts +287 -0
- package/src/errors.ts +269 -0
- package/src/index.ts +137 -0
- package/src/parts.ts +409 -0
- package/src/providers/AnthropicProvider.ts +550 -0
- package/src/providers/GeminiProvider.ts +380 -0
- package/src/providers/OpenAiProvider.ts +511 -0
- package/src/providers/extraHeaders.ts +41 -0
- package/src/providers/systemPrompt.ts +19 -0
- package/src/reasoning.ts +386 -0
- package/src/resolveContent.ts +425 -0
- package/src/types.ts +175 -0
- package/src/untrusted.ts +440 -0
package/src/errors.ts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
export type LlmHttpProvider = "anthropic" | "openai" | "gemini";
|
|
2
|
+
|
|
3
|
+
const LABEL: Record<LlmHttpProvider, string> = {
|
|
4
|
+
anthropic: "Anthropic",
|
|
5
|
+
openai: "OpenAI",
|
|
6
|
+
gemini: "Gemini",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Release the body of a non-2xx response without reading it: an unconsumed body keeps the
|
|
11
|
+
* connection (undici) busy. Never reads the text, and a failing cancel must not mask the status.
|
|
12
|
+
*/
|
|
13
|
+
export async function drainBody(resp: Response): Promise<void> {
|
|
14
|
+
await resp.body?.cancel().catch(() => undefined);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Why a request failed when the status alone cannot say. Closed; `"auth"` is a refused credential. */
|
|
18
|
+
export type LlmHttpErrorKind = "auth";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A provider's HTTP API answered with a non-2xx status. `status` is what a caller should branch
|
|
22
|
+
* on. The response body is deliberately NOT kept: it can echo the prompt, so it is never put in
|
|
23
|
+
* the message or on the error.
|
|
24
|
+
*/
|
|
25
|
+
export class LlmHttpError extends Error {
|
|
26
|
+
readonly status: number;
|
|
27
|
+
readonly provider: LlmHttpProvider;
|
|
28
|
+
/** Set to `false` for a 3xx (a redirect, never followed): retrying cannot help. */
|
|
29
|
+
readonly retryable?: false;
|
|
30
|
+
/**
|
|
31
|
+
* Why the request failed, when the status alone cannot say. Closed: `"auth"` means the
|
|
32
|
+
* credential was refused (401/403, or a 400 the provider's own error code names as a bad key), a
|
|
33
|
+
* configuration fault rather than a malformed request. Absent otherwise.
|
|
34
|
+
*/
|
|
35
|
+
readonly kind?: LlmHttpErrorKind;
|
|
36
|
+
constructor(provider: LlmHttpProvider, status: number, kind?: LlmHttpErrorKind) {
|
|
37
|
+
super(`${LABEL[provider]} API error ${status}`);
|
|
38
|
+
this.name = "LlmHttpError";
|
|
39
|
+
this.status = status;
|
|
40
|
+
this.provider = provider;
|
|
41
|
+
// A redirect is never followed (it would re-send the body and credentials elsewhere), and
|
|
42
|
+
// asking again changes nothing: the base URL is misconfigured or the path is intercepted.
|
|
43
|
+
if (status >= 300 && status < 400) this.retryable = false;
|
|
44
|
+
if (kind === "auth" || status === 401 || status === 403) this.kind = "auth";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The most of a non-2xx body that is ever read to look for a provider error code. */
|
|
49
|
+
export const MAX_ERROR_BODY_BYTES = 16 * 1024;
|
|
50
|
+
|
|
51
|
+
/** The longest the error-body read may take; a server that stalls after the headers is given up on. */
|
|
52
|
+
export const ERROR_BODY_READ_TIMEOUT_MS = 2000;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Read at most `maxBytes` of a non-2xx body, for at most `timeoutMs` (and no longer than `signal`
|
|
56
|
+
* allows), and parse it as JSON. The body is always consumed or cancelled and its reader released
|
|
57
|
+
* before this returns, so the caller need not drain it. Returns `undefined` for anything else (over
|
|
58
|
+
* the bound, too slow, aborted, unreadable, not JSON): the caller only ever looks for a fixed error
|
|
59
|
+
* code in the result and keeps nothing of it.
|
|
60
|
+
*/
|
|
61
|
+
export async function readBoundedErrorJson(
|
|
62
|
+
resp: Response,
|
|
63
|
+
signal?: AbortSignal,
|
|
64
|
+
maxBytes: number = MAX_ERROR_BODY_BYTES,
|
|
65
|
+
timeoutMs: number = ERROR_BODY_READ_TIMEOUT_MS
|
|
66
|
+
): Promise<unknown> {
|
|
67
|
+
const reader = resp.body?.getReader?.();
|
|
68
|
+
if (!reader) {
|
|
69
|
+
await drainBody(resp);
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
let onAbort: (() => void) | undefined;
|
|
73
|
+
const stop = new Promise<"stop">((resolve) => {
|
|
74
|
+
onAbort = () => resolve("stop");
|
|
75
|
+
if (signal?.aborted) onAbort();
|
|
76
|
+
else signal?.addEventListener("abort", onAbort, { once: true });
|
|
77
|
+
});
|
|
78
|
+
const timer = setTimeout(() => onAbort?.(), timeoutMs);
|
|
79
|
+
let finished = false;
|
|
80
|
+
try {
|
|
81
|
+
const parts: Uint8Array[] = [];
|
|
82
|
+
let total = 0;
|
|
83
|
+
while (true) {
|
|
84
|
+
const next = await Promise.race([reader.read(), stop]);
|
|
85
|
+
if (next === "stop") return undefined;
|
|
86
|
+
if (next.done) {
|
|
87
|
+
finished = true;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
total += next.value.byteLength;
|
|
91
|
+
if (total > maxBytes) return undefined;
|
|
92
|
+
parts.push(next.value);
|
|
93
|
+
}
|
|
94
|
+
const all = new Uint8Array(total);
|
|
95
|
+
let off = 0;
|
|
96
|
+
for (const p of parts) {
|
|
97
|
+
all.set(p, off);
|
|
98
|
+
off += p.byteLength;
|
|
99
|
+
}
|
|
100
|
+
return JSON.parse(new TextDecoder().decode(all));
|
|
101
|
+
} catch {
|
|
102
|
+
return undefined;
|
|
103
|
+
} finally {
|
|
104
|
+
clearTimeout(timer);
|
|
105
|
+
if (onAbort) signal?.removeEventListener("abort", onAbort);
|
|
106
|
+
// Not awaited: a stalled source must not delay the caller's throw.
|
|
107
|
+
if (!finished) reader.cancel().catch(() => undefined);
|
|
108
|
+
try {
|
|
109
|
+
reader.releaseLock();
|
|
110
|
+
} catch {
|
|
111
|
+
// A read is still pending on an older runtime; the cancel above settles it.
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A provider reported an error INSIDE a 200 stream (Anthropic `event: error`, an OpenAI-compatible
|
|
118
|
+
* `{"error": ...}` chunk). Carries only the provider and the error type or code, and only when it is
|
|
119
|
+
* a plain identifier: the message text can echo the prompt, so it is never kept.
|
|
120
|
+
*/
|
|
121
|
+
export class LlmStreamError extends Error {
|
|
122
|
+
readonly provider: LlmHttpProvider;
|
|
123
|
+
readonly code: string;
|
|
124
|
+
constructor(provider: LlmHttpProvider, code: unknown) {
|
|
125
|
+
const safe = typeof code === "string" && /^[A-Za-z0-9_.-]{1,64}$/.test(code) ? code : "unknown";
|
|
126
|
+
super(`${LABEL[provider]} stream error: ${safe}`);
|
|
127
|
+
this.name = "LlmStreamError";
|
|
128
|
+
this.provider = provider;
|
|
129
|
+
this.code = safe;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Default cap on a complete response body (bytes), and on the total bytes of a stream. */
|
|
134
|
+
export const DEFAULT_MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
|
|
135
|
+
/**
|
|
136
|
+
* Default cap on the TOTAL bytes of a stream. Much larger than the complete-body cap: an SSE
|
|
137
|
+
* chunk is ~250-300 B per token on the wire, so a long answer legitimately needs tens of MiB, and
|
|
138
|
+
* memory is bounded by the per-line cap, not by this.
|
|
139
|
+
*/
|
|
140
|
+
export const DEFAULT_MAX_STREAM_BYTES = 128 * 1024 * 1024;
|
|
141
|
+
/** Default cap on one line of a stream, in UTF-8 bytes. */
|
|
142
|
+
export const DEFAULT_MAX_LINE_BYTES = 1024 * 1024;
|
|
143
|
+
|
|
144
|
+
/** UTF-8 byte length of a string, without allocating. */
|
|
145
|
+
function utf8Length(str: string): number {
|
|
146
|
+
let n = 0;
|
|
147
|
+
for (let i = 0; i < str.length; i++) {
|
|
148
|
+
const c = str.charCodeAt(i);
|
|
149
|
+
if (c < 0x80) n += 1;
|
|
150
|
+
else if (c < 0x800) n += 2;
|
|
151
|
+
else if (c >= 0xd800 && c <= 0xdbff && i + 1 < str.length) {
|
|
152
|
+
n += 4;
|
|
153
|
+
i++;
|
|
154
|
+
} else n += 3;
|
|
155
|
+
}
|
|
156
|
+
return n;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export type LlmResponseLimitReason = "body" | "stream" | "line";
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* A provider's response exceeded the configured size cap (`maxResponseBytes` / `maxStreamBytes` / `maxLineBytes`).
|
|
163
|
+
* Carries only the provider and which limit was hit: never any of the body.
|
|
164
|
+
*/
|
|
165
|
+
export class LlmResponseLimitError extends Error {
|
|
166
|
+
readonly provider: LlmHttpProvider;
|
|
167
|
+
readonly reason: LlmResponseLimitReason;
|
|
168
|
+
constructor(provider: LlmHttpProvider, reason: LlmResponseLimitReason) {
|
|
169
|
+
super(`${LABEL[provider]} response too large (${reason})`);
|
|
170
|
+
this.name = "LlmResponseLimitError";
|
|
171
|
+
this.provider = provider;
|
|
172
|
+
this.reason = reason;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* A 2xx response whose body is not valid JSON. Fixed message, no `cause`: the parser's own error
|
|
178
|
+
* quotes the start of the body, which can hold anything the endpoint sent.
|
|
179
|
+
*/
|
|
180
|
+
export class LlmResponseInvalidError extends Error {
|
|
181
|
+
readonly provider: LlmHttpProvider;
|
|
182
|
+
constructor(provider: LlmHttpProvider) {
|
|
183
|
+
super(`${LABEL[provider]} response is not valid JSON`);
|
|
184
|
+
this.name = "LlmResponseInvalidError";
|
|
185
|
+
this.provider = provider;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Reject a non-positive or non-integer cap at construction. */
|
|
190
|
+
export function resolveLimit(value: number | undefined, fallback: number, name: string): number {
|
|
191
|
+
if (value === undefined) return fallback;
|
|
192
|
+
if (!Number.isInteger(value) || value < 1)
|
|
193
|
+
throw new RangeError(`${name} must be a positive integer`);
|
|
194
|
+
return value;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Read a complete JSON body with a byte cap. Over the cap the body is cancelled and an
|
|
199
|
+
* {@link LlmResponseLimitError} is thrown (no body text). Streams the bytes, so a hostile endpoint
|
|
200
|
+
* cannot make the process buffer more than the cap (plus one chunk).
|
|
201
|
+
*/
|
|
202
|
+
export async function readBoundedJson(
|
|
203
|
+
resp: Response,
|
|
204
|
+
provider: LlmHttpProvider,
|
|
205
|
+
maxBytes: number
|
|
206
|
+
): Promise<unknown> {
|
|
207
|
+
const declared = Number(resp.headers?.get("content-length"));
|
|
208
|
+
if (Number.isFinite(declared) && declared > maxBytes) {
|
|
209
|
+
await drainBody(resp);
|
|
210
|
+
throw new LlmResponseLimitError(provider, "body");
|
|
211
|
+
}
|
|
212
|
+
// No stream to read (an empty body, or a non-network `Response` stand-in): nothing to bound.
|
|
213
|
+
if (!resp.body) {
|
|
214
|
+
try {
|
|
215
|
+
return await resp.json();
|
|
216
|
+
} catch {
|
|
217
|
+
throw new LlmResponseInvalidError(provider);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const reader = resp.body.getReader();
|
|
221
|
+
const parts: Uint8Array[] = [];
|
|
222
|
+
let total = 0;
|
|
223
|
+
try {
|
|
224
|
+
while (true) {
|
|
225
|
+
const { done, value } = await reader.read();
|
|
226
|
+
if (done) break;
|
|
227
|
+
total += value.byteLength;
|
|
228
|
+
if (total > maxBytes) {
|
|
229
|
+
await reader.cancel().catch(() => undefined);
|
|
230
|
+
throw new LlmResponseLimitError(provider, "body");
|
|
231
|
+
}
|
|
232
|
+
parts.push(value);
|
|
233
|
+
}
|
|
234
|
+
} finally {
|
|
235
|
+
reader.releaseLock?.();
|
|
236
|
+
}
|
|
237
|
+
const all = new Uint8Array(total);
|
|
238
|
+
let off = 0;
|
|
239
|
+
for (const p of parts) {
|
|
240
|
+
all.set(p, off);
|
|
241
|
+
off += p.byteLength;
|
|
242
|
+
}
|
|
243
|
+
try {
|
|
244
|
+
return JSON.parse(new TextDecoder().decode(all));
|
|
245
|
+
} catch {
|
|
246
|
+
throw new LlmResponseInvalidError(provider);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Byte and line accounting for an SSE stream; each check throws {@link LlmResponseLimitError}. */
|
|
251
|
+
export class StreamLimiter {
|
|
252
|
+
private total = 0;
|
|
253
|
+
constructor(
|
|
254
|
+
private readonly provider: LlmHttpProvider,
|
|
255
|
+
private readonly maxBytes: number,
|
|
256
|
+
private readonly maxLine: number
|
|
257
|
+
) {}
|
|
258
|
+
chunk(value: Uint8Array): void {
|
|
259
|
+
this.total += value.byteLength;
|
|
260
|
+
if (this.total > this.maxBytes) throw new LlmResponseLimitError(this.provider, "stream");
|
|
261
|
+
}
|
|
262
|
+
/** `lines` are the complete lines of this chunk, `rest` the unfinished tail. */
|
|
263
|
+
lines(lines: readonly string[], rest: string): void {
|
|
264
|
+
// UTF-8 is at most 3 bytes per UTF-16 unit: only measure what could be over the cap.
|
|
265
|
+
const over = (l: string) => l.length * 3 > this.maxLine && utf8Length(l) > this.maxLine;
|
|
266
|
+
if (over(rest)) throw new LlmResponseLimitError(this.provider, "line");
|
|
267
|
+
for (const l of lines) if (over(l)) throw new LlmResponseLimitError(this.provider, "line");
|
|
268
|
+
}
|
|
269
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
export {
|
|
2
|
+
LlmHttpError,
|
|
3
|
+
LlmResponseInvalidError,
|
|
4
|
+
LlmResponseLimitError,
|
|
5
|
+
LlmStreamError,
|
|
6
|
+
} from "./errors";
|
|
7
|
+
export type { LlmHttpErrorKind, LlmHttpProvider, LlmResponseLimitReason } from "./errors";
|
|
8
|
+
export type {
|
|
9
|
+
LlmContent,
|
|
10
|
+
LlmMessage,
|
|
11
|
+
LlmMessageInput,
|
|
12
|
+
LlmToolSpec,
|
|
13
|
+
LlmToolSpecInput,
|
|
14
|
+
LlmRequest,
|
|
15
|
+
LlmRequestInput,
|
|
16
|
+
LlmToolCall,
|
|
17
|
+
LlmResponse,
|
|
18
|
+
LlmCapturedResponse,
|
|
19
|
+
LlmStreamChunk,
|
|
20
|
+
LlmProvider,
|
|
21
|
+
LlmReasoning,
|
|
22
|
+
LlmReasoningKind,
|
|
23
|
+
LlmReasoningPart,
|
|
24
|
+
} from "./types";
|
|
25
|
+
export type {
|
|
26
|
+
CapturedReasoningPart,
|
|
27
|
+
LlmReasoningCaptured,
|
|
28
|
+
LlmReasoningOptions,
|
|
29
|
+
ReasoningAttemptRead,
|
|
30
|
+
ReasoningLogReader,
|
|
31
|
+
ReasoningPartRead,
|
|
32
|
+
ReasoningPartStatus,
|
|
33
|
+
ReasoningQuery,
|
|
34
|
+
ReasoningReadLimits,
|
|
35
|
+
ReasoningReader,
|
|
36
|
+
ReasoningStepRead,
|
|
37
|
+
ReasoningStore,
|
|
38
|
+
} from "./reasoning";
|
|
39
|
+
export {
|
|
40
|
+
LLM_REASONING_CAPTURED,
|
|
41
|
+
captureReasoning,
|
|
42
|
+
readReasoning,
|
|
43
|
+
readReasoningBounded,
|
|
44
|
+
openReasoningText,
|
|
45
|
+
reasoningDigest,
|
|
46
|
+
reasoningStoreResolver,
|
|
47
|
+
sealReasoningText,
|
|
48
|
+
textFreeReasoning,
|
|
49
|
+
} from "./reasoning";
|
|
50
|
+
export type {
|
|
51
|
+
LlmAudioPart,
|
|
52
|
+
LlmBinarySource,
|
|
53
|
+
LlmContentPart,
|
|
54
|
+
LlmContentPartInput,
|
|
55
|
+
LlmContentRef,
|
|
56
|
+
LlmFilePart,
|
|
57
|
+
LlmImagePart,
|
|
58
|
+
LlmLayoutEntry,
|
|
59
|
+
LlmMediaPart,
|
|
60
|
+
LlmMediaPartInput,
|
|
61
|
+
LlmMessageContent,
|
|
62
|
+
LlmMessageContentInput,
|
|
63
|
+
LlmModality,
|
|
64
|
+
LlmResultPart,
|
|
65
|
+
LlmResultPartInput,
|
|
66
|
+
LlmTextPart,
|
|
67
|
+
LlmTextPartInput,
|
|
68
|
+
LlmToolResultPart,
|
|
69
|
+
LlmToolResultPartInput,
|
|
70
|
+
LlmToolUsePart,
|
|
71
|
+
} from "./parts";
|
|
72
|
+
export {
|
|
73
|
+
TaintedContentError,
|
|
74
|
+
assistantMessageOf,
|
|
75
|
+
base64ByteLength,
|
|
76
|
+
hasReasoningParts,
|
|
77
|
+
hasStructuredParts,
|
|
78
|
+
layoutOf,
|
|
79
|
+
textOf,
|
|
80
|
+
toParts,
|
|
81
|
+
withoutReasoningParts,
|
|
82
|
+
} from "./parts";
|
|
83
|
+
export type { LlmCapabilities, MediaTypeSet } from "./capabilities";
|
|
84
|
+
export {
|
|
85
|
+
UnsupportedModalityError,
|
|
86
|
+
assertRequestSupported,
|
|
87
|
+
capabilitiesForModel,
|
|
88
|
+
mediaTypeAccepted,
|
|
89
|
+
requestMediaParts,
|
|
90
|
+
} from "./capabilities";
|
|
91
|
+
export type { ContentResolveContext, ContentResolver } from "./resolveContent";
|
|
92
|
+
export {
|
|
93
|
+
MAX_RESOLVED_BYTES,
|
|
94
|
+
UnresolvedContentError,
|
|
95
|
+
inlineData,
|
|
96
|
+
resolveRequestContent,
|
|
97
|
+
} from "./resolveContent";
|
|
98
|
+
export {
|
|
99
|
+
InvalidLlmRequestError,
|
|
100
|
+
MAX_INLINE_BYTES,
|
|
101
|
+
MAX_INLINE_TOTAL_BYTES,
|
|
102
|
+
TOOL_INPUT_NODE_CAP,
|
|
103
|
+
OversizedInlinePartError,
|
|
104
|
+
UNTRUSTED_CONTENT_SYSTEM_NOTE,
|
|
105
|
+
UntrustedContentError,
|
|
106
|
+
exceedsNodeCap,
|
|
107
|
+
fence,
|
|
108
|
+
fenceUntrustedMedia,
|
|
109
|
+
guardRequest,
|
|
110
|
+
stripUntrusted,
|
|
111
|
+
untrustedFence,
|
|
112
|
+
validateMediaPart,
|
|
113
|
+
} from "./untrusted";
|
|
114
|
+
export type { GuardOptions } from "./untrusted";
|
|
115
|
+
export { AnthropicProvider } from "./providers/AnthropicProvider";
|
|
116
|
+
export type { AnthropicProviderConfig } from "./providers/AnthropicProvider";
|
|
117
|
+
export { OpenAiProvider } from "./providers/OpenAiProvider";
|
|
118
|
+
export type { OpenAiProviderConfig } from "./providers/OpenAiProvider";
|
|
119
|
+
export {
|
|
120
|
+
GEMINI_CAPABILITIES,
|
|
121
|
+
GEMINI_MEDIA_MODELS,
|
|
122
|
+
GeminiProvider,
|
|
123
|
+
} from "./providers/GeminiProvider";
|
|
124
|
+
export type { GeminiProviderConfig } from "./providers/GeminiProvider";
|
|
125
|
+
export {
|
|
126
|
+
LLM_INTERRUPTED,
|
|
127
|
+
MalformedStreamError,
|
|
128
|
+
assembleStream,
|
|
129
|
+
collectStream,
|
|
130
|
+
} from "./assembleStream";
|
|
131
|
+
export type {
|
|
132
|
+
CollectStreamOptions,
|
|
133
|
+
InterruptedGeneration,
|
|
134
|
+
StreamProgress,
|
|
135
|
+
} from "./assembleStream";
|
|
136
|
+
export { createLlmEffect } from "./createLlmEffect";
|
|
137
|
+
export type { CreateLlmEffectOptions } from "./createLlmEffect";
|