UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

66 lines (65 loc) • 4.49 kB
/** * The run's station for the session call grant (`session-call-grant.ts`): it mints the card's option and, when a person takes it, * writes the one session row and announces what happened. Only the synchronous ask station calls it — the run that asks is the * run that writes, under the same predicate as a session-long read grant (`PersonPathRows.sessionRowOwner`: the run reads its * session rules back and the owner's store already holds its writer; a grant never takes the writer for itself). * * The row is written straight to the session partition through the store's one writer (the scope routes it there): the consent it * stands on is the person's answer to the card itself, which the resolver attested (a person, an allow, no edit, the card's own * option); `redemption.recordId` names that card (`card:<toolCallId>`), and the notice carries the same call id. */ import { type RunnerDeps } from "../types.js"; import type { RuleOwner } from "../rule-owner.js"; import { type PermissionRuleStoreProvider } from "../permission-rule-provider.js"; import type { ToolCallRequest } from "../tool-policy.js"; import type { createRuleOffersOf } from "./permission-rule-lanes.js"; import { type CallBindingSeat, type CallGrantBinding } from "../session-call-grant.js"; import type { SessionCallGrantOffer, SessionCallGrantScreen } from "../session-call-grant-screen.js"; import type { CallShellOf } from "../call-shell.js"; /** * The door of the option, read off the SAME ladder as the card's rule offers ({@link createRuleOffersOf}): the option exists exactly * where a standing rule could clear this shell card's question — the offer factory either offers a rule or names `lane_cannot_speak` * (every other word is a door that keeps every rule off the card, a mandated question first) — and the call is no sandbox escape and * no inside peer's question (each cleared only by a grant of its own kind). One ladder, so the two options cannot disagree about * which questions a standing yes may retire. */ export declare function createCallGrantDoorOf(offersOf: ReturnType<typeof createRuleOffersOf>): (call: Pick<ToolCallRequest, "toolName" | "face">, args: unknown, ask: Parameters<typeof offersOf>[2]) => boolean; type SettleAt = { toolName: string; toolCallId: string; checkpointId: string; sessionId: string; runId: string; taskId: string; onNotice: RunnerDeps["onNotice"]; signal?: AbortSignal; }; /** * A station that offers no option (an inherited ask's, or a run that keeps no session partition) settles the member the same * way, so a key sent to it is told as at the synchronous station: whatever the resolver read is announced as rejected — * `no_offer` for a key the resolver could not match to an option (this card had none). */ export declare function settleUnofferedSessionCallGrant(screen: SessionCallGrantScreen | undefined, at: SettleAt): undefined; /** What the station holds between minting an option and reading the answer: the binding the option was minted from. */ export interface MintedCallGrant { readonly offer: SessionCallGrantOffer; readonly binding: CallGrantBinding; } export interface SessionCallGrantStation { /** The option for this card, or `undefined` (the run keeps no session rules now, or the call is not bindable). Bounded like the * gate's other awaits; a reading that fails or runs past the bound offers nothing. */ mint(command: unknown, call: CallShellOf, signal: AbortSignal | undefined): Promise<MintedCallGrant | undefined>; /** Act on the resolver's screen of the answer: write the row for `granted`, announce every outcome. */ /** `checkpointId`: the card's own id (`AskRequest.checkpointId`), which both notices carry so a surface joins them to the card. */ settle(screen: SessionCallGrantScreen | undefined, minted: MintedCallGrant | undefined, at: SettleAt): Promise<void> | undefined; } export declare function sessionCallGrantStation(cfg: { provider: PermissionRuleStoreProvider; sessionId: string; /** The run's one predicate: the owner a session row is written as, now — else absent (no option, nothing written). */ sessionRowOwner: () => RuleOwner | undefined; /** The environment, the shell the call runs on (its face's), live working directory and workspace roots one reading takes, read per call. */ seat: (call: CallShellOf) => CallBindingSeat; now?: () => number; }): SessionCallGrantStation; export {};