@nordsym/apiclaw 1.5.12 → 1.5.14

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 (70) hide show
  1. package/dist/bin.js +1 -1
  2. package/dist/cli/commands/mcp-install.js +6 -6
  3. package/dist/cli/index.js +7 -0
  4. package/dist/convex/adminActivate.js +46 -0
  5. package/dist/convex/adminStats.js +41 -0
  6. package/dist/convex/agents.js +498 -0
  7. package/dist/convex/analytics.js +165 -0
  8. package/dist/convex/billing.js +654 -0
  9. package/dist/convex/capabilities.js +144 -0
  10. package/dist/convex/chains.js +1041 -0
  11. package/dist/convex/credits.js +185 -0
  12. package/dist/convex/crons.js +16 -0
  13. package/dist/convex/directCall.js +626 -0
  14. package/dist/convex/earnProgress.js +648 -0
  15. package/dist/convex/email.js +299 -0
  16. package/dist/convex/feedback.js +226 -0
  17. package/dist/convex/http.js +909 -0
  18. package/dist/convex/logs.js +486 -0
  19. package/dist/convex/mou.js +81 -0
  20. package/dist/convex/providerKeys.js +256 -0
  21. package/dist/convex/providers.js +755 -0
  22. package/dist/convex/purchases.js +156 -0
  23. package/dist/convex/ratelimit.js +90 -0
  24. package/dist/convex/schema.js +709 -0
  25. package/dist/convex/searchLogs.js +128 -0
  26. package/dist/convex/spendAlerts.js +379 -0
  27. package/dist/convex/stripeActions.js +410 -0
  28. package/dist/convex/teams.js +214 -0
  29. package/dist/convex/telemetry.js +73 -0
  30. package/dist/convex/usage.js +228 -0
  31. package/dist/convex/waitlist.js +48 -0
  32. package/dist/convex/webhooks.js +409 -0
  33. package/dist/convex/workspaces.js +879 -0
  34. package/dist/src/analytics.js +129 -0
  35. package/dist/src/bin.js +17 -0
  36. package/dist/src/capability-router.js +240 -0
  37. package/dist/src/chainExecutor.js +451 -0
  38. package/dist/src/chainResolver.js +518 -0
  39. package/dist/src/cli/commands/doctor.js +324 -0
  40. package/dist/src/cli/commands/mcp-install.js +255 -0
  41. package/dist/src/cli/commands/restore.js +259 -0
  42. package/dist/src/cli/commands/setup.js +205 -0
  43. package/dist/src/cli/commands/uninstall.js +188 -0
  44. package/dist/src/cli/index.js +111 -0
  45. package/dist/src/cli.js +302 -0
  46. package/dist/src/confirmation.js +240 -0
  47. package/dist/src/credentials.js +357 -0
  48. package/dist/src/credits.js +260 -0
  49. package/dist/src/crypto.js +66 -0
  50. package/dist/src/discovery.js +504 -0
  51. package/dist/src/enterprise/env.js +123 -0
  52. package/dist/src/enterprise/script-generator.js +460 -0
  53. package/dist/src/execute-dynamic.js +473 -0
  54. package/dist/src/execute.js +1727 -0
  55. package/dist/src/index.js +2062 -0
  56. package/dist/src/metered.js +80 -0
  57. package/dist/src/open-apis.js +276 -0
  58. package/dist/src/proxy.js +28 -0
  59. package/dist/src/session.js +86 -0
  60. package/dist/src/stripe.js +407 -0
  61. package/dist/src/telemetry.js +49 -0
  62. package/dist/src/types.js +2 -0
  63. package/dist/src/utils/backup.js +181 -0
  64. package/dist/src/utils/config.js +220 -0
  65. package/dist/src/utils/os.js +105 -0
  66. package/dist/src/utils/paths.js +159 -0
  67. package/package.json +1 -1
  68. package/src/bin.ts +1 -1
  69. package/src/cli/commands/mcp-install.ts +6 -6
  70. package/src/cli/index.ts +8 -0
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Config Management
3
+ * Handles JSON read/write/merge operations for MCP config files
4
+ */
5
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
6
+ import { dirname } from 'path';
7
+ import { createBackup } from './backup.js';
8
+ /**
9
+ * Read and parse a JSON config file
10
+ */
11
+ export function readConfig(configPath) {
12
+ try {
13
+ if (!existsSync(configPath)) {
14
+ return {
15
+ success: true,
16
+ config: {},
17
+ isNew: true,
18
+ };
19
+ }
20
+ const content = readFileSync(configPath, 'utf-8');
21
+ // Handle empty files
22
+ if (!content.trim()) {
23
+ return {
24
+ success: true,
25
+ config: {},
26
+ isNew: true,
27
+ };
28
+ }
29
+ const config = JSON.parse(content);
30
+ return {
31
+ success: true,
32
+ config,
33
+ isNew: false,
34
+ };
35
+ }
36
+ catch (error) {
37
+ if (error instanceof SyntaxError) {
38
+ return {
39
+ success: false,
40
+ config: null,
41
+ error: `Invalid JSON in config file: ${error.message}`,
42
+ };
43
+ }
44
+ return {
45
+ success: false,
46
+ config: null,
47
+ error: error instanceof Error ? error.message : 'Unknown error reading config',
48
+ };
49
+ }
50
+ }
51
+ /**
52
+ * Write config to file with backup
53
+ */
54
+ export function writeConfig(configPath, config, createBackupFirst = true) {
55
+ try {
56
+ // Ensure directory exists
57
+ const dir = dirname(configPath);
58
+ if (!existsSync(dir)) {
59
+ mkdirSync(dir, { recursive: true });
60
+ }
61
+ // Create backup if file exists and backup requested
62
+ let backupPath = null;
63
+ if (createBackupFirst && existsSync(configPath)) {
64
+ const backupResult = createBackup(configPath);
65
+ if (!backupResult.success) {
66
+ return {
67
+ success: false,
68
+ error: `Failed to create backup: ${backupResult.error}`,
69
+ };
70
+ }
71
+ backupPath = backupResult.backupPath;
72
+ }
73
+ // Validate JSON before writing
74
+ const content = JSON.stringify(config, null, 2);
75
+ JSON.parse(content); // Validation parse
76
+ // Write file
77
+ writeFileSync(configPath, content, 'utf-8');
78
+ return {
79
+ success: true,
80
+ backupPath,
81
+ };
82
+ }
83
+ catch (error) {
84
+ return {
85
+ success: false,
86
+ error: error instanceof Error ? error.message : 'Unknown error writing config',
87
+ };
88
+ }
89
+ }
90
+ /**
91
+ * Deep merge two objects
92
+ */
93
+ export function deepMerge(target, source) {
94
+ const result = { ...target };
95
+ for (const key in source) {
96
+ const sourceValue = source[key];
97
+ const targetValue = result[key];
98
+ if (sourceValue !== null &&
99
+ typeof sourceValue === 'object' &&
100
+ !Array.isArray(sourceValue) &&
101
+ targetValue !== null &&
102
+ typeof targetValue === 'object' &&
103
+ !Array.isArray(targetValue)) {
104
+ // Recursively merge objects
105
+ result[key] = deepMerge(targetValue, sourceValue);
106
+ }
107
+ else {
108
+ // Overwrite value
109
+ result[key] = sourceValue;
110
+ }
111
+ }
112
+ return result;
113
+ }
114
+ /**
115
+ * Generate APIClaw MCP server configuration
116
+ */
117
+ export function generateApiclawConfig(options = {}) {
118
+ const config = {
119
+ command: 'npx',
120
+ args: ['-y', '@nordsym/apiclaw'],
121
+ };
122
+ if (options.workspace) {
123
+ config.env = {
124
+ APICLAW_WORKSPACE: options.workspace,
125
+ };
126
+ }
127
+ return config;
128
+ }
129
+ /**
130
+ * Generate APIClaw config for Continue (array format)
131
+ */
132
+ export function generateApiclawContinueConfig(options = {}) {
133
+ const config = {
134
+ name: options.serverName || 'apiclaw',
135
+ command: 'npx',
136
+ args: ['-y', '@nordsym/apiclaw'],
137
+ };
138
+ if (options.workspace) {
139
+ config.env = {
140
+ APICLAW_WORKSPACE: options.workspace,
141
+ };
142
+ }
143
+ return config;
144
+ }
145
+ /**
146
+ * Check if APIClaw is already configured
147
+ */
148
+ export function hasApiclawConfig(config, serverName = 'apiclaw') {
149
+ // Handle Continue's array format
150
+ if (Array.isArray(config.mcpServers)) {
151
+ const continueConfig = config;
152
+ return continueConfig.mcpServers?.some(s => s.name === serverName) || false;
153
+ }
154
+ // Handle standard object format
155
+ const mcpConfig = config;
156
+ return mcpConfig.mcpServers?.[serverName] !== undefined;
157
+ }
158
+ /**
159
+ * Merge APIClaw config into existing config (standard format)
160
+ */
161
+ export function mergeApiclawConfig(existingConfig, options = {}) {
162
+ const serverName = options.serverName || 'apiclaw';
163
+ const apiclawConfig = generateApiclawConfig(options);
164
+ return deepMerge(existingConfig, {
165
+ mcpServers: {
166
+ ...existingConfig.mcpServers,
167
+ [serverName]: apiclawConfig,
168
+ },
169
+ });
170
+ }
171
+ /**
172
+ * Merge APIClaw config into Continue config (array format)
173
+ */
174
+ export function mergeApiclawContinueConfig(existingConfig, options = {}) {
175
+ const serverName = options.serverName || 'apiclaw';
176
+ const apiclawConfig = generateApiclawContinueConfig(options);
177
+ const existingServers = existingConfig.mcpServers || [];
178
+ // Check if already exists
179
+ const existingIndex = existingServers.findIndex(s => s.name === serverName);
180
+ let newServers;
181
+ if (existingIndex >= 0) {
182
+ // Update existing
183
+ newServers = [...existingServers];
184
+ newServers[existingIndex] = apiclawConfig;
185
+ }
186
+ else {
187
+ // Add new
188
+ newServers = [...existingServers, apiclawConfig];
189
+ }
190
+ return {
191
+ ...existingConfig,
192
+ mcpServers: newServers,
193
+ };
194
+ }
195
+ /**
196
+ * Remove APIClaw from config
197
+ */
198
+ export function removeApiclawConfig(config, serverName = 'apiclaw') {
199
+ // Handle Continue's array format
200
+ if (Array.isArray(config.mcpServers)) {
201
+ const continueConfig = config;
202
+ return {
203
+ ...continueConfig,
204
+ mcpServers: continueConfig.mcpServers?.filter(s => s.name !== serverName),
205
+ };
206
+ }
207
+ // Handle standard object format
208
+ const mcpConfig = config;
209
+ const { [serverName]: _, ...remainingServers } = mcpConfig.mcpServers || {};
210
+ return {
211
+ ...mcpConfig,
212
+ mcpServers: remainingServers,
213
+ };
214
+ }
215
+ /**
216
+ * Detect if config uses Continue's array format
217
+ */
218
+ export function isContinueFormat(config) {
219
+ return Array.isArray(config.mcpServers);
220
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * OS Detection Utility
3
+ * Detects the operating system and provides platform-specific helpers
4
+ */
5
+ import { platform, homedir } from 'os';
6
+ import { join } from 'path';
7
+ /**
8
+ * Detect the current operating system
9
+ */
10
+ export function detectOS() {
11
+ const os = platform();
12
+ switch (os) {
13
+ case 'darwin':
14
+ return 'mac';
15
+ case 'win32':
16
+ return 'win';
17
+ case 'linux':
18
+ return 'linux';
19
+ default:
20
+ // Default to linux for other Unix-like systems
21
+ return 'linux';
22
+ }
23
+ }
24
+ /**
25
+ * Get the home directory for the current user
26
+ */
27
+ export function getHomeDir() {
28
+ return homedir();
29
+ }
30
+ /**
31
+ * Get the app data directory based on OS
32
+ * - macOS: ~/Library/Application Support
33
+ * - Windows: %APPDATA%
34
+ * - Linux: ~/.config
35
+ */
36
+ export function getAppDataDir() {
37
+ const home = getHomeDir();
38
+ const os = detectOS();
39
+ switch (os) {
40
+ case 'mac':
41
+ return join(home, 'Library', 'Application Support');
42
+ case 'win':
43
+ return process.env.APPDATA || join(home, 'AppData', 'Roaming');
44
+ case 'linux':
45
+ return process.env.XDG_CONFIG_HOME || join(home, '.config');
46
+ }
47
+ }
48
+ /**
49
+ * Get the user profile directory (Windows-specific, falls back to home)
50
+ */
51
+ export function getUserProfileDir() {
52
+ return process.env.USERPROFILE || getHomeDir();
53
+ }
54
+ /**
55
+ * Check if running as root/admin
56
+ */
57
+ export function isElevated() {
58
+ const os = detectOS();
59
+ if (os === 'win') {
60
+ // Windows admin check is more complex, skip for now
61
+ return false;
62
+ }
63
+ // Unix-like: check if UID is 0
64
+ return process.getuid?.() === 0;
65
+ }
66
+ /**
67
+ * Get OS-specific path separator
68
+ */
69
+ export function getPathSeparator() {
70
+ return detectOS() === 'win' ? '\\' : '/';
71
+ }
72
+ /**
73
+ * Normalize path for current OS
74
+ */
75
+ export function normalizePath(path) {
76
+ const os = detectOS();
77
+ if (os === 'win') {
78
+ // Convert forward slashes to backslashes on Windows
79
+ return path.replace(/\//g, '\\');
80
+ }
81
+ return path;
82
+ }
83
+ /**
84
+ * Expand ~ to home directory
85
+ */
86
+ export function expandHome(path) {
87
+ if (path.startsWith('~')) {
88
+ return join(getHomeDir(), path.slice(1));
89
+ }
90
+ return path;
91
+ }
92
+ /**
93
+ * Get OS display name
94
+ */
95
+ export function getOSDisplayName() {
96
+ const os = detectOS();
97
+ switch (os) {
98
+ case 'mac':
99
+ return 'macOS';
100
+ case 'win':
101
+ return 'Windows';
102
+ case 'linux':
103
+ return 'Linux';
104
+ }
105
+ }
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Config Path Resolver
3
+ * Resolves config file paths for all MCP clients across all operating systems
4
+ */
5
+ import { join } from 'path';
6
+ import { detectOS, getHomeDir, getAppDataDir, getUserProfileDir } from './os.js';
7
+ /**
8
+ * Get config path for Claude Desktop
9
+ */
10
+ function getClaudeDesktopPath(os) {
11
+ const home = getHomeDir();
12
+ const appData = getAppDataDir();
13
+ switch (os) {
14
+ case 'mac':
15
+ return join(appData, 'Claude', 'claude_desktop_config.json');
16
+ case 'win':
17
+ return join(appData, 'Claude', 'claude_desktop_config.json');
18
+ case 'linux':
19
+ return join(home, '.config', 'Claude', 'claude_desktop_config.json');
20
+ }
21
+ }
22
+ /**
23
+ * Get config path for Cursor
24
+ */
25
+ function getCursorPath(os) {
26
+ const home = getHomeDir();
27
+ const appData = getAppDataDir();
28
+ switch (os) {
29
+ case 'mac':
30
+ return join(appData, 'Cursor', 'User', 'globalStorage', 'cursor.mcp', 'config.json');
31
+ case 'win':
32
+ return join(appData, 'Cursor', 'User', 'globalStorage', 'cursor.mcp', 'config.json');
33
+ case 'linux':
34
+ return join(home, '.config', 'Cursor', 'User', 'globalStorage', 'cursor.mcp', 'config.json');
35
+ }
36
+ }
37
+ /**
38
+ * Get config path for Windsurf
39
+ */
40
+ function getWindsurfPath(os) {
41
+ const home = getHomeDir();
42
+ const userProfile = getUserProfileDir();
43
+ switch (os) {
44
+ case 'mac':
45
+ case 'linux':
46
+ return join(home, '.codeium', 'windsurf', 'mcp_config.json');
47
+ case 'win':
48
+ return join(userProfile, '.codeium', 'windsurf', 'mcp_config.json');
49
+ }
50
+ }
51
+ /**
52
+ * Get config path for Cline (VS Code extension)
53
+ */
54
+ function getClinePath(os) {
55
+ const home = getHomeDir();
56
+ const appData = getAppDataDir();
57
+ const relativePath = join('Code', 'User', 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json');
58
+ switch (os) {
59
+ case 'mac':
60
+ return join(appData, relativePath);
61
+ case 'win':
62
+ return join(appData, relativePath);
63
+ case 'linux':
64
+ return join(home, '.config', relativePath);
65
+ }
66
+ }
67
+ /**
68
+ * Get config path for Continue
69
+ */
70
+ function getContinuePath(os) {
71
+ const home = getHomeDir();
72
+ const userProfile = getUserProfileDir();
73
+ switch (os) {
74
+ case 'mac':
75
+ case 'linux':
76
+ return join(home, '.continue', 'config.json');
77
+ case 'win':
78
+ return join(userProfile, '.continue', 'config.json');
79
+ }
80
+ }
81
+ /**
82
+ * Get the config path for a specific MCP client
83
+ */
84
+ export function getConfigPath(client, os) {
85
+ const currentOS = os || detectOS();
86
+ switch (client) {
87
+ case 'claude-desktop':
88
+ return getClaudeDesktopPath(currentOS);
89
+ case 'cursor':
90
+ return getCursorPath(currentOS);
91
+ case 'windsurf':
92
+ return getWindsurfPath(currentOS);
93
+ case 'cline':
94
+ return getClinePath(currentOS);
95
+ case 'continue':
96
+ return getContinuePath(currentOS);
97
+ }
98
+ }
99
+ /**
100
+ * Get full client configuration info
101
+ */
102
+ export function getClientConfig(client, os) {
103
+ const configPath = getConfigPath(client, os);
104
+ const pathParts = configPath.split(/[/\\]/);
105
+ const configFile = pathParts.pop() || '';
106
+ const configDir = pathParts.join('/');
107
+ const displayNames = {
108
+ 'claude-desktop': 'Claude Desktop',
109
+ 'cursor': 'Cursor',
110
+ 'windsurf': 'Windsurf',
111
+ 'cline': 'Cline',
112
+ 'continue': 'Continue',
113
+ };
114
+ return {
115
+ name: client,
116
+ displayName: displayNames[client],
117
+ configPath,
118
+ configDir,
119
+ configFile,
120
+ };
121
+ }
122
+ /**
123
+ * Get all supported MCP clients
124
+ */
125
+ export function getAllClients() {
126
+ return ['claude-desktop', 'cursor', 'windsurf', 'cline', 'continue'];
127
+ }
128
+ /**
129
+ * Get config paths for all clients
130
+ */
131
+ export function getAllConfigPaths(os) {
132
+ const paths = new Map();
133
+ for (const client of getAllClients()) {
134
+ paths.set(client, getClientConfig(client, os));
135
+ }
136
+ return paths;
137
+ }
138
+ /**
139
+ * Validate that a client name is valid
140
+ */
141
+ export function isValidClient(client) {
142
+ return getAllClients().includes(client);
143
+ }
144
+ /**
145
+ * Parse client argument (accepts various formats)
146
+ */
147
+ export function parseClientArg(arg) {
148
+ const normalized = arg.toLowerCase().replace(/[_\s]/g, '-');
149
+ const aliases = {
150
+ 'claude': 'claude-desktop',
151
+ 'claude-desktop': 'claude-desktop',
152
+ 'claudedesktop': 'claude-desktop',
153
+ 'cursor': 'cursor',
154
+ 'windsurf': 'windsurf',
155
+ 'cline': 'cline',
156
+ 'continue': 'continue',
157
+ };
158
+ return aliases[normalized] || null;
159
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nordsym/apiclaw",
3
- "version": "1.5.12",
3
+ "version": "1.5.14",
4
4
  "description": "The API layer for AI agents. Dashboard + 22K APIs + 18 Direct Call providers. MCP native.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/bin.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * - setup/doctor/restore/uninstall → Run CLI
7
7
  */
8
8
 
9
- const cliCommands = ['setup', 'mcp-install', 'doctor', 'restore', 'uninstall', 'help', '--help', '-h', '--version', '-V'];
9
+ const cliCommands = ['setup', 'mcp-install', 'mcp-uninstall', 'doctor', 'restore', 'uninstall', 'help', '--help', '-h', '--version', '-V'];
10
10
 
11
11
  const firstArg = process.argv[2];
12
12
 
@@ -276,9 +276,9 @@ export async function mcpInstallCommand(options: MCPInstallOptions): Promise<voi
276
276
  } else if (successCount > 0) {
277
277
  console.log(chalk.green('\n✅ APIClaw installed successfully!\n'));
278
278
  console.log(chalk.bold('What you get:\n'));
279
- console.log(chalk.cyan(' 🔍 Search') + ' 22,000+ APIs indexed');
280
- console.log(chalk.cyan(' 🌐 Open APIs') + ' 1,600 APIs - no keys needed');
281
- console.log(chalk.cyan(' 🔑 Direct Call') + ' 1,500+ endpoints - no keys needed');
279
+ console.log(chalk.cyan(' 🔍 Search') + ' 22,000+ APIs to discover');
280
+ console.log(chalk.cyan(' 🌐 Open APIs') + ' 1,600 free APIs');
281
+ console.log(chalk.cyan(' 🔑 Direct Call') + ' 1,500+ premium (APIClaw manages keys)');
282
282
  console.log('');
283
283
  console.log('Next:');
284
284
  console.log(' 1. Restart your MCP client');
@@ -288,9 +288,9 @@ export async function mcpInstallCommand(options: MCPInstallOptions): Promise<voi
288
288
  } else {
289
289
  console.log(chalk.yellow('\n✅ APIClaw already installed in all clients.\n'));
290
290
  console.log(chalk.bold('What you have:\n'));
291
- console.log(chalk.cyan(' 🔍 Search') + ' 22,000+ APIs indexed');
292
- console.log(chalk.cyan(' 🌐 Open APIs') + ' 1,600 APIs - no keys needed');
293
- console.log(chalk.cyan(' 🔑 Direct Call') + ' 1,500+ endpoints - no keys needed');
291
+ console.log(chalk.cyan(' 🔍 Search') + ' 22,000+ APIs to discover');
292
+ console.log(chalk.cyan(' 🌐 Open APIs') + ' 1,600 free APIs');
293
+ console.log(chalk.cyan(' 🔑 Direct Call') + ' 1,500+ premium (APIClaw manages keys)');
294
294
  console.log('');
295
295
  console.log('Run with --force to reinstall (coming soon).\n');
296
296
  }
package/src/cli/index.ts CHANGED
@@ -107,6 +107,14 @@ program
107
107
  .option('-f, --force', 'Remove even if not configured')
108
108
  .action(uninstallCommand);
109
109
 
110
+ // MCP Uninstall alias - same as uninstall but for consistency with mcp-install
111
+ program
112
+ .command('mcp-uninstall')
113
+ .description('Remove APIClaw from Claude Desktop or Claude Code MCP config')
114
+ .option('-c, --client <client>', 'Target specific client (claude-desktop, claude-code)')
115
+ .option('--dry-run', 'Show what would be done without making changes')
116
+ .action(uninstallCommand);
117
+
110
118
  // Parse and execute
111
119
  program.parse();
112
120