@nordsym/apiclaw 2.1.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/README.md +15 -2
  2. package/dist/bin-http.js +0 -0
  3. package/dist/bin.bundled.js +79288 -0
  4. package/dist/funnel-client.d.ts +24 -0
  5. package/dist/funnel-client.d.ts.map +1 -0
  6. package/dist/funnel-client.js +131 -0
  7. package/dist/funnel-client.js.map +1 -0
  8. package/dist/funnel.test.d.ts +2 -0
  9. package/dist/funnel.test.d.ts.map +1 -0
  10. package/dist/funnel.test.js +145 -0
  11. package/dist/funnel.test.js.map +1 -0
  12. package/dist/gateway-client.d.ts.map +1 -1
  13. package/dist/gateway-client.js +24 -2
  14. package/dist/gateway-client.js.map +1 -1
  15. package/dist/index.bundled.js +61263 -0
  16. package/dist/index.js +161 -74
  17. package/dist/index.js.map +1 -1
  18. package/dist/postinstall.d.ts +0 -5
  19. package/dist/postinstall.d.ts.map +1 -1
  20. package/dist/postinstall.js +24 -3
  21. package/dist/postinstall.js.map +1 -1
  22. package/dist/registration-guard.d.ts +29 -0
  23. package/dist/registration-guard.d.ts.map +1 -0
  24. package/dist/registration-guard.js +87 -0
  25. package/dist/registration-guard.js.map +1 -0
  26. package/package.json +7 -2
  27. package/.claude/settings.local.json +0 -9
  28. package/.env.prod +0 -1
  29. package/apiclaw-README.md +0 -494
  30. package/convex/_generated/api.d.ts +0 -137
  31. package/convex/_generated/api.js +0 -23
  32. package/convex/_generated/dataModel.d.ts +0 -60
  33. package/convex/_generated/server.d.ts +0 -143
  34. package/convex/_generated/server.js +0 -93
  35. package/convex/adminActivate.ts +0 -53
  36. package/convex/adminStats.ts +0 -306
  37. package/convex/agents.ts +0 -939
  38. package/convex/analytics.ts +0 -187
  39. package/convex/apiKeys.ts +0 -220
  40. package/convex/backfillAnalytics.ts +0 -272
  41. package/convex/backfillSearchLogs.ts +0 -35
  42. package/convex/billing.ts +0 -834
  43. package/convex/capabilities.ts +0 -157
  44. package/convex/chains.ts +0 -1318
  45. package/convex/credits.ts +0 -211
  46. package/convex/crons.ts +0 -50
  47. package/convex/debugFilestackLogs.ts +0 -16
  48. package/convex/debugGetToken.ts +0 -18
  49. package/convex/directCall.ts +0 -713
  50. package/convex/earnProgress.ts +0 -753
  51. package/convex/email.ts +0 -329
  52. package/convex/feedback.ts +0 -265
  53. package/convex/http.ts +0 -3430
  54. package/convex/inbound.ts +0 -32
  55. package/convex/logs.ts +0 -701
  56. package/convex/migrateFilestack.ts +0 -81
  57. package/convex/migratePartnersProd.ts +0 -174
  58. package/convex/migratePratham.ts +0 -126
  59. package/convex/migrateProviderWorkspaces.ts +0 -175
  60. package/convex/mou.ts +0 -91
  61. package/convex/providerKeys.ts +0 -289
  62. package/convex/providers.ts +0 -1135
  63. package/convex/purchases.ts +0 -183
  64. package/convex/ratelimit.ts +0 -104
  65. package/convex/schema.ts +0 -869
  66. package/convex/searchLogs.ts +0 -265
  67. package/convex/seedAPILayerAPIs.ts +0 -191
  68. package/convex/seedDirectCallConfigs.ts +0 -336
  69. package/convex/seedPratham.ts +0 -149
  70. package/convex/spendAlerts.ts +0 -442
  71. package/convex/stripeActions.ts +0 -607
  72. package/convex/teams.ts +0 -243
  73. package/convex/telemetry.ts +0 -81
  74. package/convex/tsconfig.json +0 -25
  75. package/convex/updateAPIStatus.ts +0 -44
  76. package/convex/usage.ts +0 -260
  77. package/convex/usageReports.ts +0 -357
  78. package/convex/waitlist.ts +0 -55
  79. package/convex/webhooks.ts +0 -494
  80. package/convex/workspaceSettings.ts +0 -143
  81. package/convex/workspaces.ts +0 -1331
  82. package/convex.json +0 -3
  83. package/direct-test.mjs +0 -51
  84. package/email-templates/filestack-provider-outreach.html +0 -162
  85. package/email-templates/partnership-template.html +0 -116
  86. package/email-templates/pratham-draft-preview.txt +0 -57
  87. package/email-templates/pratham-partnership-draft.html +0 -141
  88. package/reports/APIClaw-Session-Report-2026-04-05.pdf +0 -0
  89. package/reports/pipeline/PIPELINE-REPORT.json +0 -153
  90. package/reports/pipeline/acquire_apisguru.json +0 -17
  91. package/reports/pipeline/capabilities.json +0 -38
  92. package/reports/pipeline/discover_azure_recursive.json +0 -1551
  93. package/reports/pipeline/discover_github.json +0 -25
  94. package/reports/pipeline/discover_github_repos.json +0 -49
  95. package/reports/pipeline/discover_swaggerhub.json +0 -24
  96. package/reports/pipeline/discover_well_known.json +0 -23
  97. package/reports/pipeline/fetch_specs.json +0 -19
  98. package/reports/pipeline/generate_providers.json +0 -14
  99. package/reports/pipeline/match_registry.json +0 -11
  100. package/reports/pipeline/parse_specs.json +0 -17
  101. package/reports/pipeline/promote_candidates.json +0 -34
  102. package/reports/pipeline/validate.json +0 -30
  103. package/reports/pipeline/validate_smoke_details.json +0 -3835
  104. package/reports/session-report-2026-04-05.html +0 -433
  105. package/seed-apis-direct.mjs +0 -106
  106. package/src/access-control.ts +0 -174
  107. package/src/adapters/base.ts +0 -364
  108. package/src/adapters/claude-desktop.ts +0 -41
  109. package/src/adapters/cline.ts +0 -88
  110. package/src/adapters/continue.ts +0 -91
  111. package/src/adapters/cursor.ts +0 -43
  112. package/src/adapters/custom.ts +0 -188
  113. package/src/adapters/detect.ts +0 -202
  114. package/src/adapters/index.ts +0 -47
  115. package/src/adapters/windsurf.ts +0 -44
  116. package/src/bin-http.ts +0 -45
  117. package/src/bin.ts +0 -34
  118. package/src/capability-router.ts +0 -331
  119. package/src/chainExecutor.ts +0 -730
  120. package/src/chainResolver.test.ts +0 -246
  121. package/src/chainResolver.ts +0 -658
  122. package/src/cli/commands/demo.ts +0 -109
  123. package/src/cli/commands/doctor.ts +0 -435
  124. package/src/cli/commands/index.ts +0 -9
  125. package/src/cli/commands/login.ts +0 -203
  126. package/src/cli/commands/mcp-install.ts +0 -373
  127. package/src/cli/commands/restore.ts +0 -333
  128. package/src/cli/commands/setup.ts +0 -297
  129. package/src/cli/commands/uninstall.ts +0 -240
  130. package/src/cli/index.ts +0 -148
  131. package/src/cli.ts +0 -370
  132. package/src/confirmation.ts +0 -296
  133. package/src/credentials.ts +0 -455
  134. package/src/credits.ts +0 -329
  135. package/src/crypto.ts +0 -75
  136. package/src/discovery.ts +0 -568
  137. package/src/enterprise/env.ts +0 -156
  138. package/src/enterprise/index.ts +0 -7
  139. package/src/enterprise/script-generator.ts +0 -481
  140. package/src/execute-dynamic.ts +0 -617
  141. package/src/execute.ts +0 -2386
  142. package/src/gateway-client.ts +0 -192
  143. package/src/hivr-whitelist.ts +0 -110
  144. package/src/http-api.ts +0 -286
  145. package/src/http-server-minimal.ts +0 -154
  146. package/src/index.ts +0 -2611
  147. package/src/intelligent-gateway.ts +0 -339
  148. package/src/mcp-analytics.ts +0 -156
  149. package/src/metered.ts +0 -149
  150. package/src/open-apis-generated.ts +0 -157
  151. package/src/open-apis.ts +0 -558
  152. package/src/postinstall.ts +0 -18
  153. package/src/product-whitelist.ts +0 -246
  154. package/src/proxy.ts +0 -36
  155. package/src/session.ts +0 -129
  156. package/src/stripe.ts +0 -497
  157. package/src/telemetry.ts +0 -71
  158. package/src/test.ts +0 -135
  159. package/src/types/convex-api.d.ts +0 -20
  160. package/src/types/convex-api.ts +0 -21
  161. package/src/types.ts +0 -109
  162. package/src/ui/colors.ts +0 -219
  163. package/src/ui/errors.ts +0 -394
  164. package/src/ui/index.ts +0 -17
  165. package/src/ui/prompts.ts +0 -390
  166. package/src/ui/spinner.ts +0 -325
  167. package/src/utils/backup.ts +0 -224
  168. package/src/utils/config.ts +0 -318
  169. package/src/utils/os.ts +0 -124
  170. package/src/utils/paths.ts +0 -203
  171. package/src/webhook.ts +0 -107
  172. package/test-10-working.cjs +0 -97
  173. package/test-14-final.cjs +0 -96
  174. package/test-actual-handlers.ts +0 -92
  175. package/test-apilayer-all-14.ts +0 -249
  176. package/test-apilayer-fixed.ts +0 -248
  177. package/test-direct-endpoints.ts +0 -174
  178. package/test-exact-endpoints.ts +0 -144
  179. package/test-final.ts +0 -83
  180. package/test-full-routing.ts +0 -100
  181. package/test-handlers-correct.ts +0 -217
  182. package/test-numverify-key.ts +0 -41
  183. package/test-via-handlers.ts +0 -92
  184. package/test-worldnews.mjs +0 -26
  185. package/tsconfig.json +0 -20
@@ -1,156 +0,0 @@
1
- /**
2
- * Environment Variable Handler
3
- * Manages APIClaw environment variables for configuration
4
- */
5
-
6
- export interface ApiclawEnvConfig {
7
- workspace?: string;
8
- apiUrl?: string;
9
- disableTelemetry?: boolean;
10
- }
11
-
12
- export const ENV_VARS = {
13
- WORKSPACE: 'APICLAW_WORKSPACE',
14
- API_URL: 'APICLAW_API_URL',
15
- DISABLE_TELEMETRY: 'APICLAW_DISABLE_TELEMETRY',
16
- } as const;
17
-
18
- export const DEFAULT_API_URL = 'https://api.apiclaw.com';
19
-
20
- /**
21
- * Read APIClaw config from environment variables
22
- */
23
- export function readEnvConfig(): ApiclawEnvConfig {
24
- return {
25
- workspace: process.env[ENV_VARS.WORKSPACE] || undefined,
26
- apiUrl: process.env[ENV_VARS.API_URL] || undefined,
27
- disableTelemetry: process.env[ENV_VARS.DISABLE_TELEMETRY] === 'true' ||
28
- process.env[ENV_VARS.DISABLE_TELEMETRY] === '1',
29
- };
30
- }
31
-
32
- /**
33
- * Get API URL with fallback to default
34
- */
35
- export function getApiUrl(): string {
36
- return process.env[ENV_VARS.API_URL] || DEFAULT_API_URL;
37
- }
38
-
39
- /**
40
- * Check if telemetry is disabled
41
- */
42
- export function isTelemetryDisabled(): boolean {
43
- const val = process.env[ENV_VARS.DISABLE_TELEMETRY];
44
- return val === 'true' || val === '1';
45
- }
46
-
47
- /**
48
- * Get pre-configured workspace ID
49
- */
50
- export function getWorkspaceFromEnv(): string | undefined {
51
- return process.env[ENV_VARS.WORKSPACE];
52
- }
53
-
54
- /**
55
- * Generate env block for MCP server config
56
- */
57
- export function generateEnvBlock(config: ApiclawEnvConfig): Record<string, string> {
58
- const env: Record<string, string> = {};
59
-
60
- if (config.workspace) {
61
- env[ENV_VARS.WORKSPACE] = config.workspace;
62
- }
63
-
64
- if (config.apiUrl && config.apiUrl !== DEFAULT_API_URL) {
65
- env[ENV_VARS.API_URL] = config.apiUrl;
66
- }
67
-
68
- if (config.disableTelemetry) {
69
- env[ENV_VARS.DISABLE_TELEMETRY] = 'true';
70
- }
71
-
72
- return env;
73
- }
74
-
75
- /**
76
- * Format env config for display
77
- */
78
- export function formatEnvConfig(config: ApiclawEnvConfig): string[] {
79
- const lines: string[] = [];
80
-
81
- if (config.workspace) {
82
- lines.push(` Workspace: ${config.workspace}`);
83
- }
84
-
85
- if (config.apiUrl) {
86
- lines.push(` API URL: ${config.apiUrl}`);
87
- }
88
-
89
- if (config.disableTelemetry) {
90
- lines.push(` Telemetry: Disabled`);
91
- }
92
-
93
- return lines;
94
- }
95
-
96
- /**
97
- * Validate workspace ID format
98
- */
99
- export function isValidWorkspaceId(id: string): boolean {
100
- // Workspace IDs should be alphanumeric with dashes/underscores
101
- return /^[a-zA-Z0-9_-]{3,64}$/.test(id);
102
- }
103
-
104
- /**
105
- * Validate API URL format
106
- */
107
- export function isValidApiUrl(url: string): boolean {
108
- try {
109
- const parsed = new URL(url);
110
- return parsed.protocol === 'http:' || parsed.protocol === 'https:';
111
- } catch {
112
- return false;
113
- }
114
- }
115
-
116
- /**
117
- * Generate shell export statements
118
- */
119
- export function generateShellExports(config: ApiclawEnvConfig): string {
120
- const lines: string[] = [];
121
-
122
- if (config.workspace) {
123
- lines.push(`export ${ENV_VARS.WORKSPACE}="${config.workspace}"`);
124
- }
125
-
126
- if (config.apiUrl) {
127
- lines.push(`export ${ENV_VARS.API_URL}="${config.apiUrl}"`);
128
- }
129
-
130
- if (config.disableTelemetry) {
131
- lines.push(`export ${ENV_VARS.DISABLE_TELEMETRY}="true"`);
132
- }
133
-
134
- return lines.join('\n');
135
- }
136
-
137
- /**
138
- * Generate PowerShell $env statements
139
- */
140
- export function generatePowerShellEnv(config: ApiclawEnvConfig): string {
141
- const lines: string[] = [];
142
-
143
- if (config.workspace) {
144
- lines.push(`$env:${ENV_VARS.WORKSPACE} = "${config.workspace}"`);
145
- }
146
-
147
- if (config.apiUrl) {
148
- lines.push(`$env:${ENV_VARS.API_URL} = "${config.apiUrl}"`);
149
- }
150
-
151
- if (config.disableTelemetry) {
152
- lines.push(`$env:${ENV_VARS.DISABLE_TELEMETRY} = "true"`);
153
- }
154
-
155
- return lines.join('\n');
156
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Enterprise Module
3
- * Exports for enterprise features: script generation, env handling
4
- */
5
-
6
- export * from './env.js';
7
- export * from './script-generator.js';
@@ -1,481 +0,0 @@
1
- /**
2
- * Enterprise Script Generator
3
- * Generates self-contained deployment scripts for bash and PowerShell
4
- */
5
-
6
- import { ApiclawEnvConfig, ENV_VARS, DEFAULT_API_URL } from './env.js';
7
-
8
- export interface ScriptOptions {
9
- workspace?: string;
10
- apiUrl?: string;
11
- disableTelemetry?: boolean;
12
- serverName?: string;
13
- verbose?: boolean;
14
- }
15
-
16
- // Env var names as strings for embedding in scripts
17
- const WORKSPACE_VAR = ENV_VARS.WORKSPACE;
18
- const API_URL_VAR = ENV_VARS.API_URL;
19
- const TELEMETRY_VAR = ENV_VARS.DISABLE_TELEMETRY;
20
-
21
- /**
22
- * Generate self-contained bash deployment script
23
- */
24
- export function generateBashScript(options: ScriptOptions = {}): string {
25
- const serverName = options.serverName || 'apiclaw';
26
- const workspaceVal = options.workspace || '';
27
- const apiUrlVal = options.apiUrl || DEFAULT_API_URL;
28
- const disableTelemetry = options.disableTelemetry ? 'true' : '';
29
- const verbose = options.verbose ? '1' : '';
30
-
31
- return `#!/usr/bin/env bash
32
- #
33
- # APIClaw MCP Auto-Setup Script
34
- # Generated by: npx @nordsym/apiclaw setup --enterprise
35
- #
36
- # This script automatically configures APIClaw for all detected MCP clients.
37
- # Supports: Claude Desktop, Cursor, Windsurf, Cline, Continue
38
- #
39
-
40
- set -e
41
-
42
- # Configuration
43
- SERVER_NAME="${serverName}"
44
- WORKSPACE="${workspaceVal}"
45
- API_URL="${apiUrlVal}"
46
- DEFAULT_API_URL="${DEFAULT_API_URL}"
47
- DISABLE_TELEMETRY="${disableTelemetry}"
48
- VERBOSE="${verbose}"
49
-
50
- # Environment variable names
51
- ENV_WORKSPACE="${WORKSPACE_VAR}"
52
- ENV_API_URL="${API_URL_VAR}"
53
- ENV_TELEMETRY="${TELEMETRY_VAR}"
54
-
55
- # Colors
56
- RED='\\033[0;31m'
57
- GREEN='\\033[0;32m'
58
- YELLOW='\\033[1;33m'
59
- BLUE='\\033[0;34m'
60
- NC='\\033[0m' # No Color
61
-
62
- log_info() { echo -e "\${BLUE}ℹ\${NC} $1"; }
63
- log_success() { echo -e "\${GREEN}✓\${NC} $1"; }
64
- log_warn() { echo -e "\${YELLOW}⚠\${NC} $1"; }
65
- log_error() { echo -e "\${RED}✗\${NC} $1"; }
66
- log_verbose() { [[ -n "$VERBOSE" ]] && echo -e " $1"; }
67
-
68
- # Detect OS
69
- detect_os() {
70
- case "$(uname -s)" in
71
- Darwin*) echo "mac" ;;
72
- Linux*) echo "linux" ;;
73
- MINGW*|MSYS*|CYGWIN*) echo "win" ;;
74
- *) echo "linux" ;;
75
- esac
76
- }
77
-
78
- OS=$(detect_os)
79
- HOME_DIR="$HOME"
80
-
81
- # Set paths based on OS
82
- case "$OS" in
83
- mac)
84
- APP_DATA="$HOME_DIR/Library/Application Support"
85
- ;;
86
- linux)
87
- APP_DATA="\${XDG_CONFIG_HOME:-$HOME_DIR/.config}"
88
- ;;
89
- win)
90
- APP_DATA="\${APPDATA:-$HOME_DIR/AppData/Roaming}"
91
- ;;
92
- esac
93
-
94
- echo ""
95
- echo "🔧 APIClaw MCP Auto-Setup"
96
- echo "========================="
97
- echo ""
98
- log_info "Detected OS: $OS"
99
-
100
- # Check for Node.js
101
- if ! command -v node &> /dev/null; then
102
- log_error "Node.js is required but not installed."
103
- exit 1
104
- fi
105
- log_success "Node.js $(node --version) found"
106
-
107
- # Check for npx
108
- if ! command -v npx &> /dev/null; then
109
- log_error "npx is required but not installed."
110
- exit 1
111
- fi
112
- log_success "npx available"
113
-
114
- # Generate APIClaw server config JSON
115
- generate_config() {
116
- local env_block=""
117
-
118
- if [[ -n "$WORKSPACE" ]] || [[ -n "$API_URL" && "$API_URL" != "$DEFAULT_API_URL" ]] || [[ -n "$DISABLE_TELEMETRY" ]]; then
119
- env_block='"env": {'
120
- local first=true
121
-
122
- if [[ -n "$WORKSPACE" ]]; then
123
- env_block+="\\"$ENV_WORKSPACE\\": \\"$WORKSPACE\\""
124
- first=false
125
- fi
126
-
127
- if [[ -n "$API_URL" && "$API_URL" != "$DEFAULT_API_URL" ]]; then
128
- [[ "$first" == "false" ]] && env_block+=','
129
- env_block+="\\"$ENV_API_URL\\": \\"$API_URL\\""
130
- first=false
131
- fi
132
-
133
- if [[ -n "$DISABLE_TELEMETRY" ]]; then
134
- [[ "$first" == "false" ]] && env_block+=','
135
- env_block+="\\"$ENV_TELEMETRY\\": \\"true\\""
136
- fi
137
-
138
- env_block+='},'
139
- fi
140
-
141
- if [[ -n "$env_block" ]]; then
142
- echo "{\\"command\\": \\"npx\\", \\"args\\": [\\"-y\\", \\"@nordsym/apiclaw\\"], $env_block}"
143
- else
144
- echo "{\\"command\\": \\"npx\\", \\"args\\": [\\"-y\\", \\"@nordsym/apiclaw\\"]}"
145
- fi
146
- }
147
-
148
- # Merge APIClaw into existing config using Node.js
149
- merge_config() {
150
- local config_path="$1"
151
- local apiclaw_config
152
- apiclaw_config=$(generate_config)
153
-
154
- if [[ -f "$config_path" ]]; then
155
- # Backup existing
156
- cp "$config_path" "$config_path.backup.$(date +%s).json"
157
-
158
- # Read existing config
159
- local existing
160
- existing=$(cat "$config_path")
161
-
162
- # Use node to merge JSON
163
- node -e "
164
- const fs = require('fs');
165
- const existing = JSON.parse(process.argv[1] || '{}');
166
- const apiclaw = JSON.parse(process.argv[2]);
167
-
168
- if (!existing.mcpServers) existing.mcpServers = {};
169
- existing.mcpServers['$SERVER_NAME'] = apiclaw;
170
-
171
- fs.writeFileSync('$config_path', JSON.stringify(existing, null, 2));
172
- " "$existing" "$apiclaw_config"
173
- else
174
- # Create new config
175
- mkdir -p "$(dirname "$config_path")"
176
- node -e "
177
- const fs = require('fs');
178
- const apiclaw = JSON.parse(process.argv[1]);
179
- const config = { mcpServers: { '$SERVER_NAME': apiclaw } };
180
- fs.writeFileSync('$config_path', JSON.stringify(config, null, 2));
181
- " "$apiclaw_config"
182
- fi
183
- }
184
-
185
- # Client config paths
186
- declare -A CLIENT_PATHS
187
-
188
- case "$OS" in
189
- mac)
190
- CLIENT_PATHS=(
191
- ["Claude Desktop"]="$APP_DATA/Claude/claude_desktop_config.json"
192
- ["Cursor"]="$APP_DATA/Cursor/User/globalStorage/cursor.mcp/config.json"
193
- ["Windsurf"]="$HOME_DIR/.codeium/windsurf/mcp_config.json"
194
- ["Cline"]="$APP_DATA/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json"
195
- ["Continue"]="$HOME_DIR/.continue/config.json"
196
- )
197
- ;;
198
- linux)
199
- CLIENT_PATHS=(
200
- ["Claude Desktop"]="$APP_DATA/Claude/claude_desktop_config.json"
201
- ["Cursor"]="$APP_DATA/Cursor/User/globalStorage/cursor.mcp/config.json"
202
- ["Windsurf"]="$HOME_DIR/.codeium/windsurf/mcp_config.json"
203
- ["Cline"]="$APP_DATA/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json"
204
- ["Continue"]="$HOME_DIR/.continue/config.json"
205
- )
206
- ;;
207
- win)
208
- CLIENT_PATHS=(
209
- ["Claude Desktop"]="$APP_DATA/Claude/claude_desktop_config.json"
210
- ["Cursor"]="$APP_DATA/Cursor/User/globalStorage/cursor.mcp/config.json"
211
- ["Windsurf"]="$USERPROFILE/.codeium/windsurf/mcp_config.json"
212
- ["Cline"]="$APP_DATA/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json"
213
- ["Continue"]="$USERPROFILE/.continue/config.json"
214
- )
215
- ;;
216
- esac
217
-
218
- # Configure each client
219
- echo ""
220
- log_info "Scanning for MCP clients..."
221
- echo ""
222
-
223
- configured=0
224
- skipped=0
225
-
226
- for client in "\${!CLIENT_PATHS[@]}"; do
227
- config_path="\${CLIENT_PATHS[$client]}"
228
- config_dir=$(dirname "$config_path")
229
-
230
- # Check if client is installed (config dir exists or we can create it)
231
- if [[ -d "$config_dir" ]] || [[ -f "$config_path" ]]; then
232
- log_info "Configuring $client..."
233
-
234
- if merge_config "$config_path"; then
235
- log_success "$client configured"
236
- ((configured++))
237
- else
238
- log_error "Failed to configure $client"
239
- fi
240
- else
241
- log_verbose "$client not detected (no config directory)"
242
- ((skipped++))
243
- fi
244
- done
245
-
246
- # Summary
247
- echo ""
248
- echo "========================="
249
- echo ""
250
-
251
- if [[ $configured -gt 0 ]]; then
252
- log_success "Configured $configured client(s)"
253
- echo ""
254
- echo "🎉 APIClaw is ready! Restart your MCP clients to activate."
255
- else
256
- log_warn "No MCP clients were detected."
257
- echo ""
258
- echo "Install one of these clients first:"
259
- echo " • Claude Desktop: https://claude.ai/download"
260
- echo " • Cursor: https://cursor.sh"
261
- echo " • Windsurf: https://codeium.com/windsurf"
262
- fi
263
-
264
- echo ""
265
- `;
266
- }
267
-
268
- /**
269
- * Generate self-contained PowerShell deployment script
270
- */
271
- export function generatePowerShellScript(options: ScriptOptions = {}): string {
272
- const serverName = options.serverName || 'apiclaw';
273
- const workspaceVal = options.workspace || '';
274
- const apiUrlVal = options.apiUrl || DEFAULT_API_URL;
275
- const disableTelemetry = options.disableTelemetry;
276
- const verbose = options.verbose;
277
-
278
- return `#Requires -Version 5.1
279
- <#
280
- .SYNOPSIS
281
- APIClaw MCP Auto-Setup Script
282
-
283
- .DESCRIPTION
284
- Automatically configures APIClaw for all detected MCP clients.
285
- Supports: Claude Desktop, Cursor, Windsurf, Cline, Continue
286
-
287
- .NOTES
288
- Generated by: npx @nordsym/apiclaw setup --enterprise
289
- #>
290
-
291
- [CmdletBinding()]
292
- param()
293
-
294
- $ErrorActionPreference = "Stop"
295
-
296
- # Configuration
297
- $ServerName = "${serverName}"
298
- $Workspace = "${workspaceVal}"
299
- $ApiUrl = "${apiUrlVal}"
300
- $DefaultApiUrl = "${DEFAULT_API_URL}"
301
- $DisableTelemetry = $${disableTelemetry ? 'true' : 'false'}
302
- $VerboseMode = $${verbose ? 'true' : 'false'}
303
-
304
- # Env var names
305
- $EnvWorkspace = "${WORKSPACE_VAR}"
306
- $EnvApiUrl = "${API_URL_VAR}"
307
- $EnvTelemetry = "${TELEMETRY_VAR}"
308
-
309
- # Helper functions
310
- function Write-Info { param($Message) Write-Host "ℹ $Message" -ForegroundColor Blue }
311
- function Write-Success { param($Message) Write-Host "✓ $Message" -ForegroundColor Green }
312
- function Write-Warn { param($Message) Write-Host "⚠ $Message" -ForegroundColor Yellow }
313
- function Write-Err { param($Message) Write-Host "✗ $Message" -ForegroundColor Red }
314
-
315
- Write-Host ""
316
- Write-Host "🔧 APIClaw MCP Auto-Setup" -ForegroundColor Cyan
317
- Write-Host "=========================" -ForegroundColor Cyan
318
- Write-Host ""
319
-
320
- # Check for Node.js
321
- try {
322
- $nodeVersion = & node --version 2>$null
323
- Write-Success "Node.js $nodeVersion found"
324
- } catch {
325
- Write-Err "Node.js is required but not installed."
326
- exit 1
327
- }
328
-
329
- # Check for npx
330
- try {
331
- $null = & npx --version 2>$null
332
- Write-Success "npx available"
333
- } catch {
334
- Write-Err "npx is required but not installed."
335
- exit 1
336
- }
337
-
338
- # Generate APIClaw config
339
- function Get-ApiclawConfig {
340
- $config = @{
341
- command = "npx"
342
- args = @("-y", "@nordsym/apiclaw")
343
- }
344
-
345
- $env = @{}
346
- if ($Workspace) { $env[$EnvWorkspace] = $Workspace }
347
- if ($ApiUrl -and $ApiUrl -ne $DefaultApiUrl) { $env[$EnvApiUrl] = $ApiUrl }
348
- if ($DisableTelemetry) { $env[$EnvTelemetry] = "true" }
349
-
350
- if ($env.Count -gt 0) {
351
- $config["env"] = $env
352
- }
353
-
354
- return $config
355
- }
356
-
357
- # Merge config into existing file
358
- function Merge-Config {
359
- param(
360
- [string]$ConfigPath
361
- )
362
-
363
- $configDir = Split-Path -Parent $ConfigPath
364
-
365
- # Ensure directory exists
366
- if (!(Test-Path $configDir)) {
367
- New-Item -ItemType Directory -Path $configDir -Force | Out-Null
368
- }
369
-
370
- # Read existing or create new
371
- if (Test-Path $ConfigPath) {
372
- # Backup existing
373
- $backupPath = "$ConfigPath.backup.$([DateTimeOffset]::UtcNow.ToUnixTimeSeconds()).json"
374
- Copy-Item $ConfigPath $backupPath
375
-
376
- $existing = Get-Content $ConfigPath -Raw | ConvertFrom-Json -AsHashtable
377
- } else {
378
- $existing = @{}
379
- }
380
-
381
- # Ensure mcpServers exists
382
- if (!$existing.ContainsKey("mcpServers")) {
383
- $existing["mcpServers"] = @{}
384
- }
385
-
386
- # Add APIClaw
387
- $existing["mcpServers"][$ServerName] = Get-ApiclawConfig
388
-
389
- # Write back
390
- $existing | ConvertTo-Json -Depth 10 | Set-Content $ConfigPath -Encoding UTF8
391
- }
392
-
393
- # Client paths
394
- $AppData = $env:APPDATA
395
- $UserProfile = $env:USERPROFILE
396
-
397
- $ClientPaths = @{
398
- "Claude Desktop" = "$AppData\\Claude\\claude_desktop_config.json"
399
- "Cursor" = "$AppData\\Cursor\\User\\globalStorage\\cursor.mcp\\config.json"
400
- "Windsurf" = "$UserProfile\\.codeium\\windsurf\\mcp_config.json"
401
- "Cline" = "$AppData\\Code\\User\\globalStorage\\saoudrizwan.claude-dev\\settings\\cline_mcp_settings.json"
402
- "Continue" = "$UserProfile\\.continue\\config.json"
403
- }
404
-
405
- Write-Host ""
406
- Write-Info "Scanning for MCP clients..."
407
- Write-Host ""
408
-
409
- $configured = 0
410
-
411
- foreach ($client in $ClientPaths.Keys) {
412
- $configPath = $ClientPaths[$client]
413
- $configDir = Split-Path -Parent $configPath
414
-
415
- if ((Test-Path $configDir) -or (Test-Path $configPath)) {
416
- Write-Info "Configuring $client..."
417
-
418
- try {
419
- Merge-Config -ConfigPath $configPath
420
- Write-Success "$client configured"
421
- $configured++
422
- } catch {
423
- Write-Err "Failed to configure $client: $_"
424
- }
425
- }
426
- }
427
-
428
- Write-Host ""
429
- Write-Host "=========================" -ForegroundColor Cyan
430
- Write-Host ""
431
-
432
- if ($configured -gt 0) {
433
- Write-Success "Configured $configured client(s)"
434
- Write-Host ""
435
- Write-Host "🎉 APIClaw is ready! Restart your MCP clients to activate." -ForegroundColor Green
436
- } else {
437
- Write-Warn "No MCP clients were detected."
438
- Write-Host ""
439
- Write-Host "Install one of these clients first:"
440
- Write-Host " • Claude Desktop: https://claude.ai/download"
441
- Write-Host " • Cursor: https://cursor.sh"
442
- Write-Host " • Windsurf: https://codeium.com/windsurf"
443
- }
444
-
445
- Write-Host ""
446
- `;
447
- }
448
-
449
- /**
450
- * Generate script based on target platform
451
- */
452
- export function generateScript(
453
- platform: 'bash' | 'powershell' | 'auto',
454
- options: ScriptOptions = {}
455
- ): { script: string; filename: string; platform: 'bash' | 'powershell' } {
456
- // Auto-detect platform
457
- let targetPlatform: 'bash' | 'powershell' = platform === 'auto'
458
- ? (process.platform === 'win32' ? 'powershell' : 'bash')
459
- : platform;
460
-
461
- if (targetPlatform === 'powershell') {
462
- return {
463
- script: generatePowerShellScript(options),
464
- filename: 'apiclaw-setup.ps1',
465
- platform: 'powershell',
466
- };
467
- }
468
-
469
- return {
470
- script: generateBashScript(options),
471
- filename: 'apiclaw-setup.sh',
472
- platform: 'bash',
473
- };
474
- }
475
-
476
- /**
477
- * Get file extension for platform
478
- */
479
- export function getScriptExtension(platform: 'bash' | 'powershell'): string {
480
- return platform === 'powershell' ? '.ps1' : '.sh';
481
- }