Skip to content

Commit 1ca081f

Browse files
committed
Format Responses adapter files with oxfmt
1 parent 7f60a43 commit 1ca081f

6 files changed

Lines changed: 48 additions & 19 deletions

File tree

src/provider/grok-responses.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,18 @@ describe("createGrokResponsesAdapter", () => {
204204
if (typeof isStreamTerminal !== "function") {
205205
throw new Error("expected isStreamTerminal to be a function");
206206
}
207-
for (const type of ["response.completed", "response.incomplete", "response.done"]) {
207+
for (const type of [
208+
"response.completed",
209+
"response.incomplete",
210+
"response.done",
211+
]) {
208212
expect(isStreamTerminal(JSON.stringify({ type }))).toBe(true);
209213
}
210-
for (const type of ["response.output_text.delta", "response.created", "response.in_progress"]) {
214+
for (const type of [
215+
"response.output_text.delta",
216+
"response.created",
217+
"response.in_progress",
218+
]) {
211219
expect(isStreamTerminal(JSON.stringify({ type }))).toBe(false);
212220
}
213221
expect(isStreamTerminal("{not json")).toBe(false);

src/provider/grok-responses.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@ export const GROK_SESSION_ID_OPTION = "grokSessionId";
1010
// Spread xAI quirks and remap only host option keys. Config still writes
1111
// grokUserId / grokSessionId / reasoning_effort; wrapping buildRequest to
1212
// alias those would hide the mismatch instead of baking the host names.
13-
export const createGrokResponsesAdapter: AdapterFactory = responsesAdapterFactory({
14-
...xaiResponsesQuirks,
15-
sessionIdOption: GROK_SESSION_ID_OPTION,
16-
headers: {
17-
...xaiResponsesQuirks.headers,
18-
fromOption: (xaiResponsesQuirks.headers?.fromOption ?? []).map((entry) =>
19-
entry.optionKey === XAI_USER_ID_OPTION ? { ...entry, optionKey: GROK_USER_ID_OPTION } : entry,
20-
),
21-
},
22-
reasoning: { ...xaiResponsesQuirks.reasoning, effortOption: "reasoning_effort" },
23-
});
13+
export const createGrokResponsesAdapter: AdapterFactory =
14+
responsesAdapterFactory({
15+
...xaiResponsesQuirks,
16+
sessionIdOption: GROK_SESSION_ID_OPTION,
17+
headers: {
18+
...xaiResponsesQuirks.headers,
19+
fromOption: (xaiResponsesQuirks.headers?.fromOption ?? []).map((entry) =>
20+
entry.optionKey === XAI_USER_ID_OPTION
21+
? { ...entry, optionKey: GROK_USER_ID_OPTION }
22+
: entry,
23+
),
24+
},
25+
reasoning: {
26+
...xaiResponsesQuirks.reasoning,
27+
effortOption: "reasoning_effort",
28+
},
29+
});

src/provider/openai-responses.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { responsesAdapterFactory, type ResponsesQuirks } from "@corbits/openai-responses";
1+
import {
2+
responsesAdapterFactory,
3+
type ResponsesQuirks,
4+
} from "@corbits/openai-responses";
25
import type { AdapterFactory } from "@intx/inference";
36
import { OPENCODE_SESSION_ID_OPTION } from "./opencode-session.js";
47

@@ -12,11 +15,14 @@ const hostQuirks: ResponsesQuirks = {
1215
path: "/responses",
1316
sessionIdOption: OPENAI_SESSION_ID_OPTION,
1417
headers: {
15-
fromOption: [{ optionKey: OPENCODE_SESSION_ID_OPTION, header: "x-opencode-session" }],
18+
fromOption: [
19+
{ optionKey: OPENCODE_SESSION_ID_OPTION, header: "x-opencode-session" },
20+
],
1621
},
1722
systemPrompt: { role: "system", shape: "string" },
1823
contentShape: "flat",
1924
reasoning: { summary: "auto" },
2025
};
2126

22-
export const createOpenAIResponsesAdapter: AdapterFactory = responsesAdapterFactory(hostQuirks);
27+
export const createOpenAIResponsesAdapter: AdapterFactory =
28+
responsesAdapterFactory(hostQuirks);

src/provider/opencode-go-adapter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import type { BuiltRequest, ProviderAdapter } from "@intx/inference";
22
import { createOpenAICompatibleAdapter } from "./openai-compatible-adapter.js";
3-
import { OPENCODE_SESSION_ID_OPTION, optionString } from "./opencode-session.js";
3+
import {
4+
OPENCODE_SESSION_ID_OPTION,
5+
optionString,
6+
} from "./opencode-session.js";
47

58
type AdapterSource = Parameters<typeof createOpenAICompatibleAdapter>[0];
69

src/provider/opencode-go-anthropic-adapter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { type BuiltRequest, type ProviderAdapter } from "@intx/inference";
22
import { createAnthropicAdapter } from "@intx/inference/providers";
3-
import { OPENCODE_SESSION_ID_OPTION, optionString } from "./opencode-session.js";
3+
import {
4+
OPENCODE_SESSION_ID_OPTION,
5+
optionString,
6+
} from "./opencode-session.js";
47

58
export const OPENCODE_GO_MESSAGES_PROVIDER = "opencode-go-messages";
69

src/provider/opencode-session.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import type { InferenceOptions } from "@intx/types/runtime";
22

33
export const OPENCODE_SESSION_ID_OPTION = "opencodeSessionId";
44

5-
export function optionString(options: InferenceOptions, key: string): string | undefined {
5+
export function optionString(
6+
options: InferenceOptions,
7+
key: string,
8+
): string | undefined {
69
const value = options.providerOptions?.[key];
710
return typeof value === "string" && value.length > 0 ? value : undefined;
811
}

0 commit comments

Comments
 (0)