@voltro/ai 0.84.0 → 0.86.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/CHANGELOG.md +1215 -0
- package/THIRD-PARTY-NOTICES.md +5 -151
- package/dist/agent.d.ts +34 -41
- package/dist/agent.js +64 -2
- package/dist/agentConstants.js +4 -0
- package/dist/agentExecutor.js +51 -0
- package/dist/api.js +199 -0
- package/dist/appTools.js +80 -0
- package/dist/budget.js +201 -0
- package/dist/callEvidence.js +51 -0
- package/dist/copilot.js +126 -0
- package/dist/cost.js +242 -0
- package/dist/embed.js +41 -0
- package/dist/embeddingProvider.js +51 -0
- package/dist/eval.js +130 -0
- package/dist/events.d.ts +171 -168
- package/dist/events.js +81 -2
- package/dist/executableModalities.js +13 -0
- package/dist/gateway.js +58 -0
- package/dist/gatewayCatalog.js +47 -0
- package/dist/gatewayMedia.js +88 -0
- package/dist/index.d.ts +328 -326
- package/dist/index.js +42 -2581
- package/dist/inferenceDispatch.js +493 -0
- package/dist/inferenceQueue.js +96 -0
- package/dist/jsonOutputValidation.js +27 -0
- package/dist/mcpClient.js +332 -0
- package/dist/mcpTools.js +80 -0
- package/dist/media.js +182 -0
- package/dist/mediaBytes.js +19 -0
- package/dist/mediaCall.js +13 -0
- package/dist/mediaTaskProvider.js +16 -0
- package/dist/middleware.js +32 -0
- package/dist/observe.js +52 -0
- package/dist/prompts.js +103 -0
- package/dist/provider.js +303 -0
- package/dist/realtimeEvent.js +97 -0
- package/dist/realtimeSession.js +154 -0
- package/dist/rerank.js +61 -0
- package/dist/resumableStream.js +321 -0
- package/dist/retrieveReranked.js +16 -0
- package/dist/runAndPersist.js +148 -0
- package/dist/semanticCache.js +66 -0
- package/dist/speechProvider.js +16 -0
- package/dist/streamRegistry.js +14 -0
- package/dist/streamText.js +170 -0
- package/dist/streamTranscribe.js +74 -0
- package/dist/streamWakeups.js +44 -0
- package/dist/structuredEvidence.js +48 -0
- package/dist/test.js +1 -1
- package/dist/threads.js +92 -0
- package/dist/tools.js +68 -0
- package/dist/transcribe.js +64 -0
- package/dist/transcriptionEvent.js +46 -0
- package/dist/workflow.d.ts +12 -10
- package/dist/workflow.js +117 -112
- package/package.json +6 -6
- package/dist/agentDescriptor-DuxvWGDi.js +0 -63
- package/dist/agentEvent-BuXA7sRt.js +0 -152
- package/dist/inferenceQueue-BmtEm3YI.js +0 -1061
- package/dist/provider-BnemgE4D.js +0 -409
package/dist/events.js
CHANGED
|
@@ -1,2 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { TranscriptionStreamError as e, TranscriptionStreamEvent as t } from "./transcriptionEvent.js";
|
|
2
|
+
import { RealtimeClientEvent as n, RealtimeServerEvent as r } from "./realtimeEvent.js";
|
|
3
|
+
import { Schema as i } from "effect";
|
|
4
|
+
//#region src/agentEvent.ts
|
|
5
|
+
var a = i.Literals([
|
|
6
|
+
"provider",
|
|
7
|
+
"tool",
|
|
8
|
+
"timeout",
|
|
9
|
+
"cancelled",
|
|
10
|
+
"decode",
|
|
11
|
+
"internal"
|
|
12
|
+
]), o = i.Struct({
|
|
13
|
+
inputTokens: i.optional(i.Number),
|
|
14
|
+
outputTokens: i.optional(i.Number),
|
|
15
|
+
totalTokens: i.optional(i.Number)
|
|
16
|
+
}), s = i.Union([
|
|
17
|
+
i.Struct({
|
|
18
|
+
_tag: i.Literal("token"),
|
|
19
|
+
text: i.String
|
|
20
|
+
}),
|
|
21
|
+
i.Struct({
|
|
22
|
+
_tag: i.Literal("reasoning"),
|
|
23
|
+
text: i.String
|
|
24
|
+
}),
|
|
25
|
+
i.Struct({
|
|
26
|
+
_tag: i.Literal("toolCall"),
|
|
27
|
+
id: i.String,
|
|
28
|
+
name: i.String,
|
|
29
|
+
input: i.Unknown,
|
|
30
|
+
execution: i.optional(i.Literal("client"))
|
|
31
|
+
}),
|
|
32
|
+
i.Struct({
|
|
33
|
+
_tag: i.Literal("toolResult"),
|
|
34
|
+
id: i.String,
|
|
35
|
+
name: i.String,
|
|
36
|
+
output: i.optional(i.Unknown),
|
|
37
|
+
error: i.optional(i.String)
|
|
38
|
+
}),
|
|
39
|
+
i.Struct({
|
|
40
|
+
_tag: i.Literal("source"),
|
|
41
|
+
sourceType: i.Literals(["url", "document"]),
|
|
42
|
+
id: i.String,
|
|
43
|
+
url: i.optional(i.String),
|
|
44
|
+
title: i.optional(i.String),
|
|
45
|
+
mediaType: i.optional(i.String),
|
|
46
|
+
filename: i.optional(i.String),
|
|
47
|
+
providerMetadata: i.optional(i.Unknown)
|
|
48
|
+
}),
|
|
49
|
+
i.Struct({
|
|
50
|
+
_tag: i.Literal("file"),
|
|
51
|
+
mediaType: i.String,
|
|
52
|
+
data: i.String,
|
|
53
|
+
providerMetadata: i.optional(i.Unknown)
|
|
54
|
+
}),
|
|
55
|
+
i.Struct({
|
|
56
|
+
_tag: i.Literal("stepMetadata"),
|
|
57
|
+
step: i.Int.pipe(i.check(i.isGreaterThanOrEqualTo(0))),
|
|
58
|
+
providerMetadata: i.Unknown
|
|
59
|
+
}),
|
|
60
|
+
i.Struct({
|
|
61
|
+
_tag: i.Literal("message"),
|
|
62
|
+
role: i.String,
|
|
63
|
+
content: i.String
|
|
64
|
+
}),
|
|
65
|
+
i.Struct({
|
|
66
|
+
_tag: i.Literal("error"),
|
|
67
|
+
code: a,
|
|
68
|
+
message: i.String,
|
|
69
|
+
retryable: i.Boolean
|
|
70
|
+
}),
|
|
71
|
+
i.Struct({
|
|
72
|
+
_tag: i.Literal("done"),
|
|
73
|
+
finishReason: i.String,
|
|
74
|
+
usage: o
|
|
75
|
+
})
|
|
76
|
+
]), c = i.Struct({
|
|
77
|
+
seq: i.Number,
|
|
78
|
+
event: s
|
|
79
|
+
});
|
|
80
|
+
//#endregion
|
|
81
|
+
export { a as AgentErrorCode, s as AgentEvent, n as RealtimeClientEvent, r as RealtimeServerEvent, c as SeqEvent, e as TranscriptionStreamError, t as TranscriptionStreamEvent };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/executableModalities.ts
|
|
2
|
+
var e = {
|
|
3
|
+
language: "generateText / generateObject / streamText",
|
|
4
|
+
embedding: "embed / embedMany",
|
|
5
|
+
image: "generateImage",
|
|
6
|
+
video: "generateVideo",
|
|
7
|
+
speech: "generateSpeech",
|
|
8
|
+
reranking: "rerank",
|
|
9
|
+
transcription: "transcribe",
|
|
10
|
+
realtime: "defineRealtimeSession / resolveRealtimeModel"
|
|
11
|
+
}, t = () => new Set(Object.keys(e)), n = (e) => t().has(e.modality);
|
|
12
|
+
//#endregion
|
|
13
|
+
export { e as MODALITY_PRIMITIVE, n as canExecute, t as executableModalities };
|
package/dist/gateway.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { capabilitiesOf as e, contextWindowOf as t, dataPolicyOf as n, knowledgeCutoffOf as r, maxOutputTokensOf as i, modalitiesOf as a, modalityOf as o, releasedAtOf as s } from "./gatewayCatalog.js";
|
|
2
|
+
import { createGateway as c, gateway as l } from "@ai-sdk/gateway";
|
|
3
|
+
//#region src/gateway.ts
|
|
4
|
+
var u = (e) => {
|
|
5
|
+
if (e === void 0) return;
|
|
6
|
+
let t = Number(e);
|
|
7
|
+
return Number.isFinite(t) ? t * 1e6 : void 0;
|
|
8
|
+
}, d = (e) => {
|
|
9
|
+
let t = u(e.pricing?.input), n = u(e.pricing?.output), r = u(e.pricing?.cachedInputTokens ?? void 0);
|
|
10
|
+
return {
|
|
11
|
+
id: e.id,
|
|
12
|
+
name: e.name,
|
|
13
|
+
...e.description == null ? {} : { description: e.description },
|
|
14
|
+
modality: o({ model_type: e.modelType }),
|
|
15
|
+
...t !== void 0 && n !== void 0 ? { pricing: {
|
|
16
|
+
inputPer1M: t,
|
|
17
|
+
outputPer1M: n,
|
|
18
|
+
...r === void 0 ? {} : { cachedInputPer1M: r }
|
|
19
|
+
} } : {}
|
|
20
|
+
};
|
|
21
|
+
}, f = async (e = {}) => {
|
|
22
|
+
let t = (await (e.gatewayProvider ?? (e.apiKey !== void 0 || e.baseURL !== void 0 ? c({
|
|
23
|
+
...e.apiKey === void 0 ? {} : { apiKey: e.apiKey },
|
|
24
|
+
...e.baseURL === void 0 ? {} : { baseURL: e.baseURL }
|
|
25
|
+
}) : l)).getAvailableModels()).models.map(d);
|
|
26
|
+
return e.modality === void 0 ? t : t.filter((t) => t.modality === e.modality);
|
|
27
|
+
}, p = "https://ai-gateway.vercel.sh/v1", m = async (e = {}) => {
|
|
28
|
+
let t = (e.baseURL ?? p).replace(/\/+$/, ""), n = e.apiKey ?? process.env.AI_GATEWAY_API_KEY, r = await (e.fetchImpl ?? fetch)(`${t}/models`, { headers: {
|
|
29
|
+
accept: "application/json",
|
|
30
|
+
...n === void 0 ? {} : { authorization: `Bearer ${n}` }
|
|
31
|
+
} });
|
|
32
|
+
if (!r.ok) throw Error(`gateway catalog: GET ${t}/models answered ${r.status}. Set AI_GATEWAY_API_KEY, or pass \`apiKey\`.`);
|
|
33
|
+
let i = await r.json(), a = (Array.isArray(i.data) ? i.data : Array.isArray(i.models) ? i.models : []).map(h);
|
|
34
|
+
return e.modality === void 0 ? a : a.filter((t) => t.modality === e.modality);
|
|
35
|
+
}, h = (c) => {
|
|
36
|
+
let l = c.pricing ?? {}, d = u(l.input), f = u(l.output), p = u(l.cachedInputTokens), m = t(c), h = i(c), g = s(c), _ = r(c);
|
|
37
|
+
return {
|
|
38
|
+
id: String(c.id ?? ""),
|
|
39
|
+
name: String(c.name ?? c.id ?? ""),
|
|
40
|
+
...typeof c.description == "string" && c.description !== "" ? { description: c.description } : {},
|
|
41
|
+
modality: o(c),
|
|
42
|
+
...d !== void 0 && f !== void 0 ? { pricing: {
|
|
43
|
+
inputPer1M: d,
|
|
44
|
+
outputPer1M: f,
|
|
45
|
+
...p === void 0 ? {} : { cachedInputPer1M: p }
|
|
46
|
+
} } : {},
|
|
47
|
+
capabilities: e(c),
|
|
48
|
+
modalities: a(c),
|
|
49
|
+
...m === void 0 ? {} : { contextWindow: m },
|
|
50
|
+
...h === void 0 ? {} : { maxOutputTokens: h },
|
|
51
|
+
...g === void 0 ? {} : { releasedAt: g },
|
|
52
|
+
..._ === void 0 ? {} : { knowledgeCutoff: _ },
|
|
53
|
+
dataPolicy: n(c),
|
|
54
|
+
raw: c
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { h as fromRaw, f as getAvailableModels, m as readGatewayCatalog, d as toModelInfo };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/gatewayCatalog.ts
|
|
2
|
+
var e = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : [], t = (e) => typeof e == "number" && Number.isFinite(e) ? e : void 0, n = (e) => e === "all" || e === "some" ? e : "none", r = (e) => {
|
|
3
|
+
let n = t(e);
|
|
4
|
+
if (n === void 0) return;
|
|
5
|
+
let r = /* @__PURE__ */ new Date(n * 1e3);
|
|
6
|
+
return Number.isNaN(r.getTime()) ? void 0 : r.toISOString();
|
|
7
|
+
}, i = (t) => {
|
|
8
|
+
let n = new Set(e(t.tags)), r = new Set(e(t.supported_parameters)), i = t.modalities ?? {}, a = new Set(e(i.input)), o = new Set(e(i.output));
|
|
9
|
+
return {
|
|
10
|
+
vision: n.has("vision") || a.has("image"),
|
|
11
|
+
reasoning: n.has("reasoning") || r.has("reasoning"),
|
|
12
|
+
toolUse: n.has("tool-use") || r.has("tools"),
|
|
13
|
+
structuredOutput: n.has("structured-output") || r.has("response_format"),
|
|
14
|
+
webSearch: n.has("web-search") || r.has("web_search_options"),
|
|
15
|
+
caching: n.has("caching") || r.has("prompt_cache_key"),
|
|
16
|
+
imageOut: o.has("image"),
|
|
17
|
+
audioOut: o.has("audio"),
|
|
18
|
+
videoOut: o.has("video"),
|
|
19
|
+
audioIn: a.has("audio"),
|
|
20
|
+
videoIn: a.has("video"),
|
|
21
|
+
fileInput: a.has("file") || a.has("pdf")
|
|
22
|
+
};
|
|
23
|
+
}, a = (t) => {
|
|
24
|
+
let n = t.modalities ?? {};
|
|
25
|
+
return {
|
|
26
|
+
input: e(n.input),
|
|
27
|
+
output: e(n.output)
|
|
28
|
+
};
|
|
29
|
+
}, o = (e) => ({
|
|
30
|
+
zeroRetention: n(e.zdr),
|
|
31
|
+
noTraining: n(e.no_training)
|
|
32
|
+
}), s = (e) => t(e.context_window), c = (e) => t(e.max_tokens), l = (e) => r(e.released), u = (e) => typeof e.knowledge == "string" && e.knowledge !== "" ? e.knowledge : void 0, d = (e) => {
|
|
33
|
+
let t = e.model_type;
|
|
34
|
+
return typeof t == "string" && [
|
|
35
|
+
"language",
|
|
36
|
+
"embedding",
|
|
37
|
+
"image",
|
|
38
|
+
"video",
|
|
39
|
+
"realtime",
|
|
40
|
+
"reranking",
|
|
41
|
+
"speech",
|
|
42
|
+
"transcription",
|
|
43
|
+
"evaluation"
|
|
44
|
+
].includes(t) ? t : "unknown";
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { i as capabilitiesOf, s as contextWindowOf, o as dataPolicyOf, u as knowledgeCutoffOf, c as maxOutputTokensOf, a as modalitiesOf, d as modalityOf, l as releasedAtOf };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { createGateway as e } from "@ai-sdk/gateway";
|
|
2
|
+
//#region src/gatewayMedia.ts
|
|
3
|
+
var t = (e, t) => {
|
|
4
|
+
let n = Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0));
|
|
5
|
+
return {
|
|
6
|
+
...e,
|
|
7
|
+
fetch: async (t, r) => {
|
|
8
|
+
let i = e.fetch ?? globalThis.fetch;
|
|
9
|
+
if (Object.keys(n).length === 0) return i(t, r);
|
|
10
|
+
if (r?.method !== "POST" || typeof r.body != "string") throw Error("Gateway media: expected a JSON POST to preserve the requested parameters");
|
|
11
|
+
let a;
|
|
12
|
+
try {
|
|
13
|
+
a = JSON.parse(r.body);
|
|
14
|
+
} catch {
|
|
15
|
+
throw Error("Gateway media: expected a JSON object to preserve the requested parameters");
|
|
16
|
+
}
|
|
17
|
+
if (typeof a != "object" || !a || Array.isArray(a)) throw Error("Gateway media: expected a JSON object to preserve the requested parameters");
|
|
18
|
+
return i(t, {
|
|
19
|
+
...r,
|
|
20
|
+
body: JSON.stringify({
|
|
21
|
+
...a,
|
|
22
|
+
...n
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}, n = (e, t) => {
|
|
28
|
+
let n = Reflect.get(e, t, e);
|
|
29
|
+
return typeof n == "function" && t !== "constructor" ? n.bind(e) : n;
|
|
30
|
+
}, r = (r, i) => {
|
|
31
|
+
let a = e(r).image(i), o = (n) => e(t(r, {
|
|
32
|
+
seed: n.seed,
|
|
33
|
+
size: n.size,
|
|
34
|
+
aspectRatio: n.aspectRatio
|
|
35
|
+
})).image(i).doGenerate(n);
|
|
36
|
+
return new Proxy(a, { get: (e, t) => t === "doGenerate" ? o : n(e, t) });
|
|
37
|
+
}, i = (r, i) => {
|
|
38
|
+
let a = e(r).video(i), o = a.doGenerate === void 0 ? void 0 : (n) => {
|
|
39
|
+
let a = e(t(r, {
|
|
40
|
+
seed: n.seed,
|
|
41
|
+
duration: n.duration,
|
|
42
|
+
fps: n.fps,
|
|
43
|
+
aspectRatio: n.aspectRatio,
|
|
44
|
+
resolution: n.resolution
|
|
45
|
+
})).video(i);
|
|
46
|
+
if (!a.doGenerate) throw Error("Gateway video does not implement doGenerate");
|
|
47
|
+
return a.doGenerate(n);
|
|
48
|
+
}, s = a.doStart === void 0 ? void 0 : (n) => {
|
|
49
|
+
let a = e(t(r, {
|
|
50
|
+
seed: n.seed,
|
|
51
|
+
duration: n.duration,
|
|
52
|
+
fps: n.fps,
|
|
53
|
+
aspectRatio: n.aspectRatio,
|
|
54
|
+
resolution: n.resolution
|
|
55
|
+
})).video(i);
|
|
56
|
+
if (!a.doStart) throw Error("Gateway video does not implement doStart");
|
|
57
|
+
return a.doStart(n);
|
|
58
|
+
};
|
|
59
|
+
return new Proxy(a, { get: (e, t) => t === "doGenerate" ? o : t === "doStart" ? s : n(e, t) });
|
|
60
|
+
}, a = 134217728, o = (e, t = process.env) => {
|
|
61
|
+
if (e !== void 0) return e;
|
|
62
|
+
let n = Number(t.VOLTRO_AI_MEDIA_MAX_RESPONSE_BYTES);
|
|
63
|
+
return Number.isFinite(n) && n > 0 ? Math.floor(n) : a;
|
|
64
|
+
}, s = (e) => `gateway media response exceeded maxResponseBytes (${e}); it was not read further. Raise \`maxResponseBytes\` on the gateway provider config, or VOLTRO_AI_MEDIA_MAX_RESPONSE_BYTES.`, c = (e) => Response.json({ error: {
|
|
65
|
+
message: s(e),
|
|
66
|
+
type: "response_too_large"
|
|
67
|
+
} }, { status: 413 }), l = async (e, t) => {
|
|
68
|
+
let n = Number(e.headers.get("content-length"));
|
|
69
|
+
if (Number.isFinite(n) && n > t) return e.body?.cancel(), c(t);
|
|
70
|
+
if (e.body === null) return e;
|
|
71
|
+
let r = e.body.getReader(), i = [], a = 0;
|
|
72
|
+
for (;;) {
|
|
73
|
+
let { done: e, value: n } = await r.read();
|
|
74
|
+
if (e) break;
|
|
75
|
+
if (a += n.byteLength, a > t) return r.cancel(), c(t);
|
|
76
|
+
i.push(new Uint8Array(n));
|
|
77
|
+
}
|
|
78
|
+
return new Response(new Blob(i), {
|
|
79
|
+
status: e.status,
|
|
80
|
+
statusText: e.statusText,
|
|
81
|
+
headers: e.headers
|
|
82
|
+
});
|
|
83
|
+
}, u = (e, t) => ({
|
|
84
|
+
...e,
|
|
85
|
+
fetch: async (n, r) => l(await (e.fetch ?? globalThis.fetch)(n, r), t)
|
|
86
|
+
});
|
|
87
|
+
//#endregion
|
|
88
|
+
export { a as DEFAULT_MEDIA_MAX_RESPONSE_BYTES, u as boundedGatewaySettings, r as gatewayImageModel, i as gatewayVideoModel, o as mediaResponseBudget, s as mediaResponseTooLargeMessage };
|