@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.
Files changed (84) hide show
  1. package/README.md +8 -5
  2. package/assets/skill-core.md +24 -14
  3. package/dist/action.d.ts +4 -1
  4. package/dist/action.js +24 -0
  5. package/dist/action.js.map +1 -1
  6. package/dist/args.d.ts +1 -1
  7. package/dist/args.js +45 -11
  8. package/dist/args.js.map +1 -1
  9. package/dist/commands/billing.d.ts +9 -0
  10. package/dist/commands/billing.js +113 -0
  11. package/dist/commands/billing.js.map +1 -0
  12. package/dist/commands/credits.d.ts +43 -0
  13. package/dist/commands/credits.js +268 -24
  14. package/dist/commands/credits.js.map +1 -1
  15. package/dist/commands/email.js +22 -0
  16. package/dist/commands/email.js.map +1 -1
  17. package/dist/commands/link-identity.js +5 -3
  18. package/dist/commands/link-identity.js.map +1 -1
  19. package/dist/commands/link-login.js +34 -11
  20. package/dist/commands/link-login.js.map +1 -1
  21. package/dist/commands/login.d.ts +1 -0
  22. package/dist/commands/login.js +25 -22
  23. package/dist/commands/login.js.map +1 -1
  24. package/dist/commands/logout.d.ts +2 -1
  25. package/dist/commands/logout.js +48 -23
  26. package/dist/commands/logout.js.map +1 -1
  27. package/dist/commands/plan.d.ts +30 -0
  28. package/dist/commands/plan.js +278 -0
  29. package/dist/commands/plan.js.map +1 -0
  30. package/dist/commands/redeem.d.ts +7 -0
  31. package/dist/commands/redeem.js +33 -0
  32. package/dist/commands/redeem.js.map +1 -0
  33. package/dist/commands/report.js +10 -3
  34. package/dist/commands/report.js.map +1 -1
  35. package/dist/commands/scan-upload.js +51 -29
  36. package/dist/commands/scan-upload.js.map +1 -1
  37. package/dist/commands/scan.js +49 -7
  38. package/dist/commands/scan.js.map +1 -1
  39. package/dist/commands/whoami.js +27 -0
  40. package/dist/commands/whoami.js.map +1 -1
  41. package/dist/config.d.ts +6 -3
  42. package/dist/config.js +5 -2
  43. package/dist/config.js.map +1 -1
  44. package/dist/connect.d.ts +21 -0
  45. package/dist/connect.js +109 -0
  46. package/dist/connect.js.map +1 -0
  47. package/dist/credentials.d.ts +18 -4
  48. package/dist/credentials.js +41 -16
  49. package/dist/credentials.js.map +1 -1
  50. package/dist/done-question.d.ts +20 -0
  51. package/dist/done-question.js +25 -0
  52. package/dist/done-question.js.map +1 -0
  53. package/dist/exit.d.ts +29 -0
  54. package/dist/exit.js +12 -0
  55. package/dist/exit.js.map +1 -1
  56. package/dist/git.d.ts +19 -1
  57. package/dist/git.js +48 -1
  58. package/dist/git.js.map +1 -1
  59. package/dist/http.js +86 -4
  60. package/dist/http.js.map +1 -1
  61. package/dist/link.d.ts +67 -18
  62. package/dist/link.js +183 -73
  63. package/dist/link.js.map +1 -1
  64. package/dist/main.js +14 -3
  65. package/dist/main.js.map +1 -1
  66. package/dist/output.js +6 -1
  67. package/dist/output.js.map +1 -1
  68. package/dist/pack.d.ts +20 -3
  69. package/dist/pack.js +40 -3
  70. package/dist/pack.js.map +1 -1
  71. package/dist/report-question.d.ts +12 -0
  72. package/dist/report-question.js +143 -0
  73. package/dist/report-question.js.map +1 -0
  74. package/dist/skill.d.ts +1 -1
  75. package/dist/skill.js +1 -1
  76. package/dist/skill.js.map +1 -1
  77. package/dist/token-rotation.d.ts +11 -0
  78. package/dist/token-rotation.js +35 -0
  79. package/dist/token-rotation.js.map +1 -0
  80. package/dist/top-up.d.ts +27 -0
  81. package/dist/top-up.js +88 -0
  82. package/dist/top-up.js.map +1 -0
  83. package/dist/types.d.ts +27 -1
  84. package/package.json +1 -1
package/README.md CHANGED
@@ -6,13 +6,13 @@ Private-beta CLI for agentic CleanSlop, published as `@cleanslop/cli` (bin `clea
6
6
 
7
7
  ```bash
8
8
  # published beta (pass the origin /agents gives you):
9
- CLEANSLOP_ORIGIN=<origin> npx @cleanslop/cli@beta scan
9
+ CLEANSLOP_ORIGIN=<origin> npx -y @cleanslop/cli@beta scan
10
10
 
11
11
  # from this repo after build:
12
12
  node cli/dist/index.js scan
13
13
  ```
14
14
 
15
- Requires Node 20 or later. **Zero runtime dependencies.** Link commands shell out to `link-cli` (`CLEANSLOP_LINK_CLI`, else `PATH`, else a pinned `npx @stripe/link-cli`); uploads pack with system `tar`.
15
+ Requires Node 20 or later. **Zero runtime dependencies.** Link commands shell out to `link-cli` (`CLEANSLOP_LINK_CLI`, else `PATH`, else a pinned `npx @stripe/link-cli`); uploads pack with a built-in tar writer.
16
16
 
17
17
  ## Gate (run locally and in CI)
18
18
 
@@ -30,11 +30,14 @@ The app TypeScript / ESLint / coverage gates exclude `cli/` (`tsconfig.json`, `t
30
30
  |---|---|
31
31
  | `scan` (default) | Resolve the github.com origin + HEAD, start a scan, optionally `--wait` |
32
32
  | `login [--no-wait \| --resume]` | RFC 8628 device flow. Prints `verification_uri_complete` and `user_code`. `--no-wait` stores the device code; `--resume` finishes it. Never prints the token. |
33
- | `logout` | Revoke server-side and delete local credentials |
33
+ | `logout [--all]` | Revoke server-side, delete this origin's credentials, and drop its pending GitHub login and Link payment. `--all` revokes every saved origin's token and deletes all local CleanSlop data (Link's own session and `~/.link-cli` files stay; `link-cli auth logout` clears the session) |
34
34
  | `whoami` | Connected `@login` and token last4 |
35
35
  | `status [id] [--wait]` | Poll scan status |
36
- | `report [id] [--format md\|json] [--preview]` | Fetch `cleanslop.report.v1` |
36
+ | `report [id] [--format md\|json] [--preview]` | Fetch `cleanslop.report.v1` (the whole list: `limit=250`). A final Markdown report with confirmed or needs-input findings is followed on stderr by a `fix_findings` question (Fix them / Show me first / Not now); `scan` does the same. Exit stays 0. |
37
37
  | `setup` | Idempotent skill/rules. Never logs in, never writes a token |
38
+ | `redeem <code>` | Redeem a promo (invite) code the human gave you for free scans (`POST /api/agent/v1/credits/redeem`). One code per account; `promo_invalid` / `promo_already_redeemed` exit 12 with an `ask_human` block. |
39
+ | `billing` | Link account: `POST /api/agent/v1/billing/sign-in-link` has the server email a sign-in link to the account's Link address, where the human subscribes, buys credits or cancels a plan. Prints the masked address it went to, plus `/signin/email?from=agent` and the masked email to type if it does not arrive. When the server cannot send (email login off, rate limited) or is older (404, read `webBilling` from `GET /me`), it prints only the typed-address page. The CLI never sees the link. Exits 10 with an `ask_human` block; `--json` prints `{sent, expiresAt \| reason, webBilling}`. Prints "Not available for this account" (exit 0) without `webBilling`. |
40
+ | `plan [starter\|pro\|max]` | Link account: starts a monthly plan paid each month from a recurring Link approval (`link-cli spend-request create --recurring-interval month`), then `POST /api/agent/v1/plans/purchases`. Without a plan name an agent gets a `link_plan` question (Starter, Pro, Max with monthly prices, Not now). Same `--no-wait` / `--resume` flow as `credits buy --link`, saved in its own `pending-plan-request.json`. When CleanSlop offers no Link plans it does what `billing` does. Prints "Started the CleanSlop … plan" (exit 0). Change or cancel the plan with `billing`. |
38
41
 
39
42
  ### Wait
40
43
 
@@ -80,7 +83,7 @@ Skill / Cursor rules / AGENTS snippet are generated from [`assets/skill-core.md`
80
83
  | 20 | Scan failed server-side |
81
84
  | 75 | Still running; resume command printed |
82
85
 
83
- `CLEANSLOP_ACTION_REQUIRED` blocks go to stderr. Never open, approve, or pay.
86
+ `CLEANSLOP_ACTION_REQUIRED` blocks go to stderr. Never open, approve, or pay. A block may end with a `CLEANSLOP_QUESTION:` JSON line (`id`, `header`, `question`, `options[]` with `value`, `label`, optional `description`, and `run` for the exact next command or `next` for a plain next step; neither means stop). Agents with a multiple-choice question tool (for example Claude Code's AskUserQuestion) should ask with it, using exactly those options, and never answer for the human. Consent questions never carry `--agree`.
84
87
 
85
88
  ## Tests
86
89
 
@@ -4,36 +4,46 @@ Run a CleanSlop readiness scan at milestones (before claiming work is done, befo
4
4
 
5
5
  ## Git preconditions
6
6
 
7
- Work from a git checkout whose `origin` is on github.com, unless `/me` reports `uploads: true` (Link). For GitHub scans, if the tree is dirty or HEAD is not on GitHub, **ask the human before committing or pushing**. Do not commit, push, stash, or rewrite history yourself. For Link uploads, pack the working tree and skip the push step.
7
+ Just run `cleanslop scan`. Do not check git state first or tell the human a commit or push may be needed: the CLI picks the source and asks when the human must choose. A clean pushed github.com commit is scanned from GitHub. A Link sign-in (`/me` `uploads: true`) always uploads the local files. A GitHub sign-in that can upload (`uploadFallback: true`) never uploads unasked: a folder with no commits or no GitHub origin asks `upload_local`, uncommitted or unpushed changes ask `push_or_upload` ("Scan local files" or "I pushed"), and a `github_install` question also offers "Scan local files". Once the human picks "Scan local files", pass `--upload` on later scans and rescans in this session without asking again. Do not commit, push, stash, or rewrite history yourself.
8
8
 
9
9
  ## Transport
10
10
 
11
- Use MCP if it is registered (`<origin>/mcp`); otherwise the CLI. Run it as `npx @cleanslop/cli <command>` unless `cleanslop` is already installed (commands below are written as `cleanslop …`). If your harness blocks npx, **ask the human** to allow it or run the command themselves; do not work around the block. In Claude Code, run long waits as a **background** command (`cleanslop scan --wait 75m`) so waiting costs zero tokens. `cleanslop setup` registers MCP for Claude Code, Cursor, and Codex and never writes a token. MCP stays on GitHub; connect with Link through the CLI.
11
+ Use MCP if it is registered (`<origin>/mcp`); otherwise the CLI. Run it as `npx -y @cleanslop/cli@latest <command>` (commands below are written as `cleanslop …`), even if `cleanslop` is installed: `-y` skips npx's install prompt, and the tag makes npx fetch the current release. If a command fails with `cli_outdated`, rerun it that way. If your harness blocks npx, **ask the human** to allow it or run the command themselves; do not work around the block. In Claude Code, run long waits as a **background** command (`cleanslop scan --wait 75m`) so waiting costs zero tokens. `cleanslop setup` registers MCP for Claude Code, Cursor, and Codex and never writes a token. MCP stays on GitHub; connect with Link through the CLI.
12
12
 
13
- ## Connect with Link
13
+ ## Connect
14
14
 
15
- Run Link and login commands in the foreground with `--no-wait`. When one prints an `approve` block, relay the link and code, wait for the human to approve, then rerun the same command with `--resume` instead of `--no-wait`.
15
+ If the human already said how to connect (Link or GitHub), use that. Otherwise, when a command says this machine is not connected and asks how to connect (`connect_method`), ask the human with exactly its options, in order (the CLI recommends GitHub in a GitHub repo and Stripe Link elsewhere).
16
16
 
17
- 1. Run `cleanslop login --link --no-wait`. The first run stops with an `ask_human` block quoting one question (an account from the Link-verified email, plus the terms). Relay it **exactly as printed**.
18
- 2. If the human says yes, rerun with `--agree --no-wait`. If not, stop.
19
- 3. If Link is not signed in on this machine, the CLI prints an `approve` block with a Link link and a phrase and exits 10. Relay them; after the human approves in the Link app, rerun with `--resume` instead of `--no-wait`.
17
+ Run Link and login commands in the foreground with `--no-wait`. When one prints an `approve` block, ask its Done / Not now question (it repeats the link and code). On Done, rerun the same command with `--resume` instead of `--no-wait`; on Not now, stop. Never ask the human to type “done”.
18
+
19
+ **GitHub:** run `cleanslop login --no-wait`, then the approve-then-`--resume` step.
20
+
21
+ **Link:**
22
+
23
+ 1. Run `cleanslop login --link --no-wait`. Choosing Link and approving it in Link is what shares the human's Link-verified email with CleanSlop; there is no separate question for it.
24
+ 2. If Link is not signed in on this machine, the CLI prints an `approve` block with a Link link and a phrase and exits 10. Ask its Done question; on Done, rerun with `--resume` instead of `--no-wait`.
25
+ 3. A returning Link user is connected with no question. Only when the email has no CleanSlop account yet does the CLI stop with an `ask_human` block quoting the terms question (create an account and agree to the terms). Relay it **exactly as printed**. If the human says yes, rerun with `--agree --no-wait`. If not, stop.
20
26
  4. On success it prints “Connected as <masked email> (Link)”. Repeat that to the human.
21
- 5. `link_existing` means the Link email already belongs to a CleanSlop account. Run `cleanslop login --no-wait` (GitHub device login), then `cleanslop link-identity --no-wait`, each with the approve-then-`--resume` step above. `link-identity` asks its own email question (`--agree` after a yes).
27
+ 5. `link_existing` means the Link email already belongs to a CleanSlop account. Run `cleanslop login --no-wait` (GitHub device login), then `cleanslop link-identity --no-wait`, each with the approve-then-`--resume` step above. `link-identity` asks no question of its own: the human already chose it in `link_existing`, and CleanSlop links only when the Link email matches the one this account has verified.
22
28
  6. `beta` means this Link email is not in the pilot yet. Tell the human and stop.
29
+ 7. If Link sign-in fails and the CLI offers GitHub instead (`link_failed`), ask the human; Link may not be available to them.
23
30
 
24
31
  ## Buy credits with Link
25
32
 
26
33
  Run purchase commands in the foreground with `--no-wait`, the same way as Link sign-in. The human approves every payment in their Link app; never approve or pay yourself.
27
34
 
28
- 1. When a scan exits 11 with a `top-up` block, ask the human whether to buy the pack it names (the block gives the scans and the price). If they say no, stop.
29
- 2. If yes, run `cleanslop credits buy --link --pack <pack> --no-wait`. It prints an `approve` block with a Link link and exits 10. Relay the link.
30
- 3. After the human approves in the Link app, run `cleanslop credits buy --link --resume`. If it prints `approve` again, they have not approved yet: relay the link again and wait. Never start a second purchase while one is pending.
35
+ 1. When a scan exits 11 with a `top-up` block, or `credits buy` without `--pack` asks which pack, ask the human to choose (the block lists each pack's scans, price, and price per scan, and says when Link will first ask for a one-time payment permission or sign-in). If they choose not to buy, stop. Never pick a pack for them.
36
+ 2. Run `cleanslop credits buy --link --pack <pack> --no-wait` with their pack. It prints an `approve` block and exits 10. Ask its Done question: Link sends the approval to the human's Link app, and there is usually no link to open. If Link first needs payment permission, the block says so (header Permission): relay it as a one-time permission, not the purchase; nothing is charged, and the purchase approval comes next.
37
+ 3. When the human answers Done, run `cleanslop credits buy --link --resume`. If it prints `approve` again, they have not approved yet: relay the prompt again and wait. If it prints `ask_human`, relay it and follow it. Never start a second purchase while one is pending.
31
38
  4. On success it prints “Added … scan credits. Balance: N”. Rerun the scan.
32
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
+ 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 on the web (Link accounts): run `cleanslop billing` when an answer runs it, or the human asks to subscribe on the web, buy credits on the web, or change 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
+ 8. Monthly plans with Link: when an answer runs `cleanslop plan` (the Monthly plan answer does when CleanSlop offers Link plans), or the human asks for a monthly plan, run `cleanslop plan`. Without a plan name it asks which plan (Starter, Pro, or Max, with monthly prices): ask it and never pick for them. Then run `cleanslop plan <plan> --no-wait`, ask its Done question, and run `cleanslop plan --resume` when they answer Done, as for packs. Tell the human that Link charges the plan price every month until they cancel with `cleanslop billing`. On success it prints “Started the CleanSlop … plan”: rerun the scan. If it prints the `cleanslop billing` block instead, Link plans are off: follow step 7.
33
43
 
34
44
  ## Relay human actions
35
45
 
36
- When the CLI prints a `CLEANSLOP_ACTION_REQUIRED` block, show the human the link and code **exactly as printed** and wait. Kinds: approve (device login, Link sign-in, or a Link payment), install (GitHub App), top-up (credits), beta (request access), reauth (reconnect GitHub), present_identity (Link), link_existing (connect Link to an existing account), ask_human (quoted terms or email-sharing question). Never open the link, never approve, never pay, never enter credentials. `cleanslop login --link` drives `link-cli` itself (Link sign-in, attestations, identity credential). Never run `link-cli … present`, `attestations pop`, or `spend-request` yourself, and never paste their output. When CleanSlop says the person must approve a payment in Link, tell them and wait. Pass `--agree` only after the human answers yes to the quoted question in this session. After login, repeat “Connected as @login” or the masked Link email to the human.
46
+ When the CLI prints a `CLEANSLOP_ACTION_REQUIRED` block, show the human the link and code **exactly as printed** and wait. Blocks that wait on the human (approvals, GitHub App install, push, checkout) carry a Done / Not now question; ask it rather than asking them to reply. Kinds: approve (device login, Link sign-in, or a Link payment), install (GitHub App), top-up (credits), beta (request access), reauth (reconnect GitHub), present_identity (Link), link_existing (connect Link to an existing account), ask_human (quoted terms question). Never open the link, never approve, never pay, never enter credentials. `cleanslop login --link` drives `link-cli` itself (Link sign-in, attestations, identity credential). Never run `link-cli … present`, `attestations pop`, or `spend-request` yourself, and never paste their output. When CleanSlop says the person must approve a payment in Link, tell them and wait. Pass `--agree` only after the human answers yes to the quoted question in this session. When a block includes a `CLEANSLOP_QUESTION:` line (a JSON question with options), you must ask it with your multiple-choice question tool if you have one (for example AskUserQuestion), offering exactly those options; never ask the human to type a reply such as “Done” instead. Only without such a tool, ask in plain text. Never answer for the human. Then do what the chosen option says: run its `run` command, follow its `next` step, or stop if it has neither. MCP tool results carry the same JSON as `action.question` on an error, or `question` on a preview; their options use `next` only. After login, repeat “Connected as @login” or the masked Link email to the human.
37
47
 
38
48
  ## Waiting
39
49
 
@@ -53,11 +63,11 @@ When `review` is `unavailable`, the findings are unreviewed first-pass results (
53
63
 
54
64
  ## Fix loop
55
65
 
56
- Fix by priority, run the repo’s tests, ask the human about `needs_input`, get a commit and push from the human, rescan **once**, and compare the delta (`new` / `still_open` / `resolved` / `no_longer_listed`). `no_longer_listed` means the review stopped listing the finding — it is not a confirmed fix.
66
+ A finished CLI report with `confirmed` or `needs_input` findings ends with a `fix_findings` question (Fix them / Show me first / Not now). The human does not see the CLI output, so the block includes a ready-made list of those findings: write it into your reply word for word as plain text, then ask the question, and do not edit code before the human answers. Then fix by priority, run the repo’s tests, ask the human about `needs_input`, rescan **once** (the CLI asks whether to upload the local files or have the human push first), and compare the delta (`new` / `still_open` / `resolved` / `no_longer_listed`). `no_longer_listed` means the review stopped listing the finding — it is not a confirmed fix.
57
67
 
58
68
  ## Stop conditions
59
69
 
60
- Stop when all listed issues are resolved; the same fingerprints are still open after one rescan; the account is out of scans and the human does not buy more (or none can be bought); the human declines; or the commit has not changed.
70
+ Stop when all listed issues are resolved; the same fingerprints are still open after one rescan; the account is out of scans and the human does not buy more (or none can be bought); the human declines; or the code has not changed.
61
71
 
62
72
  ## Report back
63
73
 
package/dist/action.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import type { CliDeps } from "./deps.js";
2
- import type { ActionRequired } from "./exit.js";
2
+ import type { ActionQuestion, ActionRequired } from "./exit.js";
3
3
  import type { AgentScan } from "./types.js";
4
4
  export declare function writeAction(deps: CliDeps, action: ActionRequired): void;
5
+ export declare const QUESTION_TOOL_HINT = "If you have a multiple-choice question tool (for example AskUserQuestion), you must ask this with it, offering exactly these options; do not ask the human to type a reply such as \"Done\". Only without such a tool, ask in plain text. Never answer for the human. Then do what the chosen option says: run its command, follow its next step, or stop.";
6
+ /** Numbered options, the machine-readable line, and how to ask. */
7
+ export declare function questionLines(question: ActionQuestion): string[];
5
8
  export declare function writeResume(deps: CliDeps, scanId: string, scan?: Pick<AgentScan, "eta" | "elapsedSec">): void;
package/dist/action.js CHANGED
@@ -11,9 +11,33 @@ export function writeAction(deps, action) {
11
11
  if (action.code) {
12
12
  lines.push("", `Code: ${action.code}`);
13
13
  }
14
+ if (action.question) {
15
+ lines.push("", ...questionLines(action.question));
16
+ }
14
17
  lines.push("", "Never open, approve, or pay yourself. Never enter credentials or payment details.");
15
18
  deps.io.stderr(`${lines.join("\n")}\n`);
16
19
  }
20
+ export const QUESTION_TOOL_HINT = "If you have a multiple-choice question tool (for example AskUserQuestion), you must ask this with it, offering exactly these options; do not ask the human to type a reply such as \"Done\". Only without such a tool, ask in plain text. Never answer for the human. Then do what the chosen option says: run its command, follow its next step, or stop.";
21
+ /** Numbered options, the machine-readable line, and how to ask. */
22
+ export function questionLines(question) {
23
+ const options = question.options.map((option, i) => {
24
+ const detail = option.description ? ` (${option.description})` : "";
25
+ const next = option.run
26
+ ? ` → run: ${option.run}`
27
+ : option.next
28
+ ? ` → next: ${option.next}`
29
+ : " → stop";
30
+ return ` ${i + 1}. ${option.label}${detail}${next}`;
31
+ });
32
+ return [
33
+ `Options:`,
34
+ ...options,
35
+ "",
36
+ `CLEANSLOP_QUESTION: ${JSON.stringify(question)}`,
37
+ "",
38
+ QUESTION_TOOL_HINT,
39
+ ];
40
+ }
17
41
  export function writeResume(deps, scanId, scan) {
18
42
  const eta = scan ? formatEtaLine(scan) : null;
19
43
  const head = eta ? `Still running (${eta}).` : "Still running.";
@@ -1 +1 @@
1
- {"version":3,"file":"action.js","sourceRoot":"","sources":["../src/action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,UAAU,WAAW,CAAC,IAAa,EAAE,MAAsB;IAC/D,MAAM,KAAK,GAAG;QACZ,8BAA8B,MAAM,CAAC,IAAI,EAAE;QAC3C,EAAE;QACF,MAAM,CAAC,WAAW;KACnB,CAAC;IACF,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAChB,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IACD,KAAK,CAAC,IAAI,CACR,EAAE,EACF,mFAAmF,CACpF,CAAC;IACF,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,IAAa,EACb,MAAc,EACd,IAA4C;IAE5C,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9C,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAChE,IAAI,CAAC,EAAE,CAAC,MAAM,CACZ,GAAG,IAAI,qCAAqC,MAAM,WAAW,CAC9D,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"action.js","sourceRoot":"","sources":["../src/action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,UAAU,WAAW,CAAC,IAAa,EAAE,MAAsB;IAC/D,MA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KAAK,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,KAAK,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC;IACvD,CAAC,CAAC,CAAC;IACH,OAAO;QACL,UAAU;QACV,GAAG,OAAO;QACV,EAAE;QACF,uBAAuB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;QACjD,EAAE;QACF,kBAAkB;KACnB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,IAAa,EACb,MAAc,EACd,IAA4C;IAE5C,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9C,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAChE,IAAI,CAAC,EAAE,CAAC,MAAM,CACZ,GAAG,IAAI,qCAAqC,MAAM,WAAW,CAC9D,CAAC;AACJ,CAAC"}
package/dist/args.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import type { ParsedArgs } from "./types.js";
2
2
  export declare function parseWaitMs(raw: string, fallback?: number): number;
3
3
  export declare function parseArgs(argv: string[], defaultWaitMs?: number): ParsedArgs;
4
- export declare const HELP_TEXT = "cleanslop \u2014 CleanSlop agent CLI\n\nUsage:\n cleanslop [scan] [--wait [duration]] [--json] [--force] [--preview]\n cleanslop login [--link] [--agree] [--no-wait | --resume]\n cleanslop link-identity [--agree] [--no-wait | --resume]\n cleanslop credits buy --link [--pack p5] [--no-wait | --resume]\n cleanslop logout\n cleanslop whoami\n cleanslop status [id] [--wait [duration]]\n cleanslop report [id] [--format md|json] [--preview]\n cleanslop email <id> --consent \"<exact question>\" [--reply \"<human reply>\"]\n cleanslop setup [--dry-run] [--uninstall] [--project] [--yes]\n\nscan is the default command. GitHub App repos, or a packed upload when /me\nreports uploads:true (Link). --dry-run on scan lists the upload pack.\n\nWait:\n --wait poll until final or the budget (default 8 minutes)\n --wait 75m Claude Code background budget (hours/minutes/seconds: 1h, 75m, 30s)\n At the deadline: exit 75 and print a resume command. The scan keeps running.\n\nFlags:\n --json one JSON document on stdout\n --force skip same-commit dedupe (sends Idempotency-Key)\n --preview first-pass report before judgment is final\n --no-wait login / link-identity / credits buy: print the approval link and exit 10\n --resume login / link-identity / credits buy: continue a pending --no-wait approval\n --link login: Stripe Link sign-up / sign-in (requires link-cli)\n --agree login --link / link-identity: pass only after the human answers yes to the quoted question\n (--accept-terms --yes-share-email together still work for login --link; --yes-share-email for link-identity)\n --pack credits buy: p5, p15, or p40 (default p5). Price and network id come from CleanSlop.\n --dry-run setup: print the plan. scan (Link): list the pack, upload nothing\n --uninstall setup: remove marker blocks / skill files\n --project setup: project files instead of user scope\n --yes setup: write in a non-TTY (otherwise non-TTY is a plan only)\n --consent email: the exact masked-recipient question you asked\n --reply email: optional verbatim human reply\n\nEnv:\n CLEANSLOP_ORIGIN API origin (default https://cleanslop.com)\n CLEANSLOP_TOKEN bearer token override (never printed)\n CLEANSLOP_LINK_CLI path to link-cli (default: link-cli on PATH)\n\nCredentials: $XDG_CONFIG_HOME/cleanslop/credentials.json or ~/.config/cleanslop/\nDirectory 0700, file 0600. Never stored inside the git worktree.\n\nExit codes: 0 ok \u00B7 1 unexpected \u00B7 2 usage \u00B7 10 human action \u00B7 11 payment\n 12 policy \u00B7 13 source \u00B7 20 scan failed \u00B7 75 still running\n\nNever open, approve, or pay yourself. Relay CLEANSLOP_ACTION_REQUIRED blocks.\n";
4
+ export declare const HELP_TEXT = "cleanslop \u2014 CleanSlop agent CLI\n\nUsage:\n cleanslop [scan] [--wait [duration]] [--json] [--force] [--preview] [--upload]\n cleanslop login [--link] [--agree] [--no-wait | --resume]\n cleanslop link-identity [--no-wait | --resume]\n cleanslop credits buy --link [--pack p5] [--no-promo] [--no-wait | --resume]\n cleanslop redeem <code>\n cleanslop billing\n cleanslop plan [starter|pro|max] [--no-wait | --resume]\n cleanslop logout [--all]\n cleanslop whoami\n cleanslop status [id] [--wait [duration]]\n cleanslop report [id] [--format md|json] [--preview]\n cleanslop email <id> --consent \"<exact question>\" [--reply \"<human reply>\"]\n cleanslop setup [--dry-run] [--uninstall] [--project] [--yes]\n\nscan is the default command. GitHub App repos, or a packed upload when /me\nreports uploads:true (Link). With uploadFallback:true (GitHub), a folder not\non GitHub asks whether to upload its files, and a dirty or unpushed checkout\nasks whether to upload them or push first. --dry-run on scan lists the upload pack.\n\nbilling (Link accounts): prints where the human manages the plan and credits\non the web and the masked email to enter there, then exits 10 to relay it.\n\nplan (Link accounts): starts a monthly plan paid each month from a recurring\nLink approval. Without a plan name it asks which one. When CleanSlop offers no\nLink plans, it does what billing does.\n\nWait:\n --wait poll until final or the budget (default 8 minutes)\n --wait 75m Claude Code background budget (hours/minutes/seconds: 1h, 75m, 30s)\n At the deadline: exit 75 and print a resume command. The scan keeps running.\n\nFlags:\n --json one JSON document on stdout\n --force skip same-commit dedupe (sends Idempotency-Key)\n --preview first-pass report before judgment is final\n --upload scan: upload the local files instead of the pushed commit (after the human picks it)\n --no-wait login / link-identity / credits buy / plan: print what to approve and exit 10\n --resume login / link-identity / credits buy / plan: continue a pending --no-wait approval\n --link login: Stripe Link sign-up / sign-in (requires link-cli)\n --agree login --link: pass only after the human answers yes to the quoted terms question\n (--accept-terms --yes-share-email together still work)\n --pack credits buy: p5, p15, or p40. Required without a terminal (the human picks); a terminal defaults to p5. Price and network id come from CleanSlop.\n --no-promo credits buy: skip the promo-code choice (the human already chose to buy)\n --all logout: revoke every saved token and delete all local CleanSlop data\n (without it, logout signs out of this origin and drops its pending login and Link payment)\n --dry-run setup: print the plan. scan (upload): list the pack, upload nothing\n --uninstall setup: remove marker blocks / skill files\n --project setup: project files instead of user scope\n --yes setup: write in a non-TTY (otherwise non-TTY is a plan only)\n --consent email: the exact masked-recipient question you asked\n --reply email: optional verbatim human reply\n\nEnv:\n CLEANSLOP_ORIGIN API origin (default https://cleanslop.com)\n CLEANSLOP_TOKEN bearer token override (never printed)\n CLEANSLOP_LINK_CLI path to link-cli (default: link-cli on PATH)\n\nCredentials: $XDG_CONFIG_HOME/cleanslop/credentials.json or ~/.config/cleanslop/\nDirectory 0700, file 0600. Never stored inside the git worktree.\n\nExit codes: 0 ok \u00B7 1 unexpected \u00B7 2 usage \u00B7 10 human action \u00B7 11 payment\n 12 policy \u00B7 13 source \u00B7 20 scan failed \u00B7 75 still running\n\nNever open, approve, or pay yourself. Relay CLEANSLOP_ACTION_REQUIRED blocks.\nAsk a CLEANSLOP_QUESTION with your multiple-choice question tool when you have\none (never ask the human to type \"Done\"), using exactly its options. Never\nanswer for the human.\n";
package/dist/args.js CHANGED
@@ -11,6 +11,9 @@ const COMMANDS = [
11
11
  "email",
12
12
  "link-identity",
13
13
  "credits",
14
+ "redeem",
15
+ "billing",
16
+ "plan",
14
17
  ];
15
18
  function isCommand(value) {
16
19
  return COMMANDS.includes(value);
@@ -38,12 +41,15 @@ function emptyArgs(defaultWaitMs) {
38
41
  wait: false,
39
42
  waitMs: defaultWaitMs,
40
43
  noWait: false,
44
+ noPromo: false,
41
45
  resume: false,
42
46
  force: false,
47
+ upload: false,
43
48
  preview: false,
44
49
  format: "md",
45
50
  dryRun: false,
46
51
  uninstall: false,
52
+ all: false,
47
53
  project: false,
48
54
  yes: false,
49
55
  consent: null,
@@ -85,9 +91,15 @@ export function parseArgs(argv, defaultWaitMs = DEFAULT_WAIT_MS) {
85
91
  case "--resume":
86
92
  out.resume = true;
87
93
  break;
94
+ case "--no-promo":
95
+ out.noPromo = true;
96
+ break;
88
97
  case "--force":
89
98
  out.force = true;
90
99
  break;
100
+ case "--upload":
101
+ out.upload = true;
102
+ break;
91
103
  case "--preview":
92
104
  out.preview = true;
93
105
  break;
@@ -97,6 +109,9 @@ export function parseArgs(argv, defaultWaitMs = DEFAULT_WAIT_MS) {
97
109
  case "--uninstall":
98
110
  out.uninstall = true;
99
111
  break;
112
+ case "--all":
113
+ out.all = true;
114
+ break;
100
115
  case "--project":
101
116
  out.project = true;
102
117
  break;
@@ -194,11 +209,14 @@ export function parseArgs(argv, defaultWaitMs = DEFAULT_WAIT_MS) {
194
209
  export const HELP_TEXT = `cleanslop — CleanSlop agent CLI
195
210
 
196
211
  Usage:
197
- cleanslop [scan] [--wait [duration]] [--json] [--force] [--preview]
212
+ cleanslop [scan] [--wait [duration]] [--json] [--force] [--preview] [--upload]
198
213
  cleanslop login [--link] [--agree] [--no-wait | --resume]
199
- cleanslop link-identity [--agree] [--no-wait | --resume]
200
- cleanslop credits buy --link [--pack p5] [--no-wait | --resume]
201
- cleanslop logout
214
+ cleanslop link-identity [--no-wait | --resume]
215
+ cleanslop credits buy --link [--pack p5] [--no-promo] [--no-wait | --resume]
216
+ cleanslop redeem <code>
217
+ cleanslop billing
218
+ cleanslop plan [starter|pro|max] [--no-wait | --resume]
219
+ cleanslop logout [--all]
202
220
  cleanslop whoami
203
221
  cleanslop status [id] [--wait [duration]]
204
222
  cleanslop report [id] [--format md|json] [--preview]
@@ -206,7 +224,16 @@ Usage:
206
224
  cleanslop setup [--dry-run] [--uninstall] [--project] [--yes]
207
225
 
208
226
  scan is the default command. GitHub App repos, or a packed upload when /me
209
- reports uploads:true (Link). --dry-run on scan lists the upload pack.
227
+ reports uploads:true (Link). With uploadFallback:true (GitHub), a folder not
228
+ on GitHub asks whether to upload its files, and a dirty or unpushed checkout
229
+ asks whether to upload them or push first. --dry-run on scan lists the upload pack.
230
+
231
+ billing (Link accounts): prints where the human manages the plan and credits
232
+ on the web and the masked email to enter there, then exits 10 to relay it.
233
+
234
+ plan (Link accounts): starts a monthly plan paid each month from a recurring
235
+ Link approval. Without a plan name it asks which one. When CleanSlop offers no
236
+ Link plans, it does what billing does.
210
237
 
211
238
  Wait:
212
239
  --wait poll until final or the budget (default 8 minutes)
@@ -217,13 +244,17 @@ Flags:
217
244
  --json one JSON document on stdout
218
245
  --force skip same-commit dedupe (sends Idempotency-Key)
219
246
  --preview first-pass report before judgment is final
220
- --no-wait login / link-identity / credits buy: print the approval link and exit 10
221
- --resume login / link-identity / credits buy: continue a pending --no-wait approval
247
+ --upload scan: upload the local files instead of the pushed commit (after the human picks it)
248
+ --no-wait login / link-identity / credits buy / plan: print what to approve and exit 10
249
+ --resume login / link-identity / credits buy / plan: continue a pending --no-wait approval
222
250
  --link login: Stripe Link sign-up / sign-in (requires link-cli)
223
- --agree login --link / link-identity: pass only after the human answers yes to the quoted question
224
- (--accept-terms --yes-share-email together still work for login --link; --yes-share-email for link-identity)
225
- --pack credits buy: p5, p15, or p40 (default p5). Price and network id come from CleanSlop.
226
- --dry-run setup: print the plan. scan (Link): list the pack, upload nothing
251
+ --agree login --link: pass only after the human answers yes to the quoted terms question
252
+ (--accept-terms --yes-share-email together still work)
253
+ --pack credits buy: p5, p15, or p40. Required without a terminal (the human picks); a terminal defaults to p5. Price and network id come from CleanSlop.
254
+ --no-promo credits buy: skip the promo-code choice (the human already chose to buy)
255
+ --all logout: revoke every saved token and delete all local CleanSlop data
256
+ (without it, logout signs out of this origin and drops its pending login and Link payment)
257
+ --dry-run setup: print the plan. scan (upload): list the pack, upload nothing
227
258
  --uninstall setup: remove marker blocks / skill files
228
259
  --project setup: project files instead of user scope
229
260
  --yes setup: write in a non-TTY (otherwise non-TTY is a plan only)
@@ -242,5 +273,8 @@ Exit codes: 0 ok · 1 unexpected · 2 usage · 10 human action · 11 payment
242
273
  12 policy · 13 source · 20 scan failed · 75 still running
243
274
 
244
275
  Never open, approve, or pay yourself. Relay CLEANSLOP_ACTION_REQUIRED blocks.
276
+ Ask a CLEANSLOP_QUESTION with your multiple-choice question tool when you have
277
+ one (never ask the human to type "Done"), using exactly its options. Never
278
+ answer for the human.
245
279
  `;
246
280
  //# sourceMappingURL=args.js.map
package/dist/args.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC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E,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC1B,MAAM,UAAU,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;gBAC7C,CAAC;gBACD,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;oBACX,MAAM,UAAU,CAAC,8BAA8B,KAAK,EAAE,CAAC,CAAC;gBAC1D,CAAC;gBACD,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC;gBACf,MAAM;QACV,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsExB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { CliDeps } from "../deps.js";
2
+ import type { ParsedArgs } from "../types.js";
3
+ /**
4
+ * Where a Link account manages its plan. The server emails the sign-in link
5
+ * to the account's Link address (the CLI never sees it); when it cannot, or
6
+ * an older server has no such route, the human types the masked address at
7
+ * `/signin/email`.
8
+ */
9
+ export declare function runBilling(deps: CliDeps, args: ParsedArgs): Promise<number>;
@@ -0,0 +1,113 @@
1
+ import { requireToken, resolveOrigin } from "../credentials.js";
2
+ import { actionError, EXIT_OK } from "../exit.js";
3
+ import { httpRequest, requireOk } from "../http.js";
4
+ import { stripeSptOffersFromErrorBody } from "./credits.js";
5
+ import { writeJson } from "../output.js";
6
+ function webBillingFrom(raw) {
7
+ return raw?.url && raw.emailMasked ? { url: raw.url, emailMasked: raw.emailMasked } : null;
8
+ }
9
+ function typedAddressPrompt({ url, emailMasked }) {
10
+ return `To subscribe, buy credits or cancel your plan, go to ${url} and enter ${emailMasked}. You'll get a sign-in link by email.`;
11
+ }
12
+ /**
13
+ * Where a Link account manages its plan. The server emails the sign-in link
14
+ * to the account's Link address (the CLI never sees it); when it cannot, or
15
+ * an older server has no such route, the human types the masked address at
16
+ * `/signin/email`.
17
+ */
18
+ export async function runBilling(deps, args) {
19
+ const origin = resolveOrigin(deps);
20
+ const creds = requireToken(deps, origin);
21
+ const result = await httpRequest(deps, origin, "POST", "/api/agent/v1/billing/sign-in-link", { token: creds.token });
22
+ if (result.status === 404)
23
+ return typedAddress(deps, args, origin, creds.token);
24
+ requireOk(result);
25
+ const body = (result.json ?? {});
26
+ const webBilling = webBillingFrom(body.webBilling);
27
+ if (!webBilling)
28
+ return notAvailable(deps, args);
29
+ const sent = body.sent === true;
30
+ if (args.json) {
31
+ writeJson(deps, {
32
+ sent,
33
+ ...(sent ? { expiresAt: body.expiresAt ?? null } : { reason: body.reason ?? null }),
34
+ webBilling,
35
+ });
36
+ }
37
+ const { url, emailMasked } = webBilling;
38
+ const humanPrompt = sent
39
+ ? `We emailed a sign-in link to ${emailMasked}. Open it to subscribe, buy credits or cancel your plan. It works once and expires in 15 minutes. No email? Go to ${url} and enter ${emailMasked}.`
40
+ : body.reason === "rate_limited"
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.`
42
+ : typedAddressPrompt(webBilling);
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
+ };
90
+ }
91
+ async function typedAddress(deps, args, origin, token) {
92
+ const result = await httpRequest(deps, origin, "GET", "/api/agent/v1/me", { token });
93
+ requireOk(result);
94
+ const webBilling = webBillingFrom(result.json?.webBilling);
95
+ if (!webBilling)
96
+ return notAvailable(deps, args);
97
+ if (args.json)
98
+ writeJson(deps, { sent: false, reason: null, webBilling });
99
+ throw actionError("", {
100
+ kind: "ask_human",
101
+ humanPrompt: typedAddressPrompt(webBilling),
102
+ url: webBilling.url,
103
+ question: await doneOnWebQuestion(deps, origin, token, typedAddressQuestion(webBilling)),
104
+ });
105
+ }
106
+ function notAvailable(deps, args) {
107
+ if (args.json)
108
+ writeJson(deps, { webBilling: null });
109
+ else
110
+ deps.io.stdout("Not available for this account.\n");
111
+ return EXIT_OK;
112
+ }
113
+ //# sourceMappingURL=billing.js.map
@@ -0,0 +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,EAAuB,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,WAAW,E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U;QAAE,OAAO,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACjD,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"}
@@ -1,4 +1,7 @@
1
1
  import type { CliDeps, HttpResult } from "../deps.js";
2
+ import { type LinkPaymentStep, type OnMissingScope } from "../link.js";
3
+ import { type PendingSpendRequest, type SpendKind } from "../credentials.js";
4
+ import { type ActionQuestion } from "../exit.js";
2
5
  import type { ParsedArgs } from "../types.js";
3
6
  declare const CREDIT_PACKS: {
4
7
  readonly p5: 5;
@@ -12,6 +15,8 @@ export type StripeSptOffer = {
12
15
  currency: string;
13
16
  networkId: string;
14
17
  purchaseUrl: string;
18
+ /** CleanSlop marks one pack as the best value. */
19
+ best?: boolean;
15
20
  };
16
21
  /** Fixed Link approval budget. Auto-buy ignores `scan --wait`. */
17
22
  export declare const LINK_APPROVAL_WAIT_MS: number;
@@ -27,10 +32,48 @@ export declare const LINK_RESUME_WAIT_MS: number;
27
32
  export declare function linkApprovalWaitMs(args: ParsedArgs, opts?: {
28
33
  autoBuy?: boolean;
29
34
  }): number;
35
+ /**
36
+ * What a saved Link spend request pays for: its pending file, the command
37
+ * that resumes it, and what to say when Link turns it down.
38
+ */
39
+ export type SpendFlow = {
40
+ kind: SpendKind;
41
+ /** Resume command without `--resume`, e.g. `cleanslop credits buy --link`. */
42
+ command: string;
43
+ /** What the human approves, e.g. `CleanSlop credit pack (p5)`. */
44
+ what: string;
45
+ /** Prompt and question after Link denied, expired or canceled the request. */
46
+ restart: (status: string) => {
47
+ humanPrompt: string;
48
+ question: ActionQuestion;
49
+ };
50
+ };
30
51
  /** Cents to a display price, e.g. `5.00 USD`. */
31
52
  export declare function formatPackPrice(amount: number, currency: string): string;
53
+ /** `p15 (15 scans, 25.00 USD, 1.67 USD per scan, best value)`. */
54
+ export declare function describePackOffer(offer: StripeSptOffer): string;
55
+ /** What the human approves, in order: a one-time Link permission (or sign-in) first when Link needs it. */
56
+ export declare function approvalNote(step: LinkPaymentStep): string;
57
+ /** The agent's prompt says it too, so the permission step is not relayed as the purchase. */
58
+ export declare function approvalPromptTail(step: LinkPaymentStep): string;
59
+ /** Every `stripe_spt` offer in a 402 `out_of_scans` body, in server order. */
60
+ export declare function stripeSptOffersFromErrorBody(json: unknown): StripeSptOffer[];
32
61
  /** Read a matching `stripe_spt` offer from a 402 `out_of_scans` body. */
33
62
  export declare function stripeSptOfferFromErrorBody(json: unknown, packHint: string | null): StripeSptOffer | null;
63
+ export declare function tokenMissingAction(spendRequestId: string, command?: string): never;
64
+ type SpendRequestEvent = "created" | "approved" | "denied" | "expired" | "canceled" | "requires_action" | "token_missing";
65
+ /**
66
+ * Tells the server (billing Slack) about a spend-request transition it cannot
67
+ * see. Once per event per request; a network error or an older server that
68
+ * 404s never blocks the purchase. Call before deleting the pending file.
69
+ */
70
+ export declare function reportSpendRequest(deps: CliDeps, token: string, pending: PendingSpendRequest, event: SpendRequestEvent, kind?: SpendKind): Promise<void>;
71
+ /** link-cli 0.27 prints no approval page for live requests; Link notifies the app. */
72
+ export declare const IN_LINK_APP = "in their Link app (Link sends them a notification; there is no link to open)";
73
+ /** Approving in Link, then `--resume`; "Not now" leaves the request pending. */
74
+ export declare function paymentApprovalQuestion(what: string, approvalUrl: string | null | undefined, command?: string): ActionQuestion;
75
+ /** Checks the spend request at least once, then polls until `waitMs` runs out. */
76
+ export declare function pollUntilApproved(deps: CliDeps, token: string, pending: PendingSpendRequest, waitMs: number, onMissingScope: OnMissingScope, flow?: SpendFlow): Promise<void>;
34
77
  /**
35
78
  * Buys a Link credit pack. Default mode (a human at a terminal) creates the
36
79
  * spend request and waits up to 10 minutes. `--no-wait` creates it (or checks