@antasphere/cli-core 0.3.0 → 0.4.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
@@ -67,38 +67,50 @@ expiresInDays?, workspaceId? })` (the full key appears exactly once),
67
67
  fetch, interactive prompt) so tool CLIs run in-process under test.
68
68
  - `CliConnectClient({ hubBaseUrl, toolBaseUrl })` — the cross-tool connect
69
69
  exchange (binding patterns §7, gcloud model — one hub login serves every
70
- federated tool): `toolToken(hubApiKey, { resource, workspaceId? })` asks
71
- the hub for a 120 s single-org JWT, `cliConnect(token)` trades it at the
72
- tool for a tool-local key (no auth header — the JWT is the credential),
73
- `exchange(hubApiKey, body)` composes both; the hub key never reaches the
74
- tool. Errors are `CliConnectError` (a `CliAuthError`) tagged with the
75
- failing `stage` plus the two remedies: `needsHubLogin` (hub 401, or 403
76
- `insufficient_scope` from a pre-`sso:exchange` key) and `needsReExchange`
77
- (tool 401 on an expired/replayed JWT).
78
- - `lookupWorkspaceKey / storeWorkspaceKey / removeWorkspaceKey` — the
79
- per-(tool, HUB org) cache of exchange-minted keys, held in the tool
80
- profile's additive `workspaceKeys` map. The legacy single `apiKey` keeps
81
- working unchanged and answers an org lookup only when the profile says it
82
- is bound to exactly that workspace.
83
- - `connectOnDemand({ tool, toolBaseUrl, resource?, org?, profileName?, env,
70
+ federated tool): `toolToken(hubApiKey, { resource })` asks the hub for a
71
+ 120 s USER-scoped JWT plus the tool's one-time offline grant
72
+ (`hubRefreshToken`; the exchange names NO org — hub ADR 014),
73
+ `cliConnect(token, hubRefreshToken?)` trades the pair at the tool for a
74
+ user-scoped tool-local key (no auth header — the JWT is the credential;
75
+ the grant is relayed so a fresh user's connect is never refused
76
+ `hub_grant_missing`), `exchange(hubApiKey, body)` composes both; the hub
77
+ key never reaches the tool, the grant never reaches anything but the
78
+ tool, and neither is ever persisted here. Errors are `CliConnectError`
79
+ (a `CliAuthError`) tagged with the failing `stage` plus the two
80
+ remedies: `needsHubLogin` (hub 401, or 403 `insufficient_scope` from a
81
+ pre-`sso:exchange` key) and `needsReExchange` (tool 401 on an
82
+ expired/replayed JWT).
83
+ - `lookupConnectKey / storeConnectKey / removeConnectKey` — the
84
+ per-(tool, HUB PROFILE) cache of exchange-minted user-scoped keys, held
85
+ in the tool profile's additive `connectKeys` map (slot = the hub profile
86
+ name; `activeHubProfile(env)` resolves it). ONE key per hub account
87
+ serves every org — the org is a per-request parameter, never part of the
88
+ credential or the cache slot. The legacy single `apiKey` belongs to the
89
+ tool's own login flow and is never consulted here.
90
+ - `connectOnDemand({ tool, toolBaseUrl, resource?, profileName?, env,
84
91
  fetch?, notify?, messages? })` + `probeToolInstance(toolBaseUrl, fetch?)`
85
92
  — the connect-on-demand seam a tool CLI runs when NO direct credential
86
- resolved (extracted from the Slideless CLI): the anonymous `GET
87
- /instance` probe gates the flow (only an Antasphere-cloud instance takes
88
- it — self-hosted/unreachable ones answer `{ outcome: 'not_cloud' }` and
89
- the tool raises its classic no-key error unchanged), the hub credential
90
- is read from the `HUB_TOOL` profile, `exchange` runs with one
91
- re-exchange retry on a dead 120 s JWT (missing/rejected hub login →
92
- guided `antasphere login` `CliUsageError`), and the minted key is cached
93
- per (tool, hub org) with first-contact baseUrl pinning — never onto a
94
- profile that names another instance. `notify` receives the human
95
- "Connected to …" notice (wire your stderr); `messages` overrides the
96
- branded copy (defaults reproduce the Slideless strings modulo tool
97
- name). Success: `{ outcome: 'connected', key, result, cached }`.
93
+ resolved (extracted from the Slideless CLI): the cache is consulted
94
+ FIRST (a hit costs zero network — no probe, no hub, no fresh mint), then
95
+ the anonymous `GET /instance` probe gates the flow (only an
96
+ Antasphere-cloud instance takes it — self-hosted/unreachable ones answer
97
+ `{ outcome: 'not_cloud' }` and the tool raises its classic no-key error
98
+ unchanged), the hub credential is read from the `HUB_TOOL` profile,
99
+ `exchange` runs with one re-exchange retry on a dead 120 s JWT
100
+ (missing/rejected hub login → guided `antasphere login`
101
+ `CliUsageError`), and the minted key is cached per (tool, hub profile)
102
+ with first-contact baseUrl pinning — never onto a profile that names
103
+ another instance. `notify` receives the human "Connected to …" notice on
104
+ fresh mints (wire your stderr; cache hits are silent); `messages`
105
+ overrides the branded copy (defaults reproduce the Slideless strings
106
+ modulo tool name). Success: `{ outcome: 'connected', key, cached,
107
+ result?, stored? }` — `cached: true` = served from the cache.
98
108
  - `getActiveWorkspace / setActiveWorkspace / resolveTargetWorkspace (env)` —
99
109
  hub-profile org context: what `antasphere org use` reads/writes
100
- (`activeWorkspaceId` on the hub profile), and the exchange-target order
101
- `--org` override → active org → the hub key's bound workspace.
110
+ (`activeWorkspaceId` on the hub profile), resolved override → active org
111
+ → the hub key's bound workspace. Org context is a per-request selection
112
+ input for tool calls — it never targets the exchange and never keys the
113
+ connect cache.
102
114
  - `migrateLegacyConfig(env, { tool, legacyDir })` — one-shot, non-destructive
103
115
  import of a tool's pre-cli-core `$XDG_CONFIG_HOME/<legacyDir>/config.json`
104
116
  into the shared home. Imports only when the tool has no profiles in the
package/dist/config.d.ts CHANGED
@@ -25,14 +25,15 @@
25
25
  export type CliEnv = Record<string, string | undefined>;
26
26
  /**
27
27
  * A tool-local key minted by the cross-tool connect exchange (binding
28
- * patterns §7), cached in the tool's profile under the HUB org it was
29
- * exchanged for. Every field beyond the key itself is informational.
28
+ * patterns §7), cached in the tool's profile under the HUB PROFILE whose
29
+ * `antasphere login` credential minted it. The key is USER-scoped (hub
30
+ * ADR 014): one key serves every org — the org is a per-request parameter,
31
+ * never part of the credential or of this cache's slot. Every field beyond
32
+ * the key itself is informational.
30
33
  */
31
- export interface CliWorkspaceKey {
34
+ export interface CliConnectKey {
32
35
  /** Full tool-local API key (`slk_`-style) — shown once at mint, cached here. */
33
36
  apiKey: string;
34
- /** The tool-local workspace the key is bound to (the hub org's projection). */
35
- toolWorkspaceId?: string;
36
37
  /** The signed-in account's email at mint. */
37
38
  email?: string;
38
39
  /** ISO timestamp of the exchange that minted the key. */
@@ -47,12 +48,13 @@ export interface CliProfile {
47
48
  email?: string;
48
49
  /** The org/workspace the key is bound to (one workspace per credential). */
49
50
  workspaceId?: string;
50
- /** Hub profiles only: the org selected via `antasphere org use` (overrides
51
- * the key's bound `workspaceId` as the default exchange target). */
51
+ /** Hub profiles only: the org selected via `antasphere org use` (the
52
+ * default per-request org context; never part of any credential). */
52
53
  activeWorkspaceId?: string;
53
- /** Tool profiles only: exchange-minted keys, one per HUB org — the
54
- * per-(tool, org) cache of the cross-tool connect flow. */
55
- workspaceKeys?: Record<string, CliWorkspaceKey>;
54
+ /** Tool profiles only: exchange-minted USER-scoped keys, ONE per hub
55
+ * profile — the (tool, hub profile) cache of the cross-tool connect
56
+ * flow. Org-independent: a cached key serves every org the user selects. */
57
+ connectKeys?: Record<string, CliConnectKey>;
56
58
  }
57
59
  export interface CliConfig {
58
60
  activeProfile?: string;
@@ -75,23 +77,23 @@ export declare function clearConfig(env: CliEnv, tool: string): void;
75
77
  /** `ant_abcd1234_…` → `ant_abcd1234_…c3f9` — safe for terminals and logs. */
76
78
  export declare function redactKey(key: string): string;
77
79
  /**
78
- * The cached tool-local key for a HUB org, if any. Strictly org-matched:
79
- * the per-org cache first, then the legacy single `apiKey` — but ONLY when
80
- * the profile's `workspaceId` says it is bound to exactly this workspace.
81
- * A key whose binding is unknown is never returned for an org lookup.
80
+ * The cached user-scoped connect key a HUB PROFILE minted for this tool
81
+ * profile, if any. The slot is the hub profile NAME — stable across runs
82
+ * and orgs (the key identifies the user; selecting a different org between
83
+ * runs never misses the cache).
82
84
  */
83
- export declare function lookupWorkspaceKey(profile: CliProfile | undefined, workspaceId: string): string | undefined;
85
+ export declare function lookupConnectKey(profile: CliProfile | undefined, hubProfileName: string): string | undefined;
84
86
  /**
85
- * Cache an exchange-minted tool key under (profile, hub org), creating the
86
- * profile on first contact (and making it active when no profile is active
87
- * yet — first cloud connect on a fresh machine). Every other profile field
88
- * is preserved untouched. Returns the file written.
87
+ * Cache an exchange-minted tool key under (profile, hub profile), creating
88
+ * the profile on first contact (and making it active when no profile is
89
+ * active yet — first cloud connect on a fresh machine). Every other profile
90
+ * field is preserved untouched. Returns the file written.
89
91
  */
90
- export declare function storeWorkspaceKey(env: CliEnv, tool: string, profileName: string, workspaceId: string, entry: CliWorkspaceKey): string;
92
+ export declare function storeConnectKey(env: CliEnv, tool: string, profileName: string, hubProfileName: string, entry: CliConnectKey): string;
91
93
  /**
92
- * Drop one org's cached key from a profile (tool logout for that org).
93
- * Returns whether anything was removed; the legacy single `apiKey` is never
94
- * touched — it belongs to the tool's own login flow.
94
+ * Drop one hub profile's cached connect key (disconnect this tool from the
95
+ * hub account). Returns whether anything was removed; the legacy single
96
+ * `apiKey` is never touched — it belongs to the tool's own login flow.
95
97
  */
96
- export declare function removeWorkspaceKey(env: CliEnv, tool: string, profileName: string, workspaceId: string): boolean;
98
+ export declare function removeConnectKey(env: CliEnv, tool: string, profileName: string, hubProfileName: string): boolean;
97
99
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,C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wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAItD;AAED,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMnE;AAID,oFAAoF;AACpF,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAWlD;AAED,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAQ/D;AAED,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAiB/E;AAED,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAG3D;AAED,6EAA6E;AAC7E,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,UAAU,GAAG,SAAS,EAC/B,cAAc,EAAE,MAAM,GACrB,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,aAAa,GACnB,MAAM,CASR;AAED;;;;GAIG;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
@@ -76,55 +76,48 @@ export function redactKey(key) {
76
76
  return `${key.slice(0, 13)}…${key.slice(-4)}`;
77
77
  }
78
78
  /**
79
- * The cached tool-local key for a HUB org, if any. Strictly org-matched:
80
- * the per-org cache first, then the legacy single `apiKey` — but ONLY when
81
- * the profile's `workspaceId` says it is bound to exactly this workspace.
82
- * A key whose binding is unknown is never returned for an org lookup.
79
+ * The cached user-scoped connect key a HUB PROFILE minted for this tool
80
+ * profile, if any. The slot is the hub profile NAME — stable across runs
81
+ * and orgs (the key identifies the user; selecting a different org between
82
+ * runs never misses the cache).
83
83
  */
84
- export function lookupWorkspaceKey(profile, workspaceId) {
85
- if (!profile)
86
- return undefined;
87
- const entry = profile.workspaceKeys?.[workspaceId];
88
- if (entry?.apiKey)
89
- return entry.apiKey;
90
- if (profile.apiKey && profile.workspaceId === workspaceId)
91
- return profile.apiKey;
92
- return undefined;
84
+ export function lookupConnectKey(profile, hubProfileName) {
85
+ return profile?.connectKeys?.[hubProfileName]?.apiKey;
93
86
  }
94
87
  /**
95
- * Cache an exchange-minted tool key under (profile, hub org), creating the
96
- * profile on first contact (and making it active when no profile is active
97
- * yet — first cloud connect on a fresh machine). Every other profile field
98
- * is preserved untouched. Returns the file written.
88
+ * Cache an exchange-minted tool key under (profile, hub profile), creating
89
+ * the profile on first contact (and making it active when no profile is
90
+ * active yet — first cloud connect on a fresh machine). Every other profile
91
+ * field is preserved untouched. Returns the file written.
99
92
  */
100
- export function storeWorkspaceKey(env, tool, profileName, workspaceId, entry) {
93
+ export function storeConnectKey(env, tool, profileName, hubProfileName, entry) {
101
94
  const config = loadConfig(env, tool);
102
95
  const profile = config.profiles[profileName] ?? {};
103
96
  config.profiles[profileName] = {
104
97
  ...profile,
105
- workspaceKeys: { ...profile.workspaceKeys, [workspaceId]: entry }
98
+ connectKeys: { ...profile.connectKeys, [hubProfileName]: entry }
106
99
  };
107
100
  if (!config.activeProfile)
108
101
  config.activeProfile = profileName;
109
102
  return saveConfig(env, tool, config);
110
103
  }
111
104
  /**
112
- * Drop one org's cached key from a profile (tool logout for that org).
113
- * Returns whether anything was removed; the legacy single `apiKey` is never
114
- * touched — it belongs to the tool's own login flow.
105
+ * Drop one hub profile's cached connect key (disconnect this tool from the
106
+ * hub account). Returns whether anything was removed; the legacy single
107
+ * `apiKey` is never touched — it belongs to the tool's own login flow.
115
108
  */
116
- export function removeWorkspaceKey(env, tool, profileName, workspaceId) {
109
+ export function removeConnectKey(env, tool, profileName, hubProfileName) {
117
110
  const config = loadConfig(env, tool);
118
111
  const profile = config.profiles[profileName];
119
- if (!profile?.workspaceKeys || !(workspaceId in profile.workspaceKeys))
112
+ if (!profile?.connectKeys || !(hubProfileName in profile.connectKeys))
120
113
  return false;
121
- const { [workspaceId]: _dropped, ...rest } = profile.workspaceKeys;
114
+ const { [hubProfileName]: _dropped, ...rest } = profile.connectKeys;
122
115
  if (Object.keys(rest).length === 0) {
123
- const { workspaceKeys: _empty, ...bare } = profile;
116
+ const { connectKeys: _empty, ...bare } = profile;
124
117
  config.profiles[profileName] = bare;
125
118
  }
126
119
  else {
127
- config.profiles[profileName] = { ...profile, workspaceKeys: rest };
120
+ config.profiles[profileName] = { ...profile, connectKeys: rest };
128
121
  }
129
122
  saveConfig(env, tool, config);
130
123
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAmE1C,+EAA+E;AAC/E,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC;AAE9B,MAAM,OAAO,GAAG,mBAAmB,CAAC;AAEpC,oEAAoE;AACpE,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,6CAA6C,CAAC,CAAC;IAChG,CAA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C,QAAQ,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"}
@@ -1,22 +1,28 @@
1
1
  import type { CliEnv } from './config.js';
2
2
  import type { CliConnectResult } from './connect.js';
3
+ import type { ResolvedProfile } from './resolve.js';
3
4
  /**
4
5
  * Connect-on-demand (binding patterns §7, gcloud model), extracted from the
5
6
  * Slideless CLI so every Antasphere tool CLI inherits "one `antasphere login`
6
7
  * serves every federated tool". When a tool CLI resolves NO credential of its
7
8
  * own, it calls `connectOnDemand`:
8
9
  *
9
- * 1. Discovery gates the flow: only an Antasphere-CLOUD instance can mint
10
- * keys through the hub (unauthenticated GET /instance — never guess).
11
- * Unreachable, foreign, or self-hosted instances answer `not_cloud`
12
- * and the tool raises its classic no-key error unchanged.
10
+ * 0. The cache is consulted FIRST: a key minted earlier for THIS instance
11
+ * under the active hub profile is USER-scoped (hub ADR 014) — it serves
12
+ * every subsequent run and every org, with zero network (no probe, no
13
+ * hub round-trip, no fresh mint).
14
+ * 1. On a miss, discovery gates the flow: only an Antasphere-CLOUD
15
+ * instance can mint keys through the hub (unauthenticated GET
16
+ * /instance — never guess). Unreachable, foreign, or self-hosted
17
+ * instances answer `not_cloud` and the tool raises its classic no-key
18
+ * error unchanged.
13
19
  * 2. The hub credential is what `antasphere login` stored on the hub
14
20
  * profile (the config home's HUB_TOOL namespace) — hub URL included,
15
21
  * never a hardcoded constant here.
16
22
  * 3. `CliConnectClient.exchange` trades it for a tool-local key (one
17
23
  * re-exchange retry when the 120 s JWT dies in transit; a rejected hub
18
24
  * credential maps to guided `antasphere login` advice).
19
- * 4. The minted key is cached per (tool, HUB org) — but only onto a
25
+ * 4. The minted key is cached per (tool, HUB PROFILE) — but only onto a
20
26
  * profile that names THIS instance (a fresh profile gets pinned to it);
21
27
  * a profile pointing elsewhere never receives it.
22
28
  *
@@ -40,19 +46,25 @@ export interface ToolInstanceProbe {
40
46
  * callers treat both exactly like "not cloud".
41
47
  */
42
48
  export declare function probeToolInstance(toolBaseUrl: string, fetchImpl?: typeof globalThis.fetch): Promise<ToolInstanceProbe | null>;
43
- /** The facts the connected notice is rendered from. */
49
+ /**
50
+ * The ACTIVE hub profile — what `antasphere login` stored. Its NAME is the
51
+ * connect cache's slot (config.ts `connectKeys`): stable per hub account on
52
+ * this machine, independent of any org selection.
53
+ */
54
+ export declare function activeHubProfile(env: CliEnv): ResolvedProfile;
55
+ /** The facts the connected notice is rendered from (fresh exchanges only —
56
+ * cache hits are silent). */
44
57
  export interface ConnectNoticeFacts {
45
58
  /** The tool instance the exchange connected to (origin-normalized). */
46
59
  toolBaseUrl: string;
47
60
  /** The signed-in account's email at mint. */
48
61
  email: string;
49
- /** The HUB org the exchange resolved to. */
50
- hubWorkspaceId: string;
51
- /** Whether the minted key was cached (per (tool, hub org)). */
52
- cached: boolean;
62
+ /** Whether the minted key was persisted for the next run (per
63
+ * (tool, hub profile)); false = the profile names another instance. */
64
+ stored: boolean;
53
65
  /** The tool profile the cache targeted. */
54
66
  profileName: string;
55
- /** When NOT cached: the other instance the profile points at. */
67
+ /** When NOT stored: the other instance the profile points at. */
56
68
  profileBaseUrl?: string;
57
69
  }
58
70
  /**
@@ -77,27 +89,27 @@ export interface ConnectOnDemandOptions {
77
89
  /** The exchange resource URL; default = this instance's MCP endpoint,
78
90
  * `${toolBaseUrl}/mcp` (the tool's registered resource URL). */
79
91
  resource?: string;
80
- /** Target hub org for the exchange (`--org` → `antasphere org use` → the
81
- * hub key's bound org — resolve via `resolveTargetWorkspace`); omit =
82
- * the hub defaults to the key's bound org server-side. */
83
- org?: string;
84
92
  /** The tool profile the minted key is cached on; default `DEFAULT_PROFILE`. */
85
93
  profileName?: string;
86
94
  env: CliEnv;
87
95
  fetch?: typeof globalThis.fetch;
88
96
  /** Receives the human "Connected to …" notice (tools wire their stderr);
89
- * omitted = silent. Machine output stays untouched either way. */
97
+ * omitted = silent. Cache hits are always silent either way. */
90
98
  notify?: (line: string) => void;
91
99
  messages?: ConnectOnDemandMessages;
92
100
  }
93
101
  export type ConnectOnDemandOutcome = {
94
102
  outcome: 'connected';
95
- /** The minted tool-local key — this invocation's credential. */
103
+ /** The tool-local key — this invocation's credential. */
96
104
  key: string;
97
- /** The full exchange result (user, hub org, tool workspace, key meta). */
98
- result: CliConnectResult;
99
- /** Whether the key was cached per (tool, hub org) for the next run. */
105
+ /** true = served from the (tool, hub profile) config cache: zero
106
+ * network, nothing minted. false = a fresh exchange ran. */
100
107
  cached: boolean;
108
+ /** Fresh exchanges only: the full result (user, key meta). */
109
+ result?: CliConnectResult;
110
+ /** Fresh exchanges only: whether the minted key was persisted for
111
+ * the next run (false = the profile names another instance). */
112
+ stored?: boolean;
101
113
  } | {
102
114
  /** Not an Antasphere-cloud instance (or unreachable): the caller
103
115
  * raises its classic no-key error unchanged. */
@@ -105,10 +117,11 @@ export type ConnectOnDemandOutcome = {
105
117
  };
106
118
  /**
107
119
  * The hub → tool exchange fallback a tool CLI runs when no direct credential
108
- * resolved. Returns `not_cloud` when the instance is not an Antasphere-cloud
109
- * one (or unreachable). Throws a guided `CliUsageError` when the instance IS
110
- * cloud but the hub login is missing or rejected; every other exchange
111
- * failure propagates as its `CliConnectError`.
120
+ * resolved. Serves the cached user-scoped key when one exists for this
121
+ * (instance, hub profile); otherwise returns `not_cloud` when the instance
122
+ * is not an Antasphere-cloud one (or unreachable). Throws a guided
123
+ * `CliUsageError` when the instance IS cloud but the hub login is missing or
124
+ * rejected; every other exchange failure propagates as its `CliConnectError`.
112
125
  */
113
126
  export declare function connectOnDemand(opts: ConnectOnDemandOptions): Promise<ConnectOnDemandOutcome>;
114
127
  //# sourceMappingURL=connect-on-demand.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connect-on-demand.d.ts","sourceRoot":"","sources":["../src/connect-on-demand.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;;;GAsBG;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,CAsBnC;AAED,uDAAuD;AACvD,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,WAAW,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,cAAc,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,MAAM,EAAE,OAAO,CAAC;IAChB,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;0DACsD;IACtD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wEAAwE;IACxE,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,MAAM,CAAC;CACnD;AAuBD,MAAM,WAAW,sBAAsB;IACrC,8EAA8E;IAC9E,IAAI,EA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AED,MAAM,MAAM,sBAAsB,GAC9B;IACE,OAAO,EAAE,WAAW,CAAC;IACrB,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAC;IACZ;iEAC6D;IAC7D,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;AAEN;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAwFnG"}
@@ -1,4 +1,4 @@
1
- import { assertToolNamespace, HUB_TOOL, loadConfig, saveConfig, storeWorkspaceKey } from './config.js';
1
+ import { assertToolNamespace, HUB_TOOL, loadConfig, lookupConnectKey, saveConfig, storeConnectKey } from './config.js';
2
2
  import { CliConnectClient, CliConnectError } from './connect.js';
3
3
  import { CliUsageError, DEFAULT_PROFILE, resolveProfile } from './resolve.js';
4
4
  /**
@@ -30,6 +30,14 @@ export async function probeToolInstance(toolBaseUrl, fetchImpl) {
30
30
  return null;
31
31
  }
32
32
  }
33
+ /**
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.
37
+ */
38
+ export function activeHubProfile(env) {
39
+ return resolveProfile(loadConfig(env, HUB_TOOL), undefined);
40
+ }
33
41
  function defaultMissingHubLogin(tool) {
34
42
  const envVar = `${tool.replace(/-/g, '_').toUpperCase()}_API_KEY`;
35
43
  return (`This ${tool} instance signs in through the Antasphere hub. Run \`antasphere login\` once, ` +
@@ -37,23 +45,38 @@ function defaultMissingHubLogin(tool) {
37
45
  }
38
46
  const DEFAULT_HUB_LOGIN_REJECTED = 'The stored Antasphere hub credential was rejected — run `antasphere login` again, then retry.';
39
47
  function defaultConnected(facts) {
40
- return (`Connected to ${facts.toolBaseUrl} as ${facts.email} via Antasphere (org ${facts.hubWorkspaceId})` +
41
- (facts.cached
48
+ return (`Connected to ${facts.toolBaseUrl} as ${facts.email} via Antasphere` +
49
+ (facts.stored
42
50
  ? ''
43
51
  : ` — key NOT cached: profile '${facts.profileName}' points at ${facts.profileBaseUrl}`) +
44
52
  '.\n');
45
53
  }
46
54
  /**
47
55
  * The hub → tool exchange fallback a tool CLI runs when no direct credential
48
- * resolved. Returns `not_cloud` when the instance is not an Antasphere-cloud
49
- * one (or unreachable). Throws a guided `CliUsageError` when the instance IS
50
- * cloud but the hub login is missing or rejected; every other exchange
51
- * failure propagates as its `CliConnectError`.
56
+ * resolved. Serves the cached user-scoped key when one exists for this
57
+ * (instance, hub profile); otherwise returns `not_cloud` when the instance
58
+ * is not an Antasphere-cloud one (or unreachable). Throws a guided
59
+ * `CliUsageError` when the instance IS cloud but the hub login is missing or
60
+ * rejected; every other exchange failure propagates as its `CliConnectError`.
52
61
  */
53
62
  export async function connectOnDemand(opts) {
54
63
  assertToolNamespace(opts.tool);
55
64
  const toolBaseUrl = opts.toolBaseUrl.replace(/\/+$/, '');
56
65
  const messages = opts.messages ?? {};
66
+ const profileName = opts.profileName ?? DEFAULT_PROFILE;
67
+ // 0. The cache: a key minted earlier by the active hub profile is
68
+ // user-scoped — it serves every run and every org (hub ADR 014; the
69
+ // org is a per-request parameter, never part of the credential). Only
70
+ // a profile that names THIS instance is trusted: a cached key never
71
+ // travels to a different instance. A hit costs zero network.
72
+ const hub = activeHubProfile(opts.env);
73
+ const existing = loadConfig(opts.env, opts.tool).profiles[profileName];
74
+ const pinnedHere = existing?.baseUrl?.replace(/\/+$/, '') === toolBaseUrl;
75
+ if (pinnedHere && hub.name) {
76
+ const cachedKey = lookupConnectKey(existing, hub.name);
77
+ if (cachedKey)
78
+ return { outcome: 'connected', key: cachedKey, cached: true };
79
+ }
57
80
  // 1. Only a CLOUD instance can mint keys through the hub — ask discovery,
58
81
  // never guess. An unreachable or foreign instance is `not_cloud`.
59
82
  const probe = await probeToolInstance(toolBaseUrl, opts.fetch);
@@ -62,21 +85,21 @@ export async function connectOnDemand(opts) {
62
85
  // 2. The hub credential is what `antasphere login` stored on the hub
63
86
  // profile (HUB_TOOL namespace) — one login for the whole tool family.
64
87
  // The hub URL comes from that same profile, never from a constant here.
65
- const { profile: hubProfile } = resolveProfile(loadConfig(opts.env, HUB_TOOL), undefined);
66
- const hubKey = hubProfile?.apiKey;
67
- const hubBaseUrl = hubProfile?.baseUrl;
68
- if (!hubKey || !hubBaseUrl) {
88
+ const hubKey = hub.profile?.apiKey;
89
+ const hubBaseUrl = hub.profile?.baseUrl;
90
+ if (!hubKey || !hubBaseUrl || !hub.name) {
69
91
  throw new CliUsageError(messages.missingHubLogin ?? defaultMissingHubLogin(opts.tool));
70
92
  }
71
93
  // 3. The exchange resource defaults to THIS instance's registered resource
72
94
  // URL — its MCP endpoint, derived from the resolved instance origin.
95
+ // The body names NO org: the exchange is user-scoped end to end.
73
96
  const resource = opts.resource ?? `${toolBaseUrl}/mcp`;
74
97
  const connect = new CliConnectClient({
75
98
  hubBaseUrl,
76
99
  toolBaseUrl,
77
100
  ...(opts.fetch ? { fetch: opts.fetch } : {})
78
101
  });
79
- const body = { resource, ...(opts.org ? { workspaceId: opts.org } : {}) };
102
+ const body = { resource };
80
103
  let result;
81
104
  try {
82
105
  result = await connect.exchange(hubKey, body);
@@ -94,16 +117,13 @@ export async function connectOnDemand(opts) {
94
117
  throw e;
95
118
  }
96
119
  }
97
- // 4. Cache the minted key per (tool, hub org) — but only onto a profile
98
- // that names THIS instance (or a fresh one, which gets pinned to it),
99
- // never onto a profile pointing somewhere else.
100
- const profileName = opts.profileName ?? DEFAULT_PROFILE;
101
- const existing = loadConfig(opts.env, opts.tool).profiles[profileName];
102
- const cached = !existing?.baseUrl || existing.baseUrl.replace(/\/+$/, '') === toolBaseUrl;
103
- if (cached) {
104
- storeWorkspaceKey(opts.env, opts.tool, profileName, result.hubWorkspaceId, {
120
+ // 4. Cache the minted key per (tool, hub profile) — but only onto a
121
+ // profile that names THIS instance (or a fresh one, which gets pinned
122
+ // to it), never onto a profile pointing somewhere else.
123
+ const stored = !existing?.baseUrl || pinnedHere;
124
+ if (stored) {
125
+ storeConnectKey(opts.env, opts.tool, profileName, hub.name, {
105
126
  apiKey: result.key,
106
- toolWorkspaceId: result.toolWorkspaceId,
107
127
  email: result.user.email,
108
128
  mintedAt: new Date().toISOString()
109
129
  });
@@ -118,13 +138,12 @@ export async function connectOnDemand(opts) {
118
138
  const facts = {
119
139
  toolBaseUrl,
120
140
  email: result.user.email,
121
- hubWorkspaceId: result.hubWorkspaceId,
122
- cached,
141
+ stored,
123
142
  profileName,
124
- // `cached` is false only when the profile names another instance.
125
- ...(cached ? {} : { profileBaseUrl: existing?.baseUrl })
143
+ // `stored` is false only when the profile names another instance.
144
+ ...(stored ? {} : { profileBaseUrl: existing?.baseUrl })
126
145
  };
127
146
  opts.notify?.((messages.connected ?? defaultConnected)(facts));
128
- return { outcome: 'connected', key: result.key, result, cached };
147
+ return { outcome: 'connected', key: result.key, result, cached: false, stored };
129
148
  }
130
149
  //# sourceMappingURL=connect-on-demand.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"connect-on-demand.js","sourceRoot":"","sources":["../src/connect-on-demand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEvG,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAqC9E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,WAAmB,EACnB,SAAmC;IAEnC,MAAM,CAAC,GAAG,SAAS,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,C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