Skip to content

@pgege/kaboo-runtime


Class: PostgresGrantStore

Defined in: src/stores/postgres-grants.ts:62

Durable GrantStore backed by Postgres, in its own kaboo_tool_grants table (created on first use, independent of any application schema). pg is an optional peer dependency — install it in the host app to use this store.

Example

import { Pool } from "pg";
import { createKabooRunner, PostgresGrantStore, PostgresThreadStore } from "@pgege/kaboo-runtime";

const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const runner = createKabooRunner(new PostgresThreadStore({ pool }), {
  accessPolicy: { ownerOf: (threadId) => threadId.split(":")[0] ?? null },
  approvals: { grants: new PostgresGrantStore({ pool }) },
});

Implements

Constructors

Constructor

new PostgresGrantStore(options): PostgresGrantStore

Defined in: src/stores/postgres-grants.ts:67

Parameters

options

PostgresGrantStoreOptions

Returns

PostgresGrantStore

Methods

list()

list(query): Promise\<ToolGrant[]>

Defined in: src/stores/postgres-grants.ts:110

The grants a run may use: the owner's "always" grants and the thread's own.

Parameters

query

GrantQuery

Returns

Promise\<ToolGrant[]>

Implementation of

GrantStore.list


listForOwner()

listForOwner(ownerId): Promise\<ToolGrant[]>

Defined in: src/stores/postgres-grants.ts:147

Every grant the owner holds, for a settings page.

Parameters

ownerId

string

Returns

Promise\<ToolGrant[]>

Implementation of

GrantStore.listForOwner


revoke()

revoke(ownerId, id): Promise\<void>

Defined in: src/stores/postgres-grants.ts:142

Revoke one of the owner's grants. A grant owned by someone else is left alone.

Parameters

ownerId

string

id

string

Returns

Promise\<void>

Implementation of

GrantStore.revoke


save()

save(grant): Promise\<ToolGrant>

Defined in: src/stores/postgres-grants.ts:120

Save a grant, replacing an identical one (same owner, agent, thread, tool, subject).

Parameters

grant

NewToolGrant

Returns

Promise\<ToolGrant>

Implementation of

GrantStore.save