@nordsym/apiclaw 1.5.16 โ†’ 1.5.18

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 (172) hide show
  1. package/convex/http.js +196 -0
  2. package/convex/http.js.map +1 -1
  3. package/convex/http.ts +201 -0
  4. package/convex/http.ts.bak +934 -0
  5. package/dist/analytics.d.ts +0 -4
  6. package/dist/analytics.d.ts.map +1 -1
  7. package/dist/analytics.js +0 -1
  8. package/dist/analytics.js.map +1 -1
  9. package/dist/bin.js +1 -1
  10. package/dist/cli/commands/mcp-install.d.ts.map +1 -1
  11. package/dist/cli/commands/mcp-install.js +8 -87
  12. package/dist/cli/commands/mcp-install.js.map +1 -1
  13. package/dist/cli/index.js +0 -7
  14. package/dist/credentials.d.ts.map +1 -1
  15. package/dist/credentials.js +0 -128
  16. package/dist/credentials.js.map +1 -1
  17. package/dist/discovery.d.ts.map +1 -1
  18. package/dist/discovery.js +82 -191
  19. package/dist/discovery.js.map +1 -1
  20. package/dist/http-api.d.ts.map +1 -1
  21. package/dist/http-api.js +33 -17
  22. package/dist/http-api.js.map +1 -1
  23. package/dist/proxy.js +1 -1
  24. package/dist/proxy.js.map +1 -1
  25. package/landing/next-env.d.ts +0 -1
  26. package/landing/src/app/api/auth/magic-link/route.ts +1 -1
  27. package/landing/src/app/auth/verify/page.tsx +0 -6
  28. package/landing/src/app/dashboard/verify/page.tsx +0 -6
  29. package/landing/src/app/join/page.tsx +0 -6
  30. package/landing/src/app/layout.tsx +2 -2
  31. package/landing/src/app/login/page.tsx +1 -1
  32. package/landing/src/app/mou/[partnerId]/page.tsx +0 -6
  33. package/landing/src/app/page.tsx +18 -39
  34. package/landing/src/app/providers/dashboard/[apiId]/actions/[actionId]/edit/page.tsx +0 -6
  35. package/landing/src/app/providers/dashboard/[apiId]/actions/new/page.tsx +0 -5
  36. package/landing/src/app/providers/dashboard/[apiId]/actions/page.tsx +0 -5
  37. package/landing/src/app/providers/dashboard/[apiId]/direct-call/page.tsx +1 -6
  38. package/landing/src/app/providers/dashboard/[apiId]/page.tsx +0 -5
  39. package/landing/src/app/providers/dashboard/[apiId]/test/page.tsx +0 -5
  40. package/landing/src/app/providers/dashboard/layout.tsx +6 -6
  41. package/landing/src/app/providers/dashboard/login/page.tsx +1 -1
  42. package/landing/src/app/providers/dashboard/page.tsx +1 -1
  43. package/landing/src/app/providers/dashboard/verify/page.tsx +0 -6
  44. package/landing/src/app/providers/layout.tsx +1 -1
  45. package/landing/src/app/upgrade/page.tsx +0 -6
  46. package/landing/src/app/workspace/page.tsx +0 -6
  47. package/landing/src/components/HeroTabs.tsx +2 -2
  48. package/landing/src/components/{Workspace.tsx โ†’ ProviderDashboard.tsx} +2 -2
  49. package/landing/src/components/VideoDemo.tsx +10 -21
  50. package/landing/src/lib/mock-data.ts +1 -1
  51. package/landing/src/lib/stats.json +1 -1
  52. package/package.json +4 -6
  53. package/src/analytics.ts +0 -5
  54. package/src/bin.ts +1 -1
  55. package/src/cli/commands/mcp-install.ts +8 -90
  56. package/src/cli/index.ts +0 -8
  57. package/src/credentials.ts +0 -136
  58. package/src/discovery.ts +82 -191
  59. package/src/http-api.ts +34 -18
  60. package/src/proxy.ts +1 -1
  61. package/APILAYER_STATUS_2026-03-24.md +0 -38
  62. package/CHANGELOG-WHITELIST-V2.md +0 -269
  63. package/HIVR-WHITELIST-STATUS.md +0 -205
  64. package/HIVR-WHITELIST.md +0 -148
  65. package/TERMINOLOGY-AUDIT.md +0 -99
  66. package/TERMINOLOGY-FIXED.md +0 -74
  67. package/VIDEO-DEMO-GUIDE.md +0 -82
  68. package/WHITELIST-ARCHITECTURE.md +0 -379
  69. package/api/discover.ts +0 -71
  70. package/api/health.ts +0 -20
  71. package/direct-test.mjs +0 -51
  72. package/dist/access-control.d.ts +0 -45
  73. package/dist/access-control.d.ts.map +0 -1
  74. package/dist/access-control.js +0 -142
  75. package/dist/access-control.js.map +0 -1
  76. package/dist/chain-types.d.ts +0 -187
  77. package/dist/chain-types.d.ts.map +0 -1
  78. package/dist/chain-types.js +0 -33
  79. package/dist/chain-types.js.map +0 -1
  80. package/dist/convex/adminActivate.js +0 -46
  81. package/dist/convex/adminStats.js +0 -41
  82. package/dist/convex/agents.js +0 -498
  83. package/dist/convex/analytics.js +0 -165
  84. package/dist/convex/billing.js +0 -654
  85. package/dist/convex/capabilities.js +0 -144
  86. package/dist/convex/chains.js +0 -1041
  87. package/dist/convex/credits.js +0 -185
  88. package/dist/convex/crons.js +0 -16
  89. package/dist/convex/directCall.js +0 -626
  90. package/dist/convex/earnProgress.js +0 -648
  91. package/dist/convex/email.js +0 -299
  92. package/dist/convex/feedback.js +0 -226
  93. package/dist/convex/http.js +0 -909
  94. package/dist/convex/logs.js +0 -486
  95. package/dist/convex/mou.js +0 -81
  96. package/dist/convex/providerKeys.js +0 -256
  97. package/dist/convex/providers.js +0 -755
  98. package/dist/convex/purchases.js +0 -156
  99. package/dist/convex/ratelimit.js +0 -90
  100. package/dist/convex/schema.js +0 -709
  101. package/dist/convex/searchLogs.js +0 -128
  102. package/dist/convex/spendAlerts.js +0 -379
  103. package/dist/convex/stripeActions.js +0 -410
  104. package/dist/convex/teams.js +0 -214
  105. package/dist/convex/telemetry.js +0 -73
  106. package/dist/convex/usage.js +0 -228
  107. package/dist/convex/waitlist.js +0 -48
  108. package/dist/convex/webhooks.js +0 -409
  109. package/dist/convex/workspaces.js +0 -879
  110. package/dist/hivr-whitelist.d.ts +0 -18
  111. package/dist/hivr-whitelist.d.ts.map +0 -1
  112. package/dist/hivr-whitelist.js +0 -95
  113. package/dist/hivr-whitelist.js.map +0 -1
  114. package/dist/http-server-minimal.d.ts +0 -7
  115. package/dist/http-server-minimal.d.ts.map +0 -1
  116. package/dist/http-server-minimal.js +0 -126
  117. package/dist/http-server-minimal.js.map +0 -1
  118. package/dist/product-whitelist.d.ts +0 -37
  119. package/dist/product-whitelist.d.ts.map +0 -1
  120. package/dist/product-whitelist.js +0 -203
  121. package/dist/product-whitelist.js.map +0 -1
  122. package/dist/src/analytics.js +0 -129
  123. package/dist/src/bin.js +0 -17
  124. package/dist/src/capability-router.js +0 -240
  125. package/dist/src/chainExecutor.js +0 -451
  126. package/dist/src/chainResolver.js +0 -518
  127. package/dist/src/cli/commands/doctor.js +0 -324
  128. package/dist/src/cli/commands/mcp-install.js +0 -255
  129. package/dist/src/cli/commands/restore.js +0 -259
  130. package/dist/src/cli/commands/setup.js +0 -205
  131. package/dist/src/cli/commands/uninstall.js +0 -188
  132. package/dist/src/cli/index.js +0 -111
  133. package/dist/src/cli.js +0 -302
  134. package/dist/src/confirmation.js +0 -240
  135. package/dist/src/credentials.js +0 -357
  136. package/dist/src/credits.js +0 -260
  137. package/dist/src/crypto.js +0 -66
  138. package/dist/src/discovery.js +0 -504
  139. package/dist/src/enterprise/env.js +0 -123
  140. package/dist/src/enterprise/script-generator.js +0 -460
  141. package/dist/src/execute-dynamic.js +0 -473
  142. package/dist/src/execute.js +0 -1727
  143. package/dist/src/index.js +0 -2062
  144. package/dist/src/metered.js +0 -80
  145. package/dist/src/open-apis.js +0 -276
  146. package/dist/src/proxy.js +0 -28
  147. package/dist/src/session.js +0 -86
  148. package/dist/src/stripe.js +0 -407
  149. package/dist/src/telemetry.js +0 -49
  150. package/dist/src/types.js +0 -2
  151. package/dist/src/utils/backup.js +0 -181
  152. package/dist/src/utils/config.js +0 -220
  153. package/dist/src/utils/os.js +0 -105
  154. package/dist/src/utils/paths.js +0 -159
  155. package/landing/pages/api/discover.ts +0 -43
  156. package/landing/pages/api/health.ts +0 -20
  157. package/scripts/test-whitelist-v2.sh +0 -128
  158. package/src/access-control.ts +0 -174
  159. package/src/hivr-whitelist.ts +0 -110
  160. package/src/http-server-minimal.ts +0 -154
  161. package/src/product-whitelist.ts +0 -246
  162. package/test-actual-handlers.ts +0 -92
  163. package/test-apilayer-all-14.ts +0 -249
  164. package/test-apilayer-fixed.ts +0 -248
  165. package/test-direct-endpoints.ts +0 -174
  166. package/test-exact-endpoints.ts +0 -144
  167. package/test-final.ts +0 -83
  168. package/test-full-routing.ts +0 -100
  169. package/test-handlers-correct.ts +0 -217
  170. package/test-numverify-key.ts +0 -41
  171. package/test-via-handlers.ts +0 -92
  172. package/test-worldnews.mjs +0 -26
@@ -1,220 +0,0 @@
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
- }
@@ -1,105 +0,0 @@
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
- }
@@ -1,159 +0,0 @@
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
- }
@@ -1,43 +0,0 @@
1
- /**
2
- * APIClaw Discovery API - Next.js API Route
3
- * GET /api/discover?query=...&agentId=...
4
- */
5
-
6
- import type { NextApiRequest, NextApiResponse } from 'next';
7
-
8
- // Import from built dist (since we can't easily import TS from parent)
9
- // For now, return a simple response - we'll implement full logic after verifying deployment
10
-
11
- export default async function handler(
12
- req: NextApiRequest,
13
- res: NextApiResponse
14
- ) {
15
- // CORS
16
- res.setHeader('Access-Control-Allow-Origin', '*');
17
- res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
18
- res.setHeader('Access-Control-Allow-Headers', 'Content-Type, X-Agent-Id');
19
-
20
- if (req.method === 'OPTIONS') {
21
- return res.status(200).end();
22
- }
23
-
24
- if (req.method !== 'GET') {
25
- return res.status(405).json({ error: 'Method not allowed' });
26
- }
27
-
28
- const { query, agentId, category, maxResults } = req.query;
29
-
30
- if (!query || typeof query !== 'string') {
31
- return res.status(400).json({ error: 'Missing query parameter' });
32
- }
33
-
34
- // TODO: Import actual whitelist + discovery logic
35
- // For now, simple passthrough
36
- return res.status(200).json({
37
- success: true,
38
- query,
39
- agentId: typeof agentId === 'string' ? agentId : undefined,
40
- message: 'APIClaw Discovery API - implementation pending',
41
- timestamp: new Date().toISOString(),
42
- });
43
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * APIClaw Health Check - Next.js API Route
3
- * GET /api/health
4
- */
5
-
6
- import type { NextApiRequest, NextApiResponse } from 'next';
7
-
8
- export default async function handler(
9
- req: NextApiRequest,
10
- res: NextApiResponse
11
- ) {
12
- res.setHeader('Access-Control-Allow-Origin', '*');
13
-
14
- return res.status(200).json({
15
- status: 'ok',
16
- service: 'apiclaw-http-api',
17
- version: '2.0.0',
18
- timestamp: new Date().toISOString(),
19
- });
20
- }
@@ -1,128 +0,0 @@
1
- #!/bin/bash
2
- # Test script for APIClaw Whitelist v2.0
3
- # Tests whitelist, access control, and analytics
4
-
5
- set -e
6
-
7
- echo "๐Ÿงช APIClaw Whitelist v2.0 Test Suite"
8
- echo "===================================="
9
- echo ""
10
-
11
- API_URL="${APICLAW_API_URL:-http://localhost:3000}"
12
-
13
- # Colors
14
- GREEN='\033[0;32m'
15
- RED='\033[0;31m'
16
- YELLOW='\033[1;33m'
17
- NC='\033[0m' # No Color
18
-
19
- function test_case() {
20
- local name=$1
21
- local expected=$2
22
- local cmd=$3
23
-
24
- echo -n "Testing: $name ... "
25
-
26
- response=$(eval "$cmd" 2>&1)
27
- status=$?
28
-
29
- if echo "$response" | grep -q "$expected"; then
30
- echo -e "${GREEN}โœ“ PASS${NC}"
31
- return 0
32
- else
33
- echo -e "${RED}โœ— FAIL${NC}"
34
- echo " Expected: $expected"
35
- echo " Got: $response"
36
- return 1
37
- fi
38
- }
39
-
40
- echo "1. Test Whitelist Authorization"
41
- echo "--------------------------------"
42
-
43
- # Test 1: Whitelisted agent (namespaced)
44
- test_case \
45
- "Namespaced agent (hivr:bytebee) authorized" \
46
- "200\|success" \
47
- "curl -s '$API_URL/api/discover?query=web&agentId=hivr:bytebee'"
48
-
49
- # Test 2: Whitelisted agent (legacy format)
50
- test_case \
51
- "Legacy agent (bytebee) authorized" \
52
- "200\|success" \
53
- "curl -s '$API_URL/api/discover?query=web&agentId=bytebee'"
54
-
55
- # Test 3: Unauthorized agent
56
- test_case \
57
- "Unauthorized agent denied" \
58
- "403\|Unauthorized\|Access Denied" \
59
- "curl -s '$API_URL/api/discover?query=web&agentId=hacker:evil'"
60
-
61
- echo ""
62
- echo "2. Test Access Control"
63
- echo "----------------------"
64
-
65
- # Test 4: Hivr agent accessing allowed provider
66
- test_case \
67
- "Hivr agent accessing brave_search (allowed)" \
68
- "200\|success" \
69
- "curl -s -X POST '$API_URL/api/call_api' -H 'Content-Type: application/json' -d '{\"agentId\":\"hivr:bytebee\",\"provider\":\"brave_search\",\"action\":\"search\",\"params\":{\"query\":\"test\"}}'"
70
-
71
- # Test 5: Restricted access (if NordSym configured)
72
- # This will fail if NordSym not configured yet, which is OK
73
- echo -n "Testing: NordSym agent restricted access ... "
74
- if curl -s -X POST "$API_URL/api/call_api" \
75
- -H "Content-Type: application/json" \
76
- -d '{"agentId":"nordsym:test","provider":"restricted_api","action":"call","params":{}}' \
77
- | grep -q "403\|Access Denied\|not whitelisted"; then
78
- echo -e "${GREEN}โœ“ PASS${NC} (correctly denied)"
79
- else
80
- echo -e "${YELLOW}โŠ˜ SKIP${NC} (NordSym not configured)"
81
- fi
82
-
83
- echo ""
84
- echo "3. Test Analytics"
85
- echo "-----------------"
86
-
87
- # Test 6: Product field in logs
88
- if [ -f ~/.apiclaw/logs/api-calls.jsonl ]; then
89
- recent_logs=$(tail -5 ~/.apiclaw/logs/api-calls.jsonl)
90
-
91
- echo -n "Testing: Product field in logs ... "
92
- if echo "$recent_logs" | grep -q '"product":"hivr"'; then
93
- echo -e "${GREEN}โœ“ PASS${NC}"
94
- else
95
- echo -e "${YELLOW}โŠ˜ WARN${NC} (no recent Hivr calls logged)"
96
- fi
97
- else
98
- echo -e "${YELLOW}โŠ˜ SKIP${NC} (no log file yet)"
99
- fi
100
-
101
- echo ""
102
- echo "4. Test Cache Behavior"
103
- echo "----------------------"
104
-
105
- # Test 7: Multiple requests use cache
106
- echo -n "Testing: Cache performance ... "
107
- start=$(date +%s%N)
108
- for i in {1..5}; do
109
- curl -s "$API_URL/api/discover?query=web&agentId=hivr:bytebee" > /dev/null
110
- done
111
- end=$(date +%s%N)
112
- elapsed=$(( (end - start) / 1000000 )) # Convert to ms
113
-
114
- if [ $elapsed -lt 1000 ]; then
115
- echo -e "${GREEN}โœ“ PASS${NC} (${elapsed}ms for 5 requests)"
116
- else
117
- echo -e "${YELLOW}โŠ˜ WARN${NC} (${elapsed}ms - cache might not be working)"
118
- fi
119
-
120
- echo ""
121
- echo "===================================="
122
- echo "Test suite complete!"
123
- echo ""
124
- echo "Next steps:"
125
- echo "1. Check logs: tail -f ~/.apiclaw/logs/api-calls.jsonl"
126
- echo "2. Monitor analytics for product field"
127
- echo "3. Add NordSym product source when ready"
128
- echo ""