Skip to content

Commit 7499691

Browse files
authored
Merge pull request #60 from atxp-dev/naveen/referral-system
fix(agent): pass --redeem referral code to registration endpoint
2 parents d47e621 + 2946666 commit 7499691

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/atxp/src/commands/agent.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ function showAgentHelp(): void {
5454
console.log();
5555
console.log(chalk.bold('Register Options:'));
5656
console.log(' ' + chalk.yellow('--server') + ' ' + 'Accounts server URL (default: https://accounts.atxp.ai)');
57+
console.log(' ' + chalk.yellow('--redeem') + ' ' + 'Referral code to redeem at registration (e.g. ref_xxx)');
5758
console.log();
5859
console.log(chalk.bold('Examples:'));
5960
console.log(' npx atxp agent create');
6061
console.log(' npx atxp agent list');
6162
console.log(' npx atxp agent register');
63+
console.log(' npx atxp agent register --redeem ref_xxx');
6264
console.log(' npx atxp agent register --server http://localhost:8016');
6365
console.log(' CONNECTION_TOKEN=<agent_token> npx atxp email inbox');
6466
}
@@ -152,6 +154,7 @@ function getArgValue(flag: string): string | undefined {
152154

153155
async function registerAgent(): Promise<void> {
154156
const baseUrl = getArgValue('--server') || getBaseUrl();
157+
const referralCode = getArgValue('--redeem');
155158

156159
console.log(chalk.gray(`Registering agent at ${baseUrl}...`));
157160

@@ -164,7 +167,7 @@ async function registerAgent(): Promise<void> {
164167
const res = await fetch(`${baseUrl}/agents/register`, {
165168
method: 'POST',
166169
headers: { 'Content-Type': 'application/json', 'X-ATXP-Client': ATXP_CLIENT_HEADER },
167-
body: JSON.stringify({ ctx }),
170+
body: JSON.stringify({ ctx, ...(referralCode ? { referralCode } : {}) }),
168171
});
169172

170173
if (!res.ok) {

0 commit comments

Comments
 (0)