@antasphere/chassis-cli 0.0.0-stage → 1.0.1

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 (117) hide show
  1. package/LICENSE +82 -0
  2. package/dist/commands/auth.d.ts +6 -0
  3. package/dist/commands/auth.d.ts.map +1 -0
  4. package/dist/commands/auth.js +582 -0
  5. package/dist/commands/auth.js.map +1 -0
  6. package/dist/commands/completion.d.ts +5 -0
  7. package/dist/commands/completion.d.ts.map +1 -0
  8. package/dist/commands/completion.js +85 -0
  9. package/dist/commands/completion.js.map +1 -0
  10. package/dist/commands/demo.d.ts +12 -0
  11. package/dist/commands/demo.d.ts.map +1 -0
  12. package/dist/commands/demo.js +210 -0
  13. package/dist/commands/demo.js.map +1 -0
  14. package/dist/commands/files.d.ts +21 -0
  15. package/dist/commands/files.d.ts.map +1 -0
  16. package/dist/commands/files.js +178 -0
  17. package/dist/commands/files.js.map +1 -0
  18. package/dist/commands/projects.d.ts +38 -0
  19. package/dist/commands/projects.d.ts.map +1 -0
  20. package/dist/commands/projects.js +386 -0
  21. package/dist/commands/projects.js.map +1 -0
  22. package/dist/commands/teams.d.ts +46 -0
  23. package/dist/commands/teams.d.ts.map +1 -0
  24. package/dist/commands/teams.js +265 -0
  25. package/dist/commands/teams.js.map +1 -0
  26. package/dist/commands/workspaces.d.ts +22 -0
  27. package/dist/commands/workspaces.d.ts.map +1 -0
  28. package/dist/commands/workspaces.js +116 -0
  29. package/dist/commands/workspaces.js.map +1 -0
  30. package/dist/config.d.ts +29 -0
  31. package/dist/config.d.ts.map +1 -0
  32. package/dist/config.js +54 -0
  33. package/dist/config.js.map +1 -0
  34. package/dist/context.d.ts +152 -0
  35. package/dist/context.d.ts.map +1 -0
  36. package/dist/context.js +456 -0
  37. package/dist/context.js.map +1 -0
  38. package/dist/identity.d.ts +36 -0
  39. package/dist/identity.d.ts.map +1 -0
  40. package/dist/identity.js +18 -0
  41. package/dist/identity.js.map +1 -0
  42. package/dist/index.d.ts +24 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +31 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/kit.d.ts +46 -0
  47. package/dist/kit.d.ts.map +1 -0
  48. package/dist/kit.js +2 -0
  49. package/dist/kit.js.map +1 -0
  50. package/dist/open.d.ts +27 -0
  51. package/dist/open.d.ts.map +1 -0
  52. package/dist/open.js +45 -0
  53. package/dist/open.js.map +1 -0
  54. package/dist/owner-session.d.ts +34 -0
  55. package/dist/owner-session.d.ts.map +1 -0
  56. package/dist/owner-session.js +106 -0
  57. package/dist/owner-session.js.map +1 -0
  58. package/dist/program.d.ts +5 -0
  59. package/dist/program.d.ts.map +1 -0
  60. package/dist/program.js +150 -0
  61. package/dist/program.js.map +1 -0
  62. package/dist/safe-write.d.ts +46 -0
  63. package/dist/safe-write.d.ts.map +1 -0
  64. package/dist/safe-write.js +127 -0
  65. package/dist/safe-write.js.map +1 -0
  66. package/dist/stdin.d.ts +4 -0
  67. package/dist/stdin.d.ts.map +1 -0
  68. package/dist/stdin.js +36 -0
  69. package/dist/stdin.js.map +1 -0
  70. package/dist/testing/index.d.ts +70 -0
  71. package/dist/testing/index.d.ts.map +1 -0
  72. package/dist/testing/index.js +67 -0
  73. package/dist/testing/index.js.map +1 -0
  74. package/dist/workspace.d.ts +79 -0
  75. package/dist/workspace.d.ts.map +1 -0
  76. package/dist/workspace.js +139 -0
  77. package/dist/workspace.js.map +1 -0
  78. package/package.json +43 -3
  79. package/src/commands/auth.ts +687 -0
  80. package/src/commands/completion.ts +102 -0
  81. package/src/commands/demo.ts +271 -0
  82. package/src/commands/files.ts +197 -0
  83. package/src/commands/projects.ts +460 -0
  84. package/src/commands/teams.ts +320 -0
  85. package/src/commands/workspaces.ts +140 -0
  86. package/src/config.ts +81 -0
  87. package/src/context.ts +616 -0
  88. package/src/identity.ts +48 -0
  89. package/src/index.ts +70 -0
  90. package/src/kit.ts +50 -0
  91. package/src/open.ts +48 -0
  92. package/src/owner-session.ts +152 -0
  93. package/src/program.ts +183 -0
  94. package/src/safe-write.ts +136 -0
  95. package/src/stdin.ts +39 -0
  96. package/src/testing/index.ts +129 -0
  97. package/src/workspace.ts +229 -0
  98. package/test/host/identity.test.ts +229 -0
  99. package/test/host/minimal-host.ts +16 -0
  100. package/test/host/minimal-tool.ts +40 -0
  101. package/test/suite/cli.test.ts +301 -0
  102. package/test/suite/config.test.ts +59 -0
  103. package/test/suite/demo.test.ts +467 -0
  104. package/test/suite/hub-profile-shared.test.ts +123 -0
  105. package/test/suite/login.test.ts +743 -0
  106. package/test/suite/logout.test.ts +247 -0
  107. package/test/suite/migration.test.ts +109 -0
  108. package/test/suite/open.test.ts +59 -0
  109. package/test/suite/profiles.test.ts +380 -0
  110. package/test/suite/projects.test.ts +550 -0
  111. package/test/suite/recovery.test.ts +348 -0
  112. package/test/suite/security.test.ts +199 -0
  113. package/test/suite/signin-fixtures.ts +204 -0
  114. package/test/suite/teams.test.ts +354 -0
  115. package/test/suite/whoami.test.ts +159 -0
  116. package/test/suite/workspace.test.ts +402 -0
  117. package/README.md +0 -3
@@ -0,0 +1,152 @@
1
+ import { type ChassisClient, type ClientOptions } from '@antasphere/chassis-sdk';
2
+ import type { Command } from 'commander';
3
+ import { CliUsageError, type CliIo as CoreCliIo, type ConnectOnDemandOptions, type ProfileSource } from '@antasphere/cli-core';
4
+ import type { CliConfig, CliConfigStore, CliProfile } from './config.js';
5
+ import type { CliIdentity } from './identity.js';
6
+ import { type CliWorkspace, type WorkspaceSelection, type WorkspaceSource } from './workspace.js';
7
+ export { CliUsageError } from '@antasphere/cli-core';
8
+ /**
9
+ * A refusal of the API that a command turned into a sentence (the project
10
+ * verbs do), thrown as the usage error it reads as, with the wire status
11
+ * kept: the runner adds what only it knows, the workspace a 404 was asked of.
12
+ */
13
+ export declare class CliApiRefusal extends CliUsageError {
14
+ readonly status: number;
15
+ constructor(message: string, status: number);
16
+ }
17
+ /**
18
+ * The tool's I/O seam: cli-core's, plus an injectable stdin reader so the
19
+ * `--*-stdin` secret flags (stdin.ts) stay testable in-process. The bin
20
+ * leaves it unset and the default reads `process.stdin`.
21
+ */
22
+ export interface CliIo extends CoreCliIo {
23
+ readStdin?: () => Promise<string>;
24
+ /**
25
+ * `process.stdout` carries `isTTY`; a pipe does not. The only signal the
26
+ * CLI reads before opening a browser unasked (open.ts): a piped run is a
27
+ * script or an agent, and a browser popping up on a build agent is a bug.
28
+ */
29
+ out: CoreCliIo['out'] & {
30
+ isTTY?: boolean;
31
+ };
32
+ /**
33
+ * The browser opener seam. The bin leaves it unset and the default spawns
34
+ * the platform command (open.ts); tests inject a recorder.
35
+ */
36
+ openUrl?: (url: string) => void;
37
+ /**
38
+ * The wait seam. The bin leaves it unset and the default is a timer; tests
39
+ * inject a recorder, so a command that waits out a rate wall is tested
40
+ * without the wait.
41
+ */
42
+ sleep?: (ms: number) => Promise<void>;
43
+ }
44
+ /**
45
+ * Strip terminal control sequences from human output.
46
+ *
47
+ * Almost everything the CLI prints in its human mode is content someone
48
+ * ELSE wrote: annotation bodies and author names from a share-link
49
+ * recipient, the titles of the tool's resources, form-response payloads, stored
50
+ * filenames, and server error messages. A terminal renders ANSI escapes in
51
+ * all of it — colours and cursor moves are the mild end; OSC 8 hyperlinks
52
+ * hide a URL behind friendly text, OSC 52 writes the user's clipboard, and
53
+ * a CSI sequence can scrub the line above so the owner never sees what the
54
+ * command really did.
55
+ *
56
+ * So the human sinks are wrapped (`ttySafeIo`) and everything they print
57
+ * loses C0 (except tab / LF / CR, which the tables and the CSV need), the
58
+ * 8-bit C1 introducers, and complete CSI/OSC/two-character escapes. `--json`
59
+ * output deliberately bypasses this: it is data, not display, and
60
+ * `JSON.stringify` already escapes every C0 byte.
61
+ */
62
+ export declare function sanitizeForTty(s: string): string;
63
+ /** Wrap an io so every human write is sanitized (see sanitizeForTty). */
64
+ export declare function ttySafeIo(io: CliIo): CliIo;
65
+ export declare function setStdinApiKey(io: CliIo, key: string): void;
66
+ /** The key `--api-key-stdin` already read, if any. */
67
+ export declare function stdinApiKey(io: CliIo): string | undefined;
68
+ /**
69
+ * `--json` output goes to the RAW sink: machine output must stay
70
+ * byte-exact, and JSON.stringify already escapes the C0 range.
71
+ */
72
+ export declare function printJson(io: CliIo, value: unknown): void;
73
+ /**
74
+ * Where this invocation's credential came from, in the order it resolves:
75
+ * the flag (or `--api-key-stdin`), the tool's key variable, the profile's own
76
+ * key (the tool's login), the key the hub exchange cached on the profile, a
77
+ * fresh hub exchange run by this very command, or nothing yet.
78
+ */
79
+ export type CredentialSource = 'flag' | 'env' | 'profile' | 'hub-cache' | 'hub-exchange' | 'none';
80
+ export interface CliContext<TClient extends ChassisClient<string> = ChassisClient<string>> {
81
+ client: TClient;
82
+ baseUrl: string;
83
+ apiKey: string | undefined;
84
+ /** Where `apiKey` came from (`whoami` says it; the recovery reads it). */
85
+ credentialSource: CredentialSource;
86
+ json: boolean;
87
+ io: CliIo;
88
+ /**
89
+ * The profile this run selected (cli-core `selectProfile`: --profile, the
90
+ * instance URL, the active profile, the implicit `cloud` profile). Always
91
+ * named on a tool with a cloud URL; `profileCreated` says it is not on
92
+ * disk yet.
93
+ */
94
+ profileName: string | undefined;
95
+ profileSource: ProfileSource | undefined;
96
+ profileCreated: boolean;
97
+ config: CliConfig;
98
+ /**
99
+ * What selects the workspace (workspace.ts), undefined = the server's
100
+ * default. Resolved here, APPLIED by `requireApiKey`: a name needs `/me`,
101
+ * and `resolveContext` is synchronous.
102
+ */
103
+ workspaceSelection: WorkspaceSelection | undefined;
104
+ /** The id `requireApiKey` put on the client; undefined until then, or with no selection. */
105
+ workspaceId: string | undefined;
106
+ }
107
+ /** What `createContext` hands back: the context functions of ONE tool. */
108
+ export interface CliContextKit<TClient extends ChassisClient<string>> {
109
+ resolveProfile(config: CliConfig, requested: string | undefined): {
110
+ name: string | undefined;
111
+ profile: CliProfile | undefined;
112
+ };
113
+ resolveContext(cmd: Command, io: CliIo): CliContext<TClient>;
114
+ requireApiKey(ctx: CliContext<TClient>, opts?: {
115
+ workspace?: boolean;
116
+ }): Promise<string>;
117
+ workspaceSource(ctx: CliContext<TClient>): WorkspaceSource;
118
+ explainWorkspaceRefusal(io: CliIo, e: unknown): Promise<string | null>;
119
+ workspaceNotFoundHint(io: CliIo): string;
120
+ /** The instance a profile names: its `baseUrl`, else the tool's cloud URL. */
121
+ profileUrl(profile: CliProfile | undefined): string;
122
+ /** The `connectOnDemand` options of one context (the tool, the instance, the profile, the wire). */
123
+ connectOptions(ctx: CliContext<TClient>): ConnectOnDemandOptions;
124
+ }
125
+ /**
126
+ * The context functions, bound to one tool: its identity (identity.ts), the
127
+ * client it talks through, and the config and workspace functions already
128
+ * bound to the same identity.
129
+ */
130
+ export declare function createContext<TClient extends ChassisClient<string>>(input: {
131
+ identity: CliIdentity;
132
+ createClient: (options: ClientOptions) => TClient;
133
+ config: Pick<CliConfigStore, 'loadConfig' | 'removeConnectKey'>;
134
+ workspace: CliWorkspace;
135
+ }): CliContextKit<TClient>;
136
+ /**
137
+ * `--all` for a cursor-paginated list: the first page, then every next page
138
+ * while the server hands a cursor, the rows in order. The one loop behind
139
+ * every `--all`; a server that repeats a cursor is stopped here, once.
140
+ */
141
+ export declare function drainPages<T>(first: {
142
+ rows: T[];
143
+ nextCursor: string | null;
144
+ }, fetchPage: (cursor: string) => Promise<{
145
+ rows: T[];
146
+ nextCursor: string | null;
147
+ }>): Promise<T[]>;
148
+ /** Human-readable size (B / KB / MB) for the listing commands. */
149
+ export declare function fmtBytes(n: number): string;
150
+ /** Minimal aligned two-space table for human output. */
151
+ export declare function table(rows: string[][]): string;
152
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACnG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM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AC,EAAE,CAAC,CAWd;AAED,kEAAkE;AAClE,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAI1C;AAED,wDAAwD;AACxD,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAc9C"}
@@ -0,0 +1,456 @@
1
+ import { PlatformApiError } from '@antasphere/chassis-sdk';
2
+ import { activeHubProfile, CLOUD_PROFILE, CliAuthClient, CliUsageError, connectOnDemand, lookupConnectKey, printJson as corePrintJson, refreshConnectKey, resolveApiKey, resolveBaseUrl, sameInstance, selectProfile } from '@antasphere/cli-core';
3
+ import { isWorkspaceId, matchWorkspace } from './workspace.js';
4
+ // The injectable I/O seam, the usage-error class, and the resolution
5
+ // helpers live in @antasphere/cli-core (extracted from this CLI); re-exported
6
+ // so the command modules' imports stay unchanged.
7
+ export { CliUsageError } from '@antasphere/cli-core';
8
+ /**
9
+ * A refusal of the API that a command turned into a sentence (the project
10
+ * verbs do), thrown as the usage error it reads as, with the wire status
11
+ * kept: the runner adds what only it knows, the workspace a 404 was asked of.
12
+ */
13
+ export class CliApiRefusal extends CliUsageError {
14
+ status;
15
+ constructor(message, status) {
16
+ super(message);
17
+ this.status = status;
18
+ this.name = 'CliApiRefusal';
19
+ }
20
+ }
21
+ // ── Terminal-control sanitation ──────────────────────────────────────────────
22
+ /**
23
+ * Strip terminal control sequences from human output.
24
+ *
25
+ * Almost everything the CLI prints in its human mode is content someone
26
+ * ELSE wrote: annotation bodies and author names from a share-link
27
+ * recipient, the titles of the tool's resources, form-response payloads, stored
28
+ * filenames, and server error messages. A terminal renders ANSI escapes in
29
+ * all of it — colours and cursor moves are the mild end; OSC 8 hyperlinks
30
+ * hide a URL behind friendly text, OSC 52 writes the user's clipboard, and
31
+ * a CSI sequence can scrub the line above so the owner never sees what the
32
+ * command really did.
33
+ *
34
+ * So the human sinks are wrapped (`ttySafeIo`) and everything they print
35
+ * loses C0 (except tab / LF / CR, which the tables and the CSV need), the
36
+ * 8-bit C1 introducers, and complete CSI/OSC/two-character escapes. `--json`
37
+ * output deliberately bypasses this: it is data, not display, and
38
+ * `JSON.stringify` already escapes every C0 byte.
39
+ */
40
+ export function sanitizeForTty(s) {
41
+ /* eslint-disable no-control-regex -- matching control characters IS the job here. */
42
+ return (s
43
+ // OSC: ESC ] … terminated by BEL, ST (ESC \\) or the end of the string.
44
+ .replace(/\u001b\][\s\S]*?(?:\u0007|\u001b\\|$)/g, '')
45
+ // CSI: ESC [ params intermediates final.
46
+ .replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, '')
47
+ // Any other two-character escape (charset switches, RIS, …).
48
+ .replace(/\u001b[@-Z\\-_]/g, '')
49
+ // Whatever is left: stray C0 (ESC included), DEL, and the 8-bit C1
50
+ // block whose 0x9b / 0x9d are CSI / OSC on their own. Tab (0x09),
51
+ // LF (0x0a) and CR (0x0d) survive — tables and CSV are built of them.
52
+ .replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g, ''));
53
+ /* eslint-enable no-control-regex */
54
+ }
55
+ /** Raw sink behind a sanitizing one, so `--json` can still print verbatim. */
56
+ const rawSinks = new WeakMap();
57
+ /** Wrap an io so every human write is sanitized (see sanitizeForTty). */
58
+ export function ttySafeIo(io) {
59
+ const safe = {
60
+ ...io,
61
+ // `isTTY` rides along: the open decision reads it through the wrapper.
62
+ out: {
63
+ write: (s) => io.out.write(sanitizeForTty(s)),
64
+ ...(io.out.isTTY !== undefined ? { isTTY: io.out.isTTY } : {})
65
+ },
66
+ err: { write: (s) => io.err.write(sanitizeForTty(s)) }
67
+ };
68
+ rawSinks.set(safe, io);
69
+ return safe;
70
+ }
71
+ /**
72
+ * The `--api-key-stdin` value, parked against this invocation's io because
73
+ * `resolveContext` is synchronous and cannot read stdin itself.
74
+ */
75
+ const stdinApiKeys = new WeakMap();
76
+ export function setStdinApiKey(io, key) {
77
+ stdinApiKeys.set(io, key);
78
+ }
79
+ /** The key `--api-key-stdin` already read, if any. */
80
+ export function stdinApiKey(io) {
81
+ return stdinApiKeys.get(io);
82
+ }
83
+ /**
84
+ * `--json` output goes to the RAW sink: machine output must stay
85
+ * byte-exact, and JSON.stringify already escapes the C0 range.
86
+ */
87
+ export function printJson(io, value) {
88
+ corePrintJson(rawSinks.get(io) ?? io, value);
89
+ }
90
+ /** The context whose selection reached the wire, for the runner's error path. */
91
+ const appliedContexts = new WeakMap();
92
+ /**
93
+ * The context functions, bound to one tool: its identity (identity.ts), the
94
+ * client it talks through, and the config and workspace functions already
95
+ * bound to the same identity.
96
+ */
97
+ export function createContext(input) {
98
+ const { identity, createClient } = input;
99
+ const { loadConfig, removeConnectKey } = input.config;
100
+ const { describeSelection, explainRefusal, pickWorkspaceSelection } = input.workspace;
101
+ const unknownHint = `run \`${identity.bin} profiles\` to list them.`;
102
+ /** The named (or active) profile, erroring on an explicitly named missing one. */
103
+ function resolveProfile(config, requested) {
104
+ const { name, profile } = selectProfile({ config, requested, cloudUrl: identity.cloudUrl, unknownHint });
105
+ return { name, profile };
106
+ }
107
+ function profileUrl(profile) {
108
+ return profile?.baseUrl ?? identity.cloudUrl;
109
+ }
110
+ /**
111
+ * Backend + credential resolution, in its documented order:
112
+ *
113
+ * profile: --profile → the profile of --api-url / <PREFIX>_URL (made in
114
+ * memory, named for the host, when none is saved) → the active
115
+ * profile (`<bin> use`) → the implicit `cloud` profile
116
+ * base URL: --api-url (or --url) → <PREFIX>_URL → profile baseUrl → the
117
+ * tool's cloud URL
118
+ * API key: --api-key → <PREFIX>_API_KEY → profile apiKey
119
+ * → the hub-connect key cached on the profile (cloud instances)
120
+ * workspace: --org / --workspace → <PREFIX>_ORG / <PREFIX>_WORKSPACE
121
+ * → none (the server's default; workspace.ts)
122
+ *
123
+ * A profile is an instance (cli-core 0.5.0): a cached hub key is read only
124
+ * when the profile names the instance this request goes to, so a key
125
+ * minted for the cloud can never be sent to some other instance named by
126
+ * --api-url / <PREFIX>_URL. A self-hosted CLI names its instance once, as a
127
+ * profile; the cloud needs no flag at all.
128
+ */
129
+ function resolveContext(cmd, io) {
130
+ const opts = cmd.optsWithGlobals();
131
+ const config = loadConfig(io.env);
132
+ const apiUrl = opts.apiUrl ?? opts.url ?? io.env[`${identity.envPrefix}_URL`];
133
+ const selected = selectProfile({
134
+ config,
135
+ requested: opts.profile,
136
+ apiUrl,
137
+ cloudUrl: identity.cloudUrl,
138
+ unknownHint
139
+ });
140
+ const { name: profileName, profile } = selected;
141
+ const baseUrl = resolveBaseUrl({
142
+ flag: apiUrl,
143
+ env: io.env,
144
+ envVar: `${identity.envPrefix}_URL`,
145
+ profile,
146
+ cloudUrl: identity.cloudUrl
147
+ });
148
+ // A profile's own key is sent only to the instance the profile names
149
+ // (verifier round 1, F5): `--profile a --api-url <b>` must never hand
150
+ // a's key to b, exactly as the connect cache below never does.
151
+ const sameProfileInstance = sameInstance(profileUrl(profile), baseUrl);
152
+ let apiKey = resolveApiKey({
153
+ flag: opts.apiKey ?? stdinApiKeys.get(io),
154
+ env: io.env,
155
+ envVar: `${identity.envPrefix}_API_KEY`,
156
+ profile: sameProfileInstance ? profile : undefined
157
+ });
158
+ let credentialSource = opts.apiKey !== undefined || stdinApiKeys.get(io) !== undefined
159
+ ? 'flag'
160
+ : io.env[`${identity.envPrefix}_API_KEY`]
161
+ ? 'env'
162
+ : apiKey
163
+ ? 'profile'
164
+ : 'none';
165
+ if (!apiKey && sameProfileInstance) {
166
+ // No direct key: the connect cache's slot is the ACTIVE hub profile
167
+ // (what `antasphere login` stored) — org-independent by design. A key
168
+ // cached for ANOTHER account than the login now stored on that slot
169
+ // (`antasphere login --email other` since) is never served: it is the
170
+ // other person's credential (PRDCT-3032); connectForKey retires it.
171
+ const hub = activeHubProfile(io.env);
172
+ if (hub.name && !cachedForAnotherAccount(profile, hub.name, hub.profile?.email)) {
173
+ apiKey = lookupConnectKey(profile, hub.name);
174
+ }
175
+ if (apiKey)
176
+ credentialSource = 'hub-cache';
177
+ }
178
+ const fetchImpl = io.fetch ?? globalThis.fetch.bind(globalThis);
179
+ const ctx = {
180
+ client: createClient({ baseUrl, ...(apiKey ? { apiKey } : {}), fetch: fetchImpl }),
181
+ baseUrl,
182
+ apiKey,
183
+ credentialSource,
184
+ json: Boolean(opts.json),
185
+ io,
186
+ profileName,
187
+ profileSource: selected.source,
188
+ profileCreated: selected.created,
189
+ config,
190
+ workspaceSelection: pickWorkspaceSelection({
191
+ workspaceFlag: opts.workspace,
192
+ orgFlag: opts.org,
193
+ env: io.env
194
+ }),
195
+ workspaceId: undefined
196
+ };
197
+ if (credentialSource === 'hub-cache' && apiKey) {
198
+ // A cached key may have been revoked at the hub since it was minted
199
+ // (a swept membership, a logout elsewhere): the client's fetch recovers
200
+ // once, below, instead of stranding the person on a 401.
201
+ ctx.client = createClient({ baseUrl, apiKey, fetch: recoveringFetch(ctx, fetchImpl) });
202
+ }
203
+ return ctx;
204
+ }
205
+ /**
206
+ * The cached connect key on `slot` was minted for another Antasphere
207
+ * account than the one whose login the slot now holds. Both addresses must
208
+ * be known: a cache entry or a hub profile without one is trusted as before.
209
+ */
210
+ function cachedForAnotherAccount(profile, slot, hubEmail) {
211
+ const cached = profile?.connectKeys?.[slot]?.email;
212
+ if (!cached || !hubEmail)
213
+ return false;
214
+ return cached.toLowerCase() !== hubEmail.toLowerCase();
215
+ }
216
+ const NO_KEY_MESSAGE = `An API key is required. Sign in (\`${identity.bin} login\`), pass --api-key, or set ` +
217
+ `${identity.envPrefix}_API_KEY.`;
218
+ /** The tool's own copy for the cli-core seam: the one-command login is the remedy. */
219
+ const MISSING_HUB_LOGIN_MESSAGE = `This ${identity.displayName} instance signs in through Antasphere. Run \`${identity.bin} login\` once ` +
220
+ `(or \`antasphere login\`), then retry — or pass --api-key <${identity.keyPrefix}_…> / set ` +
221
+ `${identity.envPrefix}_API_KEY.`;
222
+ function connectOptions(ctx) {
223
+ const { io } = ctx;
224
+ return {
225
+ tool: identity.tool,
226
+ toolBaseUrl: ctx.baseUrl,
227
+ // A profile with no baseUrl of its own is at the cloud URL (cli-core 0.5.0).
228
+ cloudUrl: identity.cloudUrl,
229
+ profileName: ctx.profileName ?? CLOUD_PROFILE,
230
+ env: io.env,
231
+ // Thread the injected fetch so the probe + exchange stay on the test
232
+ // harness wire (and any proxying the runner set up).
233
+ ...(io.fetch ? { fetch: io.fetch } : {}),
234
+ notify: (line) => io.err.write(line),
235
+ messages: { missingHubLogin: MISSING_HUB_LOGIN_MESSAGE }
236
+ };
237
+ }
238
+ /**
239
+ * The stranded-key recovery (PRDCT-2947): a fetch that, on the FIRST 401
240
+ * answered to a key served from the connect cache, evicts that key, runs
241
+ * the hub exchange again (cli-core `refreshConnectKey`) and replays the
242
+ * request once with the new key. A second 401 stands. A hub refusal on the
243
+ * way (a restricted tool, a swept account) is the hub's own sentence, exit
244
+ * 3, through the runner. An instance that is no longer cloud recovers
245
+ * nothing and the 401 stands as it is.
246
+ */
247
+ function recoveringFetch(ctx, base) {
248
+ let recovered = false;
249
+ return async (input, init) => {
250
+ const res = await base(input, init);
251
+ if (res.status !== 401 || recovered || ctx.credentialSource !== 'hub-cache')
252
+ return res;
253
+ recovered = true;
254
+ // A 401 under a workspace selection may be the SELECTION's refusal:
255
+ // the server answers a workspace the person does not belong to exactly
256
+ // like an unknown key (no oracle). Ask `/me` once without it; when the
257
+ // key answers there, it is alive and nothing is evicted, exchanged or
258
+ // replayed (verifier round 1, F2: a refused --org leaked a live key per
259
+ // command). The runner then explains the refusal.
260
+ if (ctx.workspaceId !== undefined && ctx.apiKey) {
261
+ const probe = await base(`${ctx.baseUrl}/api/v1/me`, {
262
+ headers: { authorization: `Bearer ${ctx.apiKey}` }
263
+ }).catch(() => null);
264
+ // Only a probe that ANSWERS 401 proves the key dead (verifier round 2,
265
+ // F10): a probe with no answer, or any other status, keeps the key and
266
+ // lets the 401 stand.
267
+ if (!probe || probe.status !== 401)
268
+ return res;
269
+ }
270
+ const outcome = await refreshConnectKey(connectOptions(ctx));
271
+ if (outcome.outcome === 'not_cloud')
272
+ return res;
273
+ ctx.apiKey = outcome.key;
274
+ ctx.credentialSource = 'hub-exchange';
275
+ ctx.io.err.write('The cached key was refused; signed in again through Antasphere.\n');
276
+ const headers = new Headers(init?.headers);
277
+ headers.set('authorization', `Bearer ${outcome.key}`);
278
+ return base(input, { ...init, headers });
279
+ };
280
+ }
281
+ /**
282
+ * Requires an API key; throws a friendly message the runner turns into exit 1.
283
+ *
284
+ * When nothing resolved, this is the connect-on-demand seam (binding
285
+ * patterns §7, gcloud model), owned by @antasphere/cli-core since 0.3.0:
286
+ * if — and only if — discovery says the instance is an Antasphere-cloud
287
+ * one, the stored `antasphere login` credential is exchanged (hub → tool)
288
+ * for a USER-scoped tool-local API key, which is cached on the selected
289
+ * profile under the hub profile's name and used for this invocation — and
290
+ * served from that cache on every subsequent run (no re-exchange, no fresh
291
+ * mint). Self-hosted instances never take this branch: they get the
292
+ * classic error unchanged.
293
+ */
294
+ async function requireApiKey(ctx, opts = {}) {
295
+ const key = ctx.apiKey ?? (await connectForKey(ctx));
296
+ if (opts.workspace !== false)
297
+ await applyWorkspace(ctx);
298
+ return key;
299
+ }
300
+ /**
301
+ * Put the selected workspace on the client (PRDCT-2419). Every signed-in
302
+ * command calls `requireApiKey`, so this is the one place the selection is
303
+ * applied and no command names it. An id is sent as it is (a workspace id
304
+ * or a hub organization id: the server maps the latter and fails closed on
305
+ * one that is not the person's, and `explainWorkspaceRefusal` says so); a
306
+ * name costs one `/me` to find its id. `workspaces` and `workspace default`
307
+ * pass `workspace: false`: they are how a person repairs a selection that
308
+ * no longer works, so they must answer when it does not.
309
+ */
310
+ async function applyWorkspace(ctx) {
311
+ const selection = ctx.workspaceSelection;
312
+ if (!selection || ctx.workspaceId !== undefined)
313
+ return;
314
+ const id = isWorkspaceId(selection.value)
315
+ ? selection.value
316
+ : matchWorkspace((await ctx.client.me()).workspaces, selection.value).id;
317
+ ctx.client.setWorkspace(id);
318
+ ctx.workspaceId = id;
319
+ appliedContexts.set(ctx.io, ctx);
320
+ }
321
+ /** How the workspace of this invocation was chosen (`whoami`). */
322
+ function workspaceSource(ctx) {
323
+ return ctx.workspaceSelection?.source ?? 'default';
324
+ }
325
+ /**
326
+ * The sentence for a refusal the SELECTION caused, or null (workspace.ts
327
+ * `explainRefusal`). Asks `/me` once WITHOUT the selection: when that
328
+ * answers, the key is good and the workspace is what was refused. Any
329
+ * failure of the probe means the plain error is the honest one.
330
+ */
331
+ async function explainWorkspaceRefusal(io, e) {
332
+ const ctx = appliedContexts.get(io);
333
+ if (!ctx?.workspaceSelection || ctx.workspaceId === undefined || !ctx.apiKey)
334
+ return null;
335
+ if (!(e instanceof PlatformApiError))
336
+ return null;
337
+ if (e.code !== 'workspace_mismatch' && e.code !== 'invalid_api_key')
338
+ return null;
339
+ try {
340
+ const fetchImpl = io.fetch ?? globalThis.fetch.bind(globalThis);
341
+ const me = await createClient({ baseUrl: ctx.baseUrl, apiKey: ctx.apiKey, fetch: fetchImpl }).me();
342
+ return explainRefusal({
343
+ code: e.code,
344
+ status: e.status,
345
+ selection: ctx.workspaceSelection,
346
+ workspaceId: ctx.workspaceId,
347
+ me,
348
+ baseUrl: ctx.baseUrl
349
+ });
350
+ }
351
+ catch {
352
+ return null;
353
+ }
354
+ }
355
+ /**
356
+ * The hint for a 404 under a selection: a resource id (a linked folder's, a
357
+ * pasted one) lives in ONE workspace, and the same id asked of another is
358
+ * "not found" — true, and useless without the workspace that was asked.
359
+ */
360
+ function workspaceNotFoundHint(io) {
361
+ const ctx = appliedContexts.get(io);
362
+ if (!ctx?.workspaceSelection || ctx.workspaceId === undefined)
363
+ return '';
364
+ const { workspaceSelection: selection } = ctx;
365
+ const noun = selection.kind === 'org' ? 'organization' : 'workspace';
366
+ return ` (looked in the ${noun} "${selection.value}", selected by ${describeSelection(selection)})`;
367
+ }
368
+ async function connectForKey(ctx) {
369
+ const { io } = ctx;
370
+ // The cached key of another account (the hub login on the slot changed)
371
+ // is revoked on its instance and forgotten before the exchange runs for
372
+ // the account now signed in (PRDCT-3032). Best effort: a dead key
373
+ // answers 401 and is forgotten all the same.
374
+ const hub = activeHubProfile(io.env);
375
+ if (ctx.profileName && hub.name) {
376
+ const profile = loadConfig(io.env).profiles[ctx.profileName];
377
+ if (cachedForAnotherAccount(profile, hub.name, hub.profile?.email)) {
378
+ const stale = profile?.connectKeys?.[hub.name];
379
+ if (stale) {
380
+ io.err.write(`The ${identity.displayName} key cached for ${stale.email ?? 'another Antasphere login'} is retired: ` +
381
+ `the Antasphere login is now ${hub.profile?.email ?? 'another account'}.\n`);
382
+ const auth = new CliAuthClient({
383
+ baseUrl: profileUrl(profile),
384
+ ...(io.fetch ? { fetch: io.fetch } : {})
385
+ });
386
+ await auth.revoke(stale.apiKey).catch(() => undefined);
387
+ removeConnectKey(io.env, ctx.profileName, hub.name);
388
+ }
389
+ }
390
+ }
391
+ const outcome = await connectOnDemand(connectOptions(ctx));
392
+ if (outcome.outcome === 'not_cloud') {
393
+ // Self-hosted / unreachable: the classic error, byte-identical.
394
+ throw new CliUsageError(NO_KEY_MESSAGE);
395
+ }
396
+ // The minted key becomes this invocation's credential.
397
+ ctx.apiKey = outcome.key;
398
+ ctx.credentialSource = outcome.cached ? 'hub-cache' : 'hub-exchange';
399
+ const fetchImpl = io.fetch ?? globalThis.fetch.bind(globalThis);
400
+ ctx.client = createClient({
401
+ baseUrl: ctx.baseUrl,
402
+ apiKey: outcome.key,
403
+ fetch: outcome.cached ? recoveringFetch(ctx, fetchImpl) : fetchImpl
404
+ });
405
+ return outcome.key;
406
+ }
407
+ return {
408
+ resolveProfile,
409
+ resolveContext,
410
+ requireApiKey,
411
+ workspaceSource,
412
+ explainWorkspaceRefusal,
413
+ workspaceNotFoundHint,
414
+ profileUrl,
415
+ connectOptions
416
+ };
417
+ }
418
+ /**
419
+ * `--all` for a cursor-paginated list: the first page, then every next page
420
+ * while the server hands a cursor, the rows in order. The one loop behind
421
+ * every `--all`; a server that repeats a cursor is stopped here, once.
422
+ */
423
+ export async function drainPages(first, fetchPage) {
424
+ const rows = [...first.rows];
425
+ const seen = new Set();
426
+ let cursor = first.nextCursor;
427
+ while (cursor && !seen.has(cursor)) {
428
+ seen.add(cursor);
429
+ const page = await fetchPage(cursor);
430
+ rows.push(...page.rows);
431
+ cursor = page.nextCursor;
432
+ }
433
+ return rows;
434
+ }
435
+ /** Human-readable size (B / KB / MB) for the listing commands. */
436
+ export function fmtBytes(n) {
437
+ if (n < 1024)
438
+ return `${n} B`;
439
+ if (n < 1024 * 1024)
440
+ return `${(n / 1024).toFixed(1)} KB`;
441
+ return `${(n / (1024 * 1024)).toFixed(1)} MB`;
442
+ }
443
+ /** Minimal aligned two-space table for human output. */
444
+ export function table(rows) {
445
+ if (rows.length === 0)
446
+ return '';
447
+ const first = rows[0];
448
+ const widths = first.map((_, i) => Math.max(...rows.map((r) => (r[i] ?? '').length)));
449
+ return (rows
450
+ .map((r) => r
451
+ .map((cell, i) => (i === r.length - 1 ? cell : (cell ?? '').padEnd(widths[i] ?? 0)))
452
+ .join(' ')
453
+ .trimEnd())
454
+ .join('\n') + '\n');
455
+ }
456
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA0C,MAAM,yBAAyB,CAAC;AAEnG,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,SAAS,IAAI,aAAa,EAC1B,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,aAAa,EAId,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,aAAa,EACb,cAAc,EAIf,MAAM,gBAAgB,CAAC;AAExB,qEAAqE;AACrE,8EAA8E;AAC9E,kDAAkD;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;;GAIG;AACH,MAAM,OAAO,aAAc,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