Repository navigation
feat(stream): delta-only message updates from omp to the browser #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
85 commits
Select commit
Hold shift + click to select a range
94b9e8f
docs: WebSocket host link spec and plan
andrebrait 1d1bcac
docs: record the WebSocket link probe
andrebrait a11955a
feat(hosts): ack message, close codes and binary result frames for th…
andrebrait 2fd9469
feat(hosts): the host daemon links over one WebSocket
andrebrait e91c6db
fix(hosts): no dial after stop; contain handler errors
andrebrait a6fcb7b
feat(hosts): the web server takes host links over one WebSocket
andrebrait dd24dda
fix(hosts): refuse a revoked host's hello, cap the first frame, conta…
andrebrait 1b9372e
test(hosts): run the link integration test over a real WebSocket
andrebrait bea3904
fix(hosts): pace the downlink from the outbox instead of bursting
andrebrait c7e2b6b
docs: describe the WebSocket host link
andrebrait 7d364a5
docs: correct shutdown close, stale rows and the slow-link floor
andrebrait fe5c923
docs: the ai-web proxy is Traefik, not nginx
andrebrait ac5c4dd
docs(hosts): design link pieces and fair sending (protocol 5)
andrebrait 5871623
feat(hosts): link protocol 5 sends large messages in fair 256 KiB pieces
andrebrait 807e8e4
docs(hosts): describe link pieces and fair sending (protocol 5)
andrebrait 381fd2c
fix(hosts): sender and joiner bounds for link pieces
andrebrait f6c6326
fix(hosts): bound unacked link data below the socket in both directions
andrebrait f934e9e
docs(hosts): describe the unacked link window
andrebrait b34c61d
fix(hosts): no unacked window for v4 daemons; pin the window and rese…
andrebrait 1f912d7
docs(hosts): v4 daemons get no unacked window
andrebrait cc67982
fix(hosts): unacked link window of 2 pieces (512 KiB), not 4
andrebrait 0f6222f
docs: label the remote host link WebSocket in the architecture diagrams
andrebrait 3a8284c
docs: link protocol version 5 with minimum 4; a v4 daemon links besid…
andrebrait 312273a
docs: browser transport experiment spec and plan
andrebrait 6b7f972
refactor(agent): share the command path; timing headers on /api/agent…
andrebrait c52e3d6
test(agent): cover the shared command path by behaviour
andrebrait 67ad8f4
feat(events): browserTransport setting, emit times and transport cont…
andrebrait 6fc9da9
fix(events): stamp coalesced updates with their own emit time
andrebrait 60be575
feat(events): browser WebSocket endpoint with command dedupe
andrebrait 3575a4c
fix(events): scope command dedupe to the session; assert the server ping
andrebrait a2bddf2
feat(metrics): transport sample endpoint, JSONL store and summary script
andrebrait 6768cbe
fix(metrics): owner-only file, stable report sections, answered-later…
andrebrait 0126563
feat(worker): WebSocket mode with a general socket and one per session
andrebrait 6ac7bc0
fix(worker): no ??= in the worker; one redial per wake burst
andrebrait 710e518
feat(worker): agent commands over the session socket
andrebrait b090cd2
docs: socket assignment modes for the browser transport experiment
andrebrait a1b53bc
fix(worker): check retiring sockets, spare unacked uploads, treat tra…
andrebrait 7426683
feat(events): every browser socket carries any session
andrebrait 8d0b44d
feat(worker): ws-client, ws-session and ws-pool modes with make-befor…
andrebrait bb86f9c
fix(worker): keep a session's commands in order across a move
andrebrait d32dc48
feat(worker): ws-pool sized from active sessions with rendezvous buckets
andrebrait 02c7b7b
fix(worker): pool tests catch a missing shrink cancel; correct rebala…
andrebrait 6dd6f45
feat(metrics): instrument every browser transport
andrebrait dafd84e
fix(metrics): measure every transport the same way
andrebrait cded548
fix(metrics): drop a held SSE frame when SSE closes
andrebrait 3c312a9
feat(settings): browser transport modes in Settings; document the exp…
andrebrait 6bef7e7
fix(settings): save pool drafts only on blur or Enter
andrebrait 979545d
fix(metrics): separate detector reconnects and apply the upload floor
andrebrait 42521f3
fix(worker): subscribe before probing and cover transport edge cases
andrebrait ead24fa
refactor(transport): remove unused GET timing and mode accessor
andrebrait 97dc202
test(metrics): skip the POSIX mode check on Windows, like the notific…
andrebrait 6ef3381
feat(worker): ws-client-split mode, one shared socket for all sessions
andrebrait bbc84f9
test(worker): cover split-client last-view switches and mode transitions
andrebrait a4fa1bd
fix(metrics): key hang lookups on client+req and count unmeasured abo…
andrebrait 6f32080
fix(metrics): compute a group's max without spreading its values
andrebrait 3321d99
fix(metrics): a status-0 failure does not count as answered later
andrebrait 74bd7aa
feat(link): record head-of-line samples on both ends of the host link
andrebrait 3e45f76
feat(metrics): summarize link samples and add a head-of-line load probe
andrebrait df2e9cd
fix(link): monotonic ackMs and advisory stats samples, with a per-hos…
andrebrait 31d254c
test(link): write the hub's held link samples before a test restores …
andrebrait bcafb17
feat(metrics): --session for link samples, budget drops and the ackMs…
andrebrait 8289a90
fix(probe): let the stored-image prompt finish and tolerate get_state…
andrebrait 3063219
fix(metrics): the link ackMs note for v5's prompt acks
andrebrait 19a998d
fix(probe): wait up to 300 s for B's setup, ask for a no-tool reply, …
andrebrait 0085c36
fix(hosts): restart the op deadline on result bytes and decode joined…
andrebrait 8a6c099
fix(probe): fail before the phases when B's read is not a large frame
andrebrait 4787987
fix(hosts): refresh the op deadline only on kept result bytes; pin th…
andrebrait 7996518
fix(probe): end an API call in flight on a stop signal; a second sign…
andrebrait 3e4e82c
fix(probe): a stop signal ends the run quietly with its partial summa…
andrebrait 31d0cec
fix(hosts): write dropped link samples when the link ends or freezes;…
andrebrait 7aa341a
fix(hosts): reset a pending result's pieces only for a fresh daemon, …
andrebrait 9cb9ecc
feat(stream): rebuild streaming messages from omp's delta message upd…
andrebrait fb2f75e
feat(stream): ask omp for delta message updates and keep the whole me…
andrebrait fe4cbbf
feat(events): merge queued message updates under backpressure instead…
andrebrait 29c7216
feat(chat): apply omp's delta updates in the browser at display rate
andrebrait 4ccc26a
docs: streaming message updates as omp deltas
andrebrait d25f31a
fix(chat): a delta already in a catch-up snapshot is not applied again
andrebrait 4efc770
fix(chat): never replay a merged delta on a snapshot that holds part …
andrebrait de11687
fix(stream): only starts and rebuilt deltas are delta bases; a failed…
andrebrait 642dcef
perf(stream): re-parse streamed tool arguments only after 2 KB or 100…
andrebrait 590185b
docs: changelog entry for delta streaming; AGENTS.md on bases, the se…
andrebrait eedd0df
fix(chat): drop the unobservable re-hold in seed; test that a repeate…
andrebrait 4101b46
fix(message-delta): keep trailing spaces of an unfinished string and …
andrebrait b4b9358
fix(message-update-coalescer): bound the deltas held without a base
andrebrait 62d606f
docs(message-update-coalescer): say why the held-delta cap moves the …
andrebrait File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { handleBrowserSocketUpgrade, type BrowserSocketData } from "@/lib/browser-socket"; | ||
|
|
||
| // GET /api/events/ws — the browser's WebSocket transport (lib/browser-socket.ts); undefined once upgraded | ||
| // (server/app.ts). Gated like every API route: the password gate and origin check run before the upgrade. | ||
| export function GET(_req: Request, { upgrade }: { upgrade: (data: BrowserSocketData) => boolean }) { | ||
| return handleBrowserSocketUpgrade(upgrade); | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,14 @@ | ||
| import { handleLinkGet, handleLinkPost } from "@/lib/hosts/hub"; | ||
| import { handleLinkUpgrade, handleOutdatedLinkPost, type LinkSocketData } from "@/lib/hosts/hub"; | ||
|
|
||
| // The `ompweb host` daemon's link (lib/hosts/hub.ts). proxy.ts does not run | ||
| // for this path: the hub checks the host's bearer token before reading a body, | ||
| // and only then lifts Bun's idle timeout (disableIdleTimeout, server/app.ts). | ||
| type Context = { disableIdleTimeout: () => void }; | ||
| // for this path: the hub checks the host's bearer token before it upgrades. | ||
|
|
||
| // GET /api/hosts/link — downlink: a long-lived NDJSON stream, server → daemon. | ||
| export function GET(req: Request, { disableIdleTimeout }: Context) { | ||
| return handleLinkGet(req, disableIdleTimeout); | ||
| // GET /api/hosts/link — the link's WebSocket; undefined once upgraded (server/app.ts). | ||
| export function GET(req: Request, { upgrade }: { upgrade: (data: LinkSocketData) => boolean }) { | ||
| return handleLinkUpgrade(req, upgrade); | ||
| } | ||
|
|
||
| // POST /api/hosts/link — uplink: a batch of NDJSON messages, daemon → server. | ||
| export function POST(req: Request, { disableIdleTimeout }: Context) { | ||
| return handleLinkPost(req, disableIdleTimeout); | ||
| // POST /api/hosts/link — only refuses a daemon from before the WebSocket (its hello POST) with 426. | ||
| export function POST(req: Request) { | ||
| return handleOutdatedLinkPost(req); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { parseJsonWithinLimit, RequestBodyTooLargeError } from "@/lib/bounded-form-data"; | ||
| import { appendTransportSamples } from "@/lib/transport-metrics"; | ||
| import { isRecord } from "@/lib/type-guards"; | ||
|
|
||
| const MAX_BODY_BYTES = 256 * 1024; | ||
| const MAX_SAMPLES = 1_000; | ||
|
|
||
| // GET /api/transport-metrics — the server clock, the SSE transport's clock probe. | ||
| export function GET() { | ||
| return Response.json({ now: Date.now() }, { headers: { "cache-control": "no-store" } }); | ||
| } | ||
|
|
||
| // POST /api/transport-metrics { samples } — appended to <agent dir>/omp-web/transport-metrics.jsonl. | ||
| export async function POST(req: Request) { | ||
| let body: unknown; | ||
| try { | ||
| body = await parseJsonWithinLimit(req, MAX_BODY_BYTES); | ||
| } catch (error) { | ||
| if (error instanceof RequestBodyTooLargeError) return Response.json({ error: "Transport metrics request is too large", code: "request_too_large" }, { status: 413 }); | ||
| body = null; | ||
| } | ||
| if (!isRecord(body) || !Array.isArray(body.samples) || body.samples.length > MAX_SAMPLES) { | ||
| return Response.json({ error: "samples must be an array of at most 1000 objects", code: "invalid_transport_metrics" }, { status: 400 }); | ||
| } | ||
| return Response.json({ written: appendTransportSamples(body.samples, req.headers.get("user-agent")) }); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.