@opencode-ai/ai 0.0.0-dev-17814 → 0.0.0-dev-17822

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.
@@ -4,6 +4,8 @@ export interface Options {
4
4
  readonly id: string;
5
5
  readonly name: string;
6
6
  readonly rotateAfterMs?: number;
7
+ readonly enabled?: (url: string) => boolean;
8
+ readonly url?: (url: string) => string;
7
9
  readonly headers?: (headers: Headers.Headers) => Headers.Headers;
8
10
  readonly driver?: (input: {
9
11
  readonly request: Readonly<Record<string, unknown>>;
@@ -79,12 +79,12 @@ export const transport = (options) => {
79
79
  prepare: (input) => Effect.gen(function* () {
80
80
  const parts = yield* HttpTransport.jsonRequestParts(input);
81
81
  const headers = Headers.remove(options.headers?.(parts.headers) ?? parts.headers, "content-length");
82
- const channel = input.webSocket
82
+ const channel = input.webSocket && (options.enabled?.(parts.url) ?? true)
83
83
  ? yield* Effect.gen(function* () {
84
84
  const create = yield* message(parts.jsonBody);
85
85
  const base = driver(options, create.message);
86
86
  return {
87
- url: yield* WebSocketTransport.toWebSocketUrl(parts.url),
87
+ url: yield* WebSocketTransport.toWebSocketUrl(options.url?.(parts.url) ?? parts.url),
88
88
  headers,
89
89
  rotateAfterMs: options.rotateAfterMs,
90
90
  driver: options.driver?.({ request: create.request, message: create.message, base }) ?? base,
@@ -1,3 +1,4 @@
1
+ import { Headers } from "effect/unstable/http";
1
2
  import { Auth } from "../route/auth.js";
2
3
  import {} from "../route/auth-options.js";
3
4
  import { ProviderID } from "../schema/index.js";
@@ -7,11 +8,35 @@ import { ProviderShared } from "../protocols/shared.js";
7
8
  import { withOpenAIOptions } from "./openai-options.js";
8
9
  export const id = ProviderID.make("azure");
9
10
  const routeAuth = Auth.remove("authorization");
11
+ const RESPONSES_WEBSOCKET_ROTATE_AFTER_MS = 55 * 60 * 1000;
10
12
  const resourceBaseURL = (resourceName) => `https://${resourceName.trim()}.openai.azure.com/openai`;
11
13
  const responsesRoute = OpenAIResponses.route.with({
12
14
  id: "azure-openai-responses",
13
15
  provider: id,
14
16
  auth: routeAuth,
17
+ transport: OpenAIResponses.channelTransport({
18
+ id: "azure-openai-responses",
19
+ name: "Azure OpenAI Responses",
20
+ rotateAfterMs: RESPONSES_WEBSOCKET_ROTATE_AFTER_MS,
21
+ enabled: (value) => {
22
+ const url = new URL(value);
23
+ return (url.protocol === "https:" &&
24
+ url.hostname.endsWith(".openai.azure.com") &&
25
+ url.pathname.endsWith("/openai/v1/responses") &&
26
+ url.searchParams.get("api-version") === "v1");
27
+ },
28
+ url: (value) => {
29
+ const url = new URL(value);
30
+ url.searchParams.delete("api-version");
31
+ return url.toString();
32
+ },
33
+ headers: (headers) => {
34
+ const apiKey = headers["api-key"];
35
+ if (!apiKey)
36
+ return headers;
37
+ return Headers.remove(Headers.set(headers, "authorization", `Bearer ${apiKey}`), "api-key");
38
+ },
39
+ }),
15
40
  });
16
41
  const chatRoute = OpenAIChat.route.with({
17
42
  id: "azure-openai-chat",
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-17814",
3
+ "version": "0.0.0-dev-17822",
4
4
  "name": "@opencode-ai/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "devDependencies": {
31
31
  "@clack/prompts": "1.0.0-alpha.1",
32
32
  "@effect/platform-node": "4.0.0-rc.110",
33
- "@opencode-ai/http-recorder": "0.0.0-dev-17814",
33
+ "@opencode-ai/http-recorder": "0.0.0-dev-17822",
34
34
  "@tsconfig/bun": "1.0.9",
35
35
  "@types/bun": "1.3.13",
36
36
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@smithy/eventstream-codec": "4.2.14",
41
41
  "@smithy/util-utf8": "4.2.2",
42
- "@opencode-ai/schema": "0.0.0-dev-17814",
42
+ "@opencode-ai/schema": "0.0.0-dev-17822",
43
43
  "aws4fetch": "1.0.20",
44
44
  "effect": "4.0.0-rc.110",
45
45
  "google-auth-library": "10.5.0"