@antasphere/cli-core 0.5.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 -85
  2. package/dist/auth.d.ts +1 -1
  3. package/dist/auth.d.ts.map +1 -1
  4. package/dist/config.d.ts +120 -62
  5. package/dist/config.d.ts.map +1 -1
  6. package/dist/config.js +207 -91
  7. package/dist/config.js.map +1 -1
  8. package/dist/connect-on-demand.d.ts +196 -99
  9. package/dist/connect-on-demand.d.ts.map +1 -1
  10. package/dist/connect-on-demand.js +565 -117
  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 -136
  41. package/src/connect-on-demand.ts +801 -223
  42. package/src/connect.ts +8 -8
  43. package/src/index.ts +42 -26
  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
package/src/connect.ts CHANGED
@@ -22,10 +22,10 @@ import { CliAuthError, type CliAuthMintedKey } from './auth.js';
22
22
  * The hub key is sent to the HUB only — it never reaches the tool. The
23
23
  * hubRefreshToken is sent to the TOOL only (it is that tool's own grant;
24
24
  * redeeming it needs the tool client's credentials) and never persisted by
25
- * the CLI. The minted key is cached per (tool profile, hub profile) in the
26
- * tool's config namespace (config.ts `connectKeys`), on the profile of the
27
- * instance it was minted for; day-to-day tool CLI calls then take the
28
- * ordinary local API-key path with the hub out of the loop.
25
+ * the CLI. The minted key is kept on the profile of the site it was minted
26
+ * for, filed by hub and account (config.ts `hubKeys`); day-to-day tool CLI
27
+ * calls then take the ordinary local API-key path with the hub out of the
28
+ * loop.
29
29
  */
30
30
 
31
31
  export type CliConnectStage = 'hub' | 'tool';
@@ -90,7 +90,7 @@ export class CliConnectError extends CliAuthError {
90
90
  }
91
91
 
92
92
  export interface CliToolTokenBody {
93
- /** The tool's registry resource URL (e.g. `https://app.slideless.ai/mcp`).
93
+ /** The tool's registry resource URL (e.g. `https://tool.example.com/mcp`).
94
94
  * The ONLY field — the exchange is user-scoped and names no org
95
95
  * (hub contract `ssoToolTokenRequestSchema`, ADR 014). */
96
96
  resource: string;
@@ -122,7 +122,7 @@ export interface CliConnected {
122
122
 
123
123
  /** The flattened outcome of a full exchange. */
124
124
  export interface CliConnectResult {
125
- /** Full tool-local key — user-scoped: ONE per (tool profile, hub profile),
125
+ /** Full tool-local key — user-scoped: ONE per (profile, hub, account),
126
126
  * valid for every org the user can select per request (config.ts). */
127
127
  key: string;
128
128
  apiKey: CliAuthMintedKey;
@@ -133,9 +133,9 @@ export interface CliConnectResult {
133
133
  }
134
134
 
135
135
  export interface CliConnectClientOptions {
136
- /** Hub origin, e.g. https://account.antasphere.com */
136
+ /** Hub origin, e.g. https://account.example.com */
137
137
  hubBaseUrl: string;
138
- /** Tool instance origin, e.g. https://app.slideless.ai */
138
+ /** Tool instance origin, e.g. https://tool.example.com */
139
139
  toolBaseUrl: string;
140
140
  fetch?: typeof globalThis.fetch;
141
141
  }
package/src/index.ts CHANGED
@@ -1,50 +1,63 @@
1
1
  /**
2
2
  * @antasphere/cli-core — the shared foundation every Antasphere tool CLI
3
3
  * builds on (hub-architecture §8): the `~/.config/antasphere/` config home
4
- * with tool-namespaced profiles where A PROFILE IS AN INSTANCE (named for
5
- * its host, the implicit `cloud` profile at the tool's cloud URL), the
6
- * profile selection rule (--profile → instance URL → active → cloud), the
7
- * flag → env → profile → cloud URL resolution order, the per-command
8
- * organization override (`resolveOrg`; the hub's server-side default
9
- * organization applies otherwise), the instance email-OTP auth client, the
10
- * hub→tool cross-tool connect exchange (user-scoped, no org in the
11
- * exchange) with its per-(tool profile, hub profile) key cache, the
12
- * connect-on-demand seam a tool CLI runs when no direct credential
13
- * resolved, the stranded-key recovery, and the CliIo prompt seam. Tool
14
- * commands, wire types, and API surfaces live in the tools; this package
15
- * carries only config/login plumbing, never secrets.
4
+ * with tool-namespaced profiles where A PROFILE IS AN INSTANCE (a site,
5
+ * named for its host, the implicit `cloud` profile at the tool's cloud URL),
6
+ * every write one locked `updateConfig`, the profile selection rule
7
+ * (--profile → instance URL → active → cloud), the flag → env → profile →
8
+ * cloud URL resolution order, the per-command organization override
9
+ * (`resolveOrg`; the hub's server-side default organization applies
10
+ * otherwise), the instance email-OTP auth client, the hub→tool cross-tool
11
+ * connect exchange (user-scoped, no org in the exchange), the sign-in that
12
+ * follows the site (the login at the hub the site trusts, `planSignIn`) with
13
+ * its kept keys filed by hub and account, the connect-on-demand seam a tool
14
+ * CLI runs when no direct credential resolved, the stranded-key recovery,
15
+ * and the CliIo prompt seam. Tool commands, wire types, and API surfaces
16
+ * live in the tools; this package carries only config/login plumbing, never
17
+ * secrets.
16
18
  */
17
19
 
18
20
  export {
19
21
  assertToolNamespace,
22
+ CliConfigError,
20
23
  clearConfig,
21
24
  configPath,
22
25
  HUB_TOOL,
23
26
  loadConfig,
24
- lookupConnectKey,
25
27
  parseConfig,
26
- profileCredential,
27
28
  redactKey,
28
- removeConnectKey,
29
- saveConfig,
30
- storeConnectKey
29
+ updateConfig
31
30
  } from './config.js';
31
+ export type { CliConfig, CliConnectKey, CliEnv, CliHubKey, CliProfile, CliSiteFacts } from './config.js';
32
+
33
+ export { forgetKeys, keysHeldElsewhere, keysOfProfile } from './kept-keys.js';
34
+ export type { ProfileKey } from './kept-keys.js';
35
+
36
+ export { chooseHub, chooseLogin, listLogins, planSignIn, undecidedLogins } from './sign-in.js';
32
37
  export type {
33
- CliConfig,
34
- CliConnectKey,
35
- CliEnv,
36
- CliProfile,
37
- ProfileCredential,
38
- StoreConnectKeyOptions
39
- } from './config.js';
38
+ ChooseHubInput,
39
+ ChooseLoginInput,
40
+ CliLogin,
41
+ HubChoice,
42
+ HubSource,
43
+ LoginChoice,
44
+ PlanSignInInput,
45
+ SignInPlan,
46
+ SignInReason,
47
+ SignInState
48
+ } from './sign-in.js';
40
49
 
41
50
  export { ask, printJson } from './io.js';
42
51
  export type { CliIo } from './io.js';
43
52
 
53
+ export { withFileLockAsync } from './lock.js';
54
+ export type { FileLockOptions } from './lock.js';
55
+
44
56
  export {
45
57
  CLOUD_PROFILE,
46
58
  CliUsageError,
47
59
  firstSet,
60
+ freshProfileName,
48
61
  normalizeUrl,
49
62
  profileNameFor,
50
63
  profileUrl,
@@ -87,16 +100,19 @@ export type {
87
100
  } from './connect.js';
88
101
 
89
102
  export {
90
- activeHubProfile,
91
103
  connectOnDemand,
104
+ HUB_URL_ENV,
92
105
  probeToolInstance,
93
- refreshConnectKey
106
+ refreshConnectKey,
107
+ rememberSite
94
108
  } from './connect-on-demand.js';
95
109
  export type {
110
+ ConnectedLogin,
96
111
  ConnectNoticeFacts,
97
112
  ConnectOnDemandMessages,
98
113
  ConnectOnDemandOptions,
99
114
  ConnectOnDemandOutcome,
115
+ RefreshConnectKeyOptions,
100
116
  ToolInstanceProbe
101
117
  } from './connect-on-demand.js';
102
118