API Reference
InMemoryPermissionStore
Defined in: permissions/in-memory-permission-store.ts:66
RAM-backed PermissionStore with a fallback policy and seeded rules.
Remarks
Policies live in process memory and are lost on restart. Durable "always" choices made through permissionGate are written back via InMemoryPermissionStore.set.
Example
const store = new InMemoryPermissionStore({
fallback: PermissionPolicy.Ask,
rules: { read_file: PermissionPolicy.Allow },
});
await store.get("read_file", {}); // -> PermissionPolicy.Allow
await store.get("delete_file", {}); // -> PermissionPolicy.Ask (fallback)See
- PermissionStore for the interface contract.
- permissionGate for the hook that consumes this store.
Implements
Constructors
Constructor
new InMemoryPermissionStore(options?): InMemoryPermissionStore;Defined in: permissions/in-memory-permission-store.ts:76
Create a store with the given fallback and seeded rules.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | InMemoryPermissionStoreOptions | Fallback policy and seed rules; see InMemoryPermissionStoreOptions. |
Returns
InMemoryPermissionStore
Methods
get()
get(toolName, _args?): Promise<PermissionPolicy>;Defined in: permissions/in-memory-permission-store.ts:88
Return the policy for a tool, falling back to the configured default.
Parameters
| Parameter | Type | Description |
|---|---|---|
toolName | string | The name of the tool being called. |
_args? | unknown | The call's arguments (unused; accepted for interface parity). |
Returns
Promise<PermissionPolicy>
The seeded rule for toolName, or the fallback policy.
Implementation of
set()
set(toolName, policy): Promise<void>;Defined in: permissions/in-memory-permission-store.ts:98
Persist a durable allow/deny policy for a tool.
Parameters
| Parameter | Type | Description |
|---|---|---|
toolName | string | The name of the tool the decision applies to. |
policy | SettablePolicy | The durable policy to store. |
Returns
Promise<void>