thoughtleaders-cli 0.9.24__py3-none-any.whl → 0.9.25__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: thoughtleaders-cli
3
- Version: 0.9.24
3
+ Version: 0.9.25
4
4
  Summary: ThoughtLeaders CLI — query sponsorship data, channels, brands, and intelligence
5
5
  Project-URL: Homepage, https://thoughtleaders.io
6
6
  Project-URL: Repository, https://github.com/ThoughtLeaders-io/thoughtleaders-cli
@@ -235,6 +235,17 @@ tl describe show sponsorships --filters # Available filters for sponsorships
235
235
  tl balance # Your credit balance
236
236
  ```
237
237
 
238
+ ### Usage resets
239
+
240
+ A usage reset refills your weekly credits to your plan's allotment and restarts your 5-hour session. You get one as a gift from ThoughtLeaders when you sign up, one for each new organization that signs up with your invite link, and a bonus when that organization makes its first proposal or payment. Resets expire 90 days after they're granted, and you spend them only when you choose to.
241
+
242
+ ```bash
243
+ tl resets # Resets you have, recent history, your invite link
244
+ tl resets use # Spend one (asks first; --yes skips the question)
245
+ ```
246
+
247
+ When a query is refused because you're out of credits or at your session limit, the error tells you if you have a reset to spend, and gives your invite link: invite a friend outside your organization and you get a free reset when they join.
248
+
238
249
  `tl db pg` is priced **per-row**: the per-row rate is the **sum of the rates of the tables the query touches** (default 1.0/row; some tables are cheaper or dearer), plus a flat per-row charge for every expensive column read (demographics, channel outreach emails), all times the rows returned. Aggregate queries (`count`/`GROUP BY`) add a surcharge proportional to the rows they aggregate. Run `tl describe show db --json` to see the live `pg_pricing` map, and check `usage.credit_rate` in the response envelope after a query to see what your query was actually charged.
239
250
 
240
251
  To preview a query's cost **before** running it, add `--pricing`: `tl db pg "SELECT … LIMIT 100" --pricing` runs only the planner's `EXPLAIN`, prints the cost breakdown and an upper-bound estimate (at the query's `LIMIT`), and costs a flat **1 credit** — the query itself never executes. Works with `--json` too. `--pricing` is also available on `tl db fb` and `tl db es`; those backends have no per-table or per-column charges, so the estimate is the flat per-row rate at the query's row ceiling (`LIMIT` for Firebolt, `size` — or the aggregation doc cap — for Elasticsearch).
@@ -1,11 +1,11 @@
1
- tl_cli/__init__.py,sha256=Fr4WPfFPO4tfJasNz2cfjOo8stYGSDkrJhJ8azhBL5o,113
1
+ tl_cli/__init__.py,sha256=FJmx37kfHmnIsBUD1CvOOOkLCvPjoXbgAtI_NqXLP-M,113
2
2
  tl_cli/__main__.py,sha256=-FCBeOBi5Zi0hhZI3FWRilisl2DHxKeszgkY0r9VLR4,444
3
3
  tl_cli/_completions.py,sha256=kOyEUqC26vbYvyXWi513WX8fF73qQLR5WWuRSe_wqyk,164
4
4
  tl_cli/_typer_utils.py,sha256=ZiZsCVmEznPvBw-dYbr3tu3zWZ0iN6kjoQmK3gMqD28,860
5
5
  tl_cli/config.py,sha256=w-_uC8jrHOj5GX2POxL0xUN6J1iy32W6VAlrzNQKs5E,2239
6
6
  tl_cli/filters.py,sha256=Yjj04lONGGmtCAIYN5i6KD12mAnUKEZ7i9heeWtdj7o,2952
7
7
  tl_cli/hints.py,sha256=cT8kuDtkAZqwXkc2RV0Yg_abofK-g9UiXwTTBunX78U,1557
8
- tl_cli/main.py,sha256=M4i6gDCT42ulpnEQJuosb3h-OadrRBE82OpW4OJJ7nQ,6653
8
+ tl_cli/main.py,sha256=SnNazaGCB_J3n3xuIkAJwDK7Odaj7nOiw9grBWStORI,6747
9
9
  tl_cli/query_history.py,sha256=vA5avDU1DBZDWSb-w2ZxEZxV2MD21cqwzfYjXawOWZI,5540
10
10
  tl_cli/self_update.py,sha256=ea4zoNXcWWoMrSxc9zzoy4OM-rxZHCWPquV48k9_gTE,19091
11
11
  tl_cli/skill_registry.py,sha256=slB3K0tI_-mrPT7Eswzq2Sjlo8Wcwk5nDy0w9yQh6mM,11957
@@ -15,7 +15,7 @@ tl_cli/auth/login.py,sha256=BWIGqHF6EMj41G4MeGhGNh2OdF10USCOnylBRV18nYI,14819
15
15
  tl_cli/auth/pkce.py,sha256=4Q6Ip-TeZFNG9c3swXNi4gH7mdMkltKa62gZZNybt8U,658
16
16
  tl_cli/auth/token_store.py,sha256=qX0AIw4RGxCDpoeygc5CoCOkp8L7ppEXTyUVEiIuK9E,3446
17
17
  tl_cli/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- tl_cli/client/errors.py,sha256=rZJNpzJnqOJ4oL7VjQcqQlZV2SoU5MbHTIbeCUyMr6I,6000
18
+ tl_cli/client/errors.py,sha256=vkfZB8nX2KFLJcnKNNzOFEuXomuNFL0sVAvbffLBMP0,7270
19
19
  tl_cli/client/http.py,sha256=KMDlHtKsfBCfD7-OiCic7SG5iAgHO0z25COtaQPx0fI,6342
20
20
  tl_cli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  tl_cli/commands/_comments_common.py,sha256=x91WPSpDdV8AwE8Mwx4VtZQKWXBufsnBnC1lFD0Tzys,4522
@@ -36,6 +36,7 @@ tl_cli/commands/profiles.py,sha256=nnfp96iKFxnj_We73t8NUGgL-1F_x2H2XG2QM0brXy8,2
36
36
  tl_cli/commands/proposals.py,sha256=IXx9DsR7lPWRM4QvKB65t7xKNAK3H6ax9LIlIj8ydEs,2945
37
37
  tl_cli/commands/recommender.py,sha256=oDXcsmcfNgeNMUgxZuEL_UjPTn9UFwDTqb_-EuTlZdM,21394
38
38
  tl_cli/commands/reports.py,sha256=u7vtxcybITYih17iNZKsFN4LZwBSqh9L3iBo27OLubY,30754
39
+ tl_cli/commands/resets.py,sha256=0I1XA5QMQNZwS8L306uiS105AcF97BpXP3k5yEBQBiY,7132
39
40
  tl_cli/commands/schema.py,sha256=rmfg5pvKHa5kQi59YBIHCMzBNawmYPi2tBMcZP7Vrxw,6432
40
41
  tl_cli/commands/setup.py,sha256=1VCU8iURJZA0X_Q6ukGfomS8RfI_yWJiMqpp9qTdW9E,37360
41
42
  tl_cli/commands/skills.py,sha256=4Vg5ph6T7T3WcIqIZc83EJPhtB79FE7fMej9uVhElqc,15884
@@ -47,7 +48,7 @@ tl_cli/commands/workflows.py,sha256=ctduYa--Md6zbs8kQwO6mSyR9o1KB1UpNOaANuupDfU,
47
48
  tl_cli/output/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
49
  tl_cli/output/formatter.py,sha256=itNyHcDfRbksJgJ58JLtwJIrlHjqQj9gmK6uc3d9bSM,25692
49
50
  tl_cli/_plugin/.claude-plugin/marketplace.json,sha256=l56PMmyjfGXNGlV30wRyOAe74B6gJNCVNCxgsBbSNxc,446
50
- tl_cli/_plugin/.claude-plugin/plugin.json,sha256=RE1yHOU6LJMeA2u0DwL08urULLGRQ0XGFxq6srEvJD4,467
51
+ tl_cli/_plugin/.claude-plugin/plugin.json,sha256=uWYFqkkObW0NN0twaFeUo4i703EG0fsmqKzyg8SMc1E,467
51
52
  tl_cli/_plugin/agents/cast-sheet.md,sha256=0owR8XIjR4tbKuK4t3WruiJAjGQ8se2cnOGwzigs4Lk,1224
52
53
  tl_cli/_plugin/agents/gem-classifier.md,sha256=s9kkbhUc-JhJ_be9z6LNaojykQSV16zrOd-QVaKNwxc,1250
53
54
  tl_cli/_plugin/agents/keyword-context-classifier.md,sha256=8Pk6WqJKuF-ERkBh54Aa-9t60CvjdOIH0RurFlG-T7I,4325
@@ -65,7 +66,7 @@ tl_cli/_plugin/skills/connector-impact/SKILL.md,sha256=K4mozNpRSLjTSICRTX8LihnKI
65
66
  tl_cli/_plugin/skills/connector-impact/references/help.md,sha256=Wd8X35OwYAswj-xoFZPnCWctwFIx9EXNZ511FDB2I5c,5831
66
67
  tl_cli/_plugin/skills/connector-impact/references/impact-schema.md,sha256=dlAtA6OwkqgXojaItnaQBEIXVxLoVuavuWsPtQ4Rc_0,10155
67
68
  tl_cli/_plugin/skills/connector-impact/references/impact-to-tl-mapping.md,sha256=58IJ5r1I0aEmIETFm81vMAbd1NxVMol8-fqqvHG3qXY,22122
68
- tl_cli/_plugin/skills/tl/SKILL.md,sha256=C9XAkgeQUB-Or8-CSbZPVwoh9JS184bK0gj1y7nNiJ8,72757
69
+ tl_cli/_plugin/skills/tl/SKILL.md,sha256=W2AhPCr9GZLQjquHkdVjVL3y7z5N8blzbKNYKce_f54,73200
69
70
  tl_cli/_plugin/skills/tl/references/business-glossary.md,sha256=DkM-3DGnI_Dvr8fsB9B00-5erXv9r94umFCMVBGOxEs,20214
70
71
  tl_cli/_plugin/skills/tl/references/elasticsearch-schema.md,sha256=zjuHmJRooTTZvu2GfoQxG8xmRcExcKa33K1jipLAShI,25222
71
72
  tl_cli/_plugin/skills/tl/references/firebolt-schema.md,sha256=yf_elP_qXQePtMJNMshoVUOrI_3CXezF0NOoiYTbMNU,11335
@@ -148,8 +149,8 @@ tl_cli/_plugin/skills/tl-top-partnerships/SKILL.md,sha256=jOMMr40XRnAZv-oRLeyKJT
148
149
  tl_cli/_plugin/skills/tl-top-partnerships/scripts/top_partnerships.py,sha256=OqhoyvFe1zrtrStChcam7oPYgFnSbGHC3WAgLhLIC3w,13738
149
150
  tl_cli/_plugin/skills/tl-views-guarantee/SKILL.md,sha256=IH7q1WJDWri9TWJMiga1FMGJO_GKSbWwaDS6CVNZ9c0,9270
150
151
  tl_cli/_plugin/skills/tl-views-guarantee/scripts/vg.py,sha256=5FucKm0WXa16btyUKMyGpdRQ5euVhzKMSoTonuwlm5I,16444
151
- thoughtleaders_cli-0.9.24.dist-info/METADATA,sha256=ZEkuSp3hTzzSb7YHv8TR3OeGYUpI6f7ynkpRrBbsH9E,22294
152
- thoughtleaders_cli-0.9.24.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
153
- thoughtleaders_cli-0.9.24.dist-info/entry_points.txt,sha256=umZp-1BkGkHDG0bNZXpTXrjwW0HGf9IDFN40eAWuuvg,39
154
- thoughtleaders_cli-0.9.24.dist-info/licenses/LICENSE,sha256=RUfdfLsn6jygiyrnnVUHt6r4IPwr2rbDm9Kixgtu8fo,1071
155
- thoughtleaders_cli-0.9.24.dist-info/RECORD,,
152
+ thoughtleaders_cli-0.9.25.dist-info/METADATA,sha256=I6U7BB-Iuj9jpwZYbvu5xxSNT2xHtPXranq2G-hxmnw,23146
153
+ thoughtleaders_cli-0.9.25.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
154
+ thoughtleaders_cli-0.9.25.dist-info/entry_points.txt,sha256=umZp-1BkGkHDG0bNZXpTXrjwW0HGf9IDFN40eAWuuvg,39
155
+ thoughtleaders_cli-0.9.25.dist-info/licenses/LICENSE,sha256=RUfdfLsn6jygiyrnnVUHt6r4IPwr2rbDm9Kixgtu8fo,1071
156
+ thoughtleaders_cli-0.9.25.dist-info/RECORD,,
tl_cli/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """ThoughtLeaders CLI — query sponsorship data, channels, brands, and intelligence."""
2
2
 
3
- __version__ = "0.9.24"
3
+ __version__ = "0.9.25"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tl-cli",
3
- "version": "0.9.24",
3
+ "version": "0.9.25",
4
4
  "description": "ThoughtLeaders CLI — query sponsorship deals, channels, brands, uploads, and intelligence from the terminal",
5
5
  "author": {
6
6
  "name": "ThoughtLeaders",
@@ -111,7 +111,7 @@ Other key concepts:
111
111
  - **`purchase_date`** — when the sponsorship was purchased (i.e. when the deal was made); These make up bookings.
112
112
  - **`scheduled_date`** — the date the video is/was expected to be published (scheduled)
113
113
  - **`publish_date`** — the date the video was actually published; These make up live ads.
114
- - **Credits** — every data query costs credits; use `tl describe` to see rates. Top up with `tl credits buy --amount-usd N` (free; opens a browser checkout). New accounts get a starter balance on first `tl auth login`; the rate is shown by `tl credits pricing`.
114
+ - **Credits** — every data query costs credits; use `tl describe` to see rates. Top up with `tl credits buy --amount-usd N` (free; opens a browser checkout). New accounts get a starter balance on first `tl auth login`; the rate is shown by `tl credits pricing`. When a credits or session-limit refusal says the user has usage resets, a reset refills their weekly credits and restarts their 5-hour session; `tl resets` lists them. Spending one is the user's call: ask them first, and only then run `tl resets use --yes`.
115
115
 
116
116
  Users see data scoped by their organization and plan:
117
117
  - **Media buyers** see sponsorships where their org is the brand. They see `price` but never `cost`.
@@ -559,6 +559,8 @@ tl balance --json # Credit balance + recent usage (free)
559
559
  tl credits pricing # Current usd-per-credit rate (free, no auth)
560
560
  tl credits buy --amount-usd 10 # Start a top-up; opens browser checkout (free)
561
561
  tl credits history # Recent top-ups for the caller's org (free)
562
+ tl resets --json # Usage resets, invite link, referrals (free)
563
+ tl resets use --yes # Spend a usage reset — only after the user says so (free)
562
564
  tl whoami # Current user, org, brands (free)
563
565
  tl auth status # Auth check (free)
564
566
  tl changelog # Release notes — current version, or current..latest if behind (free)
tl_cli/client/errors.py CHANGED
@@ -66,6 +66,30 @@ def _print_hint(hint: str | None) -> None:
66
66
  err.print(f"[bold yellow]Hint:[/bold yellow] [yellow]{escape(hint)}[/yellow]")
67
67
 
68
68
 
69
+ def _print_resets_hint(error: ApiError) -> None:
70
+ """On a credits or session refusal, tell a user who has banked usage
71
+ resets that they can spend one. Spending is always their own choice, so
72
+ this only names the command — it never spends a reset."""
73
+ raw = error.raw if isinstance(error.raw, dict) else {}
74
+ count = raw.get("_billing_resets_available")
75
+ if isinstance(count, int) and not isinstance(count, bool) and count > 0:
76
+ noun = "usage reset" if count == 1 else "usage resets"
77
+ err.print(f"You have {count} {noun}. Spend one with: [bold]tl resets use[/bold]")
78
+
79
+
80
+ def _print_invite_hint(error: ApiError) -> None:
81
+ """On a credits or session refusal, point the user at their personal
82
+ invite link, which earns them a reset. Older servers send no link, and
83
+ then nothing is printed."""
84
+ raw = error.raw if isinstance(error.raw, dict) else {}
85
+ link = raw.get("_billing_invite_link")
86
+ if isinstance(link, str) and link:
87
+ err.print(
88
+ "Or invite a friend outside your organization. "
89
+ f"You'll get a free reset when they join: {escape(link)}"
90
+ )
91
+
92
+
69
93
  def handle_api_error(error: ApiError) -> None:
70
94
  """Print a user-friendly error message and exit with the right code."""
71
95
  detail, hint = _split_hint(error)
@@ -95,6 +119,8 @@ def handle_api_error(error: ApiError) -> None:
95
119
  err.print("Or visit: https://app.thoughtleaders.io/billing")
96
120
  _print_hint(hint)
97
121
  err.print("Top up with: [bold]tl credits buy --amount-usd 10[/bold]")
122
+ _print_resets_hint(error)
123
+ _print_invite_hint(error)
98
124
  _print_debug(error)
99
125
  sys.exit(4)
100
126
  elif error.status_code == 403:
@@ -125,6 +151,8 @@ def handle_api_error(error: ApiError) -> None:
125
151
  else:
126
152
  err.print("[yellow]Rate limited.[/yellow] Please wait and try again.")
127
153
  _print_hint(hint)
154
+ _print_resets_hint(error)
155
+ _print_invite_hint(error)
128
156
  _print_debug(error)
129
157
  sys.exit(3)
130
158
  elif error.status_code >= 500:
@@ -0,0 +1,222 @@
1
+ """tl resets — banked usage resets: list them and spend one.
2
+
3
+ A usage reset refills your weekly credits to your plan's allotment and
4
+ restarts your 5-hour session. Spending one is always your explicit choice.
5
+ """
6
+
7
+ import json
8
+ import sys
9
+ from datetime import datetime
10
+
11
+ import typer
12
+ from rich.console import Console
13
+ from rich.markup import escape
14
+ from rich.table import Table
15
+
16
+ from tl_cli._typer_utils import AlphaSortedTyperGroup
17
+ from tl_cli.client.errors import ApiError, handle_api_error
18
+ from tl_cli.client.http import get_client
19
+ from tl_cli.output.formatter import detect_format
20
+
21
+ app = typer.Typer(cls=AlphaSortedTyperGroup, help="Usage resets: list them and spend one (free)")
22
+ console = Console()
23
+ err = Console(stderr=True)
24
+
25
+ SOURCE_LABELS = {
26
+ "welcome": "Gift from ThoughtLeaders",
27
+ "referred_bonus": "You were invited",
28
+ "referral_signup": "Your invite was accepted",
29
+ "referral_bonus": "Your invitee's first proposal or payment",
30
+ "admin_grant": "Added by support",
31
+ }
32
+
33
+ STATUS_LABELS = {
34
+ "issued": "Available",
35
+ "used": "Used",
36
+ "expired": "Expired",
37
+ "capped": "Over the limit",
38
+ "voided": "Removed",
39
+ }
40
+
41
+ # Refusals of `tl resets use`. None of them consume a reset; the server's
42
+ # `detail` says why, so it is shown as is.
43
+ REFUSAL_CODES = {"nothing_to_restore", "reset_not_eligible", "resets_disabled", "no_reset_available"}
44
+
45
+ DISABLED_MESSAGE = "Usage resets aren't available on your account."
46
+ HISTORY_LIMIT = 10
47
+
48
+
49
+ def _label(mapping: dict[str, str], value: str | None) -> str:
50
+ return mapping.get(value or "", value or "")
51
+
52
+
53
+ def _day(value: str | None) -> str:
54
+ """An ISO timestamp as its calendar date; anything unparseable as is."""
55
+ if not value:
56
+ return ""
57
+ try:
58
+ return datetime.fromisoformat(value.replace("Z", "+00:00")).date().isoformat()
59
+ except ValueError:
60
+ return value
61
+
62
+
63
+ def _plural(n: int, word: str) -> str:
64
+ return f"{n} {word}" if n == 1 else f"{n} {word}s"
65
+
66
+
67
+ def _interactive() -> bool:
68
+ return sys.stdin.isatty()
69
+
70
+
71
+ def _render_resets(data: dict) -> None:
72
+ if not data.get("enabled"):
73
+ console.print(DISABLED_MESSAGE)
74
+ return
75
+
76
+ available = data.get("available") or []
77
+ console.print(f"\n[bold]Usage resets available:[/bold] [cyan]{len(available)}[/cyan]")
78
+ console.print(
79
+ "[dim]A reset refills your weekly credits to your plan's allotment "
80
+ "and restarts your 5-hour session.[/dim]"
81
+ )
82
+ if not data.get("eligible", True):
83
+ console.print("[yellow]Resets can't be spent on your current plan.[/yellow]")
84
+
85
+ if available:
86
+ table = Table(title="Available")
87
+ table.add_column("Reason")
88
+ table.add_column("Expires")
89
+ for reset in available:
90
+ table.add_row(_label(SOURCE_LABELS, reset.get("source")), _day(reset.get("expires_at")))
91
+ console.print(table)
92
+ if data.get("eligible", True):
93
+ console.print("Spend one with: [bold]tl resets use[/bold]")
94
+
95
+ history = data.get("history") or []
96
+ if history:
97
+ table = Table(title="Recent history")
98
+ table.add_column("Reason")
99
+ table.add_column("Status")
100
+ table.add_column("Granted")
101
+ table.add_column("Used / expires")
102
+ for reset in history[:HISTORY_LIMIT]:
103
+ when = reset.get("used_at") if reset.get("status") == "used" else reset.get("expires_at")
104
+ table.add_row(
105
+ _label(SOURCE_LABELS, reset.get("source")),
106
+ _label(STATUS_LABELS, reset.get("status")),
107
+ _day(reset.get("granted_at")),
108
+ _day(when),
109
+ )
110
+ console.print(table)
111
+
112
+ link = data.get("referral_link")
113
+ if link:
114
+ console.print(
115
+ "\nInvite a friend outside your organization. "
116
+ f"You'll get a free reset when they join: {escape(link)}"
117
+ )
118
+ bonus = data.get("bonus_resets")
119
+ if bonus:
120
+ console.print(
121
+ f"[dim]You get {_plural(bonus, 'more reset')} when their organization "
122
+ "makes its first proposal or payment.[/dim]"
123
+ )
124
+
125
+ referrals = data.get("referrals") or {}
126
+ made = referrals.get("made") or 0
127
+ valid = referrals.get("valid") or 0
128
+ if made:
129
+ console.print(f"{_plural(made, 'user')} signed up with your link")
130
+ if valid:
131
+ console.print(f"{_plural(valid, 'user')} earned you a reset")
132
+
133
+ expiry_days = data.get("expiry_days")
134
+ if expiry_days:
135
+ console.print(f"[dim]Resets expire {expiry_days} days after they're granted.[/dim]")
136
+
137
+
138
+ def _render_use(result: dict) -> None:
139
+ console.print("[green]Usage reset spent.[/green]")
140
+ console.print(
141
+ f"Weekly credits: {result.get('weekly_before')} → "
142
+ f"[cyan]{result.get('weekly_after')}[/cyan] credits"
143
+ )
144
+ if result.get("session_reanchored"):
145
+ console.print("Your 5-hour session restarted.")
146
+ left = result.get("available")
147
+ if left is not None:
148
+ console.print(f"Resets left: [cyan]{left}[/cyan]")
149
+
150
+
151
+ @app.callback(invoke_without_command=True)
152
+ def resets(
153
+ ctx: typer.Context,
154
+ json_output: bool = typer.Option(False, "--json", help="JSON output"),
155
+ ) -> None:
156
+ """Show your usage resets, your invite link and referrals (free, no credits).
157
+
158
+ Examples:
159
+ tl resets
160
+ tl resets --json
161
+ tl resets use
162
+ """
163
+ if ctx.invoked_subcommand is not None:
164
+ return
165
+
166
+ fmt = detect_format(json_output, False, False)
167
+ client = get_client()
168
+ try:
169
+ data = client.get("/resets")
170
+ except ApiError as e:
171
+ handle_api_error(e)
172
+ return
173
+ finally:
174
+ client.close()
175
+
176
+ if fmt == "json":
177
+ print(json.dumps(data, indent=2, default=str))
178
+ return
179
+ _render_resets(data)
180
+
181
+
182
+ @app.command("use")
183
+ def use_cmd(
184
+ yes: bool = typer.Option(False, "--yes", "-y", help="Spend without asking for confirmation"),
185
+ json_output: bool = typer.Option(False, "--json", help="JSON output"),
186
+ ) -> None:
187
+ """Spend one usage reset (the one that expires first).
188
+
189
+ Refills your weekly credits to your plan's allotment and restarts your
190
+ 5-hour session. Asks for confirmation unless --yes is passed or the
191
+ session isn't interactive.
192
+
193
+ Examples:
194
+ tl resets use
195
+ tl resets use --yes --json
196
+ """
197
+ fmt = detect_format(json_output, False, False)
198
+ if not yes and _interactive():
199
+ if not typer.confirm(
200
+ "Spend one usage reset? It refills your weekly credits and restarts your 5-hour session.",
201
+ err=True,
202
+ ):
203
+ err.print("No reset spent.")
204
+ raise typer.Exit(1)
205
+
206
+ client = get_client()
207
+ try:
208
+ result = client.post("/resets/use")
209
+ except ApiError as e:
210
+ code = e.raw.get("code") if isinstance(e.raw, dict) else None
211
+ if code in REFUSAL_CODES:
212
+ err.print(f"[yellow]{escape(e.detail)}[/yellow]")
213
+ raise typer.Exit(5 if e.status_code == 403 else 1)
214
+ handle_api_error(e)
215
+ return
216
+ finally:
217
+ client.close()
218
+
219
+ if fmt == "json":
220
+ print(json.dumps(result, indent=2, default=str))
221
+ return
222
+ _render_use(result)
tl_cli/main.py CHANGED
@@ -30,6 +30,7 @@ from tl_cli.commands.profiles import app as profiles_app
30
30
  from tl_cli.commands.proposals import app as proposals_app
31
31
  from tl_cli.commands.recommender import app as recommender_app
32
32
  from tl_cli.commands.reports import app as reports_app
33
+ from tl_cli.commands.resets import app as resets_app
33
34
  from tl_cli.commands.schema import app as schema_app
34
35
  from tl_cli.commands.setup import app as setup_app
35
36
  from tl_cli.commands.skills import app as skills_app
@@ -124,6 +125,7 @@ app.add_typer(describe_app, name="describe")
124
125
  app.add_typer(schema_app, name="schema")
125
126
  app.add_typer(balance_app, name="balance")
126
127
  app.add_typer(credits_app, name="credits")
128
+ app.add_typer(resets_app, name="resets")
127
129
  app.add_typer(doctor_app, name="doctor")
128
130
  app.add_typer(whoami_app, name="whoami")
129
131
  app.add_typer(agent_app, name="agent")