openai 7.13.0 → 7.14.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 +15 -0
- package/client.d.mts +3 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +3 -0
- package/client.d.ts.map +1 -1
- package/client.js +3 -0
- package/client.js.map +1 -1
- package/client.mjs +3 -0
- package/client.mjs.map +1 -1
- package/helpers/live.d.mts +2 -0
- package/helpers/live.d.mts.map +1 -0
- package/helpers/live.d.ts +2 -0
- package/helpers/live.d.ts.map +1 -0
- package/helpers/live.js +6 -0
- package/helpers/live.js.map +1 -0
- package/helpers/live.mjs +2 -0
- package/helpers/live.mjs.map +1 -0
- package/lib/live/transcript-grouper.d.mts +96 -0
- package/lib/live/transcript-grouper.d.mts.map +1 -0
- package/lib/live/transcript-grouper.d.ts +96 -0
- package/lib/live/transcript-grouper.d.ts.map +1 -0
- package/lib/live/transcript-grouper.js +223 -0
- package/lib/live/transcript-grouper.js.map +1 -0
- package/lib/live/transcript-grouper.mjs +219 -0
- package/lib/live/transcript-grouper.mjs.map +1 -0
- package/lib/live/transcript-grouping.d.mts +49 -0
- package/lib/live/transcript-grouping.d.mts.map +1 -0
- package/lib/live/transcript-grouping.d.ts +49 -0
- package/lib/live/transcript-grouping.d.ts.map +1 -0
- package/lib/live/transcript-grouping.js +287 -0
- package/lib/live/transcript-grouping.js.map +1 -0
- package/lib/live/transcript-grouping.mjs +283 -0
- package/lib/live/transcript-grouping.mjs.map +1 -0
- package/lib/live/webrtc.d.mts +13 -0
- package/lib/live/webrtc.d.mts.map +1 -0
- package/lib/live/webrtc.d.ts +13 -0
- package/lib/live/webrtc.d.ts.map +1 -0
- package/lib/live/webrtc.js +16 -0
- package/lib/live/webrtc.js.map +1 -0
- package/lib/live/webrtc.mjs +10 -0
- package/lib/live/webrtc.mjs.map +1 -0
- package/lib/realtime/webrtc.d.mts +13 -0
- package/lib/realtime/webrtc.d.mts.map +1 -0
- package/lib/realtime/webrtc.d.ts +13 -0
- package/lib/realtime/webrtc.d.ts.map +1 -0
- package/lib/realtime/webrtc.js +16 -0
- package/lib/realtime/webrtc.js.map +1 -0
- package/lib/realtime/webrtc.mjs +10 -0
- package/lib/realtime/webrtc.mjs.map +1 -0
- package/lib/webrtc/connection.d.mts +40 -0
- package/lib/webrtc/connection.d.mts.map +1 -0
- package/lib/webrtc/connection.d.ts +40 -0
- package/lib/webrtc/connection.d.ts.map +1 -0
- package/lib/webrtc/connection.js +228 -0
- package/lib/webrtc/connection.js.map +1 -0
- package/lib/webrtc/connection.mjs +224 -0
- package/lib/webrtc/connection.mjs.map +1 -0
- package/lib/webrtc/data-channel.d.mts +32 -0
- package/lib/webrtc/data-channel.d.mts.map +1 -0
- package/lib/webrtc/data-channel.d.ts +32 -0
- package/lib/webrtc/data-channel.d.ts.map +1 -0
- package/lib/webrtc/data-channel.js +125 -0
- package/lib/webrtc/data-channel.js.map +1 -0
- package/lib/webrtc/data-channel.mjs +121 -0
- package/lib/webrtc/data-channel.mjs.map +1 -0
- package/lib/webrtc/errors.d.mts +19 -0
- package/lib/webrtc/errors.d.mts.map +1 -0
- package/lib/webrtc/errors.d.ts +19 -0
- package/lib/webrtc/errors.d.ts.map +1 -0
- package/lib/webrtc/errors.js +18 -0
- package/lib/webrtc/errors.js.map +1 -0
- package/lib/webrtc/errors.mjs +14 -0
- package/lib/webrtc/errors.mjs.map +1 -0
- package/lib/webrtc/subscriptions.d.mts +13 -0
- package/lib/webrtc/subscriptions.d.mts.map +1 -0
- package/lib/webrtc/subscriptions.d.ts +13 -0
- package/lib/webrtc/subscriptions.d.ts.map +1 -0
- package/lib/webrtc/subscriptions.js +62 -0
- package/lib/webrtc/subscriptions.js.map +1 -0
- package/lib/webrtc/subscriptions.mjs +58 -0
- package/lib/webrtc/subscriptions.mjs.map +1 -0
- package/lib/webrtc/types.d.mts +99 -0
- package/lib/webrtc/types.d.mts.map +1 -0
- package/lib/webrtc/types.d.ts +99 -0
- package/lib/webrtc/types.d.ts.map +1 -0
- package/lib/webrtc/types.js +3 -0
- package/lib/webrtc/types.js.map +1 -0
- package/lib/webrtc/types.mjs +2 -0
- package/lib/webrtc/types.mjs.map +1 -0
- package/live/webrtc.d.mts +3 -0
- package/live/webrtc.d.mts.map +1 -0
- package/live/webrtc.d.ts +3 -0
- package/live/webrtc.d.ts.map +1 -0
- package/live/webrtc.js +8 -0
- package/live/webrtc.js.map +1 -0
- package/live/webrtc.mjs +2 -0
- package/live/webrtc.mjs.map +1 -0
- package/package.json +11 -1
- package/realtime/webrtc.d.mts +3 -0
- package/realtime/webrtc.d.mts.map +1 -0
- package/realtime/webrtc.d.ts +3 -0
- package/realtime/webrtc.d.ts.map +1 -0
- package/realtime/webrtc.js +8 -0
- package/realtime/webrtc.js.map +1 -0
- package/realtime/webrtc.mjs +2 -0
- package/realtime/webrtc.mjs.map +1 -0
- package/resources/beta/responses/responses.d.mts +48 -0
- package/resources/beta/responses/responses.d.mts.map +1 -1
- package/resources/beta/responses/responses.d.ts +48 -0
- package/resources/beta/responses/responses.d.ts.map +1 -1
- package/resources/beta/responses/responses.js.map +1 -1
- package/resources/beta/responses/responses.mjs.map +1 -1
- package/resources/conversations/items.d.mts +16 -0
- package/resources/conversations/items.d.mts.map +1 -1
- package/resources/conversations/items.d.ts +16 -0
- package/resources/conversations/items.d.ts.map +1 -1
- package/resources/index.d.mts +1 -0
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -0
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/live/forks/forks.d.mts +110 -0
- package/resources/live/forks/forks.d.mts.map +1 -0
- package/resources/live/forks/forks.d.ts +110 -0
- package/resources/live/forks/forks.d.ts.map +1 -0
- package/resources/live/forks/forks.js +9 -0
- package/resources/live/forks/forks.js.map +1 -0
- package/resources/live/forks/forks.mjs +5 -0
- package/resources/live/forks/forks.mjs.map +1 -0
- package/resources/live/forks/index.d.mts +4 -0
- package/resources/live/forks/index.d.mts.map +1 -0
- package/resources/live/forks/index.d.ts +4 -0
- package/resources/live/forks/index.d.ts.map +1 -0
- package/resources/live/forks/index.js +7 -0
- package/resources/live/forks/index.js.map +1 -0
- package/resources/live/forks/index.mjs +3 -0
- package/resources/live/forks/index.mjs.map +1 -0
- package/resources/live/forks/internal-base.d.mts +73 -0
- package/resources/live/forks/internal-base.d.mts.map +1 -0
- package/resources/live/forks/internal-base.d.ts +73 -0
- package/resources/live/forks/internal-base.d.ts.map +1 -0
- package/resources/live/forks/internal-base.js +49 -0
- package/resources/live/forks/internal-base.js.map +1 -0
- package/resources/live/forks/internal-base.mjs +43 -0
- package/resources/live/forks/internal-base.mjs.map +1 -0
- package/resources/live/forks/ws-base.d.mts +109 -0
- package/resources/live/forks/ws-base.d.mts.map +1 -0
- package/resources/live/forks/ws-base.d.ts +109 -0
- package/resources/live/forks/ws-base.d.ts.map +1 -0
- package/resources/live/forks/ws-base.js +476 -0
- package/resources/live/forks/ws-base.js.map +1 -0
- package/resources/live/forks/ws-base.mjs +472 -0
- package/resources/live/forks/ws-base.mjs.map +1 -0
- package/resources/live/forks/ws.d.mts +13 -0
- package/resources/live/forks/ws.d.mts.map +1 -0
- package/resources/live/forks/ws.d.ts +13 -0
- package/resources/live/forks/ws.d.ts.map +1 -0
- package/resources/live/forks/ws.js +34 -0
- package/resources/live/forks/ws.js.map +1 -0
- package/resources/live/forks/ws.mjs +29 -0
- package/resources/live/forks/ws.mjs.map +1 -0
- package/resources/live/forks.d.mts +2 -0
- package/resources/live/forks.d.mts.map +1 -0
- package/resources/live/forks.d.ts +2 -0
- package/resources/live/forks.d.ts.map +1 -0
- package/resources/live/forks.js +6 -0
- package/resources/live/forks.js.map +1 -0
- package/resources/live/forks.mjs +3 -0
- package/resources/live/forks.mjs.map +1 -0
- package/resources/live/index.d.mts +7 -0
- package/resources/live/index.d.mts.map +1 -0
- package/resources/live/index.d.ts +7 -0
- package/resources/live/index.d.ts.map +1 -0
- package/resources/live/index.js +13 -0
- package/resources/live/index.js.map +1 -0
- package/resources/live/index.mjs +6 -0
- package/resources/live/index.mjs.map +1 -0
- package/resources/live/internal-base.d.mts +71 -0
- package/resources/live/internal-base.d.mts.map +1 -0
- package/resources/live/internal-base.d.ts +71 -0
- package/resources/live/internal-base.d.ts.map +1 -0
- package/resources/live/internal-base.js +48 -0
- package/resources/live/internal-base.js.map +1 -0
- package/resources/live/internal-base.mjs +42 -0
- package/resources/live/internal-base.mjs.map +1 -0
- package/resources/live/live.d.mts +1864 -0
- package/resources/live/live.d.mts.map +1 -0
- package/resources/live/live.d.ts +1864 -0
- package/resources/live/live.d.ts.map +1 -0
- package/resources/live/live.js +40 -0
- package/resources/live/live.js.map +1 -0
- package/resources/live/live.mjs +35 -0
- package/resources/live/live.mjs.map +1 -0
- package/resources/live/sessions.d.mts +254 -0
- package/resources/live/sessions.d.mts.map +1 -0
- package/resources/live/sessions.d.ts +254 -0
- package/resources/live/sessions.d.ts.map +1 -0
- package/resources/live/sessions.js +118 -0
- package/resources/live/sessions.js.map +1 -0
- package/resources/live/sessions.mjs +114 -0
- package/resources/live/sessions.mjs.map +1 -0
- package/resources/live/sideband/index.d.mts +4 -0
- package/resources/live/sideband/index.d.mts.map +1 -0
- package/resources/live/sideband/index.d.ts +4 -0
- package/resources/live/sideband/index.d.ts.map +1 -0
- package/resources/live/sideband/index.js +7 -0
- package/resources/live/sideband/index.js.map +1 -0
- package/resources/live/sideband/index.mjs +3 -0
- package/resources/live/sideband/index.mjs.map +1 -0
- package/resources/live/sideband/internal-base.d.mts +73 -0
- package/resources/live/sideband/internal-base.d.mts.map +1 -0
- package/resources/live/sideband/internal-base.d.ts +73 -0
- package/resources/live/sideband/internal-base.d.ts.map +1 -0
- package/resources/live/sideband/internal-base.js +49 -0
- package/resources/live/sideband/internal-base.js.map +1 -0
- package/resources/live/sideband/internal-base.mjs +43 -0
- package/resources/live/sideband/internal-base.mjs.map +1 -0
- package/resources/live/sideband/sideband.d.mts +25 -0
- package/resources/live/sideband/sideband.d.mts.map +1 -0
- package/resources/live/sideband/sideband.d.ts +25 -0
- package/resources/live/sideband/sideband.d.ts.map +1 -0
- package/resources/live/sideband/sideband.js +9 -0
- package/resources/live/sideband/sideband.js.map +1 -0
- package/resources/live/sideband/sideband.mjs +5 -0
- package/resources/live/sideband/sideband.mjs.map +1 -0
- package/resources/live/sideband/ws-base.d.mts +114 -0
- package/resources/live/sideband/ws-base.d.mts.map +1 -0
- package/resources/live/sideband/ws-base.d.ts +114 -0
- package/resources/live/sideband/ws-base.d.ts.map +1 -0
- package/resources/live/sideband/ws-base.js +476 -0
- package/resources/live/sideband/ws-base.js.map +1 -0
- package/resources/live/sideband/ws-base.mjs +472 -0
- package/resources/live/sideband/ws-base.mjs.map +1 -0
- package/resources/live/sideband/ws.d.mts +13 -0
- package/resources/live/sideband/ws.d.mts.map +1 -0
- package/resources/live/sideband/ws.d.ts +13 -0
- package/resources/live/sideband/ws.d.ts.map +1 -0
- package/resources/live/sideband/ws.js +34 -0
- package/resources/live/sideband/ws.js.map +1 -0
- package/resources/live/sideband/ws.mjs +29 -0
- package/resources/live/sideband/ws.mjs.map +1 -0
- package/resources/live/sideband.d.mts +2 -0
- package/resources/live/sideband.d.mts.map +1 -0
- package/resources/live/sideband.d.ts +2 -0
- package/resources/live/sideband.d.ts.map +1 -0
- package/resources/live/sideband.js +6 -0
- package/resources/live/sideband.js.map +1 -0
- package/resources/live/sideband.mjs +3 -0
- package/resources/live/sideband.mjs.map +1 -0
- package/resources/live/ws-base.d.mts +106 -0
- package/resources/live/ws-base.d.mts.map +1 -0
- package/resources/live/ws-base.d.ts +106 -0
- package/resources/live/ws-base.d.ts.map +1 -0
- package/resources/live/ws-base.js +476 -0
- package/resources/live/ws-base.js.map +1 -0
- package/resources/live/ws-base.mjs +472 -0
- package/resources/live/ws-base.mjs.map +1 -0
- package/resources/live/ws.d.mts +13 -0
- package/resources/live/ws.d.mts.map +1 -0
- package/resources/live/ws.d.ts +13 -0
- package/resources/live/ws.d.ts.map +1 -0
- package/resources/live/ws.js +34 -0
- package/resources/live/ws.js.map +1 -0
- package/resources/live/ws.mjs +29 -0
- package/resources/live/ws.mjs.map +1 -0
- package/resources/live.d.mts +2 -0
- package/resources/live.d.mts.map +1 -0
- package/resources/live.d.ts +2 -0
- package/resources/live.d.ts.map +1 -0
- package/resources/live.js +6 -0
- package/resources/live.js.map +1 -0
- package/resources/live.mjs +3 -0
- package/resources/live.mjs.map +1 -0
- package/resources/responses/responses.d.mts +48 -0
- package/resources/responses/responses.d.mts.map +1 -1
- package/resources/responses/responses.d.ts +48 -0
- package/resources/responses/responses.d.ts.map +1 -1
- package/resources/responses/responses.js.map +1 -1
- package/resources/responses/responses.mjs.map +1 -1
- package/resources/webhooks/webhooks.d.mts +72 -5
- package/resources/webhooks/webhooks.d.mts.map +1 -1
- package/resources/webhooks/webhooks.d.ts +72 -5
- package/resources/webhooks/webhooks.d.ts.map +1 -1
- package/src/client.ts +5 -0
- package/src/helpers/live.ts +8 -0
- package/src/lib/live/transcript-grouper.ts +303 -0
- package/src/lib/live/transcript-grouping.ts +362 -0
- package/src/lib/live/webrtc.ts +23 -0
- package/src/lib/realtime/webrtc.ts +20 -0
- package/src/lib/webrtc/connection.ts +309 -0
- package/src/lib/webrtc/data-channel.ts +144 -0
- package/src/lib/webrtc/errors.ts +38 -0
- package/src/lib/webrtc/subscriptions.ts +62 -0
- package/src/lib/webrtc/types.ts +109 -0
- package/src/live/webrtc.ts +10 -0
- package/src/realtime/webrtc.ts +10 -0
- package/src/resources/beta/responses/responses.ts +60 -0
- package/src/resources/conversations/items.ts +20 -0
- package/src/resources/index.ts +1 -0
- package/src/resources/live/api.md +87 -0
- package/src/resources/live/forks/forks.ts +169 -0
- package/src/resources/live/forks/index.ts +5 -0
- package/src/resources/live/forks/internal-base.ts +107 -0
- package/src/resources/live/forks/ws-base.ts +611 -0
- package/src/resources/live/forks/ws.ts +46 -0
- package/src/resources/live/forks.ts +3 -0
- package/src/resources/live/index.ts +20 -0
- package/src/resources/live/internal-base.ts +104 -0
- package/src/resources/live/live.ts +2296 -0
- package/src/resources/live/sessions.ts +337 -0
- package/src/resources/live/sideband/index.ts +10 -0
- package/src/resources/live/sideband/internal-base.ts +107 -0
- package/src/resources/live/sideband/sideband.ts +58 -0
- package/src/resources/live/sideband/ws-base.ts +621 -0
- package/src/resources/live/sideband/ws.ts +46 -0
- package/src/resources/live/sideband.ts +3 -0
- package/src/resources/live/ws-base.ts +607 -0
- package/src/resources/live/ws.ts +42 -0
- package/src/resources/live.ts +3 -0
- package/src/resources/responses/responses.ts +60 -0
- package/src/resources/webhooks/api.md +1 -0
- package/src/resources/webhooks/webhooks.ts +82 -3
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
4
|
+
import * as LiveAPI from './live';
|
|
5
|
+
import { APIPromise } from '../../core/api-promise';
|
|
6
|
+
import { buildHeaders } from '../../internal/headers';
|
|
7
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
8
|
+
import { path } from '../../internal/utils/path';
|
|
9
|
+
|
|
10
|
+
export class Sessions extends APIResource {
|
|
11
|
+
/**
|
|
12
|
+
* Accept an incoming SIP call with Live startup configuration.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* await client.live.sessions.accept('session_id', {
|
|
17
|
+
* session: { model: 'gpt-live-1', type: 'live' },
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
accept(sessionID: string, body: SessionAcceptParams, options?: RequestOptions): APIPromise<void> {
|
|
22
|
+
return this._client.post(path`/live/sessions/${sessionID}/accept`, {
|
|
23
|
+
body,
|
|
24
|
+
...options,
|
|
25
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
26
|
+
__security: { bearerAuth: true },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get Live session content
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const response =
|
|
36
|
+
* await client.live.sessions.downloadRecording('live_SQ');
|
|
37
|
+
*
|
|
38
|
+
* const content = await response.blob();
|
|
39
|
+
* console.log(content);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
downloadRecording(sessionID: string, options?: RequestOptions): APIPromise<Response> {
|
|
43
|
+
return this._client.get(path`/live/sessions/${sessionID}/content`, {
|
|
44
|
+
...options,
|
|
45
|
+
headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
|
|
46
|
+
__security: { bearerAuth: true },
|
|
47
|
+
__binaryResponse: true,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Fork a stored Live session onto a new WebRTC connection.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const response = await client.live.sessions.fork(
|
|
57
|
+
* 'session_id',
|
|
58
|
+
* { transport: { sdp: 'x', type: 'webrtc' } },
|
|
59
|
+
* );
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
fork(
|
|
63
|
+
sessionID: string,
|
|
64
|
+
body: SessionForkParams,
|
|
65
|
+
options?: RequestOptions,
|
|
66
|
+
): APIPromise<SessionForkResponse> {
|
|
67
|
+
return this._client.post(path`/live/sessions/${sessionID}/fork`, {
|
|
68
|
+
body,
|
|
69
|
+
...options,
|
|
70
|
+
__security: { bearerAuth: true },
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Hang up a Live session.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* await client.live.sessions.hangup('session_id');
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
hangup(sessionID: string, options?: RequestOptions): APIPromise<void> {
|
|
83
|
+
return this._client.post(path`/live/sessions/${sessionID}/hangup`, {
|
|
84
|
+
...options,
|
|
85
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
86
|
+
__security: { bearerAuth: true },
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Transfer a Live SIP call to another destination.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* await client.live.sessions.refer('session_id', {
|
|
96
|
+
* target_uri: 'tel:+14155550123',
|
|
97
|
+
* });
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
refer(sessionID: string, body: SessionReferParams, options?: RequestOptions): APIPromise<void> {
|
|
101
|
+
return this._client.post(path`/live/sessions/${sessionID}/refer`, {
|
|
102
|
+
body,
|
|
103
|
+
...options,
|
|
104
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
105
|
+
__security: { bearerAuth: true },
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Reject an incoming SIP call.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* await client.live.sessions.reject('session_id', {
|
|
115
|
+
* status_code: 486,
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
reject(sessionID: string, body: SessionRejectParams, options?: RequestOptions): APIPromise<void> {
|
|
120
|
+
return this._client.post(path`/live/sessions/${sessionID}/reject`, {
|
|
121
|
+
body,
|
|
122
|
+
...options,
|
|
123
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
124
|
+
__security: { bearerAuth: true },
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The created Live session identifier and WebRTC answer. Apply transport.sdp as
|
|
131
|
+
* the peer's remote answer and wait for session.started on the data channel before
|
|
132
|
+
* sending commands.
|
|
133
|
+
*/
|
|
134
|
+
export interface SessionForkResponse {
|
|
135
|
+
/**
|
|
136
|
+
* The newly created Live session. Use its ID for session controls and sideband
|
|
137
|
+
* connections.
|
|
138
|
+
*/
|
|
139
|
+
session: SessionForkResponse.Session;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* WebRTC transport with the SDP answer.
|
|
143
|
+
*/
|
|
144
|
+
transport: SessionForkResponse.Transport;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export namespace SessionForkResponse {
|
|
148
|
+
/**
|
|
149
|
+
* The newly created Live session. Use its ID for session controls and sideband
|
|
150
|
+
* connections.
|
|
151
|
+
*/
|
|
152
|
+
export interface Session {
|
|
153
|
+
/**
|
|
154
|
+
* Opaque session identifier. Preserve the returned value unchanged, including its
|
|
155
|
+
* prefix.
|
|
156
|
+
*/
|
|
157
|
+
id: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* WebRTC transport with the SDP answer.
|
|
162
|
+
*/
|
|
163
|
+
export interface Transport {
|
|
164
|
+
/**
|
|
165
|
+
* Session Description Protocol message for the WebRTC connection.
|
|
166
|
+
*/
|
|
167
|
+
sdp: string;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The transport used for the Live session. Always `webrtc`.
|
|
171
|
+
*/
|
|
172
|
+
type: 'webrtc';
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface SessionAcceptParams {
|
|
177
|
+
/**
|
|
178
|
+
* Model and startup configuration for the Live session that answers the incoming
|
|
179
|
+
* SIP call.
|
|
180
|
+
*/
|
|
181
|
+
session: SessionAcceptParams.Session;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export namespace SessionAcceptParams {
|
|
185
|
+
/**
|
|
186
|
+
* Model and startup configuration for the Live session that answers the incoming
|
|
187
|
+
* SIP call.
|
|
188
|
+
*/
|
|
189
|
+
export interface Session {
|
|
190
|
+
/**
|
|
191
|
+
* The Live model to use for the accepted call.
|
|
192
|
+
*/
|
|
193
|
+
model: (string & {}) | 'gpt-live-1';
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The session type. Always `live`.
|
|
197
|
+
*/
|
|
198
|
+
type: 'live';
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Startup audio output configuration. SIP negotiates the media format;
|
|
202
|
+
* audio.format is only accepted for primary WebSockets. Voice cannot change after
|
|
203
|
+
* startup.
|
|
204
|
+
*/
|
|
205
|
+
audio?: Session.Audio;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Who handles tasks delegated by the Live model. Omitted or null selects your
|
|
209
|
+
* application; use `responses` to let the API manage a Responses backend.
|
|
210
|
+
*/
|
|
211
|
+
delegation?: LiveAPI.ClientDelegation | Session.Responses | null;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Ordered text-only history supplied before startup. Supports developer, user, and
|
|
215
|
+
* assistant messages with one text part each; at most 128 messages and 8,192
|
|
216
|
+
* rendered tokens in total.
|
|
217
|
+
*/
|
|
218
|
+
input?: Array<LiveAPI.InitialItem>;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Frontend instructions for voice, conversation, interruptions, and when to
|
|
222
|
+
* delegate. Start with the
|
|
223
|
+
* [Live prompting guide](https://developers.openai.com/api/docs/guides/live-prompting);
|
|
224
|
+
* put business rules and tool workflows in a separate
|
|
225
|
+
* [backend prompt](https://developers.openai.com/api/docs/guides/live-delegation#start-with-your-existing-backend-prompt).
|
|
226
|
+
* Limited to 16,384 client-supplied tokens. Omitted or blank instructions use
|
|
227
|
+
* server defaults. Immutable after startup.
|
|
228
|
+
*/
|
|
229
|
+
instructions?: string | null;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Whether to store the session for later forking and recording download. Defaults
|
|
233
|
+
* to false for new sessions.
|
|
234
|
+
*/
|
|
235
|
+
store?: boolean;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export namespace Session {
|
|
239
|
+
/**
|
|
240
|
+
* Startup audio output configuration. SIP negotiates the media format;
|
|
241
|
+
* audio.format is only accepted for primary WebSockets. Voice cannot change after
|
|
242
|
+
* startup.
|
|
243
|
+
*/
|
|
244
|
+
export interface Audio {
|
|
245
|
+
/**
|
|
246
|
+
* Settings for speech generated by the Live model. Choose the voice before
|
|
247
|
+
* starting the session.
|
|
248
|
+
*/
|
|
249
|
+
output?: Audio.Output;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export namespace Audio {
|
|
253
|
+
/**
|
|
254
|
+
* Settings for speech generated by the Live model. Choose the voice before
|
|
255
|
+
* starting the session.
|
|
256
|
+
*/
|
|
257
|
+
export interface Output {
|
|
258
|
+
/**
|
|
259
|
+
* The voice used for Live speech, as a built-in voice name or a custom voice
|
|
260
|
+
* object containing its ID. Defaults to `marin` and cannot change after startup.
|
|
261
|
+
*/
|
|
262
|
+
voice?: string | LiveAPI.BuiltInVoice | LiveAPI.CustomVoice;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Delegate tasks to a Responses model managed by the Live session.
|
|
268
|
+
*/
|
|
269
|
+
export interface Responses {
|
|
270
|
+
/**
|
|
271
|
+
* Backend model, prompt, and tools used when the Live session delegates a task to
|
|
272
|
+
* Responses.
|
|
273
|
+
*/
|
|
274
|
+
responses: LiveAPI.ResponsesDelegationConfig;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* The delegation owner. Always `responses` for tasks handled by the Responses API.
|
|
278
|
+
*/
|
|
279
|
+
type: 'responses';
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export interface SessionForkParams {
|
|
285
|
+
/**
|
|
286
|
+
* WebRTC transport with an SDP offer for the new connection to the forked session.
|
|
287
|
+
*/
|
|
288
|
+
transport: SessionForkParams.Transport;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Optional configuration overrides for the new Live session. Omit this object or
|
|
292
|
+
* send an empty object to inherit the stored session's settings.
|
|
293
|
+
*/
|
|
294
|
+
session?: LiveAPI.MediaSessionForkConfig;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export namespace SessionForkParams {
|
|
298
|
+
/**
|
|
299
|
+
* WebRTC transport with an SDP offer for the new connection to the forked session.
|
|
300
|
+
*/
|
|
301
|
+
export interface Transport {
|
|
302
|
+
/**
|
|
303
|
+
* Session Description Protocol message for the WebRTC connection.
|
|
304
|
+
*/
|
|
305
|
+
sdp: string;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* The transport used for the Live session. Always `webrtc`.
|
|
309
|
+
*/
|
|
310
|
+
type: 'webrtc';
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export interface SessionReferParams {
|
|
315
|
+
/**
|
|
316
|
+
* Nonblank URI for the SIP Refer-To header, such as tel:+14155550123 or
|
|
317
|
+
* sip:agent@example.com.
|
|
318
|
+
*/
|
|
319
|
+
target_uri: string;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export interface SessionRejectParams {
|
|
323
|
+
/**
|
|
324
|
+
* SIP rejection status sent to the caller. This field is required.
|
|
325
|
+
*/
|
|
326
|
+
status_code: number;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export declare namespace Sessions {
|
|
330
|
+
export {
|
|
331
|
+
type SessionForkResponse as SessionForkResponse,
|
|
332
|
+
type SessionAcceptParams as SessionAcceptParams,
|
|
333
|
+
type SessionForkParams as SessionForkParams,
|
|
334
|
+
type SessionReferParams as SessionReferParams,
|
|
335
|
+
type SessionRejectParams as SessionRejectParams,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
Sideband,
|
|
5
|
+
type ConnectClientEvent,
|
|
6
|
+
type ConnectServerEvent,
|
|
7
|
+
type SidebandConnectParams,
|
|
8
|
+
} from './sideband';
|
|
9
|
+
export { type SidebandWSClientOptions } from './ws';
|
|
10
|
+
export { type SidebandWSReconnectOptions, type SidebandWSParameters } from './ws-base';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import * as LiveAPI from '../live';
|
|
4
|
+
import * as SidebandAPI from './sideband';
|
|
5
|
+
import { OpenAI } from '../../../client';
|
|
6
|
+
import { EventEmitter } from '../../../core/EventEmitter';
|
|
7
|
+
import { OpenAIError } from '../../../core/error';
|
|
8
|
+
import { path } from '../../../internal/utils/path';
|
|
9
|
+
|
|
10
|
+
import type { RawWebSocketData, ReconnectingEvent, UnsentMessage } from '../../../internal/ws';
|
|
11
|
+
import { SidebandWSParameters } from './ws-base';
|
|
12
|
+
|
|
13
|
+
export type SidebandStreamMessage =
|
|
14
|
+
| { type: 'connecting' | 'open' | 'closing' }
|
|
15
|
+
| { type: 'close'; code: number; reason: string; unsent: UnsentMessage<SidebandAPI.ConnectClientEvent>[] }
|
|
16
|
+
| { type: 'reconnecting'; reconnect: ReconnectingEvent<SidebandWSParameters> }
|
|
17
|
+
| { type: 'reconnected' }
|
|
18
|
+
| { type: 'message'; message: SidebandAPI.ConnectServerEvent }
|
|
19
|
+
| { type: 'raw'; data: RawWebSocketData }
|
|
20
|
+
| { type: 'error'; error: WebSocketError };
|
|
21
|
+
|
|
22
|
+
export class WebSocketError extends OpenAIError {
|
|
23
|
+
/**
|
|
24
|
+
* The error data that the API sent back in an error event.
|
|
25
|
+
*/
|
|
26
|
+
error?: LiveAPI.ErrorEvent | undefined;
|
|
27
|
+
|
|
28
|
+
constructor(message: string, event: LiveAPI.ErrorEvent | null) {
|
|
29
|
+
super(message);
|
|
30
|
+
|
|
31
|
+
this.error = event ?? undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
36
|
+
|
|
37
|
+
type WebSocketEvents = Simplify<
|
|
38
|
+
{
|
|
39
|
+
event: (event: SidebandAPI.ConnectServerEvent) => void;
|
|
40
|
+
raw: (data: RawWebSocketData) => void;
|
|
41
|
+
error: (error: WebSocketError) => void;
|
|
42
|
+
close: (code: number, reason: string, unsent: UnsentMessage<SidebandAPI.ConnectClientEvent>[]) => void;
|
|
43
|
+
reconnecting: (event: ReconnectingEvent<SidebandWSParameters>) => void;
|
|
44
|
+
reconnected: () => void;
|
|
45
|
+
} & {
|
|
46
|
+
[EventType in Exclude<NonNullable<SidebandAPI.ConnectServerEvent['type']>, 'error'>]: (
|
|
47
|
+
event: Extract<SidebandAPI.ConnectServerEvent, { type?: EventType }>,
|
|
48
|
+
) => unknown;
|
|
49
|
+
}
|
|
50
|
+
>;
|
|
51
|
+
|
|
52
|
+
export abstract class SidebandEmitter extends EventEmitter<WebSocketEvents> {
|
|
53
|
+
/**
|
|
54
|
+
* Send an event to the API.
|
|
55
|
+
*/
|
|
56
|
+
abstract send(event: SidebandAPI.ConnectClientEvent): void;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Send raw data over the WebSocket without JSON serialization.
|
|
60
|
+
*/
|
|
61
|
+
abstract sendRaw(data: RawWebSocketData): void;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Close the WebSocket connection.
|
|
65
|
+
*/
|
|
66
|
+
abstract close(props?: { code: number; reason: string }): void;
|
|
67
|
+
|
|
68
|
+
protected _onError(event: null, message: string, cause: any): void;
|
|
69
|
+
protected _onError(event: LiveAPI.ErrorEvent, message?: string | undefined): void;
|
|
70
|
+
protected _onError(event: LiveAPI.ErrorEvent | null, message?: string | undefined, cause?: any): void {
|
|
71
|
+
message = message ?? safeJSONStringify(event) ?? 'unknown error';
|
|
72
|
+
|
|
73
|
+
if (!this._hasListener('error')) {
|
|
74
|
+
const error = new WebSocketError(
|
|
75
|
+
message +
|
|
76
|
+
`\n\nTo resolve these unhandled rejection errors you should bind an \`error\` callback, e.g. \`ws.on('error', (error) => ...)\` `,
|
|
77
|
+
event,
|
|
78
|
+
);
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
error.cause = cause;
|
|
81
|
+
Promise.reject(error);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const error = new WebSocketError(message, event);
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
error.cause = cause;
|
|
88
|
+
|
|
89
|
+
this._emit('error', error);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function buildURL(client: OpenAI, parameters: Record<string, unknown>): URL {
|
|
94
|
+
const { session_id: path0, ...query } = parameters;
|
|
95
|
+
const endpoint = path`/live/sessions/${path0}/attach`;
|
|
96
|
+
const url = new URL(client.buildURL(endpoint, query, undefined));
|
|
97
|
+
url.protocol = url.protocol === 'http:' || url.protocol === 'ws:' ? 'ws:' : 'wss:';
|
|
98
|
+
return url;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function safeJSONStringify(value: unknown): string | null {
|
|
102
|
+
try {
|
|
103
|
+
return JSON.stringify(value);
|
|
104
|
+
} catch {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../../core/resource';
|
|
4
|
+
import * as LiveAPI from '../live';
|
|
5
|
+
|
|
6
|
+
export class Sideband extends APIResource {}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Client events accepted by an attached Live sideband WebSocket. The session is
|
|
10
|
+
* already started; send audio over the primary connection.
|
|
11
|
+
*/
|
|
12
|
+
export type ConnectClientEvent =
|
|
13
|
+
| LiveAPI.SessionUpdateEvent
|
|
14
|
+
| LiveAPI.InputAudioMuteEvent
|
|
15
|
+
| LiveAPI.InputAudioUnmuteEvent
|
|
16
|
+
| LiveAPI.InstructionsAppendEvent
|
|
17
|
+
| LiveAPI.ThinkingAppendEvent
|
|
18
|
+
| LiveAPI.CommentaryAppendEvent
|
|
19
|
+
| LiveAPI.ResponseItemCreateEvent
|
|
20
|
+
| LiveAPI.ResponseCreateEvent
|
|
21
|
+
| LiveAPI.SessionCloseEvent;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Server events received by an attached Live sideband WebSocket. Audio deltas are
|
|
25
|
+
* delivered over the primary connection.
|
|
26
|
+
*/
|
|
27
|
+
export type ConnectServerEvent =
|
|
28
|
+
| LiveAPI.SessionStartedEvent
|
|
29
|
+
| LiveAPI.SessionUpdatedEvent
|
|
30
|
+
| LiveAPI.InputAudioMutedEvent
|
|
31
|
+
| LiveAPI.InputAudioUnmutedEvent
|
|
32
|
+
| LiveAPI.InstructionsAppendedEvent
|
|
33
|
+
| LiveAPI.ThinkingAppendedEvent
|
|
34
|
+
| LiveAPI.CommentaryAppendedEvent
|
|
35
|
+
| LiveAPI.InputTranscriptDeltaEvent
|
|
36
|
+
| LiveAPI.OutputTranscriptDeltaEvent
|
|
37
|
+
| LiveAPI.DelegationCreatedEvent
|
|
38
|
+
| LiveAPI.ResponseEvent
|
|
39
|
+
| LiveAPI.SessionUsageUpdatedEvent
|
|
40
|
+
| LiveAPI.SessionClosedEvent
|
|
41
|
+
| LiveAPI.ErrorEvent
|
|
42
|
+
| LiveAPI.InfoEvent;
|
|
43
|
+
|
|
44
|
+
export interface SidebandConnectParams {
|
|
45
|
+
/**
|
|
46
|
+
* Opt in to the graceful WebSocket closing handshake when the session ends. The
|
|
47
|
+
* server may also enable this behavior by default.
|
|
48
|
+
*/
|
|
49
|
+
graceful_close?: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export declare namespace Sideband {
|
|
53
|
+
export {
|
|
54
|
+
type ConnectClientEvent as ConnectClientEvent,
|
|
55
|
+
type ConnectServerEvent as ConnectServerEvent,
|
|
56
|
+
type SidebandConnectParams as SidebandConnectParams,
|
|
57
|
+
};
|
|
58
|
+
}
|