Skip to content

Commit 52e811b

Browse files
Merge pull request #862 from corbitsdev/cl-7423-corbits-code-switch-the-grok-and-opencode-go-responses
Switch Grok and OpenCode Go Responses to the shared packages
2 parents 396339a + 1ca081f commit 52e811b

17 files changed

Lines changed: 131 additions & 566 deletions

bun.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,23 @@
8080
"tar": "^7.5.1"
8181
},
8282
"dependencies": {
83+
"@corbits/openai-responses": "github:corbitsdev/corbits-openai-responses",
84+
"@corbits/xai-provider": "github:corbitsdev/corbits-xai-provider",
8385
"@intx/agent": "workspace:*",
8486
"@intx/authz": "workspace:*",
8587
"@intx/crypto": "0.3.0",
88+
"@intx/harness": "workspace:*",
89+
"@intx/hub-sessions": "0.3.0",
8690
"@intx/inference": "workspace:*",
8791
"@intx/log": "workspace:*",
92+
"@intx/mail-memory": "0.3.0",
93+
"@intx/mailbox": "workspace:*",
94+
"@intx/mime": "workspace:*",
8895
"@intx/storage-isogit": "workspace:*",
8996
"@intx/tools-lsp": "0.3.0",
9097
"@intx/tools-posix": "workspace:*",
91-
"@intx/mailbox": "workspace:*",
92-
"@intx/harness": "workspace:*",
93-
"@intx/mime": "workspace:*",
94-
"@intx/mail-memory": "0.3.0",
95-
"@intx/hub-sessions": "0.3.0",
96-
"@intx/workflow-host": "0.3.0",
9798
"@intx/types": "workspace:*",
99+
"@intx/workflow-host": "0.3.0",
98100
"@modelcontextprotocol/sdk": "^1.29.0",
99101
"@opentui/core": "0.5.10",
100102
"arktype": "catalog:",

src/config/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ import {
4646
GROK_RESPONSES_PROVIDER,
4747
GROK_SESSION_ID_OPTION,
4848
GROK_USER_ID_OPTION,
49-
} from "../provider/grok-responses-adapter.js";
49+
} from "../provider/grok-responses.js";
5050
import { BIFROST_PROVIDER } from "../provider/bifrost-adapter.js";
5151
import { isOllamaProviderId, ollamaOpenAIBaseURL } from "../provider/ollama.js";
5252
import { selectableGoModelIds } from "../provider/opencode-go-models.js";
5353
import {
5454
OPENAI_RESPONSES_PROVIDER,
5555
OPENAI_SESSION_ID_OPTION,
56-
OPENCODE_SESSION_ID_OPTION,
57-
} from "../provider/openai-responses-adapter.js";
56+
} from "../provider/openai-responses.js";
57+
import { OPENCODE_SESSION_ID_OPTION } from "../provider/opencode-session.js";
5858
import { OPENCODE_GO_MESSAGES_PROVIDER } from "../provider/opencode-go-anthropic-adapter.js";
5959
import { xaiUserIdFromAccessToken } from "../auth/xai/session.js";
6060
import {

src/provider/grok-responses-adapter.ts

Lines changed: 0 additions & 278 deletions
This file was deleted.

src/provider/grok-responses-adapter.test.ts renamed to src/provider/grok-responses.test.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, test } from "bun:test";
22
import type { ConversationTurn, LastCycleSource } from "@intx/types/runtime";
3-
import { createGrokResponsesAdapter } from "./grok-responses-adapter.js";
3+
import { createGrokResponsesAdapter } from "./grok-responses.js";
44

55
const source: LastCycleSource = {
66
sourceId: "xai/test",
@@ -196,4 +196,30 @@ describe("createGrokResponsesAdapter", () => {
196196
).toBe(1_500);
197197
expect(adapter.extractRetryAfterMs?.(new Headers({}))).toBeUndefined();
198198
});
199+
200+
test("treats Responses completed, incomplete, and done events as stream-terminal", () => {
201+
const adapter = createGrokResponsesAdapter(source);
202+
const isStreamTerminal = adapter.isStreamTerminal;
203+
expect(typeof isStreamTerminal).toBe("function");
204+
if (typeof isStreamTerminal !== "function") {
205+
throw new Error("expected isStreamTerminal to be a function");
206+
}
207+
for (const type of [
208+
"response.completed",
209+
"response.incomplete",
210+
"response.done",
211+
]) {
212+
expect(isStreamTerminal(JSON.stringify({ type }))).toBe(true);
213+
}
214+
for (const type of [
215+
"response.output_text.delta",
216+
"response.created",
217+
"response.in_progress",
218+
]) {
219+
expect(isStreamTerminal(JSON.stringify({ type }))).toBe(false);
220+
}
221+
expect(isStreamTerminal("{not json")).toBe(false);
222+
expect(isStreamTerminal("null")).toBe(false);
223+
expect(isStreamTerminal('"just a string"')).toBe(false);
224+
});
199225
});

0 commit comments

Comments
 (0)