@vidge/dsh-agent-hub 0.1.0-rc3 → 0.1.0-rc4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -486,15 +486,21 @@ var SHARED_ENV_KEYS = [
486
486
  ];
487
487
  function inheritedLlmCredentials(backend) {
488
488
  const creds = {};
489
- const take = (key) => {
489
+ const chosen = backend === "auto" ? BACKEND_ENV_GROUPS.find((group) => process.env[group.selector] !== void 0) : BACKEND_ENV_GROUPS.find((group) => group.id === backend);
490
+ for (const key of chosen?.keys ?? []) {
490
491
  const value = process.env[key];
491
492
  if (value !== void 0) creds[key] = value;
492
- };
493
- const chosen = backend === "auto" ? BACKEND_ENV_GROUPS.find((group) => process.env[group.selector] !== void 0) : BACKEND_ENV_GROUPS.find((group) => group.id === backend);
494
- for (const key of chosen?.keys ?? []) take(key);
495
- for (const key of SHARED_ENV_KEYS) take(key);
493
+ }
496
494
  return creds;
497
495
  }
496
+ function inheritedSharedEnv() {
497
+ const shared = {};
498
+ for (const key of SHARED_ENV_KEYS) {
499
+ const value = process.env[key];
500
+ if (value !== void 0) shared[key] = value;
501
+ }
502
+ return shared;
503
+ }
498
504
  function claudeChildEnv(spec) {
499
505
  const derived = spec.providerEnv;
500
506
  const selected = derived ?? inheritedLlmCredentials(spec.backend ?? "auto");
@@ -506,6 +512,7 @@ function claudeChildEnv(spec) {
506
512
  }
507
513
  return {
508
514
  ...env,
515
+ ...inheritedSharedEnv(),
509
516
  ...selected,
510
517
  ...spec.model === void 0 ? {} : { ANTHROPIC_MODEL: spec.model },
511
518
  ...spec.env
@@ -606,6 +613,7 @@ function readProviderProfile(ctx, provider) {
606
613
  }
607
614
  function mapRouteToEnv(provider, profile, key) {
608
615
  const headers = profile.headers ?? {};
616
+ const extra = profile.childEnv ?? {};
609
617
  if (BEDROCK_PROVIDER_IDS.has(provider)) {
610
618
  return {
611
619
  CLAUDE_CODE_USE_BEDROCK: "1",
@@ -615,13 +623,15 @@ function mapRouteToEnv(provider, profile, key) {
615
623
  // explicit and the gateway ignores it; without one the client refuses to
616
624
  // construct. A route pointing at a corporate gateway has no real region,
617
625
  // so this is a placeholder the endpoint override makes irrelevant.
618
- ..."AWS_REGION" in headers ? {} : { AWS_REGION: "us-east-1" }
626
+ ..."AWS_REGION" in headers ? {} : { AWS_REGION: "us-east-1" },
627
+ ...extra
619
628
  };
620
629
  }
621
630
  if (ANTHROPIC_PROVIDER_IDS.has(provider) || profile.api === "anthropic-messages") {
622
631
  return {
623
632
  ANTHROPIC_AUTH_TOKEN: key,
624
- ...profile.baseURL === void 0 ? {} : { ANTHROPIC_BASE_URL: profile.baseURL }
633
+ ...profile.baseURL === void 0 ? {} : { ANTHROPIC_BASE_URL: profile.baseURL },
634
+ ...extra
625
635
  };
626
636
  }
627
637
  return void 0;
@@ -644,9 +654,10 @@ async function deriveProviderEnv(ctx, provider) {
644
654
  if (key === void 0 || key === "") return void 0;
645
655
  const env = mapRouteToEnv(provider, profile, key);
646
656
  if (env === void 0) return void 0;
657
+ const extra = Object.keys(profile.childEnv ?? {});
647
658
  return {
648
659
  env,
649
- diagnostic: `claude-code: routing to dsh provider "${provider}"${profile.baseURL === void 0 ? "" : ` at ${profile.baseURL}`} (credential ${ref})`
660
+ diagnostic: `claude-code: routing to dsh provider "${provider}"${profile.baseURL === void 0 ? "" : ` at ${profile.baseURL}`} (credential ${ref})${extra.length === 0 ? "" : `; route env ${extra.join(", ")}`}`
650
661
  };
651
662
  }
652
663
 
@@ -13,7 +13,9 @@
13
13
  *
14
14
  * Only the route's *transport* is derived. Which model runs is settled earlier
15
15
  * by the agent's own resolution (session choice, then `agentDefaultModel`), and
16
- * is passed in rather than re-read here.
16
+ * is passed in rather than re-read here. A route may also carry a `childEnv`
17
+ * map, which is not derived at all but forwarded verbatim — the escape hatch
18
+ * for what a protocol mapping cannot express.
17
19
  *
18
20
  * Everything is resolved per call. `credentials.resolve` is contractually a
19
21
  * per-call read — the store layers process env over `~/.dsh/.credentials.yaml`
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.1.0-rc3",
7
+ "version": "0.1.0-rc4",
8
8
  "repository": "github:vidgewong/dsh-agent-hub",
9
9
  "type": "module",
10
10
  "main": "lib/index.js",