fix: resolve a2a.json under dsh web alias and infer LAN baseUrl on 0.0.0.0 - #2
Merged
Merged
Conversation
…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.
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.
Summary
Fixes two runtime bugs found when launching DSH via
dsh web(the--profile webalias):1.
dsh webcould not locate the per-profilea2a.jsonRoot cause: the dsh launcher resolves the
webprofile internally but never writes--profile webback intoprocess.argv(and exposes no env var for it).profileNameFromArgv()therefore returnedundefinedanda2a.jsonresolution fell through to cwd-based guessing — wrong file when starting from outside the profile directory.Fix:
profileNameFromDshAlias()recognizes thewebsubcommand (first user token, only when no--profileflag is present) andresolveConfigPath()uses it as step 0. Verified on a real machine:dsh webfrom~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 to0.0.0.0(skipping link-local169.254.0.0/16and CGNAT100.64.0.0/10, preferring default-route interfaces likeen0/eth0), falling back to loopback only when no LAN address exists. ExplicitbaseUrlconfig still wins. Verified:0.0.0.0:3080→http://192.168.136.64:3080.Tests
test/a2a-config.test.ts— 4 cases for--profile,webalias, and path-resolution priority (serialized; they mutate global argv/env).test/a2a.test.ts— 3 newinferBaseUrlcases.npm test: 44/44 pass, client bundle smoke OK.Files
src/a2a-config.ts—profileNameFromDshAlias()+ wiring intoresolveConfigPath()src/index.ts—inferBaseUrl()/primaryLanAddress()test/a2a-config.test.ts(new),test/a2a.test.tsREADME.md/README.en.md— documented behaviorlib/— rebuilt artifacts (tracked in this repo)