@sema-agent/core
Version:
Stateless, task-oriented AI agent core
39 lines (38 loc) • 2.47 kB
TypeScript
/**
* The request-body sugar: the one place the task's role-layer prompt inputs are read and turned into overlays of
* the `task` source class. Two inputs, one reading each:
*
* - the role base — the first of two sources that names one decides it ({@link roleBaseOf}): the task (its door-judged
* `promptRole` and its `systemPrompt`), then the requested model role's preset. The deciding source's word is the run's
* host role; its text, when it names one, is a `replace` of `core/role.base`, applied after the selector chose the
* variant. Neither naming one leaves the selector's answer (a delegated child's is the sub-agent persona variant);
* - the appended block — `TaskSpec.appendSystemPrompt`, or a saved team's leg's (`teamAppend`) — an `add` to the `task-append` band (entry `core/role.append`);
*
* and nothing else reads them for assembly (`gate:sugar-single-site`). The sugar is applied first within its class,
* the task-seat mods after it. Its one possible violation is locked text: a role-layer input carrying, verbatim, a
* guarded run of a message a locked band places (any shipped rendering, cut at its slots; `lockedTextIn`) is an
* already-assembled prompt or a mechanism frame's words, and the task is refused by name
* (`prompt.assembled_role_refused`) — never passed through, never silently dropped.
*/
import type { HostRole } from "./catalog/schema.js";
import { type SourcedOverlay } from "./overlay.js";
import { type RoleBaseDeclaration } from "./role-base.js";
/** The task's role-layer prompt inputs, as prepare holds them. */
export interface SugarInputs {
readonly spec: {
readonly systemPrompt?: string;
readonly appendSystemPrompt?: string;
};
/** The task seat's role word as its door judged it (`TaskSpec.promptRole`, `resolveHost`). */
readonly taskRole?: HostRole;
readonly resolvedRole: RoleBaseDeclaration;
/** A saved team's leg: its appended block as its prepare read the team (the duties, then the team's own prompt) — the spec of such a
* leg states no `appendSystemPrompt` (team-run.ts). */
readonly teamAppend?: string;
}
/** The task class's first overlays (role base, then the appended block) and the run's host role, from ONE decision. */
export interface RequestBodySugar {
readonly overlays: readonly SourcedOverlay[];
readonly hostRole?: HostRole;
}
export declare function requestBodySugar(inputs: SugarInputs): RequestBodySugar;