UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

44 lines (43 loc) • 3.25 kB
/** * The person's account of the permission rules a leg's tool policy left out because it could not read them * (`config.entries_not_applied`, kind `rule_text_unreadable`; before 7.70.0 the code `permission.settings_rules_skipped`; audience user). * * `createPermissionRulePolicy` leaves out a rule a person's settings layer wrote (`user`, `project`) whose text it cannot read, instead of * refusing the whole request; the policy carries them (`ToolPolicy.skippedRules`). The leg goes on without them, which is only honest * when the person who wrote them is told — a deny or ask rule among them is not in force. Every leg tells the rules of the policies it * holds as its own (`TaskSpec.toolPolicy` / `RunnerDeps.toolPolicy`, and the resume-edit seat) that no ancestor of its delegation chain * holds — an ancestor told its own at its prepare, so a child holding the same rules says nothing. A delegated leg's notice goes where * every user-face notice of the leg goes (its tree's root session, naming the leg: `LegNotice`). Once per session per set of rules * (`AnnounceOnceLedger.oncePerSession`): a later run of the same conversation over the same rules says nothing, a changed set is told * again. The notice rides the person's notice stream only; nothing of it enters the model's context. */ import { type EngineNotice } from "../engine-notice.js"; import type { LegNotice } from "../leg-identity.js"; import { type SkippedPermissionRule } from "../permission-rules.js"; import type { RunnerDeps } from "../runner-deps.js"; import type { ToolPolicy } from "../tool-policy.js"; import { type AnnounceOnceLedger } from "./announce-once-ledger.js"; /** How many rules the sentence and the detail name; `detail.count` counts every one. */ export declare const SKIPPED_RULES_SHOWN = 8; /** * The notice for the rules a leg's policy left out. `detail: { kind: "rule_text_unreadable", entries: [{ entry, reason, behavior, layer }], * count, identity, …address, runId }` — `entries` the first unique ones (`entry` the rule through `noticeRuleText`, the reading every * rule-naming notice uses; `reason` the compiler's issue code), `count` all of them and `identity` their whole set, the leg's notice * address (`sessionId`; on a delegated leg the tree's root with `sourceSessionId` / `agentId` naming the leg). `undefined` when there is none. */ export declare function skippedRulesNotice(rules: readonly SkippedPermissionRule[], ids: { readonly address: LegNotice["route"]["address"]; readonly runId: string; }): EngineNotice | undefined; /** Prepare's phase, on every leg: tell the person the rules the leg's own policies left out that no ancestor of its chain holds, once * per session per set. `own` = the policies the leg holds as its own; `chain` = its delegation chain's entries (the ancestors'). */ export declare function announceSkippedPermissionRules(input: { readonly own: ReadonlyArray<ToolPolicy | undefined>; readonly chain: ReadonlyArray<{ readonly policy?: ToolPolicy; }> | undefined; readonly onNotice: RunnerDeps["onNotice"]; readonly legNotice: LegNotice; readonly onceLedger: Pick<AnnounceOnceLedger, "oncePerSession">; readonly runId: string; }): void;