@sema-agent/core
Version:
Stateless, task-oriented AI agent core
75 lines (74 loc) • 4.94 kB
TypeScript
import { Type } from "typebox";
export declare const TASK_OUTPUT_TOOL_NAME = "TaskOutput";
export declare const TASK_STOP_TOOL_NAME = "TaskStop";
export declare const TASK_OUTPUT_CONTRACT: {
readonly contractId: "core.task_output@1";
readonly implementationRevision: "1";
};
export declare const TASK_STOP_CONTRACT: {
readonly contractId: "core.task_stop@1";
readonly implementationRevision: "1";
};
export declare const TASK_OUTPUT_MISSING_ID_MESSAGE = "Error (TaskOutput): Missing required parameter: task_id";
export declare const TASK_STOP_MISSING_ID_MESSAGE = "Missing required parameter: task_id";
export declare const TASK_STOP_PARAMS: Type.TObject<{
task_id: Type.TOptional<Type.TString>;
shell_id: Type.TOptional<Type.TString>;
}>;
/**
* Trims and skips blank/whitespace-only candidates, returning the first non-blank string among `values`.
* RB-479-A①: callers pass ONLY the tool's declared id parameters (TaskOutput: task_id; TaskStop:
* task_id, shell_id) — an id smuggled under any other key falls to the loud missing-parameter refusal.
* The trim/skip-blank behavior stays (a whitespace-only id reports the same missing-parameter text as an
* absent one, instead of falling through to a not-found lookup on the literal " ").
*/
export declare function resolveTaskIdArg(...values: unknown[]): string | undefined;
/**
* design/157 B17 (S2) — the declaration face is a FUNCTION OF CAPABILITY (fable 终判 D3/D4/D6): what the
* tool advertises to the model must match what the mount can actually do. A flag is true only when the
* deployment really delivers that behavior; every composed sentence below is gated on the flag it
* describes, so no mount ever advertises a file path that is never written, a notification that never
* fires, a wait that never blocks, or name addressing that never resolves.
*/
export interface TaskToolCapabilities {
/** The unified registry face: workflow-task support + own-scope fencing (registry mounts only). */
lanes: boolean;
/** Bash(run_in_background)'s launch receipt carries the output file path (registry mounts only). */
outputFile: boolean;
/** A terminal <task-notification> fires when the task completes — true only when the deployment
* actually wired `taskNotification` (B17 方案查出的既有假广告: the registry mount used to advertise
* this unconditionally; prepare-task now passes the real wiring state). */
notification: boolean;
/** TaskOutput block/timeout wait semantics (registry pollTask; the env-direct poll is instantaneous). */
blockWait: boolean;
/** TaskStop accepts a background agent's spawn NAME as task_id (registry name resolution only). */
nameAddressing: boolean;
}
/** Full-capability profile = the registry-backed mount with notifications wired (CC 209 verbatim form). */
export declare const REGISTRY_TASK_TOOL_CAPS: TaskToolCapabilities;
/** The env-direct thin-shell profile: cursor polling over a background shell, nothing else. */
export declare const ENV_DIRECT_TASK_TOOL_CAPS: TaskToolCapabilities;
/**
* TaskOutput description, composed per capability. With every flag true this reproduces the registry's
* pre-S2 literal byte-for-byte — the first two sentences are the CC 2.1.209 A5 deprecated form
* (209-verbatim except the task-type names, mapped to sema's lanes; divergence-logged; the anchor
* commentary lives at the registry factory). With `notification` false the <task-notification> half is
* honestly omitted and the cursor-polling guidance (the env side's long-standing wording) is composed in
* instead — completion must then be detected by status, and SAYING so is the capability-honest guidance.
*/
export declare function composeTaskOutputDescription(caps: TaskToolCapabilities): string;
/**
* TaskStop description, composed per capability. All-true reproduces the registry literal (CC206-B 欠账:
* the named-agent bullet is CC-verbatim; CC's teammate bullet stays honestly omitted — sema's team face is
* in-process, not registry-addressable); `nameAddressing:false` drops exactly that bullet (the env shell
* has no agent-name resolution), which reproduces the env-direct literal.
*/
export declare function composeTaskStopDescription(caps: TaskToolCapabilities): string;
/**
* TaskOutput params, composed per capability (fable 终判 D3 — an advertised parameter the execute body
* ignores is a lie): block/timeout enter the schema only where the poll can actually wait
* (design/116 W3 — CC TaskOutput block/timeout; sema block default documented as true, CC-parity).
* Canonical surface stays design/115 review S-3: task_id + sema-delta filter — and (RB-479-A①) the
* declared surface is also the RESOLVED surface; no undeclared id key is read.
*/
export declare function composeTaskOutputParams(caps: Pick<TaskToolCapabilities, "blockWait" | "lanes">): ReturnType<typeof Type.Object>;