@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/embed.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { aiGenerationError as e } from "./api.js";
|
|
2
|
+
import { embeddingProviderFromEnv as t, resolveEmbeddingModel as n } from "./embeddingProvider.js";
|
|
3
|
+
import { cosineSimilarity as r, embed as i, embedMany as a } from "ai";
|
|
4
|
+
import { Effect as o } from "effect";
|
|
5
|
+
//#region src/embed.ts
|
|
6
|
+
var s = (r, a) => o.tryPromise({
|
|
7
|
+
try: async (e) => {
|
|
8
|
+
let o = a ?? t();
|
|
9
|
+
l(o.expectedDimensions);
|
|
10
|
+
let s = await n(o), c = await i({
|
|
11
|
+
model: s,
|
|
12
|
+
value: r,
|
|
13
|
+
abortSignal: e,
|
|
14
|
+
...o.providerOptions === void 0 ? {} : { providerOptions: o.providerOptions }
|
|
15
|
+
});
|
|
16
|
+
return u(c.embedding, o.expectedDimensions, 0), c.embedding;
|
|
17
|
+
},
|
|
18
|
+
catch: (t) => e(t)
|
|
19
|
+
}), c = (r, i) => o.tryPromise({
|
|
20
|
+
try: async (e) => {
|
|
21
|
+
let o = i ?? t();
|
|
22
|
+
l(o.expectedDimensions);
|
|
23
|
+
let s = await n(o), c = await a({
|
|
24
|
+
model: s,
|
|
25
|
+
values: [...r],
|
|
26
|
+
abortSignal: e,
|
|
27
|
+
...o.providerOptions === void 0 ? {} : { providerOptions: o.providerOptions }
|
|
28
|
+
});
|
|
29
|
+
if (c.embeddings.length !== r.length) throw Error(`embedMany: expected ${r.length} vectors, received ${c.embeddings.length}`);
|
|
30
|
+
return c.embeddings.forEach((e, t) => u(e, o.expectedDimensions, t)), c.embeddings;
|
|
31
|
+
},
|
|
32
|
+
catch: (t) => e(t)
|
|
33
|
+
}), l = (e) => {
|
|
34
|
+
if (e !== void 0 && (!Number.isSafeInteger(e) || e <= 0)) throw Error("embedding expectedDimensions must be a positive safe integer");
|
|
35
|
+
}, u = (e, t, n) => {
|
|
36
|
+
if (!Array.isArray(e)) throw Error(`embedding ${n}: expected a vector array`);
|
|
37
|
+
if (t !== void 0 && e.length !== t) throw Error(`embedding ${n}: expected ${t} dimensions, received ${e.length}`);
|
|
38
|
+
if (e.length === 0 || e.some((e) => !Number.isFinite(e))) throw Error(`embedding ${n}: expected a non-empty vector of finite numbers`);
|
|
39
|
+
}, d = (e, t) => r([...e], [...t]);
|
|
40
|
+
//#endregion
|
|
41
|
+
export { d as cosineSimilarity, s as embed, c as embedMany };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createGateway as e, gateway as t } from "@ai-sdk/gateway";
|
|
2
|
+
//#region src/embeddingProvider.ts
|
|
3
|
+
var n = (e, t) => ({
|
|
4
|
+
specificationVersion: "v4",
|
|
5
|
+
provider: "mock",
|
|
6
|
+
modelId: e,
|
|
7
|
+
maxEmbeddingsPerCall: 2048,
|
|
8
|
+
supportsParallelCalls: !0,
|
|
9
|
+
doEmbed: async ({ values: e }) => ({
|
|
10
|
+
embeddings: e.map((e) => r(e, t)),
|
|
11
|
+
usage: { tokens: e.reduce((e, t) => e + t.length, 0) },
|
|
12
|
+
warnings: []
|
|
13
|
+
})
|
|
14
|
+
}), r = (e, t) => {
|
|
15
|
+
let n = Array(t);
|
|
16
|
+
for (let r = 0; r < t; r++) {
|
|
17
|
+
let t = 2166136261 ^ r * 16777619;
|
|
18
|
+
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
19
|
+
n[r] = (t >>> 0) / 4294967295 * 2 - 1;
|
|
20
|
+
}
|
|
21
|
+
return n;
|
|
22
|
+
}, i = async (r) => {
|
|
23
|
+
switch (r.name) {
|
|
24
|
+
case "mock": return n(r.model, r.mockDim ?? 8);
|
|
25
|
+
case "openai": return (await a("@ai-sdk/openai", "openai")).openai.textEmbeddingModel(r.model);
|
|
26
|
+
case "voyage": return (await a("voyage-ai-provider", "voyage")).voyage.textEmbeddingModel(r.model);
|
|
27
|
+
case "cohere": return (await a("@ai-sdk/cohere", "cohere")).cohere.textEmbeddingModel(r.model);
|
|
28
|
+
case "gateway": return (r.apiKey !== void 0 || r.baseURL !== void 0 ? e({
|
|
29
|
+
...r.apiKey === void 0 ? {} : { apiKey: r.apiKey },
|
|
30
|
+
...r.baseURL === void 0 ? {} : { baseURL: r.baseURL }
|
|
31
|
+
}) : t).embeddingModel(r.model);
|
|
32
|
+
}
|
|
33
|
+
}, a = async (e, t) => {
|
|
34
|
+
try {
|
|
35
|
+
return await import(
|
|
36
|
+
/* @vite-ignore */
|
|
37
|
+
e
|
|
38
|
+
);
|
|
39
|
+
} catch {
|
|
40
|
+
throw Error(`embedding provider '${t}' needs the '${e}' package — install it (pnpm add ${e}) or use AI_EMBED_PROVIDER=mock for tests/demos.`);
|
|
41
|
+
}
|
|
42
|
+
}, o = (e = process.env) => {
|
|
43
|
+
let t = (e.AI_EMBED_PROVIDER ?? "mock").toLowerCase(), n = t === "openai" ? "text-embedding-3-small" : t === "voyage" ? "voyage-3" : t === "cohere" ? "embed-english-v3.0" : t === "gateway" ? "openai/text-embedding-3-small" : "mock", r = e.AI_EMBED_MODEL ?? n, i = e.AI_EMBED_MOCK_DIM === void 0 ? void 0 : Number(e.AI_EMBED_MOCK_DIM);
|
|
44
|
+
return {
|
|
45
|
+
name: t,
|
|
46
|
+
model: r,
|
|
47
|
+
...i !== void 0 && Number.isFinite(i) ? { mockDim: i } : {}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { o as embeddingProviderFromEnv, r as hashToVector, i as resolveEmbeddingModel };
|
package/dist/eval.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { providerFromEnv as e } from "./provider.js";
|
|
2
|
+
import { generateObject as t } from "./api.js";
|
|
3
|
+
import { Effect as n, Schema as r } from "effect";
|
|
4
|
+
//#region src/eval.ts
|
|
5
|
+
var i = (e) => {
|
|
6
|
+
if (e.name.trim() === "") throw Error("defineEval: name must be non-empty");
|
|
7
|
+
if (e.cases.length === 0) throw Error(`defineEval "${e.name}": at least one case is required`);
|
|
8
|
+
let t = /* @__PURE__ */ new Set();
|
|
9
|
+
for (let n of e.cases) {
|
|
10
|
+
if (n.id.trim() === "") throw Error(`defineEval "${e.name}": every case needs a non-empty id`);
|
|
11
|
+
if (t.has(n.id)) throw Error(`defineEval "${e.name}": duplicate case id "${n.id}"`);
|
|
12
|
+
t.add(n.id);
|
|
13
|
+
}
|
|
14
|
+
let n = e.judge?.threshold;
|
|
15
|
+
if (n !== void 0 && (n < 0 || n > 1)) throw Error(`defineEval "${e.name}": judge.threshold must be within 0..1 (got ${n})`);
|
|
16
|
+
return {
|
|
17
|
+
...e,
|
|
18
|
+
__eval: !0
|
|
19
|
+
};
|
|
20
|
+
}, a = (e) => typeof e == "object" && !!e && "__eval" in e && e.__eval === !0, o = (e, t) => {
|
|
21
|
+
let n = [], r = e.text;
|
|
22
|
+
for (let i of t) switch (i.kind) {
|
|
23
|
+
case "contains": {
|
|
24
|
+
let e = i.caseInsensitive ? r.toLowerCase() : r, t = i.caseInsensitive ? i.value.toLowerCase() : i.value;
|
|
25
|
+
e.includes(t) || n.push({
|
|
26
|
+
assertion: i,
|
|
27
|
+
detail: `output does not contain "${i.value}"`
|
|
28
|
+
});
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
case "notContains": {
|
|
32
|
+
let e = i.caseInsensitive ? r.toLowerCase() : r, t = i.caseInsensitive ? i.value.toLowerCase() : i.value;
|
|
33
|
+
e.includes(t) && n.push({
|
|
34
|
+
assertion: i,
|
|
35
|
+
detail: `output unexpectedly contains "${i.value}"`
|
|
36
|
+
});
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case "matches": {
|
|
40
|
+
let e;
|
|
41
|
+
try {
|
|
42
|
+
e = new RegExp(i.pattern, i.flags);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
n.push({
|
|
45
|
+
assertion: i,
|
|
46
|
+
detail: `invalid pattern /${i.pattern}/: ${e.message}`
|
|
47
|
+
});
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
e.test(r) || n.push({
|
|
51
|
+
assertion: i,
|
|
52
|
+
detail: `output does not match /${i.pattern}/`
|
|
53
|
+
});
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
case "equals":
|
|
57
|
+
(i.trim ? r.trim() : r) !== (i.trim ? i.value.trim() : i.value) && n.push({
|
|
58
|
+
assertion: i,
|
|
59
|
+
detail: "output is not equal to the expected value"
|
|
60
|
+
});
|
|
61
|
+
break;
|
|
62
|
+
case "maxLatencyMs":
|
|
63
|
+
e.latencyMs > i.value && n.push({
|
|
64
|
+
assertion: i,
|
|
65
|
+
detail: `latency ${e.latencyMs}ms exceeds ${i.value}ms`
|
|
66
|
+
});
|
|
67
|
+
break;
|
|
68
|
+
case "nonEmpty": r.trim() === "" && n.push({
|
|
69
|
+
assertion: i,
|
|
70
|
+
detail: "output is empty"
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return n;
|
|
74
|
+
}, s = .7, c = (e, t, n, r, i) => {
|
|
75
|
+
let a = o(t, [...n, ...e.assert ?? []]), s = r?.threshold ?? .7, c = i === void 0 || i.score >= s;
|
|
76
|
+
return {
|
|
77
|
+
id: e.id,
|
|
78
|
+
pass: a.length === 0 && c,
|
|
79
|
+
assertionFailures: a,
|
|
80
|
+
...i === void 0 ? {} : { judge: i },
|
|
81
|
+
output: t
|
|
82
|
+
};
|
|
83
|
+
}, l = async (e, t) => {
|
|
84
|
+
let n = [];
|
|
85
|
+
for (let r of e.cases) {
|
|
86
|
+
let i = await t.replay({
|
|
87
|
+
case: r,
|
|
88
|
+
def: e
|
|
89
|
+
}), a = e.judge !== void 0 && t.judge !== void 0 ? await t.judge({
|
|
90
|
+
case: r,
|
|
91
|
+
output: i,
|
|
92
|
+
config: e.judge
|
|
93
|
+
}) : void 0;
|
|
94
|
+
n.push(c(r, i, e.assert ?? [], e.judge, a));
|
|
95
|
+
}
|
|
96
|
+
let r = n.filter((e) => !e.pass).length;
|
|
97
|
+
return {
|
|
98
|
+
name: e.name,
|
|
99
|
+
ok: r === 0,
|
|
100
|
+
passed: n.length - r,
|
|
101
|
+
failed: r,
|
|
102
|
+
cases: n,
|
|
103
|
+
...t.branchId === void 0 ? {} : { branch: { id: t.branchId } }
|
|
104
|
+
};
|
|
105
|
+
}, u = r.Struct({
|
|
106
|
+
pass: r.Boolean,
|
|
107
|
+
score: r.Number,
|
|
108
|
+
reason: r.String
|
|
109
|
+
}), d = (e, t, n) => [
|
|
110
|
+
"You are grading an AI assistant response against a rubric. Respond with a JSON",
|
|
111
|
+
"object { pass: boolean, score: number (0..1), reason: string }. Score 1 is a",
|
|
112
|
+
"perfect response, 0 is unusable. Be strict: a plausible-sounding but wrong or",
|
|
113
|
+
"incomplete answer scores low.",
|
|
114
|
+
"",
|
|
115
|
+
`RUBRIC:\n${n.rubric}`,
|
|
116
|
+
...e.golden === void 0 ? [] : ["", `REFERENCE (the previously-accepted answer):\n${e.golden}`],
|
|
117
|
+
...e.input.prompt === "" ? [] : ["", `USER PROMPT:\n${e.input.prompt}`],
|
|
118
|
+
"",
|
|
119
|
+
`CANDIDATE RESPONSE (to grade):\n${t.text}`
|
|
120
|
+
].join("\n"), f = async ({ case: r, output: i, config: a }) => await n.runPromise(t({
|
|
121
|
+
schema: u,
|
|
122
|
+
prompt: d(r, i, a),
|
|
123
|
+
provider: e()
|
|
124
|
+
}).pipe(n.map((e) => e.object), n.catch((e) => n.succeed({
|
|
125
|
+
pass: !1,
|
|
126
|
+
score: 0,
|
|
127
|
+
reason: `judge failed: ${e.message}`
|
|
128
|
+
}))));
|
|
129
|
+
//#endregion
|
|
130
|
+
export { s as DEFAULT_JUDGE_THRESHOLD, i as defineEval, o as evaluateAssertions, a as isEvalDefinition, f as llmJudge, l as runEval, c as scoreCase };
|
package/dist/events.d.ts
CHANGED
|
@@ -1,63 +1,66 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
|
+
import { YieldableError } from 'effect/Cause';
|
|
2
3
|
|
|
3
4
|
/** Error taxonomy. `retryable` on the event drives client/agent retry. */
|
|
4
|
-
export declare const AgentErrorCode: Schema.
|
|
5
|
+
export declare const AgentErrorCode: Schema.Literals<readonly ["provider", "tool", "timeout", "cancelled", "decode", "internal"]>;
|
|
5
6
|
|
|
6
7
|
export declare type AgentErrorCode = typeof AgentErrorCode.Type;
|
|
7
8
|
|
|
8
|
-
export declare const AgentEvent: Schema.Union<[Schema.Struct<{
|
|
9
|
-
_tag: Schema.Literal<
|
|
10
|
-
text:
|
|
9
|
+
export declare const AgentEvent: Schema.Union<readonly [Schema.Struct<{
|
|
10
|
+
readonly _tag: Schema.Literal<"token">;
|
|
11
|
+
readonly text: Schema.String;
|
|
11
12
|
}>, Schema.Struct<{
|
|
12
|
-
_tag: Schema.Literal<
|
|
13
|
-
text:
|
|
13
|
+
readonly _tag: Schema.Literal<"reasoning">;
|
|
14
|
+
readonly text: Schema.String;
|
|
14
15
|
}>, Schema.Struct<{
|
|
15
|
-
_tag: Schema.Literal<
|
|
16
|
-
id:
|
|
17
|
-
name:
|
|
18
|
-
input:
|
|
16
|
+
readonly _tag: Schema.Literal<"toolCall">;
|
|
17
|
+
readonly id: Schema.String;
|
|
18
|
+
readonly name: Schema.String;
|
|
19
|
+
readonly input: Schema.Unknown;
|
|
20
|
+
/** Present when the caller must execute this pending call. */
|
|
21
|
+
readonly execution: Schema.optional<Schema.Literal<"client">>;
|
|
19
22
|
}>, Schema.Struct<{
|
|
20
|
-
_tag: Schema.Literal<
|
|
21
|
-
id:
|
|
22
|
-
name:
|
|
23
|
-
output: Schema.optional<
|
|
24
|
-
error: Schema.optional<
|
|
23
|
+
readonly _tag: Schema.Literal<"toolResult">;
|
|
24
|
+
readonly id: Schema.String;
|
|
25
|
+
readonly name: Schema.String;
|
|
26
|
+
readonly output: Schema.optional<Schema.Unknown>;
|
|
27
|
+
readonly error: Schema.optional<Schema.String>;
|
|
25
28
|
}>, Schema.Struct<{
|
|
26
|
-
_tag: Schema.Literal<
|
|
27
|
-
sourceType: Schema.
|
|
28
|
-
id:
|
|
29
|
-
url: Schema.optional<
|
|
30
|
-
title: Schema.optional<
|
|
31
|
-
mediaType: Schema.optional<
|
|
32
|
-
filename: Schema.optional<
|
|
29
|
+
readonly _tag: Schema.Literal<"source">;
|
|
30
|
+
readonly sourceType: Schema.Literals<readonly ["url", "document"]>;
|
|
31
|
+
readonly id: Schema.String;
|
|
32
|
+
readonly url: Schema.optional<Schema.String>;
|
|
33
|
+
readonly title: Schema.optional<Schema.String>;
|
|
34
|
+
readonly mediaType: Schema.optional<Schema.String>;
|
|
35
|
+
readonly filename: Schema.optional<Schema.String>;
|
|
33
36
|
/** Provider-owned citation attribution; not normalized or interpreted. */
|
|
34
|
-
providerMetadata: Schema.optional<
|
|
37
|
+
readonly providerMetadata: Schema.optional<Schema.Unknown>;
|
|
35
38
|
}>, Schema.Struct<{
|
|
36
|
-
_tag: Schema.Literal<
|
|
37
|
-
mediaType:
|
|
38
|
-
data:
|
|
39
|
+
readonly _tag: Schema.Literal<"file">;
|
|
40
|
+
readonly mediaType: Schema.String;
|
|
41
|
+
readonly data: Schema.String;
|
|
39
42
|
/** Metadata for this file, not the whole model step. */
|
|
40
|
-
providerMetadata: Schema.optional<
|
|
43
|
+
readonly providerMetadata: Schema.optional<Schema.Unknown>;
|
|
41
44
|
}>, Schema.Struct<{
|
|
42
|
-
_tag: Schema.Literal<
|
|
43
|
-
step: Schema.
|
|
44
|
-
providerMetadata:
|
|
45
|
+
readonly _tag: Schema.Literal<"stepMetadata">;
|
|
46
|
+
readonly step: Schema.Int;
|
|
47
|
+
readonly providerMetadata: Schema.Unknown;
|
|
45
48
|
}>, Schema.Struct<{
|
|
46
|
-
_tag: Schema.Literal<
|
|
47
|
-
role:
|
|
48
|
-
content:
|
|
49
|
+
readonly _tag: Schema.Literal<"message">;
|
|
50
|
+
readonly role: Schema.String;
|
|
51
|
+
readonly content: Schema.String;
|
|
49
52
|
}>, Schema.Struct<{
|
|
50
|
-
_tag: Schema.Literal<
|
|
51
|
-
code: Schema.
|
|
52
|
-
message:
|
|
53
|
-
retryable:
|
|
53
|
+
readonly _tag: Schema.Literal<"error">;
|
|
54
|
+
readonly code: Schema.Literals<readonly ["provider", "tool", "timeout", "cancelled", "decode", "internal"]>;
|
|
55
|
+
readonly message: Schema.String;
|
|
56
|
+
readonly retryable: Schema.Boolean;
|
|
54
57
|
}>, Schema.Struct<{
|
|
55
|
-
_tag: Schema.Literal<
|
|
56
|
-
finishReason:
|
|
57
|
-
usage: Schema.Struct<{
|
|
58
|
-
inputTokens: Schema.optional<
|
|
59
|
-
outputTokens: Schema.optional<
|
|
60
|
-
totalTokens: Schema.optional<
|
|
58
|
+
readonly _tag: Schema.Literal<"done">;
|
|
59
|
+
readonly finishReason: Schema.String;
|
|
60
|
+
readonly usage: Schema.Struct<{
|
|
61
|
+
readonly inputTokens: Schema.optional<Schema.Number>;
|
|
62
|
+
readonly outputTokens: Schema.optional<Schema.Number>;
|
|
63
|
+
readonly totalTokens: Schema.optional<Schema.Number>;
|
|
61
64
|
}>;
|
|
62
65
|
}>]>;
|
|
63
66
|
|
|
@@ -65,81 +68,81 @@ export declare type AgentEvent = typeof AgentEvent.Type;
|
|
|
65
68
|
|
|
66
69
|
/** Browser-safe input allowlist. Session configuration and provider credentials
|
|
67
70
|
* belong to the server, never to events received from the browser. */
|
|
68
|
-
export declare const RealtimeClientEvent: Schema.Union<[Schema.Struct<{
|
|
69
|
-
type: Schema.Literal<
|
|
70
|
-
audio: Schema.
|
|
71
|
+
export declare const RealtimeClientEvent: Schema.Union<readonly [Schema.Struct<{
|
|
72
|
+
readonly type: Schema.Literal<"input-audio-append">;
|
|
73
|
+
readonly audio: Schema.String;
|
|
71
74
|
}>, Schema.Struct<{
|
|
72
|
-
type: Schema.
|
|
75
|
+
readonly type: Schema.Literals<readonly ["input-audio-commit", "input-audio-clear", "response-create", "response-cancel"]>;
|
|
73
76
|
}>, Schema.Struct<{
|
|
74
|
-
type: Schema.Literal<
|
|
75
|
-
item: Schema.Struct<{
|
|
76
|
-
type: Schema.Literal<
|
|
77
|
-
role: Schema.Literal<
|
|
78
|
-
text:
|
|
77
|
+
readonly type: Schema.Literal<"conversation-item-create">;
|
|
78
|
+
readonly item: Schema.Struct<{
|
|
79
|
+
readonly type: Schema.Literal<"text-message">;
|
|
80
|
+
readonly role: Schema.Literal<"user">;
|
|
81
|
+
readonly text: Schema.String;
|
|
79
82
|
}>;
|
|
80
83
|
}>, Schema.Struct<{
|
|
81
|
-
type: Schema.Literal<
|
|
82
|
-
itemId:
|
|
83
|
-
contentIndex: Schema.
|
|
84
|
-
audioEndMs: Schema.
|
|
84
|
+
readonly type: Schema.Literal<"conversation-item-truncate">;
|
|
85
|
+
readonly itemId: Schema.String;
|
|
86
|
+
readonly contentIndex: Schema.Number;
|
|
87
|
+
readonly audioEndMs: Schema.Number;
|
|
85
88
|
}>]>;
|
|
86
89
|
|
|
87
90
|
export declare type RealtimeClientEvent = typeof RealtimeClientEvent.Type;
|
|
88
91
|
|
|
89
92
|
/** Safe, normalized server events. No raw provider payload, client secret,
|
|
90
93
|
* arbitrary conversation item or provider error message crosses this surface. */
|
|
91
|
-
export declare const RealtimeServerEvent: Schema.Union<[Schema.Struct<{
|
|
92
|
-
type: Schema.Literal<
|
|
94
|
+
export declare const RealtimeServerEvent: Schema.Union<readonly [Schema.Struct<{
|
|
95
|
+
readonly type: Schema.Literal<"ready">;
|
|
93
96
|
}>, Schema.Struct<{
|
|
94
|
-
type: Schema.Literal<
|
|
95
|
-
sessionId: Schema.optional<
|
|
97
|
+
readonly type: Schema.Literal<"session-created">;
|
|
98
|
+
readonly sessionId: Schema.optional<Schema.String>;
|
|
96
99
|
}>, Schema.Struct<{
|
|
97
|
-
type: Schema.Literal<
|
|
100
|
+
readonly type: Schema.Literal<"session-updated">;
|
|
98
101
|
}>, Schema.Struct<{
|
|
99
|
-
type: Schema.
|
|
100
|
-
itemId: Schema.optional<
|
|
102
|
+
readonly type: Schema.Literals<readonly ["speech-started", "speech-stopped"]>;
|
|
103
|
+
readonly itemId: Schema.optional<Schema.String>;
|
|
101
104
|
}>, Schema.Struct<{
|
|
102
|
-
type: Schema.Literal<
|
|
103
|
-
itemId: Schema.optional<
|
|
104
|
-
previousItemId: Schema.optional<
|
|
105
|
+
readonly type: Schema.Literal<"audio-committed">;
|
|
106
|
+
readonly itemId: Schema.optional<Schema.String>;
|
|
107
|
+
readonly previousItemId: Schema.optional<Schema.String>;
|
|
105
108
|
}>, Schema.Struct<{
|
|
106
|
-
itemId:
|
|
107
|
-
type: Schema.Literal<
|
|
109
|
+
readonly itemId: Schema.String;
|
|
110
|
+
readonly type: Schema.Literal<"conversation-item-added">;
|
|
108
111
|
}>, Schema.Struct<{
|
|
109
|
-
transcript:
|
|
110
|
-
itemId:
|
|
111
|
-
type: Schema.Literal<
|
|
112
|
+
readonly transcript: Schema.String;
|
|
113
|
+
readonly itemId: Schema.String;
|
|
114
|
+
readonly type: Schema.Literal<"input-transcription-completed">;
|
|
112
115
|
}>, Schema.Struct<{
|
|
113
|
-
type: Schema.Literal<
|
|
114
|
-
responseId:
|
|
116
|
+
readonly type: Schema.Literal<"response-created">;
|
|
117
|
+
readonly responseId: Schema.String;
|
|
115
118
|
}>, Schema.Struct<{
|
|
116
|
-
type: Schema.Literal<
|
|
117
|
-
responseId:
|
|
118
|
-
status:
|
|
119
|
+
readonly type: Schema.Literal<"response-done">;
|
|
120
|
+
readonly responseId: Schema.String;
|
|
121
|
+
readonly status: Schema.String;
|
|
119
122
|
}>, Schema.Struct<{
|
|
120
|
-
itemId:
|
|
121
|
-
responseId:
|
|
122
|
-
type: Schema.
|
|
123
|
+
readonly itemId: Schema.String;
|
|
124
|
+
readonly responseId: Schema.String;
|
|
125
|
+
readonly type: Schema.Literals<readonly ["output-item-added", "output-item-done", "content-part-added", "content-part-done", "audio-done"]>;
|
|
123
126
|
}>, Schema.Struct<{
|
|
124
|
-
delta: Schema.
|
|
125
|
-
itemId:
|
|
126
|
-
responseId:
|
|
127
|
-
type: Schema.Literal<
|
|
127
|
+
readonly delta: Schema.String;
|
|
128
|
+
readonly itemId: Schema.String;
|
|
129
|
+
readonly responseId: Schema.String;
|
|
130
|
+
readonly type: Schema.Literal<"audio-delta">;
|
|
128
131
|
}>, Schema.Struct<{
|
|
129
|
-
delta:
|
|
130
|
-
itemId:
|
|
131
|
-
responseId:
|
|
132
|
-
type: Schema.
|
|
132
|
+
readonly delta: Schema.String;
|
|
133
|
+
readonly itemId: Schema.String;
|
|
134
|
+
readonly responseId: Schema.String;
|
|
135
|
+
readonly type: Schema.Literals<readonly ["text-delta", "audio-transcript-delta"]>;
|
|
133
136
|
}>, Schema.Struct<{
|
|
134
|
-
text: Schema.optional<
|
|
135
|
-
itemId:
|
|
136
|
-
responseId:
|
|
137
|
-
type: Schema.Literal<
|
|
137
|
+
readonly text: Schema.optional<Schema.String>;
|
|
138
|
+
readonly itemId: Schema.String;
|
|
139
|
+
readonly responseId: Schema.String;
|
|
140
|
+
readonly type: Schema.Literal<"text-done">;
|
|
138
141
|
}>, Schema.Struct<{
|
|
139
|
-
transcript: Schema.optional<
|
|
140
|
-
itemId:
|
|
141
|
-
responseId:
|
|
142
|
-
type: Schema.Literal<
|
|
142
|
+
readonly transcript: Schema.optional<Schema.String>;
|
|
143
|
+
readonly itemId: Schema.String;
|
|
144
|
+
readonly responseId: Schema.String;
|
|
145
|
+
readonly type: Schema.Literal<"audio-transcript-done">;
|
|
143
146
|
}>]>;
|
|
144
147
|
|
|
145
148
|
export declare type RealtimeServerEvent = typeof RealtimeServerEvent.Type;
|
|
@@ -156,60 +159,62 @@ export declare type RealtimeServerEvent = typeof RealtimeServerEvent.Type;
|
|
|
156
159
|
* client bundle.
|
|
157
160
|
*/
|
|
158
161
|
export declare const SeqEvent: Schema.Struct<{
|
|
159
|
-
seq:
|
|
160
|
-
event: Schema.Union<[Schema.Struct<{
|
|
161
|
-
_tag: Schema.Literal<
|
|
162
|
-
text:
|
|
162
|
+
readonly seq: Schema.Number;
|
|
163
|
+
readonly event: Schema.Union<readonly [Schema.Struct<{
|
|
164
|
+
readonly _tag: Schema.Literal<"token">;
|
|
165
|
+
readonly text: Schema.String;
|
|
163
166
|
}>, Schema.Struct<{
|
|
164
|
-
_tag: Schema.Literal<
|
|
165
|
-
text:
|
|
167
|
+
readonly _tag: Schema.Literal<"reasoning">;
|
|
168
|
+
readonly text: Schema.String;
|
|
166
169
|
}>, Schema.Struct<{
|
|
167
|
-
_tag: Schema.Literal<
|
|
168
|
-
id:
|
|
169
|
-
name:
|
|
170
|
-
input:
|
|
170
|
+
readonly _tag: Schema.Literal<"toolCall">;
|
|
171
|
+
readonly id: Schema.String;
|
|
172
|
+
readonly name: Schema.String;
|
|
173
|
+
readonly input: Schema.Unknown;
|
|
174
|
+
/** Present when the caller must execute this pending call. */
|
|
175
|
+
readonly execution: Schema.optional<Schema.Literal<"client">>;
|
|
171
176
|
}>, Schema.Struct<{
|
|
172
|
-
_tag: Schema.Literal<
|
|
173
|
-
id:
|
|
174
|
-
name:
|
|
175
|
-
output: Schema.optional<
|
|
176
|
-
error: Schema.optional<
|
|
177
|
+
readonly _tag: Schema.Literal<"toolResult">;
|
|
178
|
+
readonly id: Schema.String;
|
|
179
|
+
readonly name: Schema.String;
|
|
180
|
+
readonly output: Schema.optional<Schema.Unknown>;
|
|
181
|
+
readonly error: Schema.optional<Schema.String>;
|
|
177
182
|
}>, Schema.Struct<{
|
|
178
|
-
_tag: Schema.Literal<
|
|
179
|
-
sourceType: Schema.
|
|
180
|
-
id:
|
|
181
|
-
url: Schema.optional<
|
|
182
|
-
title: Schema.optional<
|
|
183
|
-
mediaType: Schema.optional<
|
|
184
|
-
filename: Schema.optional<
|
|
183
|
+
readonly _tag: Schema.Literal<"source">;
|
|
184
|
+
readonly sourceType: Schema.Literals<readonly ["url", "document"]>;
|
|
185
|
+
readonly id: Schema.String;
|
|
186
|
+
readonly url: Schema.optional<Schema.String>;
|
|
187
|
+
readonly title: Schema.optional<Schema.String>;
|
|
188
|
+
readonly mediaType: Schema.optional<Schema.String>;
|
|
189
|
+
readonly filename: Schema.optional<Schema.String>;
|
|
185
190
|
/** Provider-owned citation attribution; not normalized or interpreted. */
|
|
186
|
-
providerMetadata: Schema.optional<
|
|
191
|
+
readonly providerMetadata: Schema.optional<Schema.Unknown>;
|
|
187
192
|
}>, Schema.Struct<{
|
|
188
|
-
_tag: Schema.Literal<
|
|
189
|
-
mediaType:
|
|
190
|
-
data:
|
|
193
|
+
readonly _tag: Schema.Literal<"file">;
|
|
194
|
+
readonly mediaType: Schema.String;
|
|
195
|
+
readonly data: Schema.String;
|
|
191
196
|
/** Metadata for this file, not the whole model step. */
|
|
192
|
-
providerMetadata: Schema.optional<
|
|
197
|
+
readonly providerMetadata: Schema.optional<Schema.Unknown>;
|
|
193
198
|
}>, Schema.Struct<{
|
|
194
|
-
_tag: Schema.Literal<
|
|
195
|
-
step: Schema.
|
|
196
|
-
providerMetadata:
|
|
199
|
+
readonly _tag: Schema.Literal<"stepMetadata">;
|
|
200
|
+
readonly step: Schema.Int;
|
|
201
|
+
readonly providerMetadata: Schema.Unknown;
|
|
197
202
|
}>, Schema.Struct<{
|
|
198
|
-
_tag: Schema.Literal<
|
|
199
|
-
role:
|
|
200
|
-
content:
|
|
203
|
+
readonly _tag: Schema.Literal<"message">;
|
|
204
|
+
readonly role: Schema.String;
|
|
205
|
+
readonly content: Schema.String;
|
|
201
206
|
}>, Schema.Struct<{
|
|
202
|
-
_tag: Schema.Literal<
|
|
203
|
-
code: Schema.
|
|
204
|
-
message:
|
|
205
|
-
retryable:
|
|
207
|
+
readonly _tag: Schema.Literal<"error">;
|
|
208
|
+
readonly code: Schema.Literals<readonly ["provider", "tool", "timeout", "cancelled", "decode", "internal"]>;
|
|
209
|
+
readonly message: Schema.String;
|
|
210
|
+
readonly retryable: Schema.Boolean;
|
|
206
211
|
}>, Schema.Struct<{
|
|
207
|
-
_tag: Schema.Literal<
|
|
208
|
-
finishReason:
|
|
209
|
-
usage: Schema.Struct<{
|
|
210
|
-
inputTokens: Schema.optional<
|
|
211
|
-
outputTokens: Schema.optional<
|
|
212
|
-
totalTokens: Schema.optional<
|
|
212
|
+
readonly _tag: Schema.Literal<"done">;
|
|
213
|
+
readonly finishReason: Schema.String;
|
|
214
|
+
readonly usage: Schema.Struct<{
|
|
215
|
+
readonly inputTokens: Schema.optional<Schema.Number>;
|
|
216
|
+
readonly outputTokens: Schema.optional<Schema.Number>;
|
|
217
|
+
readonly totalTokens: Schema.optional<Schema.Number>;
|
|
213
218
|
}>;
|
|
214
219
|
}>]>;
|
|
215
220
|
}>;
|
|
@@ -220,42 +225,40 @@ export declare type SeqEvent = typeof SeqEvent.Type;
|
|
|
220
225
|
export declare class TranscriptionStreamError extends TranscriptionStreamError_base {
|
|
221
226
|
}
|
|
222
227
|
|
|
223
|
-
declare const TranscriptionStreamError_base: Schema.
|
|
224
|
-
readonly
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
message: typeof Schema.String;
|
|
228
|
-
}>;
|
|
228
|
+
declare const TranscriptionStreamError_base: Schema.Class<TranscriptionStreamError, Schema.TaggedStruct<"TranscriptionStreamError", {
|
|
229
|
+
readonly reason: Schema.Literals<readonly ["input", "unsupported", "provider", "cancelled"]>;
|
|
230
|
+
readonly message: Schema.String;
|
|
231
|
+
}>, YieldableError>;
|
|
229
232
|
|
|
230
233
|
/** Partial text is replaceable, delta text is append-only, and final text seals a segment. */
|
|
231
|
-
export declare const TranscriptionStreamEvent: Schema.Union<[Schema.Struct<{
|
|
232
|
-
delta:
|
|
233
|
-
id: Schema.optional<
|
|
234
|
-
type: Schema.Literal<
|
|
234
|
+
export declare const TranscriptionStreamEvent: Schema.Union<readonly [Schema.Struct<{
|
|
235
|
+
readonly delta: Schema.String;
|
|
236
|
+
readonly id: Schema.optional<Schema.String>;
|
|
237
|
+
readonly type: Schema.Literal<"transcript-delta">;
|
|
235
238
|
}>, Schema.Struct<{
|
|
236
|
-
text:
|
|
237
|
-
startSecond: Schema.optional<
|
|
238
|
-
durationInSeconds: Schema.optional<
|
|
239
|
-
channelIndex: Schema.optional<
|
|
240
|
-
id: Schema.optional<
|
|
241
|
-
type: Schema.Literal<
|
|
239
|
+
readonly text: Schema.String;
|
|
240
|
+
readonly startSecond: Schema.optional<Schema.Number>;
|
|
241
|
+
readonly durationInSeconds: Schema.optional<Schema.Number>;
|
|
242
|
+
readonly channelIndex: Schema.optional<Schema.Number>;
|
|
243
|
+
readonly id: Schema.optional<Schema.String>;
|
|
244
|
+
readonly type: Schema.Literal<"transcript-partial">;
|
|
242
245
|
}>, Schema.Struct<{
|
|
243
|
-
text:
|
|
244
|
-
startSecond: Schema.optional<
|
|
245
|
-
endSecond: Schema.optional<
|
|
246
|
-
channelIndex: Schema.optional<
|
|
247
|
-
id: Schema.optional<
|
|
248
|
-
type: Schema.Literal<
|
|
246
|
+
readonly text: Schema.String;
|
|
247
|
+
readonly startSecond: Schema.optional<Schema.Number>;
|
|
248
|
+
readonly endSecond: Schema.optional<Schema.Number>;
|
|
249
|
+
readonly channelIndex: Schema.optional<Schema.Number>;
|
|
250
|
+
readonly id: Schema.optional<Schema.String>;
|
|
251
|
+
readonly type: Schema.Literal<"transcript-final">;
|
|
249
252
|
}>, Schema.Struct<{
|
|
250
|
-
type: Schema.Literal<
|
|
251
|
-
text:
|
|
252
|
-
segments: Schema
|
|
253
|
-
text:
|
|
254
|
-
start:
|
|
255
|
-
end:
|
|
253
|
+
readonly type: Schema.Literal<"finish">;
|
|
254
|
+
readonly text: Schema.String;
|
|
255
|
+
readonly segments: Schema.$Array<Schema.Struct<{
|
|
256
|
+
readonly text: Schema.String;
|
|
257
|
+
readonly start: Schema.Number;
|
|
258
|
+
readonly end: Schema.Number;
|
|
256
259
|
}>>;
|
|
257
|
-
language: Schema.optional<
|
|
258
|
-
durationSec: Schema.optional<
|
|
260
|
+
readonly language: Schema.optional<Schema.String>;
|
|
261
|
+
readonly durationSec: Schema.optional<Schema.Number>;
|
|
259
262
|
}>]>;
|
|
260
263
|
|
|
261
264
|
export declare type TranscriptionStreamEvent = typeof TranscriptionStreamEvent.Type;
|