multiclaws 0.4.41 → 0.4.43

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 (39) hide show
  1. package/README.md +2 -0
  2. package/dist/gateway/handlers.d.ts +4 -4
  3. package/dist/gateway/handlers.js +239 -239
  4. package/dist/index.d.ts +8 -8
  5. package/dist/index.js +710 -710
  6. package/dist/infra/frp.d.ts +55 -55
  7. package/dist/infra/frp.js +398 -398
  8. package/dist/infra/gateway-client.d.ts +27 -27
  9. package/dist/infra/gateway-client.js +136 -136
  10. package/dist/infra/json-store.d.ts +4 -4
  11. package/dist/infra/json-store.js +57 -57
  12. package/dist/infra/logger.d.ts +14 -14
  13. package/dist/infra/logger.js +25 -25
  14. package/dist/infra/rate-limiter.d.ts +19 -19
  15. package/dist/infra/rate-limiter.js +69 -69
  16. package/dist/infra/tailscale.d.ts +19 -19
  17. package/dist/infra/tailscale.js +120 -120
  18. package/dist/infra/telemetry.d.ts +3 -3
  19. package/dist/infra/telemetry.js +17 -17
  20. package/dist/infra/version.d.ts +1 -1
  21. package/dist/infra/version.js +19 -19
  22. package/dist/service/a2a-adapter.d.ts +80 -80
  23. package/dist/service/a2a-adapter.js +505 -505
  24. package/dist/service/agent-profile.d.ts +17 -17
  25. package/dist/service/agent-profile.js +58 -58
  26. package/dist/service/agent-registry.d.ts +29 -29
  27. package/dist/service/agent-registry.js +131 -131
  28. package/dist/service/multiclaws-service.d.ts +150 -150
  29. package/dist/service/multiclaws-service.js +1137 -1137
  30. package/dist/service/session-store.d.ts +46 -46
  31. package/dist/service/session-store.js +143 -143
  32. package/dist/task/tracker.d.ts +46 -46
  33. package/dist/task/tracker.js +191 -191
  34. package/dist/team/team-store.d.ts +42 -42
  35. package/dist/team/team-store.js +195 -195
  36. package/dist/types/openclaw.d.ts +109 -109
  37. package/dist/types/openclaw.js +2 -2
  38. package/package.json +1 -1
  39. package/skills/meeting-scheduler/SKILL.md +112 -105
@@ -1,27 +1,27 @@
1
- export type GatewayConfig = {
2
- port: number;
3
- token: string;
4
- };
5
- export type InvokeToolResult = {
6
- ok: boolean;
7
- result?: unknown;
8
- error?: {
9
- type?: string;
10
- message?: string;
11
- };
12
- };
13
- /**
14
- * Call the local OpenClaw gateway's /tools/invoke endpoint.
15
- * Requires the tool to be allowed by gateway policy.
16
- *
17
- * Timeout is enforced via AbortController on the fetch call.
18
- * Circuit breaker tracks error rates per tool to fail fast on persistent failures.
19
- * p-retry handles transient errors with up to 2 retries.
20
- */
21
- export declare function invokeGatewayTool(params: {
22
- gateway: GatewayConfig;
23
- tool: string;
24
- args?: Record<string, unknown>;
25
- sessionKey?: string;
26
- timeoutMs?: number;
27
- }): Promise<unknown>;
1
+ export type GatewayConfig = {
2
+ port: number;
3
+ token: string;
4
+ };
5
+ export type InvokeToolResult = {
6
+ ok: boolean;
7
+ result?: unknown;
8
+ error?: {
9
+ type?: string;
10
+ message?: string;
11
+ };
12
+ };
13
+ /**
14
+ * Call the local OpenClaw gateway's /tools/invoke endpoint.
15
+ * Requires the tool to be allowed by gateway policy.
16
+ *
17
+ * Timeout is enforced via AbortController on the fetch call.
18
+ * Circuit breaker tracks error rates per tool to fail fast on persistent failures.
19
+ * p-retry handles transient errors with up to 2 retries.
20
+ */
21
+ export declare function invokeGatewayTool(params: {
22
+ gateway: GatewayConfig;
23
+ tool: string;
24
+ args?: Record<string, unknown>;
25
+ sessionKey?: string;
26
+ timeoutMs?: number;
27
+ }): Promise<unknown>;
@@ -1,136 +1,136 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.invokeGatewayTool = invokeGatewayTool;
40
- const opossum_1 = __importDefault(require("opossum"));
41
- class NonRetryableError extends Error {
42
- }
43
- const breakerCache = new Map();
44
- let pRetryModulePromise = null;
45
- async function loadPRetry() {
46
- if (!pRetryModulePromise) {
47
- pRetryModulePromise = Promise.resolve().then(() => __importStar(require("p-retry")));
48
- }
49
- return await pRetryModulePromise;
50
- }
51
- function getBreaker(key, timeoutMs) {
52
- const existing = breakerCache.get(key);
53
- if (existing) {
54
- return existing;
55
- }
56
- const breaker = new opossum_1.default((operation) => operation(), {
57
- timeout: false, // timeout handled by AbortController in the operation
58
- errorThresholdPercentage: 50,
59
- resetTimeout: 10_000,
60
- volumeThreshold: 5,
61
- });
62
- breakerCache.set(key, breaker);
63
- return breaker;
64
- }
65
- async function executeResilient(params) {
66
- const pRetryModule = await loadPRetry();
67
- const pRetry = pRetryModule.default;
68
- const AbortError = pRetryModule.AbortError;
69
- const breaker = getBreaker(params.key, params.timeoutMs);
70
- return (await pRetry(async () => {
71
- try {
72
- return (await breaker.fire(params.operation));
73
- }
74
- catch (error) {
75
- if (error instanceof NonRetryableError && AbortError) {
76
- throw new AbortError(error.message);
77
- }
78
- throw error;
79
- }
80
- }, {
81
- retries: 2,
82
- factor: 2,
83
- minTimeout: 150,
84
- maxTimeout: 1200,
85
- randomize: true,
86
- }));
87
- }
88
- /**
89
- * Call the local OpenClaw gateway's /tools/invoke endpoint.
90
- * Requires the tool to be allowed by gateway policy.
91
- *
92
- * Timeout is enforced via AbortController on the fetch call.
93
- * Circuit breaker tracks error rates per tool to fail fast on persistent failures.
94
- * p-retry handles transient errors with up to 2 retries.
95
- */
96
- async function invokeGatewayTool(params) {
97
- const url = `http://localhost:${params.gateway.port}/tools/invoke`;
98
- const timeoutMs = params.timeoutMs ?? 8_000;
99
- const key = `${params.gateway.port}:${params.tool}`;
100
- return await executeResilient({
101
- key,
102
- timeoutMs,
103
- operation: async () => {
104
- const controller = new AbortController();
105
- const timer = setTimeout(() => controller.abort(), timeoutMs);
106
- try {
107
- const response = await fetch(url, {
108
- method: "POST",
109
- headers: {
110
- "Content-Type": "application/json",
111
- Authorization: `Bearer ${params.gateway.token}`,
112
- },
113
- body: JSON.stringify({
114
- tool: params.tool,
115
- action: "json",
116
- args: params.args ?? {},
117
- sessionKey: params.sessionKey ?? "main",
118
- }),
119
- signal: controller.signal,
120
- });
121
- const json = (await response.json());
122
- if (!response.ok || !json.ok) {
123
- const msg = json.error?.message ?? `HTTP ${response.status}`;
124
- if (response.status >= 400 && response.status < 500 && response.status !== 429) {
125
- throw new NonRetryableError(`invokeGatewayTool(${params.tool}) failed: ${msg}`);
126
- }
127
- throw new Error(`invokeGatewayTool(${params.tool}) failed: ${msg}`);
128
- }
129
- return json.result;
130
- }
131
- finally {
132
- clearTimeout(timer);
133
- }
134
- },
135
- });
136
- }
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.invokeGatewayTool = invokeGatewayTool;
40
+ const opossum_1 = __importDefault(require("opossum"));
41
+ class NonRetryableError extends Error {
42
+ }
43
+ const breakerCache = new Map();
44
+ let pRetryModulePromise = null;
45
+ async function loadPRetry() {
46
+ if (!pRetryModulePromise) {
47
+ pRetryModulePromise = Promise.resolve().then(() => __importStar(require("p-retry")));
48
+ }
49
+ return await pRetryModulePromise;
50
+ }
51
+ function getBreaker(key, timeoutMs) {
52
+ const existing = breakerCache.get(key);
53
+ if (existing) {
54
+ return existing;
55
+ }
56
+ const breaker = new opossum_1.default((operation) => operation(), {
57
+ timeout: false, // timeout handled by AbortController in the operation
58
+ errorThresholdPercentage: 50,
59
+ resetTimeout: 10_000,
60
+ volumeThreshold: 5,
61
+ });
62
+ breakerCache.set(key, breaker);
63
+ return breaker;
64
+ }
65
+ async function executeResilient(params) {
66
+ const pRetryModule = await loadPRetry();
67
+ const pRetry = pRetryModule.default;
68
+ const AbortError = pRetryModule.AbortError;
69
+ const breaker = getBreaker(params.key, params.timeoutMs);
70
+ return (await pRetry(async () => {
71
+ try {
72
+ return (await breaker.fire(params.operation));
73
+ }
74
+ catch (error) {
75
+ if (error instanceof NonRetryableError && AbortError) {
76
+ throw new AbortError(error.message);
77
+ }
78
+ throw error;
79
+ }
80
+ }, {
81
+ retries: 2,
82
+ factor: 2,
83
+ minTimeout: 150,
84
+ maxTimeout: 1200,
85
+ randomize: true,
86
+ }));
87
+ }
88
+ /**
89
+ * Call the local OpenClaw gateway's /tools/invoke endpoint.
90
+ * Requires the tool to be allowed by gateway policy.
91
+ *
92
+ * Timeout is enforced via AbortController on the fetch call.
93
+ * Circuit breaker tracks error rates per tool to fail fast on persistent failures.
94
+ * p-retry handles transient errors with up to 2 retries.
95
+ */
96
+ async function invokeGatewayTool(params) {
97
+ const url = `http://localhost:${params.gateway.port}/tools/invoke`;
98
+ const timeoutMs = params.timeoutMs ?? 8_000;
99
+ const key = `${params.gateway.port}:${params.tool}`;
100
+ return await executeResilient({
101
+ key,
102
+ timeoutMs,
103
+ operation: async () => {
104
+ const controller = new AbortController();
105
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
106
+ try {
107
+ const response = await fetch(url, {
108
+ method: "POST",
109
+ headers: {
110
+ "Content-Type": "application/json",
111
+ Authorization: `Bearer ${params.gateway.token}`,
112
+ },
113
+ body: JSON.stringify({
114
+ tool: params.tool,
115
+ action: "json",
116
+ args: params.args ?? {},
117
+ sessionKey: params.sessionKey ?? "main",
118
+ }),
119
+ signal: controller.signal,
120
+ });
121
+ const json = (await response.json());
122
+ if (!response.ok || !json.ok) {
123
+ const msg = json.error?.message ?? `HTTP ${response.status}`;
124
+ if (response.status >= 400 && response.status < 500 && response.status !== 429) {
125
+ throw new NonRetryableError(`invokeGatewayTool(${params.tool}) failed: ${msg}`);
126
+ }
127
+ throw new Error(`invokeGatewayTool(${params.tool}) failed: ${msg}`);
128
+ }
129
+ return json.result;
130
+ }
131
+ finally {
132
+ clearTimeout(timer);
133
+ }
134
+ },
135
+ });
136
+ }
@@ -1,4 +1,4 @@
1
- export declare function ensureJsonFile(filePath: string, fallback: unknown): Promise<void>;
2
- export declare function readJsonWithFallback<T>(filePath: string, fallback: T): Promise<T>;
3
- export declare function writeJsonAtomically(filePath: string, value: unknown): Promise<void>;
4
- export declare function withJsonLock<T>(filePath: string, fallback: unknown, fn: () => Promise<T>): Promise<T>;
1
+ export declare function ensureJsonFile(filePath: string, fallback: unknown): Promise<void>;
2
+ export declare function readJsonWithFallback<T>(filePath: string, fallback: T): Promise<T>;
3
+ export declare function writeJsonAtomically(filePath: string, value: unknown): Promise<void>;
4
+ export declare function withJsonLock<T>(filePath: string, fallback: unknown, fn: () => Promise<T>): Promise<T>;
@@ -1,57 +1,57 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ensureJsonFile = ensureJsonFile;
7
- exports.readJsonWithFallback = readJsonWithFallback;
8
- exports.writeJsonAtomically = writeJsonAtomically;
9
- exports.withJsonLock = withJsonLock;
10
- const promises_1 = __importDefault(require("node:fs/promises"));
11
- const node_crypto_1 = __importDefault(require("node:crypto"));
12
- const node_path_1 = __importDefault(require("node:path"));
13
- const proper_lockfile_1 = __importDefault(require("proper-lockfile"));
14
- const LOCK_OPTIONS = {
15
- retries: {
16
- retries: 10,
17
- factor: 1.5,
18
- minTimeout: 50,
19
- maxTimeout: 1_000,
20
- randomize: true,
21
- },
22
- stale: 10_000,
23
- };
24
- async function ensureJsonFile(filePath, fallback) {
25
- await promises_1.default.mkdir(node_path_1.default.dirname(filePath), { recursive: true });
26
- try {
27
- await promises_1.default.access(filePath);
28
- }
29
- catch {
30
- await writeJsonAtomically(filePath, fallback);
31
- }
32
- }
33
- async function readJsonWithFallback(filePath, fallback) {
34
- try {
35
- const content = await promises_1.default.readFile(filePath, "utf8");
36
- return JSON.parse(content);
37
- }
38
- catch {
39
- return fallback;
40
- }
41
- }
42
- async function writeJsonAtomically(filePath, value) {
43
- await promises_1.default.mkdir(node_path_1.default.dirname(filePath), { recursive: true });
44
- const tmp = `${filePath}.${process.pid}.${Date.now()}.${node_crypto_1.default.randomUUID()}.tmp`;
45
- await promises_1.default.writeFile(tmp, JSON.stringify(value, null, 2), "utf8");
46
- await promises_1.default.rename(tmp, filePath);
47
- }
48
- async function withJsonLock(filePath, fallback, fn) {
49
- await ensureJsonFile(filePath, fallback);
50
- const release = await proper_lockfile_1.default.lock(filePath, LOCK_OPTIONS);
51
- try {
52
- return await fn();
53
- }
54
- finally {
55
- await release();
56
- }
57
- }
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ensureJsonFile = ensureJsonFile;
7
+ exports.readJsonWithFallback = readJsonWithFallback;
8
+ exports.writeJsonAtomically = writeJsonAtomically;
9
+ exports.withJsonLock = withJsonLock;
10
+ const promises_1 = __importDefault(require("node:fs/promises"));
11
+ const node_crypto_1 = __importDefault(require("node:crypto"));
12
+ const node_path_1 = __importDefault(require("node:path"));
13
+ const proper_lockfile_1 = __importDefault(require("proper-lockfile"));
14
+ const LOCK_OPTIONS = {
15
+ retries: {
16
+ retries: 10,
17
+ factor: 1.5,
18
+ minTimeout: 50,
19
+ maxTimeout: 1_000,
20
+ randomize: true,
21
+ },
22
+ stale: 10_000,
23
+ };
24
+ async function ensureJsonFile(filePath, fallback) {
25
+ await promises_1.default.mkdir(node_path_1.default.dirname(filePath), { recursive: true });
26
+ try {
27
+ await promises_1.default.access(filePath);
28
+ }
29
+ catch {
30
+ await writeJsonAtomically(filePath, fallback);
31
+ }
32
+ }
33
+ async function readJsonWithFallback(filePath, fallback) {
34
+ try {
35
+ const content = await promises_1.default.readFile(filePath, "utf8");
36
+ return JSON.parse(content);
37
+ }
38
+ catch {
39
+ return fallback;
40
+ }
41
+ }
42
+ async function writeJsonAtomically(filePath, value) {
43
+ await promises_1.default.mkdir(node_path_1.default.dirname(filePath), { recursive: true });
44
+ const tmp = `${filePath}.${process.pid}.${Date.now()}.${node_crypto_1.default.randomUUID()}.tmp`;
45
+ await promises_1.default.writeFile(tmp, JSON.stringify(value, null, 2), "utf8");
46
+ await promises_1.default.rename(tmp, filePath);
47
+ }
48
+ async function withJsonLock(filePath, fallback, fn) {
49
+ await ensureJsonFile(filePath, fallback);
50
+ const release = await proper_lockfile_1.default.lock(filePath, LOCK_OPTIONS);
51
+ try {
52
+ return await fn();
53
+ }
54
+ finally {
55
+ await release();
56
+ }
57
+ }
@@ -1,14 +1,14 @@
1
- export type BasicLogger = {
2
- info: (message: string) => void;
3
- warn: (message: string) => void;
4
- error: (message: string) => void;
5
- debug?: (message: string) => void;
6
- };
7
- export declare const noopLogger: BasicLogger;
8
- /**
9
- * Creates a structured logger that delegates to OpenClaw's base logger.
10
- * Only outputs via baseLogger to avoid duplicate stdout writes.
11
- */
12
- export declare function createStructuredLogger(baseLogger: BasicLogger, _name?: string): {
13
- logger: BasicLogger;
14
- };
1
+ export type BasicLogger = {
2
+ info: (message: string) => void;
3
+ warn: (message: string) => void;
4
+ error: (message: string) => void;
5
+ debug?: (message: string) => void;
6
+ };
7
+ export declare const noopLogger: BasicLogger;
8
+ /**
9
+ * Creates a structured logger that delegates to OpenClaw's base logger.
10
+ * Only outputs via baseLogger to avoid duplicate stdout writes.
11
+ */
12
+ export declare function createStructuredLogger(baseLogger: BasicLogger, _name?: string): {
13
+ logger: BasicLogger;
14
+ };
@@ -1,25 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noopLogger = void 0;
4
- exports.createStructuredLogger = createStructuredLogger;
5
- exports.noopLogger = {
6
- info: () => { },
7
- warn: () => { },
8
- error: () => { },
9
- debug: () => { },
10
- };
11
- /**
12
- * Creates a structured logger that delegates to OpenClaw's base logger.
13
- * Only outputs via baseLogger to avoid duplicate stdout writes.
14
- */
15
- function createStructuredLogger(baseLogger, _name = "multiclaws") {
16
- const bridge = {
17
- info: (message) => baseLogger.info(message),
18
- warn: (message) => baseLogger.warn(message),
19
- error: (message) => baseLogger.error(message),
20
- debug: (message) => baseLogger.debug?.(message),
21
- };
22
- return {
23
- logger: bridge,
24
- };
25
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.noopLogger = void 0;
4
+ exports.createStructuredLogger = createStructuredLogger;
5
+ exports.noopLogger = {
6
+ info: () => { },
7
+ warn: () => { },
8
+ error: () => { },
9
+ debug: () => { },
10
+ };
11
+ /**
12
+ * Creates a structured logger that delegates to OpenClaw's base logger.
13
+ * Only outputs via baseLogger to avoid duplicate stdout writes.
14
+ */
15
+ function createStructuredLogger(baseLogger, _name = "multiclaws") {
16
+ const bridge = {
17
+ info: (message) => baseLogger.info(message),
18
+ warn: (message) => baseLogger.warn(message),
19
+ error: (message) => baseLogger.error(message),
20
+ debug: (message) => baseLogger.debug?.(message),
21
+ };
22
+ return {
23
+ logger: bridge,
24
+ };
25
+ }
@@ -1,19 +1,19 @@
1
- /**
2
- * Simple sliding-window rate limiter keyed by peer ID.
3
- * Returns true if the request should be allowed, false if rate-limited.
4
- * Periodically prunes empty/stale keys to prevent unbounded memory growth.
5
- */
6
- export declare class RateLimiter {
7
- private readonly windowMs;
8
- private readonly maxRequests;
9
- private readonly windows;
10
- private pruneTimer;
11
- constructor(opts?: {
12
- windowMs?: number;
13
- maxRequests?: number;
14
- });
15
- allow(key: string): boolean;
16
- reset(key: string): void;
17
- destroy(): void;
18
- private pruneStaleKeys;
19
- }
1
+ /**
2
+ * Simple sliding-window rate limiter keyed by peer ID.
3
+ * Returns true if the request should be allowed, false if rate-limited.
4
+ * Periodically prunes empty/stale keys to prevent unbounded memory growth.
5
+ */
6
+ export declare class RateLimiter {
7
+ private readonly windowMs;
8
+ private readonly maxRequests;
9
+ private readonly windows;
10
+ private pruneTimer;
11
+ constructor(opts?: {
12
+ windowMs?: number;
13
+ maxRequests?: number;
14
+ });
15
+ allow(key: string): boolean;
16
+ reset(key: string): void;
17
+ destroy(): void;
18
+ private pruneStaleKeys;
19
+ }