arcagent-mcp 0.1.0
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 +84 -0
- package/dist/auth/apiKeyAuth.d.ts +16 -0
- package/dist/auth/apiKeyAuth.d.ts.map +1 -0
- package/dist/auth/apiKeyAuth.js +65 -0
- package/dist/auth/apiKeyAuth.js.map +1 -0
- package/dist/config.d.ts +21 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +63 -0
- package/dist/config.js.map +1 -0
- package/dist/convex/client.d.ts +7 -0
- package/dist/convex/client.d.ts.map +1 -0
- package/dist/convex/client.js +60 -0
- package/dist/convex/client.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +370 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/clerk.d.ts +12 -0
- package/dist/lib/clerk.d.ts.map +1 -0
- package/dist/lib/clerk.js +77 -0
- package/dist/lib/clerk.js.map +1 -0
- package/dist/lib/context.d.ts +30 -0
- package/dist/lib/context.d.ts.map +1 -0
- package/dist/lib/context.js +73 -0
- package/dist/lib/context.js.map +1 -0
- package/dist/lib/crypto.d.ts +14 -0
- package/dist/lib/crypto.d.ts.map +1 -0
- package/dist/lib/crypto.js +25 -0
- package/dist/lib/crypto.js.map +1 -0
- package/dist/lib/httpError.d.ts +10 -0
- package/dist/lib/httpError.d.ts.map +1 -0
- package/dist/lib/httpError.js +13 -0
- package/dist/lib/httpError.js.map +1 -0
- package/dist/lib/lruCache.d.ts +13 -0
- package/dist/lib/lruCache.d.ts.map +1 -0
- package/dist/lib/lruCache.js +52 -0
- package/dist/lib/lruCache.js.map +1 -0
- package/dist/lib/rateLimit.d.ts +14 -0
- package/dist/lib/rateLimit.d.ts.map +1 -0
- package/dist/lib/rateLimit.js +108 -0
- package/dist/lib/rateLimit.js.map +1 -0
- package/dist/lib/sessionStore.d.ts +15 -0
- package/dist/lib/sessionStore.d.ts.map +1 -0
- package/dist/lib/sessionStore.js +86 -0
- package/dist/lib/sessionStore.js.map +1 -0
- package/dist/lib/telemetry.d.ts +21 -0
- package/dist/lib/telemetry.d.ts.map +1 -0
- package/dist/lib/telemetry.js +43 -0
- package/dist/lib/telemetry.js.map +1 -0
- package/dist/lib/toolHelper.d.ts +13 -0
- package/dist/lib/toolHelper.d.ts.map +1 -0
- package/dist/lib/toolHelper.js +20 -0
- package/dist/lib/toolHelper.js.map +1 -0
- package/dist/lib/toolProfiles.d.ts +62 -0
- package/dist/lib/toolProfiles.d.ts.map +1 -0
- package/dist/lib/toolProfiles.js +110 -0
- package/dist/lib/toolProfiles.js.map +1 -0
- package/dist/lib/types.d.ts +128 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +3 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +101 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/cancelBounty.d.ts +3 -0
- package/dist/tools/cancelBounty.d.ts.map +1 -0
- package/dist/tools/cancelBounty.js +59 -0
- package/dist/tools/cancelBounty.js.map +1 -0
- package/dist/tools/checkNotifications.d.ts +3 -0
- package/dist/tools/checkNotifications.d.ts.map +1 -0
- package/dist/tools/checkNotifications.js +69 -0
- package/dist/tools/checkNotifications.js.map +1 -0
- package/dist/tools/claimBounty.d.ts +3 -0
- package/dist/tools/claimBounty.d.ts.map +1 -0
- package/dist/tools/claimBounty.js +59 -0
- package/dist/tools/claimBounty.js.map +1 -0
- package/dist/tools/createBounty.d.ts +3 -0
- package/dist/tools/createBounty.d.ts.map +1 -0
- package/dist/tools/createBounty.js +90 -0
- package/dist/tools/createBounty.js.map +1 -0
- package/dist/tools/extendClaim.d.ts +3 -0
- package/dist/tools/extendClaim.d.ts.map +1 -0
- package/dist/tools/extendClaim.js +68 -0
- package/dist/tools/extendClaim.js.map +1 -0
- package/dist/tools/fundBountyEscrow.d.ts +3 -0
- package/dist/tools/fundBountyEscrow.d.ts.map +1 -0
- package/dist/tools/fundBountyEscrow.js +49 -0
- package/dist/tools/fundBountyEscrow.js.map +1 -0
- package/dist/tools/getAgentProfile.d.ts +3 -0
- package/dist/tools/getAgentProfile.d.ts.map +1 -0
- package/dist/tools/getAgentProfile.js +45 -0
- package/dist/tools/getAgentProfile.js.map +1 -0
- package/dist/tools/getBountyDetails.d.ts +3 -0
- package/dist/tools/getBountyDetails.d.ts.map +1 -0
- package/dist/tools/getBountyDetails.js +79 -0
- package/dist/tools/getBountyDetails.js.map +1 -0
- package/dist/tools/getBountyGenerationStatus.d.ts +3 -0
- package/dist/tools/getBountyGenerationStatus.d.ts.map +1 -0
- package/dist/tools/getBountyGenerationStatus.js +71 -0
- package/dist/tools/getBountyGenerationStatus.js.map +1 -0
- package/dist/tools/getClaimStatus.d.ts +3 -0
- package/dist/tools/getClaimStatus.d.ts.map +1 -0
- package/dist/tools/getClaimStatus.js +78 -0
- package/dist/tools/getClaimStatus.js.map +1 -0
- package/dist/tools/getLeaderboard.d.ts +3 -0
- package/dist/tools/getLeaderboard.d.ts.map +1 -0
- package/dist/tools/getLeaderboard.js +40 -0
- package/dist/tools/getLeaderboard.js.map +1 -0
- package/dist/tools/getMyAgentStats.d.ts +3 -0
- package/dist/tools/getMyAgentStats.d.ts.map +1 -0
- package/dist/tools/getMyAgentStats.js +65 -0
- package/dist/tools/getMyAgentStats.js.map +1 -0
- package/dist/tools/getRepoMap.d.ts +3 -0
- package/dist/tools/getRepoMap.d.ts.map +1 -0
- package/dist/tools/getRepoMap.js +139 -0
- package/dist/tools/getRepoMap.js.map +1 -0
- package/dist/tools/getSubmissionFeedback.d.ts +3 -0
- package/dist/tools/getSubmissionFeedback.d.ts.map +1 -0
- package/dist/tools/getSubmissionFeedback.js +81 -0
- package/dist/tools/getSubmissionFeedback.js.map +1 -0
- package/dist/tools/getTestSuites.d.ts +3 -0
- package/dist/tools/getTestSuites.d.ts.map +1 -0
- package/dist/tools/getTestSuites.js +64 -0
- package/dist/tools/getTestSuites.js.map +1 -0
- package/dist/tools/getVerificationStatus.d.ts +3 -0
- package/dist/tools/getVerificationStatus.d.ts.map +1 -0
- package/dist/tools/getVerificationStatus.js +115 -0
- package/dist/tools/getVerificationStatus.js.map +1 -0
- package/dist/tools/importWorkItem.d.ts +3 -0
- package/dist/tools/importWorkItem.d.ts.map +1 -0
- package/dist/tools/importWorkItem.js +156 -0
- package/dist/tools/importWorkItem.js.map +1 -0
- package/dist/tools/listBounties.d.ts +3 -0
- package/dist/tools/listBounties.d.ts.map +1 -0
- package/dist/tools/listBounties.js +49 -0
- package/dist/tools/listBounties.js.map +1 -0
- package/dist/tools/listMySubmissions.d.ts +3 -0
- package/dist/tools/listMySubmissions.d.ts.map +1 -0
- package/dist/tools/listMySubmissions.js +46 -0
- package/dist/tools/listMySubmissions.js.map +1 -0
- package/dist/tools/rateAgent.d.ts +3 -0
- package/dist/tools/rateAgent.d.ts.map +1 -0
- package/dist/tools/rateAgent.js +94 -0
- package/dist/tools/rateAgent.js.map +1 -0
- package/dist/tools/registerAccount.d.ts +3 -0
- package/dist/tools/registerAccount.d.ts.map +1 -0
- package/dist/tools/registerAccount.js +103 -0
- package/dist/tools/registerAccount.js.map +1 -0
- package/dist/tools/releaseClaim.d.ts +3 -0
- package/dist/tools/releaseClaim.d.ts.map +1 -0
- package/dist/tools/releaseClaim.js +43 -0
- package/dist/tools/releaseClaim.js.map +1 -0
- package/dist/tools/setupPaymentMethod.d.ts +3 -0
- package/dist/tools/setupPaymentMethod.d.ts.map +1 -0
- package/dist/tools/setupPaymentMethod.js +53 -0
- package/dist/tools/setupPaymentMethod.js.map +1 -0
- package/dist/tools/setupPayoutAccount.d.ts +3 -0
- package/dist/tools/setupPayoutAccount.d.ts.map +1 -0
- package/dist/tools/setupPayoutAccount.js +44 -0
- package/dist/tools/setupPayoutAccount.js.map +1 -0
- package/dist/tools/submitSolution.d.ts +3 -0
- package/dist/tools/submitSolution.d.ts.map +1 -0
- package/dist/tools/submitSolution.js +98 -0
- package/dist/tools/submitSolution.js.map +1 -0
- package/dist/tools/workspaceApplyPatch.d.ts +41 -0
- package/dist/tools/workspaceApplyPatch.d.ts.map +1 -0
- package/dist/tools/workspaceApplyPatch.js +328 -0
- package/dist/tools/workspaceApplyPatch.js.map +1 -0
- package/dist/tools/workspaceBatchRead.d.ts +3 -0
- package/dist/tools/workspaceBatchRead.d.ts.map +1 -0
- package/dist/tools/workspaceBatchRead.js +95 -0
- package/dist/tools/workspaceBatchRead.js.map +1 -0
- package/dist/tools/workspaceBatchWrite.d.ts +3 -0
- package/dist/tools/workspaceBatchWrite.d.ts.map +1 -0
- package/dist/tools/workspaceBatchWrite.js +94 -0
- package/dist/tools/workspaceBatchWrite.js.map +1 -0
- package/dist/tools/workspaceCrashReports.d.ts +3 -0
- package/dist/tools/workspaceCrashReports.d.ts.map +1 -0
- package/dist/tools/workspaceCrashReports.js +76 -0
- package/dist/tools/workspaceCrashReports.js.map +1 -0
- package/dist/tools/workspaceEditFile.d.ts +3 -0
- package/dist/tools/workspaceEditFile.d.ts.map +1 -0
- package/dist/tools/workspaceEditFile.js +93 -0
- package/dist/tools/workspaceEditFile.js.map +1 -0
- package/dist/tools/workspaceExec.d.ts +3 -0
- package/dist/tools/workspaceExec.d.ts.map +1 -0
- package/dist/tools/workspaceExec.js +65 -0
- package/dist/tools/workspaceExec.js.map +1 -0
- package/dist/tools/workspaceExecStream.d.ts +3 -0
- package/dist/tools/workspaceExecStream.d.ts.map +1 -0
- package/dist/tools/workspaceExecStream.js +110 -0
- package/dist/tools/workspaceExecStream.js.map +1 -0
- package/dist/tools/workspaceGlob.d.ts +3 -0
- package/dist/tools/workspaceGlob.d.ts.map +1 -0
- package/dist/tools/workspaceGlob.js +78 -0
- package/dist/tools/workspaceGlob.js.map +1 -0
- package/dist/tools/workspaceGrep.d.ts +3 -0
- package/dist/tools/workspaceGrep.d.ts.map +1 -0
- package/dist/tools/workspaceGrep.js +184 -0
- package/dist/tools/workspaceGrep.js.map +1 -0
- package/dist/tools/workspaceListFiles.d.ts +3 -0
- package/dist/tools/workspaceListFiles.d.ts.map +1 -0
- package/dist/tools/workspaceListFiles.js +86 -0
- package/dist/tools/workspaceListFiles.js.map +1 -0
- package/dist/tools/workspaceReadFile.d.ts +3 -0
- package/dist/tools/workspaceReadFile.d.ts.map +1 -0
- package/dist/tools/workspaceReadFile.js +94 -0
- package/dist/tools/workspaceReadFile.js.map +1 -0
- package/dist/tools/workspaceSearch.d.ts +3 -0
- package/dist/tools/workspaceSearch.d.ts.map +1 -0
- package/dist/tools/workspaceSearch.js +102 -0
- package/dist/tools/workspaceSearch.js.map +1 -0
- package/dist/tools/workspaceShell.d.ts +3 -0
- package/dist/tools/workspaceShell.d.ts.map +1 -0
- package/dist/tools/workspaceShell.js +64 -0
- package/dist/tools/workspaceShell.js.map +1 -0
- package/dist/tools/workspaceStatus.d.ts +3 -0
- package/dist/tools/workspaceStatus.d.ts.map +1 -0
- package/dist/tools/workspaceStatus.js +105 -0
- package/dist/tools/workspaceStatus.js.map +1 -0
- package/dist/tools/workspaceWriteFile.d.ts +3 -0
- package/dist/tools/workspaceWriteFile.d.ts.map +1 -0
- package/dist/tools/workspaceWriteFile.js +81 -0
- package/dist/tools/workspaceWriteFile.js.map +1 -0
- package/dist/worker/client.d.ts +9 -0
- package/dist/worker/client.d.ts.map +1 -0
- package/dist/worker/client.js +53 -0
- package/dist/worker/client.js.map +1 -0
- package/dist/workspace/cache.d.ts +29 -0
- package/dist/workspace/cache.d.ts.map +1 -0
- package/dist/workspace/cache.js +57 -0
- package/dist/workspace/cache.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Response } from "express";
|
|
2
|
+
export interface ErrorEnvelope {
|
|
3
|
+
error: {
|
|
4
|
+
code: string;
|
|
5
|
+
message: string;
|
|
6
|
+
retryable: boolean;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare function sendError(res: Response, status: number, code: string, message: string, retryable?: boolean): void;
|
|
10
|
+
//# sourceMappingURL=httpError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpError.d.ts","sourceRoot":"","sources":["../../src/lib/httpError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,OAAO,CAAC;KACpB,CAAC;CACH;AAED,wBAAgB,SAAS,CACvB,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,SAAS,UAAQ,GAChB,IAAI,CAQN"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendError = sendError;
|
|
4
|
+
function sendError(res, status, code, message, retryable = false) {
|
|
5
|
+
res.status(status).json({
|
|
6
|
+
error: {
|
|
7
|
+
code,
|
|
8
|
+
message,
|
|
9
|
+
retryable,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=httpError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpError.js","sourceRoot":"","sources":["../../src/lib/httpError.ts"],"names":[],"mappings":";;AAUA,8BAcC;AAdD,SAAgB,SAAS,CACvB,GAAa,EACb,MAAc,EACd,IAAY,EACZ,OAAe,EACf,SAAS,GAAG,KAAK;IAEjB,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;QACtB,KAAK,EAAE;YACL,IAAI;YACJ,OAAO;YACP,SAAS;SACV;KACsB,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class LruTtlCache<K, V> {
|
|
2
|
+
private readonly maxSize;
|
|
3
|
+
private readonly ttlMs;
|
|
4
|
+
private readonly store;
|
|
5
|
+
constructor(maxSize: number, ttlMs: number);
|
|
6
|
+
get(key: K): V | undefined;
|
|
7
|
+
set(key: K, value: V): void;
|
|
8
|
+
delete(key: K): void;
|
|
9
|
+
clear(): void;
|
|
10
|
+
size(): number;
|
|
11
|
+
keys(): IterableIterator<K>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=lruCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lruCache.d.ts","sourceRoot":"","sources":["../../src/lib/lruCache.ts"],"names":[],"mappings":"AAKA,qBAAa,WAAW,CAAC,CAAC,EAAE,CAAC;IAIzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAJxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA+B;gBAGlC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM;IAGhC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAc1B,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAc3B,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI;IAIpB,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,MAAM;IAId,IAAI,IAAI,gBAAgB,CAAC,CAAC,CAAC;CAG5B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LruTtlCache = void 0;
|
|
4
|
+
class LruTtlCache {
|
|
5
|
+
maxSize;
|
|
6
|
+
ttlMs;
|
|
7
|
+
store = new Map();
|
|
8
|
+
constructor(maxSize, ttlMs) {
|
|
9
|
+
this.maxSize = maxSize;
|
|
10
|
+
this.ttlMs = ttlMs;
|
|
11
|
+
}
|
|
12
|
+
get(key) {
|
|
13
|
+
const entry = this.store.get(key);
|
|
14
|
+
if (!entry)
|
|
15
|
+
return undefined;
|
|
16
|
+
if (entry.expiresAt <= Date.now()) {
|
|
17
|
+
this.store.delete(key);
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
// LRU touch
|
|
21
|
+
this.store.delete(key);
|
|
22
|
+
this.store.set(key, entry);
|
|
23
|
+
return entry.value;
|
|
24
|
+
}
|
|
25
|
+
set(key, value) {
|
|
26
|
+
this.store.delete(key);
|
|
27
|
+
this.store.set(key, {
|
|
28
|
+
value,
|
|
29
|
+
expiresAt: Date.now() + this.ttlMs,
|
|
30
|
+
});
|
|
31
|
+
while (this.store.size > this.maxSize) {
|
|
32
|
+
const oldest = this.store.keys().next().value;
|
|
33
|
+
if (!oldest)
|
|
34
|
+
break;
|
|
35
|
+
this.store.delete(oldest);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
delete(key) {
|
|
39
|
+
this.store.delete(key);
|
|
40
|
+
}
|
|
41
|
+
clear() {
|
|
42
|
+
this.store.clear();
|
|
43
|
+
}
|
|
44
|
+
size() {
|
|
45
|
+
return this.store.size;
|
|
46
|
+
}
|
|
47
|
+
keys() {
|
|
48
|
+
return this.store.keys();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.LruTtlCache = LruTtlCache;
|
|
52
|
+
//# sourceMappingURL=lruCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lruCache.js","sourceRoot":"","sources":["../../src/lib/lruCache.ts"],"names":[],"mappings":";;;AAKA,MAAa,WAAW;IAIH;IACA;IAJF,KAAK,GAAG,IAAI,GAAG,EAAoB,CAAC;IAErD,YACmB,OAAe,EACf,KAAa;QADb,YAAO,GAAP,OAAO,CAAQ;QACf,UAAK,GAAL,KAAK,CAAQ;IAC7B,CAAC;IAEJ,GAAG,CAAC,GAAM;QACR,MAAM,KA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,CAAC;IACzB,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;CACF;AAnDD,kCAmDC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RateLimitStore } from "../config";
|
|
2
|
+
export interface RateLimiter {
|
|
3
|
+
check(key: string, maxTokens?: number, refillIntervalMs?: number): Promise<boolean>;
|
|
4
|
+
close(): Promise<void>;
|
|
5
|
+
mode(): RateLimitStore;
|
|
6
|
+
}
|
|
7
|
+
export interface CreateRateLimiterOptions {
|
|
8
|
+
store: RateLimitStore;
|
|
9
|
+
redisUrl?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function createRateLimiter(options: CreateRateLimiterOptions): RateLimiter;
|
|
12
|
+
export declare function checkRateLimit(key: string, maxTokens?: number, refillIntervalMs?: number): boolean;
|
|
13
|
+
export declare function startCleanupInterval(): NodeJS.Timeout;
|
|
14
|
+
//# sourceMappingURL=rateLimit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimit.d.ts","sourceRoot":"","sources":["../../src/lib/rateLimit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAOhD,MAAM,WAAW,WAAW;IAC1B,KAAK,CACH,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,MAAM,EAClB,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,cAAc,CAAC;CACxB;AA8ED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,cAAc,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,WAAW,CAShF;AAgCD,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,SAAS,SAAqB,EAC9B,gBAAgB,SAA6B,GAC5C,OAAO,CAET;AAED,wBAAgB,oBAAoB,IAAI,MAAM,CAAC,OAAO,CASrD"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRateLimiter = createRateLimiter;
|
|
4
|
+
exports.checkRateLimit = checkRateLimit;
|
|
5
|
+
exports.startCleanupInterval = startCleanupInterval;
|
|
6
|
+
const redis_1 = require("redis");
|
|
7
|
+
const DEFAULT_MAX_TOKENS = 60;
|
|
8
|
+
const DEFAULT_REFILL_INTERVAL_MS = 60_000;
|
|
9
|
+
class MemoryRateLimiter {
|
|
10
|
+
buckets = new Map();
|
|
11
|
+
cleanupTimer;
|
|
12
|
+
constructor() {
|
|
13
|
+
this.cleanupTimer = setInterval(() => this.cleanup(), 5 * 60 * 1000);
|
|
14
|
+
this.cleanupTimer.unref();
|
|
15
|
+
}
|
|
16
|
+
async check(key, maxTokens = DEFAULT_MAX_TOKENS, refillIntervalMs = DEFAULT_REFILL_INTERVAL_MS) {
|
|
17
|
+
return checkRateLimitInternal(this.buckets, key, maxTokens, refillIntervalMs);
|
|
18
|
+
}
|
|
19
|
+
async close() {
|
|
20
|
+
if (this.cleanupTimer) {
|
|
21
|
+
clearInterval(this.cleanupTimer);
|
|
22
|
+
this.cleanupTimer = undefined;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
mode() {
|
|
26
|
+
return "memory";
|
|
27
|
+
}
|
|
28
|
+
cleanup() {
|
|
29
|
+
const cutoff = Date.now() - 10 * 60 * 1000;
|
|
30
|
+
for (const [key, bucket] of this.buckets) {
|
|
31
|
+
if (bucket.lastRefill < cutoff) {
|
|
32
|
+
this.buckets.delete(key);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
class RedisRateLimiter {
|
|
38
|
+
client;
|
|
39
|
+
ready;
|
|
40
|
+
constructor(redisUrl) {
|
|
41
|
+
this.client = (0, redis_1.createClient)({ url: redisUrl });
|
|
42
|
+
this.ready = this.client.connect().then(() => undefined);
|
|
43
|
+
}
|
|
44
|
+
async check(key, maxTokens = DEFAULT_MAX_TOKENS, refillIntervalMs = DEFAULT_REFILL_INTERVAL_MS) {
|
|
45
|
+
await this.ready;
|
|
46
|
+
const windowMs = Math.max(refillIntervalMs, 1000);
|
|
47
|
+
const redisKey = `mcp:ratelimit:${key}`;
|
|
48
|
+
const count = await this.client.incr(redisKey);
|
|
49
|
+
if (count === 1) {
|
|
50
|
+
await this.client.pExpire(redisKey, windowMs);
|
|
51
|
+
}
|
|
52
|
+
return count <= maxTokens;
|
|
53
|
+
}
|
|
54
|
+
async close() {
|
|
55
|
+
if (this.client.isOpen) {
|
|
56
|
+
await this.client.quit();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
mode() {
|
|
60
|
+
return "redis";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function createRateLimiter(options) {
|
|
64
|
+
if (options.store === "redis") {
|
|
65
|
+
if (!options.redisUrl) {
|
|
66
|
+
console.warn("[rate-limit] RATE_LIMIT_STORE=redis set but no redis URL was provided; falling back to memory");
|
|
67
|
+
return new MemoryRateLimiter();
|
|
68
|
+
}
|
|
69
|
+
return new RedisRateLimiter(options.redisUrl);
|
|
70
|
+
}
|
|
71
|
+
return new MemoryRateLimiter();
|
|
72
|
+
}
|
|
73
|
+
function checkRateLimitInternal(buckets, key, maxTokens, refillIntervalMs) {
|
|
74
|
+
const now = Date.now();
|
|
75
|
+
let bucket = buckets.get(key);
|
|
76
|
+
if (!bucket) {
|
|
77
|
+
bucket = { tokens: maxTokens - 1, lastRefill: now };
|
|
78
|
+
buckets.set(key, bucket);
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
const elapsed = now - bucket.lastRefill;
|
|
82
|
+
const tokensToAdd = Math.floor((elapsed / refillIntervalMs) * maxTokens);
|
|
83
|
+
if (tokensToAdd > 0) {
|
|
84
|
+
bucket.tokens = Math.min(maxTokens, bucket.tokens + tokensToAdd);
|
|
85
|
+
bucket.lastRefill = now;
|
|
86
|
+
}
|
|
87
|
+
if (bucket.tokens > 0) {
|
|
88
|
+
bucket.tokens -= 1;
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
// Backward-compatible exports for existing tests/usages.
|
|
94
|
+
const legacyBuckets = new Map();
|
|
95
|
+
function checkRateLimit(key, maxTokens = DEFAULT_MAX_TOKENS, refillIntervalMs = DEFAULT_REFILL_INTERVAL_MS) {
|
|
96
|
+
return checkRateLimitInternal(legacyBuckets, key, maxTokens, refillIntervalMs);
|
|
97
|
+
}
|
|
98
|
+
function startCleanupInterval() {
|
|
99
|
+
return setInterval(() => {
|
|
100
|
+
const cutoff = Date.now() - 10 * 60 * 1000;
|
|
101
|
+
for (const [key, bucket] of legacyBuckets) {
|
|
102
|
+
if (bucket.lastRefill < cutoff) {
|
|
103
|
+
legacyBuckets.delete(key);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}, 5 * 60 * 1000);
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=rateLimit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimit.js","sourceRoot":"","sources":["../../src/lib/rateLimit.ts"],"names":[],"mappings":";;AAmGA,8CASC;AAgCD,wCAMC;AAED,oDASC;AA7JD,iCAA2D;AAkB3D,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAE1C,MAAM,iBAAiB;IACJ,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7C,YAAY,CAA6B;IAEjD;QACE,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC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,MAAM,CAAC,UAAU,GAAG,MAAM,EAAE,CAAC;gBAC/B,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;IACH,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SessionRecord } from "./types";
|
|
2
|
+
export declare class SessionStore {
|
|
3
|
+
private readonly ttlMs;
|
|
4
|
+
private readonly maxSessions;
|
|
5
|
+
private readonly sessions;
|
|
6
|
+
constructor(ttlMs: number, maxSessions: number);
|
|
7
|
+
setOwned(sessionId: string, userId: string): SessionRecord;
|
|
8
|
+
get(sessionId: string): SessionRecord | undefined;
|
|
9
|
+
delete(sessionId: string): void;
|
|
10
|
+
size(): number;
|
|
11
|
+
cleanupExpired(): number;
|
|
12
|
+
clear(): void;
|
|
13
|
+
private evictIfNeeded;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=sessionStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionStore.d.ts","sourceRoot":"","sources":["../../src/lib/sessionStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,qBAAa,YAAY;IAIrB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAJ9B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoC;gBAG1C,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM;IAGtC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa;IAuB1D,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAiBjD,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI/B,IAAI,IAAI,MAAM;IAId,cAAc,IAAI,MAAM;IAYxB,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,aAAa;CActB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SessionStore = void 0;
|
|
4
|
+
class SessionStore {
|
|
5
|
+
ttlMs;
|
|
6
|
+
maxSessions;
|
|
7
|
+
sessions = new Map();
|
|
8
|
+
constructor(ttlMs, maxSessions) {
|
|
9
|
+
this.ttlMs = ttlMs;
|
|
10
|
+
this.maxSessions = maxSessions;
|
|
11
|
+
}
|
|
12
|
+
setOwned(sessionId, userId) {
|
|
13
|
+
const now = Date.now();
|
|
14
|
+
const existing = this.sessions.get(sessionId);
|
|
15
|
+
const record = existing
|
|
16
|
+
? {
|
|
17
|
+
...existing,
|
|
18
|
+
userId,
|
|
19
|
+
lastSeenAt: now,
|
|
20
|
+
expiresAt: now + this.ttlMs,
|
|
21
|
+
}
|
|
22
|
+
: {
|
|
23
|
+
sessionId,
|
|
24
|
+
userId,
|
|
25
|
+
createdAt: now,
|
|
26
|
+
lastSeenAt: now,
|
|
27
|
+
expiresAt: now + this.ttlMs,
|
|
28
|
+
};
|
|
29
|
+
this.sessions.set(sessionId, record);
|
|
30
|
+
this.evictIfNeeded();
|
|
31
|
+
return record;
|
|
32
|
+
}
|
|
33
|
+
get(sessionId) {
|
|
34
|
+
const existing = this.sessions.get(sessionId);
|
|
35
|
+
if (!existing)
|
|
36
|
+
return undefined;
|
|
37
|
+
if (existing.expiresAt <= Date.now()) {
|
|
38
|
+
this.sessions.delete(sessionId);
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const updated = {
|
|
42
|
+
...existing,
|
|
43
|
+
lastSeenAt: Date.now(),
|
|
44
|
+
expiresAt: Date.now() + this.ttlMs,
|
|
45
|
+
};
|
|
46
|
+
this.sessions.set(sessionId, updated);
|
|
47
|
+
return updated;
|
|
48
|
+
}
|
|
49
|
+
delete(sessionId) {
|
|
50
|
+
this.sessions.delete(sessionId);
|
|
51
|
+
}
|
|
52
|
+
size() {
|
|
53
|
+
return this.sessions.size;
|
|
54
|
+
}
|
|
55
|
+
cleanupExpired() {
|
|
56
|
+
const now = Date.now();
|
|
57
|
+
let removed = 0;
|
|
58
|
+
for (const [key, value] of this.sessions) {
|
|
59
|
+
if (value.expiresAt <= now) {
|
|
60
|
+
this.sessions.delete(key);
|
|
61
|
+
removed += 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return removed;
|
|
65
|
+
}
|
|
66
|
+
clear() {
|
|
67
|
+
this.sessions.clear();
|
|
68
|
+
}
|
|
69
|
+
evictIfNeeded() {
|
|
70
|
+
while (this.sessions.size > this.maxSessions) {
|
|
71
|
+
let oldestKey;
|
|
72
|
+
let oldestLastSeen = Number.POSITIVE_INFINITY;
|
|
73
|
+
for (const [key, value] of this.sessions) {
|
|
74
|
+
if (value.lastSeenAt < oldestLastSeen) {
|
|
75
|
+
oldestLastSeen = value.lastSeenAt;
|
|
76
|
+
oldestKey = key;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (!oldestKey)
|
|
80
|
+
break;
|
|
81
|
+
this.sessions.delete(oldestKey);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.SessionStore = SessionStore;
|
|
86
|
+
//# sourceMappingURL=sessionStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionStore.js","sourceRoot":"","sources":["../../src/lib/sessionStore.ts"],"names":[],"mappings":";;;AAEA,MAAa,YAAY;IAIJ;IACA;IAJF,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAE7D,YACmB,KAAa,EACb,WAAmB;QADnB,UAAK,GAAL,KAAK,CAAQ;QACb,gBAAW,GAAX,WAAW,CAAQ;IACnC,CAAC;IAEJ,QAAQ,CAAC,SAAiB,EAAE,MAAc;QACxC,MAAM,GAAG,GAAG,IAAI,CAA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ited: number;
|
|
5
|
+
activeSessions: number;
|
|
6
|
+
p50Ms: number;
|
|
7
|
+
p95Ms: number;
|
|
8
|
+
p99Ms: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class HttpTelemetry {
|
|
11
|
+
private requestsTotal;
|
|
12
|
+
private authFailures;
|
|
13
|
+
private rateLimited;
|
|
14
|
+
private latencies;
|
|
15
|
+
private readonly maxSamples;
|
|
16
|
+
recordRequest(durationMs: number): void;
|
|
17
|
+
recordAuthFailure(): void;
|
|
18
|
+
recordRateLimited(): void;
|
|
19
|
+
snapshot(activeSessions: number): TelemetrySnapshot;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/lib/telemetry.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IAEnC,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQvC,iBAAiB,IAAI,IAAI;IAIzB,iBAAiB,IAAI,IAAI;IAIzB,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,iBAAiB;CAqBpD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpTelemetry = void 0;
|
|
4
|
+
class HttpTelemetry {
|
|
5
|
+
requestsTotal = 0;
|
|
6
|
+
authFailures = 0;
|
|
7
|
+
rateLimited = 0;
|
|
8
|
+
latencies = [];
|
|
9
|
+
maxSamples = 2000;
|
|
10
|
+
recordRequest(durationMs) {
|
|
11
|
+
this.requestsTotal += 1;
|
|
12
|
+
this.latencies.push(durationMs);
|
|
13
|
+
if (this.latencies.length > this.maxSamples) {
|
|
14
|
+
this.latencies.shift();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
recordAuthFailure() {
|
|
18
|
+
this.authFailures += 1;
|
|
19
|
+
}
|
|
20
|
+
recordRateLimited() {
|
|
21
|
+
this.rateLimited += 1;
|
|
22
|
+
}
|
|
23
|
+
snapshot(activeSessions) {
|
|
24
|
+
const sorted = [...this.latencies].sort((a, b) => a - b);
|
|
25
|
+
const pick = (percentile) => {
|
|
26
|
+
if (sorted.length === 0)
|
|
27
|
+
return 0;
|
|
28
|
+
const idx = Math.min(sorted.length - 1, Math.floor((percentile / 100) * sorted.length));
|
|
29
|
+
return sorted[idx];
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
requestsTotal: this.requestsTotal,
|
|
33
|
+
authFailures: this.authFailures,
|
|
34
|
+
rateLimited: this.rateLimited,
|
|
35
|
+
activeSessions,
|
|
36
|
+
p50Ms: pick(50),
|
|
37
|
+
p95Ms: pick(95),
|
|
38
|
+
p99Ms: pick(99),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.HttpTelemetry = HttpTelemetry;
|
|
43
|
+
//# sourceMappingURL=telemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/lib/telemetry.ts"],"names":[],"mappings":";;;AAUA,MAAa,aAAa;IAChB,aAAa,GAAG,CAAC,CAAC;IAClB,YAAY,GAAG,CAAC,CAAC;IACjB,WAAW,GAAG,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AC;YACf,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC;SAChB,CAAC;IACJ,CAAC;CACF;AA5CD,sCA4CC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
4
|
+
/**
|
|
5
|
+
* Register a tool with the MCP server, working around TypeScript's
|
|
6
|
+
* "Type instantiation is excessively deep" error that occurs with
|
|
7
|
+
* zod 3.25+ and the MCP SDK's dual v3/v4 type inference.
|
|
8
|
+
*
|
|
9
|
+
* The schema is passed as `any` to bypass deep type inference,
|
|
10
|
+
* while still getting runtime validation from zod.
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerTool(server: McpServer, name: string, description: string, schema: Record<string, any>, handler: (args: any, extra: RequestHandlerExtra<any, any>) => Promise<CallToolResult>): void;
|
|
13
|
+
//# sourceMappingURL=toolHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolHelper.d.ts","sourceRoot":"","sources":["../../src/lib/toolHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAEnF;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EAEnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAE3B,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,mBAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,cAAc,CAAC,GACpF,IAAI,CAGN"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerTool = registerTool;
|
|
4
|
+
/**
|
|
5
|
+
* Register a tool with the MCP server, working around TypeScript's
|
|
6
|
+
* "Type instantiation is excessively deep" error that occurs with
|
|
7
|
+
* zod 3.25+ and the MCP SDK's dual v3/v4 type inference.
|
|
8
|
+
*
|
|
9
|
+
* The schema is passed as `any` to bypass deep type inference,
|
|
10
|
+
* while still getting runtime validation from zod.
|
|
11
|
+
*/
|
|
12
|
+
function registerTool(server, name, description,
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
schema,
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
handler) {
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
server.tool(name, description, schema, handler);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=toolHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolHelper.js","sourceRoot":"","sources":["../../src/lib/toolHelper.ts"],"names":[],"mappings":";;AAYA,oCAWC;AAnBD;;;;;;;GAOG;AACH,SAAgB,YAAY,CAC1B,MAAiB,EACjB,IAAY,EACZ,WAAmB;AACnB,8DAA8D;AAC9D,MAA2B;AAC3B,8DAA8D;AAC9D,OAAqF;IAErF,8DAA8D;IAC7D,MAAM,CAAC,IAAY,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent-breed abstraction layer.
|
|
3
|
+
*
|
|
4
|
+
* Different AI agent runtimes (Claude Code, Codex, generic) have different
|
|
5
|
+
* tool naming conventions and preferred interaction modes. ToolProfiles map
|
|
6
|
+
* canonical tool names to agent-specific aliases and configure defaults.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* const profile = getToolProfile("codex");
|
|
10
|
+
* const toolName = profile.toolAliases["workspace_exec"] ?? "workspace_exec";
|
|
11
|
+
*/
|
|
12
|
+
export interface ToolProfile {
|
|
13
|
+
/** Profile identifier (e.g. "claude-code", "codex", "generic"). */
|
|
14
|
+
name: string;
|
|
15
|
+
/**
|
|
16
|
+
* Maps canonical tool names to agent-specific aliases.
|
|
17
|
+
* If a canonical name is not in the map, use it as-is.
|
|
18
|
+
*
|
|
19
|
+
* Example: { "workspace_apply_patch": "apply_patch" } means Codex
|
|
20
|
+
* agents see the tool as "apply_patch" instead of "workspace_apply_patch".
|
|
21
|
+
*/
|
|
22
|
+
toolAliases: Record<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Preferred shell execution mode for this agent breed.
|
|
25
|
+
*
|
|
26
|
+
* - "stateless": Each command runs in a fresh shell (workspace_exec).
|
|
27
|
+
* Better for agents that issue independent, self-contained commands.
|
|
28
|
+
* - "persistent": Commands run in a persistent session (workspace_shell).
|
|
29
|
+
* Better for agents that rely on cd, env vars, and shell state.
|
|
30
|
+
*/
|
|
31
|
+
defaultShellMode: "stateless" | "persistent";
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get a tool profile by name.
|
|
35
|
+
*
|
|
36
|
+
* @param profileName - Profile identifier. Falls back to "generic" if
|
|
37
|
+
* not recognized or not provided.
|
|
38
|
+
* @returns The matching ToolProfile.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getToolProfile(profileName?: string): ToolProfile;
|
|
41
|
+
/**
|
|
42
|
+
* Resolve a canonical tool name to the agent-specific alias
|
|
43
|
+
* for the given profile.
|
|
44
|
+
*
|
|
45
|
+
* @param profile - The active tool profile.
|
|
46
|
+
* @param canonicalName - The canonical tool name (e.g. "workspace_exec").
|
|
47
|
+
* @returns The alias if one exists, otherwise the canonical name.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveToolName(profile: ToolProfile, canonicalName: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Build a reverse lookup from alias back to canonical name.
|
|
52
|
+
* Useful when receiving tool calls from agents that use aliases.
|
|
53
|
+
*
|
|
54
|
+
* @param profile - The active tool profile.
|
|
55
|
+
* @returns A map from alias to canonical name.
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildReverseLookup(profile: ToolProfile): Record<string, string>;
|
|
58
|
+
/**
|
|
59
|
+
* List all available profile names.
|
|
60
|
+
*/
|
|
61
|
+
export declare function listProfileNames(): string[];
|
|
62
|
+
//# sourceMappingURL=toolProfiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolProfiles.d.ts","sourceRoot":"","sources":["../../src/lib/toolProfiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,MAAM,WAAW,WAAW;IAC1B,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;OAMG;IACH,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEpC;;;;;;;OAOG;IACH,gBAAgB,EAAE,WAAW,GAAG,YAAY,CAAC;CAC9C;AAyDD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,WAAW,CAGhE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,WAAW,EACpB,aAAa,EAAE,MAAM,GACpB,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,WAAW,GACnB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMxB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agent-breed abstraction layer.
|
|
4
|
+
*
|
|
5
|
+
* Different AI agent runtimes (Claude Code, Codex, generic) have different
|
|
6
|
+
* tool naming conventions and preferred interaction modes. ToolProfiles map
|
|
7
|
+
* canonical tool names to agent-specific aliases and configure defaults.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* const profile = getToolProfile("codex");
|
|
11
|
+
* const toolName = profile.toolAliases["workspace_exec"] ?? "workspace_exec";
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.getToolProfile = getToolProfile;
|
|
15
|
+
exports.resolveToolName = resolveToolName;
|
|
16
|
+
exports.buildReverseLookup = buildReverseLookup;
|
|
17
|
+
exports.listProfileNames = listProfileNames;
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Profile Definitions
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
const claudeCodeProfile = {
|
|
22
|
+
name: "claude-code",
|
|
23
|
+
toolAliases: {
|
|
24
|
+
// Claude Code natively uses workspace_* naming — no aliases needed.
|
|
25
|
+
// The persistent shell is the preferred mode for Claude Code agents
|
|
26
|
+
// since they naturally chain commands with cd and env vars.
|
|
27
|
+
},
|
|
28
|
+
defaultShellMode: "persistent",
|
|
29
|
+
};
|
|
30
|
+
const codexProfile = {
|
|
31
|
+
name: "codex",
|
|
32
|
+
toolAliases: {
|
|
33
|
+
// Codex agents are trained on apply_patch as their primary edit tool.
|
|
34
|
+
// Map the V4A adapter to the name Codex models expect.
|
|
35
|
+
"workspace_apply_patch": "apply_patch",
|
|
36
|
+
// Codex prefers shorter tool names without the workspace_ prefix
|
|
37
|
+
"workspace_exec": "shell",
|
|
38
|
+
"workspace_shell": "shell_session",
|
|
39
|
+
"workspace_read_file": "read_file",
|
|
40
|
+
"workspace_write_file": "write_file",
|
|
41
|
+
"workspace_edit_file": "edit_file",
|
|
42
|
+
"workspace_glob": "glob",
|
|
43
|
+
"workspace_grep": "grep",
|
|
44
|
+
"workspace_list_files": "list_files",
|
|
45
|
+
"workspace_search": "search",
|
|
46
|
+
"workspace_batch_read": "batch_read",
|
|
47
|
+
"workspace_batch_write": "batch_write",
|
|
48
|
+
"workspace_crash_reports": "crash_reports",
|
|
49
|
+
},
|
|
50
|
+
defaultShellMode: "stateless",
|
|
51
|
+
};
|
|
52
|
+
const genericProfile = {
|
|
53
|
+
name: "generic",
|
|
54
|
+
toolAliases: {
|
|
55
|
+
// Generic agents use canonical names with no aliases.
|
|
56
|
+
},
|
|
57
|
+
defaultShellMode: "stateless",
|
|
58
|
+
};
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// Registry
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
const profiles = {
|
|
63
|
+
"claude-code": claudeCodeProfile,
|
|
64
|
+
codex: codexProfile,
|
|
65
|
+
generic: genericProfile,
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Get a tool profile by name.
|
|
69
|
+
*
|
|
70
|
+
* @param profileName - Profile identifier. Falls back to "generic" if
|
|
71
|
+
* not recognized or not provided.
|
|
72
|
+
* @returns The matching ToolProfile.
|
|
73
|
+
*/
|
|
74
|
+
function getToolProfile(profileName) {
|
|
75
|
+
if (!profileName)
|
|
76
|
+
return genericProfile;
|
|
77
|
+
return profiles[profileName] ?? genericProfile;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Resolve a canonical tool name to the agent-specific alias
|
|
81
|
+
* for the given profile.
|
|
82
|
+
*
|
|
83
|
+
* @param profile - The active tool profile.
|
|
84
|
+
* @param canonicalName - The canonical tool name (e.g. "workspace_exec").
|
|
85
|
+
* @returns The alias if one exists, otherwise the canonical name.
|
|
86
|
+
*/
|
|
87
|
+
function resolveToolName(profile, canonicalName) {
|
|
88
|
+
return profile.toolAliases[canonicalName] ?? canonicalName;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Build a reverse lookup from alias back to canonical name.
|
|
92
|
+
* Useful when receiving tool calls from agents that use aliases.
|
|
93
|
+
*
|
|
94
|
+
* @param profile - The active tool profile.
|
|
95
|
+
* @returns A map from alias to canonical name.
|
|
96
|
+
*/
|
|
97
|
+
function buildReverseLookup(profile) {
|
|
98
|
+
const reverse = {};
|
|
99
|
+
for (const [canonical, alias] of Object.entries(profile.toolAliases)) {
|
|
100
|
+
reverse[alias] = canonical;
|
|
101
|
+
}
|
|
102
|
+
return reverse;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* List all available profile names.
|
|
106
|
+
*/
|
|
107
|
+
function listProfileNames() {
|
|
108
|
+
return Object.keys(profiles);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=toolProfiles.js.map
|