@cleanslop/cli 0.1.0-beta.4 → 0.1.0-beta.41
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 +8 -5
- package/assets/skill-core.md +24 -14
- package/dist/action.d.ts +4 -1
- package/dist/action.js +24 -0
- package/dist/action.js.map +1 -1
- package/dist/args.d.ts +1 -1
- package/dist/args.js +45 -11
- package/dist/args.js.map +1 -1
- package/dist/commands/billing.d.ts +9 -0
- package/dist/commands/billing.js +113 -0
- package/dist/commands/billing.js.map +1 -0
- package/dist/commands/credits.d.ts +43 -0
- package/dist/commands/credits.js +268 -24
- package/dist/commands/credits.js.map +1 -1
- package/dist/commands/email.js +22 -0
- package/dist/commands/email.js.map +1 -1
- package/dist/commands/link-identity.js +5 -3
- package/dist/commands/link-identity.js.map +1 -1
- package/dist/commands/link-login.js +34 -11
- package/dist/commands/link-login.js.map +1 -1
- package/dist/commands/login.d.ts +1 -0
- package/dist/commands/login.js +25 -22
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts +2 -1
- package/dist/commands/logout.js +48 -23
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/plan.d.ts +30 -0
- package/dist/commands/plan.js +278 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/redeem.d.ts +7 -0
- package/dist/commands/redeem.js +33 -0
- package/dist/commands/redeem.js.map +1 -0
- package/dist/commands/report.js +10 -3
- package/dist/commands/report.js.map +1 -1
- package/dist/commands/scan-upload.js +51 -29
- package/dist/commands/scan-upload.js.map +1 -1
- package/dist/commands/scan.js +49 -7
- package/dist/commands/scan.js.map +1 -1
- package/dist/commands/whoami.js +27 -0
- package/dist/commands/whoami.js.map +1 -1
- package/dist/config.d.ts +6 -3
- package/dist/config.js +5 -2
- package/dist/config.js.map +1 -1
- package/dist/connect.d.ts +21 -0
- package/dist/connect.js +109 -0
- package/dist/connect.js.map +1 -0
- package/dist/credentials.d.ts +18 -4
- package/dist/credentials.js +41 -16
- package/dist/credentials.js.map +1 -1
- package/dist/done-question.d.ts +20 -0
- package/dist/done-question.js +25 -0
- package/dist/done-question.js.map +1 -0
- package/dist/exit.d.ts +29 -0
- package/dist/exit.js +12 -0
- package/dist/exit.js.map +1 -1
- package/dist/git.d.ts +19 -1
- package/dist/git.js +48 -1
- package/dist/git.js.map +1 -1
- package/dist/http.js +86 -4
- package/dist/http.js.map +1 -1
- package/dist/link.d.ts +67 -18
- package/dist/link.js +183 -73
- package/dist/link.js.map +1 -1
- package/dist/main.js +14 -3
- package/dist/main.js.map +1 -1
- package/dist/output.js +6 -1
- package/dist/output.js.map +1 -1
- package/dist/pack.d.ts +20 -3
- package/dist/pack.js +40 -3
- package/dist/pack.js.map +1 -1
- package/dist/report-question.d.ts +12 -0
- package/dist/report-question.js +143 -0
- package/dist/report-question.js.map +1 -0
- package/dist/skill.d.ts +1 -1
- package/dist/skill.js +1 -1
- package/dist/skill.js.map +1 -1
- package/dist/token-rotation.d.ts +11 -0
- package/dist/token-rotation.js +35 -0
- package/dist/token-rotation.js.map +1 -0
- package/dist/top-up.d.ts +27 -0
- package/dist/top-up.js +88 -0
- package/dist/top-up.js.map +1 -0
- package/dist/types.d.ts +27 -1
- package/package.json +1 -1
|
@@ -1,26 +1,47 @@
|
|
|
1
1
|
import { CLIENT_ID, TERMS_UPDATED_ON } from "../config.js";
|
|
2
|
-
import {
|
|
2
|
+
import { offerGithubAfterLinkFailure } from "../connect.js";
|
|
3
|
+
import { resolveOrigin } from "../credentials.js";
|
|
3
4
|
import { CliError, EXIT_OK, EXIT_POLICY, EXIT_UNEXPECTED } from "../exit.js";
|
|
4
5
|
import { asErrorBody, hasIdentityPresentationChallenge, httpRequest, throwHttpError, } from "../http.js";
|
|
5
|
-
import {
|
|
6
|
+
import { linkAttestation, linkAuthMode, linkSignupBody, presentLinkIdentity, readLinkClaimsChallenge, linkTermsAgreed, requireLinkTermsConsent, } from "../link.js";
|
|
7
|
+
import { storeLoginToken } from "../token-rotation.js";
|
|
8
|
+
/** The server answers `terms_required` when the Link-verified email is new. */
|
|
9
|
+
function needsTerms(result) {
|
|
10
|
+
return asErrorBody(result.json).error === "terms_required";
|
|
11
|
+
}
|
|
6
12
|
export async function runLinkLogin(deps, args) {
|
|
7
|
-
const authMode = linkAuthMode(args);
|
|
8
13
|
const origin = resolveOrigin(deps);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
14
|
+
// Choosing Link and approving it in Link covers sharing the verified email.
|
|
15
|
+
// The terms are asked only when that email has no CleanSlop account yet.
|
|
16
|
+
const agreed = linkTermsAgreed(args) ? "flag" : null;
|
|
17
|
+
const first = await signInWithLink(deps, args, origin, agreed);
|
|
18
|
+
if (first !== "terms_required")
|
|
19
|
+
return first;
|
|
20
|
+
const consentSource = await requireLinkTermsConsent(deps, origin);
|
|
21
|
+
const second = await signInWithLink(deps, args, origin, consentSource);
|
|
22
|
+
if (second === "terms_required") {
|
|
23
|
+
throw new CliError("CleanSlop still asks for the current terms.", EXIT_UNEXPECTED);
|
|
24
|
+
}
|
|
25
|
+
return second;
|
|
26
|
+
}
|
|
27
|
+
async function signInWithLink(deps, args, origin, consentSource) {
|
|
28
|
+
const acceptTerms = consentSource ? TERMS_UPDATED_ON : null;
|
|
29
|
+
const attestation = await linkAttestation(deps, { mode: linkAuthMode(args) }).catch(offerGithubAfterLinkFailure);
|
|
12
30
|
const started = await httpRequest(deps, origin, "POST", "/oauth/link", {
|
|
13
31
|
headers: { Authorization: attestation.authorization },
|
|
14
|
-
body: linkSignupBody(deps,
|
|
32
|
+
body: linkSignupBody(deps, acceptTerms, consentSource),
|
|
15
33
|
});
|
|
16
34
|
if (!hasIdentityPresentationChallenge(started)) {
|
|
35
|
+
// A server from before terms-on-create refuses here instead.
|
|
36
|
+
if (!consentSource && needsTerms(started))
|
|
37
|
+
return "terms_required";
|
|
17
38
|
throwHttpError(started);
|
|
18
39
|
}
|
|
19
40
|
const challenge = readLinkClaimsChallenge(started.json, origin);
|
|
20
41
|
const presented = await presentLinkIdentity(deps, {
|
|
21
42
|
aud: challenge.aud,
|
|
22
43
|
nonce: challenge.nonce,
|
|
23
|
-
});
|
|
44
|
+
}).catch(offerGithubAfterLinkFailure);
|
|
24
45
|
const completed = await httpRequest(deps, origin, "POST", "/oauth/link", {
|
|
25
46
|
headers: {
|
|
26
47
|
Authorization: attestation.authorization,
|
|
@@ -29,10 +50,12 @@ export async function runLinkLogin(deps, args) {
|
|
|
29
50
|
},
|
|
30
51
|
body: {
|
|
31
52
|
client: CLIENT_ID,
|
|
32
|
-
acceptTerms:
|
|
33
|
-
consentSource,
|
|
53
|
+
...(acceptTerms ? { acceptTerms } : {}),
|
|
54
|
+
...(consentSource ? { consentSource } : {}),
|
|
34
55
|
},
|
|
35
56
|
});
|
|
57
|
+
if (!consentSource && needsTerms(completed))
|
|
58
|
+
return "terms_required";
|
|
36
59
|
const body = asErrorBody(completed.json);
|
|
37
60
|
if (completed.status >= 400) {
|
|
38
61
|
if (body.error === "link_pilot_required") {
|
|
@@ -51,7 +74,7 @@ export async function runLinkLogin(deps, args) {
|
|
|
51
74
|
const emailMasked = (typeof account?.emailMasked === "string" && account.emailMasked) ||
|
|
52
75
|
(typeof account?.email_masked === "string" && account.email_masked) ||
|
|
53
76
|
null;
|
|
54
|
-
await
|
|
77
|
+
await storeLoginToken(deps, origin, {
|
|
55
78
|
token: issued.access_token,
|
|
56
79
|
githubLogin: issued.account?.github_login ?? null,
|
|
57
80
|
grantId: issued.grant_id ?? null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-login.js","sourceRoot":"","sources":["../../src/commands/link-login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"link-login.js","sourceRoot":"","sources":["../../src/commands/link-login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,g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;QACnE,IAAI,CAAC;IACP,MAAM,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE;QAClC,KAAK,EAAE,MAAM,CAAC,YAAY;QAC1B,WAAW,EAAE,MAAM,CAAC,OAAO,EAAE,YAAY,IAAI,IAAI;QACjD,OAAO,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;KACjC,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,WAAW,IAAI,iBAAiB,CAAC;IAC/C,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,gBAAgB,KAAK,WAAW,CAAC,CAAC;IACjD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/commands/login.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ import type { ParsedArgs } from "../types.js";
|
|
|
3
3
|
/** Matches server DEVICE_EXTEND_TTL_MS — first /connect view extends the code. */
|
|
4
4
|
export declare const DEVICE_POLL_GRACE_MS: number;
|
|
5
5
|
export declare function devicePollDeadline(expiresAt: number): number;
|
|
6
|
+
export declare const GITHUB_RESUME_COMMAND = "cleanslop login --resume";
|
|
6
7
|
export declare function runLogin(deps: CliDeps, args: ParsedArgs): Promise<number>;
|
package/dist/commands/login.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { CLIENT_ID, DEVICE_GRANT_TYPE, PACKAGE_VERSION } from "../config.js";
|
|
2
|
-
import { deletePendingLogin,
|
|
2
|
+
import { deletePendingLogin, readPendingLogin, resolveOrigin, writePendingLogin, } from "../credentials.js";
|
|
3
|
+
import { questionLines } from "../action.js";
|
|
4
|
+
import { doneQuestion } from "../done-question.js";
|
|
3
5
|
import { actionError, CliError, EXIT_ACTION, EXIT_OK, EXIT_UNEXPECTED, usageError, } from "../exit.js";
|
|
4
6
|
import { detectAgentHint, gitToplevel, parseGithubRemote } from "../git.js";
|
|
5
7
|
import { asErrorBody, httpRequest } from "../http.js";
|
|
8
|
+
import { storeLoginToken } from "../token-rotation.js";
|
|
6
9
|
import { runLinkLogin } from "./link-login.js";
|
|
7
10
|
/** Matches server DEVICE_EXTEND_TTL_MS — first /connect view extends the code. */
|
|
8
11
|
export const DEVICE_POLL_GRACE_MS = 30 * 60 * 1000;
|
|
@@ -18,16 +21,28 @@ async function repoHint(deps) {
|
|
|
18
21
|
return undefined;
|
|
19
22
|
return parseGithubRemote(remote.stdout)?.fullName;
|
|
20
23
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
export const GITHUB_RESUME_COMMAND = "cleanslop login --resume";
|
|
25
|
+
/** `--no-wait` exits after printing, so it also asks the human to say when they approved. */
|
|
26
|
+
function printApproval(deps, device, opts = {}) {
|
|
27
|
+
const url = device.verificationUriComplete;
|
|
28
|
+
const code = device.userCode;
|
|
29
|
+
deps.io.stderr(`${url}\n`);
|
|
30
|
+
deps.io.stderr(`${code}\n`);
|
|
31
|
+
const lines = [
|
|
25
32
|
"CLEANSLOP_ACTION_REQUIRED: approve",
|
|
26
33
|
"",
|
|
27
|
-
`Ask the human to open ${
|
|
34
|
+
`Ask the human to open ${url} and confirm code ${code}.`,
|
|
28
35
|
"Do not open or approve it yourself.",
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
];
|
|
37
|
+
if (opts.askDone) {
|
|
38
|
+
lines.push("", ...questionLines(doneQuestion({
|
|
39
|
+
id: "github_approval",
|
|
40
|
+
header: "Approve",
|
|
41
|
+
question: `Open ${url}, confirm code ${code}, and approve CleanSlop. Done?`,
|
|
42
|
+
then: { run: GITHUB_RESUME_COMMAND },
|
|
43
|
+
})));
|
|
44
|
+
}
|
|
45
|
+
deps.io.stderr(`${lines.join("\n")}\n`);
|
|
31
46
|
}
|
|
32
47
|
async function pollDeviceToken(deps, origin, device) {
|
|
33
48
|
let intervalMs = Math.max(3, device.interval) * 1000;
|
|
@@ -61,23 +76,11 @@ async function pollDeviceToken(deps, origin, device) {
|
|
|
61
76
|
throw new CliError("Token response was missing access_token.", EXIT_UNEXPECTED);
|
|
62
77
|
}
|
|
63
78
|
const login = issued.account?.github_login ?? null;
|
|
64
|
-
|
|
65
|
-
await storeToken(deps, origin, {
|
|
79
|
+
await storeLoginToken(deps, origin, {
|
|
66
80
|
token: issued.access_token,
|
|
67
81
|
githubLogin: login,
|
|
68
82
|
grantId: issued.grant_id ?? null,
|
|
69
83
|
});
|
|
70
|
-
if (prior?.token) {
|
|
71
|
-
try {
|
|
72
|
-
await httpRequest(deps, origin, "POST", "/oauth/revoke", {
|
|
73
|
-
token: prior.token,
|
|
74
|
-
body: { token: prior.token },
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
// Best-effort; the new login is already stored.
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
84
|
deletePendingLogin(deps);
|
|
82
85
|
const label = login ? `@${login}` : "your GitHub account";
|
|
83
86
|
deps.io.stdout(`Connected as ${label}\n`);
|
|
@@ -174,7 +177,7 @@ export async function runLogin(deps, args) {
|
|
|
174
177
|
printApproval(deps, {
|
|
175
178
|
verificationUriComplete: device.verification_uri_complete,
|
|
176
179
|
userCode: device.user_code,
|
|
177
|
-
});
|
|
180
|
+
}, { askDone: args.noWait });
|
|
178
181
|
if (args.noWait) {
|
|
179
182
|
await writePendingLogin(deps, {
|
|
180
183
|
version: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EACL,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,GAClB,MAAM,mBAAmB,C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C,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;IAC9D,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC;IAEnD,aAAa,CACX,IAAI,EACJ;QACE,uBAAuB,EAAE,MAAM,CAAC,yBAAyB;QACzD,QAAQ,EAAE,MAAM,CAAC,SAAS;KAC3B,EACD,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CACzB,CAAC;IAEF,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,MAAM,iBAAiB,CAAC,IAAI,EAAE;YAC5B,OAAO,EAAE,CAAC;YACV,MAAM;YACN,UAAU,EAAE,MAAM,CAAC,WAAW;YAC9B,QAAQ,EAAE,MAAM,CAAC,SAAS;YAC1B,uBAAuB,EAAE,MAAM,CAAC,yBAAyB;YACzD,SAAS;YACT,QAAQ,EAAE,WAAW;SACtB,CAAC,CAAC;QACH,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,OAAO,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE;QACnC,UAAU,EAAE,MAAM,CAAC,WAAW;QAC9B,QAAQ,EAAE,MAAM,CAAC,SAAS;QAC1B,uBAAuB,EAAE,MAAM,CAAC,yBAAyB;QACzD,QAAQ,EAAE,WAAW;QACrB,SAAS;KACV,CAAC,CAAC;AACL,CAAC"}
|
package/dist/commands/logout.js
CHANGED
|
@@ -1,40 +1,65 @@
|
|
|
1
|
-
import { deleteOriginCreds,
|
|
1
|
+
import { deleteAllLocalState, deleteOriginCreds, deletePendingFor, readCredentialsFile, resolveOrigin, resolveToken, } from "../credentials.js";
|
|
2
2
|
import { EXIT_OK, EXIT_UNEXPECTED } from "../exit.js";
|
|
3
3
|
import { httpRequest } from "../http.js";
|
|
4
|
-
|
|
4
|
+
/** Revokes `token` at `origin`; prints why and returns false when it could not. */
|
|
5
|
+
async function revoke(deps, origin, token) {
|
|
6
|
+
try {
|
|
7
|
+
const result = await httpRequest(deps, origin, "POST", "/oauth/revoke", {
|
|
8
|
+
token,
|
|
9
|
+
body: { token },
|
|
10
|
+
});
|
|
11
|
+
if (result.status >= 200 && result.status < 300)
|
|
12
|
+
return true;
|
|
13
|
+
deps.io.stderr(`Could not revoke the token for ${origin} (HTTP ${result.status}).\n`);
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
17
|
+
deps.io.stderr(`Could not revoke the token for ${origin}: ${message}\n`);
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const REVOKE_BY_HAND = "Revoke this agent under Account → Connected agents.";
|
|
22
|
+
export async function runLogout(deps, args) {
|
|
23
|
+
if (args.all)
|
|
24
|
+
return runLogoutAll(deps);
|
|
5
25
|
const origin = resolveOrigin(deps);
|
|
6
26
|
const creds = resolveToken(deps, origin);
|
|
7
|
-
|
|
8
|
-
if (creds) {
|
|
9
|
-
try {
|
|
10
|
-
const result = await httpRequest(deps, origin, "POST", "/oauth/revoke", {
|
|
11
|
-
token: creds.token,
|
|
12
|
-
body: { token: creds.token },
|
|
13
|
-
});
|
|
14
|
-
if (result.status < 200 || result.status >= 300) {
|
|
15
|
-
deps.io.stderr(`Could not revoke the token (HTTP ${result.status}).\n`);
|
|
16
|
-
revokeFailed = true;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
catch (err) {
|
|
20
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
21
|
-
deps.io.stderr(`Could not revoke the token: ${message}\n`);
|
|
22
|
-
revokeFailed = true;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
27
|
+
const revoked = creds ? await revoke(deps, origin, creds.token) : true;
|
|
25
28
|
if (creds?.source !== "env") {
|
|
26
29
|
await deleteOriginCreds(deps, origin);
|
|
27
30
|
}
|
|
28
|
-
|
|
31
|
+
deletePendingFor(deps, origin);
|
|
29
32
|
if (creds?.source === "env") {
|
|
30
33
|
deps.io.stdout("Disconnected. File credentials were left in place because CLEANSLOP_TOKEN is set.\n");
|
|
31
34
|
return EXIT_OK;
|
|
32
35
|
}
|
|
33
|
-
if (
|
|
34
|
-
deps.io.stdout(
|
|
36
|
+
if (!revoked) {
|
|
37
|
+
deps.io.stdout(`Removed local credentials, but the server did not confirm revocation. ${REVOKE_BY_HAND}\n`);
|
|
35
38
|
return EXIT_UNEXPECTED;
|
|
36
39
|
}
|
|
37
40
|
deps.io.stdout("Disconnected.\n");
|
|
38
41
|
return EXIT_OK;
|
|
39
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Revokes every saved token at its own origin, then deletes every file the
|
|
45
|
+
* CLI keeps (credentials, pending GitHub login, pending Link payment). Link's
|
|
46
|
+
* own session and files are link-cli's; `link-cli auth logout` clears those.
|
|
47
|
+
*/
|
|
48
|
+
async function runLogoutAll(deps) {
|
|
49
|
+
const failed = [];
|
|
50
|
+
for (const [origin, creds] of Object.entries(readCredentialsFile(deps).origins)) {
|
|
51
|
+
if (creds?.token && !(await revoke(deps, origin, creds.token)))
|
|
52
|
+
failed.push(origin);
|
|
53
|
+
}
|
|
54
|
+
deleteAllLocalState(deps);
|
|
55
|
+
const envNote = deps.env.get("CLEANSLOP_TOKEN")?.trim()
|
|
56
|
+
? " CLEANSLOP_TOKEN is still set in this environment; unset it too."
|
|
57
|
+
: "";
|
|
58
|
+
if (failed.length > 0) {
|
|
59
|
+
deps.io.stdout(`Removed all local CleanSlop data, but ${failed.join(", ")} did not confirm revocation. ${REVOKE_BY_HAND}${envNote}\n`);
|
|
60
|
+
return EXIT_UNEXPECTED;
|
|
61
|
+
}
|
|
62
|
+
deps.io.stdout(`Disconnected everywhere and removed all local CleanSlop data.${envNote}\n`);
|
|
63
|
+
return EXIT_OK;
|
|
64
|
+
}
|
|
40
65
|
//# sourceMappingURL=logout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[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CAAC,MAAM,CAAC,CAAC;IACtF,CAAC;IACD,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE;QACrD,CAAC,CAAC,kEAAkE;QACpE,CAAC,CAAC,EAAE,CAAC;IACP,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,IAAI,CAAC,EAAE,CAAC,MAAM,CACZ,yCAAyC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gCAAgC,cAAc,GAAG,OAAO,IAAI,CACvH,CAAC;QACF,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,gEAAgE,OAAO,IAAI,CAAC,CAAC;IAC5F,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CliDeps } from "../deps.js";
|
|
2
|
+
import type { ParsedArgs } from "../types.js";
|
|
3
|
+
/** The CLI's plan ids. The server's plan id for Max is `team`; it accepts `max`. */
|
|
4
|
+
export type CliPlanId = "starter" | "pro" | "max";
|
|
5
|
+
export type PlanOffer = {
|
|
6
|
+
plan: CliPlanId;
|
|
7
|
+
name: string;
|
|
8
|
+
amount: number;
|
|
9
|
+
currency: string;
|
|
10
|
+
networkId: string;
|
|
11
|
+
purchaseUrl: string;
|
|
12
|
+
};
|
|
13
|
+
/** `max`, and `team` as an alias for it; anything else is null. */
|
|
14
|
+
export declare function parsePlanId(raw: string | null): CliPlanId | null;
|
|
15
|
+
/** Monthly plans in an offers or 402 body (`payment.plans`), in server order. */
|
|
16
|
+
export declare function planOffersFromBody(json: unknown): PlanOffer[];
|
|
17
|
+
type CurrentPlan = {
|
|
18
|
+
name: string;
|
|
19
|
+
status: "active" | "pending";
|
|
20
|
+
};
|
|
21
|
+
/** `payment.currentPlan`: the account already has a plan, or one is being set up. */
|
|
22
|
+
export declare function currentPlanFromBody(json: unknown): CurrentPlan | null;
|
|
23
|
+
/**
|
|
24
|
+
* `cleanslop plan [starter|pro|max]`: start a monthly plan paid each month
|
|
25
|
+
* from a recurring Link spend request. Same approval modes as `credits buy
|
|
26
|
+
* --link` (wait, `--no-wait`, `--resume`). When the server lists no plans,
|
|
27
|
+
* the plan lives on the website: same as `cleanslop billing`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function runPlan(deps: CliDeps, args: ParsedArgs): Promise<number>;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { writeAction } from "../action.js";
|
|
2
|
+
import { asRecord, httpRequest, requireOk, throwHttpError } from "../http.js";
|
|
3
|
+
import { createLinkSpendRequest, ensureLinkPaymentScope, grantLinkPayments, linkAuthMode, linkPaymentStep, linkSpendRequestTestMode, retrieveSharedPaymentToken, } from "../link.js";
|
|
4
|
+
import { deletePendingSpend, readPendingSpend, requireToken, resolveOrigin, writePendingSpend, } from "../credentials.js";
|
|
5
|
+
import { actionError, CliError, EXIT_OK, EXIT_PAYMENT, usageError, } from "../exit.js";
|
|
6
|
+
import { BILLING_COMMAND, NOT_NOW, PLAN_COMMAND } from "../top-up.js";
|
|
7
|
+
import { runBilling } from "./billing.js";
|
|
8
|
+
import { approvalNote, approvalPromptTail, formatPackPrice, IN_LINK_APP, LINK_APPROVAL_WAIT_MS, LINK_RESUME_WAIT_MS, paymentApprovalQuestion, pollUntilApproved, reportSpendRequest, tokenMissingAction, } from "./credits.js";
|
|
9
|
+
const PLAN_NAMES = {
|
|
10
|
+
starter: "Starter",
|
|
11
|
+
pro: "Pro",
|
|
12
|
+
max: "Max",
|
|
13
|
+
};
|
|
14
|
+
/** `max`, and `team` as an alias for it; anything else is null. */
|
|
15
|
+
export function parsePlanId(raw) {
|
|
16
|
+
const value = raw?.trim().toLowerCase();
|
|
17
|
+
if (value === "team")
|
|
18
|
+
return "max";
|
|
19
|
+
return value === "starter" || value === "pro" || value === "max" ? value : null;
|
|
20
|
+
}
|
|
21
|
+
function asPlanOffer(value) {
|
|
22
|
+
const rec = asRecord(value);
|
|
23
|
+
const plan = parsePlanId(typeof rec?.plan === "string" ? rec.plan : null);
|
|
24
|
+
if (!rec || !plan)
|
|
25
|
+
return null;
|
|
26
|
+
const amount = typeof rec.amount === "number" ? rec.amount : Number(rec.amount);
|
|
27
|
+
if (!Number.isInteger(amount) || amount < 1)
|
|
28
|
+
return null;
|
|
29
|
+
const networkId = typeof rec.networkId === "string" ? rec.networkId.trim() : "";
|
|
30
|
+
const purchaseUrl = typeof rec.purchaseUrl === "string" ? rec.purchaseUrl.trim() : "";
|
|
31
|
+
if (!networkId || !purchaseUrl)
|
|
32
|
+
return null;
|
|
33
|
+
return {
|
|
34
|
+
plan,
|
|
35
|
+
name: typeof rec.name === "string" && rec.name.trim() ? rec.name.trim() : PLAN_NAMES[plan],
|
|
36
|
+
amount,
|
|
37
|
+
currency: typeof rec.currency === "string" && rec.currency.trim() ? rec.currency.trim() : "usd",
|
|
38
|
+
networkId,
|
|
39
|
+
purchaseUrl,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Monthly plans in an offers or 402 body (`payment.plans`), in server order. */
|
|
43
|
+
export function planOffersFromBody(json) {
|
|
44
|
+
const plans = asRecord(asRecord(json)?.payment)?.plans;
|
|
45
|
+
return (Array.isArray(plans) ? plans : [])
|
|
46
|
+
.map(asPlanOffer)
|
|
47
|
+
.filter((offer) => offer != null);
|
|
48
|
+
}
|
|
49
|
+
function monthlyPrice(amount, currency) {
|
|
50
|
+
return `${formatPackPrice(amount, currency)} per month`;
|
|
51
|
+
}
|
|
52
|
+
/** `Pro (49.00 USD per month)`. */
|
|
53
|
+
function describePlan(offer) {
|
|
54
|
+
return `${offer.name} (${monthlyPrice(offer.amount, offer.currency)})`;
|
|
55
|
+
}
|
|
56
|
+
function startCommand(plan) {
|
|
57
|
+
return `${PLAN_COMMAND} ${plan} --no-wait`;
|
|
58
|
+
}
|
|
59
|
+
function spendRequestContext(offer) {
|
|
60
|
+
return `CleanSlop ${offer.name} plan, ${monthlyPrice(offer.amount, offer.currency)}. Approve this recurring Shared Payment Token so your coding agent can start a monthly CleanSlop plan. CleanSlop charges it once a month until you cancel the plan with \`${BILLING_COMMAND}\`.`;
|
|
61
|
+
}
|
|
62
|
+
function planFlow(plan) {
|
|
63
|
+
const name = PLAN_NAMES[parsePlanId(plan) ?? "starter"];
|
|
64
|
+
return {
|
|
65
|
+
kind: "plan",
|
|
66
|
+
command: PLAN_COMMAND,
|
|
67
|
+
what: `CleanSlop ${name} plan`,
|
|
68
|
+
restart: (status) => ({
|
|
69
|
+
humanPrompt: `The Link approval was ${status}. Ask the person whether to try again; if yes, run \`${startCommand(plan)}\` for a new spend request.`,
|
|
70
|
+
question: {
|
|
71
|
+
id: "link_plan_retry",
|
|
72
|
+
header: "Plan",
|
|
73
|
+
question: `The Link approval for the ${name} plan was ${status}. Try again?`,
|
|
74
|
+
options: [{ value: plan, label: "Try again", run: startCommand(plan) }, NOT_NOW],
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Every plan plus "Not now": exactly four options. */
|
|
80
|
+
function planQuestion(offers, note) {
|
|
81
|
+
return {
|
|
82
|
+
id: "link_plan",
|
|
83
|
+
header: "Plan",
|
|
84
|
+
question: `Which monthly CleanSlop plan should I start with Link? ${note}`,
|
|
85
|
+
options: [
|
|
86
|
+
...offers.map((offer) => ({
|
|
87
|
+
value: offer.plan,
|
|
88
|
+
label: `${offer.name} · ${monthlyPrice(offer.amount, offer.currency)}`,
|
|
89
|
+
run: startCommand(offer.plan),
|
|
90
|
+
})),
|
|
91
|
+
NOT_NOW,
|
|
92
|
+
],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const PLAN_APPROVAL_NOTE = "Link charges it each month until you cancel the plan with `cleanslop billing`.";
|
|
96
|
+
/** `payment.currentPlan`: the account already has a plan, or one is being set up. */
|
|
97
|
+
export function currentPlanFromBody(json) {
|
|
98
|
+
const rec = asRecord(asRecord(asRecord(json)?.payment)?.currentPlan);
|
|
99
|
+
if (!rec)
|
|
100
|
+
return null;
|
|
101
|
+
return {
|
|
102
|
+
name: typeof rec.name === "string" && rec.name.trim() ? rec.name.trim() : "monthly",
|
|
103
|
+
status: rec.status === "pending" ? "pending" : "active",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** Stops before any spend request: the server would refuse a second plan. */
|
|
107
|
+
function currentPlanError(current, approval) {
|
|
108
|
+
if (current.status === "pending") {
|
|
109
|
+
return actionError("A monthly plan is already being set up.", {
|
|
110
|
+
kind: "wait",
|
|
111
|
+
humanPrompt: `A CleanSlop ${current.name} plan is already being set up for this account, so ${approval}. Check again in a few minutes with \`cleanslop whoami\`; do not start another plan.`,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return actionError("This account already has a monthly plan.", {
|
|
115
|
+
kind: "ask_human",
|
|
116
|
+
humanPrompt: `This account already has the CleanSlop ${current.name} plan, so ${approval}. To change or cancel it, run \`${BILLING_COMMAND}\` and relay what it prints.`,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/** Reads plan offers; none means Link plans are off and the plan lives on the website. */
|
|
120
|
+
async function choosePlan(deps, origin, token, args) {
|
|
121
|
+
const wanted = parsePlanId(args.id);
|
|
122
|
+
if (args.id && !wanted)
|
|
123
|
+
throw usageError("Usage: cleanslop plan [starter|pro|max]");
|
|
124
|
+
const result = await httpRequest(deps, origin, "GET", "/api/agent/v1/credits/offers", { token });
|
|
125
|
+
requireOk(result);
|
|
126
|
+
const current = currentPlanFromBody(result.json);
|
|
127
|
+
if (current)
|
|
128
|
+
throw currentPlanError(current, "no Link approval was requested");
|
|
129
|
+
const offers = planOffersFromBody(result.json);
|
|
130
|
+
if (offers.length === 0)
|
|
131
|
+
return null;
|
|
132
|
+
const offer = offers.find((o) => o.plan === wanted);
|
|
133
|
+
if (offer)
|
|
134
|
+
return offer;
|
|
135
|
+
const step = await linkPaymentStep(deps);
|
|
136
|
+
const list = new Intl.ListFormat("en", { type: "disjunction" }).format(offers.map(describePlan));
|
|
137
|
+
throw actionError("Choose a monthly plan.", {
|
|
138
|
+
kind: "ask_human",
|
|
139
|
+
humanPrompt: `Ask the human which monthly CleanSlop plan to start with Link: ${list}. ${PLAN_APPROVAL_NOTE} If they pick one, run \`${PLAN_COMMAND} <plan> --no-wait\`, relay its approval prompt (Link notifies their Link app; there is usually no link), and after they approve run \`${PLAN_COMMAND} --resume\`.${approvalPromptTail(step)}`,
|
|
140
|
+
question: planQuestion(offers, `${PLAN_APPROVAL_NOTE} ${approvalNote(step)}`),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/** POSTs the approved token. Keeps the saved request only while the server says to retry it. */
|
|
144
|
+
async function postPlan(deps, pending, token, sharedPaymentToken) {
|
|
145
|
+
const result = await httpRequest(deps, pending.origin, "POST", "/api/agent/v1/plans/purchases", {
|
|
146
|
+
token,
|
|
147
|
+
body: { plan: pending.pack, sharedPaymentToken, spendRequestId: pending.spendRequestId },
|
|
148
|
+
});
|
|
149
|
+
const body = asRecord(result.json);
|
|
150
|
+
const reason = typeof body?.reason === "string" ? body.reason : null;
|
|
151
|
+
if (result.status >= 200 && result.status < 300) {
|
|
152
|
+
deletePendingSpend(deps, "plan");
|
|
153
|
+
return {
|
|
154
|
+
name: typeof body?.name === "string" ? body.name : PLAN_NAMES[parsePlanId(pending.pack) ?? "starter"],
|
|
155
|
+
status: typeof body?.status === "string" ? body.status : "active",
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (result.status === 404) {
|
|
159
|
+
deletePendingSpend(deps, "plan");
|
|
160
|
+
return "plans_off";
|
|
161
|
+
}
|
|
162
|
+
if (reason === "pending") {
|
|
163
|
+
throw actionError("The plan payment is still processing.", {
|
|
164
|
+
kind: "wait",
|
|
165
|
+
humanPrompt: `Link approved the plan and CleanSlop is still charging it. Run \`${PLAN_COMMAND} --resume\` in a minute — do not create a new spend request.`,
|
|
166
|
+
code: pending.spendRequestId,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
deletePendingSpend(deps, "plan");
|
|
170
|
+
if (reason === "subscription_exists" || reason === "plan_in_progress") {
|
|
171
|
+
const plan = typeof body?.plan === "string" ? parsePlanId(body.plan) : null;
|
|
172
|
+
throw currentPlanError({ name: plan ? PLAN_NAMES[plan] : "monthly", status: reason === "plan_in_progress" ? "pending" : "active" }, "the Link approval was not used and nothing was charged");
|
|
173
|
+
}
|
|
174
|
+
if (result.status === 402) {
|
|
175
|
+
const plan = parsePlanId(pending.pack) ?? "starter";
|
|
176
|
+
throw new CliError(`The Link payment for the plan failed (${reason ?? "payment_failed"}).`, EXIT_PAYMENT, {
|
|
177
|
+
kind: "ask_human",
|
|
178
|
+
humanPrompt: `Link could not pay for the ${PLAN_NAMES[plan]} plan (${reason ?? "payment_failed"}), so no plan was started. Ask the person whether to try again with \`${startCommand(plan)}\`, or to subscribe on the website with \`${BILLING_COMMAND}\`.`,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
throwHttpError(result);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* `cleanslop plan [starter|pro|max]`: start a monthly plan paid each month
|
|
185
|
+
* from a recurring Link spend request. Same approval modes as `credits buy
|
|
186
|
+
* --link` (wait, `--no-wait`, `--resume`). When the server lists no plans,
|
|
187
|
+
* the plan lives on the website: same as `cleanslop billing`.
|
|
188
|
+
*/
|
|
189
|
+
export async function runPlan(deps, args) {
|
|
190
|
+
const mode = linkAuthMode(args);
|
|
191
|
+
const origin = resolveOrigin(deps);
|
|
192
|
+
const stored = requireToken(deps, origin);
|
|
193
|
+
const saved = readPendingSpend(deps, "plan");
|
|
194
|
+
let pending = saved && saved.origin === origin ? saved : null;
|
|
195
|
+
// A different plan replaces the saved request; it is only an approval, never a charge.
|
|
196
|
+
if (pending && args.id && parsePlanId(args.id) !== parsePlanId(pending.pack)) {
|
|
197
|
+
deletePendingSpend(deps, "plan");
|
|
198
|
+
pending = null;
|
|
199
|
+
}
|
|
200
|
+
if (args.resume && !pending) {
|
|
201
|
+
throw usageError(`No Link plan approval to resume. Run \`${PLAN_COMMAND} <starter|pro|max> --no-wait\`.`);
|
|
202
|
+
}
|
|
203
|
+
if (pending) {
|
|
204
|
+
await ensureLinkPaymentScope(deps, { mode, command: PLAN_COMMAND });
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
const offer = await choosePlan(deps, origin, stored.token, args);
|
|
208
|
+
if (!offer)
|
|
209
|
+
return runBilling(deps, args);
|
|
210
|
+
const networkId = args.networkId?.trim() || deps.env.get("CLEANSLOP_STRIPE_PROFILE_ID")?.trim() || offer.networkId;
|
|
211
|
+
const testMode = linkSpendRequestTestMode(deps, networkId);
|
|
212
|
+
await ensureLinkPaymentScope(deps, { mode, command: `${PLAN_COMMAND} ${offer.plan}` });
|
|
213
|
+
const created = await createLinkSpendRequest(deps, {
|
|
214
|
+
networkId,
|
|
215
|
+
amount: offer.amount,
|
|
216
|
+
currency: offer.currency,
|
|
217
|
+
context: spendRequestContext(offer),
|
|
218
|
+
lineItem: `name:CleanSlop ${offer.name} plan (monthly),unit_amount:${offer.amount},quantity:1`,
|
|
219
|
+
total: `type:total,display_text:Total per month,amount:${offer.amount}`,
|
|
220
|
+
idempotencyKey: deps.randomId(),
|
|
221
|
+
testMode,
|
|
222
|
+
recurringInterval: "month",
|
|
223
|
+
});
|
|
224
|
+
pending = {
|
|
225
|
+
version: 1,
|
|
226
|
+
origin,
|
|
227
|
+
spendRequestId: created.id,
|
|
228
|
+
pack: offer.plan,
|
|
229
|
+
amount: offer.amount,
|
|
230
|
+
currency: offer.currency,
|
|
231
|
+
networkId,
|
|
232
|
+
purchaseUrl: offer.purchaseUrl,
|
|
233
|
+
createdAt: deps.clock.now(),
|
|
234
|
+
...(created.approvalUrl ? { approvalUrl: created.approvalUrl } : {}),
|
|
235
|
+
testMode,
|
|
236
|
+
};
|
|
237
|
+
await writePendingSpend(deps, pending, "plan");
|
|
238
|
+
await reportSpendRequest(deps, stored.token, pending, "created", "plan");
|
|
239
|
+
const what = `the CleanSlop ${offer.name} plan (${monthlyPrice(offer.amount, offer.currency)}, charged each month until they cancel with \`${BILLING_COMMAND}\`)`;
|
|
240
|
+
const ask = created.approvalUrl
|
|
241
|
+
? `Ask the human to open this link and approve ${what}. Link may also send a notification.`
|
|
242
|
+
: `Ask the human to approve ${what} ${IN_LINK_APP}.`;
|
|
243
|
+
const url = created.approvalUrl ? { url: created.approvalUrl } : {};
|
|
244
|
+
if (mode !== "wait") {
|
|
245
|
+
throw actionError("Link plan approval pending.", {
|
|
246
|
+
kind: "approve",
|
|
247
|
+
humanPrompt: `${ask} After they approve, run \`${PLAN_COMMAND} --resume\`.`,
|
|
248
|
+
...url,
|
|
249
|
+
question: paymentApprovalQuestion(`the CleanSlop ${offer.name} plan (${monthlyPrice(offer.amount, offer.currency)})`, created.approvalUrl, PLAN_COMMAND),
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
writeAction(deps, { kind: "approve", humanPrompt: `${ask} Waiting for approval.`, ...url });
|
|
253
|
+
}
|
|
254
|
+
let regranted = false;
|
|
255
|
+
const onMissingScope = async () => {
|
|
256
|
+
if (regranted)
|
|
257
|
+
return false;
|
|
258
|
+
regranted = true;
|
|
259
|
+
await grantLinkPayments(deps, { mode, command: PLAN_COMMAND });
|
|
260
|
+
return true;
|
|
261
|
+
};
|
|
262
|
+
const waitMs = mode === "no-wait" ? 0 : mode === "resume" ? LINK_RESUME_WAIT_MS : LINK_APPROVAL_WAIT_MS;
|
|
263
|
+
await pollUntilApproved(deps, stored.token, pending, waitMs, onMissingScope, planFlow(pending.pack));
|
|
264
|
+
const sharedPaymentToken = await retrieveSharedPaymentToken(deps, pending.spendRequestId, {
|
|
265
|
+
testMode: pending.testMode,
|
|
266
|
+
onMissingScope,
|
|
267
|
+
});
|
|
268
|
+
if (!sharedPaymentToken) {
|
|
269
|
+
await reportSpendRequest(deps, stored.token, pending, "token_missing", "plan");
|
|
270
|
+
tokenMissingAction(pending.spendRequestId, PLAN_COMMAND);
|
|
271
|
+
}
|
|
272
|
+
const started = await postPlan(deps, pending, stored.token, sharedPaymentToken);
|
|
273
|
+
if (started === "plans_off")
|
|
274
|
+
return runBilling(deps, args);
|
|
275
|
+
deps.io.stdout(`Started the CleanSlop ${started.name} plan (${started.status}). Change or cancel it with \`${BILLING_COMMAND}\`.\n`);
|
|
276
|
+
return EXIT_OK;
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=plan.js.map
|