Skip to content

Commit 601f280

Browse files
authored
Merge branch 'dev' into fix/aws-sso-login
2 parents 43efbd6 + a3f7ea2 commit 601f280

97 files changed

Lines changed: 4642 additions & 2837 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
# Compare SDK types generated from Hono vs HttpApi specs.
3+
# Sorts types alphabetically so only meaningful body differences show.
4+
#
5+
# Usage: ./scripts/diff-sdk-types.sh # full diff
6+
# ./scripts/diff-sdk-types.sh --stat # summary only
7+
set -euo pipefail
8+
9+
DIR="$(cd "$(dirname "$0")/.." && pwd)"
10+
SDK="$(cd "$DIR/../sdk/js" && pwd)"
11+
12+
normalize() {
13+
python3 -c "
14+
import re, sys
15+
content = open(sys.argv[1]).read()
16+
blocks = re.split(r'(?=^export (?:type|function|const) )', content, flags=re.MULTILINE)
17+
header, body = blocks[0], blocks[1:]
18+
body.sort(key=lambda b: m.group(1) if (m := re.match(r'export \w+ (\w+)', b)) else '')
19+
sys.stdout.write(header + ''.join(body))
20+
" "$1"
21+
}
22+
23+
echo "Generating Hono SDK..." >&2
24+
(cd "$SDK" && bun run script/build.ts >/dev/null 2>&1)
25+
normalize "$SDK/src/v2/gen/types.gen.ts" > /tmp/sdk-types-hono.ts
26+
git -C "$SDK" checkout -- src/ 2>/dev/null
27+
28+
echo "Generating HttpApi SDK..." >&2
29+
(cd "$SDK" && OPENCODE_SDK_OPENAPI=httpapi bun run script/build.ts >/dev/null 2>&1)
30+
normalize "$SDK/src/v2/gen/types.gen.ts" > /tmp/sdk-types-httpapi.ts
31+
git -C "$SDK" checkout -- src/ 2>/dev/null
32+
33+
echo "" >&2
34+
if [[ "${1:-}" == "--stat" ]]; then
35+
diff_output=$(diff /tmp/sdk-types-hono.ts /tmp/sdk-types-httpapi.ts || true)
36+
honly=$(printf "%s\n" "$diff_output" | grep -c '^< export type' || true)
37+
aonly=$(printf "%s\n" "$diff_output" | grep -c '^> export type' || true)
38+
total=$(printf "%s\n" "$diff_output" | wc -l | tr -d ' ')
39+
echo "Hono-only: $honly types HttpApi-only: $aonly types Diff lines: $total"
40+
echo ""
41+
if [[ $honly -gt 0 ]]; then
42+
echo "=== Hono-only types ==="
43+
printf "%s\n" "$diff_output" | grep '^< export type' | sed 's/< export type //' | sed 's/[ =].*//' | sed 's/^/ /'
44+
echo ""
45+
fi
46+
if [[ $aonly -gt 0 ]]; then
47+
echo "=== HttpApi-only types ==="
48+
printf "%s\n" "$diff_output" | grep '^> export type' | sed 's/> export type //' | sed 's/[ =].*//' | sed 's/^/ /'
49+
fi
50+
else
51+
diff /tmp/sdk-types-hono.ts /tmp/sdk-types-httpapi.ts || true
52+
fi

packages/opencode/specs/effect/http-api.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ Required before route deletion:
129129
- Compare generated SDK output against `dev` for every route group deletion.
130130
- Remove Hono OpenAPI stubs only after Effect OpenAPI is the SDK source for those paths.
131131

132+
V2 cleanup once SDK compatibility no longer needs the legacy Hono contract:
133+
134+
- Remove `public.ts` compatibility transforms that hide honest `HttpApi` metadata, including auth `securitySchemes`, per-route `security`, and generated `401` responses.
135+
- Stop remapping built-in `HttpApi` error schemas back to legacy Hono `BadRequestError` / `NotFoundError` components if V2 clients can consume the actual Effect error shape.
136+
- Prefer the direct `HttpApi` OpenAPI output for request/response bodies and named component schemas instead of rewriting it to match Hono generator quirks.
137+
- Keep schema fixes that describe the actual wire format, but delete transforms that only preserve legacy SDK type names or inline-vs-ref shape.
138+
- Re-evaluate `auth_token` as an OpenAPI security scheme rather than a hand-injected query parameter once clients can consume the V2 spec.
139+
132140
### 5. Make HttpApi Default For JSON Routes
133141

134142
After JSON parity and SDK generation are covered:

packages/opencode/src/agent/agent.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export const Info = Schema.Struct({
3131
mode: Schema.Literals(["subagent", "primary", "all"]),
3232
native: Schema.optional(Schema.Boolean),
3333
hidden: Schema.optional(Schema.Boolean),
34-
topP: Schema.optional(Schema.Number),
35-
temperature: Schema.optional(Schema.Number),
34+
topP: Schema.optional(Schema.Finite),
35+
temperature: Schema.optional(Schema.Finite),
3636
color: Schema.optional(Schema.String),
3737
permission: Permission.Ruleset,
3838
model: Schema.optional(
@@ -44,7 +44,7 @@ export const Info = Schema.Struct({
4444
variant: Schema.optional(Schema.String),
4545
prompt: Schema.optional(Schema.String),
4646
options: Schema.Record(Schema.String, Schema.Unknown),
47-
steps: Schema.optional(Schema.Number),
47+
steps: Schema.optional(Schema.Finite),
4848
})
4949
.annotate({ identifier: "Agent" })
5050
.pipe(withStatics((s) => ({ zod: zod(s) })))

packages/opencode/src/auth/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from "path"
22
import { Effect, Layer, Record, Result, Schema, Context } from "effect"
33
import { zod } from "@/util/effect-zod"
4+
import { NonNegativeInt } from "@/util/schema"
45
import { Global } from "@opencode-ai/core/global"
56
import { AppFileSystem } from "@opencode-ai/core/filesystem"
67

@@ -14,7 +15,7 @@ export class Oauth extends Schema.Class<Oauth>("OAuth")({
1415
type: Schema.Literal("oauth"),
1516
refresh: Schema.String,
1617
access: Schema.String,
17-
expires: Schema.Number,
18+
expires: NonNegativeInt,
1819
accountId: Schema.optional(Schema.String),
1920
enterpriseUrl: Schema.optional(Schema.String),
2021
}) {}

packages/opencode/src/bus/bus-event.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,16 @@ export function payloads() {
3434
.toArray()
3535
}
3636

37+
export function effectPayloads() {
38+
return registry
39+
.entries()
40+
.map(([type, def]) =>
41+
Schema.Struct({
42+
type: Schema.Literal(type),
43+
properties: def.properties,
44+
}).annotate({ identifier: `Event.${type}` }),
45+
)
46+
.toArray()
47+
}
48+
3749
export * as BusEvent from "./bus-event"

packages/opencode/src/cli/cmd/tui/event.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BusEvent } from "@/bus/bus-event"
22
import { SessionID } from "@/session/schema"
3+
import { PositiveInt } from "@/util/schema"
34
import { Effect, Schema } from "effect"
45

56
const DEFAULT_TOAST_DURATION = 5000
@@ -38,7 +39,7 @@ export const TuiEvent = {
3839
title: Schema.optional(Schema.String),
3940
message: Schema.String,
4041
variant: Schema.Literals(["info", "success", "warning", "error"]),
41-
duration: Schema.Number.pipe(Schema.withDecodingDefault(Effect.succeed(DEFAULT_TOAST_DURATION))).annotate({
42+
duration: PositiveInt.pipe(Schema.withDecodingDefault(Effect.succeed(DEFAULT_TOAST_DURATION))).annotate({
4243
description: "Duration in milliseconds",
4344
}),
4445
}),

packages/opencode/src/config/agent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const AgentSchema = Schema.StructWithRest(
2626
variant: Schema.optional(Schema.String).annotate({
2727
description: "Default model variant for this agent (applies only when using the agent's configured model).",
2828
}),
29-
temperature: Schema.optional(Schema.Number),
30-
top_p: Schema.optional(Schema.Number),
29+
temperature: Schema.optional(Schema.Finite),
30+
top_p: Schema.optional(Schema.Finite),
3131
prompt: Schema.optional(Schema.String),
3232
tools: Schema.optional(Schema.Record(Schema.String, Schema.Boolean)).annotate({
3333
description: "@deprecated Use 'permission' field instead",

packages/opencode/src/config/console-state.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Schema } from "effect"
22
import { zod } from "@/util/effect-zod"
3+
import { NonNegativeInt } from "@/util/schema"
34

45
export class ConsoleState extends Schema.Class<ConsoleState>("ConsoleState")({
56
consoleManagedProviders: Schema.mutable(Schema.Array(Schema.String)),
67
activeOrgName: Schema.optional(Schema.String),
7-
switchableOrgCount: Schema.Number,
8+
switchableOrgCount: NonNegativeInt,
89
}) {
910
static readonly zod = zod(this)
1011
}

packages/opencode/src/config/mcp.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Schema } from "effect"
22
import { zod } from "@/util/effect-zod"
3-
import { withStatics } from "@/util/schema"
3+
import { PositiveInt, withStatics } from "@/util/schema"
44

55
export const Local = Schema.Struct({
66
type: Schema.Literal("local").annotate({ description: "Type of MCP server connection" }),
@@ -13,7 +13,7 @@ export const Local = Schema.Struct({
1313
enabled: Schema.optional(Schema.Boolean).annotate({
1414
description: "Enable or disable the MCP server on startup",
1515
}),
16-
timeout: Schema.optional(Schema.Number).annotate({
16+
timeout: Schema.optional(PositiveInt).annotate({
1717
description: "Timeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified.",
1818
}),
1919
})
@@ -49,7 +49,7 @@ export const Remote = Schema.Struct({
4949
oauth: Schema.optional(Schema.Union([OAuth, Schema.Literal(false)])).annotate({
5050
description: "OAuth authentication configuration for the MCP server. Set to false to disable OAuth auto-detection.",
5151
}),
52-
timeout: Schema.optional(Schema.Number).annotate({
52+
timeout: Schema.optional(PositiveInt).annotate({
5353
description: "Timeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified.",
5454
}),
5555
})

packages/opencode/src/config/provider.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@ export const Model = Schema.Struct({
2121
),
2222
cost: Schema.optional(
2323
Schema.Struct({
24-
input: Schema.Number,
25-
output: Schema.Number,
26-
cache_read: Schema.optional(Schema.Number),
27-
cache_write: Schema.optional(Schema.Number),
24+
input: Schema.Finite,
25+
output: Schema.Finite,
26+
cache_read: Schema.optional(Schema.Finite),
27+
cache_write: Schema.optional(Schema.Finite),
2828
context_over_200k: Schema.optional(
2929
Schema.Struct({
30-
input: Schema.Number,
31-
output: Schema.Number,
32-
cache_read: Schema.optional(Schema.Number),
33-
cache_write: Schema.optional(Schema.Number),
30+
input: Schema.Finite,
31+
output: Schema.Finite,
32+
cache_read: Schema.optional(Schema.Finite),
33+
cache_write: Schema.optional(Schema.Finite),
3434
}),
3535
),
3636
}),
3737
),
3838
limit: Schema.optional(
3939
Schema.Struct({
40-
context: Schema.Number,
41-
input: Schema.optional(Schema.Number),
42-
output: Schema.Number,
40+
context: Schema.Finite,
41+
input: Schema.optional(Schema.Finite),
42+
output: Schema.Finite,
4343
}),
4444
),
4545
modalities: Schema.optional(

0 commit comments

Comments
 (0)