@frontmcp/plugin-cache 1.7.2 → 1.8.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/cache.plugin.d.ts +21 -2
- package/cache.plugin.d.ts.map +1 -1
- package/cache.types.d.ts +14 -0
- package/cache.types.d.ts.map +1 -1
- package/esm/index.mjs +3744 -79
- package/esm/package.json +3 -2
- package/index.js +3727 -82
- package/package.json +3 -2
package/cache.plugin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DynamicPlugin, FlowCtxOf, ProviderType } from '@frontmcp/sdk';
|
|
2
|
-
import { CachePluginOptions } from './cache.types';
|
|
1
|
+
import { DynamicPlugin, type FlowCtxOf, type ProviderType } from '@frontmcp/sdk';
|
|
2
|
+
import { type CachePluginOptions } from './cache.types';
|
|
3
3
|
export default class CachePlugin extends DynamicPlugin<CachePluginOptions> {
|
|
4
4
|
static dynamicProviders: (options: CachePluginOptions) => ProviderType[];
|
|
5
5
|
static defaultOptions: CachePluginOptions;
|
|
@@ -20,6 +20,25 @@ export default class CachePlugin extends DynamicPlugin<CachePluginOptions> {
|
|
|
20
20
|
private getTtl;
|
|
21
21
|
willReadCache(flowCtx: FlowCtxOf<'tools:call-tool'>): Promise<void>;
|
|
22
22
|
willWriteCache(flowCtx: FlowCtxOf<'tools:call-tool'>): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* The identity a cache entry belongs to (GHSA-r6v6-p4r8-p936).
|
|
25
|
+
*
|
|
26
|
+
* Most caches sit in front of tools whose output depends on who is asking. Without this the
|
|
27
|
+
* key was the tool plus its arguments, so the first caller's response was served to every
|
|
28
|
+
* later one: `getProfile({})` is the same key for everybody.
|
|
29
|
+
*
|
|
30
|
+
* The session is the last resort rather than the first choice, because an authenticated
|
|
31
|
+
* caller can hold several sessions and should share their own cached entries across them.
|
|
32
|
+
*/
|
|
33
|
+
private resolveCallerIdentity;
|
|
34
|
+
/**
|
|
35
|
+
* Build the storage key for a tool call.
|
|
36
|
+
*
|
|
37
|
+
* Read and write both go through here. They used to build the key at two separate call
|
|
38
|
+
* sites, and a key that differs between them silently disables the cache rather than
|
|
39
|
+
* failing visibly.
|
|
40
|
+
*/
|
|
41
|
+
private buildCacheKey;
|
|
23
42
|
/**
|
|
24
43
|
* Check if a tool is cacheable based on metadata or tools list.
|
|
25
44
|
* This can be used by other plugins or flows to determine cacheability.
|
package/cache.plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.plugin.d.ts","sourceRoot":"","sources":["../src/cache.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"cache.plugin.d.ts","sourceRoot":"","sources":["../src/cache.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAQb,KAAK,SAAS,EAEd,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,KAAK,kBAAkB,EAAsC,MAAM,eAAe,CAAC;AA2C5F,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,aAAa,CAAC,kBAAkB,CAAC;IACxE,OAAgB,gBAAgB,GAAI,SAAS,kBAAkB,oBAqD7D;IAEF,MAAM,CAAC,cAAc,EAAE,kBAAkB,CAEvC;IACF,OAAO,EAAE,kBAAkB,CAAC;gBAEhB,OAAO,GAAE,kBAA+C;IAQpE;;OAEG;IACH,OAAO,CAAC,eAAe;IAYvB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAsBzB;;OAEG;IACH,OAAO,CAAC,MAAM;IAQR,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,iBAAiB,CAAC;IA0EnD,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAyB1D;;;;;;;;;OASG;IACH,OAAO,CAAC,qBAAqB;IAsB7B;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAQrB;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;CAGvC"}
|
package/cache.types.d.ts
CHANGED
|
@@ -52,6 +52,20 @@ export interface BaseCachePluginOptions {
|
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
54
|
bypassHeader?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Include the caller's identity in the cache key.
|
|
57
|
+
*
|
|
58
|
+
* On by default (GHSA-r6v6-p4r8-p936). Most cached tools return something that depends on
|
|
59
|
+
* who is asking, and a key built only from the tool and its arguments serves the first
|
|
60
|
+
* caller's response to everyone else.
|
|
61
|
+
*
|
|
62
|
+
* Set this to `false` ONLY for a cache whose entries are identical for every caller --
|
|
63
|
+
* public reference data, a currency table, a static document. Anything derived from the
|
|
64
|
+
* caller's own permissions, tenant or account must leave it on.
|
|
65
|
+
*
|
|
66
|
+
* @default true
|
|
67
|
+
*/
|
|
68
|
+
keyByIdentity?: boolean;
|
|
55
69
|
}
|
|
56
70
|
export interface RedisClientCachePluginOptions extends BaseCachePluginOptions {
|
|
57
71
|
type: 'redis-client';
|
package/cache.types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.types.d.ts","sourceRoot":"","sources":["../src/cache.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AAE/C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,0BAA0B;QAClC,KAAK,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC;KACvC;CACF;AAED,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB;;;;;;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