IF Commons GitHub

toolGrant

concept

A tool that an agent has been granted, perhaps with a condition on its calls, never more than the agent's owner may do

Model identityAgent. Written in commons/data/models/identity-agent/mod.ts:99. Identified by agent, tool.

Governance: attributes

approvalcode of toolApprovalrequired

Whether a call needs approval

Becomes the column approval of tool_grant.

Written at commons/data/models/identity-agent/mod.ts:103

expressiontextoptional

A condition on a call, over its arguments

Becomes the column expression of tool_grant.

Written at commons/data/models/identity-agent/mod.ts:102

maxCallsPerRunintegeroptional

How many calls a run may make

Becomes the column max_calls_per_run of tool_grant.

Written at commons/data/models/identity-agent/mod.ts:104

statuscode of useStatusrequired

Whether the grant is applied

Becomes the column status of tool_grant.

Written at commons/data/models/identity-agent/mod.ts:106

validToinstantoptional

When the grant ends

Becomes the column valid_to of tool_grant.

Written at commons/data/models/identity-agent/mod.ts:105

Governance: relationships

agentone

The agent To agent. Written at commons/data/models/identity-agent/mod.ts:127

grantedByone

Who granted it To principal. Written at commons/data/models/identity-agent/mod.ts:99

toolone

The tool To agentTool. Written at commons/data/models/identity-agent/mod.ts:99

Logical: the table

Projects to the table tool_grant with the primary key agent_principal_id, tool_agent_tool_id.

ColumnTypeNullRoleFrom
agent_principal_idtextfalsereferencetoolGrant.agent
approvaltextfalseattributetoolGrant.approval
expressiontexttrueattributetoolGrant.expression
granted_by_principal_idtextfalsereferencetoolGrant.grantedBy
max_calls_per_runintegertrueattributetoolGrant.maxCallsPerRun
statustextfalseattributetoolGrant.status
tool_agent_tool_idtextfalsereferencetoolGrant.tool
valid_totimestamptrueattributetoolGrant.validTo

Physical: SQL

CREATE TABLE IF NOT EXISTS "tool_grant" (
    "agent_principal_id" VARCHAR NOT NULL,
    "tool_agent_tool_id" VARCHAR NOT NULL,
    "expression" VARCHAR,
    "approval" VARCHAR NOT NULL,
    "max_calls_per_run" INTEGER,
    "valid_to" TIMESTAMPTZ,
    "status" VARCHAR NOT NULL,
    "granted_by_principal_id" VARCHAR NOT NULL,
    PRIMARY KEY ("agent_principal_id", "tool_agent_tool_id"),
    CONSTRAINT "tool_grant_agent_principal_id_fk" FOREIGN KEY ("agent_principal_id") REFERENCES "agent" ("principal_id"),
    CONSTRAINT "tool_grant_tool_agent_tool_id_fk" FOREIGN KEY ("tool_agent_tool_id") REFERENCES "agent_tool" ("agent_tool_id"),
    CONSTRAINT "tool_grant_granted_by_principal_id_fk" FOREIGN KEY ("granted_by_principal_id") REFERENCES "principal" ("principal_id"),
    CONSTRAINT "tool_grant_approval_ck" CHECK ("approval" IN ('inherit', 'always')),
    CONSTRAINT "tool_grant_status_ck" CHECK ("status" IN ('active', 'retired'))
);

Physical: the typed table

Read and written from TypeScript with the types the model gives: import { toolGrant } from "@intellectual-frontiers/data/sql/typed/models". Generated in commons/data/sql/typed/models/identity-agent.auto.ts: do not edit.

import { from } from "@intellectual-frontiers/data/sql/typed";
import { toolGrant } from "@intellectual-frontiers/data/sql/typed/models";

const rows = await from(toolGrant).select((s) => ({ agentPrincipalId: s.toolGrant.agentPrincipalId, toolAgentToolId: s.toolGrant.toolAgentToolId })).run(runner);

Titles, headings, exports, tables, columns and requirements. Esc closes.