@mycadet/cli 0.12.7 → 0.12.9-dev.202610131452.9acab64
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-cloud-login.ts +18 -0
- package/node_modules/@mycadet/assistant-api/index.ts +11 -11
- package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/package.json +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +6 -4
- 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 +1 -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} +28 -18
- 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__/ensure-binary.test.ts +182 -0
- 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 +15 -20
- package/src/__tests__/ngrok-spawn.test.ts +49 -0
- package/src/__tests__/orphan-detection.test.ts +1 -1
- package/src/__tests__/pair.test.ts +149 -85
- package/src/__tests__/{ps-platform-status.test.ts → ps-cloud-status.test.ts} +80 -26
- package/src/__tests__/ps-table.test.ts +79 -0
- 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} +2 -2
- package/src/__tests__/teleport-backup.test.ts +3 -3
- package/src/__tests__/teleport.test.ts +180 -211
- package/src/__tests__/tunnel.test.ts +490 -270
- package/src/__tests__/uninstall.test.ts +150 -9
- 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 +260 -43
- package/src/__tests__/workos-pkce.test.ts +2 -2
- package/src/commands/backup.ts +24 -24
- package/src/commands/client.ts +76 -78
- package/src/commands/completions.test.ts +104 -0
- package/src/commands/completions.ts +87 -0
- package/src/commands/debug.ts +20 -20
- package/src/commands/exec.ts +12 -12
- package/src/commands/flags.ts +2 -2
- package/src/commands/hatch.ts +27 -24
- package/src/commands/login.ts +22 -22
- package/src/commands/logs.ts +8 -8
- package/src/commands/pair.ts +140 -37
- package/src/commands/ps.ts +232 -86
- package/src/commands/restart.ts +30 -0
- package/src/commands/restore.ts +140 -22
- package/src/commands/retire.ts +48 -150
- package/src/commands/rollback.ts +20 -26
- package/src/commands/setup.ts +2 -2
- package/src/commands/sleep.ts +2 -2
- package/src/commands/teleport.ts +110 -129
- package/src/commands/terminal.ts +158 -18
- package/src/commands/tunnel.ts +156 -175
- package/src/commands/uninstall.ts +137 -54
- package/src/commands/unpair.ts +3 -3
- package/src/commands/upgrade.ts +30 -54
- package/src/commands/use.ts +1 -1
- package/src/commands/wake.ts +166 -50
- package/src/index.ts +18 -9
- package/src/lib/__tests__/{platform-client-signed-url.test.ts → cloud-client-signed-url.test.ts} +16 -16
- package/src/lib/__tests__/docker.test.ts +168 -20
- package/src/lib/__tests__/job-polling.test.ts +2 -2
- package/src/lib/__tests__/local-gateway-cli.test.ts +42 -0
- 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} +105 -99
- package/src/lib/cloud-login.ts +23 -24
- package/src/lib/{platform-releases.ts → cloud-releases.ts} +11 -9
- package/src/lib/cloud-values.ts +3 -0
- package/src/lib/color.ts +4 -0
- package/src/lib/config-utils.ts +1 -1
- package/src/lib/detached-process.ts +1 -1
- package/src/lib/docker.ts +300 -111
- package/src/lib/ensure-binary.ts +171 -0
- package/src/lib/environments/__tests__/paths.test.ts +29 -3
- package/src/lib/environments/__tests__/resolve.test.ts +26 -26
- package/src/lib/environments/paths.ts +16 -8
- package/src/lib/environments/resolve.ts +10 -12
- package/src/lib/flag-args.test.ts +1 -1
- package/src/lib/flag-args.ts +1 -1
- package/src/lib/guardian-token.ts +37 -5
- package/src/lib/hatch-local.ts +32 -29
- package/src/lib/hatch-next-steps.ts +5 -9
- package/src/lib/health-check.ts +6 -6
- package/src/lib/ingress-config.ts +8 -35
- package/src/lib/job-polling.ts +2 -2
- 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 +46 -34
- package/src/lib/nginx-ingress.ts +40 -15
- package/src/lib/pair.ts +1 -1
- 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/step-runner.ts +6 -1
- package/src/lib/sync-cloud-assistants.ts +19 -19
- 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} +36 -15
- package/src/lib/tunnels/gateway-notify.ts +61 -0
- package/src/lib/{ngrok.ts → tunnels/ngrok.ts} +350 -89
- package/src/lib/{tailscale-tunnel.ts → tunnels/tailscale.ts} +53 -9
- package/src/lib/upgrade-lifecycle.ts +8 -21
- 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/node_modules/@mycadet/assistant-api/events/show-platform-login.ts +0 -20
- 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
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* A teleport ends with the source assistant being retired, so each surface
|
|
5
5
|
* snapshots the source before any data leaves it. This module holds the
|
|
6
6
|
* decisions those surfaces must agree on: how fresh an existing backup has to
|
|
7
|
-
* be to stand in for a new one, and how a
|
|
7
|
+
* be to stand in for a new one, and how a cloud (PVC) snapshot is judged
|
|
8
8
|
* restorable. Transport lives with each client; nothing here touches the
|
|
9
9
|
* network or the filesystem.
|
|
10
10
|
*/
|
|
@@ -43,7 +43,7 @@ export function hasRecentBackup(
|
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
/** The fields of a
|
|
46
|
+
/** The fields of a cloud backup listing entry the policy reads. */
|
|
47
47
|
export interface ManagedBackupEntry {
|
|
48
48
|
snapshot_name?: string;
|
|
49
49
|
created_at?: string;
|
|
@@ -16,7 +16,7 @@ import { withLockfileLock } from "./lockfile-lock";
|
|
|
16
16
|
* `cadet unpair`: the remote assistant itself is never touched (host-side
|
|
17
17
|
* device revocation is `cadet devices`). Only pairing records
|
|
18
18
|
* (`cloud: "paired"`, created by `cadet connect import`) are forgettable this
|
|
19
|
-
* way; local and
|
|
19
|
+
* way; local and cloud assistants go through retire.
|
|
20
20
|
*/
|
|
21
21
|
export function unpairAssistant(
|
|
22
22
|
lockfilePaths: string[],
|
|
@@ -53,7 +53,7 @@ function unpairAssistantLocked(
|
|
|
53
53
|
ok: false,
|
|
54
54
|
status: 400,
|
|
55
55
|
error:
|
|
56
|
-
"Only paired assistants can be unpaired. Use retire for local or
|
|
56
|
+
"Only paired assistants can be unpaired. Use retire for local or cloud assistants.",
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"./error": "./src/error.ts",
|
|
27
27
|
"./reactions": "./src/reactions.ts",
|
|
28
28
|
"./guardian-requests": "./src/guardian-requests.ts",
|
|
29
|
-
"./
|
|
29
|
+
"./cloud-credential": "./src/cloud-credential.ts",
|
|
30
30
|
"./plan-credit": "./src/plan-credit.ts",
|
|
31
31
|
"./integration-categories": "./src/integration-categories.ts",
|
|
32
32
|
"./mcp-oauth": "./src/mcp-oauth.ts"
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/bun": "1.2.4",
|
|
43
|
-
"typescript": "5.
|
|
43
|
+
"typescript": "5.9.3"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Wire contract for asking an assistant whether its stored
|
|
2
|
+
* Wire contract for asking an assistant whether its stored cloud-managed
|
|
3
3
|
* credential still authenticates.
|
|
4
4
|
*
|
|
5
5
|
* The daemon route is the authoritative serving side:
|
|
6
6
|
* - `POST /v1/platform/verify-credential`
|
|
7
|
-
* (`assistant/src/runtime/routes/
|
|
7
|
+
* (`assistant/src/runtime/routes/cloud-routes.ts`)
|
|
8
8
|
*
|
|
9
9
|
* The daemon's platform client produces the verdict, the route reports it,
|
|
10
10
|
* and the `cadet` CLI reads it before deciding whether a stored key can be
|
|
@@ -15,26 +15,26 @@
|
|
|
15
15
|
import { z } from "zod";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* What the
|
|
18
|
+
* What the cloud said about the stored credential, right now.
|
|
19
19
|
*
|
|
20
|
-
* - `valid`: the
|
|
21
|
-
* - `rejected`: the
|
|
20
|
+
* - `valid`: the cloud accepted it.
|
|
21
|
+
* - `rejected`: the cloud refused it (unauthorized or forbidden); the
|
|
22
22
|
* credential needs replacing.
|
|
23
23
|
* - `unknown`: the check itself could not run (no credential stored, the
|
|
24
24
|
* platform unreachable, a server error). Not evidence either way.
|
|
25
25
|
*/
|
|
26
|
-
export const
|
|
26
|
+
export const CloudCredentialVerificationStatusSchema = z.enum([
|
|
27
27
|
"valid",
|
|
28
28
|
"rejected",
|
|
29
29
|
"unknown",
|
|
30
30
|
]);
|
|
31
|
-
export type
|
|
32
|
-
typeof
|
|
31
|
+
export type CloudCredentialVerificationStatus = z.infer<
|
|
32
|
+
typeof CloudCredentialVerificationStatusSchema
|
|
33
33
|
>;
|
|
34
34
|
|
|
35
35
|
/** `POST /v1/platform/verify-credential` response body. */
|
|
36
36
|
export const PlatformVerifyCredentialResponseSchema = z.object({
|
|
37
|
-
status:
|
|
37
|
+
status: CloudCredentialVerificationStatusSchema,
|
|
38
38
|
});
|
|
39
39
|
export type PlatformVerifyCredentialResponse = z.infer<
|
|
40
40
|
typeof PlatformVerifyCredentialResponseSchema
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
* Format: `local_oauth:<providerKey>/<connectionId>` where providerKey
|
|
16
16
|
* is the bare provider name (e.g. `google`).
|
|
17
17
|
*
|
|
18
|
-
* 3. **
|
|
18
|
+
* 3. **Cloud OAuth** — references an OAuth connection managed by the
|
|
19
19
|
* platform. Format: `platform_oauth:<connectionId>` where connectionId
|
|
20
|
-
* is the
|
|
20
|
+
* is the cloud-assigned connection identifier.
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
import { z } from "zod";
|
|
@@ -96,7 +96,7 @@ export function localOAuthHandle(
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
|
-
* Build a
|
|
99
|
+
* Build a cloud (platform) OAuth credential handle from a connection ID.
|
|
100
100
|
*/
|
|
101
101
|
export function platformOAuthHandle(connectionId: string): string {
|
|
102
102
|
return `${HandleType.PlatformOAuth}:${connectionId}`;
|
|
@@ -31,7 +31,7 @@ export * from "./no-response.js";
|
|
|
31
31
|
export * from "./plan-credit.js";
|
|
32
32
|
export * from "./integration-categories.js";
|
|
33
33
|
export * from "./mcp-oauth.js";
|
|
34
|
-
export * from "./
|
|
34
|
+
export * from "./cloud-credential.js";
|
|
35
35
|
export * from "./remote-web-pairing.js";
|
|
36
36
|
export * from "./twilio-ingress.js";
|
|
37
37
|
export * from "./url-normalization.js";
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* `{env}-cloud.mycadet.ai` → `tunnel-{env}.mycadet.ai`). Returns null for
|
|
5
5
|
* hosts outside that convention (localhost, custom domains). Shared by the
|
|
6
6
|
* gateway speech relay and the web live-voice client so the two ends of the
|
|
7
|
-
*
|
|
7
|
+
* cloud-speech transport can't drift.
|
|
8
8
|
*/
|
|
9
9
|
export function tunnelHostForPlatformHost(host: string): string | null {
|
|
10
10
|
if (host === "cloud.mycadet.ai") {
|
|
@@ -100,11 +100,17 @@ export const INGRESS_PAIRING_TUNNEL_KEY = "pairingTunnel";
|
|
|
100
100
|
export const INGRESS_ASSISTANT_ID_KEY = "assistantId";
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
|
-
* The
|
|
104
|
-
* `cadet tunnel
|
|
105
|
-
*
|
|
103
|
+
* The tunnel providers the CLI offers, in the order they are presented —
|
|
104
|
+
* the managed `cadet` tunnel first (listed, not yet implemented), then the
|
|
105
|
+
* local ones. `cadet tunnel`'s accepted `--provider` values and the
|
|
106
|
+
* persisted-record validation below both derive from it.
|
|
106
107
|
*/
|
|
107
|
-
export const TUNNEL_PROVIDERS = [
|
|
108
|
+
export const TUNNEL_PROVIDERS = [
|
|
109
|
+
"cadet",
|
|
110
|
+
"ngrok",
|
|
111
|
+
"cloudflare",
|
|
112
|
+
"tailscale",
|
|
113
|
+
] as const;
|
|
108
114
|
|
|
109
115
|
export type TunnelProviderName = (typeof TUNNEL_PROVIDERS)[number];
|
|
110
116
|
|
|
@@ -152,7 +152,7 @@ export const DEFAULT_REMOTE_WEB_PAIRING_PLATFORM: RemoteWebPairingPlatform =
|
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
154
|
* A requested platform coerced to a known value. The pairing-token route is
|
|
155
|
-
* publicly reachable and the
|
|
155
|
+
* publicly reachable and the cloud renders verbatim in the host's
|
|
156
156
|
* paired-devices list, so an unrecognized value never reaches the DB.
|
|
157
157
|
*/
|
|
158
158
|
export function resolveRemoteWebPairingPlatform(
|
|
@@ -34,7 +34,7 @@ import { RpcErrorSchema } from "./error.js";
|
|
|
34
34
|
|
|
35
35
|
export const CesRpcMethod = {
|
|
36
36
|
/** Push an updated assistant credential to CES after post-hatch provisioning. */
|
|
37
|
-
|
|
37
|
+
UpdateCloudCredential: "update_managed_credential",
|
|
38
38
|
/** Retrieve a single credential by account name. */
|
|
39
39
|
GetCredential: "get_credential",
|
|
40
40
|
/** Store or update a credential by account name. */
|
|
@@ -63,7 +63,7 @@ export type CesRpcMethod = (typeof CesRpcMethod)[keyof typeof CesRpcMethod];
|
|
|
63
63
|
// update_managed_credential
|
|
64
64
|
// ---------------------------------------------------------------------------
|
|
65
65
|
|
|
66
|
-
export const
|
|
66
|
+
export const UpdateCloudCredentialSchema = z.object({
|
|
67
67
|
/** The assistant API key to push to CES for platform credential materialization. */
|
|
68
68
|
assistantApiKey: z.string(), // nosemgrep: not-a-secret
|
|
69
69
|
/**
|
|
@@ -72,16 +72,16 @@ export const UpdateManagedCredentialSchema = z.object({
|
|
|
72
72
|
*/
|
|
73
73
|
assistantId: z.string().optional(),
|
|
74
74
|
});
|
|
75
|
-
export type
|
|
76
|
-
typeof
|
|
75
|
+
export type UpdateCloudCredential = z.infer<
|
|
76
|
+
typeof UpdateCloudCredentialSchema
|
|
77
77
|
>;
|
|
78
78
|
|
|
79
|
-
export const
|
|
80
|
-
/** Whether the
|
|
79
|
+
export const UpdateCloudCredentialResponseSchema = z.object({
|
|
80
|
+
/** Whether the cloud credential was successfully updated. */
|
|
81
81
|
updated: z.boolean(),
|
|
82
82
|
});
|
|
83
|
-
export type
|
|
84
|
-
typeof
|
|
83
|
+
export type UpdateCloudCredentialResponse = z.infer<
|
|
84
|
+
typeof UpdateCloudCredentialResponseSchema
|
|
85
85
|
>;
|
|
86
86
|
|
|
87
87
|
// ---------------------------------------------------------------------------
|
|
@@ -311,9 +311,9 @@ export type BulkSetCredentialRecordsResponse = z.infer<
|
|
|
311
311
|
* schemas. Useful for building type-safe RPC dispatch layers.
|
|
312
312
|
*/
|
|
313
313
|
export interface CesRpcContract {
|
|
314
|
-
[CesRpcMethod.
|
|
315
|
-
request:
|
|
316
|
-
response:
|
|
314
|
+
[CesRpcMethod.UpdateCloudCredential]: {
|
|
315
|
+
request: UpdateCloudCredential;
|
|
316
|
+
response: UpdateCloudCredentialResponse;
|
|
317
317
|
};
|
|
318
318
|
[CesRpcMethod.GetCredential]: {
|
|
319
319
|
request: GetCredential;
|
|
@@ -361,9 +361,9 @@ export interface CesRpcContract {
|
|
|
361
361
|
* Schema lookup map for runtime validation of RPC payloads.
|
|
362
362
|
*/
|
|
363
363
|
export const CesRpcSchemas = {
|
|
364
|
-
[CesRpcMethod.
|
|
365
|
-
request:
|
|
366
|
-
response:
|
|
364
|
+
[CesRpcMethod.UpdateCloudCredential]: {
|
|
365
|
+
request: UpdateCloudCredentialSchema,
|
|
366
|
+
response: UpdateCloudCredentialResponseSchema,
|
|
367
367
|
},
|
|
368
368
|
[CesRpcMethod.GetCredential]: {
|
|
369
369
|
request: GetCredentialSchema,
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* - **URL**: tools whose candidates include a URL (`web_fetch`,
|
|
16
16
|
* `network_request`).
|
|
17
17
|
* - **Managed skill**: tools that manage first-party skill packages
|
|
18
|
-
* (`
|
|
18
|
+
* (`scaffold_cloud_skill`, `delete_cloud_skill`).
|
|
19
19
|
* - **Skill load**: the `skill_load` tool, which uses a distinct candidate
|
|
20
20
|
* namespace (`skill_load:selector` or `skill_load_dynamic:selector`).
|
|
21
21
|
* - **Generic**: everything else (computer-use tools, UI surface tools,
|
|
@@ -58,8 +58,8 @@ export const URL_TOOLS = ["web_fetch", "network_request"] as const;
|
|
|
58
58
|
* Tools that manage first-party skill packages (scaffold/delete).
|
|
59
59
|
*/
|
|
60
60
|
export const MANAGED_SKILL_TOOLS = [
|
|
61
|
-
"
|
|
62
|
-
"
|
|
61
|
+
"scaffold_cloud_skill",
|
|
62
|
+
"delete_cloud_skill",
|
|
63
63
|
] as const;
|
|
64
64
|
|
|
65
65
|
/**
|
|
@@ -89,8 +89,8 @@ export function isUrlRule(rule: { tool: string }): boolean {
|
|
|
89
89
|
return URL_TOOLS_SET.has(rule.tool);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
/** Returns true when the rule's tool belongs to the
|
|
93
|
-
export function
|
|
92
|
+
/** Returns true when the rule's tool belongs to the cloud-skill-tool family. */
|
|
93
|
+
export function isCloudSkillRule(rule: { tool: string }): boolean {
|
|
94
94
|
return MANAGED_SKILL_TOOLS_SET.has(rule.tool);
|
|
95
95
|
}
|
|
96
96
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mycadet/cli",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.9-dev.202610131452.9acab64",
|
|
4
4
|
"description": "CLI tools for mycadet",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"./src/commands/*": "./src/commands/*.ts"
|
|
16
16
|
},
|
|
17
17
|
"bin": {
|
|
18
|
-
"cadet": "./src/index.ts"
|
|
18
|
+
"cadet-dev": "./src/index.ts"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"format": "prettier --write .",
|
|
22
22
|
"format:check": "prettier --check .",
|
|
23
|
-
"lint": "eslint --max-warnings
|
|
23
|
+
"lint": "eslint --max-warnings 323",
|
|
24
24
|
"lint:unused": "knip --include files,dependencies,unlisted",
|
|
25
25
|
"compile:check": "bun build --compile src/index.ts --outfile /dev/null",
|
|
26
26
|
"test": "bun run scripts/run-tests.ts",
|
|
27
|
-
"typecheck": "bunx
|
|
27
|
+
"typecheck": "bunx tsgo --noEmit"
|
|
28
28
|
},
|
|
29
29
|
"author": "Cadet AI",
|
|
30
30
|
"license": "MIT",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"qrcode-terminal": "0.12.0",
|
|
42
42
|
"react": "19.2.6",
|
|
43
43
|
"react-devtools-core": "7.0.1",
|
|
44
|
+
"yaml": "2.8.2",
|
|
44
45
|
"zod": "4.3.6"
|
|
45
46
|
},
|
|
46
47
|
"bundledDependencies": [
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
"@types/bun": "1.3.11",
|
|
57
58
|
"@types/qrcode-terminal": "0.12.2",
|
|
58
59
|
"@types/react": "19.2.14",
|
|
60
|
+
"@typescript/native-preview": "7.0.0-dev.20260624.1",
|
|
59
61
|
"eslint": "10.1.0",
|
|
60
62
|
"knip": "5.88.1",
|
|
61
63
|
"prettier": "3.8.1",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, mock, test } from "bun:test";
|
|
2
2
|
|
|
3
|
-
import * as
|
|
3
|
+
import * as realCloudClient from "../lib/cloud-client.js";
|
|
4
4
|
|
|
5
5
|
const calls: string[] = [];
|
|
6
6
|
let verifyResult: "valid" | "rejected" | "unknown" | null = "valid";
|
|
@@ -9,9 +9,9 @@ let readResult: { value: string | null; unreachable: boolean } = {
|
|
|
9
9
|
unreachable: false,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
mock.module("../lib/
|
|
13
|
-
...
|
|
14
|
-
|
|
12
|
+
mock.module("../lib/cloud-client.js", () => ({
|
|
13
|
+
...realCloudClient,
|
|
14
|
+
verifyGatewayCloudCredential: mock(async () => {
|
|
15
15
|
calls.push("verify");
|
|
16
16
|
return verifyResult;
|
|
17
17
|
}),
|
|
@@ -61,13 +61,13 @@ describe("resolveAssistantApiKeyForInjection", () => {
|
|
|
61
61
|
// The verdict comes first and the key is read after it, so the value
|
|
62
62
|
// returned is the one the verdict covered, never one a concurrent repair
|
|
63
63
|
// has since replaced.
|
|
64
|
-
test("a stored key the
|
|
64
|
+
test("a stored key the cloud accepts is read after the verdict", async () => {
|
|
65
65
|
const resolved = await resolveAssistantApiKeyForInjection(ARGS);
|
|
66
66
|
expect(resolved).toEqual({ apiKey: "stored-key", source: "stored" });
|
|
67
67
|
expect(calls).toEqual(["verify", "read"]);
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
test("a stored key the
|
|
70
|
+
test("a stored key the cloud rejects is replaced without being read", async () => {
|
|
71
71
|
verifyResult = "rejected";
|
|
72
72
|
const resolved = await resolveAssistantApiKeyForInjection(ARGS);
|
|
73
73
|
expect(resolved).toEqual({ apiKey: "fresh-key", source: "reprovisioned" });
|
package/src/__tests__/{assistant-client-platform-auth.test.ts → assistant-client-cloud-auth.test.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tests for AssistantClient's
|
|
2
|
+
* Tests for AssistantClient's cloud-managed (`cloud: "cadet"`) auth path.
|
|
3
3
|
* These entries have no guardian token on disk, so the client must authenticate
|
|
4
4
|
* with the stored platform credential instead of sending an anonymous request
|
|
5
|
-
* (which the
|
|
5
|
+
* (which the cloud answers with a bare 403).
|
|
6
6
|
*/
|
|
7
7
|
import {
|
|
8
8
|
afterAll,
|
|
@@ -16,7 +16,7 @@ import { mkdtempSync, rmSync } from "node:fs";
|
|
|
16
16
|
import { tmpdir } from "node:os";
|
|
17
17
|
import { join } from "node:path";
|
|
18
18
|
|
|
19
|
-
const testDir = mkdtempSync(join(tmpdir(), "client-
|
|
19
|
+
const testDir = mkdtempSync(join(tmpdir(), "client-cloud-auth-test-"));
|
|
20
20
|
const ORIGINAL_LOCKFILE_DIR = process.env.CADET_LOCKFILE_DIR;
|
|
21
21
|
const ORIGINAL_CONFIG_HOME = process.env.XDG_CONFIG_HOME;
|
|
22
22
|
const ORIGINAL_FETCH = globalThis.fetch;
|
|
@@ -24,15 +24,15 @@ const ORIGINAL_FETCH = globalThis.fetch;
|
|
|
24
24
|
import { AssistantClient } from "../lib/assistant-client.js";
|
|
25
25
|
import { saveAssistantEntry } from "../lib/assistant-config.js";
|
|
26
26
|
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} from "../lib/
|
|
27
|
+
clearCloudToken,
|
|
28
|
+
saveCloudToken,
|
|
29
|
+
} from "../lib/cloud-client.js";
|
|
30
30
|
|
|
31
31
|
const PLATFORM_URL = "https://platform.example.com";
|
|
32
32
|
const ASSISTANT_ID = "019d1e04-cb20-719a-b04b-310072904444";
|
|
33
33
|
const ORG_ID = "org-abc";
|
|
34
34
|
|
|
35
|
-
/** Seed a
|
|
35
|
+
/** Seed a cloud-managed lockfile entry, optionally with a stored token. */
|
|
36
36
|
function seedCloud(token?: string): void {
|
|
37
37
|
saveAssistantEntry({
|
|
38
38
|
assistantId: ASSISTANT_ID,
|
|
@@ -41,7 +41,7 @@ function seedCloud(token?: string): void {
|
|
|
41
41
|
cloud: "cadet",
|
|
42
42
|
});
|
|
43
43
|
if (token) {
|
|
44
|
-
|
|
44
|
+
saveCloudToken(token);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -68,7 +68,7 @@ const isOrgFetch = (url: string) => url.includes("/v1/organizations/");
|
|
|
68
68
|
const isRefresh = (url: string) => url.includes("/v1/guardian/refresh");
|
|
69
69
|
|
|
70
70
|
function orgResponse(): Response {
|
|
71
|
-
return new Response(JSON.stringify({ results: [{ id: ORG_ID }] }), {
|
|
71
|
+
return new Response(JSON.stringify({ results: [{ id: ORG_ID, name: "My Cadet" }] }), {
|
|
72
72
|
status: 200,
|
|
73
73
|
headers: { "content-type": "application/json" },
|
|
74
74
|
});
|
|
@@ -79,7 +79,7 @@ describe("AssistantClient cloud-managed auth", () => {
|
|
|
79
79
|
process.env.CADET_LOCKFILE_DIR = testDir;
|
|
80
80
|
process.env.XDG_CONFIG_HOME = testDir;
|
|
81
81
|
// Tests share testDir, so a token saved by an earlier one must not leak.
|
|
82
|
-
|
|
82
|
+
clearCloudToken();
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
afterEach(() => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Tests for AssistantClient's reactive 401 -> refresh -> retry: a paired/local
|
|
3
3
|
* guardian access token that 401s is refreshed once via the stored refresh
|
|
4
4
|
* credential and the request retried. Self-gating (no refresh token => no
|
|
5
|
-
* retry) and never applied to the
|
|
5
|
+
* retry) and never applied to the cloud session-auth path.
|
|
6
6
|
*/
|
|
7
7
|
import {
|
|
8
8
|
afterAll,
|
|
@@ -148,7 +148,7 @@ describe("AssistantClient 401 -> refresh -> retry", () => {
|
|
|
148
148
|
expect(calls.filter((c) => isRefresh(c.url))).toHaveLength(0);
|
|
149
149
|
});
|
|
150
150
|
|
|
151
|
-
test("never refreshes on the
|
|
151
|
+
test("never refreshes on the cloud session-auth path", async () => {
|
|
152
152
|
seedPaired("refresh-tok"); // entry must exist; session auth ignores it
|
|
153
153
|
let assistantAttempts = 0;
|
|
154
154
|
const calls = stubFetch((url) => {
|