@sema-agent/core
Version:
Stateless, task-oriented AI agent core
25 lines (24 loc) • 1.76 kB
TypeScript
import type { AgentMessage } from "../internal/harness-types.js";
import type { ToolResultMessage } from "../internal/llm.js";
/** Read the (possibly absent) `role` off an AgentMessage defensively — the union doesn't expose it
* uniformly, so context passes narrow by role with a single cast in one place. */
export declare function messageRole(m: AgentMessage): string | undefined;
/**
* The PROVIDER's own name for the model that answered this assistant message, when it differs from the
* ENGINE-SELECTED id the message is stamped with — the ONE read of `AssistantMessage.responseModel`, so
* the per-turn frame, the result face, the side-query projection and the mismatch notice admit it on the
* same terms rather than on four. The READ twin of `noteResponseModel` (`brain/stream-shared.ts`), which
* states the same law on the write side; this side re-tests rather than trusting, because a HOST's own
* Brain mints these messages too. `undefined` ⇒ the provider named the stamped id, named nothing, or
* named something unreadable — ONE reading, never three. Readable = {@link isProviderEchoShape}, the write
* twin's own predicate.
*/
export declare function providerReportedModel(m: {
readonly model?: unknown;
readonly responseModel?: unknown;
}): string | undefined;
/** True if the message is a tool-result message (shared by the context-edit and context-guard passes).
* A TYPE PREDICATE, not a bare boolean: `role: "toolResult"` belongs to exactly one member of the
* union, so callers that check it can read `.content`/`.toolName` and rebuild the message directly
* instead of asserting the shape back with `as unknown as` (RB-436-g). */
export declare function isToolResult(m: AgentMessage): m is ToolResultMessage;