feat: point Try It panels at localhost with editable port, format all API output#36
Merged
Merged
Conversation
… API output
- OpenAPI servers: http://localhost:{port}/api/v1 with editable port
variable (default 3000, the documented coven daemon serve --tcp standard)
so hosted docs never display/resolve docs.opencoven.ai
- Proxy bridge: socket-first dial with loopback TCP fallback on the chosen
port; validates absolute targets (http + loopback + /api/ paths), keeps
legacy /api/coven-proxy URLs, self-dial guard returns a clear 503 hint
- Pretty-print all JSON responses through the bridge; code samples pipe
curl through jq and pretty-print in TS/Python/Rust
- Prose: port selector + TCP fallback + standard port 3000 in openapi
index, socket-api, and reference/api pages
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the docs-site OpenAPI “Try It” experience to target localhost with an editable port, bridge requests to the local daemon (Unix socket first, TCP loopback fallback), and present consistently pretty-printed JSON output across the proxy and generated code samples.
Changes:
- Switch OpenAPI
serverstohttp://localhost:{port}/api/v1with aportvariable defaulting to3000, and refresh related prose. - Extend the proxy dialer to attempt
$COVEN_HOME/coven.sockfirst, then fall back to127.0.0.1:<port>with a self-dial guard and JSON pretty-printing. - Update generated OpenAPI code samples (curl/TS/Python/Rust) to print formatted JSON output.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| scripts/build-openapi-samples.mjs | Pretty-prints API output in generated code samples (adds jq and language-specific formatting). |
| openapi/coven.daemon.v1.yaml | Sets localhost server with editable port and refactors repeated event cursor params into reusable components. |
| lib/coven-proxy-dial.ts | Adds TCP fallback dialing, self-dial avoidance, and JSON response formatting for the proxy bridge. |
| app/api/coven-proxy/route.ts | Validates absolute loopback targets, extracts port for fallback, and preserves legacy /api/coven-proxy/... behavior. |
| app/api/coven-proxy/[...path]/route.ts | Passes selfHost into the dialer for self-dial guarding on path-prefix proxy calls. |
| content/docs/openapi/index.mdx | Documents the server URL/port selector behavior, fallback transport, and jq sanity check. |
| content/docs/daemon/socket-api.mdx | Updates transport prose and examples to reflect formatted output and standard port 3000. |
| content/docs/reference/api.mdx | Notes the standard loopback TCP address/port in the reference transport description. |
Comment on lines
+22
to
+23
| const LEGACY_PROXY_PREFIX = '/api/coven-proxy'; | ||
| const LOOPBACK_HOSTNAMES = new Set(['localhost', '127.0.0.1', '[::1]']); |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Server URL → localhost, never docs.opencoven.ai
serversis nowhttp://localhost:{port}/api/v1with an editableportvariable (default3000) — the playground server selector renders it as an input (persisted per-reader). 3000 matches the documented daemon standardcoven daemon serve --tcp 127.0.0.1:3000./api/coven-proxy/api/v1server resolved against the docs origin, so hosted pages displayed and targetedhttps://docs.opencoven.ai/....Proxy bridge (both
app/api/coven-proxyroutes +lib/coven-proxy-dial.ts)$COVEN_HOME/coven.sock), fallback to loopback TCP on the chosen port.http:only, loopback hosts only, paths under/api/; legacy/api/coven-proxy-prefixed URLs still work.daemon_unreachablehint instead of a confusing Next.js 404.Formatted output everywhere
application/json/+jsonresponses (Try It panels, status banner).| jq .; TS/Python/Rust print pretty JSON (JSON.stringify(...,null,2),json.dumps(indent=2),serde_json::to_string_pretty).Prose:
openapi/index.mdx(port selector, TCP fallback row, jq sanity check),daemon/socket-api.mdx+reference/api.mdx(standard port 3000).Verified
npx tsc --noEmitand fullpnpm build(all check scripts) green/api/→ 400cause:'self'+ hint; no listener → 503ECONNREFUSED.built.yaml+ endpoint MDX viaopenapi:build(gitignored artifacts)