@trawlme/cli 3.17.0 → 3.18.0
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 +1 -0
- package/dist/commands/referral.d.ts +2 -0
- package/dist/commands/referral.js +38 -0
- package/dist/index.js +2 -0
- package/dist/lib/referral.d.ts +6 -0
- package/dist/lib/referral.js +7 -0
- package/dist/lib/tips.js +2 -1
- package/docs/agent-quickstart.md +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,7 @@ trawl whoami [--json] Show the authenticated user's ide
|
|
|
62
62
|
trawl orgs list [--json] List your organizations (id, name, role) — session login only; bare `trawl orgs` is the same
|
|
63
63
|
trawl orgs current [--json] Show the current organization
|
|
64
64
|
trawl orgs switch <id> [--json] Switch the current organization (403 = not a member)
|
|
65
|
+
trawl referral [--json] Print your personal referral link and the reward — session login only
|
|
65
66
|
trawl token [--json] Print the stored credential — API key or session JWT (for MCP Bearer auth)
|
|
66
67
|
trawl ping [--json] Health/version handshake against the Trawl API
|
|
67
68
|
trawl spec [--json] Print a versioned, machine-readable description of the command tree
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { api, apiKeyUnsupportedError } from '../lib/api.js';
|
|
4
|
+
import { getApiUrl, getAuthMode } from '../lib/config.js';
|
|
5
|
+
import { deriveDocsOrigin } from '../lib/docs.js';
|
|
6
|
+
import { json } from '../lib/format.js';
|
|
7
|
+
import { REFERRAL_REWARD_LINE } from '../lib/referral.js';
|
|
8
|
+
const UNAVAILABLE = 'Referral links are not available for this account.';
|
|
9
|
+
const CODE_SHAPE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
10
|
+
export const referral = new Command('referral')
|
|
11
|
+
.description('Print your personal referral link and the reward')
|
|
12
|
+
.option('--json', 'Output as JSON')
|
|
13
|
+
.action(async (opts) => {
|
|
14
|
+
if (getAuthMode() === 'apiKey') {
|
|
15
|
+
throw apiKeyUnsupportedError('trawl referral');
|
|
16
|
+
}
|
|
17
|
+
const me = await api.get('/api/users/me');
|
|
18
|
+
const raw = me?.referralCode;
|
|
19
|
+
const code = typeof raw === 'string' && CODE_SHAPE.test(raw) ? raw : '';
|
|
20
|
+
if (!code) {
|
|
21
|
+
if (opts.json)
|
|
22
|
+
json({ referralCode: null, referralLink: null, message: UNAVAILABLE });
|
|
23
|
+
else
|
|
24
|
+
console.log(chalk.dim(UNAVAILABLE));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const origin = deriveDocsOrigin(getApiUrl());
|
|
28
|
+
const link = origin ? `${origin.protocol}//${origin.host}/signup?ref=${code}` : null;
|
|
29
|
+
if (opts.json) {
|
|
30
|
+
json({ referralCode: code, referralLink: link, reward: REFERRAL_REWARD_LINE });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (link)
|
|
34
|
+
console.log(chalk.bold(link));
|
|
35
|
+
else
|
|
36
|
+
console.log(`Referral code: ${chalk.bold(code)} ${chalk.dim('(web app URL unknown for this API base)')}`);
|
|
37
|
+
console.log(chalk.dim(REFERRAL_REWARD_LINE));
|
|
38
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { whoami } from './commands/whoami.js';
|
|
|
15
15
|
import { ping } from './commands/ping.js';
|
|
16
16
|
import { admin } from './commands/admin.js';
|
|
17
17
|
import { orgs } from './commands/orgs.js';
|
|
18
|
+
import { referral } from './commands/referral.js';
|
|
18
19
|
import { spec } from './commands/spec.js';
|
|
19
20
|
import { autoUpdateInstalledSkills } from './lib/skills.js';
|
|
20
21
|
import { maybeSuggestSkillsInstall } from './lib/skillsNudge.js';
|
|
@@ -74,6 +75,7 @@ export function createProgram() {
|
|
|
74
75
|
program.addCommand(skills);
|
|
75
76
|
program.addCommand(admin, { hidden: true });
|
|
76
77
|
program.addCommand(orgs);
|
|
78
|
+
program.addCommand(referral);
|
|
77
79
|
program.addCommand(login);
|
|
78
80
|
program.addCommand(logout);
|
|
79
81
|
program.addCommand(telemetry);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const REFERRAL_REWARD = {
|
|
2
|
+
referee: 1_500,
|
|
3
|
+
referrer: 3_000,
|
|
4
|
+
};
|
|
5
|
+
const fmt = (n) => n.toLocaleString('en-US');
|
|
6
|
+
export const REFERRAL_REWARD_SHORT = `they get ${fmt(REFERRAL_REWARD.referee)}, you get ${fmt(REFERRAL_REWARD.referrer)} compute`;
|
|
7
|
+
export const REFERRAL_REWARD_LINE = `Each friend who signs up with your link gets ${fmt(REFERRAL_REWARD.referee)} free compute; you get ${fmt(REFERRAL_REWARD.referrer)}.`;
|
package/dist/lib/tips.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import config from './config.js';
|
|
3
3
|
import { api } from './api.js';
|
|
4
|
+
import { REFERRAL_REWARD_SHORT } from './referral.js';
|
|
4
5
|
const TIP_THROTTLE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
5
6
|
const FLAG_CHECK_TIMEOUT_MS = 2_000;
|
|
6
|
-
const REFERRAL_TIP_TEXT =
|
|
7
|
+
const REFERRAL_TIP_TEXT = `Invite a builder — ${REFERRAL_REWARD_SHORT} → run \`trawl referral\``;
|
|
7
8
|
function isOptedOut() {
|
|
8
9
|
if (process.env['TRAWL_NO_TIPS'] !== undefined)
|
|
9
10
|
return true;
|
package/docs/agent-quickstart.md
CHANGED
|
@@ -89,6 +89,7 @@ trawl data <id> [--json] [--fresh] [--errors] Get scrap data (last persisted ru
|
|
|
89
89
|
trawl runs|history <id> [--json] [-n <limit>] List past runs for a scrap
|
|
90
90
|
trawl run-info <hid> [--json] Show details of a single run
|
|
91
91
|
trawl whoami [--json] Show the authenticated user's identity
|
|
92
|
+
trawl referral [--json] Print your personal referral link and the reward — session login only
|
|
92
93
|
trawl token [--json] Print the stored credential — API key or session JWT (for MCP Bearer auth)
|
|
93
94
|
trawl ping [--json] Health/version handshake against the Trawl API
|
|
94
95
|
trawl spec [--json] Print a versioned, machine-readable description of the command tree
|