@memberjunction/ai 6.1.0-edge.1 → 6.1.0-edge.3
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 +180 -4
- package/dist/generic/baseAudio.d.ts +46 -1
- package/dist/generic/baseAudio.d.ts.map +1 -1
- package/dist/generic/baseAudio.js.map +1 -1
- package/dist/generic/baseRealtime.d.ts +9 -0
- package/dist/generic/baseRealtime.d.ts.map +1 -1
- package/dist/generic/baseRealtime.js +11 -0
- package/dist/generic/baseRealtime.js.map +1 -1
- package/dist/generic/modelConfiguration.d.ts +114 -0
- package/dist/generic/modelConfiguration.d.ts.map +1 -0
- package/dist/generic/modelConfiguration.js +94 -0
- package/dist/generic/modelConfiguration.js.map +1 -0
- package/dist/generic/realtimeUsage.d.ts +61 -0
- package/dist/generic/realtimeUsage.d.ts.map +1 -0
- package/dist/generic/realtimeUsage.js +46 -0
- package/dist/generic/realtimeUsage.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,7 +1,183 @@
|
|
|
1
|
-
|
|
1
|
+
Business Source License 1.1
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB plc.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
-----------------------------------------------------------------------------
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Parameters
|
|
9
|
+
|
|
10
|
+
Licensor: Blue Cypress, Inc.
|
|
11
|
+
|
|
12
|
+
Licensed Work: MemberJunction.
|
|
13
|
+
The Licensed Work is (c) 2023-2026 Blue Cypress, Inc.
|
|
14
|
+
|
|
15
|
+
Additional Use Grant: Subject to the terms of this License, Licensor grants
|
|
16
|
+
you the following additional rights to make Production
|
|
17
|
+
Use of the Licensed Work.
|
|
18
|
+
|
|
19
|
+
1. Internal Use
|
|
20
|
+
|
|
21
|
+
You may make production use of the Licensed Work for
|
|
22
|
+
your own internal business or organizational operations.
|
|
23
|
+
|
|
24
|
+
2. Nonprofit Use
|
|
25
|
+
|
|
26
|
+
If you are a Nonprofit, you may make production use of
|
|
27
|
+
the Licensed Work for the operations and activities of
|
|
28
|
+
your Organizational Family.
|
|
29
|
+
|
|
30
|
+
3. MemberJunction Certified Program Use
|
|
31
|
+
|
|
32
|
+
If you are authorized by Licensor under the
|
|
33
|
+
MemberJunction Certified Program to provide professional
|
|
34
|
+
services using the Licensed Work, you may make
|
|
35
|
+
production use of the Licensed Work in providing such
|
|
36
|
+
professional services to a client, provided that:
|
|
37
|
+
|
|
38
|
+
(a) the Licensed Work is deployed in, and the applicable
|
|
39
|
+
production use occurs within, an environment owned,
|
|
40
|
+
leased, licensed, subscribed to, or otherwise controlled
|
|
41
|
+
by that client; and
|
|
42
|
+
|
|
43
|
+
(b) the production use is for that client's own internal
|
|
44
|
+
business or organizational operations or is otherwise
|
|
45
|
+
independently permitted to that client under this
|
|
46
|
+
Additional Use Grant.
|
|
47
|
+
|
|
48
|
+
4. Definitions Applicable to the Additional Use Grant
|
|
49
|
+
|
|
50
|
+
"Affiliate" means, with respect to a specified Person,
|
|
51
|
+
any other Person that directly or indirectly Controls,
|
|
52
|
+
is Controlled by, or is under common Control with such
|
|
53
|
+
specified Person.
|
|
54
|
+
|
|
55
|
+
"Control" (including the terms "Controls," "Controlled
|
|
56
|
+
by," and "under common Control with") means the direct
|
|
57
|
+
or indirect possession of the power to direct or cause
|
|
58
|
+
the direction of the management and policies of a
|
|
59
|
+
Person, whether through ownership of voting interests,
|
|
60
|
+
by contract, or otherwise.
|
|
61
|
+
|
|
62
|
+
"Organizational Family" means, with respect to a Person,
|
|
63
|
+
(a) such Person and its Affiliates, and (b) any
|
|
64
|
+
nonprofit organization, governmental entity, chapter,
|
|
65
|
+
division, local affiliate, regional affiliate, state
|
|
66
|
+
affiliate, national affiliate, or other entity that is
|
|
67
|
+
formally affiliated with such Person through governing
|
|
68
|
+
documents, a charter, bylaws, a membership agreement, or
|
|
69
|
+
another written organizational instrument, and is
|
|
70
|
+
recognized under such documents as part of the same
|
|
71
|
+
organizational structure.
|
|
72
|
+
|
|
73
|
+
"Nonprofit" means a Person recognized by the Internal
|
|
74
|
+
Revenue Service as exempt from federal income taxation
|
|
75
|
+
under Section 501(c)(3), 501(c)(4), 501(c)(5), or
|
|
76
|
+
501(c)(6) of the Internal Revenue Code, or a foreign
|
|
77
|
+
organization recognized under substantially equivalent
|
|
78
|
+
laws.
|
|
79
|
+
|
|
80
|
+
A Person claiming eligibility as a Nonprofit shall, upon
|
|
81
|
+
Licensor's reasonable request, provide documentation
|
|
82
|
+
reasonably sufficient to demonstrate that it qualifies
|
|
83
|
+
as a Nonprofit. If such Person materially misrepresents,
|
|
84
|
+
or is unable to demonstrate, its qualification as a
|
|
85
|
+
Nonprofit, the rights granted to such Person under
|
|
86
|
+
Section 2 of this Additional Use Grant shall terminate.
|
|
87
|
+
|
|
88
|
+
"MemberJunction Certified Program" means Licensor's
|
|
89
|
+
then-current program for certifying and authorizing a
|
|
90
|
+
Person to provide professional services using the
|
|
91
|
+
Licensed Work.
|
|
92
|
+
|
|
93
|
+
"Person" means any individual, corporation, limited
|
|
94
|
+
liability company, partnership, association, nonprofit
|
|
95
|
+
organization, governmental entity, or other legal or
|
|
96
|
+
organizational entity.
|
|
97
|
+
|
|
98
|
+
Change Date: Four (4) years from the date the Licensed Work is first
|
|
99
|
+
made available.
|
|
100
|
+
|
|
101
|
+
Change License: MIT License.
|
|
102
|
+
|
|
103
|
+
For information about alternative licensing arrangements for the Licensed
|
|
104
|
+
Work, please contact Blue Cypress, Inc.
|
|
105
|
+
|
|
106
|
+
-----------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
Terms
|
|
109
|
+
|
|
110
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
111
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
112
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
113
|
+
production use.
|
|
114
|
+
|
|
115
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
116
|
+
available distribution of a specific version of the Licensed Work under this
|
|
117
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
118
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
119
|
+
above terminate.
|
|
120
|
+
|
|
121
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
122
|
+
currently in effect as described in this License, you must purchase a
|
|
123
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
124
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
125
|
+
|
|
126
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
127
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
128
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
129
|
+
for each version of the Licensed Work released by Licensor.
|
|
130
|
+
|
|
131
|
+
You must conspicuously display this License on each original or modified copy
|
|
132
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
133
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
134
|
+
License apply to your use of that work.
|
|
135
|
+
|
|
136
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
137
|
+
terminate your rights under this License for the current and all other
|
|
138
|
+
versions of the Licensed Work.
|
|
139
|
+
|
|
140
|
+
This License does not grant you any right in any trademark or logo of
|
|
141
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
142
|
+
Licensor as expressly required by this License).
|
|
143
|
+
|
|
144
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
145
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
146
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
147
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
148
|
+
TITLE.
|
|
149
|
+
|
|
150
|
+
MariaDB hereby grants you permission to use this License's text to license
|
|
151
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
152
|
+
as long as you comply with the Covenants of Licensor below.
|
|
153
|
+
|
|
154
|
+
-----------------------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
Covenants of Licensor
|
|
157
|
+
|
|
158
|
+
In consideration of the right to use this License's text and the "Business
|
|
159
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
160
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
161
|
+
|
|
162
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
163
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
164
|
+
where "compatible" means that software provided under the Change License
|
|
165
|
+
can be included in a program with software provided under GPL Version 2.0
|
|
166
|
+
or a later version. Licensor may specify additional Change Licenses without
|
|
167
|
+
limitation.
|
|
168
|
+
|
|
169
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
170
|
+
impose any additional restriction on the right granted in this License, as
|
|
171
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
172
|
+
|
|
173
|
+
3. To specify a Change Date.
|
|
174
|
+
|
|
175
|
+
4. Not to modify this License in any other way.
|
|
176
|
+
|
|
177
|
+
-----------------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
Notice
|
|
180
|
+
|
|
181
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
182
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
183
|
+
under an Open Source License, as stated in this License.
|
|
@@ -33,9 +33,54 @@ export declare class SpeechResult {
|
|
|
33
33
|
}
|
|
34
34
|
export declare class SpeechToTextParams extends BaseParams {
|
|
35
35
|
/**
|
|
36
|
-
* Base 64 encoded audio file to convert to text
|
|
36
|
+
* Base 64 encoded audio file to convert to text.
|
|
37
|
+
*
|
|
38
|
+
* Optional only in the sense that `audioData` may be supplied instead; exactly one of
|
|
39
|
+
* the two is required.
|
|
37
40
|
*/
|
|
38
41
|
audioFile: string;
|
|
42
|
+
/**
|
|
43
|
+
* The raw audio bytes, as an alternative to the base 64 `audioFile`.
|
|
44
|
+
*
|
|
45
|
+
* Preferred whenever the caller already holds a Buffer: base 64 encoding an hour of
|
|
46
|
+
* audio costs a third more memory than the bytes themselves, for a string the
|
|
47
|
+
* implementation immediately decodes again.
|
|
48
|
+
*/
|
|
49
|
+
audioData?: Buffer;
|
|
50
|
+
/**
|
|
51
|
+
* Original file name, e.g. `episode-104.mp3`. Some providers infer the container
|
|
52
|
+
* format from the extension, so supplying it when known improves reliability.
|
|
53
|
+
*/
|
|
54
|
+
fileName?: string;
|
|
55
|
+
/**
|
|
56
|
+
* ISO 639-1 language code of the spoken audio. Supplying it typically improves both
|
|
57
|
+
* accuracy and latency versus letting the model detect the language.
|
|
58
|
+
*/
|
|
59
|
+
language?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Optional text to steer style, spelling or vocabulary — e.g. proper nouns the model
|
|
62
|
+
* would otherwise mis-transcribe. Should be in the same language as the audio.
|
|
63
|
+
*/
|
|
64
|
+
prompt?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Splits an audio buffer into pieces small enough for a provider that caps upload size.
|
|
68
|
+
*
|
|
69
|
+
* This is a port rather than a bundled implementation on purpose. Splitting audio without
|
|
70
|
+
* re-encoding it means a media tool — in practice an ffmpeg binary — and a ~70MB
|
|
71
|
+
* platform-specific binary is not a dependency an AI provider package should force on
|
|
72
|
+
* every consumer, most of which transcribe short clips and never need it. Applications
|
|
73
|
+
* that do transcribe long audio already have such a tool and inject it here.
|
|
74
|
+
*/
|
|
75
|
+
export interface AudioSplitter {
|
|
76
|
+
/**
|
|
77
|
+
* Split `audio` into consecutive pieces, each no larger than `maxBytes`, ordered so
|
|
78
|
+
* that concatenating their transcripts reproduces the whole.
|
|
79
|
+
*
|
|
80
|
+
* Implementations should split on time, not byte offsets: cutting a compressed stream
|
|
81
|
+
* mid-frame produces pieces the provider cannot decode.
|
|
82
|
+
*/
|
|
83
|
+
Split(audio: Buffer, maxBytes: number): Promise<Buffer[]>;
|
|
39
84
|
}
|
|
40
85
|
/**
|
|
41
86
|
* Interface defining voice configuration settings for text-to-speech generation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseAudio.d.ts","sourceRoot":"","sources":["../../src/generic/baseAudio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGpD;;;;GAIG;AACH,8BAAsB,kBAAmB,SAAQ,SAAS;aACtC,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;aAC/D,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;aAC/D,SAAS,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;aACjC,SAAS,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;aAClC,6BAA6B,IAAI,OAAO,CAAC,wBAAwB,EAAE,CAAC;aACpE,mBAAmB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAC3D;AAED;;GAEG;AACH,qBAAa,YAAY;IACrB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,kBAAmB,SAAQ,UAAU;IAC9C
|
|
1
|
+
{"version":3,"file":"baseAudio.d.ts","sourceRoot":"","sources":["../../src/generic/baseAudio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGpD;;;;GAIG;AACH,8BAAsB,kBAAmB,SAAQ,SAAS;aACtC,YAAY,CAAC,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BAAmB,SAAQ,SAAS;CAOzD;AAED;;GAEG;AACH,MAAM,OAAO,YAAY;CAexB;AAED,MAAM,OAAO,kBAAmB,SAAQ,UAAU;
|
|
1
|
+
{"version":3,"file":"baseAudio.js","sourceRoot":"","sources":["../../src/generic/baseAudio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGpD;;;;GAIG;AACH,MAAM,OAAgB,kBAAmB,SAAQ,SAAS;CAOzD;AAED;;GAEG;AACH,MAAM,OAAO,YAAY;CAexB;AAED,MAAM,OAAO,kBAAmB,SAAQ,UAAU;CAmCjD;AAyED;;GAEG;AACH,MAAM,OAAO,SAAS;CAwCrB;AAED;;GAEG;AACH,MAAM,OAAO,WAAW;CAMvB;AAED,MAAM,OAAO,UAAU;CAmCtB;AAED,MAAM,OAAO,aAAa;CASzB;AAED;;GAEG;AACH,MAAM,OAAO,wBAAwB;CAOpC"}
|
|
@@ -167,6 +167,15 @@ export declare abstract class BaseRealtimeModel extends BaseModel {
|
|
|
167
167
|
* transport settings for self-hosted/proxied drivers. NON-OpenAI-protocol drivers (Gemini,
|
|
168
168
|
* ElevenLabs, AssemblyAI, Inworld) MUST scrub these before forwarding an open config bag to their
|
|
169
169
|
* SDK/wire — a co-agent config carrying them must be safe on every provider.
|
|
170
|
+
*
|
|
171
|
+
* **Registering a key here is what makes it safe; forgetting to is a wire leak.** A co-agent
|
|
172
|
+
* config is authored WITHOUT knowing which vendor will run, so an agnostic key is filed onto
|
|
173
|
+
* whichever driver resolves — including every driver that does not consume it. Unregistered, it
|
|
174
|
+
* survives each driver's residual-bag spread and reaches the provider as an unknown field; on the
|
|
175
|
+
* OpenAI-protocol endpoints a malformed session object is rejected WHOLESALE, taking the prompt
|
|
176
|
+
* and tools with it. So any key added to the neutral vocabulary belongs in this list at the same
|
|
177
|
+
* time, and the OpenAI family's own scrub in `ExtractRealtimeFeatures` must delete it too — that
|
|
178
|
+
* function enumerates its deletes explicitly and does NOT read this list.
|
|
170
179
|
*/
|
|
171
180
|
export declare const REALTIME_SHARED_CONFIG_KEYS: readonly string[];
|
|
172
181
|
/** A selectable provider-native voice — `ID` is sent to the provider, `Name` is the human label. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseRealtime.d.ts","sourceRoot":"","sources":["../../src/generic/baseRealtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,MAAM,MAAM,SAAS,GACf,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEnC;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAMrD;AAED,8BAAsB,iBAAkB,SAAQ,SAAS;IACrD;;;;;;;;;;OAUG;aACa,YAAY,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAEtF;;;;;;;;;;;OAWG;IACH,IAAW,oBAAoB,IAAI,OAAO,CAEzC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACU,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAItG;;;;;;;;;;;;;OAaG;IACH,IAAW,aAAa,IAAI,OAAO,CAElC;IAED;;;;;;;;;;OAUG;IACH,IAAW,eAAe,IAAI,mBAAmB,EAAE,CAElD;CACJ;AAED
|
|
1
|
+
{"version":3,"file":"baseRealtime.d.ts","sourceRoot":"","sources":["../../src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,MAAM,WAAW,sBAAsB;IACnC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,gBAAgB,EAAE,UAAU,CAAC;CAChC"}
|
|
@@ -155,6 +155,15 @@ export class BaseRealtimeModel extends BaseModel {
|
|
|
155
155
|
* transport settings for self-hosted/proxied drivers. NON-OpenAI-protocol drivers (Gemini,
|
|
156
156
|
* ElevenLabs, AssemblyAI, Inworld) MUST scrub these before forwarding an open config bag to their
|
|
157
157
|
* SDK/wire — a co-agent config carrying them must be safe on every provider.
|
|
158
|
+
*
|
|
159
|
+
* **Registering a key here is what makes it safe; forgetting to is a wire leak.** A co-agent
|
|
160
|
+
* config is authored WITHOUT knowing which vendor will run, so an agnostic key is filed onto
|
|
161
|
+
* whichever driver resolves — including every driver that does not consume it. Unregistered, it
|
|
162
|
+
* survives each driver's residual-bag spread and reaches the provider as an unknown field; on the
|
|
163
|
+
* OpenAI-protocol endpoints a malformed session object is rejected WHOLESALE, taking the prompt
|
|
164
|
+
* and tools with it. So any key added to the neutral vocabulary belongs in this list at the same
|
|
165
|
+
* time, and the OpenAI family's own scrub in `ExtractRealtimeFeatures` must delete it too — that
|
|
166
|
+
* function enumerates its deletes explicitly and does NOT read this list.
|
|
158
167
|
*/
|
|
159
168
|
export const REALTIME_SHARED_CONFIG_KEYS = [
|
|
160
169
|
'effortLevel',
|
|
@@ -163,7 +172,9 @@ export const REALTIME_SHARED_CONFIG_KEYS = [
|
|
|
163
172
|
'mcpTools',
|
|
164
173
|
'inputTranscriptionModel',
|
|
165
174
|
'voice',
|
|
175
|
+
'firstMessage',
|
|
166
176
|
'disableAutoResponse',
|
|
177
|
+
'turnDetection',
|
|
167
178
|
'endpoint',
|
|
168
179
|
'sampleRate',
|
|
169
180
|
'proxyBaseUrl',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseRealtime.js","sourceRoot":"","sources":["../../src/generic/baseRealtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAoBxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe;IAC3C,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACvD,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC;QAC3C,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;AACL,CAAC;AAED,MAAM,OAAgB,iBAAkB,SAAQ,SAAS;IAcrD;;;;;;;;;;;OAWG;IACH,IAAW,oBAAoB;QAC3B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACI,KAAK,CAAC,mBAAmB,CAAC,OAA8B;QAC3D,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,mDAAmD,CAAC,CAAC;IACjG,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAW,aAAa;QACpB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAW,eAAe;QACtB,OAAO,EAAE,CAAC;IACd,CAAC;CACJ;AAED
|
|
1
|
+
{"version":3,"file":"baseRealtime.js","sourceRoot":"","sources":["../../src/generic/baseRealtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAoBxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe;IAC3C,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACvD,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC;QAC3C,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;AACL,CAAC;AAED,MAAM,OAAgB,iBAAkB,SAAQ,SAAS;IAcrD;;;;;;;;;;;OAWG;IACH,IAAW,oBAAoB;QAC3B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACI,KAAK,CAAC,mBAAmB,CAAC,OAA8B;QAC3D,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,mDAAmD,CAAC,CAAC;IACjG,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAW,aAAa;QACpB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAW,eAAe;QACtB,OAAO,EAAE,CAAC;IACd,CAAC;CACJ;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAsB;IAC1D,aAAa;IACb,iBAAiB;IACjB,mBAAmB;IACnB,UAAU;IACV,yBAAyB;IACzB,OAAO;IACP,cAAc;IACd,qBAAqB;IACrB,eAAe;IACf,UAAU;IACV,YAAY;IACZ,cAAc;CACR,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical `ModelConfiguration` shape + the pure cascade resolver.
|
|
3
|
+
*
|
|
4
|
+
* `ModelConfiguration` is a JSONType `nvarchar(max)` column that exists at THREE levels of the
|
|
5
|
+
* model catalog, forming an inherit-with-override cascade (the structured generalization of the
|
|
6
|
+
* scalar `SupportsPrefill` / `PrefillFallbackText` cascade those same three entities already carry):
|
|
7
|
+
*
|
|
8
|
+
* ```
|
|
9
|
+
* MJ: AI Model Types . ModelConfiguration (type-wide default — e.g. every Realtime model)
|
|
10
|
+
* < MJ: AI Models . ModelConfiguration (per-model)
|
|
11
|
+
* < MJ: AI Model Vendors . ModelConfiguration (per model-on-this-provider — the winner)
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* **Lockstep contract**: this interface is the package-side mirror of
|
|
15
|
+
* `metadata/entities/JSONType-interfaces/IAIModelConfiguration.ts`, which is pushed into
|
|
16
|
+
* `EntityField.JSONTypeDefinition` and drives the CodeGen-generated `ModelConfigurationObject`
|
|
17
|
+
* accessors on the three entities. Keep the two in step when adding a section or property —
|
|
18
|
+
* the same pact `IAgentSettings` follows with `@memberjunction/ai-core-plus`.
|
|
19
|
+
*
|
|
20
|
+
* **Boundary rule** (also documented on the metadata interface): anything the engine filters,
|
|
21
|
+
* sorts, or joins on stays a COLUMN (`PowerRank`, `IsActive`, `Priority`, `Status` — SQL cannot
|
|
22
|
+
* cheaply predicate into this bag); anything a driver consumes at session/call time belongs HERE.
|
|
23
|
+
* New capability knobs go in this bag — do not add a new capability column per knob.
|
|
24
|
+
*/
|
|
25
|
+
import { JSONObject } from './baseRealtime.js';
|
|
26
|
+
/**
|
|
27
|
+
* MJ-normalized turn-detection mode vocabulary — provider-neutral by design so a shared model
|
|
28
|
+
* catalog is safe on every provider:
|
|
29
|
+
*
|
|
30
|
+
* - `'default'` — let the provider profile decide (byte-for-byte today's behavior).
|
|
31
|
+
* - `'serverVad'` — classic silence-based server VAD.
|
|
32
|
+
* - `'semanticVad'` — the provider's semantic end-of-utterance detection (OpenAI `semantic_vad`).
|
|
33
|
+
* - `'native'` — deliberately open-ended: "this model's smartest documented turn/duplex mode,
|
|
34
|
+
* whatever the profile maps it to." The forward slot for full-duplex reasoning voice models
|
|
35
|
+
* (e.g. Grok Voice Think Fast) — a profile that maps `'native'` ships the mapping once and the
|
|
36
|
+
* catalog opts models in via metadata, no driver release per model.
|
|
37
|
+
*
|
|
38
|
+
* A profile that does NOT support a requested mode logs and falls back to its default — a wrong
|
|
39
|
+
* inherited value degrades safely, it never rejects a session.
|
|
40
|
+
*/
|
|
41
|
+
export type RealtimeTurnDetectionMode = 'default' | 'serverVad' | 'semanticVad' | 'native';
|
|
42
|
+
/**
|
|
43
|
+
* Normalized turn-detection settings. Every field optional; absent fields contribute nothing.
|
|
44
|
+
* Profiles translate to their native wire fields and ignore what they have no mapping for.
|
|
45
|
+
*/
|
|
46
|
+
export interface RealtimeTurnDetectionSettings {
|
|
47
|
+
/** The normalized mode; absent = `'default'`. */
|
|
48
|
+
Mode?: RealtimeTurnDetectionMode;
|
|
49
|
+
/** Semantic-VAD aggressiveness (OpenAI `eagerness`); ignored by profiles without a mapping. */
|
|
50
|
+
Eagerness?: 'low' | 'auto' | 'high';
|
|
51
|
+
/** Server-VAD activation threshold (0–1); ignored by profiles without a mapping. */
|
|
52
|
+
Threshold?: number;
|
|
53
|
+
/** Server-VAD trailing-silence duration in ms; ignored by profiles without a mapping. */
|
|
54
|
+
SilenceDurationMs?: number;
|
|
55
|
+
}
|
|
56
|
+
/** The `Realtime` section of {@link AIModelConfiguration} — knobs the realtime drivers consume. */
|
|
57
|
+
export interface RealtimeModelConfigurationSection {
|
|
58
|
+
/**
|
|
59
|
+
* Catalog-level turn-detection default for this model. Folded into the session Config bag as
|
|
60
|
+
* the `turnDetection` key BELOW the agent/app config cascade (`realtime.session.turnDetection`)
|
|
61
|
+
* and the runtime override — the catalog supplies the default, agents/apps/callers refine it.
|
|
62
|
+
*/
|
|
63
|
+
TurnDetection?: RealtimeTurnDetectionSettings;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The `LLM` section of {@link AIModelConfiguration}. Reserved — no consumers yet. Candidate
|
|
67
|
+
* contents: per-model effort-level defaults, response-format quirks, tool-calling behavior flags.
|
|
68
|
+
* Existing capability COLUMNS (`SupportsEffortLevel`, `SupportsStreaming`, …) are NOT migrating
|
|
69
|
+
* here — new knobs only (see the boundary rule in the module docstring).
|
|
70
|
+
*/
|
|
71
|
+
export interface LLMModelConfigurationSection {
|
|
72
|
+
/** Open extension point until the first typed knob lands. */
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The per-modality model-configuration bag stored (as JSON) in the `ModelConfiguration` column of
|
|
77
|
+
* `MJ: AI Model Types`, `MJ: AI Models`, and `MJ: AI Model Vendors`. Sections are optional and
|
|
78
|
+
* per-modality so one catalog row can configure everything its model does.
|
|
79
|
+
*/
|
|
80
|
+
export interface AIModelConfiguration {
|
|
81
|
+
/** Text-generation knobs. Reserved. */
|
|
82
|
+
LLM?: LLMModelConfigurationSection;
|
|
83
|
+
/** Realtime (speech-to-speech) knobs — the first live section. */
|
|
84
|
+
Realtime?: RealtimeModelConfigurationSection;
|
|
85
|
+
/** Vision knobs. Reserved. */
|
|
86
|
+
Vision?: JSONObject;
|
|
87
|
+
/** Audio (TTS/STT) knobs. Reserved. */
|
|
88
|
+
Audio?: JSONObject;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* TOLERANTLY parses one `ModelConfiguration` column value. Returns `null` — never throws — for
|
|
92
|
+
* absent, blank, malformed, or non-object payloads, so a bad catalog row contributes nothing to
|
|
93
|
+
* the cascade instead of failing a session (mirrors `ParseRealtimeTypeConfiguration`).
|
|
94
|
+
*
|
|
95
|
+
* @param json The raw column value, or `null`/`undefined`.
|
|
96
|
+
* @returns The parsed configuration, or `null` when the layer contributes nothing.
|
|
97
|
+
*/
|
|
98
|
+
export declare function ParseModelConfiguration(json: string | null | undefined): AIModelConfiguration | null;
|
|
99
|
+
/**
|
|
100
|
+
* Resolves the EFFECTIVE model configuration by deep-merging the catalog layers, base first —
|
|
101
|
+
* type default < model < model-vendor. Merge semantics are identical to the realtime config
|
|
102
|
+
* cascade (`DeepMergeConfigs` in `@memberjunction/ai-agents` — duplicated here because package
|
|
103
|
+
* layering runs the other way):
|
|
104
|
+
*
|
|
105
|
+
* - plain object vs plain object → recursive per-key merge (a vendor row overriding ONE
|
|
106
|
+
* `Realtime.TurnDetection` knob does not wipe the model's other sections);
|
|
107
|
+
* - anything else (arrays, strings, numbers, booleans, `null`) → the later value REPLACES;
|
|
108
|
+
* - `null`/`undefined` LAYERS are skipped entirely; inputs are never mutated.
|
|
109
|
+
*
|
|
110
|
+
* @param layers The catalog layers, base first (type, model, vendor).
|
|
111
|
+
* @returns The merged configuration, or `null` when every layer is absent/empty.
|
|
112
|
+
*/
|
|
113
|
+
export declare function ResolveEffectiveModelConfiguration(...layers: Array<AIModelConfiguration | null | undefined>): AIModelConfiguration | null;
|
|
114
|
+
//# sourceMappingURL=modelConfiguration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelConfiguration.d.ts","sourceRoot":"","sources":["../../src/generic/modelConfiguration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,EAAE,UAAU,EAAa,MAAM,gBAAgB,CAAC;AAEvD;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,yBAAyB,GAAG,SAAS,GAAG,WAAW,GAAG,aAAa,GAAG,QAAQ,CAAC;AAE3F;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC1C,iDAAiD;IACjD,IAAI,CAAC,EAAE,yBAAyB,CAAC;IACjC,+FAA+F;IAC/F,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IACpC,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yFAAyF;IACzF,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,mGAAmG;AACnG,MAAM,WAAW,iCAAiC;IAC9C;;;;OAIG;IACH,aAAa,CAAC,EAAE,6BAA6B,CAAC;CACjD;AAED;;;;;GAKG;AACH,MAAM,WAAW,4BAA4B;IACzC,6DAA6D;IAC7D,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACjC,uCAAuC;IACvC,GAAG,CAAC,EAAE,4BAA4B,CAAC;IACnC,kEAAkE;IAClE,QAAQ,CAAC,EAAE,iCAAiC,CAAC;IAC7C,8BAA8B;IAC9B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,uCAAuC;IACvC,KAAK,CAAC,EAAE,UAAU,CAAC;CACtB;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,oBAAoB,GAAG,IAAI,CAUpG;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kCAAkC,CAC9C,GAAG,MAAM,EAAE,KAAK,CAAC,oBAAoB,GAAG,IAAI,GAAG,SAAS,CAAC,GAC1D,oBAAoB,GAAG,IAAI,CAS7B"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical `ModelConfiguration` shape + the pure cascade resolver.
|
|
3
|
+
*
|
|
4
|
+
* `ModelConfiguration` is a JSONType `nvarchar(max)` column that exists at THREE levels of the
|
|
5
|
+
* model catalog, forming an inherit-with-override cascade (the structured generalization of the
|
|
6
|
+
* scalar `SupportsPrefill` / `PrefillFallbackText` cascade those same three entities already carry):
|
|
7
|
+
*
|
|
8
|
+
* ```
|
|
9
|
+
* MJ: AI Model Types . ModelConfiguration (type-wide default — e.g. every Realtime model)
|
|
10
|
+
* < MJ: AI Models . ModelConfiguration (per-model)
|
|
11
|
+
* < MJ: AI Model Vendors . ModelConfiguration (per model-on-this-provider — the winner)
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* **Lockstep contract**: this interface is the package-side mirror of
|
|
15
|
+
* `metadata/entities/JSONType-interfaces/IAIModelConfiguration.ts`, which is pushed into
|
|
16
|
+
* `EntityField.JSONTypeDefinition` and drives the CodeGen-generated `ModelConfigurationObject`
|
|
17
|
+
* accessors on the three entities. Keep the two in step when adding a section or property —
|
|
18
|
+
* the same pact `IAgentSettings` follows with `@memberjunction/ai-core-plus`.
|
|
19
|
+
*
|
|
20
|
+
* **Boundary rule** (also documented on the metadata interface): anything the engine filters,
|
|
21
|
+
* sorts, or joins on stays a COLUMN (`PowerRank`, `IsActive`, `Priority`, `Status` — SQL cannot
|
|
22
|
+
* cheaply predicate into this bag); anything a driver consumes at session/call time belongs HERE.
|
|
23
|
+
* New capability knobs go in this bag — do not add a new capability column per knob.
|
|
24
|
+
*/
|
|
25
|
+
import { IsPlainObject } from '@memberjunction/global';
|
|
26
|
+
/**
|
|
27
|
+
* TOLERANTLY parses one `ModelConfiguration` column value. Returns `null` — never throws — for
|
|
28
|
+
* absent, blank, malformed, or non-object payloads, so a bad catalog row contributes nothing to
|
|
29
|
+
* the cascade instead of failing a session (mirrors `ParseRealtimeTypeConfiguration`).
|
|
30
|
+
*
|
|
31
|
+
* @param json The raw column value, or `null`/`undefined`.
|
|
32
|
+
* @returns The parsed configuration, or `null` when the layer contributes nothing.
|
|
33
|
+
*/
|
|
34
|
+
export function ParseModelConfiguration(json) {
|
|
35
|
+
if (typeof json !== 'string' || json.trim().length === 0) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const parsed = JSON.parse(json);
|
|
40
|
+
return IsPlainObject(parsed) ? parsed : null;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolves the EFFECTIVE model configuration by deep-merging the catalog layers, base first —
|
|
48
|
+
* type default < model < model-vendor. Merge semantics are identical to the realtime config
|
|
49
|
+
* cascade (`DeepMergeConfigs` in `@memberjunction/ai-agents` — duplicated here because package
|
|
50
|
+
* layering runs the other way):
|
|
51
|
+
*
|
|
52
|
+
* - plain object vs plain object → recursive per-key merge (a vendor row overriding ONE
|
|
53
|
+
* `Realtime.TurnDetection` knob does not wipe the model's other sections);
|
|
54
|
+
* - anything else (arrays, strings, numbers, booleans, `null`) → the later value REPLACES;
|
|
55
|
+
* - `null`/`undefined` LAYERS are skipped entirely; inputs are never mutated.
|
|
56
|
+
*
|
|
57
|
+
* @param layers The catalog layers, base first (type, model, vendor).
|
|
58
|
+
* @returns The merged configuration, or `null` when every layer is absent/empty.
|
|
59
|
+
*/
|
|
60
|
+
export function ResolveEffectiveModelConfiguration(...layers) {
|
|
61
|
+
const result = {};
|
|
62
|
+
for (const layer of layers) {
|
|
63
|
+
if (!IsPlainObject(layer)) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
mergeInto(result, layer);
|
|
67
|
+
}
|
|
68
|
+
return Object.keys(result).length > 0 ? result : null;
|
|
69
|
+
}
|
|
70
|
+
/** Recursive worker for {@link ResolveEffectiveModelConfiguration} — merges `source` into `target`. */
|
|
71
|
+
function mergeInto(target, source) {
|
|
72
|
+
for (const key of Object.keys(source)) {
|
|
73
|
+
const incoming = source[key];
|
|
74
|
+
if (incoming === undefined) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const existing = target[key];
|
|
78
|
+
if (IsPlainObject(existing) && IsPlainObject(incoming)) {
|
|
79
|
+
mergeInto(existing, incoming);
|
|
80
|
+
}
|
|
81
|
+
else if (IsPlainObject(incoming)) {
|
|
82
|
+
const copy = {};
|
|
83
|
+
mergeInto(copy, incoming);
|
|
84
|
+
target[key] = copy;
|
|
85
|
+
}
|
|
86
|
+
else if (Array.isArray(incoming)) {
|
|
87
|
+
target[key] = incoming.slice();
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
target[key] = incoming;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=modelConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelConfiguration.js","sourceRoot":"","sources":["../../src/generic/modelConfiguration.ts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AAS;QACb,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,aAAa,CAAC,QAAQ,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrD,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAClC,CAAC;aAAM,IAAI,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,GAAe,EAAE,CAAC;YAC5B,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAC1B,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QACvB,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjC,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAiB,CAAC;QAClD,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;QAC3B,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Realtime `response.done` usage extraction — the one place that knows WHERE each OpenAI-protocol
|
|
3
|
+
* provider puts its token counts.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately dependency-free and in its own module (the same reasoning as
|
|
6
|
+
* `transcriptContinuation.ts`): both the server-side driver and the browser realtime client need
|
|
7
|
+
* it, and their unit tests mock `@memberjunction/ai` wholesale. Keeping this free of imports lets
|
|
8
|
+
* those tests pull in the REAL implementation instead of restating the parsing rule in a stub —
|
|
9
|
+
* which is precisely the failure mode that let this bug ship in the first place.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The raw usage payload carried by an OpenAI-protocol `response.done` frame. Per-response DELTAS
|
|
13
|
+
* on every provider that sends it. Indexed so per-modality detail blocks survive untyped.
|
|
14
|
+
*/
|
|
15
|
+
export interface RealtimeResponseDoneUsage {
|
|
16
|
+
input_tokens?: number;
|
|
17
|
+
output_tokens?: number;
|
|
18
|
+
[detail: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A `response.done` frame, declaring BOTH slots the OpenAI-compatible providers use for usage.
|
|
22
|
+
* See {@link ResolveResponseDoneUsage}.
|
|
23
|
+
*/
|
|
24
|
+
export interface RealtimeResponseDoneFrame {
|
|
25
|
+
/**
|
|
26
|
+
* OpenAI populates usage here. xAI sends this present but EMPTY.
|
|
27
|
+
*
|
|
28
|
+
* Typed as `unknown` deliberately: this is untrusted wire data, and each provider SDK declares
|
|
29
|
+
* its own concrete usage interface (without the index signature {@link RealtimeResponseDoneUsage}
|
|
30
|
+
* carries). Accepting `unknown` lets every SDK's frame type be passed in directly — no cast at
|
|
31
|
+
* the call site — while {@link ResolveResponseDoneUsage} does the narrowing centrally.
|
|
32
|
+
*/
|
|
33
|
+
response?: {
|
|
34
|
+
usage?: unknown;
|
|
35
|
+
} | null;
|
|
36
|
+
/** xAI populates usage here, as a sibling of `response`. OpenAI omits it. */
|
|
37
|
+
usage?: unknown;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Picks the usage payload out of an OpenAI-protocol `response.done` frame, tolerating the two
|
|
41
|
+
* layouts the compatible providers actually send on the wire:
|
|
42
|
+
*
|
|
43
|
+
* - **OpenAI** (`gpt-realtime`): populated `response.usage`; no top-level `usage`.
|
|
44
|
+
* - **xAI** (Grok Voice): populated TOP-LEVEL `usage`; `response.usage` present but `{}`.
|
|
45
|
+
*
|
|
46
|
+
* Nested wins whenever it carries real numbers, so OpenAI's behavior is unchanged and xAI is
|
|
47
|
+
* picked up as a fallback. If xAI later populates the nested slot, this keeps working untouched —
|
|
48
|
+
* hence prefer-and-fall-back rather than switching outright.
|
|
49
|
+
*
|
|
50
|
+
* **The empty-object check is the entire point.** Callers used to read only `response.usage` and
|
|
51
|
+
* guard with `if (!usage) return`. For xAI that value is `{}` — which is TRUTHY — so the guard
|
|
52
|
+
* never fired: a usage event was emitted with `input_tokens`/`output_tokens` `undefined`, those
|
|
53
|
+
* clamped to `0` downstream, an all-zero delta was dropped, and the session's tokens were never
|
|
54
|
+
* recorded at all (NULL on `AIPromptRun`) instead of failing loudly. Shared here so the
|
|
55
|
+
* client-direct and server-bridged paths cannot drift apart on it again.
|
|
56
|
+
*
|
|
57
|
+
* @param event The `response.done` frame.
|
|
58
|
+
* @returns The payload carrying token counts, or `undefined` when neither slot has any.
|
|
59
|
+
*/
|
|
60
|
+
export declare function ResolveResponseDoneUsage(event: RealtimeResponseDoneFrame): RealtimeResponseDoneUsage | undefined;
|
|
61
|
+
//# sourceMappingURL=realtimeUsage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtimeUsage.d.ts","sourceRoot":"","sources":["../../src/generic/realtimeUsage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACtC;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACtC,6EAA6E;IAC7E,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAWD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,yBAAyB,GAAG,yBAAyB,GAAG,SAAS,CAKhH"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Realtime `response.done` usage extraction — the one place that knows WHERE each OpenAI-protocol
|
|
3
|
+
* provider puts its token counts.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately dependency-free and in its own module (the same reasoning as
|
|
6
|
+
* `transcriptContinuation.ts`): both the server-side driver and the browser realtime client need
|
|
7
|
+
* it, and their unit tests mock `@memberjunction/ai` wholesale. Keeping this free of imports lets
|
|
8
|
+
* those tests pull in the REAL implementation instead of restating the parsing rule in a stub —
|
|
9
|
+
* which is precisely the failure mode that let this bug ship in the first place.
|
|
10
|
+
*/
|
|
11
|
+
/** True when a usage payload actually carries token counts (not absent, not an empty `{}`). */
|
|
12
|
+
function usageHasTokenCounts(usage) {
|
|
13
|
+
if (usage === null || typeof usage !== 'object') {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const candidate = usage;
|
|
17
|
+
return typeof candidate.input_tokens === 'number' || typeof candidate.output_tokens === 'number';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Picks the usage payload out of an OpenAI-protocol `response.done` frame, tolerating the two
|
|
21
|
+
* layouts the compatible providers actually send on the wire:
|
|
22
|
+
*
|
|
23
|
+
* - **OpenAI** (`gpt-realtime`): populated `response.usage`; no top-level `usage`.
|
|
24
|
+
* - **xAI** (Grok Voice): populated TOP-LEVEL `usage`; `response.usage` present but `{}`.
|
|
25
|
+
*
|
|
26
|
+
* Nested wins whenever it carries real numbers, so OpenAI's behavior is unchanged and xAI is
|
|
27
|
+
* picked up as a fallback. If xAI later populates the nested slot, this keeps working untouched —
|
|
28
|
+
* hence prefer-and-fall-back rather than switching outright.
|
|
29
|
+
*
|
|
30
|
+
* **The empty-object check is the entire point.** Callers used to read only `response.usage` and
|
|
31
|
+
* guard with `if (!usage) return`. For xAI that value is `{}` — which is TRUTHY — so the guard
|
|
32
|
+
* never fired: a usage event was emitted with `input_tokens`/`output_tokens` `undefined`, those
|
|
33
|
+
* clamped to `0` downstream, an all-zero delta was dropped, and the session's tokens were never
|
|
34
|
+
* recorded at all (NULL on `AIPromptRun`) instead of failing loudly. Shared here so the
|
|
35
|
+
* client-direct and server-bridged paths cannot drift apart on it again.
|
|
36
|
+
*
|
|
37
|
+
* @param event The `response.done` frame.
|
|
38
|
+
* @returns The payload carrying token counts, or `undefined` when neither slot has any.
|
|
39
|
+
*/
|
|
40
|
+
export function ResolveResponseDoneUsage(event) {
|
|
41
|
+
if (usageHasTokenCounts(event.response?.usage)) {
|
|
42
|
+
return event.response?.usage;
|
|
43
|
+
}
|
|
44
|
+
return usageHasTokenCounts(event.usage) ? event.usage : undefined;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=realtimeUsage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtimeUsage.js","sourceRoot":"","sources":["../../src/generic/realtimeUsage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA8BH,+FAA+F;AAC/F,SAAS,mBAAmB,CAAC,KAAc;IACvC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,SAAS,GAAG,KAA4D,CAAC;IAC/E,OAAO,OAAO,SAAS,CAAC,YAAY,KAAK,QAAQ,IAAI,OAAO,SAAS,CAAC,aAAa,KAAK,QAAQ,CAAC;AACrG,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAgC;IACrE,IAAI,mBAAmB,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;QAC7C,OAAO,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC;IACjC,CAAC;IACD,OAAO,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export * from './generic/baseEmbeddings.js';
|
|
|
12
12
|
export * from './generic/baseAudio.js';
|
|
13
13
|
export * from './generic/baseVideo.js';
|
|
14
14
|
export * from './generic/baseRealtime.js';
|
|
15
|
+
export * from './generic/realtimeUsage.js';
|
|
16
|
+
export * from './generic/modelConfiguration.js';
|
|
15
17
|
export * from './generic/transcriptContinuation.js';
|
|
16
18
|
export * from './generic/realtimeProxyRegistry.js';
|
|
17
19
|
export * from './generic/baseRealtimeChannelServer.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,8 @@ export * from './generic/baseEmbeddings.js';
|
|
|
12
12
|
export * from './generic/baseAudio.js';
|
|
13
13
|
export * from './generic/baseVideo.js';
|
|
14
14
|
export * from './generic/baseRealtime.js';
|
|
15
|
+
export * from './generic/realtimeUsage.js';
|
|
16
|
+
export * from './generic/modelConfiguration.js';
|
|
15
17
|
export * from './generic/transcriptContinuation.js';
|
|
16
18
|
export * from './generic/realtimeProxyRegistry.js';
|
|
17
19
|
export * from './generic/baseRealtimeChannelServer.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ai",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.1.0-edge.
|
|
4
|
+
"version": "6.1.0-edge.3",
|
|
5
5
|
"description": "MemberJunction: AI - core components for abstracting LLMs and other AI model types that are usable anywhere without ANY other MJ dependencies past @memberjunction/global which itself has zero additional dependencies.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"/dist"
|
|
10
10
|
],
|
|
11
11
|
"author": "MemberJunction.com",
|
|
12
|
-
"license": "
|
|
12
|
+
"license": "BUSL-1.1",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@memberjunction/global": "6.1.0-edge.
|
|
14
|
+
"@memberjunction/global": "6.1.0-edge.3",
|
|
15
15
|
"dotenv": "^17.2.4",
|
|
16
16
|
"rxjs": "^7.8.2"
|
|
17
17
|
},
|