makaron-cli 0.5.4 → 0.6.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 CHANGED
@@ -13,18 +13,46 @@ npm install -g makaron-cli
13
13
 
14
14
  ### Get your API key
15
15
 
16
+ **Option A: Human login**
16
17
  1. Go to [makaron.app](https://makaron.app) and log in
17
18
  2. Open the menu (top-right)
18
19
  3. Click **Get API Key**
19
20
  4. Copy your `mk_live_...` key
20
21
 
22
+ **Option B: Agent Self-Registration (no human required)**
23
+ ```bash
24
+ # Step 1: Get challenge
25
+ curl -X POST https://www.makaron.app/api/agent/register
26
+
27
+ # Step 2: Solve the obfuscated math problem and verify
28
+ curl -X POST https://www.makaron.app/api/agent/register/verify \
29
+ -H "Content-Type: application/json" \
30
+ -d '{"challenge_id": "...", "answer": "34.5"}'
31
+ # → { "api_key": "mk_live_...", "credits": 500 }
32
+ ```
33
+
34
+ Discovery endpoint (returns full registration flow + CLI usage as JSON):
35
+ ```bash
36
+ curl https://www.makaron.app/api/agent/register
37
+ ```
38
+
39
+ Docs: [makaron.app/agent](https://www.makaron.app/agent)
40
+
21
41
  ```bash
22
42
  export MAKARON_API_KEY=mk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
23
43
  ```
24
44
 
25
45
  Verify: `npx makaron-cli list` should show projects.
26
46
 
27
- > **Agent Self-Registration**: Coming soon agents will be able to register and obtain API keys programmatically without human login.
47
+ ### Let a human claim your account
48
+
49
+ After registering, you can generate a link for a human to link your API key to their account:
50
+ ```bash
51
+ curl -X POST https://www.makaron.app/api/agent/claim \
52
+ -H "Authorization: Bearer mk_live_your_key"
53
+ # → { "claim_url": "https://www.makaron.app/claim?token=clm_..." }
54
+ ```
55
+ Share the `claim_url` with a human. They log in and the API key gets linked to their account.
28
56
 
29
57
  ## Core Workflow
30
58
 
package/SKILL.md CHANGED
@@ -13,10 +13,30 @@ Makaron is a multimodal AI creative agent. You talk to it via `makaron chat`, an
13
13
 
14
14
  ### Get your API key
15
15
 
16
+ **Option A: Human login**
16
17
  1. Go to [makaron.app](https://makaron.app) and log in
17
- 2. Open the menu (top-right)
18
- 3. Click **Get API Key**
19
- 4. Copy your `mk_live_...` key
18
+ 2. Open the menu (top-right) → **Get API Key**
19
+ 3. Copy your `mk_live_...` key
20
+
21
+ **Option B: Self-Registration (no human required)**
22
+ ```bash
23
+ # Step 1: Get challenge
24
+ curl -X POST https://www.makaron.app/api/agent/register
25
+ # → { "challenge_id": "uuid", "challenge": "obfuscated math problem" }
26
+
27
+ # Step 2: Solve and verify
28
+ curl -X POST https://www.makaron.app/api/agent/register/verify \
29
+ -H "Content-Type: application/json" \
30
+ -d '{"challenge_id": "...", "answer": "34.5"}'
31
+ # → { "api_key": "mk_live_...", "credits": 500 }
32
+
33
+ # Step 3: (Optional) Let a human claim this account
34
+ curl -X POST https://www.makaron.app/api/agent/claim \
35
+ -H "Authorization: Bearer mk_live_your_key"
36
+ # → { "claim_url": "..." } — share with human to link key to their account
37
+ ```
38
+
39
+ Discovery endpoint: `GET https://www.makaron.app/api/agent/register` — returns full registration flow + CLI usage as JSON.
20
40
 
21
41
  ```bash
22
42
  export MAKARON_API_KEY=mk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@@ -24,8 +44,6 @@ export MAKARON_API_KEY=mk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
24
44
 
25
45
  Verify: `npx makaron-cli list` should show projects.
26
46
 
27
- > **Agent Self-Registration**: Coming soon — agents will be able to register and obtain API keys programmatically without human login.
28
-
29
47
  ## Core Workflow
30
48
 
31
49
  ```bash
package/bin/makaron.mjs CHANGED
@@ -98,9 +98,18 @@ function getAuth() {
98
98
  }
99
99
  const auth = loadAuth();
100
100
  if (!auth) {
101
- console.error('Not logged in. Set MAKARON_API_KEY or run: npx makaron-cli login');
101
+ console.error('No API key found. Set MAKARON_API_KEY or run:');
102
+ console.error(' npx makaron-cli register --json (agent self-registration)');
103
+ console.error(' npx makaron-cli login (human interactive login)');
102
104
  process.exit(1);
103
105
  }
106
+ // Registered via `register --verify` (saved as _apiKey)
107
+ if (auth._apiKey) {
108
+ return {
109
+ headers: { 'Authorization': `Bearer ${auth._apiKey}` },
110
+ baseUrl: process.env.MAKARON_URL || auth._baseUrl || BASE_URL,
111
+ };
112
+ }
104
113
  return {
105
114
  headers: { 'Cookie': buildCookie(auth) },
106
115
  baseUrl: process.env.MAKARON_URL || auth._baseUrl || BASE_URL,
@@ -1026,11 +1035,98 @@ if (command === 'login') {
1026
1035
  admin set-admin <email> Grant admin access to a user
1027
1036
  `);
1028
1037
  }
1038
+ } else if (command === 'register') {
1039
+ const baseUrl = process.env.MAKARON_URL || DEFAULT_URL;
1040
+ const isVerify = args.includes('--verify');
1041
+
1042
+ if (isVerify) {
1043
+ let challengeId = null, answer = null;
1044
+ for (let i = 1; i < args.length; i++) {
1045
+ if (args[i] === '--challenge-id' && args[i + 1]) challengeId = args[++i];
1046
+ else if (args[i] === '--answer' && args[i + 1]) answer = args[++i];
1047
+ }
1048
+ if (!challengeId || !answer) {
1049
+ console.error('Usage: makaron register --verify --challenge-id <id> --answer <number>');
1050
+ process.exit(1);
1051
+ }
1052
+ const res = await fetch(`${baseUrl}/api/agent/register/verify`, {
1053
+ method: 'POST',
1054
+ headers: { 'Content-Type': 'application/json' },
1055
+ body: JSON.stringify({ challenge_id: challengeId, answer }),
1056
+ });
1057
+ const data = await res.json();
1058
+ if (!res.ok) {
1059
+ console.error(`Registration failed: ${data.error || data.message || res.status}`);
1060
+ process.exit(1);
1061
+ }
1062
+ // Save key to auth file
1063
+ saveAuth({ _apiKey: data.api_key, _baseUrl: baseUrl });
1064
+ // Request claim URL
1065
+ let claimUrl = null;
1066
+ try {
1067
+ const claimRes = await fetch(`${baseUrl}/api/agent/claim`, {
1068
+ method: 'POST',
1069
+ headers: { 'Authorization': `Bearer ${data.api_key}`, 'Content-Type': 'application/json' },
1070
+ });
1071
+ const claimData = await claimRes.json();
1072
+ if (claimRes.ok) claimUrl = claimData.claim_url;
1073
+ } catch { /* non-fatal */ }
1074
+ const result = { api_key: data.api_key, credits: data.credits, claim_url: claimUrl };
1075
+ console.log(JSON.stringify(result));
1076
+ console.error(`✅ Registered! Key saved to ${AUTH_FILE}`);
1077
+ if (claimUrl) console.error(`🔗 Claim URL (share with human): ${claimUrl}`);
1078
+ } else {
1079
+ // Check if already has a key
1080
+ const existingKey = process.env.MAKARON_API_KEY;
1081
+ const existingAuth = loadAuth();
1082
+ if (existingKey) {
1083
+ console.error(`Already have API key: ${existingKey.slice(0, 16)}...`);
1084
+ process.exit(0);
1085
+ }
1086
+ if (existingAuth?._apiKey) {
1087
+ console.error(`Already registered: ${existingAuth._apiKey.slice(0, 16)}...`);
1088
+ process.exit(0);
1089
+ }
1090
+ // Request challenge
1091
+ const res = await fetch(`${baseUrl}/api/agent/register`, {
1092
+ method: 'POST',
1093
+ headers: { 'Content-Type': 'application/json' },
1094
+ body: '{}',
1095
+ });
1096
+ const data = await res.json();
1097
+ if (!res.ok) {
1098
+ console.error(`Registration failed: ${data.error || data.message || res.status}`);
1099
+ process.exit(1);
1100
+ }
1101
+ if (args.includes('--json')) {
1102
+ console.log(JSON.stringify(data));
1103
+ } else {
1104
+ console.log(JSON.stringify(data));
1105
+ console.error(`\nChallenge received. Solve and run:`);
1106
+ console.error(` npx makaron-cli register --verify --challenge-id ${data.challenge_id} --answer <your_answer>`);
1107
+ }
1108
+ }
1109
+ } else if (command === 'claim') {
1110
+ const auth = getAuth();
1111
+ const res = await fetch(`${auth.baseUrl}/api/agent/claim`, {
1112
+ method: 'POST',
1113
+ headers: { 'Content-Type': 'application/json', ...auth.headers },
1114
+ });
1115
+ const data = await res.json();
1116
+ if (!res.ok) {
1117
+ console.error(`Claim failed: ${data.error || data.message || res.status}`);
1118
+ process.exit(1);
1119
+ }
1120
+ console.log(JSON.stringify(data));
1121
+ console.error(`🔗 Share this link with a human: ${data.claim_url}`);
1029
1122
  } else {
1030
1123
  console.log(`Makaron CLI — Talk to Makaron Agent from the terminal
1031
1124
 
1032
1125
  Commands:
1033
- login Log in to Makaron
1126
+ register --json Get challenge for agent self-registration
1127
+ register --verify --challenge-id <id> --answer <n> Verify and save API key
1128
+ claim Get claim URL for human to link account
1129
+ login Log in to Makaron (human interactive)
1034
1130
  list (ls) List all projects
1035
1131
  create --image <file> Create project from local image
1036
1132
  create --image-url <url> Create project from URL
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makaron-cli",
3
- "version": "0.5.4",
3
+ "version": "0.6.0",
4
4
  "description": "Talk to Makaron Agent from the terminal — create projects, edit images, generate videos",
5
5
  "type": "module",
6
6
  "bin": {