qca-sdk 0.3.0 → 0.5.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/README.md +275 -1
- package/dist/core/auth.d.ts +12 -0
- package/dist/core/auth.d.ts.map +1 -0
- package/dist/core/auth.js +34 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/client.d.ts +14 -0
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +36 -11
- package/dist/core/client.js.map +1 -1
- package/dist/core/credentials.d.ts +3 -0
- package/dist/core/credentials.d.ts.map +1 -1
- package/dist/core/credentials.js +3 -1
- package/dist/core/credentials.js.map +1 -1
- package/dist/core/service-account-credential.d.ts +20 -0
- package/dist/core/service-account-credential.d.ts.map +1 -0
- package/dist/core/service-account-credential.js +139 -0
- package/dist/core/service-account-credential.js.map +1 -0
- package/dist/esm/core/auth.d.ts +12 -0
- package/dist/esm/core/auth.d.ts.map +1 -0
- package/dist/esm/core/auth.js +30 -0
- package/dist/esm/core/auth.js.map +1 -0
- package/dist/esm/core/client.d.ts +14 -0
- package/dist/esm/core/client.d.ts.map +1 -1
- package/dist/esm/core/client.js +36 -11
- package/dist/esm/core/client.js.map +1 -1
- package/dist/esm/core/credentials.d.ts +3 -0
- package/dist/esm/core/credentials.d.ts.map +1 -1
- package/dist/esm/core/credentials.js +1 -0
- package/dist/esm/core/credentials.js.map +1 -1
- package/dist/esm/core/service-account-credential.d.ts +20 -0
- package/dist/esm/core/service-account-credential.d.ts.map +1 -0
- package/dist/esm/core/service-account-credential.js +135 -0
- package/dist/esm/core/service-account-credential.js.map +1 -0
- package/dist/esm/forward/forwardClient.d.ts +4 -0
- package/dist/esm/forward/forwardClient.d.ts.map +1 -1
- package/dist/esm/forward/forwardClient.js +4 -0
- package/dist/esm/forward/forwardClient.js.map +1 -1
- package/dist/esm/forward/identity-service-account-token.d.ts +11 -0
- package/dist/esm/forward/identity-service-account-token.d.ts.map +1 -0
- package/dist/esm/forward/identity-service-account-token.js +18 -0
- package/dist/esm/forward/identity-service-account-token.js.map +1 -0
- package/dist/esm/forward/identity.d.ts +2 -0
- package/dist/esm/forward/identity.d.ts.map +1 -1
- package/dist/esm/forward/identity.js +2 -0
- package/dist/esm/forward/identity.js.map +1 -1
- package/dist/esm/forward/index.d.ts +9 -1
- package/dist/esm/forward/index.d.ts.map +1 -1
- package/dist/esm/forward/index.js +7 -1
- package/dist/esm/forward/index.js.map +1 -1
- package/dist/esm/forward/realtime/connection.d.ts +106 -0
- package/dist/esm/forward/realtime/connection.d.ts.map +1 -0
- package/dist/esm/forward/realtime/connection.js +465 -0
- package/dist/esm/forward/realtime/connection.js.map +1 -0
- package/dist/esm/forward/realtime/conversation.d.ts +31 -0
- package/dist/esm/forward/realtime/conversation.d.ts.map +1 -0
- package/dist/esm/forward/realtime/conversation.js +92 -0
- package/dist/esm/forward/realtime/conversation.js.map +1 -0
- package/dist/esm/forward/realtime/realtime.d.ts +9 -0
- package/dist/esm/forward/realtime/realtime.d.ts.map +1 -0
- package/dist/esm/forward/realtime/realtime.js +9 -0
- package/dist/esm/forward/realtime/realtime.js.map +1 -0
- package/dist/esm/forward/realtime/types.d.ts +204 -0
- package/dist/esm/forward/realtime/types.d.ts.map +1 -0
- package/dist/esm/forward/realtime/types.js +7 -0
- package/dist/esm/forward/realtime/types.js.map +1 -0
- package/dist/esm/forward/service-account-token.d.ts +15 -0
- package/dist/esm/forward/service-account-token.d.ts.map +1 -0
- package/dist/esm/forward/service-account-token.js +38 -0
- package/dist/esm/forward/service-account-token.js.map +1 -0
- package/dist/esm/forward/types.d.ts +35 -0
- package/dist/esm/forward/types.d.ts.map +1 -1
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/forward/forwardClient.d.ts +4 -0
- package/dist/forward/forwardClient.d.ts.map +1 -1
- package/dist/forward/forwardClient.js +4 -0
- package/dist/forward/forwardClient.js.map +1 -1
- package/dist/forward/identity-service-account-token.d.ts +11 -0
- package/dist/forward/identity-service-account-token.d.ts.map +1 -0
- package/dist/forward/identity-service-account-token.js +22 -0
- package/dist/forward/identity-service-account-token.js.map +1 -0
- package/dist/forward/identity.d.ts +2 -0
- package/dist/forward/identity.d.ts.map +1 -1
- package/dist/forward/identity.js +2 -0
- package/dist/forward/identity.js.map +1 -1
- package/dist/forward/index.d.ts +9 -1
- package/dist/forward/index.d.ts.map +1 -1
- package/dist/forward/index.js +18 -1
- package/dist/forward/index.js.map +1 -1
- package/dist/forward/realtime/connection.d.ts +106 -0
- package/dist/forward/realtime/connection.d.ts.map +1 -0
- package/dist/forward/realtime/connection.js +473 -0
- package/dist/forward/realtime/connection.js.map +1 -0
- package/dist/forward/realtime/conversation.d.ts +31 -0
- package/dist/forward/realtime/conversation.d.ts.map +1 -0
- package/dist/forward/realtime/conversation.js +97 -0
- package/dist/forward/realtime/conversation.js.map +1 -0
- package/dist/forward/realtime/realtime.d.ts +9 -0
- package/dist/forward/realtime/realtime.d.ts.map +1 -0
- package/dist/forward/realtime/realtime.js +13 -0
- package/dist/forward/realtime/realtime.js.map +1 -0
- package/dist/forward/realtime/types.d.ts +204 -0
- package/dist/forward/realtime/types.d.ts.map +1 -0
- package/dist/forward/realtime/types.js +11 -0
- package/dist/forward/realtime/types.js.map +1 -0
- package/dist/forward/service-account-token.d.ts +15 -0
- package/dist/forward/service-account-token.d.ts.map +1 -0
- package/dist/forward/service-account-token.js +43 -0
- package/dist/forward/service-account-token.js.map +1 -0
- package/dist/forward/types.d.ts +35 -0
- package/dist/forward/types.d.ts.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +12 -3
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RealtimeConversations = exports.RealtimeHistoryPage = void 0;
|
|
4
|
+
const resource_js_1 = require("../../core/resource.js");
|
|
5
|
+
const api_promise_js_1 = require("../../core/api-promise.js");
|
|
6
|
+
const error_js_1 = require("../../core/error.js");
|
|
7
|
+
const _utils_js_1 = require("../_utils.js");
|
|
8
|
+
/** History uses before cursors and events, independently of ordinary list pages. */
|
|
9
|
+
class RealtimeHistoryPage {
|
|
10
|
+
client;
|
|
11
|
+
conversationID;
|
|
12
|
+
params;
|
|
13
|
+
options;
|
|
14
|
+
data;
|
|
15
|
+
response;
|
|
16
|
+
conversation;
|
|
17
|
+
events;
|
|
18
|
+
page;
|
|
19
|
+
_request_id;
|
|
20
|
+
constructor(client, conversationID, params, options, data, response) {
|
|
21
|
+
this.client = client;
|
|
22
|
+
this.conversationID = conversationID;
|
|
23
|
+
this.params = params;
|
|
24
|
+
this.options = options;
|
|
25
|
+
this.data = data;
|
|
26
|
+
this.response = response;
|
|
27
|
+
for (const [key, value] of Object.entries(data))
|
|
28
|
+
if (!(key in this))
|
|
29
|
+
Object.defineProperty(this, key, { value, enumerable: true });
|
|
30
|
+
this.conversation = data.conversation;
|
|
31
|
+
this.events = data.events;
|
|
32
|
+
this.page = data.page;
|
|
33
|
+
this._request_id = response.headers.get('x-request-id') ?? response.headers.get('request-id');
|
|
34
|
+
}
|
|
35
|
+
hasNextPage() { return this.page.has_more && !!this.page.next_before; }
|
|
36
|
+
getNextPage() {
|
|
37
|
+
if (!this.hasNextPage())
|
|
38
|
+
throw new error_js_1.QoderError('No next history page; check hasNextPage() first');
|
|
39
|
+
if (this.page.next_before === this.params.before)
|
|
40
|
+
throw new error_js_1.QoderError('History cursor did not advance');
|
|
41
|
+
return new RealtimeConversations(this.client).history(this.conversationID, { ...this.params, before: this.page.next_before }, this.options);
|
|
42
|
+
}
|
|
43
|
+
async *iterPages() {
|
|
44
|
+
let current = this;
|
|
45
|
+
const seen = new Set();
|
|
46
|
+
if (this.params.before)
|
|
47
|
+
seen.add(this.params.before);
|
|
48
|
+
for (;;) {
|
|
49
|
+
yield current;
|
|
50
|
+
if (!current.hasNextPage())
|
|
51
|
+
return;
|
|
52
|
+
const cursor = current.page.next_before;
|
|
53
|
+
if (seen.has(cursor))
|
|
54
|
+
throw new error_js_1.QoderError('History cursor did not advance');
|
|
55
|
+
seen.add(cursor);
|
|
56
|
+
current = await current.getNextPage();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async *[Symbol.asyncIterator]() {
|
|
60
|
+
for await (const page of this.iterPages())
|
|
61
|
+
yield* page.events;
|
|
62
|
+
}
|
|
63
|
+
toJSON() { return this.data; }
|
|
64
|
+
}
|
|
65
|
+
exports.RealtimeHistoryPage = RealtimeHistoryPage;
|
|
66
|
+
class RealtimeConversations extends resource_js_1.APIResource {
|
|
67
|
+
/** Create a Beta Realtime Conversation; use a stable key for this operation. */
|
|
68
|
+
create(params, options = {}) {
|
|
69
|
+
const { idempotency_key, ...body } = params;
|
|
70
|
+
const headers = (0, _utils_js_1.requestHeaders)({ 'Idempotency-Key': idempotency_key }, options.headers);
|
|
71
|
+
const key = options.idempotencyKey ?? headers['idempotency-key'];
|
|
72
|
+
if (typeof key !== 'string' || !key || key.trim() !== key || new TextEncoder().encode(key).length > 256 || /[\x00-\x1f\x7f]/.test(key)) {
|
|
73
|
+
throw new error_js_1.QoderError('Idempotency-Key must be 1–256 UTF-8 bytes without surrounding whitespace or control characters');
|
|
74
|
+
}
|
|
75
|
+
return this._client.request({ method: 'POST', path: 'realtime/conversations', body, ...options, headers });
|
|
76
|
+
}
|
|
77
|
+
/** Query persisted history, newest first; next_before retrieves older records. */
|
|
78
|
+
history(conversationID, params = {}, options = {}) {
|
|
79
|
+
const query = { ...params, ...options.query };
|
|
80
|
+
if (query.limit !== undefined && (!Number.isInteger(query.limit) || query.limit < 1 || query.limit > 100))
|
|
81
|
+
throw new error_js_1.QoderError('History limit must be an integer from 1 to 100');
|
|
82
|
+
if (query.before !== undefined && (typeof query.before !== 'string' || !query.before))
|
|
83
|
+
throw new error_js_1.QoderError('History before must be nonempty');
|
|
84
|
+
if (query.types !== undefined && !['message', 'work', 'message,work'].includes(query.types))
|
|
85
|
+
throw new error_js_1.QoderError('History types must be message, work, or message,work');
|
|
86
|
+
const request = this._client.request({ method: 'GET', path: `realtime/conversations/${(0, _utils_js_1.pathParam)(conversationID, 'conversation_id')}/history`, ...options, query });
|
|
87
|
+
return new api_promise_js_1.APIPromise(request.asResponse(), async (response) => {
|
|
88
|
+
const data = (await request.withResponse()).data;
|
|
89
|
+
if (!data || !Array.isArray(data.events) || !data.conversation || !data.page || typeof data.page.has_more !== 'boolean'
|
|
90
|
+
|| !(data.page.next_before === null || typeof data.page.next_before === 'string') || (data.page.has_more && !data.page.next_before))
|
|
91
|
+
throw new error_js_1.QoderError('Invalid Realtime history response');
|
|
92
|
+
return new RealtimeHistoryPage(this._client, conversationID, query, { ...options, query: undefined }, data, response);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.RealtimeConversations = RealtimeConversations;
|
|
97
|
+
//# sourceMappingURL=conversation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../../src/forward/realtime/conversation.ts"],"names":[],"mappings":";;;AAAA,wDAAqD;AACrD,8DAAuD;AAEvD,kDAAiD;AACjD,4CAAyD;AAGzD,oFAAoF;AACpF,MAAa,mBAAmB;IAMD;IAAoC;IAC9C;IAAgD;IAChD;IAAwC;IAPlD,YAAY,CAA0C;IACtD,MAAM,CAAyB;IAC/B,IAAI,CAAkC;IACtC,WAAW,CAAgB;IAEpC,YAA6B,MAAiB,EAAmB,cAAsB,EACpE,MAA6B,EAAmB,OAAuB,EACvE,IAA6B,EAAW,QAAkB;QAFhD,WAAM,GAAN,MAAM,CAAW;QAAmB,mBAAc,GAA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eConversations } from './conversation.js';
|
|
3
|
+
import { RealtimeConnection, type RealtimeConnectOptions } from './connection.js';
|
|
4
|
+
/** Forward Realtime Beta. WebSocket transport is supported on Node.js only. */
|
|
5
|
+
export declare class Realtime extends APIResource {
|
|
6
|
+
readonly conversations: RealtimeConversations;
|
|
7
|
+
connect(options: RealtimeConnectOptions): Promise<RealtimeConnection>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=realtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtime.d.ts","sourceRoot":"","sources":["../../../src/forward/realtime/realtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAClF,+EAA+E;AAC/E,qBAAa,QAAS,SAAQ,WAAW;IACvC,QAAQ,CAAC,aAAa,wBAA2C;IACjE,OAAO,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CACtE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Realtime = void 0;
|
|
4
|
+
const resource_js_1 = require("../../core/resource.js");
|
|
5
|
+
const conversation_js_1 = require("./conversation.js");
|
|
6
|
+
const connection_js_1 = require("./connection.js");
|
|
7
|
+
/** Forward Realtime Beta. WebSocket transport is supported on Node.js only. */
|
|
8
|
+
class Realtime extends resource_js_1.APIResource {
|
|
9
|
+
conversations = new conversation_js_1.RealtimeConversations(this._client);
|
|
10
|
+
connect(options) { return connection_js_1.RealtimeConnection.connect(this._client, options); }
|
|
11
|
+
}
|
|
12
|
+
exports.Realtime = Realtime;
|
|
13
|
+
//# sourceMappingURL=realtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtime.js","sourceRoot":"","sources":["../../../src/forward/realtime/realtime.ts"],"names":[],"mappings":";;;AAAA,wDAAqD;AACrD,uDAA0D;AAC1D,mDAAkF;AAClF,+EAA+E;AAC/E,MAAa,QAAS,SAAQ,yBAAW;IAC9B,aAAa,GAAG,IAAI,uCAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjE,OAAO,CAAC,OAA+B,IAAiC,OAAO,kCAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACpI;AAHD,4BAGC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/** Forward Realtime Beta protocol. Timestamp strings preserve nanosecond precision. */
|
|
2
|
+
export declare const REALTIME_VERSION: "voice.realtime.v1";
|
|
3
|
+
export type RealtimeVoice = 'longanqian' | 'longanlingxin' | 'longanlingxi' | 'longanxiaoxin' | 'longanlufeng';
|
|
4
|
+
export interface RealtimeConfig {
|
|
5
|
+
audio?: {
|
|
6
|
+
output?: {
|
|
7
|
+
voice?: RealtimeVoice;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface RealtimeConversationCreateParams {
|
|
15
|
+
identity_id: string;
|
|
16
|
+
template_id: string;
|
|
17
|
+
/** Required header, omitted from the JSON body. */
|
|
18
|
+
idempotency_key: string;
|
|
19
|
+
title?: string | null;
|
|
20
|
+
metadata?: Record<string, unknown> | null;
|
|
21
|
+
config?: RealtimeConfig;
|
|
22
|
+
}
|
|
23
|
+
export interface RealtimeConversation {
|
|
24
|
+
id: string;
|
|
25
|
+
type: 'voice.conversation';
|
|
26
|
+
status: 'ready';
|
|
27
|
+
title: string | null;
|
|
28
|
+
metadata: Record<string, unknown>;
|
|
29
|
+
config: RealtimeConfig;
|
|
30
|
+
created_at: string;
|
|
31
|
+
updated_at: string;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
export interface RealtimeHistoryParams {
|
|
35
|
+
limit?: number;
|
|
36
|
+
before?: string;
|
|
37
|
+
types?: 'message' | 'work' | 'message,work';
|
|
38
|
+
}
|
|
39
|
+
export type RealtimeHistoryEventType = 'voice.user_message.completed' | 'voice.assistant_message.completed' | 'voice.assistant_message.interrupted' | 'voice.work.accepted' | 'voice.work.running' | 'voice.work.completed' | 'voice.work.failed' | 'voice.work.final_announcement' | (string & {});
|
|
40
|
+
export interface RealtimeHistoryEvent {
|
|
41
|
+
id: string;
|
|
42
|
+
type: RealtimeHistoryEventType;
|
|
43
|
+
status: string;
|
|
44
|
+
occurred_at: string;
|
|
45
|
+
role?: string;
|
|
46
|
+
text?: string;
|
|
47
|
+
work_id?: string;
|
|
48
|
+
objective?: string;
|
|
49
|
+
result?: string;
|
|
50
|
+
error?: {
|
|
51
|
+
code: string;
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
};
|
|
54
|
+
turn_id?: string;
|
|
55
|
+
user_message_event_id?: string;
|
|
56
|
+
announcement_id?: string;
|
|
57
|
+
milestone_type?: string;
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
}
|
|
60
|
+
export interface RealtimeHistoryResponse {
|
|
61
|
+
conversation: {
|
|
62
|
+
id: string;
|
|
63
|
+
title: string | null;
|
|
64
|
+
initialization_status: string;
|
|
65
|
+
metadata: Record<string, unknown>;
|
|
66
|
+
created_at: string;
|
|
67
|
+
updated_at: string;
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
};
|
|
70
|
+
events: RealtimeHistoryEvent[];
|
|
71
|
+
page: {
|
|
72
|
+
next_before: string | null;
|
|
73
|
+
has_more: boolean;
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
};
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
}
|
|
78
|
+
export interface RealtimeAudioFormat {
|
|
79
|
+
format: 'pcm16';
|
|
80
|
+
sample_rate: number;
|
|
81
|
+
channels: 1;
|
|
82
|
+
[key: string]: unknown;
|
|
83
|
+
}
|
|
84
|
+
export interface RealtimeReady {
|
|
85
|
+
config: RealtimeConfig;
|
|
86
|
+
provider: string;
|
|
87
|
+
input_audio: RealtimeAudioFormat;
|
|
88
|
+
output_audio: RealtimeAudioFormat;
|
|
89
|
+
capabilities: {
|
|
90
|
+
graceful_close: boolean;
|
|
91
|
+
[key: string]: unknown;
|
|
92
|
+
};
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
export interface RealtimePlaybackReceipt {
|
|
96
|
+
work_id?: string;
|
|
97
|
+
announcement_id?: string;
|
|
98
|
+
}
|
|
99
|
+
export type RealtimeCloseOutcome = 'no_active_response' | 'no_content' | 'saved' | 'saved_interrupted';
|
|
100
|
+
export interface RealtimeClosed {
|
|
101
|
+
request_id: string;
|
|
102
|
+
outcome: RealtimeCloseOutcome;
|
|
103
|
+
}
|
|
104
|
+
export interface RealtimeErrorPayload {
|
|
105
|
+
code: string;
|
|
106
|
+
message: string;
|
|
107
|
+
retryable?: boolean;
|
|
108
|
+
retry_after_ms?: number;
|
|
109
|
+
[key: string]: unknown;
|
|
110
|
+
}
|
|
111
|
+
export interface RealtimeServerPayloads {
|
|
112
|
+
'voice.state': {
|
|
113
|
+
state: string;
|
|
114
|
+
};
|
|
115
|
+
'voice.ready': RealtimeReady;
|
|
116
|
+
'voice.replaced': {
|
|
117
|
+
reason: string;
|
|
118
|
+
};
|
|
119
|
+
'transcript.delta': {
|
|
120
|
+
role: string;
|
|
121
|
+
text: string;
|
|
122
|
+
item_id?: string;
|
|
123
|
+
response_id?: string;
|
|
124
|
+
};
|
|
125
|
+
'transcript.final': {
|
|
126
|
+
role: string;
|
|
127
|
+
text: string;
|
|
128
|
+
item_id?: string;
|
|
129
|
+
response_id?: string;
|
|
130
|
+
};
|
|
131
|
+
'audio.delta': {
|
|
132
|
+
audio: string;
|
|
133
|
+
};
|
|
134
|
+
'audio.done': Record<string, never>;
|
|
135
|
+
'playback.interrupt': {
|
|
136
|
+
reason: string;
|
|
137
|
+
};
|
|
138
|
+
'work.accepted': {
|
|
139
|
+
status: 'accepted';
|
|
140
|
+
objective: string;
|
|
141
|
+
};
|
|
142
|
+
'work.running': {
|
|
143
|
+
status: 'running';
|
|
144
|
+
};
|
|
145
|
+
'work.progress': {
|
|
146
|
+
kind: string;
|
|
147
|
+
detail: string;
|
|
148
|
+
title?: string;
|
|
149
|
+
is_error?: boolean;
|
|
150
|
+
event_id?: string;
|
|
151
|
+
};
|
|
152
|
+
'work.milestone': {
|
|
153
|
+
announcement_id: string;
|
|
154
|
+
milestone_type: string;
|
|
155
|
+
summary: string;
|
|
156
|
+
};
|
|
157
|
+
'work.completed': {
|
|
158
|
+
status: 'completed';
|
|
159
|
+
result: string;
|
|
160
|
+
event_id?: string;
|
|
161
|
+
};
|
|
162
|
+
'work.failed': {
|
|
163
|
+
status: 'failed';
|
|
164
|
+
error: {
|
|
165
|
+
code: string;
|
|
166
|
+
[key: string]: unknown;
|
|
167
|
+
};
|
|
168
|
+
event_id?: string;
|
|
169
|
+
};
|
|
170
|
+
pong: Record<string, never>;
|
|
171
|
+
'connection.closed': RealtimeClosed;
|
|
172
|
+
error: RealtimeErrorPayload;
|
|
173
|
+
}
|
|
174
|
+
export interface RealtimeEventEnvelope {
|
|
175
|
+
version: typeof REALTIME_VERSION;
|
|
176
|
+
event_id: string;
|
|
177
|
+
sequence: number;
|
|
178
|
+
conversation_id: string;
|
|
179
|
+
timestamp: string;
|
|
180
|
+
work_id?: string;
|
|
181
|
+
announcement_id?: string;
|
|
182
|
+
[key: string]: unknown;
|
|
183
|
+
}
|
|
184
|
+
export type RealtimeKnownEvent = {
|
|
185
|
+
[K in keyof RealtimeServerPayloads]: RealtimeEventEnvelope & {
|
|
186
|
+
type: K;
|
|
187
|
+
payload: RealtimeServerPayloads[K] & Record<string, unknown>;
|
|
188
|
+
};
|
|
189
|
+
}[keyof RealtimeServerPayloads];
|
|
190
|
+
/** Unknown Beta events retain their envelope and complete payload. */
|
|
191
|
+
export type RealtimeServerEvent = RealtimeKnownEvent | (RealtimeEventEnvelope & {
|
|
192
|
+
type: string;
|
|
193
|
+
payload: Record<string, unknown>;
|
|
194
|
+
});
|
|
195
|
+
export interface RealtimeClientEvent {
|
|
196
|
+
version: typeof REALTIME_VERSION;
|
|
197
|
+
type: string;
|
|
198
|
+
payload: Record<string, unknown>;
|
|
199
|
+
}
|
|
200
|
+
/** Narrow a known event payload while continuing to allow future Beta event types. */
|
|
201
|
+
export declare function isRealtimeEvent<K extends keyof RealtimeServerPayloads>(event: RealtimeServerEvent, type: K): event is Extract<RealtimeKnownEvent, {
|
|
202
|
+
type: K;
|
|
203
|
+
}>;
|
|
204
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/forward/realtime/types.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,eAAO,MAAM,gBAAgB,EAAG,mBAA4B,CAAC;AAC7D,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,eAAe,GAAG,cAAc,GAAG,eAAe,GAAG,cAAc,CAAC;AAC/G,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE,aAAa,CAAC;YAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;SAAE,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC/F,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AACD,MAAM,WAAW,gCAAgC;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,CAA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;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AACD,MAAM,MAAM,kBAAkB,GAAG;KAAG,CAAC,IAAI,MAAM,sBAAsB,GAAG,qBAAqB,GAAG;QAC9F,IAAI,EAAE,CAAC,CAAC;QAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACvE;CAAE,CAAC,MAAM,sBAAsB,CAAC,CAAC;AAClC,sEAAsE;AACtE,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG,CAAC,qBAAqB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC,CAAC;AACpI,MAAM,WAAW,mBAAmB;IAAG,OAAO,EAAE,OAAO,gBAAgB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE;AAEzH,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,sBAAsB,EAAE,KAAK,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,GAAG,KAAK,IAAI,OAAO,CAAC,kBAAkB,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAE9J"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REALTIME_VERSION = void 0;
|
|
4
|
+
exports.isRealtimeEvent = isRealtimeEvent;
|
|
5
|
+
/** Forward Realtime Beta protocol. Timestamp strings preserve nanosecond precision. */
|
|
6
|
+
exports.REALTIME_VERSION = 'voice.realtime.v1';
|
|
7
|
+
/** Narrow a known event payload while continuing to allow future Beta event types. */
|
|
8
|
+
function isRealtimeEvent(event, type) {
|
|
9
|
+
return event.type === type;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/forward/realtime/types.ts"],"names":[],"mappings":";;;AAoHA,0CAEC;AAtHD,uFAAuF;AAC1E,QAAA,gBAAgB,GAAG,mBAA4B,CAAC;AAkH7D,sFAAsF;AACtF,SAAgB,eAAe,CAAyC,KAA0B,EAAE,IAAO;IACzG,OAAO,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { APIResource } from '../core/resource.js';
|
|
2
|
+
import { type RequestOptions } from '../core/client.js';
|
|
3
|
+
import type { APIPromise } from '../core/api-promise.js';
|
|
4
|
+
import type { ServiceAccountToken, ServiceAccountTokenCreateParams, ServiceAccountTokenRevokeParams, ServiceAccountTokenRevokeResponse } from './types.js';
|
|
5
|
+
/** @internal Per-call Key authentication overrides ordinary PAT/SAT authentication. */
|
|
6
|
+
export declare function saKeyRequestOptions(saKey: string, options?: RequestOptions): RequestOptions;
|
|
7
|
+
/** Forward SAT issuance and revocation require an explicit SA Key per call. */
|
|
8
|
+
export declare class ServiceAccountTokens extends APIResource {
|
|
9
|
+
/** Issue an admin SAT. Automatic retries are disabled to avoid duplicate issuance. */
|
|
10
|
+
create(params: ServiceAccountTokenCreateParams, options?: RequestOptions): APIPromise<ServiceAccountToken>;
|
|
11
|
+
/** Revoke a Forward SAT binding from the same SA. Creation metadata disambiguates the target. */
|
|
12
|
+
revoke(authTokenID: string, params: ServiceAccountTokenRevokeParams, options?: RequestOptions): APIPromise<ServiceAccountTokenRevokeResponse>;
|
|
13
|
+
}
|
|
14
|
+
export type { ServiceAccountToken, ServiceAccountTokenCreateParams, ServiceAccountTokenRevokeParams, ServiceAccountTokenRevokeResponse } from './types.js';
|
|
15
|
+
//# sourceMappingURL=service-account-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-account-token.d.ts","sourceRoot":"","sources":["../../src/forward/service-account-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,+BAA+B,EAAE,+BAA+B,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAE3J,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,cAAc,CAQ3F;AAED,+EAA+E;AAC/E,qBAAa,oBAAqB,SAAQ,WAAW;IACnD,sFAAsF;IACtF,MAAM,CAAC,MAAM,EAAE,+BAA+B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,mBAAmB,CAAC;IAU1G,iGAAiG;IACjG,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,+BAA+B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,iCAAiC,CAAC;CAU9I;AAED,YAAY,EAAE,mBAAmB,EAAE,+BAA+B,EAAE,+BAA+B,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceAccountTokens = void 0;
|
|
4
|
+
exports.saKeyRequestOptions = saKeyRequestOptions;
|
|
5
|
+
const resource_js_1 = require("../core/resource.js");
|
|
6
|
+
const client_js_1 = require("../core/client.js");
|
|
7
|
+
const _utils_js_1 = require("./_utils.js");
|
|
8
|
+
/** @internal Per-call Key authentication overrides ordinary PAT/SAT authentication. */
|
|
9
|
+
function saKeyRequestOptions(saKey, options) {
|
|
10
|
+
if (typeof saKey !== 'string' || saKey.length === 0 || /[\u0000-\u0020\u007f]/.test(saKey)) {
|
|
11
|
+
throw new Error('saKey must be non-empty and contain no whitespace or control characters');
|
|
12
|
+
}
|
|
13
|
+
const headers = (0, client_js_1.mergeHeaders)(options?.headers);
|
|
14
|
+
headers.set('Authorization', `Bearer ${saKey}`);
|
|
15
|
+
headers.set('Content-Type', 'application/json');
|
|
16
|
+
return { ...options, headers, maxRetries: 0 };
|
|
17
|
+
}
|
|
18
|
+
/** Forward SAT issuance and revocation require an explicit SA Key per call. */
|
|
19
|
+
class ServiceAccountTokens extends resource_js_1.APIResource {
|
|
20
|
+
/** Issue an admin SAT. Automatic retries are disabled to avoid duplicate issuance. */
|
|
21
|
+
create(params, options) {
|
|
22
|
+
const { saKey, ...payload } = params;
|
|
23
|
+
return this._client.request({
|
|
24
|
+
method: 'POST',
|
|
25
|
+
path: 'service_account_tokens',
|
|
26
|
+
body: payload,
|
|
27
|
+
...saKeyRequestOptions(saKey, options),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/** Revoke a Forward SAT binding from the same SA. Creation metadata disambiguates the target. */
|
|
31
|
+
revoke(authTokenID, params, options) {
|
|
32
|
+
const path = `service_account_tokens/${(0, _utils_js_1.pathParam)(authTokenID, 'auth_token_id')}/revoke`;
|
|
33
|
+
const { saKey, ...payload } = params;
|
|
34
|
+
return this._client.request({
|
|
35
|
+
method: 'POST',
|
|
36
|
+
path,
|
|
37
|
+
body: payload,
|
|
38
|
+
...saKeyRequestOptions(saKey, options),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.ServiceAccountTokens = ServiceAccountTokens;
|
|
43
|
+
//# sourceMappingURL=service-account-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-account-token.js","sourceRoot":"","sources":["../../src/forward/service-account-token.ts"],"names":[],"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CAAC,OAAO,CAAC,OAAO,CAAoC;YAC7D,MAAM,EAAE,MAAM;YACd,IAAI;YACJ,IAAI,EAAE,OAAO;YACb,GAAG,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC;SACvC,CAAC,CAAC;IACL,CAAC;CACF;AAvBD,oDAuBC"}
|
package/dist/forward/types.d.ts
CHANGED
|
@@ -1,4 +1,39 @@
|
|
|
1
1
|
import type { Uploadable } from '../core/uploads.js';
|
|
2
|
+
export interface ServiceAccountTokenCreateParams {
|
|
3
|
+
/** SA Key sent only in this request's Authorization header; not part of the JSON body. */
|
|
4
|
+
saKey: string;
|
|
5
|
+
/** Lifetime in seconds, 1-43200. Omit to use the issuer's default. */
|
|
6
|
+
ttl_seconds?: number;
|
|
7
|
+
/** Business audit metadata; do not include credentials or other secrets. */
|
|
8
|
+
metadata?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export interface ServiceAccountTokenRevokeParams {
|
|
11
|
+
/** SA Key used only for this request. */
|
|
12
|
+
saKey: string;
|
|
13
|
+
target_credential_id?: string;
|
|
14
|
+
/** RFC 3339 expiry from the issuance response. */
|
|
15
|
+
target_expires_at?: string;
|
|
16
|
+
reason?: string;
|
|
17
|
+
}
|
|
18
|
+
/** A newly issued Forward SAT. Treat access_token and serialized responses as secrets. */
|
|
19
|
+
export interface ServiceAccountToken {
|
|
20
|
+
type: 'service_account_token';
|
|
21
|
+
access_token: string;
|
|
22
|
+
token_type: 'Bearer';
|
|
23
|
+
expires_in: number;
|
|
24
|
+
expires_at: string;
|
|
25
|
+
auth_token_id: string;
|
|
26
|
+
service_account_id: string;
|
|
27
|
+
credential_id: string;
|
|
28
|
+
subject_type: 'admin' | 'identity';
|
|
29
|
+
/** Absent for admin tokens. */
|
|
30
|
+
identity_id?: string;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
export interface ServiceAccountTokenRevokeResponse {
|
|
34
|
+
revoked: boolean;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
2
37
|
export interface BatchListParams {
|
|
3
38
|
/**
|
|
4
39
|
* 按状态过滤。
|