@opencode/ai 0.0.0-dev-21340 → 0.0.0-dev-21351
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.
|
@@ -28,7 +28,10 @@ export const connect = Effect.fn("Realtime.connect")(function* (input) {
|
|
|
28
28
|
}
|
|
29
29
|
case "openai-realtime": {
|
|
30
30
|
if (input.transport.type === "websocket")
|
|
31
|
-
return yield* clientSecret(resolved.id, OPENAI_BASE_URL, input.model, input.apiKey,
|
|
31
|
+
return yield* clientSecret(resolved.id, OPENAI_BASE_URL, input.model, input.apiKey, {
|
|
32
|
+
expires_after: { anchor: "created_at", seconds: 60 },
|
|
33
|
+
session,
|
|
34
|
+
});
|
|
32
35
|
const form = new FormData();
|
|
33
36
|
form.append("sdp", input.transport.sdp);
|
|
34
37
|
form.append("session", encodeJson(session));
|
|
@@ -39,7 +42,9 @@ export const connect = Effect.fn("Realtime.connect")(function* (input) {
|
|
|
39
42
|
case "xai-realtime": {
|
|
40
43
|
if (input.transport.type !== "websocket")
|
|
41
44
|
return yield* invalidRequest("xAI Grok Voice only supports WebSocket transport");
|
|
42
|
-
return yield* clientSecret(resolved.id, XAI_BASE_URL, input.model, input.apiKey
|
|
45
|
+
return yield* clientSecret(resolved.id, XAI_BASE_URL, input.model, input.apiKey, {
|
|
46
|
+
expires_after: { seconds: 60 },
|
|
47
|
+
});
|
|
43
48
|
}
|
|
44
49
|
case "gemini-live": {
|
|
45
50
|
if (input.transport.type !== "websocket")
|
|
@@ -69,7 +74,7 @@ const LiveSessionResponse = Schema.fromJsonString(Schema.Struct({
|
|
|
69
74
|
transport: Schema.Struct({ sdp: Schema.String }),
|
|
70
75
|
}));
|
|
71
76
|
// xAI's ephemeral-token docs (https://docs.x.ai/developers/model-capabilities/audio/ephemeral-tokens)
|
|
72
|
-
// document the request body (`{ expires_after: { seconds } }`) but not the response payload; we assume
|
|
77
|
+
// document the request body (`{ expires_after: { seconds } }`, no `anchor` or `session`) but not the response payload; we assume
|
|
73
78
|
// it mirrors OpenAI's `{ value, expires_at }` response shape.
|
|
74
79
|
const ClientSecretResponse = Schema.fromJsonString(Schema.Struct({
|
|
75
80
|
value: Schema.String,
|
|
@@ -91,7 +96,7 @@ const post = (route, url, apiKey, body, response, authHeader) => Effect.gen(func
|
|
|
91
96
|
const text = yield* res.text.pipe(Effect.mapError((cause) => fail(`Failed to read ${route} response`, cause)));
|
|
92
97
|
return yield* Schema.decodeEffect(response)(text).pipe(Effect.mapError((cause) => fail(`${route} returned an invalid response`, cause, text)));
|
|
93
98
|
});
|
|
94
|
-
const clientSecret = (route, baseURL, model, apiKey,
|
|
99
|
+
const clientSecret = (route, baseURL, model, apiKey, body) => post(route, `${baseURL}/realtime/client_secrets`, apiKey, body, ClientSecretResponse).pipe(Effect.map((data) => ({
|
|
95
100
|
type: "websocket",
|
|
96
101
|
url: `${baseURL.replace(/^http/, "ws")}/realtime?model=${encodeURIComponent(model)}`,
|
|
97
102
|
token: data.value,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-21351",
|
|
4
4
|
"name": "@opencode/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
36
36
|
"@effect/platform-node": "4.0.1",
|
|
37
|
-
"@opencode/http-recorder": "0.0.0-dev-
|
|
37
|
+
"@opencode/http-recorder": "0.0.0-dev-21351",
|
|
38
38
|
"@tsconfig/bun": "1.0.9",
|
|
39
39
|
"@types/bun": "1.4.0",
|
|
40
40
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@aws-sdk/credential-providers": "3.1057.0",
|
|
45
45
|
"@smithy/eventstream-codec": "4.2.14",
|
|
46
46
|
"@smithy/util-utf8": "4.2.2",
|
|
47
|
-
"@opencode/schema": "0.0.0-dev-
|
|
47
|
+
"@opencode/schema": "0.0.0-dev-21351",
|
|
48
48
|
"aws4fetch": "1.0.20",
|
|
49
49
|
"effect": "4.0.1",
|
|
50
50
|
"google-auth-library": "10.5.0"
|