@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.
- package/README.md +324 -85
- package/dist/auth.d.ts +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/config.d.ts +120 -62
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +207 -91
- package/dist/config.js.map +1 -1
- package/dist/connect-on-demand.d.ts +196 -99
- package/dist/connect-on-demand.d.ts.map +1 -1
- package/dist/connect-on-demand.js +565 -117
- package/dist/connect-on-demand.js.map +1 -1
- package/dist/connect.d.ts +8 -8
- package/dist/connect.d.ts.map +1 -1
- package/dist/index.d.ts +25 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -15
- package/dist/index.js.map +1 -1
- package/dist/kept-keys.d.ts +208 -0
- package/dist/kept-keys.d.ts.map +1 -0
- package/dist/kept-keys.js +484 -0
- package/dist/kept-keys.js.map +1 -0
- package/dist/lock.d.ts +65 -0
- package/dist/lock.d.ts.map +1 -0
- package/dist/lock.js +408 -0
- package/dist/lock.js.map +1 -0
- package/dist/migrate.d.ts +9 -3
- package/dist/migrate.d.ts.map +1 -1
- package/dist/migrate.js +32 -11
- package/dist/migrate.js.map +1 -1
- package/dist/resolve.d.ts +12 -4
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +12 -8
- package/dist/resolve.js.map +1 -1
- package/dist/sign-in.d.ts +266 -0
- package/dist/sign-in.d.ts.map +1 -0
- package/dist/sign-in.js +398 -0
- package/dist/sign-in.js.map +1 -0
- package/package.json +1 -1
- package/src/auth.ts +1 -1
- package/src/config.ts +303 -136
- package/src/connect-on-demand.ts +801 -223
- package/src/connect.ts +8 -8
- package/src/index.ts +42 -26
- package/src/kept-keys.ts +561 -0
- package/src/lock.ts +479 -0
- package/src/migrate.ts +33 -11
- package/src/resolve.ts +20 -15
- 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
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
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://
|
|
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 (
|
|
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.
|
|
136
|
+
/** Hub origin, e.g. https://account.example.com */
|
|
137
137
|
hubBaseUrl: string;
|
|
138
|
-
/** Tool instance origin, e.g. https://
|
|
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 (
|
|
5
|
-
* its host, the implicit `cloud` profile at the tool's cloud URL),
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* exchange
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|