@frontmcp/plugins 0.6.1 → 0.6.3

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 (121) hide show
  1. package/cache/index.js +412 -0
  2. package/codecall/index.js +2988 -0
  3. package/esm/cache/index.mjs +395 -0
  4. package/esm/codecall/index.mjs +2959 -0
  5. package/esm/index.mjs +2951 -0
  6. package/esm/package.json +82 -0
  7. package/index.js +2973 -0
  8. package/package.json +38 -10
  9. package/src/cache/README.md +0 -186
  10. package/src/cache/cache.plugin.js +0 -167
  11. package/src/cache/cache.plugin.js.map +0 -1
  12. package/src/cache/cache.symbol.js +0 -5
  13. package/src/cache/cache.symbol.js.map +0 -1
  14. package/src/cache/cache.types.js +0 -3
  15. package/src/cache/cache.types.js.map +0 -1
  16. package/src/cache/index.js +0 -8
  17. package/src/cache/index.js.map +0 -1
  18. package/src/cache/providers/cache-memory.provider.js +0 -110
  19. package/src/cache/providers/cache-memory.provider.js.map +0 -1
  20. package/src/cache/providers/cache-redis.provider.js +0 -69
  21. package/src/cache/providers/cache-redis.provider.js.map +0 -1
  22. package/src/cache/providers/cache-vercel-kv.provider.js +0 -85
  23. package/src/cache/providers/cache-vercel-kv.provider.js.map +0 -1
  24. package/src/codecall/README.md +0 -999
  25. package/src/codecall/codecall.plugin.js +0 -152
  26. package/src/codecall/codecall.plugin.js.map +0 -1
  27. package/src/codecall/codecall.symbol.js +0 -4
  28. package/src/codecall/codecall.symbol.js.map +0 -1
  29. package/src/codecall/codecall.types.js +0 -262
  30. package/src/codecall/codecall.types.js.map +0 -1
  31. package/src/codecall/errors/index.js +0 -6
  32. package/src/codecall/errors/index.js.map +0 -1
  33. package/src/codecall/errors/tool-call.errors.js +0 -119
  34. package/src/codecall/errors/tool-call.errors.js.map +0 -1
  35. package/src/codecall/index.js +0 -8
  36. package/src/codecall/index.js.map +0 -1
  37. package/src/codecall/providers/code-call.config.js +0 -120
  38. package/src/codecall/providers/code-call.config.js.map +0 -1
  39. package/src/codecall/security/index.js +0 -7
  40. package/src/codecall/security/index.js.map +0 -1
  41. package/src/codecall/security/self-reference-guard.js +0 -70
  42. package/src/codecall/security/self-reference-guard.js.map +0 -1
  43. package/src/codecall/security/tool-access-control.service.js +0 -170
  44. package/src/codecall/security/tool-access-control.service.js.map +0 -1
  45. package/src/codecall/services/audit-logger.service.js +0 -322
  46. package/src/codecall/services/audit-logger.service.js.map +0 -1
  47. package/src/codecall/services/enclave.service.js +0 -214
  48. package/src/codecall/services/enclave.service.js.map +0 -1
  49. package/src/codecall/services/error-enrichment.service.js +0 -387
  50. package/src/codecall/services/error-enrichment.service.js.map +0 -1
  51. package/src/codecall/services/index.js +0 -13
  52. package/src/codecall/services/index.js.map +0 -1
  53. package/src/codecall/services/output-sanitizer.js +0 -260
  54. package/src/codecall/services/output-sanitizer.js.map +0 -1
  55. package/src/codecall/services/synonym-expansion.service.js +0 -374
  56. package/src/codecall/services/synonym-expansion.service.js.map +0 -1
  57. package/src/codecall/services/tool-search.service.js +0 -587
  58. package/src/codecall/services/tool-search.service.js.map +0 -1
  59. package/src/codecall/tools/describe.schema.js +0 -67
  60. package/src/codecall/tools/describe.schema.js.map +0 -1
  61. package/src/codecall/tools/describe.tool.js +0 -207
  62. package/src/codecall/tools/describe.tool.js.map +0 -1
  63. package/src/codecall/tools/execute.schema.js +0 -116
  64. package/src/codecall/tools/execute.schema.js.map +0 -1
  65. package/src/codecall/tools/execute.tool.js +0 -238
  66. package/src/codecall/tools/execute.tool.js.map +0 -1
  67. package/src/codecall/tools/index.js +0 -13
  68. package/src/codecall/tools/index.js.map +0 -1
  69. package/src/codecall/tools/invoke.schema.js +0 -27
  70. package/src/codecall/tools/invoke.schema.js.map +0 -1
  71. package/src/codecall/tools/invoke.tool.js +0 -70
  72. package/src/codecall/tools/invoke.tool.js.map +0 -1
  73. package/src/codecall/tools/search.schema.js +0 -60
  74. package/src/codecall/tools/search.schema.js.map +0 -1
  75. package/src/codecall/tools/search.tool.js +0 -108
  76. package/src/codecall/tools/search.tool.js.map +0 -1
  77. package/src/codecall/utils/describe.utils.js +0 -531
  78. package/src/codecall/utils/describe.utils.js.map +0 -1
  79. package/src/codecall/utils/index.js +0 -7
  80. package/src/codecall/utils/index.js.map +0 -1
  81. package/src/codecall/utils/mcp-result.js +0 -36
  82. package/src/codecall/utils/mcp-result.js.map +0 -1
  83. package/src/index.js +0 -9
  84. package/src/index.js.map +0 -1
  85. /package/{src/cache → cache}/cache.plugin.d.ts +0 -0
  86. /package/{src/cache → cache}/cache.symbol.d.ts +0 -0
  87. /package/{src/cache → cache}/cache.types.d.ts +0 -0
  88. /package/{src/cache → cache}/index.d.ts +0 -0
  89. /package/{src/cache → cache}/providers/cache-memory.provider.d.ts +0 -0
  90. /package/{src/cache → cache}/providers/cache-redis.provider.d.ts +0 -0
  91. /package/{src/cache → cache}/providers/cache-vercel-kv.provider.d.ts +0 -0
  92. /package/{src/codecall → codecall}/codecall.plugin.d.ts +0 -0
  93. /package/{src/codecall → codecall}/codecall.symbol.d.ts +0 -0
  94. /package/{src/codecall → codecall}/codecall.types.d.ts +0 -0
  95. /package/{src/codecall → codecall}/errors/index.d.ts +0 -0
  96. /package/{src/codecall → codecall}/errors/tool-call.errors.d.ts +0 -0
  97. /package/{src/codecall → codecall}/index.d.ts +0 -0
  98. /package/{src/codecall → codecall}/providers/code-call.config.d.ts +0 -0
  99. /package/{src/codecall → codecall}/security/index.d.ts +0 -0
  100. /package/{src/codecall → codecall}/security/self-reference-guard.d.ts +0 -0
  101. /package/{src/codecall → codecall}/security/tool-access-control.service.d.ts +0 -0
  102. /package/{src/codecall → codecall}/services/audit-logger.service.d.ts +0 -0
  103. /package/{src/codecall → codecall}/services/enclave.service.d.ts +0 -0
  104. /package/{src/codecall → codecall}/services/error-enrichment.service.d.ts +0 -0
  105. /package/{src/codecall → codecall}/services/index.d.ts +0 -0
  106. /package/{src/codecall → codecall}/services/output-sanitizer.d.ts +0 -0
  107. /package/{src/codecall → codecall}/services/synonym-expansion.service.d.ts +0 -0
  108. /package/{src/codecall → codecall}/services/tool-search.service.d.ts +0 -0
  109. /package/{src/codecall → codecall}/tools/describe.schema.d.ts +0 -0
  110. /package/{src/codecall → codecall}/tools/describe.tool.d.ts +0 -0
  111. /package/{src/codecall → codecall}/tools/execute.schema.d.ts +0 -0
  112. /package/{src/codecall → codecall}/tools/execute.tool.d.ts +0 -0
  113. /package/{src/codecall → codecall}/tools/index.d.ts +0 -0
  114. /package/{src/codecall → codecall}/tools/invoke.schema.d.ts +0 -0
  115. /package/{src/codecall → codecall}/tools/invoke.tool.d.ts +0 -0
  116. /package/{src/codecall → codecall}/tools/search.schema.d.ts +0 -0
  117. /package/{src/codecall → codecall}/tools/search.tool.d.ts +0 -0
  118. /package/{src/codecall → codecall}/utils/describe.utils.d.ts +0 -0
  119. /package/{src/codecall → codecall}/utils/index.d.ts +0 -0
  120. /package/{src/codecall → codecall}/utils/mcp-result.d.ts +0 -0
  121. /package/{src/index.d.ts → index.d.ts} +0 -0
package/cache/index.js ADDED
@@ -0,0 +1,412 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var __decorateClass = (decorators, target, key, kind) => {
31
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
32
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
33
+ if (decorator = decorators[i])
34
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
35
+ if (kind && result) __defProp(target, key, result);
36
+ return result;
37
+ };
38
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
39
+
40
+ // libs/plugins/src/cache/index.ts
41
+ var cache_exports = {};
42
+ __export(cache_exports, {
43
+ default: () => CachePlugin
44
+ });
45
+ module.exports = __toCommonJS(cache_exports);
46
+
47
+ // libs/plugins/src/cache/cache.plugin.ts
48
+ var import_sdk4 = require("@frontmcp/sdk");
49
+
50
+ // libs/plugins/src/cache/providers/cache-redis.provider.ts
51
+ var import_ioredis = __toESM(require("ioredis"));
52
+ var import_sdk = require("@frontmcp/sdk");
53
+ var CacheRedisProvider = class {
54
+ client;
55
+ constructor(options) {
56
+ if (options.type !== "redis" && options.type !== "redis-client") {
57
+ throw new Error("Invalid cache provider type");
58
+ }
59
+ if (options.type === "redis-client") {
60
+ this.client = options.client;
61
+ return;
62
+ }
63
+ this.client = new import_ioredis.default({
64
+ lazyConnect: false,
65
+ maxRetriesPerRequest: 3,
66
+ ...options.config
67
+ });
68
+ this.client.on("connect", () => console.log("[Redis] Connected"));
69
+ this.client.on("error", (err) => console.error("[Redis] Error:", err));
70
+ }
71
+ /** Set a value (auto-stringifies objects) */
72
+ async setValue(key, value, ttlSeconds) {
73
+ const strValue = typeof value === "string" ? value : JSON.stringify(value);
74
+ if (ttlSeconds && ttlSeconds > 0) {
75
+ await this.client.set(key, strValue, "EX", ttlSeconds);
76
+ } else {
77
+ await this.client.set(key, strValue);
78
+ }
79
+ }
80
+ /** Get a value and automatically parse JSON if possible */
81
+ async getValue(key, defaultValue) {
82
+ const raw = await this.client.get(key);
83
+ if (raw === null) return defaultValue;
84
+ try {
85
+ return JSON.parse(raw);
86
+ } catch {
87
+ return raw;
88
+ }
89
+ }
90
+ /** Delete a key */
91
+ async delete(key) {
92
+ await this.client.del(key);
93
+ }
94
+ /** Check if a key exists */
95
+ async exists(key) {
96
+ return await this.client.exists(key) === 1;
97
+ }
98
+ /** Gracefully close the Redis connection */
99
+ async close() {
100
+ await this.client.quit();
101
+ }
102
+ };
103
+ CacheRedisProvider = __decorateClass([
104
+ (0, import_sdk.Provider)({
105
+ name: "provider:cache:redis",
106
+ description: "Redis-based cache provider",
107
+ scope: import_sdk.ProviderScope.GLOBAL
108
+ })
109
+ ], CacheRedisProvider);
110
+
111
+ // libs/plugins/src/cache/providers/cache-memory.provider.ts
112
+ var import_sdk2 = require("@frontmcp/sdk");
113
+ var MAX_TIMEOUT_MS = 2 ** 31 - 1;
114
+ var CacheMemoryProvider = class {
115
+ memory = /* @__PURE__ */ new Map();
116
+ sweeper;
117
+ constructor(sweepIntervalTTL = 60) {
118
+ this.sweeper = setInterval(() => this.sweep(), sweepIntervalTTL * 1e3);
119
+ this.sweeper.unref?.();
120
+ }
121
+ /** Set a value (auto-stringifies objects) */
122
+ async setValue(key, value, ttlSeconds) {
123
+ const strValue = typeof value === "string" ? value : JSON.stringify(value);
124
+ const existing = this.memory.get(key);
125
+ if (existing?.timeout) clearTimeout(existing.timeout);
126
+ const entry = { value: strValue };
127
+ if (ttlSeconds && ttlSeconds > 0) {
128
+ const ttlMs = ttlSeconds * 1e3;
129
+ entry.expiresAt = Date.now() + ttlMs;
130
+ if (ttlMs <= MAX_TIMEOUT_MS) {
131
+ entry.timeout = setTimeout(() => {
132
+ const e = this.memory.get(key);
133
+ if (e && e.expiresAt && e.expiresAt <= Date.now()) {
134
+ this.memory.delete(key);
135
+ }
136
+ }, ttlMs);
137
+ entry.timeout.unref?.();
138
+ }
139
+ }
140
+ this.memory.set(key, entry);
141
+ }
142
+ /** Get a value and automatically parse JSON if possible */
143
+ async getValue(key, defaultValue) {
144
+ const entry = this.memory.get(key);
145
+ if (!entry) return defaultValue;
146
+ if (this.isExpired(entry)) {
147
+ await this.delete(key);
148
+ return defaultValue;
149
+ }
150
+ const raw = entry.value;
151
+ try {
152
+ return JSON.parse(raw);
153
+ } catch {
154
+ return raw;
155
+ }
156
+ }
157
+ /** Delete a key */
158
+ async delete(key) {
159
+ const entry = this.memory.get(key);
160
+ if (entry?.timeout) clearTimeout(entry.timeout);
161
+ this.memory.delete(key);
162
+ }
163
+ /** Check if a key exists (and not expired) */
164
+ async exists(key) {
165
+ const entry = this.memory.get(key);
166
+ if (!entry) return false;
167
+ if (this.isExpired(entry)) {
168
+ await this.delete(key);
169
+ return false;
170
+ }
171
+ return true;
172
+ }
173
+ /** Gracefully close the provider */
174
+ async close() {
175
+ if (this.sweeper) clearInterval(this.sweeper);
176
+ for (const [, entry] of this.memory) {
177
+ if (entry.timeout) clearTimeout(entry.timeout);
178
+ }
179
+ this.memory.clear();
180
+ }
181
+ // ---- internals ----
182
+ isExpired(entry) {
183
+ return entry.expiresAt !== void 0 && entry.expiresAt <= Date.now();
184
+ }
185
+ /** Periodically remove expired keys to keep memory tidy */
186
+ sweep() {
187
+ const now = Date.now();
188
+ for (const [key, entry] of this.memory) {
189
+ if (entry.expiresAt !== void 0 && entry.expiresAt <= now) {
190
+ if (entry.timeout) clearTimeout(entry.timeout);
191
+ this.memory.delete(key);
192
+ }
193
+ }
194
+ }
195
+ };
196
+ CacheMemoryProvider = __decorateClass([
197
+ (0, import_sdk2.Provider)({
198
+ name: "provider:cache:memory",
199
+ description: "Memory-based cache provider",
200
+ scope: import_sdk2.ProviderScope.GLOBAL
201
+ })
202
+ ], CacheMemoryProvider);
203
+
204
+ // libs/plugins/src/cache/providers/cache-vercel-kv.provider.ts
205
+ var import_sdk3 = require("@frontmcp/sdk");
206
+ var CacheVercelKvProvider = class {
207
+ kv;
208
+ keyPrefix;
209
+ defaultTTL;
210
+ constructor(options = {}) {
211
+ const vercelKv = require("@vercel/kv");
212
+ const hasUrl = options.url !== void 0;
213
+ const hasToken = options.token !== void 0;
214
+ if (hasUrl !== hasToken) {
215
+ throw new Error(
216
+ `CacheVercelKvProvider: Both 'url' and 'token' must be provided together, or neither. Received: url=${hasUrl ? "provided" : "missing"}, token=${hasToken ? "provided" : "missing"}`
217
+ );
218
+ }
219
+ if (options.url && options.token) {
220
+ this.kv = vercelKv.createClient({
221
+ url: options.url,
222
+ token: options.token
223
+ });
224
+ } else {
225
+ this.kv = vercelKv.kv;
226
+ }
227
+ this.keyPrefix = options.keyPrefix ?? "cache:";
228
+ this.defaultTTL = options.defaultTTL ?? 60 * 60 * 24;
229
+ }
230
+ prefixKey(key) {
231
+ return `${this.keyPrefix}${key}`;
232
+ }
233
+ /** Set a value (auto-stringifies objects) */
234
+ async setValue(key, value, ttlSeconds) {
235
+ const strValue = typeof value === "string" ? value : JSON.stringify(value);
236
+ const ttl = ttlSeconds ?? this.defaultTTL;
237
+ if (ttl > 0) {
238
+ await this.kv.set(this.prefixKey(key), strValue, { ex: ttl });
239
+ } else {
240
+ await this.kv.set(this.prefixKey(key), strValue);
241
+ }
242
+ }
243
+ /** Get a value and automatically parse JSON if possible */
244
+ async getValue(key, defaultValue) {
245
+ const raw = await this.kv.get(this.prefixKey(key));
246
+ if (raw === null || raw === void 0) return defaultValue;
247
+ if (typeof raw === "string") {
248
+ try {
249
+ return JSON.parse(raw);
250
+ } catch {
251
+ return raw;
252
+ }
253
+ }
254
+ return raw;
255
+ }
256
+ /** Delete a key */
257
+ async delete(key) {
258
+ await this.kv.del(this.prefixKey(key));
259
+ }
260
+ /** Check if a key exists */
261
+ async exists(key) {
262
+ return await this.kv.exists(this.prefixKey(key)) === 1;
263
+ }
264
+ /** Gracefully close the provider (no-op for Vercel KV - stateless REST API) */
265
+ async close() {
266
+ }
267
+ };
268
+ CacheVercelKvProvider = __decorateClass([
269
+ (0, import_sdk3.Provider)({
270
+ name: "provider:cache:vercel-kv",
271
+ description: "Vercel KV-based cache provider",
272
+ scope: import_sdk3.ProviderScope.GLOBAL
273
+ })
274
+ ], CacheVercelKvProvider);
275
+
276
+ // libs/plugins/src/cache/cache.symbol.ts
277
+ var CacheStoreToken = /* @__PURE__ */ Symbol("plugin:cache:store");
278
+
279
+ // libs/plugins/src/cache/cache.plugin.ts
280
+ var CachePlugin = class extends import_sdk4.DynamicPlugin {
281
+ options;
282
+ constructor(options = CachePlugin.defaultOptions) {
283
+ super();
284
+ this.options = {
285
+ defaultTTL: 60 * 60 * 24,
286
+ ...options
287
+ };
288
+ }
289
+ async willReadCache(flowCtx) {
290
+ const { tool, toolContext } = flowCtx.state;
291
+ if (!tool || !toolContext) return;
292
+ const { cache } = toolContext.metadata;
293
+ if (!cache || typeof toolContext.input === "undefined") {
294
+ return;
295
+ }
296
+ const cacheStore = this.get(CacheStoreToken);
297
+ const hash = hashObject({ tool: tool.fullName, input: toolContext.input });
298
+ const cached = await cacheStore.getValue(hash);
299
+ if (cached !== void 0 && cached !== null) {
300
+ if (cache === true || cache.ttl && cache.slideWindow) {
301
+ const ttl = cache === true ? this.options.defaultTTL : cache.ttl ?? this.options.defaultTTL;
302
+ await cacheStore.setValue(hash, cached, ttl);
303
+ }
304
+ if (!tool.safeParseOutput(cached).success) {
305
+ await cacheStore.delete(hash);
306
+ return;
307
+ }
308
+ flowCtx.state.rawOutput = cached;
309
+ toolContext.respond(cached);
310
+ }
311
+ }
312
+ async willWriteCache(flowCtx) {
313
+ const { tool, toolContext } = flowCtx.state;
314
+ if (!tool || !toolContext) return;
315
+ const { cache } = toolContext.metadata;
316
+ if (!cache || typeof toolContext.input === "undefined") {
317
+ return;
318
+ }
319
+ const cacheStore = this.get(CacheStoreToken);
320
+ const ttl = cache === true ? this.options.defaultTTL : cache.ttl ?? this.options.defaultTTL;
321
+ const hash = hashObject({ tool: tool.fullName, input: toolContext.input });
322
+ await cacheStore.setValue(hash, toolContext.output, ttl);
323
+ }
324
+ };
325
+ __publicField(CachePlugin, "dynamicProviders", (options) => {
326
+ const providers = [];
327
+ switch (options.type) {
328
+ case "global-store":
329
+ providers.push({
330
+ name: "cache:global-store",
331
+ provide: CacheStoreToken,
332
+ inject: () => [import_sdk4.FrontMcpConfig],
333
+ useFactory: (config) => {
334
+ const storeConfig = (0, import_sdk4.getGlobalStoreConfig)("CachePlugin", config);
335
+ const globalOptions = options;
336
+ if ((0, import_sdk4.isVercelKvProvider)(storeConfig)) {
337
+ return new CacheVercelKvProvider({
338
+ url: storeConfig.url,
339
+ token: storeConfig.token,
340
+ keyPrefix: storeConfig.keyPrefix,
341
+ defaultTTL: globalOptions.defaultTTL
342
+ });
343
+ }
344
+ return new CacheRedisProvider({
345
+ type: "redis",
346
+ config: {
347
+ host: storeConfig.host ?? "localhost",
348
+ port: storeConfig.port ?? 6379,
349
+ password: storeConfig.password,
350
+ db: storeConfig.db
351
+ },
352
+ defaultTTL: globalOptions.defaultTTL
353
+ });
354
+ }
355
+ });
356
+ break;
357
+ case "redis":
358
+ case "redis-client":
359
+ providers.push({
360
+ name: "cache:redis",
361
+ provide: CacheStoreToken,
362
+ useValue: new CacheRedisProvider(options)
363
+ });
364
+ break;
365
+ case "memory":
366
+ providers.push({
367
+ name: "cache:memory",
368
+ provide: CacheStoreToken,
369
+ useValue: new CacheMemoryProvider(options.defaultTTL)
370
+ });
371
+ break;
372
+ }
373
+ return providers;
374
+ });
375
+ __publicField(CachePlugin, "defaultOptions", {
376
+ type: "memory"
377
+ });
378
+ __decorateClass([
379
+ import_sdk4.ToolHook.Will("execute", { priority: 1e3 })
380
+ ], CachePlugin.prototype, "willReadCache", 1);
381
+ __decorateClass([
382
+ import_sdk4.ToolHook.Did("execute", { priority: 1e3 })
383
+ ], CachePlugin.prototype, "willWriteCache", 1);
384
+ CachePlugin = __decorateClass([
385
+ (0, import_sdk4.Plugin)({
386
+ name: "cache",
387
+ description: "Cache plugin for caching tool results",
388
+ providers: [
389
+ /* add providers that always loaded with the plugin or default providers */
390
+ {
391
+ // this is a default provider for cache, will be overridden if dynamicProviders based on config
392
+ name: "cache:memory",
393
+ provide: CacheStoreToken,
394
+ useValue: new CacheMemoryProvider(60 * 60 * 24)
395
+ }
396
+ ]
397
+ })
398
+ ], CachePlugin);
399
+ function hashObject(obj) {
400
+ const keys = Object.keys(obj).sort();
401
+ return keys.reduce((acc, key) => {
402
+ acc += key + ":";
403
+ const val = obj[key];
404
+ if (typeof val === "object" && val !== null) {
405
+ acc += hashObject(val);
406
+ } else {
407
+ acc += String(val);
408
+ }
409
+ acc += ";";
410
+ return acc;
411
+ }, "");
412
+ }