@cleanslop/cli 0.1.0-beta.27 → 0.1.0-beta.28

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.
@@ -38,7 +38,7 @@ Run purchase commands in the foreground with `--no-wait`, the same way as Link s
38
38
  4. On success it prints “Added … scan credits. Balance: N”. Rerun the scan.
39
39
  5. If the CLI says Link packs are not available or to contact us for credits, tell the human and stop. For a GitHub account, the `top-up` block is a checkout link instead: relay it and wait.
40
40
  6. Promo codes: if the human gives you a CleanSlop promo code, run `cleanslop redeem <code>` (MCP: `promo_redeem`). Use only a code the human typed in this session; never guess, search for, or reuse one. Each account can use one code; if the CLI says the code is not valid or already used, tell the human and stop. While the account has not used a code, the out-of-scans and `credits buy` questions also offer "Use a promo code"; if the human picks buying instead, run the command that answer gives.
41
- 7. Monthly plans (Link accounts): run `cleanslop billing` when the human picks Monthly plan or asks to subscribe, buy credits on the web or cancel a plan. Out-of-scans blocks and `whoami` name it, but do not run it unasked: it emails the human a sign-in link. It prints where the mail went (a masked email), plus a web address to use if the mail does not arrive, and exits 10: relay it exactly. The human signs in from the mail. Never open the page, never type the address, never ask for the sign-in link.
41
+ 7. Monthly plans (Link accounts): run `cleanslop billing` when the human picks Monthly plan or asks to subscribe, buy credits on the web or cancel a plan. Out-of-scans blocks and `whoami` name it, but do not run it unasked: it emails the human a sign-in link. It prints where the mail went (a masked email), plus a web address to use if the mail does not arrive, and exits 10: relay it exactly, then ask its question (done on the website, buy with Link instead, or not now). The human signs in from the mail. Never open the page, never type the address, never ask for the sign-in link.
42
42
 
43
43
  ## Relay human actions
44
44
 
@@ -1,6 +1,7 @@
1
1
  import { requireToken, resolveOrigin } from "../credentials.js";
2
2
  import { actionError, EXIT_OK } from "../exit.js";
3
3
  import { httpRequest, requireOk } from "../http.js";
4
+ import { stripeSptOffersFromErrorBody } from "./credits.js";
4
5
  import { writeJson } from "../output.js";
5
6
  function webBillingFrom(raw) {
6
7
  return raw?.url && raw.emailMasked ? { url: raw.url, emailMasked: raw.emailMasked } : null;
@@ -39,7 +40,53 @@ export async function runBilling(deps, args) {
39
40
  : body.reason === "rate_limited"
40
41
  ? `Sign-in links already went to ${emailMasked} in the last 15 minutes. Open the newest one to subscribe, buy credits or cancel your plan.`
41
42
  : typedAddressPrompt(webBilling);
42
- throw actionError("", { kind: "ask_human", humanPrompt, url });
43
+ const question = await doneOnWebQuestion(deps, origin, creds.token, sent
44
+ ? `Open the sign-in link we emailed to ${emailMasked} and finish on the CleanSlop website. Done?`
45
+ : body.reason === "rate_limited"
46
+ ? `Open the newest sign-in link sent to ${emailMasked} and finish on the CleanSlop website. Done?`
47
+ : typedAddressQuestion(webBilling));
48
+ throw actionError("", { kind: "ask_human", humanPrompt, url, question });
49
+ }
50
+ function typedAddressQuestion({ url, emailMasked }) {
51
+ return `Go to ${url}, enter ${emailMasked}, sign in from the email and finish on the CleanSlop website. Done?`;
52
+ }
53
+ /**
54
+ * Done on the web, buy a Link pack here instead (only when Link packs are on
55
+ * offer), or stop. A failed offers check just leaves the Link answer out.
56
+ */
57
+ async function doneOnWebQuestion(deps, origin, token, question) {
58
+ let offersLinkPacks = false;
59
+ try {
60
+ const offers = await httpRequest(deps, origin, "GET", "/api/agent/v1/credits/offers", { token });
61
+ offersLinkPacks = offers.status === 200 && stripeSptOffersFromErrorBody(offers.json).length > 0;
62
+ }
63
+ catch {
64
+ offersLinkPacks = false;
65
+ }
66
+ return {
67
+ id: "web_billing",
68
+ header: "Billing",
69
+ question,
70
+ options: [
71
+ {
72
+ value: "done",
73
+ label: "Done",
74
+ description: "Finished on the website",
75
+ next: "rerun the scan that ran out of scans, if any; otherwise run `cleanslop whoami` to show the plan",
76
+ },
77
+ ...(offersLinkPacks
78
+ ? [
79
+ {
80
+ value: "link",
81
+ label: "Buy with Link instead",
82
+ description: "Buy a credit pack here",
83
+ run: "cleanslop credits buy --link --no-wait",
84
+ },
85
+ ]
86
+ : []),
87
+ { value: "stop", label: "Not now", description: "Stop here" },
88
+ ],
89
+ };
43
90
  }
44
91
  async function typedAddress(deps, args, origin, token) {
45
92
  const result = await httpRequest(deps, origin, "GET", "/api/agent/v1/me", { token });
@@ -53,6 +100,7 @@ async function typedAddress(deps, args, origin, token) {
53
100
  kind: "ask_human",
54
101
  humanPrompt: typedAddressPrompt(webBilling),
55
102
  url: webBilling.url,
103
+ question: await doneOnWebQuestion(deps, origin, token, typedAddressQuestion(webBilling)),
56
104
  });
57
105
  }
58
106
  function notAvailable(deps, args) {
@@ -1 +1 @@
1
- {"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/commands/billing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAYzC,SAAS,cAAc,CACrB,GAA8D;IAE9D,OAAO,GAAG,EAAE,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7F,CAAC;AAED,SAAS,kBAAkB,CAAC,EAAE,GAAG,EAAE,WAAW,EAAc;IAC1D,OAAO,wDAAwD,GAAG,cAAc,WAAW,uCAAuC,CAAC;AACrI,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAAa,EACb,IAAgB;IAEhB,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,MAAM,WAAW,CAC9B,IAAI,EACJ,M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,IAAI,IAAI,CAAC,IAAI;QAAE,SAAS,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1E,MAAM,WAAW,CAAC,EAAE,EAAE;QACpB,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,kBAAkB,CAAC,UAAU,CAAC;QAC3C,GAAG,EAAE,UAAU,CAAC,GAAG;QACnB,QAAQ,EAAE,MAAM,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,CAAC;KACzF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,YAAY,CAAC,IAAa,EAAE,IAAgB;IACnD,IAAI,IAAI,CAAC,IAAI;QAAE,SAAS,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;;QAChD,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC;IACzD,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/dist/config.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export declare const PACKAGE_NAME = "@cleanslop/cli";
2
- export declare const PACKAGE_VERSION = "0.1.0-beta.27";
2
+ export declare const PACKAGE_VERSION = "0.1.0-beta.28";
3
3
  export declare const CLIENT_ID = "cleanslop-cli";
4
4
  export declare const DEFAULT_ORIGIN = "https://cleanslop.com";
5
5
  export declare const DEFAULT_WAIT_MS: number;
6
6
  export declare const MIN_POLL_MS = 3000;
7
7
  export declare const LONGPOLL_MAX_SEC = 45;
8
8
  export declare const DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
9
- export declare const USER_AGENT = "cleanslop-cli/0.1.0-beta.27";
9
+ export declare const USER_AGENT = "cleanslop-cli/0.1.0-beta.28";
10
10
  export declare const CREDENTIALS_FILE = "credentials.json";
11
11
  export declare const PENDING_LOGIN_FILE = "pending-login.json";
12
12
  export declare const PENDING_SPEND_FILE = "pending-spend-request.json";
package/dist/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export const PACKAGE_NAME = "@cleanslop/cli";
2
- export const PACKAGE_VERSION = "0.1.0-beta.27";
2
+ export const PACKAGE_VERSION = "0.1.0-beta.28";
3
3
  export const CLIENT_ID = "cleanslop-cli";
4
4
  export const DEFAULT_ORIGIN = "https://cleanslop.com";
5
5
  export const DEFAULT_WAIT_MS = 8 * 60 * 1000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleanslop/cli",
3
- "version": "0.1.0-beta.27",
3
+ "version": "0.1.0-beta.28",
4
4
  "description": "CleanSlop CLI — readiness scans from your coding agent",
5
5
  "type": "module",
6
6
  "bin": {