Skip to content

Commit 72223c7

Browse files
fix: bound Open Design HTTP and SSE transport (#8)
Merge reviewed bounded Open Design HTTP and SSE transport fix for issue #8.
1 parent 66bb621 commit 72223c7

7 files changed

Lines changed: 655 additions & 103 deletions

File tree

docs/open-design.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ Do not use project or file URLs.
2323
## Security
2424

2525
Do not expose Open Design directly to the Internet without authentication, VPN, Tailscale, WireGuard, or a secure reverse proxy.
26+
27+
## Runtime budgets
28+
29+
The Open Design client uses fixed safety budgets for remote calls: 5 seconds to
30+
receive response headers, 15 seconds of read-idle time, 120 seconds total per
31+
request, 1 MiB for JSON responses, 8 MiB for SSE responses, 2 MiB per stdout or
32+
stderr channel, and 10,000 SSE events. Oversized, stalled, or incomplete
33+
responses fail with a bounded diagnostic instead of being retained indefinitely.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
export type OpenDesignHttpOptions = {
2+
fetchImpl?: typeof fetch
3+
connectTimeoutMs?: number
4+
totalTimeoutMs?: number
5+
idleTimeoutMs?: number
6+
maxJsonBytes?: number
7+
maxSseBytes?: number
8+
maxOutputBytes?: number
9+
maxEvents?: number
10+
maxDiagnosticBytes?: number
11+
}
12+
13+
export const OPEN_DESIGN_HTTP_LIMITS: Readonly<{
14+
connectTimeoutMs: number
15+
totalTimeoutMs: number
16+
idleTimeoutMs: number
17+
maxJsonBytes: number
18+
maxSseBytes: number
19+
maxOutputBytes: number
20+
maxEvents: number
21+
maxDiagnosticBytes: number
22+
}>
23+
24+
export function requestJson(
25+
base: string,
26+
path: string,
27+
init?: RequestInit,
28+
options?: OpenDesignHttpOptions,
29+
): Promise<unknown>
30+
31+
export function parseSseFrames(buffer: string): {
32+
frames: Array<{ event: string; data: unknown }>
33+
rest: string
34+
}
35+
36+
export function streamOpenDesignChat(
37+
base: string,
38+
body: unknown,
39+
options?: OpenDesignHttpOptions,
40+
): Promise<{
41+
stdout: string
42+
stderr: string
43+
end: unknown
44+
eventsCount: number
45+
}>

0 commit comments

Comments
 (0)