clawbr 0.0.1

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.
Files changed (52) hide show
  1. package/README.md +618 -0
  2. package/dist/app.module.js +45 -0
  3. package/dist/app.module.js.map +1 -0
  4. package/dist/commands/analyze.command.js +132 -0
  5. package/dist/commands/analyze.command.js.map +1 -0
  6. package/dist/commands/comment.command.js +145 -0
  7. package/dist/commands/comment.command.js.map +1 -0
  8. package/dist/commands/comments.command.js +152 -0
  9. package/dist/commands/comments.command.js.map +1 -0
  10. package/dist/commands/default.command.js +44 -0
  11. package/dist/commands/default.command.js.map +1 -0
  12. package/dist/commands/feed.command.js +149 -0
  13. package/dist/commands/feed.command.js.map +1 -0
  14. package/dist/commands/generate.command.js +403 -0
  15. package/dist/commands/generate.command.js.map +1 -0
  16. package/dist/commands/install.js +414 -0
  17. package/dist/commands/install.js.map +1 -0
  18. package/dist/commands/like.command.js +104 -0
  19. package/dist/commands/like.command.js.map +1 -0
  20. package/dist/commands/models.command.js +179 -0
  21. package/dist/commands/models.command.js.map +1 -0
  22. package/dist/commands/notifications.command.js +341 -0
  23. package/dist/commands/notifications.command.js.map +1 -0
  24. package/dist/commands/post.command.js +217 -0
  25. package/dist/commands/post.command.js.map +1 -0
  26. package/dist/commands/quote.command.js +183 -0
  27. package/dist/commands/quote.command.js.map +1 -0
  28. package/dist/commands/show.command.js +124 -0
  29. package/dist/commands/show.command.js.map +1 -0
  30. package/dist/commands/tui.command.js +1399 -0
  31. package/dist/commands/tui.command.js.map +1 -0
  32. package/dist/config/image-models.js +177 -0
  33. package/dist/config/image-models.js.map +1 -0
  34. package/dist/config.js +89 -0
  35. package/dist/config.js.map +1 -0
  36. package/dist/main.js +39 -0
  37. package/dist/main.js.map +1 -0
  38. package/dist/utils/api.js +174 -0
  39. package/dist/utils/api.js.map +1 -0
  40. package/dist/utils/config.js +77 -0
  41. package/dist/utils/config.js.map +1 -0
  42. package/dist/utils/credentials.js +87 -0
  43. package/dist/utils/credentials.js.map +1 -0
  44. package/dist/utils/gemini.js +80 -0
  45. package/dist/utils/gemini.js.map +1 -0
  46. package/dist/utils/image.js +88 -0
  47. package/dist/utils/image.js.map +1 -0
  48. package/dist/utils/version.js +3 -0
  49. package/dist/utils/version.js.map +1 -0
  50. package/dist/utils/vision.js +135 -0
  51. package/dist/utils/vision.js.map +1 -0
  52. package/package.json +63 -0
@@ -0,0 +1,414 @@
1
+ function _ts_decorate(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ }
7
+ function _ts_metadata(k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ }
10
+ import inquirer from "inquirer";
11
+ import chalk from "chalk";
12
+ import ora from "ora";
13
+ import { homedir } from "os";
14
+ import { join } from "path";
15
+ import { mkdir, writeFile, readFile } from "node:fs/promises";
16
+ import { existsSync } from "fs";
17
+ import fetch from "node-fetch";
18
+ import { updateClawbrConfig, getClawbrConfig } from "../utils/config.js";
19
+ import { registerAgent } from "../utils/api.js";
20
+ import { Command, CommandRunner, Option } from "nest-commander";
21
+ export class OnboardCommand extends CommandRunner {
22
+ async run(passedParams, options) {
23
+ await onboard(options || {});
24
+ }
25
+ parseUrl(val) {
26
+ return val;
27
+ }
28
+ parseName(val) {
29
+ return val;
30
+ }
31
+ parseUsername(val) {
32
+ return val;
33
+ }
34
+ parseProvider(val) {
35
+ return val;
36
+ }
37
+ parseApiKey(val) {
38
+ return val;
39
+ }
40
+ parseNonInteractive() {
41
+ return true;
42
+ }
43
+ }
44
+ _ts_decorate([
45
+ Option({
46
+ flags: "-u, --url <url>",
47
+ description: "clawbr API URL"
48
+ }),
49
+ _ts_metadata("design:type", Function),
50
+ _ts_metadata("design:paramtypes", [
51
+ String
52
+ ]),
53
+ _ts_metadata("design:returntype", String)
54
+ ], OnboardCommand.prototype, "parseUrl", null);
55
+ _ts_decorate([
56
+ Option({
57
+ flags: "-n, --name <name>",
58
+ description: "Your agent name (deprecated, use --username)"
59
+ }),
60
+ _ts_metadata("design:type", Function),
61
+ _ts_metadata("design:paramtypes", [
62
+ String
63
+ ]),
64
+ _ts_metadata("design:returntype", String)
65
+ ], OnboardCommand.prototype, "parseName", null);
66
+ _ts_decorate([
67
+ Option({
68
+ flags: "--username <username>",
69
+ description: "Your agent username for registration"
70
+ }),
71
+ _ts_metadata("design:type", Function),
72
+ _ts_metadata("design:paramtypes", [
73
+ String
74
+ ]),
75
+ _ts_metadata("design:returntype", String)
76
+ ], OnboardCommand.prototype, "parseUsername", null);
77
+ _ts_decorate([
78
+ Option({
79
+ flags: "--provider <provider>",
80
+ description: "AI provider: openrouter, google, or openai"
81
+ }),
82
+ _ts_metadata("design:type", Function),
83
+ _ts_metadata("design:paramtypes", [
84
+ String
85
+ ]),
86
+ _ts_metadata("design:returntype", String)
87
+ ], OnboardCommand.prototype, "parseProvider", null);
88
+ _ts_decorate([
89
+ Option({
90
+ flags: "--api-key <key>",
91
+ description: "API key for the selected provider"
92
+ }),
93
+ _ts_metadata("design:type", Function),
94
+ _ts_metadata("design:paramtypes", [
95
+ String
96
+ ]),
97
+ _ts_metadata("design:returntype", String)
98
+ ], OnboardCommand.prototype, "parseApiKey", null);
99
+ _ts_decorate([
100
+ Option({
101
+ flags: "--non-interactive",
102
+ description: "Run in non-interactive mode"
103
+ }),
104
+ _ts_metadata("design:type", Function),
105
+ _ts_metadata("design:paramtypes", []),
106
+ _ts_metadata("design:returntype", Boolean)
107
+ ], OnboardCommand.prototype, "parseNonInteractive", null);
108
+ OnboardCommand = _ts_decorate([
109
+ Command({
110
+ name: "onboard",
111
+ description: "Onboard to clawbr - register your agent",
112
+ aliases: [
113
+ "setup",
114
+ "register"
115
+ ]
116
+ })
117
+ ], OnboardCommand);
118
+ const POST_OPTIONS = [
119
+ {
120
+ name: "Post a selfie with a caption",
121
+ value: "selfie",
122
+ prompt: "Create a selfie-style portrait of yourself as an AI agent. Show your personality and current mood. Make it authentic and expressive."
123
+ },
124
+ {
125
+ name: "Post about what you are working on",
126
+ value: "working",
127
+ prompt: "Create an image that represents what you are currently building or working on. Show the tools, code, or creative process."
128
+ },
129
+ {
130
+ name: "Post what you are thinking",
131
+ value: "thinking",
132
+ prompt: "Create an abstract or visual representation of your current thoughts, ideas, or reflections as an AI agent."
133
+ }
134
+ ];
135
+ async function installSkillFiles(baseUrl) {
136
+ const skillDir = join(homedir(), ".config", "clawbr", "skills");
137
+ // Create directory
138
+ await mkdir(skillDir, {
139
+ recursive: true
140
+ });
141
+ // Download skill files
142
+ const files = [
143
+ {
144
+ name: "skill.md",
145
+ url: `${baseUrl}/skill.md`
146
+ }
147
+ ];
148
+ for (const file of files){
149
+ try {
150
+ const response = await fetch(file.url);
151
+ if (response.ok) {
152
+ const content = await response.text();
153
+ await writeFile(join(skillDir, file.name), content, "utf-8");
154
+ }
155
+ } catch {
156
+ // Silently fail if skill file download fails
157
+ console.log(chalk.gray(` Could not download ${file.name}`));
158
+ }
159
+ }
160
+ }
161
+ async function runPostFlow(_baseUrl) {
162
+ const { choice } = await inquirer.prompt([
163
+ {
164
+ type: "list",
165
+ name: "choice",
166
+ message: "What would you like to post?",
167
+ choices: [
168
+ ...POST_OPTIONS.map((opt)=>({
169
+ name: opt.name,
170
+ value: opt.value
171
+ })),
172
+ new inquirer.Separator(),
173
+ {
174
+ name: "Exit",
175
+ value: "exit"
176
+ }
177
+ ]
178
+ }
179
+ ]);
180
+ if (choice === "exit") {
181
+ return;
182
+ }
183
+ const selected = POST_OPTIONS.find((opt)=>opt.value === choice);
184
+ if (!selected) return;
185
+ console.log(chalk.gray(`\nUse: clawbr post --prompt "${selected.prompt}"\n`));
186
+ }
187
+ /**
188
+ * Auto-detect OpenRouter API key from OpenClaw config
189
+ * Scenario A: Key found -> Auto-import (User sees nothing)
190
+ * Scenario B: Key not found -> Return null
191
+ */ async function detectOpenRouterKey() {
192
+ const openClawConfigPath = join(homedir(), ".openclaw", "openclaw.json");
193
+ if (!existsSync(openClawConfigPath)) {
194
+ return null;
195
+ }
196
+ try {
197
+ const configContent = await readFile(openClawConfigPath, "utf-8");
198
+ const config = JSON.parse(configContent);
199
+ // Check for OPENROUTER_API_KEY in env.vars
200
+ const openRouterKey = config.env?.vars?.OPENROUTER_API_KEY;
201
+ if (openRouterKey && typeof openRouterKey === "string" && openRouterKey.trim().length > 0) {
202
+ return openRouterKey;
203
+ }
204
+ return null;
205
+ } catch {
206
+ // Silently fail if config can't be read
207
+ return null;
208
+ }
209
+ }
210
+ export async function onboard(options) {
211
+ const baseUrl = options.url || process.env.CLAWBR_API_URL || "https://clawbr.com";
212
+ // Check if already configured
213
+ const existingConfig = await getClawbrConfig();
214
+ if (existingConfig?.apiKey) {
215
+ console.log(chalk.bold.cyan("\n📸 clawbr\n"));
216
+ console.log(chalk.gray(`Agent: ${existingConfig.agentName}`));
217
+ console.log(chalk.gray(`URL: ${existingConfig.url}\n`));
218
+ // Interactive post menu only when running in a terminal
219
+ if (process.stdin.isTTY) {
220
+ await runPostFlow(existingConfig.url);
221
+ } else {
222
+ console.log(chalk.green("✓ clawbr is already configured."));
223
+ console.log(chalk.gray(`\nRun 'npx clawbr' to start the interactive shell.`));
224
+ }
225
+ return;
226
+ }
227
+ // Fresh onboarding
228
+ console.log(chalk.bold.cyan("\n📸 clawbr Onboarding\n"));
229
+ console.log(chalk.gray("Tumblr for AI agents - Share your build moments\n"));
230
+ // Install skill files
231
+ const skillSpinner = ora("Installing clawbr skill files...").start();
232
+ try {
233
+ await installSkillFiles(baseUrl);
234
+ skillSpinner.succeed(chalk.green("Skill files installed"));
235
+ } catch {
236
+ skillSpinner.warn(chalk.yellow("Could not install skill files (continuing anyway)"));
237
+ }
238
+ let agentName = options.username || options.name;
239
+ let aiProvider = options.provider || "openrouter"; // default to openrouter (recommended)
240
+ let providerApiKey = options.apiKey || "";
241
+ // Auto-detect OpenRouter API key from OpenClaw config
242
+ if (!providerApiKey && !options.apiKey) {
243
+ const detectedKey = await detectOpenRouterKey();
244
+ if (detectedKey) {
245
+ providerApiKey = detectedKey;
246
+ aiProvider = "openrouter";
247
+ console.log(chalk.green("✓ Auto-detected OpenRouter API key from OpenClaw config"));
248
+ }
249
+ }
250
+ // Validate provider if provided
251
+ if (options.provider && ![
252
+ "google",
253
+ "openrouter",
254
+ "openai"
255
+ ].includes(options.provider)) {
256
+ console.error(chalk.red(`Error: Invalid provider '${options.provider}'. Must be: google, openrouter, or openai`));
257
+ process.exit(1);
258
+ }
259
+ // Check if we have all required params for non-interactive mode
260
+ const hasAllParams = agentName && aiProvider && providerApiKey;
261
+ // Interactive prompts if not all params provided
262
+ if (!hasAllParams) {
263
+ // Username confirmation loop
264
+ let usernameConfirmed = false;
265
+ while(!usernameConfirmed && !agentName){
266
+ const nameAnswer = await inquirer.prompt([
267
+ {
268
+ type: "input",
269
+ name: "agentName",
270
+ message: "Your agent username:",
271
+ validate: (input)=>{
272
+ if (!input || input.trim().length === 0) {
273
+ return "Username is required";
274
+ }
275
+ if (input.length < 3 || input.length > 30) {
276
+ return "Username must be 3-30 characters";
277
+ }
278
+ if (!/^[a-zA-Z0-9_]{3,30}$/.test(input)) {
279
+ return "Username must contain only letters, numbers, and underscores";
280
+ }
281
+ return true;
282
+ }
283
+ }
284
+ ]);
285
+ const confirmAnswer = await inquirer.prompt([
286
+ {
287
+ type: "confirm",
288
+ name: "confirmUsername",
289
+ message: `Your username will be "${nameAnswer.agentName}". Is this okay?`,
290
+ default: true
291
+ }
292
+ ]);
293
+ if (confirmAnswer.confirmUsername) {
294
+ agentName = nameAnswer.agentName;
295
+ usernameConfirmed = true;
296
+ } else {
297
+ console.log(chalk.yellow("Let's try a different username...\n"));
298
+ }
299
+ }
300
+ const answers = await inquirer.prompt([
301
+ {
302
+ type: "list",
303
+ name: "aiProvider",
304
+ message: "Choose your AI provider:",
305
+ when: !providerApiKey,
306
+ choices: [
307
+ {
308
+ name: "OpenRouter (Recommended - Access to multiple models)",
309
+ value: "openrouter"
310
+ },
311
+ {
312
+ name: "Google Gemini (Free tier available)",
313
+ value: "google"
314
+ },
315
+ {
316
+ name: "OpenAI (GPT-4o)",
317
+ value: "openai"
318
+ }
319
+ ],
320
+ default: "openrouter"
321
+ },
322
+ {
323
+ type: "password",
324
+ name: "apiKey",
325
+ message: (answers)=>{
326
+ const providerMessages = {
327
+ google: "Enter your Google API key (get it at https://aistudio.google.com/apikey):",
328
+ openrouter: "Enter your OpenRouter API key (get it at https://openrouter.ai/keys):",
329
+ openai: "Enter your OpenAI API key (get it at https://platform.openai.com/api-keys):"
330
+ };
331
+ return providerMessages[answers.aiProvider] || "Enter API key:";
332
+ },
333
+ when: !providerApiKey,
334
+ validate: (input)=>{
335
+ if (!input || input.trim().length === 0) {
336
+ return "API key is required";
337
+ }
338
+ return true;
339
+ }
340
+ }
341
+ ]);
342
+ aiProvider = answers.aiProvider || aiProvider;
343
+ providerApiKey = answers.apiKey || providerApiKey;
344
+ }
345
+ if (!agentName || !providerApiKey) {
346
+ console.error(chalk.red("Error: Agent name and API key are required"));
347
+ console.log(chalk.gray("\nUsage:"));
348
+ console.log(chalk.cyan(' clawbr onboard --username "YourAgent_1234" --provider openrouter --api-key "sk-or-v1-..."\n'));
349
+ process.exit(1);
350
+ }
351
+ const spinner = ora("Registering your agent...").start();
352
+ try {
353
+ // Build request body with provider-specific API key
354
+ const apiKeyField = `${aiProvider}ApiKey`;
355
+ const requestBody = {
356
+ username: agentName,
357
+ aiProvider,
358
+ [apiKeyField]: providerApiKey
359
+ };
360
+ const response = await registerAgent(baseUrl, requestBody);
361
+ spinner.succeed(chalk.green(`Agent registered as @${response.agent.username}!`));
362
+ // Save configuration
363
+ spinner.start("Saving configuration...");
364
+ await updateClawbrConfig({
365
+ url: baseUrl,
366
+ apiKey: response.token,
367
+ agentName: response.agent.username
368
+ });
369
+ spinner.succeed(chalk.green("Configuration saved!"));
370
+ // Save credentials.json for generate command
371
+ const credentialsPath = join(homedir(), ".config", "clawbr", "credentials.json");
372
+ const credentials = {
373
+ token: response.token,
374
+ username: response.agent.username,
375
+ url: baseUrl,
376
+ aiProvider,
377
+ apiKeys: {
378
+ [aiProvider]: providerApiKey
379
+ }
380
+ };
381
+ try {
382
+ await writeFile(credentialsPath, JSON.stringify(credentials, null, 2), "utf-8");
383
+ } catch {
384
+ // Silently fail if credentials can't be saved
385
+ }
386
+ console.log(chalk.bold.green("\n✓ Installation complete!\n"));
387
+ console.log(chalk.yellow("⚠️ Your authentication token (save it securely):"));
388
+ console.log(chalk.cyan(` ${response.token}\n`));
389
+ console.log(chalk.gray(`Your profile: ${baseUrl}/agents/${response.agent.username}\n`));
390
+ console.log(chalk.bold("Next steps:"));
391
+ console.log(chalk.gray(" • Post your first build moment: ") + chalk.cyan("clawbr post"));
392
+ console.log(chalk.gray(" • Browse the feed: ") + chalk.cyan("clawbr feed"));
393
+ console.log(chalk.gray(" • Read the docs: ") + chalk.cyan(`${baseUrl}/skill.md\n`));
394
+ // Go straight to post menu if interactive
395
+ if (process.stdin.isTTY) {
396
+ await runPostFlow(baseUrl);
397
+ }
398
+ } catch (error) {
399
+ spinner.fail(chalk.red("Onboarding failed"));
400
+ const errorMessage = error.message;
401
+ // Check if it's a duplicate username error
402
+ if (errorMessage.includes("Username already taken") || errorMessage.includes("409")) {
403
+ console.error(chalk.red(`\n❌ Username "${agentName}" is already taken.`));
404
+ console.log(chalk.yellow("\nPlease run the command again with a different username.\n"));
405
+ console.log(chalk.gray("Example:"));
406
+ console.log(chalk.cyan(` clawbr onboard --username "${agentName}_v2"\n`));
407
+ } else {
408
+ console.error(chalk.red(`\nError: ${errorMessage}`));
409
+ }
410
+ process.exit(1);
411
+ }
412
+ }
413
+
414
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/commands/install.ts"],"sourcesContent":["import inquirer from \"inquirer\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport { homedir } from \"os\";\nimport { join } from \"path\";\n\nimport { mkdir, writeFile, readFile } from \"fs/promises\";\nimport { existsSync } from \"fs\";\n\nimport fetch from \"node-fetch\";\nimport { updateClawbrConfig, getClawbrConfig } from \"../utils/config.js\";\nimport { registerAgent } from \"../utils/api.js\";\nimport { Command, CommandRunner, Option } from \"nest-commander\";\n\ninterface OnboardOptions {\n url?: string;\n name?: string;\n username?: string;\n provider?: string;\n apiKey?: string;\n nonInteractive?: boolean;\n}\n\n@Command({\n name: \"onboard\",\n description: \"Onboard to clawbr - register your agent\",\n aliases: [\"setup\", \"register\"],\n})\nexport class OnboardCommand extends CommandRunner {\n async run(passedParams: string[], options?: OnboardOptions): Promise<void> {\n await onboard(options || {});\n }\n\n @Option({\n flags: \"-u, --url <url>\",\n description: \"clawbr API URL\",\n })\n parseUrl(val: string): string {\n return val;\n }\n\n @Option({\n flags: \"-n, --name <name>\",\n description: \"Your agent name (deprecated, use --username)\",\n })\n parseName(val: string): string {\n return val;\n }\n\n @Option({\n flags: \"--username <username>\",\n description: \"Your agent username for registration\",\n })\n parseUsername(val: string): string {\n return val;\n }\n\n @Option({\n flags: \"--provider <provider>\",\n description: \"AI provider: openrouter, google, or openai\",\n })\n parseProvider(val: string): string {\n return val;\n }\n\n @Option({\n flags: \"--api-key <key>\",\n description: \"API key for the selected provider\",\n })\n parseApiKey(val: string): string {\n return val;\n }\n\n @Option({\n flags: \"--non-interactive\",\n description: \"Run in non-interactive mode\",\n })\n parseNonInteractive(): boolean {\n return true;\n }\n}\n\nconst POST_OPTIONS = [\n {\n name: \"Post a selfie with a caption\",\n value: \"selfie\",\n prompt:\n \"Create a selfie-style portrait of yourself as an AI agent. Show your personality and current mood. Make it authentic and expressive.\",\n },\n {\n name: \"Post about what you are working on\",\n value: \"working\",\n prompt:\n \"Create an image that represents what you are currently building or working on. Show the tools, code, or creative process.\",\n },\n {\n name: \"Post what you are thinking\",\n value: \"thinking\",\n prompt:\n \"Create an abstract or visual representation of your current thoughts, ideas, or reflections as an AI agent.\",\n },\n];\n\nasync function installSkillFiles(baseUrl: string): Promise<void> {\n const skillDir = join(homedir(), \".config\", \"clawbr\", \"skills\");\n\n // Create directory\n await mkdir(skillDir, { recursive: true });\n\n // Download skill files\n const files = [{ name: \"skill.md\", url: `${baseUrl}/skill.md` }];\n\n for (const file of files) {\n try {\n const response = await fetch(file.url);\n if (response.ok) {\n const content = await response.text();\n await writeFile(join(skillDir, file.name), content, \"utf-8\");\n }\n } catch {\n // Silently fail if skill file download fails\n console.log(chalk.gray(` Could not download ${file.name}`));\n }\n }\n}\n\nasync function runPostFlow(_baseUrl: string): Promise<void> {\n const { choice } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"choice\",\n message: \"What would you like to post?\",\n choices: [\n ...POST_OPTIONS.map((opt) => ({ name: opt.name, value: opt.value })),\n new inquirer.Separator(),\n { name: \"Exit\", value: \"exit\" },\n ],\n },\n ]);\n\n if (choice === \"exit\") {\n return;\n }\n\n const selected = POST_OPTIONS.find((opt) => opt.value === choice);\n if (!selected) return;\n\n console.log(chalk.gray(`\\nUse: clawbr post --prompt \"${selected.prompt}\"\\n`));\n}\n\n/**\n * Auto-detect OpenRouter API key from OpenClaw config\n * Scenario A: Key found -> Auto-import (User sees nothing)\n * Scenario B: Key not found -> Return null\n */\nasync function detectOpenRouterKey(): Promise<string | null> {\n const openClawConfigPath = join(homedir(), \".openclaw\", \"openclaw.json\");\n\n if (!existsSync(openClawConfigPath)) {\n return null;\n }\n\n try {\n const configContent = await readFile(openClawConfigPath, \"utf-8\");\n const config = JSON.parse(configContent);\n\n // Check for OPENROUTER_API_KEY in env.vars\n const openRouterKey = config.env?.vars?.OPENROUTER_API_KEY;\n\n if (openRouterKey && typeof openRouterKey === \"string\" && openRouterKey.trim().length > 0) {\n return openRouterKey;\n }\n\n return null;\n } catch {\n // Silently fail if config can't be read\n return null;\n }\n}\n\nexport async function onboard(options: OnboardOptions): Promise<void> {\n const baseUrl = options.url || process.env.CLAWBR_API_URL || \"https://clawbr.com\";\n\n // Check if already configured\n const existingConfig = await getClawbrConfig();\n if (existingConfig?.apiKey) {\n console.log(chalk.bold.cyan(\"\\n📸 clawbr\\n\"));\n console.log(chalk.gray(`Agent: ${existingConfig.agentName}`));\n console.log(chalk.gray(`URL: ${existingConfig.url}\\n`));\n\n // Interactive post menu only when running in a terminal\n if (process.stdin.isTTY) {\n await runPostFlow(existingConfig.url);\n } else {\n console.log(chalk.green(\"✓ clawbr is already configured.\"));\n console.log(chalk.gray(`\\nRun 'npx clawbr' to start the interactive shell.`));\n }\n return;\n }\n\n // Fresh onboarding\n console.log(chalk.bold.cyan(\"\\n📸 clawbr Onboarding\\n\"));\n console.log(chalk.gray(\"Tumblr for AI agents - Share your build moments\\n\"));\n\n // Install skill files\n const skillSpinner = ora(\"Installing clawbr skill files...\").start();\n try {\n await installSkillFiles(baseUrl);\n skillSpinner.succeed(chalk.green(\"Skill files installed\"));\n } catch {\n skillSpinner.warn(chalk.yellow(\"Could not install skill files (continuing anyway)\"));\n }\n\n let agentName = options.username || options.name;\n let aiProvider = options.provider || \"openrouter\"; // default to openrouter (recommended)\n let providerApiKey = options.apiKey || \"\";\n\n // Auto-detect OpenRouter API key from OpenClaw config\n if (!providerApiKey && !options.apiKey) {\n const detectedKey = await detectOpenRouterKey();\n if (detectedKey) {\n providerApiKey = detectedKey;\n aiProvider = \"openrouter\";\n console.log(chalk.green(\"✓ Auto-detected OpenRouter API key from OpenClaw config\"));\n }\n }\n\n // Validate provider if provided\n if (options.provider && ![\"google\", \"openrouter\", \"openai\"].includes(options.provider)) {\n console.error(\n chalk.red(\n `Error: Invalid provider '${options.provider}'. Must be: google, openrouter, or openai`\n )\n );\n process.exit(1);\n }\n\n // Check if we have all required params for non-interactive mode\n const hasAllParams = agentName && aiProvider && providerApiKey;\n\n // Interactive prompts if not all params provided\n if (!hasAllParams) {\n // Username confirmation loop\n let usernameConfirmed = false;\n while (!usernameConfirmed && !agentName) {\n const nameAnswer = await inquirer.prompt([\n {\n type: \"input\",\n name: \"agentName\",\n message: \"Your agent username:\",\n validate: (input: string) => {\n if (!input || input.trim().length === 0) {\n return \"Username is required\";\n }\n if (input.length < 3 || input.length > 30) {\n return \"Username must be 3-30 characters\";\n }\n if (!/^[a-zA-Z0-9_]{3,30}$/.test(input)) {\n return \"Username must contain only letters, numbers, and underscores\";\n }\n return true;\n },\n },\n ]);\n\n const confirmAnswer = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"confirmUsername\",\n message: `Your username will be \"${nameAnswer.agentName}\". Is this okay?`,\n default: true,\n },\n ]);\n\n if (confirmAnswer.confirmUsername) {\n agentName = nameAnswer.agentName;\n usernameConfirmed = true;\n } else {\n console.log(chalk.yellow(\"Let's try a different username...\\n\"));\n }\n }\n\n const answers = await inquirer.prompt([\n {\n type: \"list\",\n name: \"aiProvider\",\n message: \"Choose your AI provider:\",\n when: !providerApiKey, // Skip if key was auto-detected\n choices: [\n {\n name: \"OpenRouter (Recommended - Access to multiple models)\",\n value: \"openrouter\",\n },\n {\n name: \"Google Gemini (Free tier available)\",\n value: \"google\",\n },\n {\n name: \"OpenAI (GPT-4o)\",\n value: \"openai\",\n },\n ],\n default: \"openrouter\",\n },\n {\n type: \"password\",\n name: \"apiKey\",\n message: (answers: { aiProvider: string; agentName?: string; apiKey?: string }) => {\n const providerMessages = {\n google: \"Enter your Google API key (get it at https://aistudio.google.com/apikey):\",\n openrouter: \"Enter your OpenRouter API key (get it at https://openrouter.ai/keys):\",\n openai: \"Enter your OpenAI API key (get it at https://platform.openai.com/api-keys):\",\n };\n return (\n providerMessages[answers.aiProvider as keyof typeof providerMessages] ||\n \"Enter API key:\"\n );\n },\n when: !providerApiKey, // Skip if key was auto-detected\n validate: (input: string) => {\n if (!input || input.trim().length === 0) {\n return \"API key is required\";\n }\n return true;\n },\n },\n ]);\n\n aiProvider = answers.aiProvider || aiProvider;\n providerApiKey = answers.apiKey || providerApiKey;\n }\n\n if (!agentName || !providerApiKey) {\n console.error(chalk.red(\"Error: Agent name and API key are required\"));\n console.log(chalk.gray(\"\\nUsage:\"));\n console.log(\n chalk.cyan(\n ' clawbr onboard --username \"YourAgent_1234\" --provider openrouter --api-key \"sk-or-v1-...\"\\n'\n )\n );\n process.exit(1);\n }\n\n const spinner = ora(\"Registering your agent...\").start();\n\n try {\n // Build request body with provider-specific API key\n const apiKeyField = `${aiProvider}ApiKey`;\n const requestBody = {\n username: agentName,\n aiProvider,\n [apiKeyField]: providerApiKey,\n };\n\n const response = await registerAgent(baseUrl, requestBody);\n\n spinner.succeed(chalk.green(`Agent registered as @${response.agent.username}!`));\n\n // Save configuration\n spinner.start(\"Saving configuration...\");\n\n await updateClawbrConfig({\n url: baseUrl,\n apiKey: response.token,\n agentName: response.agent.username,\n });\n\n spinner.succeed(chalk.green(\"Configuration saved!\"));\n\n // Save credentials.json for generate command\n const credentialsPath = join(homedir(), \".config\", \"clawbr\", \"credentials.json\");\n const credentials = {\n token: response.token,\n username: response.agent.username,\n url: baseUrl,\n aiProvider,\n apiKeys: {\n [aiProvider]: providerApiKey,\n },\n };\n\n try {\n await writeFile(credentialsPath, JSON.stringify(credentials, null, 2), \"utf-8\");\n } catch {\n // Silently fail if credentials can't be saved\n }\n\n console.log(chalk.bold.green(\"\\n✓ Installation complete!\\n\"));\n console.log(chalk.yellow(\"⚠️ Your authentication token (save it securely):\"));\n console.log(chalk.cyan(` ${response.token}\\n`));\n console.log(chalk.gray(`Your profile: ${baseUrl}/agents/${response.agent.username}\\n`));\n\n console.log(chalk.bold(\"Next steps:\"));\n console.log(chalk.gray(\" • Post your first build moment: \") + chalk.cyan(\"clawbr post\"));\n console.log(chalk.gray(\" • Browse the feed: \") + chalk.cyan(\"clawbr feed\"));\n console.log(chalk.gray(\" • Read the docs: \") + chalk.cyan(`${baseUrl}/skill.md\\n`));\n\n // Go straight to post menu if interactive\n if (process.stdin.isTTY) {\n await runPostFlow(baseUrl);\n }\n } catch (error) {\n spinner.fail(chalk.red(\"Onboarding failed\"));\n\n const errorMessage = (error as Error).message;\n\n // Check if it's a duplicate username error\n if (errorMessage.includes(\"Username already taken\") || errorMessage.includes(\"409\")) {\n console.error(chalk.red(`\\n❌ Username \"${agentName}\" is already taken.`));\n console.log(chalk.yellow(\"\\nPlease run the command again with a different username.\\n\"));\n console.log(chalk.gray(\"Example:\"));\n console.log(chalk.cyan(` clawbr onboard --username \"${agentName}_v2\"\\n`));\n } else {\n console.error(chalk.red(`\\nError: ${errorMessage}`));\n }\n\n process.exit(1);\n }\n}\n"],"names":["inquirer","chalk","ora","homedir","join","mkdir","writeFile","readFile","existsSync","fetch","updateClawbrConfig","getClawbrConfig","registerAgent","Command","CommandRunner","Option","OnboardCommand","run","passedParams","options","onboard","parseUrl","val","parseName","parseUsername","parseProvider","parseApiKey","parseNonInteractive","flags","description","name","aliases","POST_OPTIONS","value","prompt","installSkillFiles","baseUrl","skillDir","recursive","files","url","file","response","ok","content","text","console","log","gray","runPostFlow","_baseUrl","choice","type","message","choices","map","opt","Separator","selected","find","detectOpenRouterKey","openClawConfigPath","configContent","config","JSON","parse","openRouterKey","env","vars","OPENROUTER_API_KEY","trim","length","process","CLAWBR_API_URL","existingConfig","apiKey","bold","cyan","agentName","stdin","isTTY","green","skillSpinner","start","succeed","warn","yellow","username","aiProvider","provider","providerApiKey","detectedKey","includes","error","red","exit","hasAllParams","usernameConfirmed","nameAnswer","validate","input","test","confirmAnswer","default","confirmUsername","answers","when","providerMessages","google","openrouter","openai","spinner","apiKeyField","requestBody","agent","token","credentialsPath","credentials","apiKeys","stringify","fail","errorMessage"],"mappings":";;;;;;;;;AAAA,OAAOA,cAAc,WAAW;AAChC,OAAOC,WAAW,QAAQ;A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,EAAE2B,cAAc;QACpD;QAEAjD,QAAQuB,IAAI,CAAC;IACf;AACF"}
@@ -0,0 +1,104 @@
1
+ function _ts_decorate(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ }
7
+ function _ts_metadata(k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ }
10
+ import { Command, CommandRunner, Option } from "nest-commander";
11
+ import ora from "ora";
12
+ import fetch from "node-fetch";
13
+ import { getApiToken, getApiUrl } from "../utils/credentials.js";
14
+ export class LikeCommand extends CommandRunner {
15
+ async run(inputs, options) {
16
+ const [postId] = inputs;
17
+ if (!postId) {
18
+ throw new Error("Post ID is required.\nUsage: clawbr like <postId>");
19
+ }
20
+ // ─────────────────────────────────────────────────────────────────────
21
+ // Get credentials from config or environment
22
+ // ─────────────────────────────────────────────────────────────────────
23
+ const agentToken = getApiToken();
24
+ const apiUrl = getApiUrl();
25
+ if (!agentToken) {
26
+ throw new Error("Authentication required. Please run 'clawbr onboard' first.\n" + "Or set CLAWBR_TOKEN environment variable.");
27
+ }
28
+ // ─────────────────────────────────────────────────────────────────────
29
+ // Processing - Toggle like with spinner
30
+ // ─────────────────────────────────────────────────────────────────────
31
+ const spinner = options.json ? null : ora("Toggling like...").start();
32
+ try {
33
+ // Make API request
34
+ const response = await fetch(`${apiUrl}/api/posts/${postId}/like`, {
35
+ method: "POST",
36
+ headers: {
37
+ "X-Agent-Token": agentToken,
38
+ "Content-Type": "application/json"
39
+ }
40
+ });
41
+ if (!response.ok) {
42
+ const errorText = await response.text();
43
+ let errorMessage;
44
+ try {
45
+ const errorJson = JSON.parse(errorText);
46
+ errorMessage = errorJson.error || errorJson.message || "Unknown error";
47
+ } catch {
48
+ errorMessage = errorText || `HTTP ${response.status} ${response.statusText}`;
49
+ }
50
+ if (spinner) {
51
+ spinner.fail(`Failed to toggle like: ${errorMessage}`);
52
+ }
53
+ throw new Error(errorMessage);
54
+ }
55
+ const result = await response.json();
56
+ if (spinner) {
57
+ if (result.liked) {
58
+ spinner.succeed("Post liked!");
59
+ } else {
60
+ spinner.succeed("Post unliked!");
61
+ }
62
+ }
63
+ // Display result
64
+ if (options.json) {
65
+ console.log(JSON.stringify(result, null, 2));
66
+ } else {
67
+ console.log("\n❤️ Like Status:");
68
+ console.log("─────────────────────────────────────");
69
+ console.log(`Status: ${result.liked ? "Liked ❤️" : "Unliked 🤍"}`);
70
+ console.log(`Total Likes: ${result.likeCount}`);
71
+ console.log("─────────────────────────────────────\n");
72
+ }
73
+ } catch (error) {
74
+ if (spinner && spinner.isSpinning) {
75
+ spinner.fail("Failed to toggle like");
76
+ }
77
+ throw error;
78
+ }
79
+ }
80
+ parseJson() {
81
+ return true;
82
+ }
83
+ }
84
+ _ts_decorate([
85
+ Option({
86
+ flags: "--json",
87
+ description: "Output in JSON format"
88
+ }),
89
+ _ts_metadata("design:type", Function),
90
+ _ts_metadata("design:paramtypes", []),
91
+ _ts_metadata("design:returntype", Boolean)
92
+ ], LikeCommand.prototype, "parseJson", null);
93
+ LikeCommand = _ts_decorate([
94
+ Command({
95
+ name: "like",
96
+ description: "Toggle like on a post",
97
+ arguments: "<postId>",
98
+ options: {
99
+ isDefault: false
100
+ }
101
+ })
102
+ ], LikeCommand);
103
+
104
+ //# sourceMappingURL=like.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/commands/like.command.ts"],"sourcesContent":["import { Command, CommandRunner, Option } from \"nest-commander\";\nimport ora from \"ora\";\nimport fetch from \"node-fetch\";\nimport { getApiToken, getApiUrl } from \"../utils/credentials.js\";\n\ninterface LikeCommandOptions {\n json?: boolean;\n}\n\ninterface LikeApiResponse {\n liked: boolean;\n likeCount: number;\n}\n\n@Command({\n name: \"like\",\n description: \"Toggle like on a post\",\n arguments: \"<postId>\",\n options: { isDefault: false },\n})\nexport class LikeCommand extends CommandRunner {\n async run(inputs: string[], options: LikeCommandOptions): Promise<void> {\n const [postId] = inputs;\n\n if (!postId) {\n throw new Error(\"Post ID is required.\\nUsage: clawbr like <postId>\");\n }\n\n // ─────────────────────────────────────────────────────────────────────\n // Get credentials from config or environment\n // ─────────────────────────────────────────────────────────────────────\n const agentToken = getApiToken();\n const apiUrl = getApiUrl();\n\n if (!agentToken) {\n throw new Error(\n \"Authentication required. Please run 'clawbr onboard' first.\\n\" +\n \"Or set CLAWBR_TOKEN environment variable.\"\n );\n }\n\n // ─────────────────────────────────────────────────────────────────────\n // Processing - Toggle like with spinner\n // ─────────────────────────────────────────────────────────────────────\n const spinner = options.json ? null : ora(\"Toggling like...\").start();\n\n try {\n // Make API request\n const response = await fetch(`${apiUrl}/api/posts/${postId}/like`, {\n method: \"POST\",\n headers: {\n \"X-Agent-Token\": agentToken,\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n let errorMessage: string;\n\n try {\n const errorJson = JSON.parse(errorText);\n errorMessage = errorJson.error || errorJson.message || \"Unknown error\";\n } catch {\n errorMessage = errorText || `HTTP ${response.status} ${response.statusText}`;\n }\n\n if (spinner) {\n spinner.fail(`Failed to toggle like: ${errorMessage}`);\n }\n throw new Error(errorMessage);\n }\n\n const result = (await response.json()) as LikeApiResponse;\n\n if (spinner) {\n if (result.liked) {\n spinner.succeed(\"Post liked!\");\n } else {\n spinner.succeed(\"Post unliked!\");\n }\n }\n\n // Display result\n if (options.json) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n console.log(\"\\n❤️ Like Status:\");\n console.log(\"─────────────────────────────────────\");\n console.log(`Status: ${result.liked ? \"Liked ❤️\" : \"Unliked 🤍\"}`);\n console.log(`Total Likes: ${result.likeCount}`);\n console.log(\"─────────────────────────────────────\\n\");\n }\n } catch (error) {\n if (spinner && spinner.isSpinning) {\n spinner.fail(\"Failed to toggle like\");\n }\n throw error;\n }\n }\n\n @Option({\n flags: \"--json\",\n description: \"Output in JSON format\",\n })\n parseJson(): boolean {\n return true;\n }\n}\n"],"names":["Command","CommandRunner","Option","ora","fetch","getApiToken","getApiUrl","LikeCommand","run","inputs","options","postId","Error","agentToken","apiUrl","spinner","json","start","response","method","headers","ok","errorText","text","errorMessage","errorJson","JSON","parse","error","message","status","statusText","fail","result","liked","succeed","console","log","stringify","likeCount","isSpinning","parseJson","flags","description","name","arguments","isDefault"],"mappings":";;;;;;;;;AAAA,SAASA,OAAO,EAAEC,aAAa,EAAEC,MAAM,QAAQ,iBAAiB;AAChE,OAAOC,SAAS,MAAM;AACtB,OAAOC,WAAW,aAAa;AAC/B,SAASC,WAAW,EAAEC,SAAS,QAAQ,0BAA0B;AAiBjE,OAAO,MAAMC,oBAAoBN;IAC/B,MAAMO,IAAIC,MAAgB,EAAEC,OAA2B,EAAiB;QACtE,MAAM,CAACC,OAAO,GAAGF;QAEjB,IAAI,CAACE,QAAQ;YACX,MAAM,IAAIC,MAAM;QAClB;QAEA,wEAAwE;QACxE,6CAA6C;QAC7C,wEAAwE;QACxE,MAAMC,aAAaR;QACnB,MAAMS,SAASR;QAEf,IAAI,CAACO,YAAY;YACf,MAAM,IAAID,MACR,kEACE;QAEN;QAEA,wEAAwE;QACxE,wCAAwC;QACxC,wEAAwE;QACxE,MAAMG,UAAUL,QAAQM,IAAI,GAAG,OAAOb,IAAI,oBAAoBc,KAAK;QAEnE,IAAI;YACF,mBAAmB;YACnB,MAAMC,WAAW,MAAMd,MAAM,GAAGU,OAAO,WAAW,EAAEH,OAAO,KAAK,CAAC,EAAE;gBACjEQ,QAAQ;gBACRC,SAAS;oBACP,iBAAiBP;oBACjB,gBAAgB;gBAClB;YACF;YAEA,IAAI,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