UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

82 lines (81 loc) • 6.59 kB
/** * CC config key `workflowSizeGuideline`: an ADVISORY size guideline for LLM-authored workflows * (small/medium/large/unrestricted), injected into the Workflow tool's prompt/description. It is * guidance, NOT a cap — the hard ceiling stays `WorkflowLimits.maxAgents`. * * RB-339 (2026-07-30, A 案) — REBASELINED on CC 2.1.220 (语料 ../cc-decoded/pretty220.js). The * module was anchored to 2.1.206 and had drifted on four points; all four are corrected here and the * old "verbatim" claims (which were not true of the two sentence builders) are replaced with what * each function actually is: * 1. DEFAULT. CC's `_Td = "medium"` (:455529) with `Oft` (:455538) returning `{ size: "medium", * isDefault: true }` whenever the setting is absent or not a member of the enum. sema defaulted * to "unrestricted" (= inject nothing), so an unconfigured deployment got NO guideline at all. * Behavior narrowing, declared: an unconfigured task now carries the medium section. * 2. TWO-ARM SECTION. CC's `TTd(size, isDefault)` (:455514) has a DEFAULT arm ("This session has the * default …" + the "/config" escape sentence) and an EXPLICIT arm ("A workflow size guideline is * configured for this session:" with no escape sentence). sema had a single hand-written form. * 3. CHANGE NOTICE. CC's `ETd` (:455523) — both arms differed from sema's wording. * 4. Normalization. CC's `Msn` (:455494) is a MEMBERSHIP test returning `undefined` for a non-member * (which then falls to the medium default); sema mapped every unknown value to "unrestricted", * i.e. a typo in the setting silently disabled the guideline. Now `undefined`, per CC. * * Still-current 220 anchors: `rLs` enum (:455532) / `oko` caps (:455533) / `bTd` describe (:455507) / * `STd` not-a-hard-limit sentence (:455511) / `Sj_` display label (:455497). Those five ARE verbatim. * * Injection site: CC appends the section to BOTH `prompt()` and `description()` of the Workflow tool * (`oLs`, :455548 — returns "" for "unrestricted", else "\n\n" + the sentence). Snapshot semantics: * CC memoizes the SESSION-START value (`Nsn`) so the card is stable within a session; a mid-session * /config change reaches the model via a `workflow_size_guideline_change` attachment (`vTd`, :455555) * rendered with `ETd`. sema equivalence: the card is built once per mount (`createRunWorkflowTool`) = * per-task snapshot — same stability property. * * Mid-session change lane (SHIPPED — the module no longer ships static injection only): CC's `vTd` * (:455555) recomputes the RESOLVED guideline each turn, recovers the last announced one (its own * previous attachment, falling back to the session-start snapshot) and emits a * `workflow_size_guideline_change` attachment rendered with `ETd` on inequality. sema's equivalent * lives at the run loop's turn-boundary steerer (`runtask.ts`, alongside the structurally identical * date_change / instructions_change lanes): the leg's resolved guideline is the baseline, the live * `RunnerDeps.workflowLimits` read is the current value, and {@link workflowSizeGuidelineChangeNotice} * is the copy. Comparison is on the RESOLVED coordinate on both sides, CC-exact — `vTd` compares * `Oft(...).size` against `Nsn(...).size`, so a deployment writing down the value already in force by * default is not a change. Two lane properties are sema's own and deliberate: the frame is * continuation-gated (an advisory retune must never revive a finished run), and only the * `WorkflowLimits` channel is watched — the direct-construction `RunWorkflowToolDeps.sizeGuideline` is * a per-mount pin the runner never sets. */ /** CC `rLs` member type — the config value space. */ export type WorkflowSizeGuideline = "small" | "medium" | "large" | "unrestricted"; /** CC `rLs` (:455532) — the enum options, in CC's settings-face order. */ export declare const WORKFLOW_SIZE_GUIDELINES: readonly WorkflowSizeGuideline[]; /** CC `_Td` (:455529) — the guideline in force when the deployment configured none. */ export declare const WORKFLOW_SIZE_GUIDELINE_DEFAULT: WorkflowSizeGuideline; /** CC `oko` (:455533) — the advisory agent count each tier aims under. */ export declare const WORKFLOW_SIZE_GUIDELINE_AGENT_CAPS: Readonly<Record<"small" | "medium" | "large", number>>; /** CC `Msn` (:455494) — a MEMBERSHIP test: the value when it is one of the four options, otherwise * `undefined` (an unknown/absent value is "unconfigured", NOT "unrestricted" — see * {@link resolveWorkflowSizeGuideline}, which is where the default is applied). */ export declare function normalizeWorkflowSizeGuideline(value: unknown): WorkflowSizeGuideline | undefined; /** CC `Oft` (:455538) — resolve the guideline in force plus whether it came from the default. * `isDefault` drives the two arms of {@link workflowSizeGuidelineSection}. */ export declare function resolveWorkflowSizeGuideline(value: unknown): { size: WorkflowSizeGuideline; isDefault: boolean; }; /** CC `ubd`/`yTd` — the tier's advisory agent count (undefined for "unrestricted"). CC feeds this into * its workflow-size warning thresholds; exported for the same future lane + deployments. */ export declare function workflowSizeGuidelineAgentCap(g: WorkflowSizeGuideline): number | undefined; /** CC `bTd` (:455507) — the tier description embedded in the injected sentences. Verbatim. */ export declare function describeWorkflowSizeGuideline(g: WorkflowSizeGuideline): string; /** CC `Sj_` (:455497) — the settings-face display label ("Dynamic workflow size" enum row). Verbatim. * Exported for a shell's settings 透传 (the shell only surfaces the key; the engine hosts it). */ export declare function formatWorkflowSizeGuidelineLabel(g: WorkflowSizeGuideline): string; /** * CC `oLs` (:455548) — the section appended to the Workflow tool's prompt AND description, including * the leading blank line. An EXPLICIT "unrestricted" injects nothing; an absent/unknown value resolves * to the medium DEFAULT and injects the default arm (RB-339 — this is the behavior narrowing). */ export declare function workflowSizeGuidelineSection(value: unknown): string; /** CC `ETd` (:455523) — the mid-session change notice. Verbatim. Emitted by the run loop's * `workflow_size_guideline_change` turn-boundary lane (see the module header); this is that frame's * ONLY copy — the lane renders through here rather than restating the sentences. */ export declare function workflowSizeGuidelineChangeNotice(g: WorkflowSizeGuideline): string;