@nordsym/apiclaw 1.3.6 → 1.3.8
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 +422 -169
- package/convex/_generated/api.d.ts +16 -0
- package/convex/agents.ts +403 -0
- package/convex/billing.ts +651 -216
- package/convex/crons.ts +17 -0
- package/convex/directCall.ts +80 -0
- package/convex/earnProgress.ts +753 -0
- package/convex/email.ts +135 -82
- package/convex/feedback.ts +265 -0
- package/convex/http.ts +80 -4
- package/convex/logs.ts +304 -0
- package/convex/providerKeys.ts +289 -0
- package/convex/providers.ts +18 -0
- package/convex/schema.ts +185 -1
- package/convex/stripeActions.ts +512 -0
- package/convex/webhooks.ts +494 -0
- package/convex/workspaces.ts +158 -3
- package/dist/adapters/base.d.ts +112 -0
- package/dist/adapters/base.d.ts.map +1 -0
- package/dist/adapters/base.js +247 -0
- package/dist/adapters/base.js.map +1 -0
- package/dist/adapters/claude-desktop.d.ts +12 -0
- package/dist/adapters/claude-desktop.d.ts.map +1 -0
- package/dist/adapters/claude-desktop.js +36 -0
- package/dist/adapters/claude-desktop.js.map +1 -0
- package/dist/adapters/cline.d.ts +20 -0
- package/dist/adapters/cline.d.ts.map +1 -0
- package/dist/adapters/cline.js +77 -0
- package/dist/adapters/cline.js.map +1 -0
- package/dist/adapters/continue.d.ts +26 -0
- package/dist/adapters/continue.d.ts.map +1 -0
- package/dist/adapters/continue.js +68 -0
- package/dist/adapters/continue.js.map +1 -0
- package/dist/adapters/cursor.d.ts +12 -0
- package/dist/adapters/cursor.d.ts.map +1 -0
- package/dist/adapters/cursor.js +38 -0
- package/dist/adapters/cursor.js.map +1 -0
- package/dist/adapters/custom.d.ts +47 -0
- package/dist/adapters/custom.d.ts.map +1 -0
- package/dist/adapters/custom.js +146 -0
- package/dist/adapters/custom.js.map +1 -0
- package/dist/adapters/detect.d.ts +69 -0
- package/dist/adapters/detect.d.ts.map +1 -0
- package/dist/adapters/detect.js +158 -0
- package/dist/adapters/detect.js.map +1 -0
- package/dist/adapters/index.d.ts +21 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +23 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/windsurf.d.ts +12 -0
- package/dist/adapters/windsurf.d.ts.map +1 -0
- package/dist/adapters/windsurf.js +39 -0
- package/dist/adapters/windsurf.js.map +1 -0
- package/dist/bin.d.ts +9 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +19 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +34 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +312 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/index.d.ts +9 -0
- package/dist/cli/commands/index.d.ts.map +1 -0
- package/dist/cli/commands/index.js +9 -0
- package/dist/cli/commands/index.js.map +1 -0
- package/dist/cli/commands/restore.d.ts +50 -0
- package/dist/cli/commands/restore.d.ts.map +1 -0
- package/dist/cli/commands/restore.js +260 -0
- package/dist/cli/commands/restore.js.map +1 -0
- package/dist/cli/commands/setup.d.ts +19 -0
- package/dist/cli/commands/setup.d.ts.map +1 -0
- package/dist/cli/commands/setup.js +206 -0
- package/dist/cli/commands/setup.js.map +1 -0
- package/dist/cli/commands/uninstall.d.ts +37 -0
- package/dist/cli/commands/uninstall.d.ts.map +1 -0
- package/dist/cli/commands/uninstall.js +189 -0
- package/dist/cli/commands/uninstall.js.map +1 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +97 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/discovery.d.ts +6 -2
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +296 -2
- package/dist/discovery.js.map +1 -1
- package/dist/enterprise/env.d.ts +56 -0
- package/dist/enterprise/env.d.ts.map +1 -0
- package/dist/enterprise/env.js +124 -0
- package/dist/enterprise/env.js.map +1 -0
- package/dist/enterprise/index.d.ts +7 -0
- package/dist/enterprise/index.d.ts.map +1 -0
- package/dist/enterprise/index.js +7 -0
- package/dist/enterprise/index.js.map +1 -0
- package/dist/enterprise/script-generator.d.ts +32 -0
- package/dist/enterprise/script-generator.d.ts.map +1 -0
- package/dist/enterprise/script-generator.js +461 -0
- package/dist/enterprise/script-generator.js.map +1 -0
- package/dist/execute.d.ts +21 -0
- package/dist/execute.d.ts.map +1 -1
- package/dist/execute.js +231 -0
- package/dist/execute.js.map +1 -1
- package/dist/index.js +257 -7
- package/dist/index.js.map +1 -1
- package/dist/metered.d.ts +62 -0
- package/dist/metered.d.ts.map +1 -0
- package/dist/metered.js +81 -0
- package/dist/metered.js.map +1 -0
- package/dist/stripe.d.ts +62 -0
- package/dist/stripe.d.ts.map +1 -1
- package/dist/stripe.js +212 -0
- package/dist/stripe.js.map +1 -1
- package/dist/types.d.ts +29 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/colors.d.ts +111 -0
- package/dist/ui/colors.d.ts.map +1 -0
- package/dist/ui/colors.js +185 -0
- package/dist/ui/colors.js.map +1 -0
- package/dist/ui/errors.d.ts +69 -0
- package/dist/ui/errors.d.ts.map +1 -0
- package/dist/ui/errors.js +334 -0
- package/dist/ui/errors.js.map +1 -0
- package/dist/ui/index.d.ts +10 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +14 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/prompts.d.ts +88 -0
- package/dist/ui/prompts.d.ts.map +1 -0
- package/dist/ui/prompts.js +295 -0
- package/dist/ui/prompts.js.map +1 -0
- package/dist/ui/spinner.d.ts +112 -0
- package/dist/ui/spinner.d.ts.map +1 -0
- package/dist/ui/spinner.js +229 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/utils/backup.d.ts +48 -0
- package/dist/utils/backup.d.ts.map +1 -0
- package/dist/utils/backup.js +182 -0
- package/dist/utils/backup.js.map +1 -0
- package/dist/utils/config.d.ts +80 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +221 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/os.d.ts +45 -0
- package/dist/utils/os.d.ts.map +1 -0
- package/dist/utils/os.js +106 -0
- package/dist/utils/os.js.map +1 -0
- package/dist/utils/paths.d.ts +38 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +160 -0
- package/dist/utils/paths.js.map +1 -0
- package/docs/PRD-BILLING.md +226 -0
- package/docs/PRD-EARN-SYSTEM.md +261 -0
- package/docs/PRD-MCP-AUTO-SETUP.md +623 -0
- package/docs/PRD-final-polish.md +117 -0
- package/docs/PRD-mobile-responsive.md +56 -0
- package/docs/PRD-navigation-expansion.md +295 -0
- package/docs/PRD-stripe-billing.md +312 -0
- package/docs/PRD-workspace-cleanup.md +200 -0
- package/docs/enterprise-deployment.md +728 -0
- package/landing/next.config.mjs +14 -0
- package/landing/public/stats.json +4 -2
- package/landing/scripts/generate-stats.js +12 -0
- package/landing/src/app/api/billing/checkout/route.ts +109 -0
- package/landing/src/app/api/billing/payment-method/route.ts +118 -0
- package/landing/src/app/api/billing/portal/route.ts +64 -0
- package/landing/src/app/api/workspace-auth/magic-link/route.ts +6 -3
- package/landing/src/app/auth/verify/page.tsx +31 -9
- package/landing/src/app/docs/page.tsx +1 -1
- package/landing/src/app/earn/page.tsx +6 -6
- package/landing/src/app/join/page.tsx +49 -0
- package/landing/src/app/login/page.tsx +8 -2
- package/landing/src/app/page.tsx +81 -96
- package/landing/src/app/providers/dashboard/page.tsx +1 -1
- package/landing/src/app/providers/register/page.tsx +1 -1
- package/landing/src/app/workspace/page.tsx +3269 -534
- package/landing/src/components/CheckoutButton.tsx +188 -0
- package/landing/src/components/EarnCreditsTab.tsx +842 -0
- package/landing/src/components/Toast.tsx +84 -0
- package/landing/src/lib/stats.json +3 -1
- package/package.json +9 -2
- package/src/adapters/base.ts +363 -0
- package/src/adapters/claude-desktop.ts +41 -0
- package/src/adapters/cline.ts +88 -0
- package/src/adapters/continue.ts +91 -0
- package/src/adapters/cursor.ts +43 -0
- package/src/adapters/custom.ts +188 -0
- package/src/adapters/detect.ts +202 -0
- package/src/adapters/index.ts +47 -0
- package/src/adapters/windsurf.ts +44 -0
- package/src/bin.ts +19 -0
- package/src/cli/commands/doctor.ts +367 -0
- package/src/cli/commands/index.ts +9 -0
- package/src/cli/commands/restore.ts +333 -0
- package/src/cli/commands/setup.ts +276 -0
- package/src/cli/commands/uninstall.ts +240 -0
- package/src/cli/index.ts +107 -0
- package/src/discovery.ts +328 -3
- package/src/enterprise/env.ts +156 -0
- package/src/enterprise/index.ts +7 -0
- package/src/enterprise/script-generator.ts +481 -0
- package/src/execute.ts +256 -0
- package/src/index.ts +290 -7
- package/src/metered.ts +149 -0
- package/src/stripe.ts +253 -0
- package/src/types.ts +32 -0
- package/src/ui/colors.ts +219 -0
- package/src/ui/errors.ts +394 -0
- package/src/ui/index.ts +17 -0
- package/src/ui/prompts.ts +390 -0
- package/src/ui/spinner.ts +325 -0
- package/src/utils/backup.ts +224 -0
- package/src/utils/config.ts +315 -0
- package/src/utils/os.ts +124 -0
- package/src/utils/paths.ts +203 -0
- package/landing/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { Check, X, AlertCircle, Info } from "lucide-react";
|
|
5
|
+
|
|
6
|
+
export type ToastType = "success" | "error" | "info";
|
|
7
|
+
|
|
8
|
+
interface ToastProps {
|
|
9
|
+
message: string;
|
|
10
|
+
type?: ToastType;
|
|
11
|
+
duration?: number;
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function Toast({ message, type = "success", duration = 5000, onClose }: ToastProps) {
|
|
16
|
+
const [isVisible, setIsVisible] = useState(true);
|
|
17
|
+
const [isLeaving, setIsLeaving] = useState(false);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const timer = setTimeout(() => {
|
|
21
|
+
setIsLeaving(true);
|
|
22
|
+
setTimeout(onClose, 300);
|
|
23
|
+
}, duration);
|
|
24
|
+
|
|
25
|
+
return () => clearTimeout(timer);
|
|
26
|
+
}, [duration, onClose]);
|
|
27
|
+
|
|
28
|
+
const handleClose = () => {
|
|
29
|
+
setIsLeaving(true);
|
|
30
|
+
setTimeout(onClose, 300);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const icons = {
|
|
34
|
+
success: <Check className="w-5 h-5" />,
|
|
35
|
+
error: <AlertCircle className="w-5 h-5" />,
|
|
36
|
+
info: <Info className="w-5 h-5" />,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const colors = {
|
|
40
|
+
success: "bg-green-500/20 border-green-500/50 text-green-500",
|
|
41
|
+
error: "bg-red-500/20 border-red-500/50 text-red-500",
|
|
42
|
+
info: "bg-blue-500/20 border-blue-500/50 text-blue-500",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const iconBg = {
|
|
46
|
+
success: "bg-green-500/20",
|
|
47
|
+
error: "bg-red-500/20",
|
|
48
|
+
info: "bg-blue-500/20",
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
className={`fixed top-4 right-4 z-[100] flex items-center gap-3 px-4 py-3 rounded-xl border backdrop-blur-sm shadow-lg transition-all duration-300 ${
|
|
54
|
+
colors[type]
|
|
55
|
+
} ${isLeaving ? "opacity-0 translate-x-4" : "opacity-100 translate-x-0"}`}
|
|
56
|
+
>
|
|
57
|
+
<div className={`w-8 h-8 rounded-lg ${iconBg[type]} flex items-center justify-center flex-shrink-0`}>
|
|
58
|
+
{icons[type]}
|
|
59
|
+
</div>
|
|
60
|
+
<span className="text-[var(--text-primary)] font-medium">{message}</span>
|
|
61
|
+
<button
|
|
62
|
+
onClick={handleClose}
|
|
63
|
+
className="ml-2 p-1 rounded-lg hover:bg-white/10 transition"
|
|
64
|
+
>
|
|
65
|
+
<X className="w-4 h-4 text-[var(--text-muted)]" />
|
|
66
|
+
</button>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Hook for managing toasts
|
|
72
|
+
export function useToast() {
|
|
73
|
+
const [toast, setToast] = useState<{ message: string; type: ToastType } | null>(null);
|
|
74
|
+
|
|
75
|
+
const showToast = (message: string, type: ToastType = "success") => {
|
|
76
|
+
setToast({ message, type });
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const hideToast = () => {
|
|
80
|
+
setToast(null);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return { toast, showToast, hideToast };
|
|
84
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"apiCount": 22392,
|
|
3
|
+
"openApiCount": 1636,
|
|
4
|
+
"directCallCount": 10,
|
|
3
5
|
"categoryCount": 13,
|
|
4
6
|
"lastUpdated": "2026-02-27T09:10:41.344767",
|
|
5
|
-
"generatedAt": "2026-
|
|
7
|
+
"generatedAt": "2026-03-01T02:24:02.189Z",
|
|
6
8
|
"categoryBreakdown": {
|
|
7
9
|
"Finance": 1179,
|
|
8
10
|
"Auth & Security": 491,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nordsym/apiclaw",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
4
4
|
"description": "Agent-native API discovery and Direct Call execution via MCP",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,17 +28,24 @@
|
|
|
28
28
|
"@hono/node-server": "^1.19.9",
|
|
29
29
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
30
30
|
"@supabase/supabase-js": "^2.39.0",
|
|
31
|
+
"@types/inquirer": "^9.0.9",
|
|
32
|
+
"chalk": "^5.6.2",
|
|
33
|
+
"commander": "^14.0.3",
|
|
31
34
|
"convex": "^1.32.0",
|
|
32
35
|
"dotenv": "^17.3.1",
|
|
36
|
+
"fs-extra": "^11.3.3",
|
|
33
37
|
"hono": "^4.0.0",
|
|
38
|
+
"inquirer": "^13.3.0",
|
|
39
|
+
"ora": "^9.3.0",
|
|
34
40
|
"stripe": "^20.3.1"
|
|
35
41
|
},
|
|
36
42
|
"devDependencies": {
|
|
43
|
+
"@types/fs-extra": "^11.0.4",
|
|
37
44
|
"@types/node": "^20.10.0",
|
|
38
45
|
"tsx": "^4.7.0",
|
|
39
46
|
"typescript": "^5.3.0"
|
|
40
47
|
},
|
|
41
48
|
"bin": {
|
|
42
|
-
"apiclaw": "./dist/
|
|
49
|
+
"apiclaw": "./dist/bin.js"
|
|
43
50
|
}
|
|
44
51
|
}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Client Adapter - Base Interface & Abstract Class
|
|
3
|
+
* Defines the contract for all MCP client adapters
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { existsSync } from 'fs';
|
|
7
|
+
import { dirname } from 'path';
|
|
8
|
+
import { MCPClient, getConfigPath, getClientConfig } from '../utils/paths.js';
|
|
9
|
+
import { detectOS, Platform } from '../utils/os.js';
|
|
10
|
+
import { createBackup, BackupResult } from '../utils/backup.js';
|
|
11
|
+
import {
|
|
12
|
+
readConfig,
|
|
13
|
+
writeConfig,
|
|
14
|
+
mergeApiclawConfig,
|
|
15
|
+
mergeApiclawContinueConfig,
|
|
16
|
+
hasApiclawConfig,
|
|
17
|
+
MCPConfig,
|
|
18
|
+
ContinueConfig,
|
|
19
|
+
isContinueFormat,
|
|
20
|
+
} from '../utils/config.js';
|
|
21
|
+
|
|
22
|
+
export interface ConfigResult {
|
|
23
|
+
success: boolean;
|
|
24
|
+
message: string;
|
|
25
|
+
configPath: string;
|
|
26
|
+
backupPath?: string | null;
|
|
27
|
+
isNew?: boolean;
|
|
28
|
+
alreadyConfigured?: boolean;
|
|
29
|
+
error?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface VerifyResult {
|
|
33
|
+
success: boolean;
|
|
34
|
+
hasConfig: boolean;
|
|
35
|
+
configValid: boolean;
|
|
36
|
+
message: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface InstallInfo {
|
|
40
|
+
installed: boolean;
|
|
41
|
+
appPath?: string;
|
|
42
|
+
configExists: boolean;
|
|
43
|
+
configPath: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ConfigureOptions {
|
|
47
|
+
workspaceId?: string;
|
|
48
|
+
serverName?: string;
|
|
49
|
+
force?: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* MCP Client Adapter Interface
|
|
54
|
+
*/
|
|
55
|
+
export interface MCPClientAdapter {
|
|
56
|
+
/** Internal client name */
|
|
57
|
+
name: MCPClient | 'custom';
|
|
58
|
+
|
|
59
|
+
/** Human-readable display name */
|
|
60
|
+
displayName: string;
|
|
61
|
+
|
|
62
|
+
/** Check if the client is installed on the system */
|
|
63
|
+
isInstalled(): Promise<boolean>;
|
|
64
|
+
|
|
65
|
+
/** Get the config file path for this client */
|
|
66
|
+
getConfigPath(): string;
|
|
67
|
+
|
|
68
|
+
/** Configure APIClaw MCP server for this client */
|
|
69
|
+
configure(options?: ConfigureOptions): Promise<ConfigResult>;
|
|
70
|
+
|
|
71
|
+
/** Verify the current configuration */
|
|
72
|
+
verify(): Promise<VerifyResult>;
|
|
73
|
+
|
|
74
|
+
/** Get detailed installation info */
|
|
75
|
+
getInstallInfo(): Promise<InstallInfo>;
|
|
76
|
+
|
|
77
|
+
/** Remove APIClaw configuration */
|
|
78
|
+
unconfigure(serverName?: string): Promise<ConfigResult>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Abstract base class for MCP client adapters
|
|
83
|
+
* Provides common functionality for all adapters
|
|
84
|
+
*/
|
|
85
|
+
export abstract class BaseAdapter implements MCPClientAdapter {
|
|
86
|
+
abstract name: MCPClient | 'custom';
|
|
87
|
+
abstract displayName: string;
|
|
88
|
+
|
|
89
|
+
protected os: Platform;
|
|
90
|
+
|
|
91
|
+
constructor() {
|
|
92
|
+
this.os = detectOS();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Get the config file path
|
|
97
|
+
*/
|
|
98
|
+
getConfigPath(): string {
|
|
99
|
+
if (this.name === 'custom') {
|
|
100
|
+
throw new Error('Custom adapter must override getConfigPath()');
|
|
101
|
+
}
|
|
102
|
+
return getConfigPath(this.name, this.os);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Check if config file exists
|
|
107
|
+
*/
|
|
108
|
+
protected configExists(): boolean {
|
|
109
|
+
try {
|
|
110
|
+
return existsSync(this.getConfigPath());
|
|
111
|
+
} catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Get application paths to check for installation
|
|
118
|
+
* Override in subclasses for specific clients
|
|
119
|
+
*/
|
|
120
|
+
protected abstract getAppPaths(): string[];
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Check if the client application is installed
|
|
124
|
+
*/
|
|
125
|
+
async isInstalled(): Promise<boolean> {
|
|
126
|
+
// Check if config file exists
|
|
127
|
+
if (this.configExists()) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Check if app is installed
|
|
132
|
+
const appPaths = this.getAppPaths();
|
|
133
|
+
for (const path of appPaths) {
|
|
134
|
+
if (existsSync(path)) {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Get detailed installation information
|
|
144
|
+
*/
|
|
145
|
+
async getInstallInfo(): Promise<InstallInfo> {
|
|
146
|
+
const configPath = this.getConfigPath();
|
|
147
|
+
const configExists = this.configExists();
|
|
148
|
+
|
|
149
|
+
let appPath: string | undefined;
|
|
150
|
+
const appPaths = this.getAppPaths();
|
|
151
|
+
for (const path of appPaths) {
|
|
152
|
+
if (existsSync(path)) {
|
|
153
|
+
appPath = path;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
installed: configExists || appPath !== undefined,
|
|
160
|
+
appPath,
|
|
161
|
+
configExists,
|
|
162
|
+
configPath,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Configure APIClaw MCP server
|
|
168
|
+
*/
|
|
169
|
+
async configure(options: ConfigureOptions = {}): Promise<ConfigResult> {
|
|
170
|
+
const configPath = this.getConfigPath();
|
|
171
|
+
|
|
172
|
+
try {
|
|
173
|
+
// Read existing config
|
|
174
|
+
const readResult = readConfig(configPath);
|
|
175
|
+
if (!readResult.success) {
|
|
176
|
+
return {
|
|
177
|
+
success: false,
|
|
178
|
+
message: `Failed to read config: ${readResult.error}`,
|
|
179
|
+
configPath,
|
|
180
|
+
error: readResult.error,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const config = readResult.config!;
|
|
185
|
+
const serverName = options.serverName || 'apiclaw';
|
|
186
|
+
|
|
187
|
+
// Check if already configured
|
|
188
|
+
if (!options.force && hasApiclawConfig(config, serverName)) {
|
|
189
|
+
return {
|
|
190
|
+
success: true,
|
|
191
|
+
message: `APIClaw already configured in ${this.displayName}`,
|
|
192
|
+
configPath,
|
|
193
|
+
alreadyConfigured: true,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Merge APIClaw config
|
|
198
|
+
const mergeOptions = {
|
|
199
|
+
workspace: options.workspaceId,
|
|
200
|
+
serverName,
|
|
201
|
+
force: options.force,
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const newConfig = this.mergeConfig(config, mergeOptions);
|
|
205
|
+
|
|
206
|
+
// Write config
|
|
207
|
+
const writeResult = writeConfig(configPath, newConfig);
|
|
208
|
+
if (!writeResult.success) {
|
|
209
|
+
return {
|
|
210
|
+
success: false,
|
|
211
|
+
message: `Failed to write config: ${writeResult.error}`,
|
|
212
|
+
configPath,
|
|
213
|
+
error: writeResult.error,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
success: true,
|
|
219
|
+
message: `Successfully configured APIClaw in ${this.displayName}`,
|
|
220
|
+
configPath,
|
|
221
|
+
backupPath: writeResult.backupPath,
|
|
222
|
+
isNew: readResult.isNew,
|
|
223
|
+
};
|
|
224
|
+
} catch (error) {
|
|
225
|
+
return {
|
|
226
|
+
success: false,
|
|
227
|
+
message: `Configuration failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
228
|
+
configPath,
|
|
229
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Merge APIClaw config into existing config
|
|
236
|
+
* Override in subclasses for special formats (e.g., Continue)
|
|
237
|
+
*/
|
|
238
|
+
protected mergeConfig(
|
|
239
|
+
config: MCPConfig | ContinueConfig,
|
|
240
|
+
options: { workspace?: string; serverName?: string; force?: boolean }
|
|
241
|
+
): MCPConfig | ContinueConfig {
|
|
242
|
+
return mergeApiclawConfig(config as MCPConfig, options);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Verify the current configuration
|
|
247
|
+
*/
|
|
248
|
+
async verify(): Promise<VerifyResult> {
|
|
249
|
+
const configPath = this.getConfigPath();
|
|
250
|
+
|
|
251
|
+
if (!this.configExists()) {
|
|
252
|
+
return {
|
|
253
|
+
success: false,
|
|
254
|
+
hasConfig: false,
|
|
255
|
+
configValid: false,
|
|
256
|
+
message: `Config file not found: ${configPath}`,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const readResult = readConfig(configPath);
|
|
261
|
+
if (!readResult.success) {
|
|
262
|
+
return {
|
|
263
|
+
success: false,
|
|
264
|
+
hasConfig: true,
|
|
265
|
+
configValid: false,
|
|
266
|
+
message: `Invalid config file: ${readResult.error}`,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const hasApiclaw = hasApiclawConfig(readResult.config!);
|
|
271
|
+
|
|
272
|
+
return {
|
|
273
|
+
success: hasApiclaw,
|
|
274
|
+
hasConfig: true,
|
|
275
|
+
configValid: true,
|
|
276
|
+
message: hasApiclaw
|
|
277
|
+
? `APIClaw is configured in ${this.displayName}`
|
|
278
|
+
: `APIClaw is not configured in ${this.displayName}`,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Remove APIClaw configuration
|
|
284
|
+
*/
|
|
285
|
+
async unconfigure(serverName = 'apiclaw'): Promise<ConfigResult> {
|
|
286
|
+
const configPath = this.getConfigPath();
|
|
287
|
+
|
|
288
|
+
try {
|
|
289
|
+
if (!this.configExists()) {
|
|
290
|
+
return {
|
|
291
|
+
success: true,
|
|
292
|
+
message: `No config file found for ${this.displayName}`,
|
|
293
|
+
configPath,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const readResult = readConfig(configPath);
|
|
298
|
+
if (!readResult.success) {
|
|
299
|
+
return {
|
|
300
|
+
success: false,
|
|
301
|
+
message: `Failed to read config: ${readResult.error}`,
|
|
302
|
+
configPath,
|
|
303
|
+
error: readResult.error,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const config = readResult.config!;
|
|
308
|
+
|
|
309
|
+
if (!hasApiclawConfig(config, serverName)) {
|
|
310
|
+
return {
|
|
311
|
+
success: true,
|
|
312
|
+
message: `APIClaw not found in ${this.displayName} config`,
|
|
313
|
+
configPath,
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Remove APIClaw config
|
|
318
|
+
const newConfig = this.removeFromConfig(config, serverName);
|
|
319
|
+
|
|
320
|
+
// Write config
|
|
321
|
+
const writeResult = writeConfig(configPath, newConfig);
|
|
322
|
+
if (!writeResult.success) {
|
|
323
|
+
return {
|
|
324
|
+
success: false,
|
|
325
|
+
message: `Failed to write config: ${writeResult.error}`,
|
|
326
|
+
configPath,
|
|
327
|
+
error: writeResult.error,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return {
|
|
332
|
+
success: true,
|
|
333
|
+
message: `Successfully removed APIClaw from ${this.displayName}`,
|
|
334
|
+
configPath,
|
|
335
|
+
backupPath: writeResult.backupPath,
|
|
336
|
+
};
|
|
337
|
+
} catch (error) {
|
|
338
|
+
return {
|
|
339
|
+
success: false,
|
|
340
|
+
message: `Unconfigure failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
341
|
+
configPath,
|
|
342
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Remove APIClaw from config
|
|
349
|
+
* Override in subclasses for special formats
|
|
350
|
+
*/
|
|
351
|
+
protected removeFromConfig(
|
|
352
|
+
config: MCPConfig | ContinueConfig,
|
|
353
|
+
serverName: string
|
|
354
|
+
): MCPConfig | ContinueConfig {
|
|
355
|
+
const mcpConfig = config as MCPConfig;
|
|
356
|
+
const { [serverName]: _, ...remainingServers } = mcpConfig.mcpServers || {};
|
|
357
|
+
|
|
358
|
+
return {
|
|
359
|
+
...mcpConfig,
|
|
360
|
+
mcpServers: remainingServers,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Desktop Adapter
|
|
3
|
+
* Handles MCP configuration for Claude Desktop app
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
import { BaseAdapter } from './base.js';
|
|
8
|
+
import { MCPClient } from '../utils/paths.js';
|
|
9
|
+
import { getHomeDir } from '../utils/os.js';
|
|
10
|
+
|
|
11
|
+
export class ClaudeDesktopAdapter extends BaseAdapter {
|
|
12
|
+
name: MCPClient = 'claude-desktop';
|
|
13
|
+
displayName = 'Claude Desktop';
|
|
14
|
+
|
|
15
|
+
protected getAppPaths(): string[] {
|
|
16
|
+
switch (this.os) {
|
|
17
|
+
case 'mac':
|
|
18
|
+
return [
|
|
19
|
+
'/Applications/Claude.app',
|
|
20
|
+
join(getHomeDir(), 'Applications', 'Claude.app'),
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
case 'win':
|
|
24
|
+
const localAppData = process.env.LOCALAPPDATA || join(getHomeDir(), 'AppData', 'Local');
|
|
25
|
+
const programFiles = process.env.PROGRAMFILES || 'C:\\Program Files';
|
|
26
|
+
return [
|
|
27
|
+
join(localAppData, 'Programs', 'Claude', 'Claude.exe'),
|
|
28
|
+
join(programFiles, 'Claude', 'Claude.exe'),
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
case 'linux':
|
|
32
|
+
return [
|
|
33
|
+
'/usr/bin/claude',
|
|
34
|
+
'/usr/local/bin/claude',
|
|
35
|
+
join(getHomeDir(), '.local', 'bin', 'claude'),
|
|
36
|
+
'/snap/bin/claude',
|
|
37
|
+
'/var/lib/flatpak/exports/bin/com.anthropic.claude',
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cline Adapter
|
|
3
|
+
* Handles MCP configuration for Cline VS Code extension
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
import { BaseAdapter } from './base.js';
|
|
8
|
+
import { MCPClient } from '../utils/paths.js';
|
|
9
|
+
import { getHomeDir, getAppDataDir } from '../utils/os.js';
|
|
10
|
+
|
|
11
|
+
export class ClineAdapter extends BaseAdapter {
|
|
12
|
+
name: MCPClient = 'cline';
|
|
13
|
+
displayName = 'Cline';
|
|
14
|
+
|
|
15
|
+
protected getAppPaths(): string[] {
|
|
16
|
+
// Cline is a VS Code extension, so we check for VS Code
|
|
17
|
+
// and the extension directory
|
|
18
|
+
const home = getHomeDir();
|
|
19
|
+
const appData = getAppDataDir();
|
|
20
|
+
|
|
21
|
+
switch (this.os) {
|
|
22
|
+
case 'mac':
|
|
23
|
+
return [
|
|
24
|
+
'/Applications/Visual Studio Code.app',
|
|
25
|
+
join(home, 'Applications', 'Visual Studio Code.app'),
|
|
26
|
+
// Also check for extension directory
|
|
27
|
+
join(home, '.vscode', 'extensions'),
|
|
28
|
+
join(appData, 'Code', 'User', 'globalStorage', 'saoudrizwan.claude-dev'),
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
case 'win':
|
|
32
|
+
const localAppData = process.env.LOCALAPPDATA || join(home, 'AppData', 'Local');
|
|
33
|
+
const programFiles = process.env.PROGRAMFILES || 'C:\\Program Files';
|
|
34
|
+
return [
|
|
35
|
+
join(localAppData, 'Programs', 'Microsoft VS Code', 'Code.exe'),
|
|
36
|
+
join(programFiles, 'Microsoft VS Code', 'Code.exe'),
|
|
37
|
+
// Extension directory
|
|
38
|
+
join(home, '.vscode', 'extensions'),
|
|
39
|
+
join(appData, 'Code', 'User', 'globalStorage', 'saoudrizwan.claude-dev'),
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
case 'linux':
|
|
43
|
+
return [
|
|
44
|
+
'/usr/bin/code',
|
|
45
|
+
'/usr/local/bin/code',
|
|
46
|
+
'/snap/bin/code',
|
|
47
|
+
join(home, '.local', 'bin', 'code'),
|
|
48
|
+
// Extension directory
|
|
49
|
+
join(home, '.vscode', 'extensions'),
|
|
50
|
+
join(home, '.config', 'Code', 'User', 'globalStorage', 'saoudrizwan.claude-dev'),
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Override isInstalled to also check for the Cline extension specifically
|
|
57
|
+
*/
|
|
58
|
+
async isInstalled(): Promise<boolean> {
|
|
59
|
+
// First check base implementation
|
|
60
|
+
if (await super.isInstalled()) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Check if Cline extension is installed
|
|
65
|
+
const extensionPaths = this.getClineExtensionPaths();
|
|
66
|
+
for (const path of extensionPaths) {
|
|
67
|
+
const { existsSync } = await import('fs');
|
|
68
|
+
if (existsSync(path)) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Get possible Cline extension installation paths
|
|
78
|
+
*/
|
|
79
|
+
private getClineExtensionPaths(): string[] {
|
|
80
|
+
const home = getHomeDir();
|
|
81
|
+
const extensionsDir = join(home, '.vscode', 'extensions');
|
|
82
|
+
|
|
83
|
+
// Extension directories are named like: saoudrizwan.claude-dev-x.x.x
|
|
84
|
+
return [
|
|
85
|
+
extensionsDir, // We'll check for pattern in isInstalled
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
}
|