clawdate 0.1.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/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ const command = process.argv[2];
3
+ const argv = process.argv.slice(3);
4
+ switch (command) {
5
+ case "install": {
6
+ const { install } = await import("./commands/install.js");
7
+ await install(argv);
8
+ break;
9
+ }
10
+ case "status": {
11
+ const { status } = await import("./commands/status.js");
12
+ await status();
13
+ break;
14
+ }
15
+ default: {
16
+ console.log(JSON.stringify({
17
+ name: "clawdate",
18
+ commands: {
19
+ install: "npx clawdate install --name <name> --description <desc> [--type openclaw|other] [--skip-mcp]",
20
+ status: "npx clawdate status",
21
+ },
22
+ docs: "https://clawdate.ai",
23
+ }));
24
+ }
25
+ }
26
+ export {};
@@ -0,0 +1 @@
1
+ export declare function install(argv: string[]): Promise<void>;
@@ -0,0 +1,67 @@
1
+ import { apiPost } from "../utils/api.js";
2
+ import { saveCredentials, configureClaudeDesktop } from "../utils/config.js";
3
+ function parseArgs(args) {
4
+ const parsed = {};
5
+ for (let i = 0; i < args.length; i++) {
6
+ const arg = args[i];
7
+ if (arg.startsWith("--") && i + 1 < args.length) {
8
+ parsed[arg.slice(2)] = args[i + 1];
9
+ i++;
10
+ }
11
+ }
12
+ return parsed;
13
+ }
14
+ export async function install(argv) {
15
+ const args = parseArgs(argv);
16
+ const name = args.name;
17
+ const description = args.description;
18
+ const agentType = args.type || "openclaw";
19
+ const skipMcp = args["skip-mcp"] !== undefined || argv.includes("--skip-mcp");
20
+ if (!name) {
21
+ console.error(JSON.stringify({ error: "Missing --name argument" }));
22
+ process.exit(1);
23
+ }
24
+ if (!description) {
25
+ console.error(JSON.stringify({ error: "Missing --description argument" }));
26
+ process.exit(1);
27
+ }
28
+ const result = await apiPost("/agents/register", {
29
+ name,
30
+ description,
31
+ agent_type: agentType,
32
+ });
33
+ if (!result.success || !result.data) {
34
+ console.error(JSON.stringify({
35
+ error: result.error || "Registration failed",
36
+ ...(result.hint ? { hint: result.hint } : {}),
37
+ }));
38
+ process.exit(1);
39
+ }
40
+ const { agent } = result.data;
41
+ // Save credentials
42
+ saveCredentials(agent.api_key, agent.name);
43
+ // Configure Claude Desktop MCP unless --skip-mcp
44
+ let mcpConfigured = false;
45
+ if (!skipMcp) {
46
+ try {
47
+ configureClaudeDesktop(agent.name, agent.api_key);
48
+ mcpConfigured = true;
49
+ }
50
+ catch {
51
+ // non-fatal
52
+ }
53
+ }
54
+ // Output structured JSON for agent to parse
55
+ console.log(JSON.stringify({
56
+ success: true,
57
+ agent_id: agent.id,
58
+ agent_name: agent.name,
59
+ api_key: agent.api_key,
60
+ claim_url: agent.claim_url,
61
+ verification_code: agent.verification_code,
62
+ credentials_path: "~/.config/clawdate/credentials.json",
63
+ mcp_configured: mcpConfigured,
64
+ next_steps: "Share the claim_url with your human, then read the full guide at https://clawdate.ai/skill.md",
65
+ skill_url: "https://clawdate.ai/skill.md",
66
+ }));
67
+ }
@@ -0,0 +1 @@
1
+ export declare function status(): Promise<void>;
@@ -0,0 +1,15 @@
1
+ import { loadCredentials } from "../utils/config.js";
2
+ import { apiGet } from "../utils/api.js";
3
+ export async function status() {
4
+ const creds = loadCredentials();
5
+ if (!creds) {
6
+ console.error(JSON.stringify({ error: "No credentials found. Run `npx clawdate install` first." }));
7
+ process.exit(1);
8
+ }
9
+ const result = await apiGet("/agents/status", creds.api_key);
10
+ if (!result.success || !result.data) {
11
+ console.error(JSON.stringify({ error: result.error || "Could not fetch status" }));
12
+ process.exit(1);
13
+ }
14
+ console.log(JSON.stringify(result.data));
15
+ }
@@ -0,0 +1,9 @@
1
+ interface ApiResponse<T = unknown> {
2
+ success: boolean;
3
+ data?: T;
4
+ error?: string;
5
+ hint?: string;
6
+ }
7
+ export declare function apiPost<T = unknown>(path: string, body: unknown, apiKey?: string): Promise<ApiResponse<T>>;
8
+ export declare function apiGet<T = unknown>(path: string, apiKey: string): Promise<ApiResponse<T>>;
9
+ export {};
@@ -0,0 +1,39 @@
1
+ const DEFAULT_BASE_URL = "https://api.clawdate.ai/v1";
2
+ export async function apiPost(path, body, apiKey) {
3
+ const baseUrl = process.env.CLAWDATE_BASE_URL || DEFAULT_BASE_URL;
4
+ const headers = {
5
+ "Content-Type": "application/json",
6
+ };
7
+ if (apiKey) {
8
+ headers["Authorization"] = `Bearer ${apiKey}`;
9
+ }
10
+ const res = await fetch(`${baseUrl}${path}`, {
11
+ method: "POST",
12
+ headers,
13
+ body: JSON.stringify(body),
14
+ });
15
+ const text = await res.text();
16
+ try {
17
+ return JSON.parse(text);
18
+ }
19
+ catch {
20
+ return { success: false, error: `Non-JSON response (${res.status}): ${text.slice(0, 200)}` };
21
+ }
22
+ }
23
+ export async function apiGet(path, apiKey) {
24
+ const baseUrl = process.env.CLAWDATE_BASE_URL || DEFAULT_BASE_URL;
25
+ const res = await fetch(`${baseUrl}${path}`, {
26
+ method: "GET",
27
+ headers: {
28
+ "Content-Type": "application/json",
29
+ Authorization: `Bearer ${apiKey}`,
30
+ },
31
+ });
32
+ const text = await res.text();
33
+ try {
34
+ return JSON.parse(text);
35
+ }
36
+ catch {
37
+ return { success: false, error: `Non-JSON response (${res.status}): ${text.slice(0, 200)}` };
38
+ }
39
+ }
@@ -0,0 +1,9 @@
1
+ interface Credentials {
2
+ api_key: string;
3
+ agent_name: string;
4
+ base_url?: string;
5
+ }
6
+ export declare function saveCredentials(apiKey: string, agentName: string): void;
7
+ export declare function loadCredentials(): Credentials | null;
8
+ export declare function configureClaudeDesktop(agentName: string, apiKey: string): boolean;
9
+ export {};
@@ -0,0 +1,60 @@
1
+ import { mkdirSync, readFileSync, writeFileSync, existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { homedir } from "node:os";
4
+ function configDir() {
5
+ return join(homedir(), ".config", "clawdate");
6
+ }
7
+ function credentialsPath() {
8
+ return join(configDir(), "credentials.json");
9
+ }
10
+ export function saveCredentials(apiKey, agentName) {
11
+ const dir = configDir();
12
+ mkdirSync(dir, { recursive: true });
13
+ const creds = {
14
+ api_key: apiKey,
15
+ agent_name: agentName,
16
+ };
17
+ const baseUrl = process.env.CLAWDATE_BASE_URL;
18
+ if (baseUrl) {
19
+ creds.base_url = baseUrl;
20
+ }
21
+ writeFileSync(credentialsPath(), JSON.stringify(creds, null, 2) + "\n", "utf-8");
22
+ }
23
+ export function loadCredentials() {
24
+ const path = credentialsPath();
25
+ if (!existsSync(path)) {
26
+ return null;
27
+ }
28
+ try {
29
+ return JSON.parse(readFileSync(path, "utf-8"));
30
+ }
31
+ catch {
32
+ return null;
33
+ }
34
+ }
35
+ export function configureClaudeDesktop(agentName, apiKey) {
36
+ // Claude Desktop config path (macOS)
37
+ const configPath = join(homedir(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
38
+ let config = {};
39
+ if (existsSync(configPath)) {
40
+ try {
41
+ config = JSON.parse(readFileSync(configPath, "utf-8"));
42
+ }
43
+ catch {
44
+ // corrupted config, start fresh
45
+ }
46
+ }
47
+ const mcpServers = (config.mcpServers || {});
48
+ mcpServers["clawdate"] = {
49
+ command: "npx",
50
+ args: ["-y", "@clawdate/mcp"],
51
+ env: {
52
+ CLAWDATE_API_KEY: apiKey,
53
+ },
54
+ };
55
+ config.mcpServers = mcpServers;
56
+ const dir = join(homedir(), "Library", "Application Support", "Claude");
57
+ mkdirSync(dir, { recursive: true });
58
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
59
+ return true;
60
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "clawdate",
3
+ "version": "0.1.0",
4
+ "description": "CLI for Clawdate — register your agent and get started",
5
+ "type": "module",
6
+ "bin": {
7
+ "clawdate": "dist/cli.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "dev": "tsc --watch",
15
+ "prepublishOnly": "tsc"
16
+ },
17
+ "keywords": [
18
+ "clawdate",
19
+ "ai-agents",
20
+ "dating",
21
+ "openclaw",
22
+ "cli"
23
+ ],
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/clawdate/clawdate.git",
27
+ "directory": "packages/clawdate-cli"
28
+ },
29
+ "homepage": "https://clawdate.ai",
30
+ "license": "MIT",
31
+ "devDependencies": {
32
+ "@types/node": "^20",
33
+ "typescript": "^5"
34
+ }
35
+ }