@antasphere/cli-core 0.5.0 → 0.6.0

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/README.md CHANGED
@@ -203,16 +203,18 @@ expiresInDays?, workspaceId? })` (the full key appears exactly once),
203
203
  - `lookupConnectKey / storeConnectKey / removeConnectKey / profileCredential` —
204
204
  the cache of exchange-minted user-scoped keys, held on the profile of the
205
205
  instance they were minted for, in its `connectKeys` map (slot = the hub
206
- profile name; `activeHubProfile(env)` resolves it). ONE key per hub account
206
+ profile name; `selectHubProfile(env)` resolves it). ONE key per hub account
207
207
  serves every org — the org is never part of the credential or the slot.
208
208
  `storeConnectKey(env, tool, profileName, hubProfileName, entry, { baseUrl })`
209
209
  writes `baseUrl` only on a profile that has none, a blank one counting as
210
210
  none (a profile is never repointed), creates a profile not on disk yet, and makes it active only when
211
211
  the tool had no profile at all. `removeConnectKey` never touches the tool's
212
212
  own `apiKey`. `profileCredential(profile, hubProfileName?)` answers `key` /
213
- `hub` / `none`.
214
- - `connectOnDemand({ tool, toolBaseUrl, cloudUrl?, profileName, env, resource?,
215
- fetch?, notify?, messages?, cached? })` — the seam a tool CLI runs when NO
213
+ `hub` / `none`. `cachedConnectKey(profile, hubProfileName, hubEmail)` is the
214
+ slot read the seam serves from: the key only when both e-mails are there and
215
+ match.
216
+ - `connectOnDemand({ tool, toolBaseUrl, cloudUrl?, hubCloudUrl?, profileName, env,
217
+ resource?, fetch?, notify?, messages?, cached? })` — the seam a tool CLI runs when NO
216
218
  direct credential resolved. `profileName` is REQUIRED: the profile
217
219
  `selectProfile` chose; `cloudUrl` is what a profile with no `baseUrl` is at,
218
220
  the same value the selection got. The cache is read first, on that profile
@@ -225,13 +227,22 @@ fetch?, notify?, messages?, cached? })` — the seam a tool CLI runs when NO
225
227
  or rejected hub login → a guided `antasphere login` `CliUsageError`, on
226
228
  either attempt; a refusal propagates as its `CliConnectError`), and the key
227
229
  is stored on the selected profile — never on one that is at another
228
- instance. Success:
230
+ instance. The hub profile the exchange uses is the one `ANTASPHERE_URL`
231
+ names (the profile at that instance, the way `antasphere login` picks it;
232
+ `hubCloudUrl` lets that URL name the `cloud` slot, places a hub profile with no
233
+ `baseUrl` at the hub and is the hub URL its exchange goes to; a profile's own
234
+ `baseUrl` always wins), else the active one, and
235
+ none when no hub profile is active (the account CLI would then take its cloud
236
+ profile; a tool CLI asks for `antasphere login`). A
237
+ cached tool key is served only when the hub profile's e-mail and the cached
238
+ key's e-mail match, and never when either is missing. Success:
229
239
  `{ outcome: 'connected', key, cached, result?, stored? }` — `cached: true` =
230
240
  served from the cache. `notify` receives the "Connected to …" notice on fresh
231
241
  exchanges (cache hits are silent); `messages` overrides the copy.
232
242
  `probeToolInstance(toolBaseUrl, fetch?)` is the discovery probe on its own;
233
- `activeHubProfile(env)` is the active hub profile, whose name is the cache
234
- slot.
243
+ `selectHubProfile(env, { cloudUrl? })` is that hub profile, whose name is the
244
+ cache slot (`HUB_URL_ENV` is `ANTASPHERE_URL`; `activeHubProfile(env)` is
245
+ kept, deprecated, as `selectHubProfile(env)`).
235
246
  - `refreshConnectKey(opts)` — the stranded-key recovery, same options as
236
247
  `connectOnDemand`. When a request answers 401 with a key served
237
248
  `cached: true`, the chassis calls it once: it evicts that key (only from a
@@ -256,7 +267,7 @@ Runners read `exitCode` off `CliUsageError` and `CliConnectError`.
256
267
  ## Consuming it
257
268
 
258
269
  ```json
259
- "dependencies": { "@antasphere/cli-core": "^0.5.0" }
270
+ "dependencies": { "@antasphere/cli-core": "^0.6.0" }
260
271
  ```
261
272
 
262
273
  Registry tarballs ship a prebuilt `dist/`, no build script runs on install.
@@ -270,7 +281,7 @@ with no npm token — npm authenticates the workflow's OIDC identity directly.
270
281
 
271
282
  ```bash
272
283
  # bump package.json#version, commit, then:
273
- git tag v0.5.0 && git push origin v0.5.0
284
+ git tag v0.6.0 && git push origin v0.6.0
274
285
  ```
275
286
 
276
287
  The first publish was done by hand, and the trusted publisher is configured on
package/dist/config.d.ts CHANGED
@@ -90,6 +90,17 @@ export declare function redactKey(key: string): string;
90
90
  * runs never misses the cache).
91
91
  */
92
92
  export declare function lookupConnectKey(profile: CliProfile | undefined, hubProfileName: string): string | undefined;
93
+ /**
94
+ * The cached connect key the connect-on-demand flow may SERVE: the slot's
95
+ * key, only when the hub profile carries an e-mail address, the cached
96
+ * entry carries one too, and the two are the same address (trimmed,
97
+ * case-insensitive). A key is the credential of the person who minted it
98
+ * (PRDCT-3032), so the cache serves only that person; a hub profile with no
99
+ * address is someone unknown, and an entry with no address was minted by
100
+ * someone unknown: neither is served (PRDCT-3046 F7). `lookupConnectKey`
101
+ * stays the plain slot read.
102
+ */
103
+ export declare function cachedConnectKey(profile: CliProfile | undefined, hubProfileName: string, hubEmail: string | undefined): string | undefined;
93
104
  /** How a profile signs in, for a `profiles`-style listing. */
94
105
  export type ProfileCredential = 'key' | 'hub' | 'none';
95
106
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;sCAGkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;wEAEoE;IACpE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BAAiB,CAC/B,OAAO,EAAE,UAAU,GAAG,SAAS,EAC/B,cAAc,CAAC,EAAE,MAAM,GACtB,iBAAiB,CAQnB;AAED,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,aAAa,EACpB,IAAI,GAAE,sBAA2B,GAChC,MAAM,CAWR;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,OAAO,CAaT"}
package/dist/config.js CHANGED
@@ -84,6 +84,24 @@ export function redactKey(key) {
84
84
  export function lookupConnectKey(profile, hubProfileName) {
85
85
  return profile?.connectKeys?.[hubProfileName]?.apiKey;
86
86
  }
87
+ /**
88
+ * The cached connect key the connect-on-demand flow may SERVE: the slot's
89
+ * key, only when the hub profile carries an e-mail address, the cached
90
+ * entry carries one too, and the two are the same address (trimmed,
91
+ * case-insensitive). A key is the credential of the person who minted it
92
+ * (PRDCT-3032), so the cache serves only that person; a hub profile with no
93
+ * address is someone unknown, and an entry with no address was minted by
94
+ * someone unknown: neither is served (PRDCT-3046 F7). `lookupConnectKey`
95
+ * stays the plain slot read.
96
+ */
97
+ export function cachedConnectKey(profile, hubProfileName, hubEmail) {
98
+ const entry = profile?.connectKeys?.[hubProfileName];
99
+ const hub = hubEmail?.trim().toLowerCase();
100
+ const minted = entry?.email?.trim().toLowerCase();
101
+ if (!hub || !minted || hub !== minted)
102
+ return undefined;
103
+ return entry?.apiKey;
104
+ }
87
105
  /**
88
106
  * What a profile signs in with, in the order the tool resolves it: its own
89
107
  * `apiKey` (`key`, the tool's login), else a key the hub ex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CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IACnE,CAAC;IACD,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -9,12 +9,16 @@ import type { ResolvedProfile } from './resolve.js';
9
9
  * (`selectProfile`: the profile IS the instance):
10
10
  *
11
11
  * 0. The cache is consulted FIRST: a key minted earlier for THIS instance
12
- * under the active hub profile is USER-scoped (hub ADR 014) — it serves
13
- * every subsequent run and every org, with zero network (no probe, no
14
- * hub round-trip, no fresh mint). It is read on the selected profile
15
- * only when that profile is at the resolved instance (its `baseUrl`,
16
- * else the tool's `cloudUrl` when the profile has none), so a cached
17
- * key never travels to another origin. `cached: false` skips this step.
12
+ * under the hub profile (the one `ANTASPHERE_URL` names, else the
13
+ * active one: `selectHubProfile`) is USER-scoped (hub ADR 014) — it
14
+ * serves every subsequent run and every org, with zero network (no
15
+ * probe, no hub round-trip, no fresh mint). It is read on the selected
16
+ * profile only when that profile is at the resolved instance (its
17
+ * `baseUrl`, else the tool's `cloudUrl` when the profile has none), so
18
+ * a cached key never travels to another origin, and it is served only
19
+ * to the address that minted it: the hub profile's `email` and the
20
+ * cached entry's `email` must both be there and match
21
+ * (`cachedConnectKey`). `cached: false` skips this step.
18
22
  * 1. On a miss, discovery gates the flow: only an Antasphere-CLOUD
19
23
  * instance can mint keys through the hub (unauthenticated GET
20
24
  * /instance — never guess). Unreachable, foreign, or self-hosted
@@ -22,7 +26,11 @@ import type { ResolvedProfile } from './resolve.js';
22
26
  * error unchanged.
23
27
  * 2. The hub credential is what `antasphere login` stored on the hub
24
28
  * profile (the config home's HUB_TOOL namespace) — hub URL included,
25
- * never a hardcoded constant here.
29
+ * never a hardcoded constant here. The hub profile is the one
30
+ * `ANTASPHERE_URL` names (the profile at that instance, the way the
31
+ * account CLI picks it), else the active one; a URL no hub profile is
32
+ * at has no credential, and the guided `antasphere login` error says
33
+ * so.
26
34
  * 3. `CliConnectClient.exchange` trades it for a tool-local key (one
27
35
  * re-exchange retry when the 120 s JWT dies in transit; a rejected hub
28
36
  * credential maps to guided `antasphere login` advice on either
@@ -59,10 +67,31 @@ export interface ToolInstanceProbe {
59
67
  * callers treat both exactly like "not cloud".
60
68
  */
61
69
  export declare function probeToolInstance(toolBaseUrl: string, fetchImpl?: typeof globalThis.fetch): Promise<ToolInstanceProbe | null>;
70
+ /** The hub's URL env var: the instance the account CLI talks to. */
71
+ export declare const HUB_URL_ENV = "ANTASPHERE_URL";
62
72
  /**
63
- * The ACTIVE hub profile — what `antasphere login` stored. Its NAME is the
64
- * connect cache's slot (config.ts `connectKeys`): stable per hub account on
65
- * this machine, independent of any org selection.
73
+ * The hub profile the exchange uses, selected the way the account CLI
74
+ * selects it: when `ANTASPHERE_URL` is set, the profile at that instance
75
+ * (`selectProfile`'s URL rule: the active one first when several name it,
76
+ * then `cloud`, then the first declared); a URL nothing on disk names
77
+ * yields the in-memory profile `selectProfile` makes (named for its host,
78
+ * `cloud` for `cloudUrl`, a `baseUrl` and no key), so the caller's
79
+ * missing-login error fires. Without `ANTASPHERE_URL`, the active profile,
80
+ * and none when no profile is active (here the account CLI's rule differs:
81
+ * it would fall back to its cloud profile; a tool CLI asks for a login
82
+ * instead) (PRDCT-3392: following the active profile whatever
83
+ * `ANTASPHERE_URL` said asked the wrong hub). Its NAME is the connect cache's slot (config.ts
84
+ * `connectKeys`): stable per hub account on this machine, independent of
85
+ * any org selection.
86
+ */
87
+ export declare function selectHubProfile(env: CliEnv, opts?: {
88
+ cloudUrl?: string | undefined;
89
+ }): ResolvedProfile;
90
+ /**
91
+ * The hub profile `ANTASPHERE_URL` names, else the active one — what
92
+ * `antasphere login` stored. Kept for the callers of 0.5.
93
+ *
94
+ * @deprecated Use `selectHubProfile`, which also takes the hub's cloud URL.
66
95
  */
67
96
  export declare function activeHubProfile(env: CliEnv): ResolvedProfile;
68
97
  /** The facts the connected notice is rendered from (fresh exchanges only —
@@ -104,6 +133,12 @@ export interface ConnectOnDemandOptions {
104
133
  * profile with no `baseUrl` of its own is at. Omit only for a tool with
105
134
  * no cloud instance. */
106
135
  cloudUrl?: string | undefined;
136
+ /** The hub's cloud URL, three roles: what the implicit `cloud` hub profile
137
+ * is at, so an `ANTASPHERE_URL` equal to it names the `cloud` slot (omit
138
+ * and a fresh hub profile is named for its host); where a hub profile
139
+ * with no `baseUrl` is placed for the selection; and the hub URL such a
140
+ * profile's exchange goes to. A profile's own `baseUrl` always wins. */
141
+ hubCloudUrl?: string | undefined;
107
142
  /** The exchange resource URL; default = this instance's MCP endpoint,
108
143
  * `${toolBaseUrl}/mcp` (the tool's registered resource URL). */
109
144
  resource?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"connect-on-demand.d.ts","sourceRoot":"","sources":["../src/connect-on-demand.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,aAAa,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AASrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,8EAA8E;AAC9E,MAAM,WAAW,iBAAiB;IAChC;4EACwE;IACxE,KAAK,EAAE,OAAO,CAAC;IACf,gEAAgE;IAChE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,sEAAsE;IACtE,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,GAClC,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAs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Q,CAAC,EAAE,uBAAuB,CAAC;IACnC;;sDAEkD;IAClD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,sBAAsB,GAC9B;IACE,OAAO,EAAE,WAAW,CAAC;IACrB,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAC;IACZ;;wEAEoE;IACpE,MAAM,EAAE,OAAO,CAAC;IAChB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;qEACiE;IACjE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GACD;IACE;qDACiD;IACjD,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAoBN;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAwGnG;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAOrG"}
@@ -1,6 +1,6 @@
1
- import { assertToolNamespace, HUB_TOOL, loadConfig, lookupConnectKey, removeConnectKey, storeConnectKey } from './config.js';
1
+ import { assertToolNamespace, cachedConnectKey, HUB_TOOL, loadConfig, removeConnectKey, storeConnectKey } from './config.js';
2
2
  import { CliConnectClient, CliConnectError } from './connect.js';
3
- import { CliUsageError, firstSet, normalizeUrl, profileUrl, resolveProfile, sameInstance } from './resolve.js';
3
+ import { CliUsageError, firstSet, normalizeUrl, profileUrl, resolveProfile, sameInstance, selectProfile } from './resolve.js';
4
4
  /**
5
5
  * Probe a tool instance's unauthenticated discovery endpoint
6
6
  * (`GET {toolBaseUrl}/api/v1/instance`). Returns what it advertises, or
@@ -30,13 +30,40 @@ export async function probeToolInstance(toolBaseUrl, fetchImpl) {
30
30
  return null;
31
31
  }
32
32
  }
33
+ /** The hub's URL env var: the instance the account CLI talks to. */
34
+ export const HUB_URL_ENV = 'ANTASPHERE_URL';
33
35
  /**
34
- * The ACTIVE hub profile — what `antasphere login` stored. Its NAME is the
35
- * connect cache's slot (config.ts `connectKeys`): stable per hub account on
36
- * this machine, independent of any org selection.
36
+ * The hub profile the exchange uses, selected the way the account CLI
37
+ * selects it: when `ANTASPHERE_URL` is set, the profile at that instance
38
+ * (`selectProfile`'s URL rule: the active one first when several name it,
39
+ * then `cloud`, then the first declared); a URL nothing on disk names
40
+ * yields the in-memory profile `selectProfile` makes (named for its host,
41
+ * `cloud` for `cloudUrl`, a `baseUrl` and no key), so the caller's
42
+ * missing-login error fires. Without `ANTASPHERE_URL`, the active profile,
43
+ * and none when no profile is active (here the account CLI's rule differs:
44
+ * it would fall back to its cloud profile; a tool CLI asks for a login
45
+ * instead) (PRDCT-3392: following the active profile whatever
46
+ * `ANTASPHERE_URL` said asked the wrong hub). Its NAME is the connect cache's slot (config.ts
47
+ * `connectKeys`): stable per hub account on this machine, independent of
48
+ * any org selection.
49
+ */
50
+ export function selectHubProfile(env, opts = {}) {
51
+ const config = loadConfig(env, HUB_TOOL);
52
+ const apiUrl = firstSet(env[HUB_URL_ENV]);
53
+ if (apiUrl) {
54
+ const { name, profile } = selectProfile({ config, apiUrl, cloudUrl: opts.cloudUrl });
55
+ return { name, profile };
56
+ }
57
+ return resolveProfile(config, undefined);
58
+ }
59
+ /**
60
+ * The hub profile `ANTASPHERE_URL` names, else the active one — what
61
+ * `antasphere login` stored. Kept for the callers of 0.5.
62
+ *
63
+ * @deprecated Use `selectHubProfile`, which also takes the hub's cloud URL.
37
64
  */
38
65
  export function activeHubProfile(env) {
39
- return resolveProfile(loadConfig(env, HUB_TOOL), undefined);
66
+ return selectHubProfile(env);
40
67
  }
41
68
  function defaultMissingHubLogin(tool) {
42
69
  const envVar = `${tool.replace(/-/g, '_').toUpperCase()}_API_KEY`;
@@ -80,17 +107,19 @@ export async function connectOnDemand(opts) {
80
107
  const toolBaseUrl = normalizeUrl(opts.toolBaseUrl);
81
108
  const messages = opts.messages ?? {};
82
109
  const { profileName } = opts;
83
- // 0. The cache: a key minted earlier by the active hub profile is
84
- // user-scoped — it serves every run and every org (hub ADR 014; the
85
- // org is a per-request parameter, never part of the credential). Only
86
- // the selected profile is read, and only when it is at THIS instance:
87
- // a cached key never travels to a different instance. A hit costs zero
110
+ // 0. The cache: a key minted earlier by the hub profile (the one
111
+ // ANTASPHERE_URL names, else the active one) is user-scoped — it serves
112
+ // every run and every org (hub ADR 014; the org is a per-request
113
+ // parameter, never part of the credential). Only the selected profile
114
+ // is read, and only when it is at THIS instance: a cached key never
115
+ // travels to a different instance. It is served only to the address
116
+ // that minted it (both e-mails there and equal). A hit costs zero
88
117
  // network. `cached: false` (the re-exchange after a 401) skips it.
89
- const hub = activeHubProfile(opts.env);
118
+ const hub = selectHubProfile(opts.env, { cloudUrl: opts.hubCloudUrl });
90
119
  const existing = loadConfig(opts.env, opts.tool).profiles[profileName];
91
120
  const { place, at } = placeOf(existing, toolBaseUrl, opts.cloudUrl);
92
121
  if (opts.cached !== false && place === 'here' && hub.name) {
93
- const cachedKey = lookupConnectKey(existing, hub.name);
122
+ const cachedKey = cachedConnectKey(existing, hub.name, hub.profile?.email);
94
123
  if (cachedKey)
95
124
  return { outcome: 'connected', key: cachedKey, cached: true };
96
125
  }
@@ -101,10 +130,16 @@ export async function connectOnDemand(opts) {
101
130
  return { outcome: 'not_cloud' };
102
131
  // 2. The hub credential is what `antasphere login` stored on the hub
103
132
  // profile (HUB_TOOL namespace) — one login for the whole tool family.
104
- // The hub URL comes from that same profile, never from a constant here.
133
+ // The hub URL comes from that same profile, never from a constant here;
134
+ // an in-memory profile (ANTASPHERE_URL naming no profile) has no key.
105
135
  // A blank field is no field (the package's one blank rule, firstSet).
106
136
  const hubKey = firstSet(hub.profile?.apiKey);
107
- const hubBaseUrl = firstSet(hub.profile?.baseUrl);
137
+ // A hub profile with no baseUrl (a hand edit, another writer: every
138
+ // Antasphere login writes one) is at the hub's cloud URL when the caller
139
+ // names one, the same rule a tool profile has with `cloudUrl`, and the
140
+ // rule `selectProfile` already applies to place it; the exchange half
141
+ // agrees with the selection half (verifier round 1, F4; round 3, F2).
142
+ const hubBaseUrl = firstSet(hub.profile?.baseUrl, opts.hubCloudUrl);
108
143
  if (!hubKey || !hubBaseUrl || !hub.name) {
109
144
  throw new CliUsageError(messages.missingHubLogin ?? defaultMissingHubLogin(opts.tool));
110
145
  }
@@ -176,7 +211,7 @@ export async function connectOnDemand(opts) {
176
211
  */
177
212
  export async function refreshConnectKey(opts) {
178
213
  assertToolNamespace(opts.tool);
179
- const hub = activeHubProfile(opts.env);
214
+ const hub = selectHubProfile(opts.env, { cloudUrl: opts.hubCloudUrl });
180
215
  const existing = loadConfig(opts.env, opts.tool).profiles[opts.profileName];
181
216
  const { place } = placeOf(existing, normalizeUrl(opts.toolBaseUrl), opts.cloudUrl);
182
217
  if (hub.name && place === 'here')
@@ -1 +1 @@
1
- {"version":3,"file":"connect-on-demand.js","sourceRoot":"","sources":["../src/connect-on-demand.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EACL,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACb,MAAM,cAAc,CAAC;AAwDtB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,WAAmB,EACnB,SAAmC;IAEnC,MAAM,CAAC,GAAG,SAAS,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,kBAAkB,EAAE;YACxE,MAAM,EAAE,KAAK;YACb,mEAAmE;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AM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAClF,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAA4B;IAClE,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,GAAG,GAAG,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IACvE,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5E,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnF,IAAI,GAAG,CAAC,IAAI,IAAI,KAAK,KAAK,MAAM;QAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACpG,OAAO,eAAe,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AACrD,CAAC"}
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  * commands, wire types, and API surfaces live in the tools; this package
15
15
  * carries only config/login plumbing, never secrets.
16
16
  */
17
- export { assertToolNamespace, clearConfig, configPath, HUB_TOOL, loadConfig, lookupConnectKey, parseConfig, profileCredential, redactKey, removeConnectKey, saveConfig, storeConnectKey } from './config.js';
17
+ export { assertToolNamespace, cachedConnectKey, clearConfig, configPath, HUB_TOOL, loadConfig, lookupConnectKey, parseConfig, profileCredential, redactKey, removeConnectKey, saveConfig, storeConnectKey } from './config.js';
18
18
  export type { CliConfig, CliConnectKey, CliEnv, CliProfile, ProfileCredential, StoreConnectKeyOptions } from './config.js';
19
19
  export { ask, printJson } from './io.js';
20
20
  export type { CliIo } from './io.js';
@@ -24,7 +24,7 @@ export { CliAuthClient, CliAuthError } from './auth.js';
24
24
  export type { CliAuthClientOptions, CliAuthCompleteBody, CliAuthCompleted, CliAuthMintedKey, CliAuthRequestBody, CliAuthRequested, CliAuthRevoked } from './auth.js';
25
25
  export { CliConnectClient, CliConnectError } from './connect.js';
26
26
  export type { CliConnectClientOptions, CliConnected, CliConnectResult, CliConnectStage, CliToolTokenBody, CliToolTokenMinted } from './connect.js';
27
- export { activeHubProfile, connectOnDemand, probeToolInstance, refreshConnectKey } from './connect-on-demand.js';
27
+ export { activeHubProfile, connectOnDemand, HUB_URL_ENV, probeToolInstance, refreshConnectKey, selectHubProfile } from './connect-on-demand.js';
28
28
  export type { ConnectNoticeFacts, ConnectOnDemandMessages, ConnectOnDemandOptions, ConnectOnDemandOutcome, ToolInstanceProbe } from './connect-on-demand.js';
29
29
  export { migrateLegacyConfig } from './migrate.js';
30
30
  export type { LegacyMigrationSpec, MigrationResult } from './migrate.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,eAAe,EAChB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,SAAS,EACT,aAAa,EACb,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EACL,aAAa,EACb,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,eAAe,EAChB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxD,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACf,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACjE,YAAY,EACV,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,eAAe,EAChB,MAAM,aA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C"}
package/dist/index.js CHANGED
@@ -14,11 +14,11 @@
14
14
  * commands, wire types, and API surfaces live in the tools; this package
15
15
  * carries only config/login plumbing, never secrets.
16
16
  */
17
- export { assertToolNamespace, clearConfig, configPath, HUB_TOOL, loadConfig, lookupConnectKey, parseConfig, profileCredential, redactKey, removeConnectKey, saveConfig, storeConnectKey } from './config.js';
17
+ export { assertToolNamespace, cachedConnectKey, clearConfig, configPath, HUB_TOOL, loadConfig, lookupConnectKey, parseConfig, profileCredential, redactKey, removeConnectKey, saveConfig, storeConnectKey } from './config.js';
18
18
  export { ask, printJson } from './io.js';
19
19
  export { CLOUD_PROFILE, CliUsageError, firstSet, normalizeUrl, profileNameFor, profileUrl, resolveApiKey, resolveBaseUrl, resolveOrg, resolveProfile, sameInstance, selectProfile } from './resolve.js';
20
20
  export { CliAuthClient, CliAuthError } from './auth.js';
21
21
  export { CliConnectClient, CliConnectError } from './connect.js';
22
- export { activeHubProfile, connectOnDemand, probeToolInstance, refreshConnectKey } from './connect-on-demand.js';
22
+ export { activeHubProfile, connectOnDemand, HUB_URL_ENV, probeToolInstance, refreshConnectKey, selectHubProfile } from './connect-on-demand.js';
23
23
  export { migrateLegacyConfig } from './migrate.js';
24
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,eAAe,EAChB,MAAM,aAAa,CAAC;AAUrB,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,EACL,aAAa,EACb,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACd,MAAM,cAAc,CAAC;AAWtB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAWxD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAUjE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAShC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,eAAe,EAChB,MAAM,aAAa,CAAC;AAUrB,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,EACL,aAAa,EACb,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACd,MAAM,cAAc,CAAC;AAWtB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAWxD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAUjE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAShC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antasphere/cli-core",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Shared CLI foundation for Antasphere tool CLIs: the ~/.config/antasphere config home, profiles that are instances (with the implicit cloud profile), the flag → env → profile → cloud URL resolution, the per-command organization override, the instance email-OTP auth client, the hub→tool connect exchange with its connect-on-demand seam and stranded-key recovery, and the CliIo prompt seam",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/config.ts CHANGED
@@ -168,6 +168,28 @@ export function lookupConnectKey(
168
168
  return profile?.connectKeys?.[hubProfileName]?.apiKey;
169
169
  }
170
170
 
171
+ /**
172
+ * The cached connect key the connect-on-demand flow may SERVE: the slot's
173
+ * key, only when the hub profile carries an e-mail address, the cached
174
+ * entry carries one too, and the two are the same address (trimmed,
175
+ * case-insensitive). A key is the credential of the person who minted it
176
+ * (PRDCT-3032), so the cache serves only that person; a hub profile with no
177
+ * address is someone unknown, and an entry with no address was minted by
178
+ * someone unknown: neither is served (PRDCT-3046 F7). `lookupConnectKey`
179
+ * stays the plain slot read.
180
+ */
181
+ export function cachedConnectKey(
182
+ profile: CliProfile | undefined,
183
+ hubProfileName: string,
184
+ hubEmail: string | undefined
185
+ ): string | undefined {
186
+ const entry = profile?.connectKeys?.[hubProfileName];
187
+ const hub = hubEmail?.trim().toLowerCase();
188
+ const minted = entry?.email?.trim().toLowerCase();
189
+ if (!hub || !minted || hub !== minted) return undefined;
190
+ return entry?.apiKey;
191
+ }
192
+
171
193
  /** How a profile signs in, for a `profiles`-style listing. */
172
194
  export type ProfileCredential = 'key' | 'hub' | 'none';
173
195
 
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  assertToolNamespace,
3
+ cachedConnectKey,
3
4
  HUB_TOOL,
4
5
  loadConfig,
5
- lookupConnectKey,
6
6
  removeConnectKey,
7
7
  storeConnectKey
8
8
  } from './config.js';
@@ -15,7 +15,8 @@ import {
15
15
  normalizeUrl,
16
16
  profileUrl,
17
17
  resolveProfile,
18
- sameInstance
18
+ sameInstance,
19
+ selectProfile
19
20
  } from './resolve.js';
20
21
  import type { ResolvedProfile } from './resolve.js';
21
22
 
@@ -27,12 +28,16 @@ import type { ResolvedProfile } from './resolve.js';
27
28
  * (`selectProfile`: the profile IS the instance):
28
29
  *
29
30
  * 0. The cache is consulted FIRST: a key minted earlier for THIS instance
30
- * under the active hub profile is USER-scoped (hub ADR 014) — it serves
31
- * every subsequent run and every org, with zero network (no probe, no
32
- * hub round-trip, no fresh mint). It is read on the selected profile
33
- * only when that profile is at the resolved instance (its `baseUrl`,
34
- * else the tool's `cloudUrl` when the profile has none), so a cached
35
- * key never travels to another origin. `cached: false` skips this step.
31
+ * under the hub profile (the one `ANTASPHERE_URL` names, else the
32
+ * active one: `selectHubProfile`) is USER-scoped (hub ADR 014) — it
33
+ * serves every subsequent run and every org, with zero network (no
34
+ * probe, no hub round-trip, no fresh mint). It is read on the selected
35
+ * profile only when that profile is at the resolved instance (its
36
+ * `baseUrl`, else the tool's `cloudUrl` when the profile has none), so
37
+ * a cached key never travels to another origin, and it is served only
38
+ * to the address that minted it: the hub profile's `email` and the
39
+ * cached entry's `email` must both be there and match
40
+ * (`cachedConnectKey`). `cached: false` skips this step.
36
41
  * 1. On a miss, discovery gates the flow: only an Antasphere-CLOUD
37
42
  * instance can mint keys through the hub (unauthenticated GET
38
43
  * /instance — never guess). Unreachable, foreign, or self-hosted
@@ -40,7 +45,11 @@ import type { ResolvedProfile } from './resolve.js';
40
45
  * error unchanged.
41
46
  * 2. The hub credential is what `antasphere login` stored on the hub
42
47
  * profile (the config home's HUB_TOOL namespace) — hub URL included,
43
- * never a hardcoded constant here.
48
+ * never a hardcoded constant here. The hub profile is the one
49
+ * `ANTASPHERE_URL` names (the profile at that instance, the way the
50
+ * account CLI picks it), else the active one; a URL no hub profile is
51
+ * at has no credential, and the guided `antasphere login` error says
52
+ * so.
44
53
  * 3. `CliConnectClient.exchange` trades it for a tool-local key (one
45
54
  * re-exchange retry when the 120 s JWT dies in transit; a rejected hub
46
55
  * credential maps to guided `antasphere login` advice on either
@@ -105,13 +114,42 @@ export async function probeToolInstance(
105
114
  }
106
115
  }
107
116
 
117
+ /** The hub's URL env var: the instance the account CLI talks to. */
118
+ export const HUB_URL_ENV = 'ANTASPHERE_URL';
119
+
108
120
  /**
109
- * The ACTIVE hub profile — what `antasphere login` stored. Its NAME is the
110
- * connect cache's slot (config.ts `connectKeys`): stable per hub account on
111
- * this machine, independent of any org selection.
121
+ * The hub profile the exchange uses, selected the way the account CLI
122
+ * selects it: when `ANTASPHERE_URL` is set, the profile at that instance
123
+ * (`selectProfile`'s URL rule: the active one first when several name it,
124
+ * then `cloud`, then the first declared); a URL nothing on disk names
125
+ * yields the in-memory profile `selectProfile` makes (named for its host,
126
+ * `cloud` for `cloudUrl`, a `baseUrl` and no key), so the caller's
127
+ * missing-login error fires. Without `ANTASPHERE_URL`, the active profile,
128
+ * and none when no profile is active (here the account CLI's rule differs:
129
+ * it would fall back to its cloud profile; a tool CLI asks for a login
130
+ * instead) (PRDCT-3392: following the active profile whatever
131
+ * `ANTASPHERE_URL` said asked the wrong hub). Its NAME is the connect cache's slot (config.ts
132
+ * `connectKeys`): stable per hub account on this machine, independent of
133
+ * any org selection.
134
+ */
135
+ export function selectHubProfile(env: CliEnv, opts: { cloudUrl?: string | undefined } = {}): ResolvedProfile {
136
+ const config = loadConfig(env, HUB_TOOL);
137
+ const apiUrl = firstSet(env[HUB_URL_ENV]);
138
+ if (apiUrl) {
139
+ const { name, profile } = selectProfile({ config, apiUrl, cloudUrl: opts.cloudUrl });
140
+ return { name, profile };
141
+ }
142
+ return resolveProfile(config, undefined);
143
+ }
144
+
145
+ /**
146
+ * The hub profile `ANTASPHERE_URL` names, else the active one — what
147
+ * `antasphere login` stored. Kept for the callers of 0.5.
148
+ *
149
+ * @deprecated Use `selectHubProfile`, which also takes the hub's cloud URL.
112
150
  */
113
151
  export function activeHubProfile(env: CliEnv): ResolvedProfile {
114
- return resolveProfile(loadConfig(env, HUB_TOOL), undefined);
152
+ return selectHubProfile(env);
115
153
  }
116
154
 
117
155
  /** The facts the connected notice is rendered from (fresh exchanges only —
@@ -176,6 +214,12 @@ export interface ConnectOnDemandOptions {
176
214
  * profile with no `baseUrl` of its own is at. Omit only for a tool with
177
215
  * no cloud instance. */
178
216
  cloudUrl?: string | undefined;
217
+ /** The hub's cloud URL, three roles: what the implicit `cloud` hub profile
218
+ * is at, so an `ANTASPHERE_URL` equal to it names the `cloud` slot (omit
219
+ * and a fresh hub profile is named for its host); where a hub profile
220
+ * with no `baseUrl` is placed for the selection; and the hub URL such a
221
+ * profile's exchange goes to. A profile's own `baseUrl` always wins. */
222
+ hubCloudUrl?: string | undefined;
179
223
  /** The exchange resource URL; default = this instance's MCP endpoint,
180
224
  * `${toolBaseUrl}/mcp` (the tool's registered resource URL). */
181
225
  resource?: string;
@@ -251,17 +295,19 @@ export async function connectOnDemand(opts: ConnectOnDemandOptions): Promise<Con
251
295
  const messages = opts.messages ?? {};
252
296
  const { profileName } = opts;
253
297
 
254
- // 0. The cache: a key minted earlier by the active hub profile is
255
- // user-scoped — it serves every run and every org (hub ADR 014; the
256
- // org is a per-request parameter, never part of the credential). Only
257
- // the selected profile is read, and only when it is at THIS instance:
258
- // a cached key never travels to a different instance. A hit costs zero
298
+ // 0. The cache: a key minted earlier by the hub profile (the one
299
+ // ANTASPHERE_URL names, else the active one) is user-scoped — it serves
300
+ // every run and every org (hub ADR 014; the org is a per-request
301
+ // parameter, never part of the credential). Only the selected profile
302
+ // is read, and only when it is at THIS instance: a cached key never
303
+ // travels to a different instance. It is served only to the address
304
+ // that minted it (both e-mails there and equal). A hit costs zero
259
305
  // network. `cached: false` (the re-exchange after a 401) skips it.
260
- const hub = activeHubProfile(opts.env);
306
+ const hub = selectHubProfile(opts.env, { cloudUrl: opts.hubCloudUrl });
261
307
  const existing = loadConfig(opts.env, opts.tool).profiles[profileName];
262
308
  const { place, at } = placeOf(existing, toolBaseUrl, opts.cloudUrl);
263
309
  if (opts.cached !== false && place === 'here' && hub.name) {
264
- const cachedKey = lookupConnectKey(existing, hub.name);
310
+ const cachedKey = cachedConnectKey(existing, hub.name, hub.profile?.email);
265
311
  if (cachedKey) return { outcome: 'connected', key: cachedKey, cached: true };
266
312
  }
267
313
 
@@ -272,10 +318,16 @@ export async function connectOnDemand(opts: ConnectOnDemandOptions): Promise<Con
272
318
 
273
319
  // 2. The hub credential is what `antasphere login` stored on the hub
274
320
  // profile (HUB_TOOL namespace) — one login for the whole tool family.
275
- // The hub URL comes from that same profile, never from a constant here.
321
+ // The hub URL comes from that same profile, never from a constant here;
322
+ // an in-memory profile (ANTASPHERE_URL naming no profile) has no key.
276
323
  // A blank field is no field (the package's one blank rule, firstSet).
277
324
  const hubKey = firstSet(hub.profile?.apiKey);
278
- const hubBaseUrl = firstSet(hub.profile?.baseUrl);
325
+ // A hub profile with no baseUrl (a hand edit, another writer: every
326
+ // Antasphere login writes one) is at the hub's cloud URL when the caller
327
+ // names one, the same rule a tool profile has with `cloudUrl`, and the
328
+ // rule `selectProfile` already applies to place it; the exchange half
329
+ // agrees with the selection half (verifier round 1, F4; round 3, F2).
330
+ const hubBaseUrl = firstSet(hub.profile?.baseUrl, opts.hubCloudUrl);
279
331
  if (!hubKey || !hubBaseUrl || !hub.name) {
280
332
  throw new CliUsageError(messages.missingHubLogin ?? defaultMissingHubLogin(opts.tool));
281
333
  }
@@ -356,7 +408,7 @@ export async function connectOnDemand(opts: ConnectOnDemandOptions): Promise<Con
356
408
  */
357
409
  export async function refreshConnectKey(opts: ConnectOnDemandOptions): Promise<ConnectOnDemandOutcome> {
358
410
  assertToolNamespace(opts.tool);
359
- const hub = activeHubProfile(opts.env);
411
+ const hub = selectHubProfile(opts.env, { cloudUrl: opts.hubCloudUrl });
360
412
  const existing = loadConfig(opts.env, opts.tool).profiles[opts.profileName];
361
413
  const { place } = placeOf(existing, normalizeUrl(opts.toolBaseUrl), opts.cloudUrl);
362
414
  if (hub.name && place === 'here') removeConnectKey(opts.env, opts.tool, opts.profileName, hub.name);
package/src/index.ts CHANGED
@@ -17,6 +17,7 @@
17
17
 
18
18
  export {
19
19
  assertToolNamespace,
20
+ cachedConnectKey,
20
21
  clearConfig,
21
22
  configPath,
22
23
  HUB_TOOL,
@@ -89,8 +90,10 @@ export type {
89
90
  export {
90
91
  activeHubProfile,
91
92
  connectOnDemand,
93
+ HUB_URL_ENV,
92
94
  probeToolInstance,
93
- refreshConnectKey
95
+ refreshConnectKey,
96
+ selectHubProfile
94
97
  } from './connect-on-demand.js';
95
98
  export type {
96
99
  ConnectNoticeFacts,