agentbundle-cli 0.1.2 → 0.2.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 +17 -17
- package/bin/agent-bundle.js +23 -53
- package/lib/agentcard-api.js +11 -1
- package/lib/mcp.js +1 -2
- package/lib/steps/agentcard.js +21 -47
- package/lib/steps/agentmail.js +26 -139
- package/lib/steps/agentphone.js +10 -31
- package/lib/steps/bundle.js +136 -0
- package/lib/ui.js +3 -1
- package/package.json +2 -10
package/README.md
CHANGED
|
@@ -5,22 +5,27 @@ One command to give your AI agent the three things it needs to act online — a
|
|
|
5
5
|
you through installing all three, one at a time, and registers each as an MCP server.
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npx
|
|
8
|
+
npx agent-bundle
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## What it does
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
link and the AgentMail + AgentPhone verification codes), then runs a guided, three-step onboarding:
|
|
13
|
+
A guided, three-step onboarding:
|
|
15
14
|
|
|
16
15
|
1. **Agentcard** — installs the `agent-cards` CLI, signs you up (one magic-link email click),
|
|
17
16
|
registers + authenticates the MCP server via `agent-cards setup-mcp` (hosted HTTP), and offers
|
|
18
17
|
to switch to production (real cards).
|
|
19
|
-
2. **AgentMail** —
|
|
20
|
-
|
|
21
|
-
(`mcp.agentmail.to`). Sign-ups are tagged with the `agentbundle` referrer.
|
|
18
|
+
2. **AgentMail** — takes your API key (or points you to the console to make one) and registers the
|
|
19
|
+
hosted HTTP MCP server (`mcp.agentmail.to`).
|
|
22
20
|
3. **AgentPhone** — fully automated: requests a verification code by email, you type it in, it
|
|
23
21
|
provisions a real US number, and registers the stdio MCP server (`npx -y agentphone-mcp`). No browser.
|
|
22
|
+
4. **Agent Bundle** — with all three installed, it offers the bundle subscription: **$20/mo** for
|
|
23
|
+
Agentcard + AgentMail + AgentPhone together (about half of buying them standalone). It opens a
|
|
24
|
+
Stripe-hosted checkout on the bundle server (theagentbundle.com), keyed by your email — no charge
|
|
25
|
+
until you enter a card and confirm on Stripe's page. Re-run with `--only bundle` anytime.
|
|
26
|
+
|
|
27
|
+
Every account is created in **production** — real inboxes, real numbers, and live Agentcard cards.
|
|
28
|
+
There is no test or sandbox mode.
|
|
24
29
|
|
|
25
30
|
All MCP servers are registered at **user scope** (available in every project), via `claude mcp add`.
|
|
26
31
|
|
|
@@ -30,9 +35,7 @@ It's **idempotent** — anything already configured is skipped, so it's safe to
|
|
|
30
35
|
|
|
31
36
|
| Flag | Effect |
|
|
32
37
|
|---|---|
|
|
33
|
-
| `--only <agentcard\|agentmail\|agentphone>` | Run just one product. |
|
|
34
|
-
| `--email <you@example.com>` | Email used for all three sign-ups (skips the up-front prompt). |
|
|
35
|
-
| `--sandbox` | Walk the whole flow with stub signups + a throwaway config — no real accounts, no charges. |
|
|
38
|
+
| `--only <agentcard\|agentmail\|agentphone\|bundle>` | Run just one product, or `bundle` for the $20/mo bundle checkout. |
|
|
36
39
|
| `--dry-run` | Print what it would do, change nothing. |
|
|
37
40
|
| `--yes`, `-y` | Accept defaults, skip confirmations. |
|
|
38
41
|
| `--no-color` | Plain output. |
|
|
@@ -41,20 +44,17 @@ It's **idempotent** — anything already configured is skipped, so it's safe to
|
|
|
41
44
|
## Skip prompts with env vars
|
|
42
45
|
|
|
43
46
|
```bash
|
|
44
|
-
export
|
|
45
|
-
export AGENTMAIL_API_KEY=am_... # already have a key? skip the AgentMail sign-up
|
|
47
|
+
export AGENTMAIL_API_KEY=am_...
|
|
46
48
|
export AGENTPHONE_API_KEY=sk_live_...
|
|
47
|
-
npx
|
|
49
|
+
npx agent-bundle
|
|
48
50
|
```
|
|
49
51
|
|
|
50
|
-
##
|
|
52
|
+
## Preview without changing anything
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
config is never touched and no money is spent:
|
|
54
|
+
Use `--dry-run` to print every step it would take without touching your config or creating accounts:
|
|
54
55
|
|
|
55
56
|
```bash
|
|
56
|
-
|
|
57
|
-
cat /tmp/bundle-test.json
|
|
57
|
+
npx agent-bundle --dry-run
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
## How config is written
|
package/bin/agent-bundle.js
CHANGED
|
@@ -4,35 +4,30 @@
|
|
|
4
4
|
|
|
5
5
|
const ui = require('../lib/ui');
|
|
6
6
|
const mcp = require('../lib/mcp');
|
|
7
|
-
const ac = require('../lib/agentcard-api');
|
|
8
7
|
const agentcard = require('../lib/steps/agentcard');
|
|
9
8
|
const agentmail = require('../lib/steps/agentmail');
|
|
10
9
|
const agentphone = require('../lib/steps/agentphone');
|
|
10
|
+
const bundle = require('../lib/steps/bundle');
|
|
11
11
|
|
|
12
|
-
const MODULES = {
|
|
13
|
-
agentcard,
|
|
14
|
-
agentmail,
|
|
15
|
-
agentphone,
|
|
16
|
-
};
|
|
17
12
|
const STEPS = {
|
|
18
13
|
agentcard: agentcard.step,
|
|
19
14
|
agentmail: agentmail.step,
|
|
20
15
|
agentphone: agentphone.step,
|
|
21
16
|
};
|
|
22
17
|
|
|
18
|
+
// The bundle subscription runs after the three products, not as one of them.
|
|
19
|
+
const ONLY_TARGETS = new Set([...Object.keys(STEPS), 'bundle']);
|
|
20
|
+
|
|
23
21
|
function parseArgs(argv) {
|
|
24
|
-
const ctx = { dryRun: false,
|
|
22
|
+
const ctx = { dryRun: false, yes: false, only: null, help: false };
|
|
25
23
|
for (let i = 0; i < argv.length; i++) {
|
|
26
24
|
const a = argv[i];
|
|
27
25
|
if (a === '--dry-run') ctx.dryRun = true;
|
|
28
|
-
else if (a === '--sandbox') ctx.sandbox = true;
|
|
29
26
|
else if (a === '--yes' || a === '-y') ctx.yes = true;
|
|
30
27
|
else if (a === '--no-color') {/* handled in ui */}
|
|
31
28
|
else if (a === '--help' || a === '-h') ctx.help = true;
|
|
32
29
|
else if (a === '--only') ctx.only = (argv[++i] || '').toLowerCase();
|
|
33
30
|
else if (a.startsWith('--only=')) ctx.only = a.slice(7).toLowerCase();
|
|
34
|
-
else if (a === '--email') ctx.email = (argv[++i] || '').trim();
|
|
35
|
-
else if (a.startsWith('--email=')) ctx.email = a.slice(8).trim();
|
|
36
31
|
}
|
|
37
32
|
return ctx;
|
|
38
33
|
}
|
|
@@ -42,16 +37,13 @@ function help() {
|
|
|
42
37
|
ui.info('Guided setup for your agent\'s card, inbox, and phone.\n');
|
|
43
38
|
ui.info(ui.c.bold('Usage:') + ' npx agentbundle-cli [options]\n');
|
|
44
39
|
ui.info(ui.c.bold('Options:'));
|
|
45
|
-
ui.dim('--only <agentcard|agentmail|agentphone> run just one product');
|
|
46
|
-
ui.dim('--email <you@example.com> email used for all three sign-ups (skips the prompt)');
|
|
47
|
-
ui.dim('--sandbox walk the whole flow with stub signups + a throwaway config (no money, no real accounts)');
|
|
40
|
+
ui.dim('--only <agentcard|agentmail|agentphone|bundle> run just one product (or the $20/mo bundle checkout)');
|
|
48
41
|
ui.dim('--dry-run print what it would do, change nothing');
|
|
49
42
|
ui.dim('--yes, -y accept defaults, skip confirmations');
|
|
50
43
|
ui.dim('--no-color disable colored output');
|
|
51
44
|
ui.dim('--help, -h show this help');
|
|
52
45
|
ui.blank();
|
|
53
|
-
ui.info(ui.c.bold('Pre-set to skip prompts:') + '
|
|
54
|
-
ui.info(ui.c.bold('Test safely:') + ' AGENT_BUNDLE_MCP_CONFIG=/tmp/x.json npx agentbundle-cli --sandbox');
|
|
46
|
+
ui.info(ui.c.bold('Pre-set keys to skip prompts:') + ' AGENTMAIL_API_KEY, AGENTPHONE_API_KEY');
|
|
55
47
|
ui.blank();
|
|
56
48
|
}
|
|
57
49
|
|
|
@@ -59,31 +51,12 @@ function icon(kind) {
|
|
|
59
51
|
return kind === 'ok' ? ui.c.green('✓') : kind === 'warn' ? ui.c.yellow('!') : ui.c.red('✗');
|
|
60
52
|
}
|
|
61
53
|
|
|
62
|
-
// One email drives all three sign-ups (Agentcard magic link, AgentMail + AgentPhone OTP). Collect
|
|
63
|
-
// it once up front so each product reuses it instead of asking three times. Stores it on ctx.email.
|
|
64
|
-
async function collectEmail(ctx) {
|
|
65
|
-
if (ctx.email && ac.isValidEmail(ctx.email)) return ctx.email; // from --email / AGENT_BUNDLE_EMAIL
|
|
66
|
-
if (ctx.sandbox) { ctx.email = 'agent@sandbox.local'; return ctx.email; }
|
|
67
|
-
// An invalid --email / AGENT_BUNDLE_EMAIL with no TTY to fix it must be cleared, otherwise the
|
|
68
|
-
// steps would post the bad value to the signup APIs and fail. Treat it as "no email set".
|
|
69
|
-
if (ctx.dryRun || !process.stdin.isTTY) { ctx.email = ''; return ''; }
|
|
70
|
-
for (let tries = 0; tries < 3; tries++) {
|
|
71
|
-
const entered = await ui.ask("What email should your agent's card, inbox, and phone use?");
|
|
72
|
-
if (!entered) break;
|
|
73
|
-
if (ac.isValidEmail(entered)) { ctx.email = entered; return entered; }
|
|
74
|
-
ui.warn("That doesn't look like an email — try again.");
|
|
75
|
-
}
|
|
76
|
-
ctx.email = '';
|
|
77
|
-
return '';
|
|
78
|
-
}
|
|
79
|
-
|
|
80
54
|
async function main() {
|
|
81
55
|
const ctx = parseArgs(process.argv.slice(2));
|
|
82
56
|
if (ctx.help) return help();
|
|
83
57
|
|
|
84
58
|
ui.banner();
|
|
85
59
|
if (ctx.dryRun) ui.warn('DRY RUN — nothing will be changed.');
|
|
86
|
-
if (ctx.sandbox) ui.warn('SANDBOX — stub signups, throwaway config, no real accounts or charges.');
|
|
87
60
|
|
|
88
61
|
// Preflight
|
|
89
62
|
ui.heading(0, 3, 'Preflight');
|
|
@@ -93,29 +66,15 @@ async function main() {
|
|
|
93
66
|
|
|
94
67
|
let order = ['agentcard', 'agentmail', 'agentphone'];
|
|
95
68
|
if (ctx.only) {
|
|
96
|
-
if (!
|
|
97
|
-
ui.fail(`Unknown --only target: ${ctx.only} (use agentcard | agentmail | agentphone)`);
|
|
69
|
+
if (!ONLY_TARGETS.has(ctx.only)) {
|
|
70
|
+
ui.fail(`Unknown --only target: ${ctx.only} (use agentcard | agentmail | agentphone | bundle)`);
|
|
98
71
|
process.exit(2);
|
|
99
72
|
}
|
|
100
|
-
order = [ctx.only];
|
|
73
|
+
order = ctx.only === 'bundle' ? [] : [ctx.only];
|
|
101
74
|
}
|
|
102
75
|
|
|
103
|
-
//
|
|
104
|
-
|
|
105
|
-
// for it again. A pre-set --email / AGENT_BUNDLE_EMAIL skips the prompt entirely.
|
|
106
|
-
// Only prompt when a selected product actually needs signup; if everything is already
|
|
107
|
-
// configured the prompt is skipped and the run stays a clean no-op.
|
|
108
|
-
if (!ctx.dryRun) {
|
|
109
|
-
const needEmail = order.some((key) => MODULES[key].needsSetup(ctx));
|
|
110
|
-
if (needEmail) {
|
|
111
|
-
ui.blank();
|
|
112
|
-
ui.info(ui.c.bold(ui.c.blue('Step one — your email')));
|
|
113
|
-
ui.dim('Asked once here, then reused for the sign-ups below — you won\'t be asked again.');
|
|
114
|
-
await collectEmail(ctx);
|
|
115
|
-
if (ctx.email) ui.ok('Using ' + ui.c.bold(ctx.email) + ' for the products that need it.');
|
|
116
|
-
else ui.warn('No email set up front — each product will ask only if it needs one.');
|
|
117
|
-
}
|
|
118
|
-
}
|
|
76
|
+
// The $20/mo bundle is offered after a full run, or when explicitly requested.
|
|
77
|
+
const runBundle = !ctx.only || ctx.only === 'bundle';
|
|
119
78
|
|
|
120
79
|
if (!ctx.yes && !ctx.dryRun) {
|
|
121
80
|
ui.blank();
|
|
@@ -138,6 +97,17 @@ async function main() {
|
|
|
138
97
|
}
|
|
139
98
|
}
|
|
140
99
|
|
|
100
|
+
// Offer the $20/mo bundle once the products are in place.
|
|
101
|
+
if (runBundle) {
|
|
102
|
+
ui.blank();
|
|
103
|
+
try {
|
|
104
|
+
results.push(await bundle.step(ctx));
|
|
105
|
+
} catch (e) {
|
|
106
|
+
ui.fail(`bundle crashed: ${e.message}`);
|
|
107
|
+
results.push({ product: 'Bundle', icon: 'fail', note: e.message });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
141
111
|
// Summary
|
|
142
112
|
ui.blank();
|
|
143
113
|
ui.info(ui.c.bold('── Summary ──────────────────────────────────────────'));
|
package/lib/agentcard-api.js
CHANGED
|
@@ -88,7 +88,6 @@ async function requestMagicLink(email) {
|
|
|
88
88
|
// Poll until the user clicks the magic link. Returns { jwt, email, mode }.
|
|
89
89
|
async function waitForVerification(sessionId, { intervalMs = 2500, timeoutMs = 10 * 60 * 1000 } = {}) {
|
|
90
90
|
const deadline = Date.now() + timeoutMs;
|
|
91
|
-
// Date.now is fine at runtime; this module is never run inside the workflow sandbox.
|
|
92
91
|
for (;;) {
|
|
93
92
|
const r = await getJson('/auth/me', { 'X-Magic-Token': sessionId });
|
|
94
93
|
if (r.ok && r.data && r.data.status === 'verified' && r.data.jwt) {
|
|
@@ -103,6 +102,16 @@ function isValidEmail(s) {
|
|
|
103
102
|
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s);
|
|
104
103
|
}
|
|
105
104
|
|
|
105
|
+
// Put the signed-in account into production mode (real cards). New accounts are
|
|
106
|
+
// created live, so we call this right after signup. Returns the resulting mode.
|
|
107
|
+
async function setMode(jwt, mode) {
|
|
108
|
+
const r = await postJson('/users/me/mode', { mode }, { Authorization: `Bearer ${jwt}` });
|
|
109
|
+
if (!r.ok) throw new Error(r.data.error || r.data.message || `mode change failed (HTTP ${r.status})`);
|
|
110
|
+
// Keep the local config in sync with the account's mode.
|
|
111
|
+
writeConfig({ mode });
|
|
112
|
+
return r.data.mode || mode;
|
|
113
|
+
}
|
|
114
|
+
|
|
106
115
|
module.exports = {
|
|
107
116
|
SOURCE,
|
|
108
117
|
API_URL,
|
|
@@ -111,4 +120,5 @@ module.exports = {
|
|
|
111
120
|
requestMagicLink,
|
|
112
121
|
waitForVerification,
|
|
113
122
|
isValidEmail,
|
|
123
|
+
setMode,
|
|
114
124
|
};
|
package/lib/mcp.js
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
// Two backends, auto-selected:
|
|
5
5
|
// * "claude": uses the `claude` CLI (`claude mcp get` / `claude mcp add`). Default in real use.
|
|
6
6
|
// * "file": merges into a JSON config file. Used when AGENT_BUNDLE_MCP_CONFIG is set, or when
|
|
7
|
-
// `claude` isn't on PATH
|
|
8
|
-
// user's real ~/.claude config.
|
|
7
|
+
// `claude` isn't on PATH — writes to that file instead of the user's ~/.claude config.
|
|
9
8
|
|
|
10
9
|
const { spawnSync } = require('node:child_process');
|
|
11
10
|
const fs = require('node:fs');
|
package/lib/steps/agentcard.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// [1/3] Agentcard — virtual cards. agent-bundle drives the full signup (ask email → magic link →
|
|
3
|
-
// verify), tagging the signup source as `agentbundle`, then registers the MCP server with the JWT
|
|
3
|
+
// verify), tagging the signup source as `agentbundle`, then registers the MCP server with the JWT
|
|
4
|
+
// and puts the account into production (real cards) — there's no test mode in this flow.
|
|
4
5
|
|
|
5
|
-
const { spawnSync } = require('node:child_process');
|
|
6
6
|
const ui = require('../ui');
|
|
7
7
|
const mcp = require('../mcp');
|
|
8
8
|
const ac = require('../agentcard-api');
|
|
@@ -10,21 +10,9 @@ const ac = require('../agentcard-api');
|
|
|
10
10
|
const MCP_NAME = 'agent-cards';
|
|
11
11
|
const MCP_URL = 'https://mcp.agentcard.sh/mcp';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
function run(cmd, args) {
|
|
18
|
-
ui.pause();
|
|
19
|
-
const r = spawnSync(cmd, args, { stdio: 'inherit' });
|
|
20
|
-
ui.resume();
|
|
21
|
-
return !r.error && r.status === 0;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Send the magic link and wait for the click. Reuses the shared email collected up front
|
|
25
|
-
// (ctx.email); only asks if one wasn't provided. Returns the JWT, or null.
|
|
26
|
-
async function completeSignup(ctx) {
|
|
27
|
-
let email = ctx && ctx.email && ac.isValidEmail(ctx.email) ? ctx.email : '';
|
|
13
|
+
// Ask for the email, send the magic link, and wait for the click. Returns the JWT, or null.
|
|
14
|
+
async function completeSignup() {
|
|
15
|
+
let email = '';
|
|
28
16
|
for (let tries = 0; tries < 3 && !email; tries++) {
|
|
29
17
|
const entered = await ui.ask('What email should your Agentcard account use?');
|
|
30
18
|
if (!entered) return null; // blank = skip
|
|
@@ -47,7 +35,7 @@ async function completeSignup(ctx) {
|
|
|
47
35
|
try {
|
|
48
36
|
const { jwt, email: verifiedEmail, mode } = await ac.waitForVerification(sessionId);
|
|
49
37
|
ac.writeConfig({ email: verifiedEmail || email, jwt, mode });
|
|
50
|
-
ui.ok(`Signed in as ${ui.c.bold(verifiedEmail || email)}`
|
|
38
|
+
ui.ok(`Signed in as ${ui.c.bold(verifiedEmail || email)}`);
|
|
51
39
|
return jwt;
|
|
52
40
|
} catch (e) {
|
|
53
41
|
ui.fail('Signup not completed: ' + e.message);
|
|
@@ -67,12 +55,10 @@ async function step(ctx) {
|
|
|
67
55
|
// 1. Get an authenticated session (JWT).
|
|
68
56
|
let jwt;
|
|
69
57
|
if (ctx.dryRun) {
|
|
70
|
-
ui.step('would
|
|
58
|
+
ui.step('would ask for your email, POST /auth/signup (x-platform: agentbundle), and wait for the magic link');
|
|
71
59
|
ui.dim(`would: claude mcp add --transport http ${MCP_NAME} ${MCP_URL} --header "Authorization: Bearer <jwt>"`);
|
|
60
|
+
ui.dim('would: POST /users/me/mode { mode: "prod" } to put the account into production');
|
|
72
61
|
return { product: 'Agentcard', icon: 'ok', note: 'configured (dry-run)' };
|
|
73
|
-
} else if (ctx.sandbox) {
|
|
74
|
-
ui.step('[sandbox] simulating email → magic link → verified');
|
|
75
|
-
jwt = 'sandbox_placeholder_jwt';
|
|
76
62
|
} else if (ac.readConfig().jwt) {
|
|
77
63
|
const cfg = ac.readConfig();
|
|
78
64
|
ui.ok(`Already signed in to Agentcard${cfg.email ? ' as ' + ui.c.bold(cfg.email) : ''} — skipping signup.`);
|
|
@@ -82,7 +68,7 @@ async function step(ctx) {
|
|
|
82
68
|
ui.info('Re-run this in a terminal so it can collect your email and the magic link.');
|
|
83
69
|
return { product: 'Agentcard', icon: 'warn', note: 'needs interactive signup' };
|
|
84
70
|
} else {
|
|
85
|
-
jwt = await completeSignup(
|
|
71
|
+
jwt = await completeSignup();
|
|
86
72
|
if (!jwt) {
|
|
87
73
|
ui.warn('Skipped Agentcard signup — re-run with --only agentcard when ready.');
|
|
88
74
|
return { product: 'Agentcard', icon: 'warn', note: 'signup not completed' };
|
|
@@ -101,32 +87,20 @@ async function step(ctx) {
|
|
|
101
87
|
}
|
|
102
88
|
ui.ok('Agentcard MCP server registered.');
|
|
103
89
|
|
|
104
|
-
// 3.
|
|
105
|
-
let note = 'configured (
|
|
106
|
-
|
|
107
|
-
ui.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
ui.info('Install the CLI (' + ui.c.bold('npm i -g agent-cards') + ') then run ' + ui.c.bold('agent-cards mode prod') + ' to go live.');
|
|
116
|
-
note = 'configured (TEST mode — install CLI to go live)';
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
ui.info('Staying in ' + ui.c.bold('TEST') + ' mode (sandbox cards). Go live anytime with ' + ui.c.bold('agent-cards mode prod') + '.');
|
|
120
|
-
}
|
|
90
|
+
// 3. Put the account into PRODUCTION (real cards). New accounts go live by default.
|
|
91
|
+
let note = 'configured (production)';
|
|
92
|
+
try {
|
|
93
|
+
ui.step('Setting your account to production…');
|
|
94
|
+
await ac.setMode(jwt, 'prod');
|
|
95
|
+
ui.ok('Agentcard account is in ' + ui.c.bold('production') + ' mode.');
|
|
96
|
+
ui.dim('Add a payment method to fund real cards: ' + ui.c.bold('agent-cards payment-method') + ' (or in the dashboard).');
|
|
97
|
+
} catch (e) {
|
|
98
|
+
ui.warn('Could not set production mode automatically: ' + e.message);
|
|
99
|
+
ui.dim('Set it from the dashboard, or run ' + ui.c.bold('agent-cards mode prod') + '.');
|
|
100
|
+
note = 'configured (set production in the dashboard)';
|
|
121
101
|
}
|
|
122
102
|
|
|
123
103
|
return { product: 'Agentcard', icon: 'ok', note };
|
|
124
104
|
}
|
|
125
105
|
|
|
126
|
-
|
|
127
|
-
// Lets the launcher skip the up-front email prompt when nothing needs signup.
|
|
128
|
-
function needsSetup() {
|
|
129
|
-
return !mcp.exists(MCP_NAME) && !ac.readConfig().jwt;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
module.exports = { step, MCP_NAME, needsSetup };
|
|
106
|
+
module.exports = { step, MCP_NAME };
|
package/lib/steps/agentmail.js
CHANGED
|
@@ -1,66 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
// [2/3] AgentMail — an email inbox.
|
|
3
|
-
// Signs up via https://docs.agentmail.to/api-reference/agent/sign-up, tagging referrer=agentbundle,
|
|
4
|
-
// reusing the email collected up front. The sign-up response carries the api_key directly; the OTP
|
|
5
|
-
// verify step lifts the unverified-org send allowlist.
|
|
2
|
+
// [2/3] AgentMail — an email inbox. API-key driven (one console visit only if no key yet).
|
|
6
3
|
|
|
7
4
|
const ui = require('../ui');
|
|
8
5
|
const mcp = require('../mcp');
|
|
9
|
-
const ac = require('../agentcard-api'); // shared email validation (isValidEmail)
|
|
10
6
|
|
|
11
7
|
const MCP_NAME = 'agentmail';
|
|
12
8
|
const MCP_URL = 'https://mcp.agentmail.to/mcp';
|
|
13
|
-
const API = 'https://api.agentmail.to';
|
|
14
9
|
const CONSOLE = 'https://console.agentmail.to';
|
|
15
|
-
const REFERRER = 'agentbundle'; // the channel we report this sign-up came from
|
|
16
|
-
const SOURCE = 'agentbundle-cli'; // platform identifier
|
|
17
|
-
|
|
18
|
-
async function apiPost(path, body, token) {
|
|
19
|
-
const ctrl = new AbortController();
|
|
20
|
-
const t = setTimeout(() => ctrl.abort(), 30000);
|
|
21
|
-
try {
|
|
22
|
-
const res = await fetch(API + path, {
|
|
23
|
-
method: 'POST',
|
|
24
|
-
headers: {
|
|
25
|
-
'Content-Type': 'application/json',
|
|
26
|
-
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
27
|
-
},
|
|
28
|
-
body: JSON.stringify(body),
|
|
29
|
-
signal: ctrl.signal,
|
|
30
|
-
});
|
|
31
|
-
const text = await res.text();
|
|
32
|
-
let data;
|
|
33
|
-
try { data = JSON.parse(text); } catch { data = { raw: text }; }
|
|
34
|
-
return { ok: res.ok, status: res.status, data };
|
|
35
|
-
} catch (e) {
|
|
36
|
-
return { ok: false, status: 0, data: { error: e.message } };
|
|
37
|
-
} finally {
|
|
38
|
-
clearTimeout(t);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Derive an inbox username from the email local-part, plus a short suffix so the globally-unique
|
|
43
|
-
// inbox address (username@agentmail.to) is unlikely to collide with an existing one.
|
|
44
|
-
function usernameFor(email) {
|
|
45
|
-
const local = String(email).split('@')[0].toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
|
46
|
-
const base = local || 'agent';
|
|
47
|
-
const suffix = Math.random().toString(36).slice(2, 6);
|
|
48
|
-
return `${base}-${suffix}`;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function register(key, ctx, extraNote) {
|
|
52
|
-
ui.step('Registering the AgentMail MCP server…');
|
|
53
|
-
const res = mcp.addServer(
|
|
54
|
-
{ name: MCP_NAME, transport: 'http', url: MCP_URL, headers: { 'x-api-key': key } },
|
|
55
|
-
{ dryRun: ctx.dryRun }
|
|
56
|
-
);
|
|
57
|
-
if (res.error) {
|
|
58
|
-
ui.fail('Failed to register MCP server: ' + res.error);
|
|
59
|
-
return { product: 'AgentMail', icon: 'fail', note: res.error };
|
|
60
|
-
}
|
|
61
|
-
ui.ok('AgentMail MCP server registered.');
|
|
62
|
-
return { product: 'AgentMail', icon: 'ok', note: extraNote || 'configured' };
|
|
63
|
-
}
|
|
64
10
|
|
|
65
11
|
async function step(ctx) {
|
|
66
12
|
ui.heading(2, 3, 'AgentMail — an email inbox for your agent');
|
|
@@ -71,94 +17,35 @@ async function step(ctx) {
|
|
|
71
17
|
return { product: 'AgentMail', icon: 'ok', note: 'already configured' };
|
|
72
18
|
}
|
|
73
19
|
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (ctx.dryRun) {
|
|
83
|
-
ui.step('would: POST /v0/agent/sign-up (referrer: agentbundle) → ask for OTP → POST /v0/agent/verify → get am_ key + inbox');
|
|
20
|
+
// Get the API key: env first, else prompt (the one possible browser touch).
|
|
21
|
+
let key = process.env.AGENTMAIL_API_KEY || '';
|
|
22
|
+
if (key) {
|
|
23
|
+
ui.ok(`Using AGENTMAIL_API_KEY from your environment (${ui.mask(key)}).`);
|
|
24
|
+
} else if (ctx.dryRun) {
|
|
25
|
+
ui.step('would prompt for an AgentMail API key (am_…)');
|
|
84
26
|
ui.dim(`would: claude mcp add --transport http ${MCP_NAME} ${MCP_URL} --header "x-api-key: …"`);
|
|
85
27
|
return { product: 'AgentMail', icon: 'ok', note: 'configured (dry-run)' };
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (ctx.sandbox) {
|
|
89
|
-
ui.step('[sandbox] simulating sign-up → OTP → verify…');
|
|
90
|
-
ui.ok('[sandbox] provisioned inbox my-agent@agentmail.to');
|
|
91
|
-
return register('am_sandbox_placeholder_key', ctx, 'configured (sandbox inbox)');
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Real flow — reuse the email collected up front; only ask (with validation) if one wasn't provided.
|
|
95
|
-
let email = ctx.email && ac.isValidEmail(ctx.email) ? ctx.email : '';
|
|
96
|
-
for (let tries = 0; !email && tries < 3; tries++) {
|
|
97
|
-
const entered = await ui.ask('What email should AgentMail send your verification code to?');
|
|
98
|
-
if (!entered) break;
|
|
99
|
-
if (ac.isValidEmail(entered)) email = entered;
|
|
100
|
-
else ui.warn("That doesn't look like an email — try again.");
|
|
101
|
-
}
|
|
102
|
-
if (!email) {
|
|
103
|
-
ui.warn('No email — skipping AgentMail. Re-run later.');
|
|
104
|
-
return { product: 'AgentMail', icon: 'warn', note: 'skipped (no email)' };
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Sign-up is idempotent on human_email (re-signup just rotates the key + returns it), so an
|
|
108
|
-
// existing account isn't a 409 — it returns 200. A 409 is a username collision (the random
|
|
109
|
-
// suffix clashed with another inbox), so retry with a fresh username before giving up.
|
|
110
|
-
ui.step('Creating your AgentMail inbox…');
|
|
111
|
-
let signup;
|
|
112
|
-
for (let attempt = 0; attempt < 3; attempt++) {
|
|
113
|
-
signup = await apiPost('/v0/agent/sign-up', {
|
|
114
|
-
human_email: email,
|
|
115
|
-
username: usernameFor(email),
|
|
116
|
-
source: SOURCE,
|
|
117
|
-
referrer: REFERRER,
|
|
118
|
-
});
|
|
119
|
-
if (signup.status !== 409) break;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (signup.status === 409) {
|
|
123
|
-
ui.warn('Could not auto-pick an available inbox name after a few tries.');
|
|
124
|
-
ui.info('Grab a key from ' + ui.c.cyan(CONSOLE) + ' → Settings → API Keys.');
|
|
125
|
-
const key = (await ui.ask('Paste your AgentMail API key (am_…), or blank to skip:')).trim();
|
|
126
|
-
if (!key) return { product: 'AgentMail', icon: 'warn', note: 'needs key (set AGENTMAIL_API_KEY)' };
|
|
127
|
-
return register(key, ctx);
|
|
128
|
-
}
|
|
129
|
-
if (!signup.ok || !signup.data.api_key) {
|
|
130
|
-
ui.fail('Sign-up failed: ' + (signup.data.error || signup.data.message || `HTTP ${signup.status}`));
|
|
131
|
-
return { product: 'AgentMail', icon: 'fail', note: 'sign-up failed' };
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const key = signup.data.api_key;
|
|
135
|
-
const inbox = signup.data.inbox_id;
|
|
136
|
-
if (inbox) ui.ok('Inbox created: ' + ui.c.bold(inbox));
|
|
137
|
-
|
|
138
|
-
// Verify the OTP to lift the unverified-org send allowlist. The key already works for receiving
|
|
139
|
-
// without it, so a missing/wrong code degrades gracefully rather than failing the whole step.
|
|
140
|
-
ui.ok(`Verification code sent to ${email}. Check your inbox.`);
|
|
141
|
-
const otp = await ui.ask('Enter the 6-digit code (or blank to verify later):');
|
|
142
|
-
if (otp) {
|
|
143
|
-
ui.step('Verifying…');
|
|
144
|
-
const verify = await apiPost('/v0/agent/verify', { otp_code: otp }, key);
|
|
145
|
-
if (verify.ok && verify.data.verified) {
|
|
146
|
-
ui.ok('AgentMail account verified — sending unlocked.');
|
|
147
|
-
} else {
|
|
148
|
-
ui.warn('Could not verify the code now (' + (verify.data.error || verify.data.message || `HTTP ${verify.status}`) + ').');
|
|
149
|
-
ui.dim('Your inbox still works for receiving; verify later to lift send limits.');
|
|
150
|
-
}
|
|
151
28
|
} else {
|
|
152
|
-
ui.
|
|
29
|
+
ui.info('AgentMail needs an API key (starts with ' + ui.c.bold('am_') + ').');
|
|
30
|
+
ui.info('Get one (free tier) at ' + ui.c.cyan(CONSOLE) + ' → Settings → API Keys.');
|
|
31
|
+
key = await ui.ask('Paste your AgentMail API key (or leave blank to skip for now):');
|
|
32
|
+
if (!key) {
|
|
33
|
+
ui.warn('No key provided — skipping AgentMail. Re-run later with the key set.');
|
|
34
|
+
return { product: 'AgentMail', icon: 'warn', note: 'needs key (set AGENTMAIL_API_KEY)' };
|
|
35
|
+
}
|
|
153
36
|
}
|
|
154
37
|
|
|
155
|
-
ui.
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
38
|
+
ui.step('Registering the AgentMail MCP server…');
|
|
39
|
+
const res = mcp.addServer(
|
|
40
|
+
{ name: MCP_NAME, url: MCP_URL, headers: { 'x-api-key': key } },
|
|
41
|
+
{ dryRun: ctx.dryRun }
|
|
42
|
+
);
|
|
43
|
+
if (res.error) {
|
|
44
|
+
ui.fail('Failed to register MCP server: ' + res.error);
|
|
45
|
+
return { product: 'AgentMail', icon: 'fail', note: res.error };
|
|
46
|
+
}
|
|
47
|
+
ui.ok('AgentMail MCP server registered.');
|
|
48
|
+
return { product: 'AgentMail', icon: 'ok', note: 'configured' };
|
|
162
49
|
}
|
|
163
50
|
|
|
164
|
-
module.exports = { step, MCP_NAME
|
|
51
|
+
module.exports = { step, MCP_NAME };
|
package/lib/steps/agentphone.js
CHANGED
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
const ui = require('../ui');
|
|
5
5
|
const mcp = require('../mcp');
|
|
6
|
-
const ac = require('../agentcard-api'); // shared email validation (isValidEmail)
|
|
7
6
|
|
|
8
7
|
const MCP_NAME = 'agentphone';
|
|
9
8
|
const API = 'https://api.agentphone.ai';
|
|
10
9
|
const SETTINGS = 'https://agentphone.ai/settings';
|
|
11
|
-
const SOURCE = 'agentbundle'; // sent on verify so AgentPhone attributes the signup to the bundle
|
|
12
10
|
|
|
13
11
|
async function apiPost(path, body) {
|
|
14
12
|
const ctrl = new AbortController();
|
|
@@ -55,34 +53,20 @@ async function step(ctx) {
|
|
|
55
53
|
return { product: 'AgentPhone', icon: 'ok', note: 'already configured' };
|
|
56
54
|
}
|
|
57
55
|
|
|
58
|
-
// Existing key in env?
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
ui.ok(`Using AGENTPHONE_API_KEY from your environment (${ui.mask(envKey)}).`);
|
|
63
|
-
return register(envKey, ctx);
|
|
56
|
+
// Existing key in env?
|
|
57
|
+
if (process.env.AGENTPHONE_API_KEY) {
|
|
58
|
+
ui.ok(`Using AGENTPHONE_API_KEY from your environment (${ui.mask(process.env.AGENTPHONE_API_KEY)}).`);
|
|
59
|
+
return register(process.env.AGENTPHONE_API_KEY, ctx);
|
|
64
60
|
}
|
|
65
61
|
|
|
66
62
|
if (ctx.dryRun) {
|
|
67
|
-
ui.step('would: POST /v0/agent/sign-up → ask for OTP → POST /v0/agent/verify
|
|
63
|
+
ui.step('would: POST /v0/agent/sign-up → ask for OTP → POST /v0/agent/verify → get sk_live_ key + number');
|
|
68
64
|
ui.dim(`would: claude mcp add ${MCP_NAME} --env AGENTPHONE_API_KEY=… -- npx -y agentphone-mcp`);
|
|
69
65
|
return { product: 'AgentPhone', icon: 'ok', note: 'configured (dry-run)' };
|
|
70
66
|
}
|
|
71
67
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
ui.ok('[sandbox] provisioned number +1 (555) 010-0042');
|
|
75
|
-
return register('sk_live_sandbox_placeholder_key', ctx, 'configured (sandbox number)');
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Real flow — reuse the email collected up front; only ask (with validation) if one wasn't provided.
|
|
79
|
-
let email = ctx.email && ac.isValidEmail(ctx.email) ? ctx.email : '';
|
|
80
|
-
for (let tries = 0; !email && tries < 3; tries++) {
|
|
81
|
-
const entered = await ui.ask('What email should AgentPhone send your verification code to?');
|
|
82
|
-
if (!entered) break;
|
|
83
|
-
if (ac.isValidEmail(entered)) email = entered;
|
|
84
|
-
else ui.warn("That doesn't look like an email — try again.");
|
|
85
|
-
}
|
|
68
|
+
// Real flow.
|
|
69
|
+
const email = await ui.ask('What email should AgentPhone send your verification code to?');
|
|
86
70
|
if (!email) {
|
|
87
71
|
ui.warn('No email — skipping AgentPhone. Re-run later.');
|
|
88
72
|
return { product: 'AgentPhone', icon: 'warn', note: 'skipped (no email)' };
|
|
@@ -94,7 +78,7 @@ async function step(ctx) {
|
|
|
94
78
|
if (signup.status === 409) {
|
|
95
79
|
ui.warn('You already have an AgentPhone account for that email.');
|
|
96
80
|
ui.info('Grab a key from ' + ui.c.cyan(SETTINGS) + ' → API Keys.');
|
|
97
|
-
const key =
|
|
81
|
+
const key = await ui.ask('Paste your AgentPhone API key (sk_live_…), or blank to skip:');
|
|
98
82
|
if (!key) return { product: 'AgentPhone', icon: 'warn', note: 'needs key (set AGENTPHONE_API_KEY)' };
|
|
99
83
|
return register(key, ctx);
|
|
100
84
|
}
|
|
@@ -111,7 +95,7 @@ async function step(ctx) {
|
|
|
111
95
|
}
|
|
112
96
|
|
|
113
97
|
ui.step('Verifying and provisioning your number…');
|
|
114
|
-
const verify = await apiPost('/v0/agent/verify', { verification_id: signup.data.verification_id, otp_code: otp
|
|
98
|
+
const verify = await apiPost('/v0/agent/verify', { verification_id: signup.data.verification_id, otp_code: otp });
|
|
115
99
|
if (!verify.ok || !verify.data.api_key) {
|
|
116
100
|
ui.fail('Verification failed: ' + (verify.data.error || verify.data.message || `HTTP ${verify.status}`));
|
|
117
101
|
return { product: 'AgentPhone', icon: 'fail', note: 'verification failed' };
|
|
@@ -122,9 +106,4 @@ async function step(ctx) {
|
|
|
122
106
|
return register(verify.data.api_key, ctx, `live number ${verify.data.phone_number}`);
|
|
123
107
|
}
|
|
124
108
|
|
|
125
|
-
|
|
126
|
-
function needsSetup() {
|
|
127
|
-
return !mcp.exists(MCP_NAME) && !(process.env.AGENTPHONE_API_KEY || '').trim();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
module.exports = { step, MCP_NAME, needsSetup };
|
|
109
|
+
module.exports = { step, MCP_NAME };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Final step — the $20/mo bundle subscription. After all three MCP servers are
|
|
3
|
+
// installed, this offers to subscribe to the Agent Bundle: one $20/mo charge for
|
|
4
|
+
// Agentcard + AgentMail + AgentPhone (vs ~$43 buying them standalone).
|
|
5
|
+
//
|
|
6
|
+
// Billing runs on the Agent Bundle's OWN server (theagentbundle.com), on the
|
|
7
|
+
// Agentcard Corporation Stripe account — separate from Agentcard's product
|
|
8
|
+
// backend. The customer is keyed by email; we just open Stripe's hosted
|
|
9
|
+
// checkout, so no charge happens until they enter a card and confirm there.
|
|
10
|
+
|
|
11
|
+
const { spawn } = require('node:child_process');
|
|
12
|
+
const ui = require('../ui');
|
|
13
|
+
const ac = require('../agentcard-api');
|
|
14
|
+
|
|
15
|
+
const PRICE_LABEL = '$20/mo';
|
|
16
|
+
// The bundle server. Override for local/staging with AGENT_BUNDLE_API_URL.
|
|
17
|
+
const BUNDLE_API_URL = (process.env.AGENT_BUNDLE_API_URL || 'https://theagentbundle.com').replace(/\/$/, '');
|
|
18
|
+
|
|
19
|
+
async function fetchJson(method, path, body) {
|
|
20
|
+
const ctrl = new AbortController();
|
|
21
|
+
const t = setTimeout(() => ctrl.abort(), 30000);
|
|
22
|
+
try {
|
|
23
|
+
const res = await fetch(BUNDLE_API_URL + path, {
|
|
24
|
+
method,
|
|
25
|
+
headers: { 'Content-Type': 'application/json', 'x-source': 'agent-bundle-cli' },
|
|
26
|
+
...(body ? { body: JSON.stringify(body) } : {}),
|
|
27
|
+
signal: ctrl.signal,
|
|
28
|
+
});
|
|
29
|
+
const text = await res.text();
|
|
30
|
+
let data;
|
|
31
|
+
try { data = JSON.parse(text); } catch { data = { raw: text }; }
|
|
32
|
+
return { ok: res.ok, status: res.status, data };
|
|
33
|
+
} finally {
|
|
34
|
+
clearTimeout(t);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Open a URL in the user's default browser, best-effort and non-blocking.
|
|
39
|
+
function openInBrowser(url) {
|
|
40
|
+
const cmd = process.platform === 'darwin' ? 'open'
|
|
41
|
+
: process.platform === 'win32' ? 'cmd'
|
|
42
|
+
: 'xdg-open';
|
|
43
|
+
const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url];
|
|
44
|
+
try {
|
|
45
|
+
const child = spawn(cmd, args, { stdio: 'ignore', detached: true });
|
|
46
|
+
child.on('error', () => {});
|
|
47
|
+
child.unref();
|
|
48
|
+
return true;
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Use the email from the Agentcard signup; fall back to asking.
|
|
55
|
+
async function resolveEmail(ctx) {
|
|
56
|
+
const saved = ac.readConfig().email;
|
|
57
|
+
if (saved && ac.isValidEmail(saved)) return saved;
|
|
58
|
+
if (ctx.yes || !process.stdin.isTTY) return null;
|
|
59
|
+
for (let tries = 0; tries < 3; tries++) {
|
|
60
|
+
const entered = await ui.ask('What email should your bundle subscription use?');
|
|
61
|
+
if (!entered) return null;
|
|
62
|
+
if (ac.isValidEmail(entered)) return entered;
|
|
63
|
+
ui.warn('That doesn\'t look like an email — try again.');
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function step(ctx) {
|
|
69
|
+
ui.heading(0, 0, 'Agent Bundle — one subscription for all three');
|
|
70
|
+
ui.dim(`Agentcard + AgentMail + AgentPhone together for ${PRICE_LABEL} (about half of buying them separately).`);
|
|
71
|
+
|
|
72
|
+
if (ctx.dryRun) {
|
|
73
|
+
ui.step(`would: POST ${BUNDLE_API_URL}/api/checkout {email} → open Stripe checkout for ${PRICE_LABEL}`);
|
|
74
|
+
return { product: 'Bundle', icon: 'ok', note: `offer ${PRICE_LABEL} (dry-run)` };
|
|
75
|
+
}
|
|
76
|
+
const email = await resolveEmail(ctx);
|
|
77
|
+
if (!email) {
|
|
78
|
+
ui.warn('No email for the bundle — skipping. Re-run with ' + ui.c.bold('--only bundle') + ' to subscribe.');
|
|
79
|
+
return { product: 'Bundle', icon: 'warn', note: 'needs email' };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Is the bundle live, and is this email already subscribed?
|
|
83
|
+
try {
|
|
84
|
+
const r = await fetchJson('GET', `/api/status?email=${encodeURIComponent(email)}`);
|
|
85
|
+
if (r.ok && r.data && r.data.configured === false) {
|
|
86
|
+
ui.info('The bundle isn\'t available yet — your three MCP servers are installed and ready.');
|
|
87
|
+
return { product: 'Bundle', icon: 'ok', note: 'not offered (coming soon)' };
|
|
88
|
+
}
|
|
89
|
+
if (r.ok && r.data && r.data.active) {
|
|
90
|
+
ui.ok('This email already has an active Agent Bundle — nothing to do.');
|
|
91
|
+
return { product: 'Bundle', icon: 'ok', note: 'already subscribed' };
|
|
92
|
+
}
|
|
93
|
+
} catch {
|
|
94
|
+
ui.dim('(could not check bundle status — offering anyway)');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!ctx.yes) {
|
|
98
|
+
const go = await ui.confirm(`Subscribe to the Agent Bundle for ${PRICE_LABEL} now?`, true);
|
|
99
|
+
if (!go) {
|
|
100
|
+
ui.info('No problem — subscribe anytime by re-running with ' + ui.c.bold('--only bundle') + '.');
|
|
101
|
+
return { product: 'Bundle', icon: 'warn', note: 'declined' };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
let checkoutUrl;
|
|
106
|
+
try {
|
|
107
|
+
ui.step('Creating your secure Stripe checkout…');
|
|
108
|
+
const r = await fetchJson('POST', '/api/checkout', { email });
|
|
109
|
+
if (r.status === 503) {
|
|
110
|
+
ui.info('The bundle isn\'t available yet — your three MCP servers are installed and ready.');
|
|
111
|
+
return { product: 'Bundle', icon: 'ok', note: 'not offered (coming soon)' };
|
|
112
|
+
}
|
|
113
|
+
if (r.status === 409) {
|
|
114
|
+
ui.ok('This email already has an active Agent Bundle — nothing to do.');
|
|
115
|
+
return { product: 'Bundle', icon: 'ok', note: 'already subscribed' };
|
|
116
|
+
}
|
|
117
|
+
if (!r.ok || !r.data || !r.data.checkoutUrl) {
|
|
118
|
+
throw new Error((r.data && r.data.error) || `HTTP ${r.status}`);
|
|
119
|
+
}
|
|
120
|
+
checkoutUrl = r.data.checkoutUrl;
|
|
121
|
+
} catch (e) {
|
|
122
|
+
ui.fail('Could not start checkout: ' + e.message);
|
|
123
|
+
return { product: 'Bundle', icon: 'fail', note: 'checkout failed' };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const opened = openInBrowser(checkoutUrl);
|
|
127
|
+
if (opened) ui.ok('Opened Stripe checkout in your browser.');
|
|
128
|
+
else ui.warn('Could not open your browser automatically.');
|
|
129
|
+
ui.info('Complete the ' + ui.c.bold(PRICE_LABEL) + ' subscription here:');
|
|
130
|
+
ui.info(' ' + ui.c.cyan(checkoutUrl));
|
|
131
|
+
ui.dim('No charge happens until you enter a card and confirm on Stripe\'s page.');
|
|
132
|
+
|
|
133
|
+
return { product: 'Bundle', icon: 'ok', note: `checkout opened (${PRICE_LABEL})` };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
module.exports = { step };
|
package/lib/ui.js
CHANGED
|
@@ -36,7 +36,9 @@ function banner() {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function heading(n, total, title) {
|
|
39
|
-
|
|
39
|
+
// total falsy → a plain section heading with no [n/total] counter (e.g. the bundle step).
|
|
40
|
+
const prefix = total ? `[${n}/${total}] ` : '';
|
|
41
|
+
stdout.write('\n' + c.bold(c.blue(`${prefix}${title}`)) + '\n');
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
const info = (m) => stdout.write(' ' + m + '\n');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentbundle-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "One command to give your AI agent a card, an inbox, and a phone — installs
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "One command to give your AI agent a card, an inbox, and a phone — installs AgentCard, AgentMail, and AgentPhone via a guided onboarding flow.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"agentbundle-cli": "bin/agent-bundle.js",
|
|
7
7
|
"agentbundle": "bin/agent-bundle.js",
|
|
@@ -25,13 +25,5 @@
|
|
|
25
25
|
"onboarding",
|
|
26
26
|
"cli"
|
|
27
27
|
],
|
|
28
|
-
"publishConfig": {
|
|
29
|
-
"access": "public"
|
|
30
|
-
},
|
|
31
|
-
"repository": {
|
|
32
|
-
"type": "git",
|
|
33
|
-
"url": "git+https://github.com/tiny-agent-company/tiny-agent-company.git",
|
|
34
|
-
"directory": "apps/agent-bundle-cli"
|
|
35
|
-
},
|
|
36
28
|
"license": "MIT"
|
|
37
29
|
}
|