m3triq 0.2.1 → 0.2.2

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/dist/cli.js CHANGED
@@ -23,7 +23,7 @@ const program = new Command();
23
23
  program
24
24
  .name('m3t')
25
25
  .description('M3TRIQ — protein-ligand analysis from the terminal')
26
- .version('0.2.1')
26
+ .version('0.2.2')
27
27
  .option('--json', 'Output as JSON (machine-readable)')
28
28
  .hook('preAction', (thisCommand) => {
29
29
  const opts = thisCommand.optsWithGlobals();
package/dist/client.js CHANGED
@@ -20,6 +20,18 @@ export class M3triqClient {
20
20
  });
21
21
  if (!res.ok) {
22
22
  const text = await res.text();
23
+ if (res.status === 402) {
24
+ let code = '';
25
+ try {
26
+ const j = JSON.parse(text);
27
+ code = j.code || j.error || '';
28
+ }
29
+ catch { /* not JSON */ }
30
+ if (code === 'subscription_required') {
31
+ throw new Error('Your free trial has ended. Subscribe to Pro to continue:\n console.m3triq.com/profile');
32
+ }
33
+ throw new Error('Out of credits. Top up or subscribe at console.m3triq.com/profile');
34
+ }
23
35
  throw new Error(`API error ${res.status}: ${text.substring(0, 200)}`);
24
36
  }
25
37
  return res.json();
@@ -35,14 +35,21 @@ export function registerCreditsCommands(program) {
35
35
  return;
36
36
  }
37
37
  const remainingClass = q.is_quota_exceeded ? '!! EXHAUSTED' : '';
38
+ const isTrial = q.tier === 'free' || q.tier === 'beta';
39
+ const trialEnds = q.trial_ends_at ? new Date(q.trial_ends_at).toLocaleDateString() : null;
38
40
  const periodEnd = q.period_end ? new Date(q.period_end).toLocaleDateString() : '—';
39
- const lines = [
40
- `Tier: ${q.tier}`,
41
- `Used: ${formatCredits(q.credits_used)} / ${formatCredits(q.monthly_credits)} ${progressBar(q.credits_used, q.monthly_credits)} ${formatPercentage(q.usage_percentage || 0)}`,
42
- `Top-up: ${formatCredits(q.topup_credits)}`,
43
- `Remaining: ${formatCredits(q.credits_remaining)} ${remainingClass}`.trimEnd(),
44
- `Resets: ${periodEnd}`,
45
- ];
41
+ const lines = [`Tier: ${q.tier}`];
42
+ if (isTrial) {
43
+ lines.push(q.in_trial
44
+ ? `Trial: ${q.trial_days_remaining ?? 0} day(s) left${trialEnds ? ` — ends ${trialEnds}` : ''}`
45
+ : `Trial: ENDED — subscribe to continue`);
46
+ }
47
+ lines.push(`Used: ${formatCredits(q.credits_used)} / ${formatCredits(q.monthly_credits)} ${progressBar(q.credits_used, q.monthly_credits)} ${formatPercentage(q.usage_percentage || 0)}`, `Top-up: ${formatCredits(q.topup_credits)}${q.topup_locked ? ' (locked — subscribe to use)' : ''}`, `Remaining: ${formatCredits(q.credits_remaining)} ${remainingClass}`.trimEnd());
48
+ if (!isTrial)
49
+ lines.push(`Resets: ${periodEnd}`);
50
+ if (q.has_access === false) {
51
+ lines.push('', 'Subscribe to Pro to keep using M3TRIQ: console.m3triq.com/profile');
52
+ }
46
53
  output(q, lines.join('\n'));
47
54
  });
48
55
  credits
package/dist/types.d.ts CHANGED
@@ -163,6 +163,11 @@ export interface CreditQuota {
163
163
  is_quota_exceeded: boolean;
164
164
  last_used?: string | null;
165
165
  recent_events?: CreditUsageLogEntry[];
166
+ trial_ends_at?: string | null;
167
+ has_access?: boolean;
168
+ in_trial?: boolean;
169
+ trial_days_remaining?: number | null;
170
+ topup_locked?: boolean;
166
171
  }
167
172
  export interface CreditLogResponse {
168
173
  count: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "m3triq",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "M3TRIQ — protein-ligand analysis from the terminal",
5
5
  "type": "module",
6
6
  "bin": {