Skip to content

fix: resolve a2a.json under dsh web alias and infer LAN baseUrl on 0.0.0.0 - #2

Merged
ryubyte merged 1 commit into
mainfrom
fix/dsh-web-profile-and-baseurl
Aug 21, 2026
Merged

ryubyte merged 1 commit into
mainfrom
fix/dsh-web-profile-and-baseurl

Conversation

@ryubyte

@ryubyte ryubyte commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes two runtime bugs found when launching DSH via dsh web (the --profile web alias):

1. dsh web could not locate the per-profile a2a.json

Root cause: the dsh launcher resolves the web profile internally but never writes --profile web back into process.argv (and exposes no env var for it). profileNameFromArgv() therefore returned undefined and a2a.json resolution fell through to cwd-based guessing — wrong file when starting from outside the profile directory.

Fix: profileNameFromDshAlias() recognizes the web subcommand (first user token, only when no --profile flag is present) and resolveConfigPath() uses it as step 0. Verified on a real machine: dsh web from ~ now resolves ~/.dsh/profiles/web/a2a.json.

2. AgentCard advertised 127.0.0.1 when the web server binds 0.0.0.0

Root cause: the derived base URL hardcoded 0.0.0.0 → http://127.0.0.1:<port>, which points remote A2A callers at their own loopback — unreachable.

Fix: inferBaseUrl() derives the machine's primary LAN IPv4 when bound to 0.0.0.0 (skipping link-local 169.254.0.0/16 and CGNAT 100.64.0.0/10, preferring default-route interfaces like en0/eth0), falling back to loopback only when no LAN address exists. Explicit baseUrl config still wins. Verified: 0.0.0.0:3080 → http://192.168.136.64:3080.

Tests

  • New test/a2a-config.test.ts — 4 cases for --profile, web alias, and path-resolution priority (serialized; they mutate global argv/env).
  • test/a2a.test.ts — 3 new inferBaseUrl cases.
  • npm test: 44/44 pass, client bundle smoke OK.

Files

  • src/a2a-config.ts — profileNameFromDshAlias() + wiring into resolveConfigPath()
  • src/index.ts — inferBaseUrl() / primaryLanAddress()
  • test/a2a-config.test.ts (new), test/a2a.test.ts
  • README.md / README.en.md — documented behavior
  • lib/ — rebuilt artifacts (tracked in this repo)

…0.0.0

Two runtime bugs when launching via `dsh web` (the `--profile web` alias):

1. a2a-config: the launcher resolves the `web` profile internally but never
   writes `--profile web` back into process.argv, so profileNameFromArgv()
   found nothing and a2a.json resolution fell through to cwd guessing.
   Add profileNameFromDshAlias() to recognize the `web` subcommand as the
   first user token when no --profile flag is present, and use it in
   resolveConfigPath() step 0. `dsh web` now reads/writes
   ~/.dsh/profiles/web/a2a.json from any launch directory.

2. server baseUrl: when the web server binds 0.0.0.0, the derived AgentCard
   URL was hardcoded to http://127.0.0.1:<port> - unreachable for any remote
   A2A caller. Add inferBaseUrl() + primaryLanAddress(): 0.0.0.0 now derives
   the machine's primary LAN IPv4 (skipping link-local/CGNAT), falling back
   to loopback only when none exists. Explicit baseUrl config still wins.

Tests: new test/a2a-config.test.ts (alias + path resolution, serialized),
inferBaseUrl cases in test/a2a.test.ts. npm test: 44/44 pass.
@ryubyte
ryubyte merged commit 5b404bc into main Aug 21, 2026
1 check passed
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