Skip to content

Commit b7fe86c

Browse files
authored
Merge branch 'main' into fix/pwa-installable
2 parents 4ef3916 + 3feae3a commit b7fe86c

6 files changed

Lines changed: 117 additions & 32 deletions

File tree

‎apps/server/src/serverSettings.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,7 @@ it.layer(NodeServices.layer)("server settings", (it) => {
809809
});
810810

811811
assert.equal(next.textGenerationModelSelection.instanceId, "claudeAgent");
812+
assert.equal(next.textGenerationModelSelection.model, "claude-haiku-5-5");
812813
}).pipe(Effect.provide(layerServerSettings())),
813814
);
814815

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@shadcn/lint": "0.1.5",
5757
"@types/node": "catalog:",
5858
"knip": "6.34.0",
59-
"tsc-rs": "0.4.0",
59+
"tsc-rs": "0.6.0",
6060
"typescript": "catalog:",
6161
"vite-plus": "catalog:"
6262
},

‎packages/contracts/src/model.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export const DEFAULT_TEXT_GENERATION_MODEL_BY_PROVIDER: Partial<
192192
> = {
193193
[CODEX_DRIVER_KIND]: DEFAULT_TEXT_GENERATION_MODEL,
194194
[ProviderDriverKind.make("antigravity")]: ANTIGRAVITY_DEFAULT_MODEL,
195-
[CLAUDE_DRIVER_KIND]: "claude-haiku-4-5",
195+
[CLAUDE_DRIVER_KIND]: "claude-haiku-5-5",
196196
[CURSOR_DRIVER_KIND]: "composer-2",
197197
[OPENCODE_DRIVER_KIND]: "openai/gpt-5",
198198
};
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import * as NodeAssert from "node:assert/strict";
2+
3+
import * as Cause from "effect/Cause";
4+
import { describe, it } from "vite-plus/test";
5+
6+
import { OpenCodeRuntimeError, openCodeRuntimeErrorDetail } from "./OpenCodeRuntime.ts";
7+
8+
describe("openCodeRuntimeErrorDetail", () => {
9+
it("formats an Effect TimeoutError constructed without a message", () => {
10+
const detail = openCodeRuntimeErrorDetail(new Cause.TimeoutError());
11+
NodeAssert.equal(typeof detail, "string");
12+
NodeAssert.match(detail, /TimeoutError/);
13+
});
14+
15+
it("returns the detail of an OpenCodeRuntimeError", () => {
16+
const error = new OpenCodeRuntimeError({ operation: "session.abort", detail: "aborted" });
17+
NodeAssert.equal(openCodeRuntimeErrorDetail(error), "aborted");
18+
});
19+
20+
it("returns a trimmed Error message", () => {
21+
NodeAssert.equal(openCodeRuntimeErrorDetail(new Error(" timed out ")), "timed out");
22+
});
23+
24+
it("reads an Error message getter only once", () => {
25+
const error = new Error();
26+
let reads = 0;
27+
Object.defineProperty(error, "message", {
28+
get() {
29+
reads += 1;
30+
if (reads > 1) throw new Error("message was read twice");
31+
return " timed out ";
32+
},
33+
});
34+
35+
NodeAssert.equal(openCodeRuntimeErrorDetail(error), "timed out");
36+
NodeAssert.equal(reads, 1);
37+
});
38+
39+
it("does not throw for an Error whose message is undefined", () => {
40+
// Effect's TimeoutError constructed without an argument arrives this way.
41+
const error = new Error("placeholder");
42+
Object.defineProperty(error, "message", { value: undefined, writable: true });
43+
const detail = openCodeRuntimeErrorDetail(error);
44+
NodeAssert.equal(typeof detail, "string");
45+
NodeAssert.ok(detail.length > 0);
46+
});
47+
48+
it("does not throw for an Error whose message is not a string", () => {
49+
const error = new Error("placeholder");
50+
Object.defineProperty(error, "message", { value: { code: 42 }, writable: true });
51+
const detail = openCodeRuntimeErrorDetail(error);
52+
NodeAssert.equal(typeof detail, "string");
53+
NodeAssert.ok(detail.length > 0);
54+
});
55+
56+
it("falls through to the object fallback for an Error with an empty message", () => {
57+
const error = Object.assign(new Error(""), { response: { status: 503 }, error: "down" });
58+
NodeAssert.equal(openCodeRuntimeErrorDetail(error), 'status=503 body="down"');
59+
});
60+
61+
it("formats SDK response shapes", () => {
62+
NodeAssert.equal(
63+
openCodeRuntimeErrorDetail({ response: { status: 500 }, error: { message: "boom" } }),
64+
'status=500 body={"message":"boom"}',
65+
);
66+
});
67+
68+
it("stringifies primitives", () => {
69+
NodeAssert.equal(openCodeRuntimeErrorDetail("plain"), "plain");
70+
NodeAssert.equal(openCodeRuntimeErrorDetail(undefined), "undefined");
71+
});
72+
});

‎packages/provider-opencode/src/server/OpenCodeRuntime.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,21 @@ function encodeJsonStringForDiagnostics(input: unknown): string | undefined {
117117
return Exit.isSuccess(result) ? result.value : undefined;
118118
}
119119

120+
/**
121+
* Formats OpenCode SDK and runtime failures, including errors with missing or
122+
* non-string messages.
123+
*/
120124
export function openCodeRuntimeErrorDetail(cause: unknown): string {
121125
if (isOpenCodeRuntimeError(cause)) return cause.detail;
122-
if (cause instanceof Error && cause.message.trim().length > 0) return cause.message.trim();
126+
// Effect's TimeoutError can be constructed without a message, so `message`
127+
// is not guaranteed to be a string on every Error that reaches here.
128+
if (cause instanceof Error) {
129+
const message = cause.message;
130+
if (typeof message === "string") {
131+
const trimmedMessage = message.trim();
132+
if (trimmedMessage.length > 0) return trimmedMessage;
133+
}
134+
}
123135
if (cause && typeof cause === "object") {
124136
// SDK v2 throws { response, request, error? } shapes — extract what's useful
125137
const anyCause = cause as Record<string, unknown>;

‎pnpm-lock.yaml‎

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

0 commit comments

Comments
 (0)