approvalcode of toolApprovalrequiredWhether a call needs approval
Becomes the column approval of tool_grant.
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.
approvalcode of toolApprovalrequiredWhether a call needs approval
Becomes the column approval of tool_grant.
expressiontextoptionalA condition on a call, over its arguments
Becomes the column expression of tool_grant.
maxCallsPerRunintegeroptionalHow many calls a run may make
Becomes the column max_calls_per_run of tool_grant.
statuscode of useStatusrequiredWhether the grant is applied
Becomes the column status of tool_grant.
validToinstantoptionalWhen the grant ends
Becomes the column valid_to of tool_grant.
agentoneThe agent To agent. Written at commons/data/models/identity-agent/mod.ts:127
grantedByoneWho granted it To principal. Written at commons/data/models/identity-agent/mod.ts:99
tooloneThe tool To agentTool. Written at commons/data/models/identity-agent/mod.ts:99
Projects to the table tool_grant with the primary key agent_principal_id, tool_agent_tool_id.
| Column | Type | Null | Role | From |
|---|---|---|---|---|
agent_principal_id | text | false | reference | toolGrant.agent |
approval | text | false | attribute | toolGrant.approval |
expression | text | true | attribute | toolGrant.expression |
granted_by_principal_id | text | false | reference | toolGrant.grantedBy |
max_calls_per_run | integer | true | attribute | toolGrant.maxCallsPerRun |
status | text | false | attribute | toolGrant.status |
tool_agent_tool_id | text | false | reference | toolGrant.tool |
valid_to | timestamp | true | attribute | toolGrant.validTo |
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'))
);CREATE TABLE IF NOT EXISTS "tool_grant" (
"agent_principal_id" TEXT NOT NULL,
"tool_agent_tool_id" TEXT NOT NULL,
"expression" TEXT,
"approval" TEXT NOT NULL,
"max_calls_per_run" INTEGER,
"valid_to" TIMESTAMPTZ,
"status" TEXT NOT NULL,
"granted_by_principal_id" TEXT 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'))
);CREATE TABLE IF NOT EXISTS "tool_grant" (
"agent_principal_id" TEXT NOT NULL,
"tool_agent_tool_id" TEXT NOT NULL,
"expression" TEXT,
"approval" TEXT NOT NULL,
"max_calls_per_run" INTEGER,
"valid_to" TEXT,
"status" TEXT NOT NULL,
"granted_by_principal_id" TEXT 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'))
);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);