@voltro/ai 0.75.0 → 0.77.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 +459 -0
- package/THIRD-PARTY-NOTICES.md +34 -7
- package/dist/agentEvent-BuXA7sRt.js +152 -0
- package/dist/events.d.ts +125 -0
- package/dist/events.js +2 -60
- package/dist/index.d.ts +210 -5
- package/dist/index.js +811 -544
- package/dist/{inferenceQueue-CdWTzRp7.js → inferenceQueue-t5ayqzjs.js} +380 -297
- package/dist/{provider-Cts1BRhY.js → provider-BsyDya-H.js} +8 -4
- package/dist/test.js +1 -1
- package/dist/workflow.d.ts +1 -1
- package/dist/workflow.js +70 -70
- package/package.json +10 -9
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Schema as e } from "effect";
|
|
2
|
+
//#region src/transcriptionEvent.ts
|
|
3
|
+
var t = class extends e.TaggedError()("TranscriptionStreamError", {
|
|
4
|
+
reason: e.Literal("input", "unsupported", "provider", "cancelled"),
|
|
5
|
+
message: e.String
|
|
6
|
+
}) {}, n = e.Struct({
|
|
7
|
+
text: e.String,
|
|
8
|
+
start: e.Number,
|
|
9
|
+
end: e.Number
|
|
10
|
+
}), r = { id: e.optional(e.String) }, i = e.Union(e.Struct({
|
|
11
|
+
type: e.Literal("transcript-delta"),
|
|
12
|
+
...r,
|
|
13
|
+
delta: e.String
|
|
14
|
+
}), e.Struct({
|
|
15
|
+
type: e.Literal("transcript-partial"),
|
|
16
|
+
...r,
|
|
17
|
+
text: e.String,
|
|
18
|
+
startSecond: e.optional(e.Number),
|
|
19
|
+
durationInSeconds: e.optional(e.Number),
|
|
20
|
+
channelIndex: e.optional(e.Number)
|
|
21
|
+
}), e.Struct({
|
|
22
|
+
type: e.Literal("transcript-final"),
|
|
23
|
+
...r,
|
|
24
|
+
text: e.String,
|
|
25
|
+
startSecond: e.optional(e.Number),
|
|
26
|
+
endSecond: e.optional(e.Number),
|
|
27
|
+
channelIndex: e.optional(e.Number)
|
|
28
|
+
}), e.Struct({
|
|
29
|
+
type: e.Literal("finish"),
|
|
30
|
+
text: e.String,
|
|
31
|
+
segments: e.Array(n),
|
|
32
|
+
language: e.optional(e.String),
|
|
33
|
+
durationSec: e.optional(e.Number)
|
|
34
|
+
})), a = e.String.pipe(e.pattern(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/)), o = e.Number.pipe(e.finite(), e.nonNegative()), s = e.Union(e.Struct({
|
|
35
|
+
type: e.Literal("input-audio-append"),
|
|
36
|
+
audio: a
|
|
37
|
+
}), e.Struct({ type: e.Literal("input-audio-commit", "input-audio-clear", "response-create", "response-cancel") }), e.Struct({
|
|
38
|
+
type: e.Literal("conversation-item-create"),
|
|
39
|
+
item: e.Struct({
|
|
40
|
+
type: e.Literal("text-message"),
|
|
41
|
+
role: e.Literal("user"),
|
|
42
|
+
text: e.String
|
|
43
|
+
})
|
|
44
|
+
}), e.Struct({
|
|
45
|
+
type: e.Literal("conversation-item-truncate"),
|
|
46
|
+
itemId: e.String,
|
|
47
|
+
contentIndex: o.pipe(e.int()),
|
|
48
|
+
audioEndMs: o
|
|
49
|
+
})), c = { itemId: e.String }, l = {
|
|
50
|
+
responseId: e.String,
|
|
51
|
+
...c
|
|
52
|
+
}, u = e.Union(e.Struct({ type: e.Literal("ready") }), e.Struct({
|
|
53
|
+
type: e.Literal("session-created"),
|
|
54
|
+
sessionId: e.optional(e.String)
|
|
55
|
+
}), e.Struct({ type: e.Literal("session-updated") }), e.Struct({
|
|
56
|
+
type: e.Literal("speech-started", "speech-stopped"),
|
|
57
|
+
itemId: e.optional(e.String)
|
|
58
|
+
}), e.Struct({
|
|
59
|
+
type: e.Literal("audio-committed"),
|
|
60
|
+
itemId: e.optional(e.String),
|
|
61
|
+
previousItemId: e.optional(e.String)
|
|
62
|
+
}), e.Struct({
|
|
63
|
+
type: e.Literal("conversation-item-added"),
|
|
64
|
+
...c
|
|
65
|
+
}), e.Struct({
|
|
66
|
+
type: e.Literal("input-transcription-completed"),
|
|
67
|
+
...c,
|
|
68
|
+
transcript: e.String
|
|
69
|
+
}), e.Struct({
|
|
70
|
+
type: e.Literal("response-created"),
|
|
71
|
+
responseId: e.String
|
|
72
|
+
}), e.Struct({
|
|
73
|
+
type: e.Literal("response-done"),
|
|
74
|
+
responseId: e.String,
|
|
75
|
+
status: e.String
|
|
76
|
+
}), e.Struct({
|
|
77
|
+
type: e.Literal("output-item-added", "output-item-done", "content-part-added", "content-part-done", "audio-done"),
|
|
78
|
+
...l
|
|
79
|
+
}), e.Struct({
|
|
80
|
+
type: e.Literal("audio-delta"),
|
|
81
|
+
...l,
|
|
82
|
+
delta: a
|
|
83
|
+
}), e.Struct({
|
|
84
|
+
type: e.Literal("text-delta", "audio-transcript-delta"),
|
|
85
|
+
...l,
|
|
86
|
+
delta: e.String
|
|
87
|
+
}), e.Struct({
|
|
88
|
+
type: e.Literal("text-done"),
|
|
89
|
+
...l,
|
|
90
|
+
text: e.optional(e.String)
|
|
91
|
+
}), e.Struct({
|
|
92
|
+
type: e.Literal("audio-transcript-done"),
|
|
93
|
+
...l,
|
|
94
|
+
transcript: e.optional(e.String)
|
|
95
|
+
})), d = e.Literal("provider", "tool", "timeout", "cancelled", "decode", "internal"), f = e.Struct({
|
|
96
|
+
inputTokens: e.optional(e.Number),
|
|
97
|
+
outputTokens: e.optional(e.Number),
|
|
98
|
+
totalTokens: e.optional(e.Number)
|
|
99
|
+
}), p = e.Union(e.Struct({
|
|
100
|
+
_tag: e.Literal("token"),
|
|
101
|
+
text: e.String
|
|
102
|
+
}), e.Struct({
|
|
103
|
+
_tag: e.Literal("reasoning"),
|
|
104
|
+
text: e.String
|
|
105
|
+
}), e.Struct({
|
|
106
|
+
_tag: e.Literal("toolCall"),
|
|
107
|
+
id: e.String,
|
|
108
|
+
name: e.String,
|
|
109
|
+
input: e.Unknown
|
|
110
|
+
}), e.Struct({
|
|
111
|
+
_tag: e.Literal("toolResult"),
|
|
112
|
+
id: e.String,
|
|
113
|
+
name: e.String,
|
|
114
|
+
output: e.optional(e.Unknown),
|
|
115
|
+
error: e.optional(e.String)
|
|
116
|
+
}), e.Struct({
|
|
117
|
+
_tag: e.Literal("source"),
|
|
118
|
+
sourceType: e.Literal("url", "document"),
|
|
119
|
+
id: e.String,
|
|
120
|
+
url: e.optional(e.String),
|
|
121
|
+
title: e.optional(e.String),
|
|
122
|
+
mediaType: e.optional(e.String),
|
|
123
|
+
filename: e.optional(e.String),
|
|
124
|
+
providerMetadata: e.optional(e.Unknown)
|
|
125
|
+
}), e.Struct({
|
|
126
|
+
_tag: e.Literal("file"),
|
|
127
|
+
mediaType: e.String,
|
|
128
|
+
data: e.String,
|
|
129
|
+
providerMetadata: e.optional(e.Unknown)
|
|
130
|
+
}), e.Struct({
|
|
131
|
+
_tag: e.Literal("stepMetadata"),
|
|
132
|
+
step: e.Int.pipe(e.nonNegative()),
|
|
133
|
+
providerMetadata: e.Unknown
|
|
134
|
+
}), e.Struct({
|
|
135
|
+
_tag: e.Literal("message"),
|
|
136
|
+
role: e.String,
|
|
137
|
+
content: e.String
|
|
138
|
+
}), e.Struct({
|
|
139
|
+
_tag: e.Literal("error"),
|
|
140
|
+
code: d,
|
|
141
|
+
message: e.String,
|
|
142
|
+
retryable: e.Boolean
|
|
143
|
+
}), e.Struct({
|
|
144
|
+
_tag: e.Literal("done"),
|
|
145
|
+
finishReason: e.String,
|
|
146
|
+
usage: f
|
|
147
|
+
})), m = e.Struct({
|
|
148
|
+
seq: e.Number,
|
|
149
|
+
event: p
|
|
150
|
+
});
|
|
151
|
+
//#endregion
|
|
152
|
+
export { u as a, s as i, p as n, t as o, m as r, i as s, d as t };
|
package/dist/events.d.ts
CHANGED
|
@@ -63,6 +63,87 @@ export declare const AgentEvent: Schema.Union<[Schema.Struct<{
|
|
|
63
63
|
|
|
64
64
|
export declare type AgentEvent = typeof AgentEvent.Type;
|
|
65
65
|
|
|
66
|
+
/** Browser-safe input allowlist. Session configuration and provider credentials
|
|
67
|
+
* belong to the server, never to events received from the browser. */
|
|
68
|
+
export declare const RealtimeClientEvent: Schema.Union<[Schema.Struct<{
|
|
69
|
+
type: Schema.Literal<["input-audio-append"]>;
|
|
70
|
+
audio: Schema.filter<typeof Schema.String>;
|
|
71
|
+
}>, Schema.Struct<{
|
|
72
|
+
type: Schema.Literal<["input-audio-commit", "input-audio-clear", "response-create", "response-cancel"]>;
|
|
73
|
+
}>, Schema.Struct<{
|
|
74
|
+
type: Schema.Literal<["conversation-item-create"]>;
|
|
75
|
+
item: Schema.Struct<{
|
|
76
|
+
type: Schema.Literal<["text-message"]>;
|
|
77
|
+
role: Schema.Literal<["user"]>;
|
|
78
|
+
text: typeof Schema.String;
|
|
79
|
+
}>;
|
|
80
|
+
}>, Schema.Struct<{
|
|
81
|
+
type: Schema.Literal<["conversation-item-truncate"]>;
|
|
82
|
+
itemId: typeof Schema.String;
|
|
83
|
+
contentIndex: Schema.filter<Schema.filter<Schema.filter<typeof Schema.Number>>>;
|
|
84
|
+
audioEndMs: Schema.filter<Schema.filter<typeof Schema.Number>>;
|
|
85
|
+
}>]>;
|
|
86
|
+
|
|
87
|
+
export declare type RealtimeClientEvent = typeof RealtimeClientEvent.Type;
|
|
88
|
+
|
|
89
|
+
/** Safe, normalized server events. No raw provider payload, client secret,
|
|
90
|
+
* arbitrary conversation item or provider error message crosses this surface. */
|
|
91
|
+
export declare const RealtimeServerEvent: Schema.Union<[Schema.Struct<{
|
|
92
|
+
type: Schema.Literal<["ready"]>;
|
|
93
|
+
}>, Schema.Struct<{
|
|
94
|
+
type: Schema.Literal<["session-created"]>;
|
|
95
|
+
sessionId: Schema.optional<typeof Schema.String>;
|
|
96
|
+
}>, Schema.Struct<{
|
|
97
|
+
type: Schema.Literal<["session-updated"]>;
|
|
98
|
+
}>, Schema.Struct<{
|
|
99
|
+
type: Schema.Literal<["speech-started", "speech-stopped"]>;
|
|
100
|
+
itemId: Schema.optional<typeof Schema.String>;
|
|
101
|
+
}>, Schema.Struct<{
|
|
102
|
+
type: Schema.Literal<["audio-committed"]>;
|
|
103
|
+
itemId: Schema.optional<typeof Schema.String>;
|
|
104
|
+
previousItemId: Schema.optional<typeof Schema.String>;
|
|
105
|
+
}>, Schema.Struct<{
|
|
106
|
+
itemId: typeof Schema.String;
|
|
107
|
+
type: Schema.Literal<["conversation-item-added"]>;
|
|
108
|
+
}>, Schema.Struct<{
|
|
109
|
+
transcript: typeof Schema.String;
|
|
110
|
+
itemId: typeof Schema.String;
|
|
111
|
+
type: Schema.Literal<["input-transcription-completed"]>;
|
|
112
|
+
}>, Schema.Struct<{
|
|
113
|
+
type: Schema.Literal<["response-created"]>;
|
|
114
|
+
responseId: typeof Schema.String;
|
|
115
|
+
}>, Schema.Struct<{
|
|
116
|
+
type: Schema.Literal<["response-done"]>;
|
|
117
|
+
responseId: typeof Schema.String;
|
|
118
|
+
status: typeof Schema.String;
|
|
119
|
+
}>, Schema.Struct<{
|
|
120
|
+
itemId: typeof Schema.String;
|
|
121
|
+
responseId: typeof Schema.String;
|
|
122
|
+
type: Schema.Literal<["output-item-added", "output-item-done", "content-part-added", "content-part-done", "audio-done"]>;
|
|
123
|
+
}>, Schema.Struct<{
|
|
124
|
+
delta: Schema.filter<typeof Schema.String>;
|
|
125
|
+
itemId: typeof Schema.String;
|
|
126
|
+
responseId: typeof Schema.String;
|
|
127
|
+
type: Schema.Literal<["audio-delta"]>;
|
|
128
|
+
}>, Schema.Struct<{
|
|
129
|
+
delta: typeof Schema.String;
|
|
130
|
+
itemId: typeof Schema.String;
|
|
131
|
+
responseId: typeof Schema.String;
|
|
132
|
+
type: Schema.Literal<["text-delta", "audio-transcript-delta"]>;
|
|
133
|
+
}>, Schema.Struct<{
|
|
134
|
+
text: Schema.optional<typeof Schema.String>;
|
|
135
|
+
itemId: typeof Schema.String;
|
|
136
|
+
responseId: typeof Schema.String;
|
|
137
|
+
type: Schema.Literal<["text-done"]>;
|
|
138
|
+
}>, Schema.Struct<{
|
|
139
|
+
transcript: Schema.optional<typeof Schema.String>;
|
|
140
|
+
itemId: typeof Schema.String;
|
|
141
|
+
responseId: typeof Schema.String;
|
|
142
|
+
type: Schema.Literal<["audio-transcript-done"]>;
|
|
143
|
+
}>]>;
|
|
144
|
+
|
|
145
|
+
export declare type RealtimeServerEvent = typeof RealtimeServerEvent.Type;
|
|
146
|
+
|
|
66
147
|
/**
|
|
67
148
|
* One persisted event of a RESUMABLE stream: an `AgentEvent` plus its monotonic
|
|
68
149
|
* 1-based position. `seq` is the resume cursor — a client that has rendered up
|
|
@@ -135,4 +216,48 @@ export declare const SeqEvent: Schema.Struct<{
|
|
|
135
216
|
|
|
136
217
|
export declare type SeqEvent = typeof SeqEvent.Type;
|
|
137
218
|
|
|
219
|
+
/** Browser-safe error contract for a declared transcription stream. */
|
|
220
|
+
export declare class TranscriptionStreamError extends TranscriptionStreamError_base {
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare const TranscriptionStreamError_base: Schema.TaggedErrorClass<TranscriptionStreamError, "TranscriptionStreamError", {
|
|
224
|
+
readonly _tag: Schema.tag<"TranscriptionStreamError">;
|
|
225
|
+
} & {
|
|
226
|
+
reason: Schema.Literal<["input", "unsupported", "provider", "cancelled"]>;
|
|
227
|
+
message: typeof Schema.String;
|
|
228
|
+
}>;
|
|
229
|
+
|
|
230
|
+
/** 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: typeof Schema.String;
|
|
233
|
+
id: Schema.optional<typeof Schema.String>;
|
|
234
|
+
type: Schema.Literal<["transcript-delta"]>;
|
|
235
|
+
}>, Schema.Struct<{
|
|
236
|
+
text: typeof Schema.String;
|
|
237
|
+
startSecond: Schema.optional<typeof Schema.Number>;
|
|
238
|
+
durationInSeconds: Schema.optional<typeof Schema.Number>;
|
|
239
|
+
channelIndex: Schema.optional<typeof Schema.Number>;
|
|
240
|
+
id: Schema.optional<typeof Schema.String>;
|
|
241
|
+
type: Schema.Literal<["transcript-partial"]>;
|
|
242
|
+
}>, Schema.Struct<{
|
|
243
|
+
text: typeof Schema.String;
|
|
244
|
+
startSecond: Schema.optional<typeof Schema.Number>;
|
|
245
|
+
endSecond: Schema.optional<typeof Schema.Number>;
|
|
246
|
+
channelIndex: Schema.optional<typeof Schema.Number>;
|
|
247
|
+
id: Schema.optional<typeof Schema.String>;
|
|
248
|
+
type: Schema.Literal<["transcript-final"]>;
|
|
249
|
+
}>, Schema.Struct<{
|
|
250
|
+
type: Schema.Literal<["finish"]>;
|
|
251
|
+
text: typeof Schema.String;
|
|
252
|
+
segments: Schema.Array$<Schema.Struct<{
|
|
253
|
+
text: typeof Schema.String;
|
|
254
|
+
start: typeof Schema.Number;
|
|
255
|
+
end: typeof Schema.Number;
|
|
256
|
+
}>>;
|
|
257
|
+
language: Schema.optional<typeof Schema.String>;
|
|
258
|
+
durationSec: Schema.optional<typeof Schema.Number>;
|
|
259
|
+
}>]>;
|
|
260
|
+
|
|
261
|
+
export declare type TranscriptionStreamEvent = typeof TranscriptionStreamEvent.Type;
|
|
262
|
+
|
|
138
263
|
export { }
|
package/dist/events.js
CHANGED
|
@@ -1,60 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
var t = e.Literal("provider", "tool", "timeout", "cancelled", "decode", "internal"), n = e.Struct({
|
|
4
|
-
inputTokens: e.optional(e.Number),
|
|
5
|
-
outputTokens: e.optional(e.Number),
|
|
6
|
-
totalTokens: e.optional(e.Number)
|
|
7
|
-
}), r = e.Union(e.Struct({
|
|
8
|
-
_tag: e.Literal("token"),
|
|
9
|
-
text: e.String
|
|
10
|
-
}), e.Struct({
|
|
11
|
-
_tag: e.Literal("reasoning"),
|
|
12
|
-
text: e.String
|
|
13
|
-
}), e.Struct({
|
|
14
|
-
_tag: e.Literal("toolCall"),
|
|
15
|
-
id: e.String,
|
|
16
|
-
name: e.String,
|
|
17
|
-
input: e.Unknown
|
|
18
|
-
}), e.Struct({
|
|
19
|
-
_tag: e.Literal("toolResult"),
|
|
20
|
-
id: e.String,
|
|
21
|
-
name: e.String,
|
|
22
|
-
output: e.optional(e.Unknown),
|
|
23
|
-
error: e.optional(e.String)
|
|
24
|
-
}), e.Struct({
|
|
25
|
-
_tag: e.Literal("source"),
|
|
26
|
-
sourceType: e.Literal("url", "document"),
|
|
27
|
-
id: e.String,
|
|
28
|
-
url: e.optional(e.String),
|
|
29
|
-
title: e.optional(e.String),
|
|
30
|
-
mediaType: e.optional(e.String),
|
|
31
|
-
filename: e.optional(e.String),
|
|
32
|
-
providerMetadata: e.optional(e.Unknown)
|
|
33
|
-
}), e.Struct({
|
|
34
|
-
_tag: e.Literal("file"),
|
|
35
|
-
mediaType: e.String,
|
|
36
|
-
data: e.String,
|
|
37
|
-
providerMetadata: e.optional(e.Unknown)
|
|
38
|
-
}), e.Struct({
|
|
39
|
-
_tag: e.Literal("stepMetadata"),
|
|
40
|
-
step: e.Int.pipe(e.nonNegative()),
|
|
41
|
-
providerMetadata: e.Unknown
|
|
42
|
-
}), e.Struct({
|
|
43
|
-
_tag: e.Literal("message"),
|
|
44
|
-
role: e.String,
|
|
45
|
-
content: e.String
|
|
46
|
-
}), e.Struct({
|
|
47
|
-
_tag: e.Literal("error"),
|
|
48
|
-
code: t,
|
|
49
|
-
message: e.String,
|
|
50
|
-
retryable: e.Boolean
|
|
51
|
-
}), e.Struct({
|
|
52
|
-
_tag: e.Literal("done"),
|
|
53
|
-
finishReason: e.String,
|
|
54
|
-
usage: n
|
|
55
|
-
})), i = e.Struct({
|
|
56
|
-
seq: e.Number,
|
|
57
|
-
event: r
|
|
58
|
-
});
|
|
59
|
-
//#endregion
|
|
60
|
-
export { t as AgentErrorCode, r as AgentEvent, i as SeqEvent };
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./agentEvent-BuXA7sRt.js";
|
|
2
|
+
export { o as AgentErrorCode, n as AgentEvent, t as RealtimeClientEvent, e as RealtimeServerEvent, i as SeqEvent, r as TranscriptionStreamError, a as TranscriptionStreamEvent };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { DataStore } from '@voltro/database';
|
|
|
5
5
|
import { defaultSettingsMiddleware } from 'ai';
|
|
6
6
|
import { Effect } from 'effect';
|
|
7
7
|
import { EmbeddingModelV4 } from '@ai-sdk/provider';
|
|
8
|
+
import { Experimental_RealtimeModelV4 } from '@ai-sdk/provider';
|
|
9
|
+
import { Experimental_RealtimeModelV4SessionConfig } from '@ai-sdk/provider';
|
|
8
10
|
import { Experimental_VideoModelV4 } from '@ai-sdk/provider';
|
|
9
11
|
import { Experimental_VideoModelV4File } from '@ai-sdk/provider';
|
|
10
12
|
import { extractReasoningMiddleware } from 'ai';
|
|
@@ -26,10 +28,12 @@ import { SemanticCacheShape } from '@voltro/cache';
|
|
|
26
28
|
import { simulateStreamingMiddleware } from 'ai';
|
|
27
29
|
import { SpeechModelV4 } from '@ai-sdk/provider';
|
|
28
30
|
import { Stream } from 'effect';
|
|
31
|
+
import { Subject } from '@voltro/protocol';
|
|
29
32
|
import { Table } from '@voltro/database';
|
|
30
33
|
import { ToolSet } from 'ai';
|
|
31
34
|
import { TranscriptionModelV4 } from '@ai-sdk/provider';
|
|
32
35
|
import { VoidIfEmpty } from 'effect/Types';
|
|
36
|
+
import { WebSocketGatewayRoute } from '@voltro/protocol';
|
|
33
37
|
import { YieldableError } from 'effect/Cause';
|
|
34
38
|
|
|
35
39
|
/** Count of in-flight streams (diagnostics / leak detection). */
|
|
@@ -305,6 +309,8 @@ export declare const AI_INFERENCES_TABLE = "_voltro_ai_inferences";
|
|
|
305
309
|
|
|
306
310
|
export declare const AI_USAGE_TABLE = "_voltro_ai_usage";
|
|
307
311
|
|
|
312
|
+
export declare type AiBudgetError = AiBudgetExceeded | AiBudgetInvalidInput | AiBudgetReservationConflict;
|
|
313
|
+
|
|
308
314
|
/** A refused reservation, not evidence of a provider charge. */
|
|
309
315
|
export declare class AiBudgetExceeded extends AiBudgetExceeded_base {
|
|
310
316
|
}
|
|
@@ -318,6 +324,17 @@ declare const AiBudgetExceeded_base: Schema.TaggedErrorClass<AiBudgetExceeded, "
|
|
|
318
324
|
attemptedUsd: typeof Schema.Number;
|
|
319
325
|
}>;
|
|
320
326
|
|
|
327
|
+
/** Invalid caller configuration, without echoing the supplied value. */
|
|
328
|
+
export declare class AiBudgetInvalidInput extends AiBudgetInvalidInput_base {
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
declare const AiBudgetInvalidInput_base: Schema.TaggedErrorClass<AiBudgetInvalidInput, "AiBudgetInvalidInput", {
|
|
332
|
+
readonly _tag: Schema.tag<"AiBudgetInvalidInput">;
|
|
333
|
+
} & {
|
|
334
|
+
field: Schema.Literal<["limitUsd", "addUsd", "since", "reservationId", "tenantId"]>;
|
|
335
|
+
message: typeof Schema.String;
|
|
336
|
+
}>;
|
|
337
|
+
|
|
321
338
|
export declare interface AiBudgetReservation {
|
|
322
339
|
readonly reservationId: string;
|
|
323
340
|
readonly tenantId: string | null;
|
|
@@ -325,6 +342,17 @@ export declare interface AiBudgetReservation {
|
|
|
325
342
|
readonly status: 'reserved' | 'replayed';
|
|
326
343
|
}
|
|
327
344
|
|
|
345
|
+
/** A durable reservation identity cannot be rebound or spent after release. */
|
|
346
|
+
export declare class AiBudgetReservationConflict extends AiBudgetReservationConflict_base {
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
declare const AiBudgetReservationConflict_base: Schema.TaggedErrorClass<AiBudgetReservationConflict, "AiBudgetReservationConflict", {
|
|
350
|
+
readonly _tag: Schema.tag<"AiBudgetReservationConflict">;
|
|
351
|
+
} & {
|
|
352
|
+
reason: Schema.Literal<["identity-bound", "already-released"]>;
|
|
353
|
+
message: typeof Schema.String;
|
|
354
|
+
}>;
|
|
355
|
+
|
|
328
356
|
/** Receipt and release tombstone. A receipt and its counter change commit together. */
|
|
329
357
|
export declare const aiBudgetReservationsTable: Table<typeof AI_BUDGET_RESERVATIONS_TABLE, Record<string, ColumnDefinition<unknown>>, true>;
|
|
330
358
|
|
|
@@ -1146,6 +1174,14 @@ export declare interface DefineEvalInput {
|
|
|
1146
1174
|
*/
|
|
1147
1175
|
export declare const definePrompt: (definition: PromptDefinition) => DefinedPrompt;
|
|
1148
1176
|
|
|
1177
|
+
/**
|
|
1178
|
+
* Declare an authenticated, server-owned voice/text relay as a *.ws.ts route.
|
|
1179
|
+
* This uses the gateway listener, not the physical RPC subscription socket.
|
|
1180
|
+
* Credentials, provider configuration and raw provider events stay server-side.
|
|
1181
|
+
* No reconnection or replay is attempted: a new connection is a new paid session.
|
|
1182
|
+
*/
|
|
1183
|
+
export declare const defineRealtimeSession: (options: RealtimeSessionOptions) => WebSocketGatewayRoute;
|
|
1184
|
+
|
|
1149
1185
|
export declare const defineTool: <A, I, O>(def: {
|
|
1150
1186
|
readonly name: string;
|
|
1151
1187
|
readonly description: string;
|
|
@@ -2609,7 +2645,7 @@ export declare interface ModelDataPolicy {
|
|
|
2609
2645
|
readonly noTraining: PolicyCoverage;
|
|
2610
2646
|
}
|
|
2611
2647
|
|
|
2612
|
-
export declare type ModelModality = 'language' | 'embedding' | 'image' | 'video' | 'realtime' | 'reranking' | 'speech' | 'transcription' | 'unknown';
|
|
2648
|
+
export declare type ModelModality = 'language' | 'embedding' | 'image' | 'video' | 'realtime' | 'reranking' | 'speech' | 'transcription' | 'evaluation' | 'unknown';
|
|
2613
2649
|
|
|
2614
2650
|
export declare interface ModelPrice {
|
|
2615
2651
|
/** USD per 1,000,000 input (prompt) tokens. */
|
|
@@ -3005,6 +3041,106 @@ export declare interface ReadRecorder<S extends QueryableStore> {
|
|
|
3005
3041
|
reset(): void;
|
|
3006
3042
|
}
|
|
3007
3043
|
|
|
3044
|
+
/** Browser-safe input allowlist. Session configuration and provider credentials
|
|
3045
|
+
* belong to the server, never to events received from the browser. */
|
|
3046
|
+
export declare const RealtimeClientEvent: Schema.Union<[Schema.Struct<{
|
|
3047
|
+
type: Schema.Literal<["input-audio-append"]>;
|
|
3048
|
+
audio: Schema.filter<typeof Schema.String>;
|
|
3049
|
+
}>, Schema.Struct<{
|
|
3050
|
+
type: Schema.Literal<["input-audio-commit", "input-audio-clear", "response-create", "response-cancel"]>;
|
|
3051
|
+
}>, Schema.Struct<{
|
|
3052
|
+
type: Schema.Literal<["conversation-item-create"]>;
|
|
3053
|
+
item: Schema.Struct<{
|
|
3054
|
+
type: Schema.Literal<["text-message"]>;
|
|
3055
|
+
role: Schema.Literal<["user"]>;
|
|
3056
|
+
text: typeof Schema.String;
|
|
3057
|
+
}>;
|
|
3058
|
+
}>, Schema.Struct<{
|
|
3059
|
+
type: Schema.Literal<["conversation-item-truncate"]>;
|
|
3060
|
+
itemId: typeof Schema.String;
|
|
3061
|
+
contentIndex: Schema.filter<Schema.filter<Schema.filter<typeof Schema.Number>>>;
|
|
3062
|
+
audioEndMs: Schema.filter<Schema.filter<typeof Schema.Number>>;
|
|
3063
|
+
}>]>;
|
|
3064
|
+
|
|
3065
|
+
export declare type RealtimeClientEvent = typeof RealtimeClientEvent.Type;
|
|
3066
|
+
|
|
3067
|
+
/** Safe, normalized server events. No raw provider payload, client secret,
|
|
3068
|
+
* arbitrary conversation item or provider error message crosses this surface. */
|
|
3069
|
+
export declare const RealtimeServerEvent: Schema.Union<[Schema.Struct<{
|
|
3070
|
+
type: Schema.Literal<["ready"]>;
|
|
3071
|
+
}>, Schema.Struct<{
|
|
3072
|
+
type: Schema.Literal<["session-created"]>;
|
|
3073
|
+
sessionId: Schema.optional<typeof Schema.String>;
|
|
3074
|
+
}>, Schema.Struct<{
|
|
3075
|
+
type: Schema.Literal<["session-updated"]>;
|
|
3076
|
+
}>, Schema.Struct<{
|
|
3077
|
+
type: Schema.Literal<["speech-started", "speech-stopped"]>;
|
|
3078
|
+
itemId: Schema.optional<typeof Schema.String>;
|
|
3079
|
+
}>, Schema.Struct<{
|
|
3080
|
+
type: Schema.Literal<["audio-committed"]>;
|
|
3081
|
+
itemId: Schema.optional<typeof Schema.String>;
|
|
3082
|
+
previousItemId: Schema.optional<typeof Schema.String>;
|
|
3083
|
+
}>, Schema.Struct<{
|
|
3084
|
+
itemId: typeof Schema.String;
|
|
3085
|
+
type: Schema.Literal<["conversation-item-added"]>;
|
|
3086
|
+
}>, Schema.Struct<{
|
|
3087
|
+
transcript: typeof Schema.String;
|
|
3088
|
+
itemId: typeof Schema.String;
|
|
3089
|
+
type: Schema.Literal<["input-transcription-completed"]>;
|
|
3090
|
+
}>, Schema.Struct<{
|
|
3091
|
+
type: Schema.Literal<["response-created"]>;
|
|
3092
|
+
responseId: typeof Schema.String;
|
|
3093
|
+
}>, Schema.Struct<{
|
|
3094
|
+
type: Schema.Literal<["response-done"]>;
|
|
3095
|
+
responseId: typeof Schema.String;
|
|
3096
|
+
status: typeof Schema.String;
|
|
3097
|
+
}>, Schema.Struct<{
|
|
3098
|
+
itemId: typeof Schema.String;
|
|
3099
|
+
responseId: typeof Schema.String;
|
|
3100
|
+
type: Schema.Literal<["output-item-added", "output-item-done", "content-part-added", "content-part-done", "audio-done"]>;
|
|
3101
|
+
}>, Schema.Struct<{
|
|
3102
|
+
delta: Schema.filter<typeof Schema.String>;
|
|
3103
|
+
itemId: typeof Schema.String;
|
|
3104
|
+
responseId: typeof Schema.String;
|
|
3105
|
+
type: Schema.Literal<["audio-delta"]>;
|
|
3106
|
+
}>, Schema.Struct<{
|
|
3107
|
+
delta: typeof Schema.String;
|
|
3108
|
+
itemId: typeof Schema.String;
|
|
3109
|
+
responseId: typeof Schema.String;
|
|
3110
|
+
type: Schema.Literal<["text-delta", "audio-transcript-delta"]>;
|
|
3111
|
+
}>, Schema.Struct<{
|
|
3112
|
+
text: Schema.optional<typeof Schema.String>;
|
|
3113
|
+
itemId: typeof Schema.String;
|
|
3114
|
+
responseId: typeof Schema.String;
|
|
3115
|
+
type: Schema.Literal<["text-done"]>;
|
|
3116
|
+
}>, Schema.Struct<{
|
|
3117
|
+
transcript: Schema.optional<typeof Schema.String>;
|
|
3118
|
+
itemId: typeof Schema.String;
|
|
3119
|
+
responseId: typeof Schema.String;
|
|
3120
|
+
type: Schema.Literal<["audio-transcript-done"]>;
|
|
3121
|
+
}>]>;
|
|
3122
|
+
|
|
3123
|
+
export declare type RealtimeServerEvent = typeof RealtimeServerEvent.Type;
|
|
3124
|
+
|
|
3125
|
+
export declare interface RealtimeSessionOptions {
|
|
3126
|
+
readonly path: `/${string}`;
|
|
3127
|
+
readonly model: Experimental_RealtimeModelV4;
|
|
3128
|
+
/** Runs before minting/opening. Authentication alone does not authorize AI spend. */
|
|
3129
|
+
readonly authorize: (subject: Subject, model: {
|
|
3130
|
+
readonly provider: string;
|
|
3131
|
+
readonly modelId: string;
|
|
3132
|
+
}) => Effect.Effect<boolean, unknown>;
|
|
3133
|
+
/** Server-owned configuration. Tool execution is not supported by this relay. */
|
|
3134
|
+
readonly sessionConfig: Omit<Experimental_RealtimeModelV4SessionConfig, 'tools'>;
|
|
3135
|
+
readonly limits?: {
|
|
3136
|
+
readonly maxMessageBytes?: number;
|
|
3137
|
+
readonly maxPendingBytes?: number;
|
|
3138
|
+
readonly maxPendingMessages?: number;
|
|
3139
|
+
readonly setupTimeoutMs?: number;
|
|
3140
|
+
readonly maxDurationMs?: number;
|
|
3141
|
+
};
|
|
3142
|
+
}
|
|
3143
|
+
|
|
3008
3144
|
export declare const recordAiUsage: (store: DataStore, record: AiUsageRecordInput) => Effect.Effect<CostBreakdown & {
|
|
3009
3145
|
readonly receipt: AiUsageReceipt;
|
|
3010
3146
|
}, AiUsageReceiptConflict | AiUsageLedgerError>;
|
|
@@ -3179,7 +3315,7 @@ export declare const registerStream: (streamId: string) => AbortController;
|
|
|
3179
3315
|
export declare const releaseAiBudget: (store: DataStore, opts: {
|
|
3180
3316
|
readonly reservationId: string;
|
|
3181
3317
|
readonly tenantId: string | null;
|
|
3182
|
-
}) => Effect.Effect<"released" | "already-released" | "not-found">;
|
|
3318
|
+
}) => Effect.Effect<"released" | "already-released" | "not-found", AiBudgetInvalidInput>;
|
|
3183
3319
|
|
|
3184
3320
|
export declare const releasedAtOf: (raw: RawGatewayModel) => string | undefined;
|
|
3185
3321
|
|
|
@@ -3199,7 +3335,8 @@ export declare interface RenderedPrompt extends PromptStamp {
|
|
|
3199
3335
|
export declare const replacesBuiltinSpeechProvider: (name: string) => boolean;
|
|
3200
3336
|
|
|
3201
3337
|
/** Reserve before provider I/O. Reuse reservationId only for the same logical
|
|
3202
|
-
* spend, tenant, amount and window. Zero
|
|
3338
|
+
* spend, tenant, amount and window. Zero checks for strictly positive headroom
|
|
3339
|
+
* and returns null; it never creates a free reservation.
|
|
3203
3340
|
* Call outside another transaction; the receipt and counter need one commit.
|
|
3204
3341
|
* A provider failure does not automatically release possibly billed spend. */
|
|
3205
3342
|
export declare const requireAiBudget: (store: DataStore, opts: {
|
|
@@ -3208,7 +3345,7 @@ export declare const requireAiBudget: (store: DataStore, opts: {
|
|
|
3208
3345
|
readonly addUsd?: number;
|
|
3209
3346
|
readonly since?: Date;
|
|
3210
3347
|
readonly reservationId?: string;
|
|
3211
|
-
}) => Effect.Effect<AiBudgetReservation | null,
|
|
3348
|
+
}) => Effect.Effect<AiBudgetReservation | null, AiBudgetError>;
|
|
3212
3349
|
|
|
3213
3350
|
/**
|
|
3214
3351
|
* Rerank `documents` by relevance to `query`, highest score first. Returns
|
|
@@ -3274,6 +3411,9 @@ export declare const resolveMcpBounds: (overrides: Partial<McpBounds> | undefine
|
|
|
3274
3411
|
|
|
3275
3412
|
export declare const resolveModel: (config: ProviderConfig, middleware?: AiMiddleware | ReadonlyArray<AiMiddleware>) => LanguageModelV4;
|
|
3276
3413
|
|
|
3414
|
+
/** Resolve supported server-owned provider configuration to the SDK codec. */
|
|
3415
|
+
export declare const resolveRealtimeModel: (config: ProviderConfig) => Experimental_RealtimeModelV4;
|
|
3416
|
+
|
|
3277
3417
|
export declare const resolveSpeechModel: (config: ProviderConfig) => SpeechModelV4;
|
|
3278
3418
|
|
|
3279
3419
|
/** Resolve the system prompt for a given decoded input. */
|
|
@@ -3915,6 +4055,20 @@ export declare const streamTextWithFallback: (options: StreamTextOptions) => Str
|
|
|
3915
4055
|
*/
|
|
3916
4056
|
export declare const streamTextWithRetry: (options: StreamTextOptions, retry?: StreamRetryOptions) => Stream.Stream<AgentEvent>;
|
|
3917
4057
|
|
|
4058
|
+
/** Live partial transcription, not container decoding or a durable workflow journal.
|
|
4059
|
+
* No automatic retry: replaying audio can duplicate transcript segments and charges.
|
|
4060
|
+
* Raw provider chunks, headers and private metadata are never emitted. */
|
|
4061
|
+
export declare const streamTranscribe: (options: StreamTranscribeOptions) => Stream.Stream<TranscriptionStreamEvent, TranscriptionStreamError>;
|
|
4062
|
+
|
|
4063
|
+
export declare interface StreamTranscribeOptions {
|
|
4064
|
+
/** Single-use raw audio source. Scope interruption cancels it and the provider. */
|
|
4065
|
+
readonly audio: ReadableStream<Uint8Array>;
|
|
4066
|
+
readonly inputAudioFormat: TranscriptionAudioFormat;
|
|
4067
|
+
readonly provider?: ProviderConfig;
|
|
4068
|
+
readonly providerOptions?: AiProviderOptions;
|
|
4069
|
+
readonly signal?: AbortSignal;
|
|
4070
|
+
}
|
|
4071
|
+
|
|
3918
4072
|
/** A synthesized tool's metadata (the discovery/inventory view). */
|
|
3919
4073
|
export declare interface SynthesizedTool {
|
|
3920
4074
|
readonly name: string;
|
|
@@ -3975,7 +4129,7 @@ export declare interface ToolContext {
|
|
|
3975
4129
|
readonly runtime?: Runtime.Runtime<unknown>;
|
|
3976
4130
|
/** SDK tool-call identity for this execution, not a durable application idempotency key. */
|
|
3977
4131
|
readonly invocationId?: string;
|
|
3978
|
-
/**
|
|
4132
|
+
/** Cancellation from either the caller's turn or SDK invocation; Promise handlers must pass it to their I/O. */
|
|
3979
4133
|
readonly abortSignal?: AbortSignal;
|
|
3980
4134
|
}
|
|
3981
4135
|
|
|
@@ -4055,6 +4209,13 @@ export declare interface TranscribeOptions {
|
|
|
4055
4209
|
readonly providerOptions?: AiProviderOptions;
|
|
4056
4210
|
}
|
|
4057
4211
|
|
|
4212
|
+
/** Raw audio only. Container files must be decoded before entering this stream. */
|
|
4213
|
+
export declare interface TranscriptionAudioFormat {
|
|
4214
|
+
readonly type: 'audio/pcm' | 'audio/pcmu' | 'audio/pcma';
|
|
4215
|
+
/** Required for PCM; other formats may declare their provider-supported rate. */
|
|
4216
|
+
readonly rate?: number;
|
|
4217
|
+
}
|
|
4218
|
+
|
|
4058
4219
|
export declare interface TranscriptionResult {
|
|
4059
4220
|
readonly text: string;
|
|
4060
4221
|
readonly language?: string;
|
|
@@ -4105,6 +4266,50 @@ export declare type TranscriptionSource =
|
|
|
4105
4266
|
readonly mediaType: string;
|
|
4106
4267
|
};
|
|
4107
4268
|
|
|
4269
|
+
/** Browser-safe error contract for a declared transcription stream. */
|
|
4270
|
+
export declare class TranscriptionStreamError extends TranscriptionStreamError_base {
|
|
4271
|
+
}
|
|
4272
|
+
|
|
4273
|
+
declare const TranscriptionStreamError_base: Schema.TaggedErrorClass<TranscriptionStreamError, "TranscriptionStreamError", {
|
|
4274
|
+
readonly _tag: Schema.tag<"TranscriptionStreamError">;
|
|
4275
|
+
} & {
|
|
4276
|
+
reason: Schema.Literal<["input", "unsupported", "provider", "cancelled"]>;
|
|
4277
|
+
message: typeof Schema.String;
|
|
4278
|
+
}>;
|
|
4279
|
+
|
|
4280
|
+
/** Partial text is replaceable, delta text is append-only, and final text seals a segment. */
|
|
4281
|
+
export declare const TranscriptionStreamEvent: Schema.Union<[Schema.Struct<{
|
|
4282
|
+
delta: typeof Schema.String;
|
|
4283
|
+
id: Schema.optional<typeof Schema.String>;
|
|
4284
|
+
type: Schema.Literal<["transcript-delta"]>;
|
|
4285
|
+
}>, Schema.Struct<{
|
|
4286
|
+
text: typeof Schema.String;
|
|
4287
|
+
startSecond: Schema.optional<typeof Schema.Number>;
|
|
4288
|
+
durationInSeconds: Schema.optional<typeof Schema.Number>;
|
|
4289
|
+
channelIndex: Schema.optional<typeof Schema.Number>;
|
|
4290
|
+
id: Schema.optional<typeof Schema.String>;
|
|
4291
|
+
type: Schema.Literal<["transcript-partial"]>;
|
|
4292
|
+
}>, Schema.Struct<{
|
|
4293
|
+
text: typeof Schema.String;
|
|
4294
|
+
startSecond: Schema.optional<typeof Schema.Number>;
|
|
4295
|
+
endSecond: Schema.optional<typeof Schema.Number>;
|
|
4296
|
+
channelIndex: Schema.optional<typeof Schema.Number>;
|
|
4297
|
+
id: Schema.optional<typeof Schema.String>;
|
|
4298
|
+
type: Schema.Literal<["transcript-final"]>;
|
|
4299
|
+
}>, Schema.Struct<{
|
|
4300
|
+
type: Schema.Literal<["finish"]>;
|
|
4301
|
+
text: typeof Schema.String;
|
|
4302
|
+
segments: Schema.Array$<Schema.Struct<{
|
|
4303
|
+
text: typeof Schema.String;
|
|
4304
|
+
start: typeof Schema.Number;
|
|
4305
|
+
end: typeof Schema.Number;
|
|
4306
|
+
}>>;
|
|
4307
|
+
language: Schema.optional<typeof Schema.String>;
|
|
4308
|
+
durationSec: Schema.optional<typeof Schema.Number>;
|
|
4309
|
+
}>]>;
|
|
4310
|
+
|
|
4311
|
+
export declare type TranscriptionStreamEvent = typeof TranscriptionStreamEvent.Type;
|
|
4312
|
+
|
|
4108
4313
|
/** How much timestamp detail to ask for. Providers charge for it. */
|
|
4109
4314
|
export declare type TranscriptionTimestamps = 'none' | 'segment' | 'word';
|
|
4110
4315
|
|