@nordsym/apiclaw 1.5.17 → 1.5.19

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 (228) hide show
  1. package/convex/http.js.map +1 -1
  2. package/convex/http.ts +516 -0
  3. package/dist/analytics.d.ts +0 -4
  4. package/dist/analytics.d.ts.map +1 -1
  5. package/dist/analytics.js +0 -1
  6. package/dist/analytics.js.map +1 -1
  7. package/dist/bin.js +1 -1
  8. package/dist/cli/commands/mcp-install.d.ts.map +1 -1
  9. package/dist/cli/commands/mcp-install.js +8 -87
  10. package/dist/cli/commands/mcp-install.js.map +1 -1
  11. package/dist/cli/index.js +0 -7
  12. package/dist/credentials.d.ts.map +1 -1
  13. package/dist/credentials.js +38 -43
  14. package/dist/credentials.js.map +1 -1
  15. package/dist/discovery.d.ts.map +1 -1
  16. package/dist/discovery.js +82 -191
  17. package/dist/discovery.js.map +1 -1
  18. package/dist/http-api.d.ts.map +1 -1
  19. package/dist/http-api.js +33 -17
  20. package/dist/http-api.js.map +1 -1
  21. package/dist/proxy.js +1 -1
  22. package/dist/proxy.js.map +1 -1
  23. package/landing/next-env.d.ts +0 -1
  24. package/landing/src/app/api/auth/magic-link/route.ts +1 -1
  25. package/landing/src/app/auth/verify/page.tsx +0 -6
  26. package/landing/src/app/dashboard/verify/page.tsx +0 -6
  27. package/landing/src/app/join/page.tsx +0 -6
  28. package/landing/src/app/layout.tsx +2 -2
  29. package/landing/src/app/login/page.tsx +1 -1
  30. package/landing/src/app/mou/[partnerId]/page.tsx +0 -6
  31. package/landing/src/app/page.tsx +18 -39
  32. package/landing/src/app/providers/dashboard/[apiId]/actions/[actionId]/edit/page.tsx +0 -6
  33. package/landing/src/app/providers/dashboard/[apiId]/actions/new/page.tsx +0 -5
  34. package/landing/src/app/providers/dashboard/[apiId]/actions/page.tsx +0 -5
  35. package/landing/src/app/providers/dashboard/[apiId]/direct-call/page.tsx +1 -6
  36. package/landing/src/app/providers/dashboard/[apiId]/page.tsx +0 -5
  37. package/landing/src/app/providers/dashboard/[apiId]/test/page.tsx +0 -5
  38. package/landing/src/app/providers/dashboard/layout.tsx +6 -6
  39. package/landing/src/app/providers/dashboard/login/page.tsx +1 -1
  40. package/landing/src/app/providers/dashboard/page.tsx +1 -1
  41. package/landing/src/app/providers/dashboard/verify/page.tsx +0 -6
  42. package/landing/src/app/providers/layout.tsx +1 -1
  43. package/landing/src/app/upgrade/page.tsx +0 -6
  44. package/landing/src/app/workspace/page.tsx +0 -6
  45. package/landing/src/components/HeroTabs.tsx +2 -2
  46. package/landing/src/components/{Workspace.tsx → ProviderDashboard.tsx} +2 -2
  47. package/landing/src/components/VideoDemo.tsx +10 -21
  48. package/landing/src/lib/mock-data.ts +1 -1
  49. package/landing/src/lib/stats.json +1 -1
  50. package/package.json +3 -8
  51. package/src/analytics.ts +0 -5
  52. package/src/bin.ts +1 -1
  53. package/src/cli/commands/mcp-install.ts +8 -90
  54. package/src/cli/index.ts +0 -8
  55. package/src/credentials.ts +39 -44
  56. package/src/discovery.ts +82 -191
  57. package/src/http-api.ts +34 -18
  58. package/src/proxy.ts +1 -1
  59. package/APILAYER_STATUS_2026-03-24.md +0 -38
  60. package/CHANGELOG-WHITELIST-V2.md +0 -269
  61. package/HIVR-WHITELIST-STATUS.md +0 -205
  62. package/HIVR-WHITELIST.md +0 -148
  63. package/TERMINOLOGY-AUDIT.md +0 -99
  64. package/TERMINOLOGY-FIXED.md +0 -74
  65. package/VIDEO-DEMO-GUIDE.md +0 -82
  66. package/WHITELIST-ARCHITECTURE.md +0 -379
  67. package/api/discover.ts +0 -71
  68. package/api/health.ts +0 -20
  69. package/convex/adminActivate.d.ts +0 -3
  70. package/convex/adminActivate.js +0 -47
  71. package/convex/adminStats.d.ts +0 -3
  72. package/convex/adminStats.js +0 -42
  73. package/convex/agents.d.ts +0 -54
  74. package/convex/agents.js +0 -499
  75. package/convex/analytics.d.ts +0 -5
  76. package/convex/analytics.js +0 -166
  77. package/convex/billing.d.ts +0 -88
  78. package/convex/billing.js +0 -655
  79. package/convex/capabilities.d.ts +0 -9
  80. package/convex/capabilities.js +0 -145
  81. package/convex/chains.d.ts +0 -67
  82. package/convex/chains.js +0 -1042
  83. package/convex/credits.d.ts +0 -25
  84. package/convex/credits.js +0 -186
  85. package/convex/crons.d.ts +0 -3
  86. package/convex/crons.js +0 -17
  87. package/convex/directCall.d.ts +0 -72
  88. package/convex/directCall.js +0 -627
  89. package/convex/earnProgress.d.ts +0 -58
  90. package/convex/earnProgress.js +0 -649
  91. package/convex/email.d.ts +0 -14
  92. package/convex/email.js +0 -300
  93. package/convex/feedback.d.ts +0 -7
  94. package/convex/feedback.js +0 -227
  95. package/convex/http.d.ts +0 -3
  96. package/convex/http.js +0 -910
  97. package/convex/logs.d.ts +0 -38
  98. package/convex/logs.js +0 -487
  99. package/convex/mou.d.ts +0 -6
  100. package/convex/mou.js +0 -82
  101. package/convex/providerKeys.d.ts +0 -31
  102. package/convex/providerKeys.js +0 -257
  103. package/convex/providers.d.ts +0 -29
  104. package/convex/providers.js +0 -756
  105. package/convex/purchases.d.ts +0 -7
  106. package/convex/purchases.js +0 -157
  107. package/convex/ratelimit.d.ts +0 -4
  108. package/convex/ratelimit.js +0 -91
  109. package/convex/searchLogs.d.ts +0 -4
  110. package/convex/searchLogs.js +0 -129
  111. package/convex/spendAlerts.d.ts +0 -36
  112. package/convex/spendAlerts.js +0 -380
  113. package/convex/stripeActions.d.ts +0 -19
  114. package/convex/stripeActions.js +0 -411
  115. package/convex/teams.d.ts +0 -21
  116. package/convex/teams.js +0 -215
  117. package/convex/telemetry.d.ts +0 -4
  118. package/convex/telemetry.js +0 -74
  119. package/convex/usage.d.ts +0 -27
  120. package/convex/usage.js +0 -229
  121. package/convex/waitlist.d.ts +0 -4
  122. package/convex/waitlist.js +0 -49
  123. package/convex/webhooks.d.ts +0 -12
  124. package/convex/webhooks.js +0 -410
  125. package/convex/workspaces.d.ts +0 -29
  126. package/convex/workspaces.js +0 -880
  127. package/direct-test.mjs +0 -51
  128. package/dist/access-control.d.ts +0 -45
  129. package/dist/access-control.d.ts.map +0 -1
  130. package/dist/access-control.js +0 -142
  131. package/dist/access-control.js.map +0 -1
  132. package/dist/chain-types.d.ts +0 -187
  133. package/dist/chain-types.d.ts.map +0 -1
  134. package/dist/chain-types.js +0 -33
  135. package/dist/chain-types.js.map +0 -1
  136. package/dist/convex/adminActivate.js +0 -46
  137. package/dist/convex/adminStats.js +0 -41
  138. package/dist/convex/agents.js +0 -498
  139. package/dist/convex/analytics.js +0 -165
  140. package/dist/convex/billing.js +0 -654
  141. package/dist/convex/capabilities.js +0 -144
  142. package/dist/convex/chains.js +0 -1041
  143. package/dist/convex/credits.js +0 -185
  144. package/dist/convex/crons.js +0 -16
  145. package/dist/convex/directCall.js +0 -626
  146. package/dist/convex/earnProgress.js +0 -648
  147. package/dist/convex/email.js +0 -299
  148. package/dist/convex/feedback.js +0 -226
  149. package/dist/convex/http.js +0 -909
  150. package/dist/convex/logs.js +0 -486
  151. package/dist/convex/mou.js +0 -81
  152. package/dist/convex/providerKeys.js +0 -256
  153. package/dist/convex/providers.js +0 -755
  154. package/dist/convex/purchases.js +0 -156
  155. package/dist/convex/ratelimit.js +0 -90
  156. package/dist/convex/schema.js +0 -709
  157. package/dist/convex/searchLogs.js +0 -128
  158. package/dist/convex/spendAlerts.js +0 -379
  159. package/dist/convex/stripeActions.js +0 -410
  160. package/dist/convex/teams.js +0 -214
  161. package/dist/convex/telemetry.js +0 -73
  162. package/dist/convex/usage.js +0 -228
  163. package/dist/convex/waitlist.js +0 -48
  164. package/dist/convex/webhooks.js +0 -409
  165. package/dist/convex/workspaces.js +0 -879
  166. package/dist/hivr-whitelist.d.ts +0 -18
  167. package/dist/hivr-whitelist.d.ts.map +0 -1
  168. package/dist/hivr-whitelist.js +0 -95
  169. package/dist/hivr-whitelist.js.map +0 -1
  170. package/dist/http-server-minimal.d.ts +0 -7
  171. package/dist/http-server-minimal.d.ts.map +0 -1
  172. package/dist/http-server-minimal.js +0 -126
  173. package/dist/http-server-minimal.js.map +0 -1
  174. package/dist/product-whitelist.d.ts +0 -37
  175. package/dist/product-whitelist.d.ts.map +0 -1
  176. package/dist/product-whitelist.js +0 -203
  177. package/dist/product-whitelist.js.map +0 -1
  178. package/dist/src/analytics.js +0 -129
  179. package/dist/src/bin.js +0 -17
  180. package/dist/src/capability-router.js +0 -240
  181. package/dist/src/chainExecutor.js +0 -451
  182. package/dist/src/chainResolver.js +0 -518
  183. package/dist/src/cli/commands/doctor.js +0 -324
  184. package/dist/src/cli/commands/mcp-install.js +0 -255
  185. package/dist/src/cli/commands/restore.js +0 -259
  186. package/dist/src/cli/commands/setup.js +0 -205
  187. package/dist/src/cli/commands/uninstall.js +0 -188
  188. package/dist/src/cli/index.js +0 -111
  189. package/dist/src/cli.js +0 -302
  190. package/dist/src/confirmation.js +0 -240
  191. package/dist/src/credentials.js +0 -357
  192. package/dist/src/credits.js +0 -260
  193. package/dist/src/crypto.js +0 -66
  194. package/dist/src/discovery.js +0 -504
  195. package/dist/src/enterprise/env.js +0 -123
  196. package/dist/src/enterprise/script-generator.js +0 -460
  197. package/dist/src/execute-dynamic.js +0 -473
  198. package/dist/src/execute.js +0 -1727
  199. package/dist/src/index.js +0 -2062
  200. package/dist/src/metered.js +0 -80
  201. package/dist/src/open-apis.js +0 -276
  202. package/dist/src/proxy.js +0 -28
  203. package/dist/src/session.js +0 -86
  204. package/dist/src/stripe.js +0 -407
  205. package/dist/src/telemetry.js +0 -49
  206. package/dist/src/types.js +0 -2
  207. package/dist/src/utils/backup.js +0 -181
  208. package/dist/src/utils/config.js +0 -220
  209. package/dist/src/utils/os.js +0 -105
  210. package/dist/src/utils/paths.js +0 -159
  211. package/landing/pages/api/discover.ts +0 -43
  212. package/landing/pages/api/health.ts +0 -20
  213. package/scripts/test-whitelist-v2.sh +0 -128
  214. package/src/access-control.ts +0 -174
  215. package/src/hivr-whitelist.ts +0 -110
  216. package/src/http-server-minimal.ts +0 -154
  217. package/src/product-whitelist.ts +0 -246
  218. package/test-actual-handlers.ts +0 -92
  219. package/test-apilayer-all-14.ts +0 -249
  220. package/test-apilayer-fixed.ts +0 -248
  221. package/test-direct-endpoints.ts +0 -174
  222. package/test-exact-endpoints.ts +0 -144
  223. package/test-final.ts +0 -83
  224. package/test-full-routing.ts +0 -100
  225. package/test-handlers-correct.ts +0 -217
  226. package/test-numverify-key.ts +0 -41
  227. package/test-via-handlers.ts +0 -92
  228. package/test-worldnews.mjs +0 -26
@@ -1,259 +0,0 @@
1
- /**
2
- * Restore Command
3
- * Rollback MCP client configs from backups
4
- */
5
- import { existsSync } from 'fs';
6
- import { listBackups, restoreBackup as doRestore, getLatestBackup, formatBackupInfo } from '../../utils/backup.js';
7
- import { getAllClients, getClientConfig, parseClientArg } from '../../utils/paths.js';
8
- /**
9
- * List all available backups for a client
10
- */
11
- function listClientBackups(client) {
12
- const config = getClientConfig(client);
13
- return listBackups(config.configPath);
14
- }
15
- /**
16
- * List all backups across all clients
17
- */
18
- export function listAllBackups() {
19
- const results = new Map();
20
- for (const client of getAllClients()) {
21
- const backups = listClientBackups(client);
22
- if (backups.length > 0) {
23
- results.set(client, backups);
24
- }
25
- }
26
- return results;
27
- }
28
- /**
29
- * Format backup list for display
30
- */
31
- export function formatBackupList(backups) {
32
- const lines = [];
33
- lines.push('');
34
- lines.push('šŸ“¦ Available Backups');
35
- lines.push('====================');
36
- lines.push('');
37
- if (backups.size === 0) {
38
- lines.push('No backups found.');
39
- lines.push('');
40
- lines.push('Backups are created automatically when you run setup.');
41
- lines.push('');
42
- return lines.join('\n');
43
- }
44
- for (const [client, clientBackups] of backups) {
45
- const config = getClientConfig(client);
46
- lines.push(`${config.displayName}:`);
47
- for (let i = 0; i < clientBackups.length; i++) {
48
- const backup = clientBackups[i];
49
- const marker = i === 0 ? ' (latest)' : '';
50
- lines.push(` ${i + 1}. ${formatBackupInfo(backup)}${marker}`);
51
- }
52
- lines.push('');
53
- }
54
- lines.push('Usage:');
55
- lines.push(' npx @nordsym/apiclaw restore # Restore latest for all');
56
- lines.push(' npx @nordsym/apiclaw restore --client claude # Restore latest for Claude');
57
- lines.push(' npx @nordsym/apiclaw restore --backup <path> # Restore specific backup');
58
- lines.push('');
59
- return lines.join('\n');
60
- }
61
- /**
62
- * Restore a specific client to its latest backup
63
- */
64
- export function restoreClient(client) {
65
- const config = getClientConfig(client);
66
- const configPath = config.configPath;
67
- // Check if config exists
68
- if (!existsSync(configPath)) {
69
- return {
70
- success: false,
71
- client: config.displayName,
72
- message: 'No config file to restore',
73
- };
74
- }
75
- // Get latest backup
76
- const latest = getLatestBackup(configPath);
77
- if (!latest) {
78
- return {
79
- success: false,
80
- client: config.displayName,
81
- message: 'No backups available',
82
- };
83
- }
84
- // Perform restore
85
- const result = doRestore(latest.path, configPath);
86
- if (result.success) {
87
- return {
88
- success: true,
89
- client: config.displayName,
90
- message: 'Restored successfully',
91
- backupUsed: latest.filename,
92
- preRestoreBackup: result.backupPath || undefined,
93
- };
94
- }
95
- return {
96
- success: false,
97
- client: config.displayName,
98
- message: result.error || 'Unknown error',
99
- };
100
- }
101
- /**
102
- * Restore from a specific backup file
103
- */
104
- export function restoreFromFile(backupPath, client) {
105
- // Validate backup exists
106
- if (!existsSync(backupPath)) {
107
- return {
108
- success: false,
109
- client: client ? getClientConfig(client).displayName : 'Unknown',
110
- message: `Backup file not found: ${backupPath}`,
111
- };
112
- }
113
- // If client not specified, try to detect from backup path
114
- if (!client) {
115
- for (const c of getAllClients()) {
116
- const config = getClientConfig(c);
117
- if (backupPath.includes(config.configDir)) {
118
- client = c;
119
- break;
120
- }
121
- }
122
- }
123
- if (!client) {
124
- return {
125
- success: false,
126
- client: 'Unknown',
127
- message: 'Could not determine target client. Use --client to specify.',
128
- };
129
- }
130
- const config = getClientConfig(client);
131
- const result = doRestore(backupPath, config.configPath);
132
- if (result.success) {
133
- return {
134
- success: true,
135
- client: config.displayName,
136
- message: 'Restored successfully',
137
- backupUsed: backupPath,
138
- preRestoreBackup: result.backupPath || undefined,
139
- };
140
- }
141
- return {
142
- success: false,
143
- client: config.displayName,
144
- message: result.error || 'Unknown error',
145
- };
146
- }
147
- /**
148
- * Restore all clients to their latest backups
149
- */
150
- export function restoreAll() {
151
- const results = [];
152
- for (const client of getAllClients()) {
153
- const config = getClientConfig(client);
154
- // Skip clients without backups
155
- const backups = listClientBackups(client);
156
- if (backups.length === 0) {
157
- continue;
158
- }
159
- results.push(restoreClient(client));
160
- }
161
- return results;
162
- }
163
- /**
164
- * Format restore results for display
165
- */
166
- export function formatRestoreResults(results) {
167
- const lines = [];
168
- lines.push('');
169
- lines.push('šŸ”„ Restore Results');
170
- lines.push('==================');
171
- lines.push('');
172
- if (results.length === 0) {
173
- lines.push('No clients had backups to restore.');
174
- lines.push('');
175
- return lines.join('\n');
176
- }
177
- for (const result of results) {
178
- const icon = result.success ? 'āœ“' : 'āœ—';
179
- lines.push(`${icon} ${result.client}: ${result.message}`);
180
- if (result.backupUsed) {
181
- lines.push(` Restored from: ${result.backupUsed}`);
182
- }
183
- if (result.preRestoreBackup) {
184
- lines.push(` Pre-restore backup: ${result.preRestoreBackup}`);
185
- }
186
- }
187
- lines.push('');
188
- const successful = results.filter(r => r.success).length;
189
- if (successful > 0) {
190
- lines.push(`āœ“ Restored ${successful} client(s). Restart your MCP clients to apply changes.`);
191
- }
192
- lines.push('');
193
- return lines.join('\n');
194
- }
195
- /**
196
- * Restore command handler
197
- */
198
- export async function restoreCommand(options = {}) {
199
- // List mode
200
- if (options.list) {
201
- const backups = listAllBackups();
202
- console.log(formatBackupList(backups));
203
- return;
204
- }
205
- // Dry run mode
206
- if (options.dryRun) {
207
- console.log('\nšŸ” Dry run - would restore:\n');
208
- if (options.backup) {
209
- console.log(` From file: ${options.backup}`);
210
- }
211
- else if (options.client) {
212
- const client = parseClientArg(options.client);
213
- if (client) {
214
- const latest = getLatestBackup(getClientConfig(client).configPath);
215
- console.log(` ${getClientConfig(client).displayName}: ${latest?.filename || 'No backup'}`);
216
- }
217
- }
218
- else {
219
- const backups = listAllBackups();
220
- for (const [client, clientBackups] of backups) {
221
- console.log(` ${getClientConfig(client).displayName}: ${clientBackups[0]?.filename || 'No backup'}`);
222
- }
223
- }
224
- console.log('\nRun without --dry-run to perform restore.\n');
225
- return;
226
- }
227
- // Restore from specific file
228
- if (options.backup) {
229
- const client = options.client ? parseClientArg(options.client) : undefined;
230
- const result = restoreFromFile(options.backup, client || undefined);
231
- console.log(formatRestoreResults([result]));
232
- if (!result.success) {
233
- process.exit(1);
234
- }
235
- return;
236
- }
237
- // Restore specific client
238
- if (options.client) {
239
- const client = parseClientArg(options.client);
240
- if (!client) {
241
- console.error(`\nāœ— Unknown client: ${options.client}\n`);
242
- console.error('Valid clients: claude, cursor, windsurf, cline, continue\n');
243
- process.exit(1);
244
- }
245
- const result = restoreClient(client);
246
- console.log(formatRestoreResults([result]));
247
- if (!result.success) {
248
- process.exit(1);
249
- }
250
- return;
251
- }
252
- // Restore all clients with backups
253
- const results = restoreAll();
254
- console.log(formatRestoreResults(results));
255
- const failures = results.filter(r => !r.success);
256
- if (failures.length > 0) {
257
- process.exit(1);
258
- }
259
- }
@@ -1,205 +0,0 @@
1
- /**
2
- * Setup Command
3
- * Configures APIClaw for MCP clients
4
- */
5
- import { existsSync } from 'fs';
6
- import { detectOS, getOSDisplayName } from '../../utils/os.js';
7
- import { getAllClients, getConfigPath, getClientConfig, parseClientArg } from '../../utils/paths.js';
8
- import { readConfig, writeConfig, mergeApiclawConfig, mergeApiclawContinueConfig, hasApiclawConfig, isContinueFormat } from '../../utils/config.js';
9
- /**
10
- * Detect which MCP clients are installed
11
- */
12
- function detectInstalledClients() {
13
- const clients = getAllClients();
14
- const installed = [];
15
- for (const client of clients) {
16
- const configPath = getConfigPath(client);
17
- // Check if config exists OR if parent directory exists (client might be installed but not configured)
18
- if (existsSync(configPath)) {
19
- installed.push(client);
20
- }
21
- }
22
- return installed;
23
- }
24
- /**
25
- * Check if a client's config directory structure exists (might not have config yet)
26
- */
27
- function clientMightBeInstalled(client) {
28
- const config = getClientConfig(client);
29
- const configDir = config.configDir;
30
- // Check a few levels up to see if the app is installed
31
- const pathParts = configDir.split('/').filter(Boolean);
32
- for (let i = pathParts.length; i >= Math.max(0, pathParts.length - 3); i--) {
33
- const checkPath = '/' + pathParts.slice(0, i).join('/');
34
- if (existsSync(checkPath)) {
35
- return true;
36
- }
37
- }
38
- return false;
39
- }
40
- /**
41
- * Setup a single client
42
- */
43
- async function setupClient(client, configPath, options) {
44
- const displayName = client === 'custom' ? 'Custom' : getClientConfig(client).displayName;
45
- if (options.verbose) {
46
- console.log(`\nšŸ“ Configuring ${displayName}...`);
47
- console.log(` Config path: ${configPath}`);
48
- }
49
- // Read existing config
50
- const readResult = readConfig(configPath);
51
- if (!readResult.success) {
52
- return {
53
- client: displayName,
54
- success: false,
55
- message: readResult.error || 'Failed to read config',
56
- };
57
- }
58
- const existingConfig = readResult.config;
59
- // Check if APIClaw is already configured
60
- if (hasApiclawConfig(existingConfig) && !options.force) {
61
- if (options.verbose) {
62
- console.log(` ā­ļø APIClaw already configured (use --force to update)`);
63
- }
64
- return {
65
- client: displayName,
66
- success: true,
67
- message: 'Already configured',
68
- skipped: true,
69
- };
70
- }
71
- // Merge APIClaw config
72
- let newConfig;
73
- if (client === 'continue' || isContinueFormat(existingConfig)) {
74
- newConfig = mergeApiclawContinueConfig(existingConfig, {
75
- workspace: options.workspace,
76
- force: options.force,
77
- });
78
- }
79
- else {
80
- newConfig = mergeApiclawConfig(existingConfig, {
81
- workspace: options.workspace,
82
- force: options.force,
83
- });
84
- }
85
- // Dry run - show what would happen
86
- if (options.dryRun) {
87
- console.log(`\nšŸ“‹ Would configure ${displayName}:`);
88
- console.log(` Path: ${configPath}`);
89
- console.log(` Changes:`);
90
- if (isContinueFormat(newConfig)) {
91
- const continueConfig = newConfig;
92
- const apiclaw = continueConfig.mcpServers?.find(s => s.name === 'apiclaw');
93
- console.log(JSON.stringify(apiclaw, null, 4).split('\n').map(l => ` ${l}`).join('\n'));
94
- }
95
- else {
96
- const mcpConfig = newConfig;
97
- console.log(JSON.stringify({ apiclaw: mcpConfig.mcpServers?.apiclaw }, null, 4).split('\n').map(l => ` ${l}`).join('\n'));
98
- }
99
- return {
100
- client: displayName,
101
- success: true,
102
- message: 'Dry run - no changes made',
103
- skipped: true,
104
- };
105
- }
106
- // Write config
107
- const writeResult = writeConfig(configPath, newConfig, true);
108
- if (!writeResult.success) {
109
- return {
110
- client: displayName,
111
- success: false,
112
- message: writeResult.error || 'Failed to write config',
113
- };
114
- }
115
- return {
116
- client: displayName,
117
- success: true,
118
- message: readResult.isNew ? 'Created new config' : 'Updated existing config',
119
- backupPath: writeResult.backupPath,
120
- };
121
- }
122
- /**
123
- * Main setup command handler
124
- */
125
- export async function setupCommand(options) {
126
- const os = detectOS();
127
- const osName = getOSDisplayName();
128
- console.log('\nšŸš€ APIClaw MCP Auto-Setup\n');
129
- console.log(`Platform: ${osName}\n`);
130
- // Determine which clients to configure
131
- let clientsToSetup = [];
132
- if (options.config) {
133
- // Custom config path
134
- clientsToSetup.push({ client: 'custom', path: options.config });
135
- }
136
- else if (options.client) {
137
- // Specific client
138
- const client = parseClientArg(options.client);
139
- if (!client) {
140
- console.error(`āŒ Unknown client: ${options.client}`);
141
- console.log(' Supported clients: claude-desktop, cursor, windsurf, cline, continue');
142
- process.exit(1);
143
- }
144
- clientsToSetup.push({ client, path: getConfigPath(client) });
145
- }
146
- else {
147
- // Auto-detect or all
148
- console.log('šŸ” Detecting MCP clients...\n');
149
- const allClients = getAllClients();
150
- const detected = detectInstalledClients();
151
- for (const client of allClients) {
152
- const config = getClientConfig(client);
153
- const isDetected = detected.includes(client);
154
- const icon = isDetected ? 'āœ“' : 'āœ—';
155
- const status = isDetected ? 'found' : 'not found';
156
- console.log(` ${icon} ${config.displayName} ${status}`);
157
- if (isDetected || options.all) {
158
- clientsToSetup.push({ client, path: config.configPath });
159
- }
160
- }
161
- console.log('');
162
- if (clientsToSetup.length === 0) {
163
- console.log('āš ļø No MCP clients detected. Use --client to specify manually.');
164
- console.log(' Example: npx @nordsym/apiclaw setup --client claude-desktop');
165
- process.exit(0);
166
- }
167
- }
168
- // Setup each client
169
- const results = [];
170
- for (const { client, path } of clientsToSetup) {
171
- const result = await setupClient(client, path, options);
172
- results.push(result);
173
- const icon = result.success ? (result.skipped ? 'ā­ļø' : 'āœ“') : 'āœ—';
174
- console.log(`${icon} ${result.client}: ${result.message}`);
175
- if (result.backupPath && options.verbose) {
176
- console.log(` Backup: ${result.backupPath}`);
177
- }
178
- }
179
- // Summary
180
- const succeeded = results.filter(r => r.success && !r.skipped).length;
181
- const skipped = results.filter(r => r.skipped).length;
182
- const failed = results.filter(r => !r.success).length;
183
- console.log('\n' + '═'.repeat(50));
184
- if (failed === 0) {
185
- if (options.dryRun) {
186
- console.log('\nāœ… Dry run complete! Use without --dry-run to apply changes.\n');
187
- }
188
- else if (succeeded > 0) {
189
- console.log('\nāœ… APIClaw configured successfully!\n');
190
- console.log('Next steps:');
191
- console.log(' 1. Restart your AI coding assistant');
192
- console.log(' 2. Ask your agent: "List available APIs"\n');
193
- console.log('Need help? https://apiclaw.nordsym.com/docs/setup\n');
194
- }
195
- else if (skipped === results.length) {
196
- console.log('\nāœ… APIClaw already configured in all clients.\n');
197
- console.log('Use --force to reconfigure.\n');
198
- }
199
- }
200
- else {
201
- console.log(`\nāš ļø Setup completed with ${failed} error(s).\n`);
202
- console.log('For troubleshooting, visit: https://apiclaw.nordsym.com/docs/setup/troubleshooting\n');
203
- process.exit(1);
204
- }
205
- }
@@ -1,188 +0,0 @@
1
- /**
2
- * Uninstall Command
3
- * Remove APIClaw configuration from MCP clients
4
- */
5
- import { existsSync } from 'fs';
6
- import { getAllClients, getClientConfig, parseClientArg } from '../../utils/paths.js';
7
- import { readConfig, writeConfig, removeApiclawConfig, hasApiclawConfig } from '../../utils/config.js';
8
- import { createBackup } from '../../utils/backup.js';
9
- /**
10
- * Remove APIClaw from a single client
11
- */
12
- export function uninstallFromClient(client, options = {}) {
13
- const config = getClientConfig(client);
14
- const configPath = config.configPath;
15
- const serverName = options.serverName || 'apiclaw';
16
- // Check if config file exists
17
- if (!existsSync(configPath)) {
18
- return {
19
- success: true,
20
- client: config.displayName,
21
- action: 'not-found',
22
- message: 'Config file not found (client not installed)',
23
- };
24
- }
25
- // Read config
26
- const readResult = readConfig(configPath);
27
- if (!readResult.success || !readResult.config) {
28
- return {
29
- success: false,
30
- client: config.displayName,
31
- action: 'error',
32
- message: readResult.error || 'Failed to read config',
33
- };
34
- }
35
- // Check if APIClaw is configured
36
- if (!hasApiclawConfig(readResult.config, serverName)) {
37
- if (options.force) {
38
- return {
39
- success: true,
40
- client: config.displayName,
41
- action: 'skipped',
42
- message: `${serverName} not configured (forced check)`,
43
- };
44
- }
45
- return {
46
- success: true,
47
- client: config.displayName,
48
- action: 'skipped',
49
- message: `${serverName} not configured`,
50
- };
51
- }
52
- // Dry run - just report what would happen
53
- if (options.dryRun) {
54
- return {
55
- success: true,
56
- client: config.displayName,
57
- action: 'skipped',
58
- message: `Would remove ${serverName} (dry run)`,
59
- };
60
- }
61
- // Create backup before modifying
62
- let backupPath;
63
- if (!options.noBackup) {
64
- const backupResult = createBackup(configPath);
65
- if (backupResult.success) {
66
- backupPath = backupResult.backupPath || undefined;
67
- }
68
- }
69
- // Remove APIClaw from config
70
- const updatedConfig = removeApiclawConfig(readResult.config, serverName);
71
- // Write updated config (without creating another backup)
72
- const writeResult = writeConfig(configPath, updatedConfig, false);
73
- if (!writeResult.success) {
74
- return {
75
- success: false,
76
- client: config.displayName,
77
- action: 'error',
78
- message: writeResult.error || 'Failed to write config',
79
- backupPath,
80
- };
81
- }
82
- return {
83
- success: true,
84
- client: config.displayName,
85
- action: 'removed',
86
- message: `${serverName} removed`,
87
- backupPath,
88
- };
89
- }
90
- /**
91
- * Uninstall from all clients
92
- */
93
- export function uninstallFromAll(options = {}) {
94
- const results = [];
95
- for (const client of getAllClients()) {
96
- results.push(uninstallFromClient(client, options));
97
- }
98
- return results;
99
- }
100
- /**
101
- * Format uninstall results for display
102
- */
103
- export function formatUninstallResults(results) {
104
- const lines = [];
105
- lines.push('');
106
- lines.push('šŸ—‘ļø Uninstall Results');
107
- lines.push('====================');
108
- lines.push('');
109
- const removed = results.filter(r => r.action === 'removed');
110
- const skipped = results.filter(r => r.action === 'skipped');
111
- const notFound = results.filter(r => r.action === 'not-found');
112
- const errors = results.filter(r => r.action === 'error');
113
- // Show removed
114
- if (removed.length > 0) {
115
- lines.push('Removed:');
116
- for (const result of removed) {
117
- lines.push(` āœ“ ${result.client}`);
118
- if (result.backupPath) {
119
- lines.push(` Backup: ${result.backupPath}`);
120
- }
121
- }
122
- lines.push('');
123
- }
124
- // Show skipped
125
- if (skipped.length > 0) {
126
- lines.push('Skipped (not configured):');
127
- for (const result of skipped) {
128
- lines.push(` ā—‹ ${result.client}`);
129
- }
130
- lines.push('');
131
- }
132
- // Show not found
133
- if (notFound.length > 0) {
134
- lines.push('Not installed:');
135
- for (const result of notFound) {
136
- lines.push(` ā—‹ ${result.client}`);
137
- }
138
- lines.push('');
139
- }
140
- // Show errors
141
- if (errors.length > 0) {
142
- lines.push('Errors:');
143
- for (const result of errors) {
144
- lines.push(` āœ— ${result.client}: ${result.message}`);
145
- }
146
- lines.push('');
147
- }
148
- // Summary
149
- if (removed.length > 0) {
150
- lines.push(`āœ“ APIClaw removed from ${removed.length} client(s).`);
151
- lines.push(' Restart your MCP clients for changes to take effect.');
152
- }
153
- else if (errors.length === 0) {
154
- lines.push('No changes made - APIClaw was not configured in any client.');
155
- }
156
- lines.push('');
157
- return lines.join('\n');
158
- }
159
- /**
160
- * Uninstall command handler
161
- */
162
- export async function uninstallCommand(options = {}) {
163
- const serverName = options.serverName || 'apiclaw';
164
- // Dry run notice
165
- if (options.dryRun) {
166
- console.log('\nšŸ” Dry run - no changes will be made\n');
167
- }
168
- let results;
169
- // Uninstall from specific client
170
- if (options.client) {
171
- const client = parseClientArg(options.client);
172
- if (!client) {
173
- console.error(`\nāœ— Unknown client: ${options.client}\n`);
174
- console.error('Valid clients: claude, cursor, windsurf, cline, continue\n');
175
- process.exit(1);
176
- }
177
- results = [uninstallFromClient(client, options)];
178
- }
179
- else {
180
- // Uninstall from all clients
181
- results = uninstallFromAll(options);
182
- }
183
- console.log(formatUninstallResults(results));
184
- const errors = results.filter(r => r.action === 'error');
185
- if (errors.length > 0) {
186
- process.exit(1);
187
- }
188
- }