@antasphere/cli-core 0.6.0 → 0.7.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.
Files changed (48) hide show
  1. package/README.md +324 -96
  2. package/dist/auth.d.ts +1 -1
  3. package/dist/auth.d.ts.map +1 -1
  4. package/dist/config.d.ts +120 -73
  5. package/dist/config.d.ts.map +1 -1
  6. package/dist/config.js +207 -109
  7. package/dist/config.js.map +1 -1
  8. package/dist/connect-on-demand.d.ts +194 -132
  9. package/dist/connect-on-demand.d.ts.map +1 -1
  10. package/dist/connect-on-demand.js +561 -148
  11. package/dist/connect-on-demand.js.map +1 -1
  12. package/dist/connect.d.ts +8 -8
  13. package/dist/connect.d.ts.map +1 -1
  14. package/dist/index.d.ts +25 -17
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +20 -15
  17. package/dist/index.js.map +1 -1
  18. package/dist/kept-keys.d.ts +208 -0
  19. package/dist/kept-keys.d.ts.map +1 -0
  20. package/dist/kept-keys.js +484 -0
  21. package/dist/kept-keys.js.map +1 -0
  22. package/dist/lock.d.ts +65 -0
  23. package/dist/lock.d.ts.map +1 -0
  24. package/dist/lock.js +408 -0
  25. package/dist/lock.js.map +1 -0
  26. package/dist/migrate.d.ts +9 -3
  27. package/dist/migrate.d.ts.map +1 -1
  28. package/dist/migrate.js +32 -11
  29. package/dist/migrate.js.map +1 -1
  30. package/dist/resolve.d.ts +12 -4
  31. package/dist/resolve.d.ts.map +1 -1
  32. package/dist/resolve.js +12 -8
  33. package/dist/resolve.js.map +1 -1
  34. package/dist/sign-in.d.ts +266 -0
  35. package/dist/sign-in.d.ts.map +1 -0
  36. package/dist/sign-in.js +398 -0
  37. package/dist/sign-in.js.map +1 -0
  38. package/package.json +1 -1
  39. package/src/auth.ts +1 -1
  40. package/src/config.ts +303 -158
  41. package/src/connect-on-demand.ts +797 -271
  42. package/src/connect.ts +8 -8
  43. package/src/index.ts +40 -27
  44. package/src/kept-keys.ts +561 -0
  45. package/src/lock.ts +479 -0
  46. package/src/migrate.ts +33 -11
  47. package/src/resolve.ts +20 -15
  48. package/src/sign-in.ts +601 -0
@@ -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;AA4E1C,+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,CAAC;AACH,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,IAAY;IAClD,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC1B,MAAM,IAAI,GAAG,GAAG,CAAC,eAAe,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAClF,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACtC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,OAAO,CAAC,CAAC;AAC7F,CAAC;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AAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC"}
@@ -1,202 +1,264 @@
1
1
  import type { CliEnv } from './config.js';
2
2
  import type { CliConnectResult } from './connect.js';
3
- import type { ResolvedProfile } from './resolve.js';
4
3
  /**
5
- * Connect-on-demand (binding patterns §7, gcloud model), extracted from the
6
- * Slideless CLI so every Antasphere tool CLI inherits "one `antasphere login`
7
- * serves every federated tool". When a tool CLI resolves NO credential of its
8
- * own, it calls `connectOnDemand` with the profile it selected
9
- * (`selectProfile`: the profile IS the instance):
4
+ * Connect-on-demand (binding patterns §7, gcloud model): one Antasphere login
5
+ * per hub serves every federated tool. When a tool CLI resolves NO credential
6
+ * of its own, it calls `connectOnDemand` with the profile it selected
7
+ * (`selectProfile`: the profile IS the site), and the sign-in FOLLOWS THE
8
+ * SITE (R2, PRDCT-3521): the login used is the login at the hub the site
9
+ * trusts (`planSignIn`), never the machine's active hub login.
10
10
  *
11
- * 0. The cache is consulted FIRST: a key minted earlier for THIS instance
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.
22
- * 1. On a miss, discovery gates the flow: only an Antasphere-CLOUD
23
- * instance can mint keys through the hub (unauthenticated GET
24
- * /instance — never guess). Unreachable, foreign, or self-hosted
25
- * instances answer `not_cloud` and the tool raises its classic no-key
26
- * error unchanged.
27
- * 2. The hub credential is what `antasphere login` stored on the hub
28
- * profile (the config home's HUB_TOOL namespace) — hub URL included,
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.
34
- * 3. `CliConnectClient.exchange` trades it for a tool-local key (one
35
- * re-exchange retry when the 120 s JWT dies in transit; a rejected hub
36
- * credential maps to guided `antasphere login` advice on either
37
- * attempt; a hub REFUSAL, a 403 that is not the scope case, propagates
38
- * as its `CliConnectError` with the hub's own sentence and `exitCode`
39
- * 3).
40
- * 4. The minted key is cached on the SELECTED profile under the hub
41
- * profile's name. A profile not on disk yet is created with this
42
- * instance's URL, and made active only when the tool had no profile at
43
- * all; an existing profile is never renamed or repointed, and one that
44
- * is at another instance never receives the key.
11
+ * 0. A profile at another site than the command's is refused before any
12
+ * request, and so is a profile with no site of its own that holds a
13
+ * key (its keys are never adopted): nothing is minted for a profile
14
+ * that cannot keep the key (PRDCT-3044). The old slots are moved once.
15
+ * Then the plan: a refusal
16
+ * (`ANTASPHERE_URL` or `--hub` naming another hub than the site's) is
17
+ * thrown; a servable kept key is served with zero network, after one
18
+ * discovery read when what the profile remembers of its site is missing
19
+ * or older than a day (`cached: false` skips this step).
20
+ * 1. Discovery gates the flow: only a site that signs in through an
21
+ * Antasphere hub can mint keys through one (unauthenticated GET
22
+ * /instance, never a guess); an unreachable, foreign or self-hosted site
23
+ * answers `not_cloud`, and the tool raises its classic no-key error.
24
+ * What the site says is remembered on its profile (`rememberSite`).
25
+ * 2. The plan again, on the fresh facts: a refusal, a hub to pick or a
26
+ * login to pick is a `CliUsageError` naming the way out.
45
27
  *
46
- * A stranded key recovers: on a 401 with a key that came from the cache,
47
- * the tool CLI calls `refreshConnectKey` once (evict, exchange again with
48
- * `cached: false`) and retries its request once; a second 401 fails.
28
+ * Whatever the command ends with (a key served, an error, `not_cloud` from
29
+ * a site that answered, an exchange), the stale keys of its plan go first:
30
+ * revoked on the profile's own site with no lock held, then forgotten; a
31
+ * site that does not answer within the limit (`requestTimeoutMs`, 10 s:
32
+ * every revoke on a command's way is bounded) keeps them for the next
33
+ * command. A key whose login is gone is one of them. A stale key another
34
+ * profile at that same site still holds is never revoked: it is forgotten
35
+ * on this profile only, and `notify` says so (`keysHeldElsewhere`, R2's
36
+ * one rule).
37
+ * 3. The mint is single-flight: a second lock, per (profile, hub, e-mail),
38
+ * the file read again inside it (and the login, when it carried no
39
+ * e-mail: another command's exchange may have told its address), and
40
+ * the exchange only when the key is still missing. The hub key goes to
41
+ * the chosen login's OWN hub and nowhere else (one re-exchange retry
42
+ * when the 120 s JWT dies in transit; a rejected hub key maps to
43
+ * `messages.hubLoginRejected`; a refusal propagates as its
44
+ * `CliConnectError`, exit code 3). A hub the profile's `lastHub` chose
45
+ * (or, in a recovery, the refused key's) that does not know this site's
46
+ * resource ends on that error with the way out appended (`login --hub
47
+ * <hub>`).
48
+ * 4. First stored wins: when another command stored a kept key for the
49
+ * slot after this command's re-read under the mint lock, it is kept and
50
+ * used, and the key just minted is revoked on the site; when the site
51
+ * does not answer that revoke, the key is filed undated in its slot, a
52
+ * stale duplicate the next command revokes; when it refuses it (a 403),
53
+ * `notify` is told and nothing is filed. A key the profile held at
54
+ * that re-read is not first stored (a login with no e-mail is never
55
+ * served a key, so its exchange may mint for a slot that holds one): the
56
+ * key just minted is stored beside it, and the older one is a stale
57
+ * duplicate the next command revokes. A key minted for a profile that
58
+ * cannot keep it is revoked on its site, and `notify` is told when that
59
+ * revoke did not answer. The store writes the address of the hub the
60
+ * exchange went through on the profile, in its normal form
61
+ * (`normalizeUrl`: `lastHub`), whichever key is kept.
62
+ * 5. A login whose address the hub's answer contradicts (or that had none)
63
+ * takes the hub's address (`healed`), before the mint lock is let go:
64
+ * a command waiting on it with that login finds the key just kept.
49
65
  *
50
- * A new tool needs only its namespace, its cloud URL, and copy — the flow
51
- * itself is tool-agnostic.
66
+ * A stranded key recovers: on a 401 with a key served `cached: true`, the
67
+ * tool CLI calls `refreshConnectKey` once with that key (compare-and-evict,
68
+ * the refused key's hub kept as the profile's `lastHub` when it holds none,
69
+ * then the exchange again for the refused key's account, at that key's hub
70
+ * when the site names none and a login is in place there) and retries its
71
+ * request once; a second 401 fails.
52
72
  */
53
- /** What the unauthenticated discovery probe learned about a tool instance. */
73
+ /** What the unauthenticated discovery probe learned about a site. */
54
74
  export interface ToolInstanceProbe {
55
- /** Whether the instance signs in through the Antasphere hub (advertises
56
- * the `antasphere` auth method, or calls itself the cloud edition). */
75
+ /** The site probed (`normalizeUrl`'d): whose facts these are. */
76
+ url: string;
77
+ /** Whether the site signs in through an Antasphere hub (advertises the
78
+ * `antasphere` auth method, or calls itself the cloud edition). */
57
79
  cloud: boolean;
58
- /** The instance's self-reported edition (`cloud`, `oss`, …). */
80
+ /** The site's self-reported edition (`cloud`, `oss`, …). */
59
81
  edition: string | undefined;
60
82
  /** The advertised auth methods (open enum — unknown entries kept). */
61
83
  authMethods: string[];
84
+ /** The Antasphere hub the site names (`auth.hub`, `normalizeUrl`'d), or null when it names none. */
85
+ hub: string | null;
86
+ /** Its discovery `name`, or null. */
87
+ name: string | null;
88
+ /** The CLI version it announces (`cli.version`), or null. */
89
+ cliVersion: string | null;
62
90
  }
63
91
  /**
64
- * Probe a tool instance's unauthenticated discovery endpoint
92
+ * Probe a site's unauthenticated discovery endpoint
65
93
  * (`GET {toolBaseUrl}/api/v1/instance`). Returns what it advertises, or
66
- * `null` when the instance is unreachable or answers a foreign shape —
67
- * callers treat both exactly like "not cloud".
94
+ * `null` when the site is unreachable or answers a foreign shape — callers
95
+ * treat both exactly like "not cloud".
68
96
  */
69
97
  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. */
98
+ /** The hub's URL env var: for a site that names no hub, the hub a command signs in at. */
71
99
  export declare const HUB_URL_ENV = "ANTASPHERE_URL";
72
100
  /**
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.
101
+ * Remember what a site said of itself on its profile, under `updateConfig`:
102
+ * only for a profile on disk at that site (`probe.url`; a profile with no
103
+ * `baseUrl` is at `cloudUrl`), and only when the hub, `federated`, the name
104
+ * or the CLI version differ from what the profile holds, or when its
105
+ * `seenAt` is older than 24 hours, or with `force` (`profiles --check`).
106
+ * Otherwise nothing is written. Answers whether the file changed.
86
107
  */
87
- export declare function selectHubProfile(env: CliEnv, opts?: {
108
+ export declare function rememberSite(env: CliEnv, tool: string, profileName: string, probe: ToolInstanceProbe, opts?: {
109
+ force?: boolean | undefined;
88
110
  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.
95
- */
96
- export declare function activeHubProfile(env: CliEnv): ResolvedProfile;
97
- /** The facts the connected notice is rendered from (fresh exchanges only —
98
- * cache hits are silent). */
111
+ }): boolean;
112
+ /** The facts the connected notice is rendered from (fresh exchanges only — served keys are silent). */
99
113
  export interface ConnectNoticeFacts {
100
- /** The tool instance the exchange connected to (origin-normalized). */
114
+ /** The site the exchange connected to (origin-normalized). */
101
115
  toolBaseUrl: string;
102
- /** The signed-in account's email at mint. */
116
+ /** The signed-in account's email, as the hub answered it. */
103
117
  email: string;
104
- /** Whether the minted key was persisted for the next run (on the
105
- * selected profile, under the hub profile's name); false = the profile
106
- * is at another instance. */
118
+ /** Whether the minted key was kept on the profile: always true (a profile at another site is
119
+ * refused before any request). */
107
120
  stored: boolean;
108
- /** The tool profile the cache targeted. */
121
+ /** The tool profile the key is kept on. */
109
122
  profileName: string;
110
- /** When NOT stored: the other instance the profile is at. */
123
+ /** Never set any more (kept for the shape of 0.6). */
111
124
  profileBaseUrl?: string;
112
125
  }
113
126
  /**
114
- * Branded copy seams. Defaults reproduce the Slideless CLI's strings modulo
115
- * the tool name (the tool namespace stands in for the display name, and the
116
- * key-env-var name is derived from it: `slideless` → `SLIDELESS_API_KEY`).
127
+ * Branded copy seams. The sentences that say why a command cannot sign in
128
+ * (a refusal, a hub or a login to pick, no login at the site's hub) are
129
+ * cli-core's own, with the tool's binary (`bin`) in them.
117
130
  */
118
131
  export interface ConnectOnDemandMessages {
119
- /** `CliUsageError` text when the instance is cloud but no `antasphere
120
- * login` credential is stored on the hub profile. */
121
- missingHubLogin?: string;
122
- /** `CliUsageError` text when the hub rejected the stored credential. */
132
+ /** `CliUsageError` text when the hub rejected the login's stored key. */
123
133
  hubLoginRejected?: string;
124
134
  /** Renders the success notice handed to `notify` (newline included). */
125
135
  connected?: (facts: ConnectNoticeFacts) => string;
126
136
  }
127
137
  export interface ConnectOnDemandOptions {
128
- /** The tool's config namespace (lowercase slug — it names the cache file). */
138
+ /** The tool's config namespace (lowercase slug — it names the profiles file). */
129
139
  tool: string;
130
- /** The resolved tool instance origin the CLI is talking to. */
140
+ /** The site the command talks to. */
131
141
  toolBaseUrl: string;
132
142
  /** The tool's cloud URL, the same value `selectProfile` got: what a
133
143
  * profile with no `baseUrl` of its own is at. Omit only for a tool with
134
- * no cloud instance. */
144
+ * no cloud site. */
135
145
  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;
142
- /** The exchange resource URL; default = this instance's MCP endpoint,
146
+ /** REQUIRED: the hub's cloud URL, what a login with no `baseUrl` of its own
147
+ * is at (`listLogins`); a `TypeError` naming it when it is missing, blank
148
+ * or not an `http:` or `https:` URL. A login's own `baseUrl` always wins,
149
+ * and its key goes to that login's own hub only. */
150
+ hubCloudUrl: string;
151
+ /** `login --hub`: the hub to sign in at, for a site that names none. Refused, both named, when
152
+ * the site names another one. */
153
+ hubUrl?: string | undefined;
154
+ /** `login --email`: the account to sign in with, among the logins at the site's hub. */
155
+ email?: string | undefined;
156
+ /** The binary named in the sentences (default: the tool's namespace). */
157
+ bin?: string | undefined;
158
+ /** The exchange resource URL; default = this site's MCP endpoint,
143
159
  * `${toolBaseUrl}/mcp` (the tool's registered resource URL). */
144
160
  resource?: string;
145
161
  /** The tool profile the CLI selected for this run (`selectProfile`), the
146
- * one the minted key is cached on. Not on disk yet → created with
147
- * `toolBaseUrl` on first contact; at another instance → the key is
148
- * returned but never stored. cli-core never guesses it. */
162
+ * one the key is kept on. Not on disk yet → created with `toolBaseUrl` on
163
+ * first contact; at another site → refused before any request. cli-core
164
+ * never guesses it. */
149
165
  profileName: string;
150
166
  env: CliEnv;
151
167
  fetch?: typeof globalThis.fetch;
152
- /** Receives the human "Connected to …" notice (tools wire their stderr);
153
- * omitted = silent. Cache hits are always silent either way. */
168
+ /** Receives the human "Connected to …" notice, and the line that says a key
169
+ * minted on the site could not be revoked there (tools wire their stderr);
170
+ * omitted = silent. Served keys are always silent either way. */
154
171
  notify?: (line: string) => void;
155
172
  messages?: ConnectOnDemandMessages;
156
- /** false = do not read the cache: run the exchange even when a key is
157
- * cached (the one re-exchange after a 401 on a cached key;
158
- * `refreshConnectKey` sets it). Default true. */
173
+ /** false = skip step 0 (serving a kept key before discovery is read):
174
+ * discovery is read and the plan decided on fresh facts. A kept key the
175
+ * file holds for the slot inside the mint lock is still used (another
176
+ * command's mint); a caller that wants a fresh key forgets the kept one
177
+ * first (`forgetKeys`). Default true. */
159
178
  cached?: boolean;
179
+ /** The limit of each revoke cli-core sends on a command's way (a profile's stale keys, a key just
180
+ * minted that cannot be kept), in milliseconds: past it the revoke is aborted and counts as no
181
+ * answer (a stale key then stays for the next command), and the command goes on. 10 s when absent;
182
+ * a value that is not an integer from 1 to 2 147 483 647 (2^31 − 1) reads as absent: a Node timer
183
+ * refuses a fraction and cuts a longer delay to 1 ms. */
184
+ requestTimeoutMs?: number;
185
+ }
186
+ export interface RefreshConnectKeyOptions extends ConnectOnDemandOptions {
187
+ /** The kept key the site refused (401): evicted only when it is still the one kept. */
188
+ refusedKey: string;
189
+ }
190
+ /** The login that signed a command in. */
191
+ export interface ConnectedLogin {
192
+ /** The login's entry name in the hub file. */
193
+ name: string;
194
+ /** Its hub. */
195
+ hub: string;
196
+ /** The account's address. */
197
+ email: string;
160
198
  }
161
199
  export type ConnectOnDemandOutcome = {
162
200
  outcome: 'connected';
163
201
  /** The tool-local key — this invocation's credential. */
164
202
  key: string;
165
- /** true = served from the (tool profile, hub profile) config cache:
166
- * zero network, nothing minted. false = a fresh exchange ran. A 401
167
- * on a `cached: true` key is what warrants `refreshConnectKey`. */
203
+ /** true = a kept key, nothing minted by this command (served, or stored by another
204
+ * command first). false = a fresh exchange ran and its key is kept. A 401 on a
205
+ * `cached: true` key is what warrants `refreshConnectKey`. */
168
206
  cached: boolean;
207
+ /** The login that signed the command in. */
208
+ login: ConnectedLogin;
169
209
  /** Fresh exchanges only: the full result (user, key meta). */
170
210
  result?: CliConnectResult;
171
- /** Fresh exchanges only: whether the minted key was persisted for
172
- * the next run (false = the profile is at another instance). */
211
+ /** Fresh exchanges only: the minted key is kept on the profile (always true). */
173
212
  stored?: boolean;
213
+ /** The login's address, replaced by the hub's answer after a fresh exchange
214
+ * (`from` null when it had none). */
215
+ healed?: {
216
+ from: string | null;
217
+ to: string;
218
+ };
174
219
  } | {
175
- /** Not an Antasphere-cloud instance (or unreachable): the caller
220
+ /** Not a site that signs in through an Antasphere hub (or unreachable): the caller
176
221
  * raises its classic no-key error unchanged. */
177
222
  outcome: 'not_cloud';
178
223
  };
179
224
  /**
180
- * The hub → tool exchange fallback a tool CLI runs when no direct credential
181
- * resolved. Serves the cached user-scoped key when one exists for this
182
- * (instance, hub profile) on the selected profile; otherwise returns
183
- * `not_cloud` when the instance is not an Antasphere-cloud one (or
184
- * unreachable). Throws a guided `CliUsageError` when the instance IS cloud
185
- * but the hub login is missing or rejected; a refusal and every other
186
- * exchange failure propagate as their `CliConnectError` (`exitCode` says 3
187
- * for the refusal, `message` is the server's own sentence).
225
+ * The hub → tool exchange a tool CLI runs when no direct credential resolved,
226
+ * signed in by the login at the hub the site trusts (the flow is the module
227
+ * comment's). Answers the key (`cached: true` when kept, false when minted by
228
+ * this command) with the login that signed it in, or `not_cloud`. Throws a
229
+ * `CliUsageError` naming the way out when the profile is at another site or
230
+ * has no site of its own while it holds a key (both before any request),
231
+ * when `ANTASPHERE_URL` or `hubUrl` names another hub than the site's, when
232
+ * a hub or a login must be picked, when no login is at the site's hub, or
233
+ * when the hub rejected the login's key; a refusal and every other exchange
234
+ * failure propagate as their `CliConnectError` (`exitCode` 3 for a refusal).
235
+ * A missing, blank or unreadable `hubCloudUrl` is a `TypeError` naming it,
236
+ * before any read, request or write.
188
237
  */
189
238
  export declare function connectOnDemand(opts: ConnectOnDemandOptions): Promise<ConnectOnDemandOutcome>;
190
239
  /**
191
240
  * The stranded-key recovery: what a tool CLI calls once when a request
192
- * answered 401 with a key that `connectOnDemand` served from the cache
193
- * (`cached: true`). Evicts that key from the selected profile (the hub
194
- * revoked it, or a membership was swept), only when that profile is at
195
- * this instance (a key of another instance is never touched), and runs the
196
- * exchange again with the cache skipped. The caller retries its request
197
- * once with the new key and fails on a second 401; `not_cloud` means there
198
- * is nothing to recover with, and the caller fails with its 401 as it
199
- * stands.
241
+ * answered 401 with a key `connectOnDemand` served (`cached: true`), with that
242
+ * key as `refusedKey`. COMPARE-AND-EVICT: the kept entry whose key is
243
+ * `refusedKey` is removed (only on a profile at this site); when none is,
244
+ * another command already replaced it, and the kept key the plan now serves
245
+ * is returned (`cached: true`) with no exchange. Otherwise the exchange runs
246
+ * again (`cached: false`), never serving the refused key. The refused key's
247
+ * slot is read before the eviction takes it away: the recovery continues the
248
+ * command whose key was refused, so its account picks the login at the hub
249
+ * the recovery signs in at, the way the `email` option does when the caller
250
+ * gives none, and its hub is the recovery's first hint, never the `hubUrl`
251
+ * option: for a site that names no hub, the order is `--hub`,
252
+ * `ANTASPHERE_URL`, the refused key's hub while a login is in place there,
253
+ * the newest kept key in place, then `lastHub`; a site that names a hub
254
+ * decides it. The eviction's own write also keeps that hub as the profile's
255
+ * `lastHub` when the profile holds none (one from before the field), for the
256
+ * commands after it. An exchange that hub refuses because it does not know
257
+ * the site ends on the way out, as at a remembered hub (`login --hub`). The
258
+ * caller retries its request once with the new key and fails on a second
259
+ * 401; `not_cloud` means there is nothing to recover with. A missing, blank
260
+ * or unreadable `hubCloudUrl` is a `TypeError` naming it, before anything is
261
+ * read, evicted or sent.
200
262
  */
201
- export declare function refreshConnectKey(opts: ConnectOnDemandOptions): Promise<ConnectOnDemandOutcome>;
263
+ export declare function refreshConnectKey(opts: RefreshConnectKeyOptions): Promise<ConnectOnDemandOutcome>;
202
264
  //# 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":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,aAAa,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAUrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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