Skip to content

feat(web): serve the SDK and custom pages from the local relay - #3566

Open
paul-nechifor wants to merge 1 commit into
paul/feat/w1-web-sdkfrom
paul/feat/w2-sdk-serving
Open

feat(web): serve the SDK and custom pages from the local relay#3566
paul-nechifor wants to merge 1 commit into
paul/feat/w1-web-sdkfrom
paul/feat/w2-sdk-serving

Conversation

@paul-nechifor

Copy link
Copy Markdown
Contributor

No description provided.

- The relay serves the SDK bundle at /sdk.js and, with --serve-dir DIR, a
  custom page directory at / in place of the cockpit. /api/* and /sdk.js win.
- examples/minimal/ is a zero-build page: one HTML file importing /sdk.js.
  Run it with: dimos run <bp> --local-relay --serve-dir web/examples/minimal.
- Directory traversal and symlink escapes out of the served dir are rejected,
  with tests.
- The local relay answers /api/info, /api/stats, /sdk.js and served JS modules
  with wildcard CORS so Vite dev servers and file: pages can bootstrap.
- That is safe only on loopback, so startRelay refuses a non-loopback host
  unless --unsafe-non-loopback acknowledges it.
- ensure_cockpit_dist becomes ensure_web_dist: cockpit and SDK build under one
  staleness stamp, and release wheels ship both prebuilt dists.
- New browser e2e test_sdk_browser.py pins the zero-build, cross-origin, and
  file: page forms. --serve-dir is rejected with --relay-url.
@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
4189 1 4188 176
View the top 1 failed test(s) by shortest run time
dimos.codebase_checks.test_no_sections::test_no_section_markers
Stack Traces | 0.785s run time
def test_no_section_markers():
        """
        Fail if any file contains section-style comment markers.
    
        If a file is too complicated to be understood without sections, then the
        sections should be files. We don't need "subfiles".
        """
        violations = find_section_markers()
        if violations:
            report_lines = [
                f"Found {len(violations)} section marker(s). "
                "If a file is too complicated to be understood without sections, "
                'then the sections should be files. We don\'t need "subfiles".',
                "",
            ]
            for path, lineno, text in violations:
                report_lines.append(f"  {path}:{lineno}: {text.strip()}")
>           raise AssertionError("\n".join(report_lines))
E           AssertionError: Found 2 section marker(s). If a file is too complicated to be understood without sections, then the sections should be files. We don't need "subfiles".
E           
E             .../web/relay_bridge/test_relay_bridge_module.py:1208: # --- Teleop (the tele_cmd_vel tx channel) ---
E             .../web/relay_bridge/test_relay_bridge_e2e.py:401: # --- Teleop e2e: viewer datagrams -> relay lease gate -> bridge publishes ---

lineno     = 401
path       = '.../web/relay_bridge/test_relay_bridge_e2e.py'
report_lines = ['Found 2 section marker(s). If a file is too complicated to be understood without sections, then the sections should ...y_bridge/test_relay_bridge_e2e.py:401: # --- Teleop e2e: viewer datagrams -> relay lease gate -> bridge publishes ---']
text       = '# --- Teleop e2e: viewer datagrams -> relay lease gate -> bridge publishes ---'
violations = [('.../web/relay_bridge/test_relay_bridge_module.py', 1208, '# --- Teleop (the tele_cmd_vel tx channel) ---'), ('dim...idge/test_relay_bridge_e2e.py', 401, '# --- Teleop e2e: viewer datagrams -> relay lease gate -> bridge publishes ---')]

dimos/codebase_checks/test_no_sections.py:145: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This change enables the local relay to serve the browser SDK at /sdk.js and, when configured, serve operator-selected static pages from the same local origin. It also builds and packages the SDK and Cockpit distributions for relay use.

The static-file sibling-prefix traversal concern was disproved against a real relay instance. A request for an in-root file returned 200 OK with the expected content, while /%2e%2e/site-private/secret.txt returned 404 Not Found and did not disclose the adjacent sibling file. The relay server test suite also completed successfully with 9 tests and 18 steps passing.

No defects were found that require changes before merge.

Confidence Score: 5/5

The local static-serving path exercised by the focused probe prevents the tested attempt to read an adjacent directory outside the configured serve root.

The review has no remaining findings. The focused executable check used the actual relay and raw HTTP requests to compare a known-good in-root response with the suspected out-of-root path, and the relay suite passed.

Files Needing Attention: No files require follow-up changes. The focused behavior was exercised in web/relay/server.ts.

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex ran a focused executable probe that created a temporary static root, started the real startRelay server, and issued raw HTTP requests.
  • The in-root request returned HTTP/1.1 200 OK with PUBLIC_OK, confirming the static-serving path was active.
  • The percent-encoded traversal request /%2e%2e/site-private/secret.txt returned HTTP/1.1 404 Not Found, indicating the secret could not be accessed via the sibling path.
  • T-Rex reran the existing relay HTTP/WebTransport test suite, which completed with 9 tests and 18 steps passing.
  • Artifacts from the run were gathered and summarized, including the focused probe source and the relay test-suite outputs to support review.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "feat(web): serve the SDK and custom page..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant