@mycadet/cli 0.12.7 → 0.12.8
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 +2 -2
- package/knip.json +1 -1
- package/node_modules/@mycadet/assistant-api/events/cloud-disconnected.ts +21 -0
- package/node_modules/@mycadet/assistant-api/events/host-bash.ts +1 -1
- package/node_modules/@mycadet/assistant-api/events/host-cu.ts +1 -1
- package/node_modules/@mycadet/assistant-api/events/host-file.ts +1 -1
- package/node_modules/@mycadet/assistant-api/events/notification-intent.ts +1 -1
- package/node_modules/@mycadet/assistant-api/events/{show-platform-login.ts → show-cloud-login.ts} +3 -5
- package/node_modules/@mycadet/assistant-api/index.ts +11 -11
- package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/package.json +1 -1
- package/node_modules/@mycadet/{service-contracts/src/platform-credential.ts → assistant-api/node_modules/@mycadet/service-contracts/src/cloud-credential.ts} +9 -9
- package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/src/handles.ts +3 -3
- package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/src/index.ts +1 -1
- package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/src/ingress.ts +11 -5
- package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/src/remote-web-pairing.ts +1 -1
- package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/src/rpc.ts +14 -14
- package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/src/trust-rules.ts +5 -5
- package/node_modules/@mycadet/assistant-api/responses/home.ts +1 -1
- package/node_modules/@mycadet/assistant-api/surfaces.ts +4 -4
- package/node_modules/@mycadet/avatar-manifest/src/__tests__/notification-avatar.test.ts +1 -1
- package/node_modules/@mycadet/avatar-manifest/src/notification-avatar.ts +2 -2
- package/node_modules/@mycadet/environments/src/seeds.ts +6 -6
- package/node_modules/@mycadet/environments/src/shell.test.ts +1 -1
- package/node_modules/@mycadet/environments/src/types.ts +6 -6
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/avatar-manifest/src/__tests__/notification-avatar.test.ts +1 -1
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/avatar-manifest/src/notification-avatar.ts +2 -2
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/environments/src/seeds.ts +6 -6
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/environments/src/shell.test.ts +1 -1
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/environments/src/types.ts +6 -6
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/package.json +1 -1
- package/node_modules/@mycadet/{assistant-api/node_modules/@mycadet/service-contracts/src/platform-credential.ts → local-mode/node_modules/@mycadet/service-contracts/src/cloud-credential.ts} +9 -9
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/src/handles.ts +3 -3
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/src/index.ts +1 -1
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/src/ingress.ts +11 -5
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/src/remote-web-pairing.ts +1 -1
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/src/rpc.ts +14 -14
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/src/trust-rules.ts +5 -5
- package/node_modules/@mycadet/local-mode/src/__tests__/pair.test.ts +5 -5
- package/node_modules/@mycadet/local-mode/src/__tests__/retire.test.ts +1 -1
- package/node_modules/@mycadet/local-mode/src/config.ts +2 -2
- package/node_modules/@mycadet/local-mode/src/index.ts +1 -1
- package/node_modules/@mycadet/local-mode/src/lockfile-contract.test.ts +3 -3
- package/node_modules/@mycadet/local-mode/src/lockfile-contract.ts +10 -5
- package/node_modules/@mycadet/local-mode/src/lockfile.test.ts +15 -15
- package/node_modules/@mycadet/local-mode/src/lockfile.ts +9 -9
- package/node_modules/@mycadet/local-mode/src/pair.ts +2 -2
- package/node_modules/@mycadet/local-mode/src/retire.ts +3 -3
- package/node_modules/@mycadet/local-mode/src/teleport-backup-policy.ts +2 -2
- package/node_modules/@mycadet/local-mode/src/unpair.ts +2 -2
- package/node_modules/@mycadet/service-contracts/package.json +1 -1
- package/node_modules/@mycadet/{local-mode/node_modules/@mycadet/service-contracts/src/platform-credential.ts → service-contracts/src/cloud-credential.ts} +9 -9
- package/node_modules/@mycadet/service-contracts/src/handles.ts +3 -3
- package/node_modules/@mycadet/service-contracts/src/index.ts +1 -1
- package/node_modules/@mycadet/service-contracts/src/ingress.ts +11 -5
- package/node_modules/@mycadet/service-contracts/src/remote-web-pairing.ts +1 -1
- package/node_modules/@mycadet/service-contracts/src/rpc.ts +14 -14
- package/node_modules/@mycadet/service-contracts/src/trust-rules.ts +5 -5
- package/package.json +3 -2
- package/src/__tests__/assistant-api-key-resolution.test.ts +6 -6
- package/src/__tests__/{assistant-client-platform-auth.test.ts → assistant-client-cloud-auth.test.ts} +10 -10
- package/src/__tests__/assistant-client-refresh.test.ts +2 -2
- package/src/__tests__/backup.test.ts +86 -91
- package/src/__tests__/client-token.test.ts +1 -1
- package/src/__tests__/client-tui-refresh.test.ts +1 -1
- package/src/__tests__/client-web-config.test.ts +2 -2
- package/src/__tests__/{platform-client.test.ts → cloud-client.test.ts} +59 -59
- package/src/__tests__/{platform-releases.test.ts → cloud-releases.test.ts} +5 -5
- package/src/__tests__/{cloudflare-tunnel.test.ts → cloudflare.test.ts} +1 -1
- package/src/__tests__/connect-import.test.ts +55 -39
- package/src/__tests__/debug.test.ts +38 -38
- package/src/__tests__/guardian-token.test.ts +149 -56
- package/src/__tests__/hatch-provider-secrets.test.ts +2 -2
- package/src/__tests__/helpers/guardian-token.ts +22 -0
- package/src/__tests__/helpers/http.ts +10 -0
- package/src/__tests__/nginx-ingress.test.ts +18 -18
- package/src/__tests__/orphan-detection.test.ts +1 -1
- package/src/__tests__/pair.test.ts +1 -8
- package/src/__tests__/{ps-platform-status.test.ts → ps-cloud-status.test.ts} +79 -26
- package/src/__tests__/{recover.test.ts → restore.test.ts} +29 -28
- package/src/__tests__/retire.test.ts +58 -199
- package/src/__tests__/root-process-lockfile.test.ts +99 -0
- package/src/__tests__/sleep.test.ts +19 -19
- package/src/__tests__/statefulset.test.ts +8 -8
- package/src/__tests__/{tailscale-tunnel.test.ts → tailscale.test.ts} +1 -1
- package/src/__tests__/teleport-backup.test.ts +3 -3
- package/src/__tests__/teleport.test.ts +180 -196
- package/src/__tests__/tunnel.test.ts +255 -227
- package/src/__tests__/uninstall.test.ts +13 -4
- package/src/__tests__/upgrade-local.test.ts +3 -3
- package/src/__tests__/upgrade-replay-env.test.ts +12 -12
- package/src/__tests__/wake.test.ts +258 -41
- package/src/__tests__/workos-pkce.test.ts +2 -2
- package/src/commands/backup.ts +22 -22
- package/src/commands/client.ts +76 -76
- package/src/commands/debug.ts +20 -20
- package/src/commands/exec.ts +5 -5
- package/src/commands/hatch.ts +22 -22
- package/src/commands/login.ts +22 -22
- package/src/commands/logs.ts +1 -1
- package/src/commands/ps.ts +188 -79
- package/src/commands/restart.ts +30 -0
- package/src/commands/restore.ts +138 -20
- package/src/commands/retire.ts +46 -148
- package/src/commands/rollback.ts +18 -24
- package/src/commands/setup.ts +2 -2
- package/src/commands/teleport.ts +93 -93
- package/src/commands/terminal.ts +157 -17
- package/src/commands/tunnel.ts +80 -122
- package/src/commands/uninstall.ts +55 -7
- package/src/commands/unpair.ts +3 -3
- package/src/commands/upgrade.ts +22 -46
- package/src/commands/wake.ts +162 -46
- package/src/index.ts +3 -9
- package/src/lib/__tests__/{platform-client-signed-url.test.ts → cloud-client-signed-url.test.ts} +16 -16
- package/src/lib/__tests__/job-polling.test.ts +1 -1
- package/src/lib/__tests__/local-runtime-client.test.ts +4 -4
- package/src/lib/__tests__/runtime-url.test.ts +1 -1
- package/src/lib/assistant-api-key-resolution.ts +5 -5
- package/src/lib/assistant-client.ts +8 -8
- package/src/lib/assistant-config.ts +58 -12
- package/src/lib/{platform-client.ts → cloud-client.ts} +107 -98
- package/src/lib/cloud-login.ts +24 -24
- package/src/lib/{platform-releases.ts → cloud-releases.ts} +5 -5
- package/src/lib/cloud-values.ts +3 -0
- package/src/lib/config-utils.ts +1 -1
- package/src/lib/detached-process.ts +1 -1
- package/src/lib/docker.ts +111 -10
- package/src/lib/environments/__tests__/paths.test.ts +2 -2
- package/src/lib/environments/__tests__/resolve.test.ts +26 -26
- package/src/lib/environments/resolve.ts +8 -8
- package/src/lib/guardian-token.ts +36 -4
- package/src/lib/hatch-local.ts +19 -23
- package/src/lib/health-check.ts +6 -6
- package/src/lib/ingress-config.ts +8 -35
- package/src/lib/job-polling.ts +1 -1
- package/src/lib/live-voice/connection.ts +12 -12
- package/src/lib/live-voice/tunnel.test.ts +11 -11
- package/src/lib/live-voice/tunnel.ts +15 -15
- package/src/lib/local-runtime-client.ts +20 -20
- package/src/lib/local.ts +9 -30
- package/src/lib/nginx-ingress.ts +41 -14
- package/src/lib/process.ts +1 -1
- package/src/lib/provider-secrets.ts +3 -3
- package/src/lib/retire-apple-container.ts +1 -1
- package/src/lib/runtime-url.ts +8 -8
- package/src/lib/statefulset.ts +2 -2
- package/src/lib/sync-cloud-assistants.ts +18 -18
- package/src/lib/teleport-backup.ts +4 -4
- package/src/lib/terminal-client.ts +17 -17
- package/src/lib/terminal-session.ts +24 -24
- package/src/lib/{tunnel-edge.ts → tunnel.ts} +199 -11
- package/src/lib/tunnels/cadet.ts +29 -0
- package/src/lib/{cloudflare-tunnel.ts → tunnels/cloudflare.ts} +15 -4
- package/src/lib/tunnels/gateway-notify.ts +61 -0
- package/src/lib/{ngrok.ts → tunnels/ngrok.ts} +201 -30
- package/src/lib/{tailscale-tunnel.ts → tunnels/tailscale.ts} +19 -5
- package/src/lib/upgrade-lifecycle.ts +3 -17
- package/src/lib/upgrade-preflight.ts +2 -2
- package/src/lib/workos-pkce.ts +5 -5
- package/node_modules/@mycadet/assistant-api/events/platform-disconnected.ts +0 -21
- package/src/commands/recover.ts +0 -131
- package/src/commands/roadmap.ts +0 -459
- package/src/commands/ssh.ts +0 -144
- package/src/commands/workflows.ts +0 -305
- package/src/lib/managed-cloud.ts +0 -3
package/src/commands/exec.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "fs";
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { isCloudHome } from "../lib/cloud-values.js";
|
|
5
5
|
import { spawn } from "child_process";
|
|
6
6
|
import { red } from "../lib/color";
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ import { resolveAssistant } from "../lib/assistant-config";
|
|
|
9
9
|
import { dockerResourceNames } from "../lib/docker";
|
|
10
10
|
import type { ServiceName } from "../lib/docker";
|
|
11
11
|
import { execAppleContainer } from "../lib/exec-apple-container";
|
|
12
|
-
import {
|
|
12
|
+
import { getCloudUrl, readCloudToken } from "../lib/cloud-client";
|
|
13
13
|
import { sshAppleContainer } from "../lib/ssh-apple-container";
|
|
14
14
|
import {
|
|
15
15
|
interactiveSession,
|
|
@@ -243,8 +243,8 @@ export const exec = Object.assign(
|
|
|
243
243
|
return;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
if (
|
|
247
|
-
const token =
|
|
246
|
+
if (isCloudHome(cloud)) {
|
|
247
|
+
const token = readCloudToken();
|
|
248
248
|
if (!token) {
|
|
249
249
|
console.error(
|
|
250
250
|
red("Not logged in. Run `cadet login` first to authenticate with Cadet Cloud."),
|
|
@@ -255,7 +255,7 @@ export const exec = Object.assign(
|
|
|
255
255
|
const assistant = {
|
|
256
256
|
assistantId: entry.assistantId,
|
|
257
257
|
token,
|
|
258
|
-
|
|
258
|
+
cloudUrl: getCloudUrl(),
|
|
259
259
|
};
|
|
260
260
|
|
|
261
261
|
const serviceParam = service === "assistant" ? undefined : service;
|
package/src/commands/hatch.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Direct import — bun embeds this at compile time so it works in compiled binaries.
|
|
2
|
-
import {
|
|
2
|
+
import { isCloudHome } from "../lib/cloud-values.js";
|
|
3
3
|
import cliPkg from "../../package.json";
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -12,10 +12,10 @@ import { hatchDocker } from "../lib/docker";
|
|
|
12
12
|
import { parseFeatureFlagArgs, readAmbientFlagEnvVars } from "../lib/flag-args";
|
|
13
13
|
import { hatchLocal } from "../lib/hatch-local";
|
|
14
14
|
import {
|
|
15
|
-
|
|
15
|
+
getCloudUrl,
|
|
16
16
|
hatchAssistant,
|
|
17
|
-
|
|
18
|
-
} from "../lib/
|
|
17
|
+
readCloudToken,
|
|
18
|
+
} from "../lib/cloud-client";
|
|
19
19
|
import { validateAssistantName } from "../lib/retire-archive";
|
|
20
20
|
|
|
21
21
|
const DEFAULT_REMOTE: RemoteHost = "local";
|
|
@@ -30,7 +30,7 @@ interface HatchArgs {
|
|
|
30
30
|
configValues: Record<string, string>;
|
|
31
31
|
flagEnvVars: Record<string, string>;
|
|
32
32
|
analyze: boolean;
|
|
33
|
-
|
|
33
|
+
disableCloud: boolean;
|
|
34
34
|
netnsContainer: string | null;
|
|
35
35
|
gatewayPort: number | null;
|
|
36
36
|
assistantCaCert: string | null;
|
|
@@ -41,10 +41,10 @@ function parseArgs(): HatchArgs {
|
|
|
41
41
|
process.argv.slice(3),
|
|
42
42
|
);
|
|
43
43
|
const flagEnvVars = { ...readAmbientFlagEnvVars(), ...cliFlagVars };
|
|
44
|
-
const
|
|
45
|
-
process.env.
|
|
46
|
-
let
|
|
47
|
-
|
|
44
|
+
const disableCloudAmbient =
|
|
45
|
+
process.env.CADET_DISABLE_CLOUD?.trim().toLowerCase();
|
|
46
|
+
let disableCloud =
|
|
47
|
+
disableCloudAmbient === "true" || disableCloudAmbient === "1";
|
|
48
48
|
let verbose = false;
|
|
49
49
|
let keepAlive = false;
|
|
50
50
|
let name: string | null = null;
|
|
@@ -91,7 +91,7 @@ function parseArgs(): HatchArgs {
|
|
|
91
91
|
" --analyze Emit a structured hatch-timing log line on stdout",
|
|
92
92
|
);
|
|
93
93
|
console.log(
|
|
94
|
-
" --disable-
|
|
94
|
+
" --disable-cloud Suppress all outbound platform API calls",
|
|
95
95
|
);
|
|
96
96
|
console.log(
|
|
97
97
|
" --netns-container <name> Join an existing container's network namespace (docker target only) instead of creating a per-instance network. The namespace owner publishes host ports, so --gateway-port is required.",
|
|
@@ -162,8 +162,8 @@ function parseArgs(): HatchArgs {
|
|
|
162
162
|
const value = next.slice(eqIndex + 1);
|
|
163
163
|
configValues[key] = value;
|
|
164
164
|
i++;
|
|
165
|
-
} else if (arg === "--disable-
|
|
166
|
-
|
|
165
|
+
} else if (arg === "--disable-cloud") {
|
|
166
|
+
disableCloud = true;
|
|
167
167
|
} else if (arg === "--netns-container") {
|
|
168
168
|
const next = args[i + 1];
|
|
169
169
|
if (!next || next.startsWith("-")) {
|
|
@@ -193,7 +193,7 @@ function parseArgs(): HatchArgs {
|
|
|
193
193
|
i++;
|
|
194
194
|
} else {
|
|
195
195
|
console.error(
|
|
196
|
-
`Error: Unknown argument '${arg}'. Valid options: -v, --verbose, --watch, --source <path>, --keep-alive, --name <name>, --remote <${VALID_REMOTE_HOSTS.join("|")}>, --config <key=value>, --flag <key=value>, --analyze, --disable-
|
|
196
|
+
`Error: Unknown argument '${arg}'. Valid options: -v, --verbose, --watch, --source <path>, --keep-alive, --name <name>, --remote <${VALID_REMOTE_HOSTS.join("|")}>, --config <key=value>, --flag <key=value>, --analyze, --disable-cloud, --netns-container <name>, --gateway-port <port>, --assistant-ca-cert <path>`,
|
|
197
197
|
);
|
|
198
198
|
process.exit(1);
|
|
199
199
|
}
|
|
@@ -209,7 +209,7 @@ function parseArgs(): HatchArgs {
|
|
|
209
209
|
configValues,
|
|
210
210
|
flagEnvVars,
|
|
211
211
|
analyze,
|
|
212
|
-
|
|
212
|
+
disableCloud,
|
|
213
213
|
netnsContainer,
|
|
214
214
|
gatewayPort,
|
|
215
215
|
assistantCaCert,
|
|
@@ -237,15 +237,15 @@ export const hatch = Object.assign(
|
|
|
237
237
|
configValues,
|
|
238
238
|
flagEnvVars,
|
|
239
239
|
analyze,
|
|
240
|
-
|
|
240
|
+
disableCloud,
|
|
241
241
|
netnsContainer,
|
|
242
242
|
gatewayPort,
|
|
243
243
|
assistantCaCert,
|
|
244
244
|
} = parseArgs();
|
|
245
245
|
|
|
246
|
-
if (
|
|
247
|
-
process.env.
|
|
248
|
-
flagEnvVars.
|
|
246
|
+
if (disableCloud) {
|
|
247
|
+
process.env.CADET_DISABLE_CLOUD = "true";
|
|
248
|
+
flagEnvVars.CADET_DISABLE_CLOUD = "true";
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
if (watch && remote !== "local" && remote !== "docker") {
|
|
@@ -308,7 +308,7 @@ export const hatch = Object.assign(
|
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
-
if (
|
|
311
|
+
if (isCloudHome(remote)) {
|
|
312
312
|
await hatchCadetPlatform();
|
|
313
313
|
return;
|
|
314
314
|
}
|
|
@@ -321,7 +321,7 @@ export const hatch = Object.assign(
|
|
|
321
321
|
|
|
322
322
|
|
|
323
323
|
async function hatchCadetPlatform(): Promise<void> {
|
|
324
|
-
const token =
|
|
324
|
+
const token = readCloudToken();
|
|
325
325
|
if (!token) {
|
|
326
326
|
console.error("Not logged in. Run `cadet login --token <token>` first.");
|
|
327
327
|
process.exit(1);
|
|
@@ -337,11 +337,11 @@ async function hatchCadetPlatform(): Promise<void> {
|
|
|
337
337
|
|
|
338
338
|
const { assistant: result } = await hatchAssistant(token);
|
|
339
339
|
|
|
340
|
-
const
|
|
340
|
+
const cloudUrl = getCloudUrl();
|
|
341
341
|
|
|
342
342
|
saveAssistantEntry({
|
|
343
343
|
assistantId: result.id,
|
|
344
|
-
runtimeUrl:
|
|
344
|
+
runtimeUrl: cloudUrl,
|
|
345
345
|
cloud: "cloud",
|
|
346
346
|
hatchedAt: new Date().toISOString(),
|
|
347
347
|
});
|
package/src/commands/login.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isCloudHome } from "../lib/cloud-values.js";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
getActiveAssistant,
|
|
@@ -7,18 +7,18 @@ import {
|
|
|
7
7
|
setActiveAssistant,
|
|
8
8
|
} from "../lib/assistant-config";
|
|
9
9
|
import {
|
|
10
|
-
|
|
10
|
+
clearCloudToken,
|
|
11
11
|
fetchCurrentUser,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from "../lib/
|
|
12
|
+
fetchCloudAssistants,
|
|
13
|
+
readCloudToken,
|
|
14
|
+
saveCloudToken,
|
|
15
|
+
} from "../lib/cloud-client";
|
|
16
16
|
import {
|
|
17
17
|
describeLoginError,
|
|
18
18
|
registerLocalAssistantWithPlatform,
|
|
19
19
|
workosPkceLogin,
|
|
20
20
|
} from "../lib/cloud-login.js";
|
|
21
|
-
import {
|
|
21
|
+
import { getCloudUrl } from "../lib/cloud-client";
|
|
22
22
|
import { syncCloudAssistants } from "../lib/sync-cloud-assistants";
|
|
23
23
|
|
|
24
24
|
|
|
@@ -34,7 +34,7 @@ export const login = Object.assign(
|
|
|
34
34
|
console.log("By default, opens a browser window for authentication.");
|
|
35
35
|
console.log("Alternatively, pass a session token directly with --token.");
|
|
36
36
|
console.log("");
|
|
37
|
-
console.log("On success, syncs cloud
|
|
37
|
+
console.log("On success, syncs cloud assistants to the local");
|
|
38
38
|
console.log("lockfile so they appear in `cadet ps`.");
|
|
39
39
|
console.log("");
|
|
40
40
|
console.log("Options:");
|
|
@@ -66,7 +66,7 @@ export const login = Object.assign(
|
|
|
66
66
|
|
|
67
67
|
// Block if already authenticated (unless --force)
|
|
68
68
|
if (!forceFlag && !token) {
|
|
69
|
-
const existingToken =
|
|
69
|
+
const existingToken = readCloudToken();
|
|
70
70
|
if (existingToken) {
|
|
71
71
|
try {
|
|
72
72
|
const existingUser = await fetchCurrentUser(existingToken);
|
|
@@ -83,7 +83,7 @@ export const login = Object.assign(
|
|
|
83
83
|
// If no --token flag, use app-held WorkOS PKCE login.
|
|
84
84
|
if (!token) {
|
|
85
85
|
try {
|
|
86
|
-
token = await workosPkceLogin(
|
|
86
|
+
token = await workosPkceLogin(getCloudUrl());
|
|
87
87
|
} catch (error) {
|
|
88
88
|
console.error(`❌ ${describeLoginError(error)}`);
|
|
89
89
|
process.exit(1);
|
|
@@ -94,10 +94,10 @@ export const login = Object.assign(
|
|
|
94
94
|
|
|
95
95
|
try {
|
|
96
96
|
const user = await fetchCurrentUser(token);
|
|
97
|
-
|
|
97
|
+
saveCloudToken(token);
|
|
98
98
|
console.log(`✅ Logged in as ${user.email}`);
|
|
99
99
|
|
|
100
|
-
// Register the local assistant with the
|
|
100
|
+
// Register the local assistant with the cloud (non-fatal).
|
|
101
101
|
// Mirrors the desktop app's LocalAssistantBootstrapService flow.
|
|
102
102
|
try {
|
|
103
103
|
await registerLocalAssistantWithPlatform(token, user);
|
|
@@ -105,8 +105,8 @@ export const login = Object.assign(
|
|
|
105
105
|
// Non-fatal — login succeeded even if registration fails
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
// Sync cloud assistants from the
|
|
109
|
-
// This ensures `cadet ps` shows
|
|
108
|
+
// Sync cloud assistants from the cloud into the local lockfile.
|
|
109
|
+
// This ensures `cadet ps` shows cloud assistants immediately
|
|
110
110
|
// after login (e.g. after a retire-and-rehatch cycle). We've just
|
|
111
111
|
// saved this token, so it's guaranteed non-empty here.
|
|
112
112
|
try {
|
|
@@ -122,9 +122,9 @@ export const login = Object.assign(
|
|
|
122
122
|
|
|
123
123
|
// If no active assistant is set, activate the first cloud one.
|
|
124
124
|
if (!getActiveAssistant()) {
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
127
|
-
setActiveAssistant(
|
|
125
|
+
const cloudAssistants = await fetchCloudAssistants(token);
|
|
126
|
+
if (cloudAssistants.length > 0) {
|
|
127
|
+
setActiveAssistant(cloudAssistants[0].id);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
} catch {
|
|
@@ -148,13 +148,13 @@ export const logout = Object.assign(
|
|
|
148
148
|
console.log("Usage: cadet logout");
|
|
149
149
|
console.log("");
|
|
150
150
|
console.log("Log out of Cadet Cloud, remove the stored session token,");
|
|
151
|
-
console.log("and remove cloud
|
|
151
|
+
console.log("and remove cloud assistants from the local lockfile.");
|
|
152
152
|
process.exit(0);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
// Remove cloud
|
|
155
|
+
// Remove cloud assistants from the lockfile.
|
|
156
156
|
const cloudAssistants = loadAllAssistants().filter((a) =>
|
|
157
|
-
|
|
157
|
+
isCloudHome(a.cloud),
|
|
158
158
|
);
|
|
159
159
|
for (const a of cloudAssistants) {
|
|
160
160
|
removeAssistantEntry(a.assistantId);
|
|
@@ -165,7 +165,7 @@ export const logout = Object.assign(
|
|
|
165
165
|
);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
clearCloudToken();
|
|
169
169
|
console.log("Logged out. Cadet Cloud token removed.");
|
|
170
170
|
},
|
|
171
171
|
{ description: "Log out of Cadet Cloud" },
|
|
@@ -182,7 +182,7 @@ export const whoami = Object.assign(
|
|
|
182
182
|
process.exit(0);
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
const token =
|
|
185
|
+
const token = readCloudToken();
|
|
186
186
|
if (!token) {
|
|
187
187
|
console.error("Not logged in. Run `cadet login` first.");
|
|
188
188
|
process.exit(1);
|
package/src/commands/logs.ts
CHANGED
|
@@ -623,7 +623,7 @@ export const logs = Object.assign(
|
|
|
623
623
|
|
|
624
624
|
case "cadet":
|
|
625
625
|
console.error(
|
|
626
|
-
"Logs for Cadet
|
|
626
|
+
"Logs for Cadet Cloud instances are not yet supported.\n" +
|
|
627
627
|
"View logs in the Cadet Cloud dashboard.",
|
|
628
628
|
);
|
|
629
629
|
process.exit(1);
|