@nordsym/apiclaw 2.2.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.
- package/README.md +15 -2
- package/dist/bin-http.js +0 -0
- package/dist/bin.bundled.js +79288 -0
- package/dist/gateway-client.d.ts.map +1 -1
- package/dist/gateway-client.js +24 -2
- package/dist/gateway-client.js.map +1 -1
- package/dist/index.bundled.js +61263 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
- package/.claude/settings.local.json +0 -13
- package/.env.prod +0 -1
- package/apiclaw-README.md +0 -494
- package/convex/_generated/api.d.ts +0 -145
- package/convex/_generated/api.js +0 -23
- package/convex/_generated/dataModel.d.ts +0 -60
- package/convex/_generated/server.d.ts +0 -143
- package/convex/_generated/server.js +0 -93
- package/convex/_listWorkspaces.ts +0 -13
- package/convex/adminActivate.ts +0 -53
- package/convex/adminStats.ts +0 -306
- package/convex/agents.ts +0 -939
- package/convex/analytics.ts +0 -187
- package/convex/apiKeys.ts +0 -220
- package/convex/backfillAnalytics.ts +0 -272
- package/convex/backfillSearchLogs.ts +0 -35
- package/convex/billing.ts +0 -834
- package/convex/capabilities.ts +0 -157
- package/convex/chains.ts +0 -1318
- package/convex/credits.ts +0 -211
- package/convex/crons.ts +0 -65
- package/convex/debugFilestackLogs.ts +0 -16
- package/convex/debugGetToken.ts +0 -18
- package/convex/directCall.ts +0 -713
- package/convex/earnProgress.ts +0 -753
- package/convex/email.ts +0 -329
- package/convex/feedback.ts +0 -265
- package/convex/funnel.ts +0 -431
- package/convex/guards.ts +0 -174
- package/convex/http.ts +0 -3756
- package/convex/inbound.ts +0 -32
- package/convex/logs.ts +0 -701
- package/convex/migrateFilestack.ts +0 -81
- package/convex/migratePartnersProd.ts +0 -174
- package/convex/migratePratham.ts +0 -126
- package/convex/migrateProviderWorkspaces.ts +0 -175
- package/convex/mou.ts +0 -91
- package/convex/nurture.ts +0 -355
- package/convex/providerKeys.ts +0 -289
- package/convex/providers.ts +0 -1135
- package/convex/purchases.ts +0 -183
- package/convex/ratelimit.ts +0 -104
- package/convex/schema.ts +0 -926
- package/convex/searchLogs.ts +0 -265
- package/convex/seedAPILayerAPIs.ts +0 -191
- package/convex/seedDirectCallConfigs.ts +0 -336
- package/convex/seedPratham.ts +0 -149
- package/convex/spendAlerts.ts +0 -442
- package/convex/stripeActions.ts +0 -607
- package/convex/teams.ts +0 -243
- package/convex/telemetry.ts +0 -81
- package/convex/tsconfig.json +0 -25
- package/convex/updateAPIStatus.ts +0 -44
- package/convex/usage.ts +0 -260
- package/convex/usageReports.ts +0 -357
- package/convex/waitlist.ts +0 -55
- package/convex/webhooks.ts +0 -494
- package/convex/workspaceSettings.ts +0 -143
- package/convex/workspaces.ts +0 -1331
- package/convex.json +0 -3
- package/direct-test.mjs +0 -51
- package/email-templates/filestack-provider-outreach.html +0 -162
- package/email-templates/partnership-template.html +0 -116
- package/email-templates/pratham-draft-preview.txt +0 -57
- package/email-templates/pratham-partnership-draft.html +0 -141
- package/reports/APIClaw-Session-Report-2026-04-05.pdf +0 -0
- package/reports/pipeline/PIPELINE-REPORT.json +0 -153
- package/reports/pipeline/acquire_apisguru.json +0 -17
- package/reports/pipeline/capabilities.json +0 -38
- package/reports/pipeline/discover_azure_recursive.json +0 -1551
- package/reports/pipeline/discover_github.json +0 -25
- package/reports/pipeline/discover_github_repos.json +0 -49
- package/reports/pipeline/discover_swaggerhub.json +0 -24
- package/reports/pipeline/discover_well_known.json +0 -23
- package/reports/pipeline/fetch_specs.json +0 -19
- package/reports/pipeline/generate_providers.json +0 -14
- package/reports/pipeline/match_registry.json +0 -11
- package/reports/pipeline/parse_specs.json +0 -17
- package/reports/pipeline/promote_candidates.json +0 -34
- package/reports/pipeline/validate.json +0 -30
- package/reports/pipeline/validate_smoke_details.json +0 -3835
- package/reports/session-report-2026-04-05.html +0 -433
- package/seed-apis-direct.mjs +0 -106
- package/src/access-control.ts +0 -174
- package/src/adapters/base.ts +0 -364
- package/src/adapters/claude-desktop.ts +0 -41
- package/src/adapters/cline.ts +0 -88
- package/src/adapters/continue.ts +0 -91
- package/src/adapters/cursor.ts +0 -43
- package/src/adapters/custom.ts +0 -188
- package/src/adapters/detect.ts +0 -202
- package/src/adapters/index.ts +0 -47
- package/src/adapters/windsurf.ts +0 -44
- package/src/bin-http.ts +0 -45
- package/src/bin.ts +0 -34
- package/src/capability-router.ts +0 -331
- package/src/chainExecutor.ts +0 -730
- package/src/chainResolver.test.ts +0 -246
- package/src/chainResolver.ts +0 -658
- package/src/cli/commands/demo.ts +0 -109
- package/src/cli/commands/doctor.ts +0 -435
- package/src/cli/commands/index.ts +0 -9
- package/src/cli/commands/login.ts +0 -203
- package/src/cli/commands/mcp-install.ts +0 -373
- package/src/cli/commands/restore.ts +0 -333
- package/src/cli/commands/setup.ts +0 -297
- package/src/cli/commands/uninstall.ts +0 -240
- package/src/cli/index.ts +0 -148
- package/src/cli.ts +0 -370
- package/src/confirmation.ts +0 -296
- package/src/credentials.ts +0 -455
- package/src/credits.ts +0 -329
- package/src/crypto.ts +0 -75
- package/src/discovery.ts +0 -568
- package/src/enterprise/env.ts +0 -156
- package/src/enterprise/index.ts +0 -7
- package/src/enterprise/script-generator.ts +0 -481
- package/src/execute-dynamic.ts +0 -617
- package/src/execute.ts +0 -2386
- package/src/funnel-client.ts +0 -168
- package/src/funnel.test.ts +0 -187
- package/src/gateway-client.ts +0 -192
- package/src/hivr-whitelist.ts +0 -110
- package/src/http-api.ts +0 -286
- package/src/http-server-minimal.ts +0 -154
- package/src/index.ts +0 -2702
- package/src/intelligent-gateway.ts +0 -339
- package/src/mcp-analytics.ts +0 -156
- package/src/metered.ts +0 -149
- package/src/open-apis-generated.ts +0 -157
- package/src/open-apis.ts +0 -558
- package/src/postinstall.ts +0 -40
- package/src/product-whitelist.ts +0 -246
- package/src/proxy.ts +0 -36
- package/src/registration-guard.ts +0 -117
- package/src/session.ts +0 -129
- package/src/stripe.ts +0 -497
- package/src/telemetry.ts +0 -71
- package/src/test.ts +0 -135
- package/src/types/convex-api.d.ts +0 -20
- package/src/types/convex-api.ts +0 -21
- package/src/types.ts +0 -109
- package/src/ui/colors.ts +0 -219
- package/src/ui/errors.ts +0 -394
- package/src/ui/index.ts +0 -17
- package/src/ui/prompts.ts +0 -390
- package/src/ui/spinner.ts +0 -325
- package/src/utils/backup.ts +0 -224
- package/src/utils/config.ts +0 -318
- package/src/utils/os.ts +0 -124
- package/src/utils/paths.ts +0 -203
- package/src/webhook.ts +0 -107
- package/test-10-working.cjs +0 -97
- package/test-14-final.cjs +0 -96
- package/test-actual-handlers.ts +0 -92
- package/test-apilayer-all-14.ts +0 -249
- package/test-apilayer-fixed.ts +0 -248
- package/test-direct-endpoints.ts +0 -174
- package/test-exact-endpoints.ts +0 -144
- package/test-final.ts +0 -83
- package/test-full-routing.ts +0 -100
- package/test-handlers-correct.ts +0 -217
- package/test-numverify-key.ts +0 -41
- package/test-via-handlers.ts +0 -92
- package/test-worldnews.mjs +0 -26
- package/tsconfig.json +0 -20
package/src/access-control.ts
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Access Control System
|
|
3
|
-
* Controls which products/agents can access which providers
|
|
4
|
-
*
|
|
5
|
-
* Rules format:
|
|
6
|
-
* - Wildcard: "hivr:*" = all Hivr agents
|
|
7
|
-
* - Specific: "hivr:bytebee" = only ByteBee
|
|
8
|
-
* - Product-level: "nordsym:*" = all NordSym agents
|
|
9
|
-
*
|
|
10
|
-
* Provider wildcards:
|
|
11
|
-
* - "*" = all providers
|
|
12
|
-
* - "brave_*" = all Brave providers
|
|
13
|
-
* - Specific: ["brave_search", "groq"]
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
interface AccessRule {
|
|
17
|
-
agentPattern: string;
|
|
18
|
-
allowedProviders: string[];
|
|
19
|
-
description?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Default access rules
|
|
23
|
-
// These can be moved to Convex table for dynamic updates
|
|
24
|
-
const DEFAULT_RULES: AccessRule[] = [
|
|
25
|
-
{
|
|
26
|
-
agentPattern: 'hivr:*',
|
|
27
|
-
allowedProviders: ['*'], // Hivr gets everything
|
|
28
|
-
description: 'All Hivr bees get full access',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
agentPattern: 'nordsym:*',
|
|
32
|
-
allowedProviders: ['brave_search', 'groq', 'replicate'],
|
|
33
|
-
description: 'NordSym team gets selected providers',
|
|
34
|
-
},
|
|
35
|
-
// Add more rules as needed
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
// Cache for compiled rules
|
|
39
|
-
let compiledRules: {
|
|
40
|
-
pattern: RegExp;
|
|
41
|
-
providers: string[];
|
|
42
|
-
}[] | null = null;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Compile agentPattern to RegExp
|
|
46
|
-
*/
|
|
47
|
-
function compilePattern(pattern: string): RegExp {
|
|
48
|
-
// Convert wildcard pattern to regex
|
|
49
|
-
// "hivr:*" → /^hivr:.+$/
|
|
50
|
-
// "hivr:byte*" → /^hivr:byte.+$/
|
|
51
|
-
const escaped = pattern
|
|
52
|
-
.replace(/[.+^${}()|[\]\\]/g, '\\$&') // Escape regex chars
|
|
53
|
-
.replace(/\*/g, '.+'); // Replace * with .+
|
|
54
|
-
|
|
55
|
-
return new RegExp(`^${escaped}$`, 'i');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Compile all rules (cache for performance)
|
|
60
|
-
*/
|
|
61
|
-
function compileRules(): void {
|
|
62
|
-
compiledRules = DEFAULT_RULES.map(rule => ({
|
|
63
|
-
pattern: compilePattern(rule.agentPattern),
|
|
64
|
-
providers: rule.allowedProviders,
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Check if provider matches pattern
|
|
70
|
-
*/
|
|
71
|
-
function matchesProvider(provider: string, pattern: string): boolean {
|
|
72
|
-
if (pattern === '*') return true;
|
|
73
|
-
if (pattern.endsWith('*')) {
|
|
74
|
-
const prefix = pattern.slice(0, -1);
|
|
75
|
-
return provider.startsWith(prefix);
|
|
76
|
-
}
|
|
77
|
-
return provider === pattern;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Check if agentId is allowed to access provider
|
|
82
|
-
*/
|
|
83
|
-
export function canAccessProvider(agentId: string, provider: string): boolean {
|
|
84
|
-
if (!compiledRules) {
|
|
85
|
-
compileRules();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const normalized = agentId.toLowerCase().trim();
|
|
89
|
-
const normalizedProvider = provider.toLowerCase().trim();
|
|
90
|
-
|
|
91
|
-
// Find matching rule
|
|
92
|
-
for (const rule of compiledRules!) {
|
|
93
|
-
if (rule.pattern.test(normalized)) {
|
|
94
|
-
// Check if provider is allowed
|
|
95
|
-
for (const providerPattern of rule.providers) {
|
|
96
|
-
if (matchesProvider(normalizedProvider, providerPattern)) {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
// Rule matched but provider not in allowlist
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// No rule matched = deny by default
|
|
106
|
-
console.warn(`[Access Control] No rule for ${normalized}`);
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Get allowed providers for agentId
|
|
112
|
-
*/
|
|
113
|
-
export function getAllowedProviders(agentId: string): string[] {
|
|
114
|
-
if (!compiledRules) {
|
|
115
|
-
compileRules();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const normalized = agentId.toLowerCase().trim();
|
|
119
|
-
|
|
120
|
-
// Find matching rule
|
|
121
|
-
for (const rule of compiledRules!) {
|
|
122
|
-
if (rule.pattern.test(normalized)) {
|
|
123
|
-
return rule.providers;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return [];
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Add new access rule (runtime)
|
|
132
|
-
*/
|
|
133
|
-
export function addAccessRule(rule: AccessRule): void {
|
|
134
|
-
DEFAULT_RULES.push(rule);
|
|
135
|
-
compiledRules = null; // Force recompile
|
|
136
|
-
console.log(`[Access Control] Added rule for ${rule.agentPattern}`);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Get all access rules (for debugging/admin)
|
|
141
|
-
*/
|
|
142
|
-
export function getAccessRules(): AccessRule[] {
|
|
143
|
-
return [...DEFAULT_RULES];
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Check if agentId + provider combination is allowed
|
|
148
|
-
* Combines whitelist check + access control
|
|
149
|
-
*/
|
|
150
|
-
export async function isAllowed(
|
|
151
|
-
agentId: string | undefined,
|
|
152
|
-
provider: string
|
|
153
|
-
): Promise<{ allowed: boolean; reason?: string }> {
|
|
154
|
-
if (!agentId) {
|
|
155
|
-
return { allowed: false, reason: 'No agentId provided' };
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// First check: Is agent whitelisted?
|
|
159
|
-
const { isAuthorized } = await import('./product-whitelist.js');
|
|
160
|
-
const whitelisted = await isAuthorized(agentId);
|
|
161
|
-
|
|
162
|
-
if (!whitelisted) {
|
|
163
|
-
return { allowed: false, reason: 'Agent not whitelisted' };
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Second check: Does agent have access to this provider?
|
|
167
|
-
const hasAccess = canAccessProvider(agentId, provider);
|
|
168
|
-
|
|
169
|
-
if (!hasAccess) {
|
|
170
|
-
return { allowed: false, reason: 'Provider not in access list' };
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return { allowed: true };
|
|
174
|
-
}
|
package/src/adapters/base.ts
DELETED
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Client Adapter - Base Interface & Abstract Class
|
|
3
|
-
* Defines the contract for all MCP client adapters
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { existsSync } from 'fs';
|
|
7
|
-
import { dirname } from 'path';
|
|
8
|
-
import { MCPClient, getConfigPath, getClientConfig } from '../utils/paths.js';
|
|
9
|
-
import { detectOS, Platform } from '../utils/os.js';
|
|
10
|
-
import { createBackup, BackupResult } from '../utils/backup.js';
|
|
11
|
-
import {
|
|
12
|
-
readConfig,
|
|
13
|
-
writeConfig,
|
|
14
|
-
mergeApiclawConfig,
|
|
15
|
-
mergeApiclawContinueConfig,
|
|
16
|
-
hasApiclawConfig,
|
|
17
|
-
MCPConfig,
|
|
18
|
-
ContinueConfig,
|
|
19
|
-
isContinueFormat,
|
|
20
|
-
} from '../utils/config.js';
|
|
21
|
-
|
|
22
|
-
export interface ConfigResult {
|
|
23
|
-
success: boolean;
|
|
24
|
-
message: string;
|
|
25
|
-
configPath: string;
|
|
26
|
-
backupPath?: string | null;
|
|
27
|
-
isNew?: boolean;
|
|
28
|
-
alreadyConfigured?: boolean;
|
|
29
|
-
error?: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface VerifyResult {
|
|
33
|
-
success: boolean;
|
|
34
|
-
hasConfig: boolean;
|
|
35
|
-
configValid: boolean;
|
|
36
|
-
message: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface InstallInfo {
|
|
40
|
-
installed: boolean;
|
|
41
|
-
appPath?: string;
|
|
42
|
-
configExists: boolean;
|
|
43
|
-
configPath: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface ConfigureOptions {
|
|
47
|
-
workspaceId?: string;
|
|
48
|
-
serverName?: string;
|
|
49
|
-
force?: boolean;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* MCP Client Adapter Interface
|
|
54
|
-
*/
|
|
55
|
-
export interface MCPClientAdapter {
|
|
56
|
-
/** Internal client name */
|
|
57
|
-
name: MCPClient | 'custom';
|
|
58
|
-
|
|
59
|
-
/** Human-readable display name */
|
|
60
|
-
displayName: string;
|
|
61
|
-
|
|
62
|
-
/** Check if the client is installed on the system */
|
|
63
|
-
isInstalled(): Promise<boolean>;
|
|
64
|
-
|
|
65
|
-
/** Get the config file path for this client */
|
|
66
|
-
getConfigPath(): string;
|
|
67
|
-
|
|
68
|
-
/** Configure APIClaw MCP server for this client */
|
|
69
|
-
configure(options?: ConfigureOptions): Promise<ConfigResult>;
|
|
70
|
-
|
|
71
|
-
/** Verify the current configuration */
|
|
72
|
-
verify(): Promise<VerifyResult>;
|
|
73
|
-
|
|
74
|
-
/** Get detailed installation info */
|
|
75
|
-
getInstallInfo(): Promise<InstallInfo>;
|
|
76
|
-
|
|
77
|
-
/** Remove APIClaw configuration */
|
|
78
|
-
unconfigure(serverName?: string): Promise<ConfigResult>;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Abstract base class for MCP client adapters
|
|
83
|
-
* Provides common functionality for all adapters
|
|
84
|
-
*/
|
|
85
|
-
export abstract class BaseAdapter implements MCPClientAdapter {
|
|
86
|
-
abstract name: MCPClient | 'custom';
|
|
87
|
-
abstract displayName: string;
|
|
88
|
-
|
|
89
|
-
protected os: Platform;
|
|
90
|
-
|
|
91
|
-
constructor() {
|
|
92
|
-
this.os = detectOS();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Get the config file path
|
|
97
|
-
*/
|
|
98
|
-
getConfigPath(): string {
|
|
99
|
-
if (this.name === 'custom') {
|
|
100
|
-
throw new Error('Custom adapter must override getConfigPath()');
|
|
101
|
-
}
|
|
102
|
-
return getConfigPath(this.name, this.os);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Check if config file exists
|
|
107
|
-
*/
|
|
108
|
-
protected configExists(): boolean {
|
|
109
|
-
try {
|
|
110
|
-
return existsSync(this.getConfigPath());
|
|
111
|
-
} catch {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Get application paths to check for installation
|
|
118
|
-
* Override in subclasses for specific clients
|
|
119
|
-
*/
|
|
120
|
-
protected abstract getAppPaths(): string[];
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Check if the client application is installed
|
|
124
|
-
*/
|
|
125
|
-
async isInstalled(): Promise<boolean> {
|
|
126
|
-
// Check if config file exists
|
|
127
|
-
if (this.configExists()) {
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Check if app is installed
|
|
132
|
-
const appPaths = this.getAppPaths();
|
|
133
|
-
for (const path of appPaths) {
|
|
134
|
-
if (existsSync(path)) {
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Get detailed installation information
|
|
144
|
-
*/
|
|
145
|
-
async getInstallInfo(): Promise<InstallInfo> {
|
|
146
|
-
const configPath = this.getConfigPath();
|
|
147
|
-
const configExists = this.configExists();
|
|
148
|
-
|
|
149
|
-
let appPath: string | undefined;
|
|
150
|
-
const appPaths = this.getAppPaths();
|
|
151
|
-
for (const path of appPaths) {
|
|
152
|
-
if (existsSync(path)) {
|
|
153
|
-
appPath = path;
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return {
|
|
159
|
-
installed: configExists || appPath !== undefined,
|
|
160
|
-
appPath,
|
|
161
|
-
configExists,
|
|
162
|
-
configPath,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Configure APIClaw MCP server
|
|
168
|
-
*/
|
|
169
|
-
async configure(options: ConfigureOptions = {}): Promise<ConfigResult> {
|
|
170
|
-
const configPath = this.getConfigPath();
|
|
171
|
-
|
|
172
|
-
try {
|
|
173
|
-
// Read existing config
|
|
174
|
-
const readResult = readConfig(configPath);
|
|
175
|
-
if (!readResult.success) {
|
|
176
|
-
return {
|
|
177
|
-
success: false,
|
|
178
|
-
message: `Failed to read config: ${readResult.error}`,
|
|
179
|
-
configPath,
|
|
180
|
-
error: readResult.error,
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const config = readResult.config!;
|
|
185
|
-
const serverName = options.serverName || 'apiclaw';
|
|
186
|
-
|
|
187
|
-
// Check if already configured
|
|
188
|
-
if (!options.force && hasApiclawConfig(config, serverName)) {
|
|
189
|
-
return {
|
|
190
|
-
success: true,
|
|
191
|
-
message: `APIClaw already configured in ${this.displayName}`,
|
|
192
|
-
configPath,
|
|
193
|
-
alreadyConfigured: true,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Merge APIClaw config
|
|
198
|
-
const mergeOptions = {
|
|
199
|
-
workspace: options.workspaceId,
|
|
200
|
-
serverName,
|
|
201
|
-
force: options.force,
|
|
202
|
-
clientName: this.name === 'custom' ? undefined : this.name,
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
const newConfig = this.mergeConfig(config, mergeOptions);
|
|
206
|
-
|
|
207
|
-
// Write config
|
|
208
|
-
const writeResult = writeConfig(configPath, newConfig);
|
|
209
|
-
if (!writeResult.success) {
|
|
210
|
-
return {
|
|
211
|
-
success: false,
|
|
212
|
-
message: `Failed to write config: ${writeResult.error}`,
|
|
213
|
-
configPath,
|
|
214
|
-
error: writeResult.error,
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return {
|
|
219
|
-
success: true,
|
|
220
|
-
message: `Successfully configured APIClaw in ${this.displayName}`,
|
|
221
|
-
configPath,
|
|
222
|
-
backupPath: writeResult.backupPath,
|
|
223
|
-
isNew: readResult.isNew,
|
|
224
|
-
};
|
|
225
|
-
} catch (error) {
|
|
226
|
-
return {
|
|
227
|
-
success: false,
|
|
228
|
-
message: `Configuration failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
229
|
-
configPath,
|
|
230
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Merge APIClaw config into existing config
|
|
237
|
-
* Override in subclasses for special formats (e.g., Continue)
|
|
238
|
-
*/
|
|
239
|
-
protected mergeConfig(
|
|
240
|
-
config: MCPConfig | ContinueConfig,
|
|
241
|
-
options: { workspace?: string; serverName?: string; force?: boolean }
|
|
242
|
-
): MCPConfig | ContinueConfig {
|
|
243
|
-
return mergeApiclawConfig(config as MCPConfig, options);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Verify the current configuration
|
|
248
|
-
*/
|
|
249
|
-
async verify(): Promise<VerifyResult> {
|
|
250
|
-
const configPath = this.getConfigPath();
|
|
251
|
-
|
|
252
|
-
if (!this.configExists()) {
|
|
253
|
-
return {
|
|
254
|
-
success: false,
|
|
255
|
-
hasConfig: false,
|
|
256
|
-
configValid: false,
|
|
257
|
-
message: `Config file not found: ${configPath}`,
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const readResult = readConfig(configPath);
|
|
262
|
-
if (!readResult.success) {
|
|
263
|
-
return {
|
|
264
|
-
success: false,
|
|
265
|
-
hasConfig: true,
|
|
266
|
-
configValid: false,
|
|
267
|
-
message: `Invalid config file: ${readResult.error}`,
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const hasApiclaw = hasApiclawConfig(readResult.config!);
|
|
272
|
-
|
|
273
|
-
return {
|
|
274
|
-
success: hasApiclaw,
|
|
275
|
-
hasConfig: true,
|
|
276
|
-
configValid: true,
|
|
277
|
-
message: hasApiclaw
|
|
278
|
-
? `APIClaw is configured in ${this.displayName}`
|
|
279
|
-
: `APIClaw is not configured in ${this.displayName}`,
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Remove APIClaw configuration
|
|
285
|
-
*/
|
|
286
|
-
async unconfigure(serverName = 'apiclaw'): Promise<ConfigResult> {
|
|
287
|
-
const configPath = this.getConfigPath();
|
|
288
|
-
|
|
289
|
-
try {
|
|
290
|
-
if (!this.configExists()) {
|
|
291
|
-
return {
|
|
292
|
-
success: true,
|
|
293
|
-
message: `No config file found for ${this.displayName}`,
|
|
294
|
-
configPath,
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const readResult = readConfig(configPath);
|
|
299
|
-
if (!readResult.success) {
|
|
300
|
-
return {
|
|
301
|
-
success: false,
|
|
302
|
-
message: `Failed to read config: ${readResult.error}`,
|
|
303
|
-
configPath,
|
|
304
|
-
error: readResult.error,
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const config = readResult.config!;
|
|
309
|
-
|
|
310
|
-
if (!hasApiclawConfig(config, serverName)) {
|
|
311
|
-
return {
|
|
312
|
-
success: true,
|
|
313
|
-
message: `APIClaw not found in ${this.displayName} config`,
|
|
314
|
-
configPath,
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Remove APIClaw config
|
|
319
|
-
const newConfig = this.removeFromConfig(config, serverName);
|
|
320
|
-
|
|
321
|
-
// Write config
|
|
322
|
-
const writeResult = writeConfig(configPath, newConfig);
|
|
323
|
-
if (!writeResult.success) {
|
|
324
|
-
return {
|
|
325
|
-
success: false,
|
|
326
|
-
message: `Failed to write config: ${writeResult.error}`,
|
|
327
|
-
configPath,
|
|
328
|
-
error: writeResult.error,
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
return {
|
|
333
|
-
success: true,
|
|
334
|
-
message: `Successfully removed APIClaw from ${this.displayName}`,
|
|
335
|
-
configPath,
|
|
336
|
-
backupPath: writeResult.backupPath,
|
|
337
|
-
};
|
|
338
|
-
} catch (error) {
|
|
339
|
-
return {
|
|
340
|
-
success: false,
|
|
341
|
-
message: `Unconfigure failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
342
|
-
configPath,
|
|
343
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Remove APIClaw from config
|
|
350
|
-
* Override in subclasses for special formats
|
|
351
|
-
*/
|
|
352
|
-
protected removeFromConfig(
|
|
353
|
-
config: MCPConfig | ContinueConfig,
|
|
354
|
-
serverName: string
|
|
355
|
-
): MCPConfig | ContinueConfig {
|
|
356
|
-
const mcpConfig = config as MCPConfig;
|
|
357
|
-
const { [serverName]: _, ...remainingServers } = mcpConfig.mcpServers || {};
|
|
358
|
-
|
|
359
|
-
return {
|
|
360
|
-
...mcpConfig,
|
|
361
|
-
mcpServers: remainingServers,
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Claude Desktop Adapter
|
|
3
|
-
* Handles MCP configuration for Claude Desktop app
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { join } from 'path';
|
|
7
|
-
import { BaseAdapter } from './base.js';
|
|
8
|
-
import { MCPClient } from '../utils/paths.js';
|
|
9
|
-
import { getHomeDir } from '../utils/os.js';
|
|
10
|
-
|
|
11
|
-
export class ClaudeDesktopAdapter extends BaseAdapter {
|
|
12
|
-
name: MCPClient = 'claude-desktop';
|
|
13
|
-
displayName = 'Claude Desktop';
|
|
14
|
-
|
|
15
|
-
protected getAppPaths(): string[] {
|
|
16
|
-
switch (this.os) {
|
|
17
|
-
case 'mac':
|
|
18
|
-
return [
|
|
19
|
-
'/Applications/Claude.app',
|
|
20
|
-
join(getHomeDir(), 'Applications', 'Claude.app'),
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
case 'win':
|
|
24
|
-
const localAppData = process.env.LOCALAPPDATA || join(getHomeDir(), 'AppData', 'Local');
|
|
25
|
-
const programFiles = process.env.PROGRAMFILES || 'C:\\Program Files';
|
|
26
|
-
return [
|
|
27
|
-
join(localAppData, 'Programs', 'Claude', 'Claude.exe'),
|
|
28
|
-
join(programFiles, 'Claude', 'Claude.exe'),
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
case 'linux':
|
|
32
|
-
return [
|
|
33
|
-
'/usr/bin/claude',
|
|
34
|
-
'/usr/local/bin/claude',
|
|
35
|
-
join(getHomeDir(), '.local', 'bin', 'claude'),
|
|
36
|
-
'/snap/bin/claude',
|
|
37
|
-
'/var/lib/flatpak/exports/bin/com.anthropic.claude',
|
|
38
|
-
];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
package/src/adapters/cline.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cline Adapter
|
|
3
|
-
* Handles MCP configuration for Cline VS Code extension
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { join } from 'path';
|
|
7
|
-
import { BaseAdapter } from './base.js';
|
|
8
|
-
import { MCPClient } from '../utils/paths.js';
|
|
9
|
-
import { getHomeDir, getAppDataDir } from '../utils/os.js';
|
|
10
|
-
|
|
11
|
-
export class ClineAdapter extends BaseAdapter {
|
|
12
|
-
name: MCPClient = 'cline';
|
|
13
|
-
displayName = 'Cline';
|
|
14
|
-
|
|
15
|
-
protected getAppPaths(): string[] {
|
|
16
|
-
// Cline is a VS Code extension, so we check for VS Code
|
|
17
|
-
// and the extension directory
|
|
18
|
-
const home = getHomeDir();
|
|
19
|
-
const appData = getAppDataDir();
|
|
20
|
-
|
|
21
|
-
switch (this.os) {
|
|
22
|
-
case 'mac':
|
|
23
|
-
return [
|
|
24
|
-
'/Applications/Visual Studio Code.app',
|
|
25
|
-
join(home, 'Applications', 'Visual Studio Code.app'),
|
|
26
|
-
// Also check for extension directory
|
|
27
|
-
join(home, '.vscode', 'extensions'),
|
|
28
|
-
join(appData, 'Code', 'User', 'globalStorage', 'saoudrizwan.claude-dev'),
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
case 'win':
|
|
32
|
-
const localAppData = process.env.LOCALAPPDATA || join(home, 'AppData', 'Local');
|
|
33
|
-
const programFiles = process.env.PROGRAMFILES || 'C:\\Program Files';
|
|
34
|
-
return [
|
|
35
|
-
join(localAppData, 'Programs', 'Microsoft VS Code', 'Code.exe'),
|
|
36
|
-
join(programFiles, 'Microsoft VS Code', 'Code.exe'),
|
|
37
|
-
// Extension directory
|
|
38
|
-
join(home, '.vscode', 'extensions'),
|
|
39
|
-
join(appData, 'Code', 'User', 'globalStorage', 'saoudrizwan.claude-dev'),
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
case 'linux':
|
|
43
|
-
return [
|
|
44
|
-
'/usr/bin/code',
|
|
45
|
-
'/usr/local/bin/code',
|
|
46
|
-
'/snap/bin/code',
|
|
47
|
-
join(home, '.local', 'bin', 'code'),
|
|
48
|
-
// Extension directory
|
|
49
|
-
join(home, '.vscode', 'extensions'),
|
|
50
|
-
join(home, '.config', 'Code', 'User', 'globalStorage', 'saoudrizwan.claude-dev'),
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Override isInstalled to also check for the Cline extension specifically
|
|
57
|
-
*/
|
|
58
|
-
async isInstalled(): Promise<boolean> {
|
|
59
|
-
// First check base implementation
|
|
60
|
-
if (await super.isInstalled()) {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Check if Cline extension is installed
|
|
65
|
-
const extensionPaths = this.getClineExtensionPaths();
|
|
66
|
-
for (const path of extensionPaths) {
|
|
67
|
-
const { existsSync } = await import('fs');
|
|
68
|
-
if (existsSync(path)) {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Get possible Cline extension installation paths
|
|
78
|
-
*/
|
|
79
|
-
private getClineExtensionPaths(): string[] {
|
|
80
|
-
const home = getHomeDir();
|
|
81
|
-
const extensionsDir = join(home, '.vscode', 'extensions');
|
|
82
|
-
|
|
83
|
-
// Extension directories are named like: saoudrizwan.claude-dev-x.x.x
|
|
84
|
-
return [
|
|
85
|
-
extensionsDir, // We'll check for pattern in isInstalled
|
|
86
|
-
];
|
|
87
|
-
}
|
|
88
|
-
}
|