Skip to content

Commit 20e27a3

Browse files
committed
feat(api): speech session improvements for API 1.1
1 parent 516aaf0 commit 20e27a3

8 files changed

Lines changed: 263 additions & 136 deletions

File tree

_carbonsteel.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"version": "1.1",
3-
"generated_at": "2026-05-07T23:13:22Z",
4-
"spec_sha": "dd2556942628d8b4:63d381c5e2045349",
3+
"generated_at": "2026-05-09T12:00:13Z",
4+
"spec_sha": "4c822a78c44f68ac:53f7f73325c83be4",
55
"files": [
66
"api.md",
77
"src/_shims/MultipartBody.ts",

src/_websocketRuntime.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
// Vendored by carbonsteel. DO NOT EDIT here in the SDK; edit
2-
// tool/carbonsteel/src/lmnt/tool/carbonsteel/codegen/node/vendor/src/_websocketRuntime.ts
3-
// in the monorepo and re-run carbonsteel.
4-
//
51
// Spec-agnostic WebSocket session helpers shared by the generated SpeechSession.
62
// MessageQueue: simple async resolver/buffer pair so the generated session can
73
// expose an `AsyncIterator` while the underlying WebSocket pushes via callbacks.
8-
// processAudioData: normalises Blob/Buffer payloads to a uniform binary type.
4+
// processBinaryFrame: normalises Blob/Buffer payloads to a uniform binary type.
95

106
import { Buffer } from 'buffer';
117
import { LmntError } from './error';
@@ -47,12 +43,12 @@ export class MessageQueue {
4743
}
4844
}
4945

50-
export async function processAudioData(audioData: Blob | Buffer): Promise<ArrayBuffer | Buffer> {
51-
if (audioData instanceof Blob) {
52-
return await audioData.arrayBuffer();
53-
} else if (audioData instanceof Buffer) {
54-
return audioData;
46+
export async function processBinaryFrame(frame: Blob | Buffer): Promise<ArrayBuffer | Buffer> {
47+
if (frame instanceof Blob) {
48+
return await frame.arrayBuffer();
49+
} else if (frame instanceof Buffer) {
50+
return frame;
5551
} else {
56-
throw new LmntError(`Unexpected message type received from server: ${audioData}`);
52+
throw new LmntError(`Unexpected message type received from server: ${frame}`);
5753
}
5854
}

src/core.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,24 @@ async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
8585
}
8686

8787
/**
88-
* Attaches `_request_id` (read from the `request-id` response header) as a non-enumerable
88+
* Attaches `request_id` (read from the `request-id` response header) as a non-enumerable
8989
* property on object responses. Skipped for arrays and non-objects (callers can read the
9090
* `request-id` header from the underlying `Response` directly via `.withResponse()`).
9191
*/
9292
export function addRequestID<T>(value: T, response: Response): T {
9393
if (!value || typeof value !== 'object' || Array.isArray(value)) {
9494
return value;
9595
}
96-
return Object.defineProperty(value, '_request_id', {
96+
return Object.defineProperty(value, 'request_id', {
9797
value: response.headers.get('request-id'),
9898
enumerable: false,
9999
}) as T;
100100
}
101101

102-
/** Optional `_request_id` field added to plain-object responses by `addRequestID`. */
102+
/** `request_id` field added to plain-object responses by `addRequestID`. */
103103
export type WithRequestID<T> =
104104
T extends Array<any> | Response ? T
105-
: T extends Record<string, any> ? T & { _request_id?: string | null }
105+
: T extends Record<string, any> ? T & { request_id: string | null }
106106
: T;
107107

108108
/**

src/error.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class APIError<
1717
readonly error: TError;
1818

1919
/** The unique identifier of the request that caused this error, matching the `request-id` response header. */
20-
readonly requestID: string | null | undefined;
20+
readonly request_id: string | null | undefined;
2121

2222
/** The `error.type` from the API response body, e.g. `"rate_limit_error"`. */
2323
readonly type: string | null;
@@ -32,7 +32,7 @@ export class APIError<
3232
super(`${APIError.makeMessage(status, error, message)}`);
3333
this.status = status;
3434
this.headers = headers;
35-
this.requestID = headers?.['request-id'] ?? undefined;
35+
this.request_id = headers?.['request-id'] ?? undefined;
3636
this.error = error;
3737
this.type = type ?? null;
3838
}

0 commit comments

Comments
 (0)