Class: StateSyncLayer
Defined in: packages/core/src/state-sync/StateSyncLayer.ts:46
Constructors
Constructor
new StateSyncLayer(config): StateSyncLayer;Defined in: packages/core/src/state-sync/StateSyncLayer.ts:76
Construct a StateSyncLayer from user configuration.
Eagerly validates all policies and defaults at construction time. If any policy is invalid, construction fails immediately with a descriptive error.
Parameters
| Parameter | Type | Description |
|---|---|---|
config | StateSyncConfig | State sync configuration (policies + optional defaults) |
Returns
StateSyncLayer
Throws
If any policy or default is invalid
Methods
decorateResult()
decorateResult(toolName, result): ToolResponse;Defined in: packages/core/src/state-sync/StateSyncLayer.ts:110
Decorate a tool call response with causal invalidation signals.
Called after every tools/call execution. If the tool's policy has invalidates patterns and the call succeeded (isError !== true), prepends a [System: Cache invalidated for X — caused by Y] block at content index 0.
Parameters
| Parameter | Type | Description |
|---|---|---|
toolName | string | The name of the tool that was called |
result | ToolResponse | The tool call result from the handler |
Returns
Decorated result (with System block) or unchanged result
decorateTools()
decorateTools(tools): {
_meta?: {
[key: string]: unknown;
};
annotations?: {
destructiveHint?: boolean;
idempotentHint?: boolean;
openWorldHint?: boolean;
readOnlyHint?: boolean;
title?: string;
};
description?: string;
execution?: {
taskSupport?: "optional" | "required" | "forbidden";
};
icons?: {
mimeType?: string;
sizes?: string[];
src: string;
theme?: "light" | "dark";
}[];
inputSchema: {
[key: string]: unknown;
properties?: {
[key: string]: object;
};
required?: string[];
type: "object";
};
name: string;
outputSchema?: {
[key: string]: unknown;
properties?: {
[key: string]: object;
};
required?: string[];
type: "object";
};
title?: string;
}[];Defined in: packages/core/src/state-sync/StateSyncLayer.ts:94
Decorate all tool descriptions with their resolved Cache-Control directives.
Called during tools/list to append [Cache-Control: X] to each tool's description. Tools without a matching policy (and no defaults) are returned unchanged.
Uses per-tool caching to avoid redundant decoration on repeated calls.
Parameters
| Parameter | Type | Description |
|---|---|---|
tools | { _meta?: { [key: string]: unknown; }; annotations?: { destructiveHint?: boolean; idempotentHint?: boolean; openWorldHint?: boolean; readOnlyHint?: boolean; title?: string; }; description?: string; execution?: { taskSupport?: "optional" | "required" | "forbidden"; }; icons?: { mimeType?: string; sizes?: string[]; src: string; theme?: "light" | "dark"; }[]; inputSchema: { [key: string]: unknown; properties?: { [key: string]: object; }; required?: string[]; type: "object"; }; name: string; outputSchema?: { [key: string]: unknown; properties?: { [key: string]: object; }; required?: string[]; type: "object"; }; title?: string; }[] | Original MCP tool definitions from the registry |
Returns
{ _meta?: { [key: string]: unknown; }; annotations?: { destructiveHint?: boolean; idempotentHint?: boolean; openWorldHint?: boolean; readOnlyHint?: boolean; title?: string; }; description?: string; execution?: { taskSupport?: "optional" | "required" | "forbidden"; }; icons?: { mimeType?: string; sizes?: string[]; src: string; theme?: "light" | "dark"; }[]; inputSchema: { [key: string]: unknown; properties?: { [key: string]: object; }; required?: string[]; type: "object"; }; name: string; outputSchema?: { [key: string]: unknown; properties?: { [key: string]: object; }; required?: string[]; type: "object"; }; title?: string; }[]
Decorated tool definitions (cached shallow copies where modified)