UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

43 lines (42 loc) • 2.41 kB
import type { SkillSpec } from "../core/agent-definition.js"; import type { ContentExposure } from "../core/content-exposure.js"; import type { ToolSpec } from "../core/tool-spec.js"; /** The tool's model-facing name. */ export declare const SKILL_PROPOSAL_TOOL_NAME = "ProposeSkill"; /** Where a proposal came from, as the engine states it (never a tool argument). `exposure` is the proposing session's * external-content state as the memory write path reads it ({@link ContentExposure}); read `"unknown"` as `"external"`. */ export interface SkillProposalSource { sessionId: string; taskId?: string; principal?: string; exposure: ContentExposure; } type ProposedSkill = Pick<SkillSpec, "name" | "description" | "content" | "allowedTools" | "disallowedTools">; /** What the seat receives. `skill` has the shape of the {@link SkillSpec} members it names, so a host that approves it can hand it * in as one. `proposalId` is the same for the same skill proposed again under the same session id (a de-duplication key, not a * version). */ export interface SkillProposal { proposalId: string; skill: ProposedSkill; source: SkillProposalSource; } /** The seat's verdict: an accepted / reason verdict of its own (not a goal verdict's members). `reason` and `ref` (the host's own record name) are the host's own * record and go nowhere else; the model is told only whether the proposal was accepted. */ export interface SkillProposalVerdict { accepted: boolean; reason: string; ref?: string; } export interface SkillProposalToolOptions { /** The host's seat. A throw, a rejection or an answer outside {@link SkillProposalVerdict} fails the call (the model is told * that whether the proposal was stored is unknown); the run goes on. */ propose: (proposal: SkillProposal, ctx: { signal: AbortSignal; }) => SkillProposalVerdict | Promise<SkillProposalVerdict>; /** Whether a proposal may carry a non-empty `allowed_tools` (tools its activation would let run without asking). Absent = * `false`: such a proposal is refused before the seat. */ allowToolGrants?: boolean; } /** Build the `ProposeSkill` tool around the host's seat. Throws a `TypeError` on a seat that is not a function or a grant knob that is not a boolean. */ export declare function createSkillProposalTool(opts: SkillProposalToolOptions): ToolSpec; export {};