Skip to content
RELKIT
Esc
↑↓navigate↵open⌘Jpreview
On this page

Agents API

Generated public TypeScript reference for @relkit/agents.

Common APIs

For configuration and examples, read approvals, agents, organization.

For a complete workflow, follow build an offline agent.

Frontend usage

Observe an agent and send controls shows the client side of this capability.

Public imports

  • @relkit/agents — 182 exports
  • @relkit/agents/client-events — 5 exports

All exported APIs

Names link to their complete contracts. Re-exports share their original contract; legacy exports keep their separate identity. Examples link to the API’s inline sample, a maintained repository usage, or the shared module walkthrough.

API Kind Import from Example
AcceptControlRequest Type @relkit/agents Module example
AcceptRunReceipt Type @relkit/agents Module example
AcceptRunRequest Type @relkit/agents Module example
AdmitContinuationRequest Type @relkit/agents Module example
AGENT_OBSERVABILITY_PROTOCOL Value @relkit/agents Module example
AGENT_OBSERVABILITY_VERSION Value @relkit/agents Module example
AgentApprovalHandler Type @relkit/agents Module example
AgentCapturePolicy Type @relkit/agents API example
AgentCapturePolicyError Value @relkit/agents Module example
AgentCaptureRecord Type @relkit/agents API example
AgentChatMapping Type @relkit/agents API example
AgentClientEvent Type @relkit/agents, @relkit/agents/client-events Source example
agentClientEvents Value @relkit/agents, @relkit/agents/client-events API example
AgentClientEvents Type @relkit/agents API example
agentClientEventsEffect Value @relkit/agents, @relkit/agents/client-events API example
AgentClientPolicy Type @relkit/agents API example
AgentClientPolicyError Value @relkit/agents Module example
AgentContentSink Type @relkit/agents Module example
AgentControl Type @relkit/agents API example
AgentConversationMessage Type @relkit/agents Module example
AgentDescriptor Type @relkit/agents Module example
AgentEdgeRelationship Type @relkit/agents API example
AgentExecutionEvent Type @relkit/agents Source example
AgentExecutionSnapshot Type @relkit/agents Module example
AgentInstructions Type @relkit/agents Module example
AgentLimits Type @relkit/agents Module example
AgentObservabilitySink Type @relkit/agents API example
AgentObservation Type @relkit/agents Source example
AgentObservedEdge Type @relkit/agents API example
AgentOperation Type @relkit/agents API example
AgentProgressEvent Type @relkit/agents, @relkit/agents/client-events Module example
AgentProgressScope Type @relkit/agents Module example
AgentRequestScope Type @relkit/agents Source example
AgentRuntimeHooks Type @relkit/agents API example
AgentSpanCapture Type @relkit/agents API example
AgentStateLimits Type @relkit/agents Source example
AgentStateProvider Type @relkit/agents Source example
AgentSteeringSource Type @relkit/agents Module example
AgentTelemetry Value @relkit/agents API example
AgentTelemetryLive Value @relkit/agents API example
AgentTelemetryService Type @relkit/agents Module example
AgentToolEvent Type @relkit/agents, @relkit/agents/client-events Module example
AgentToolReferences Type @relkit/agents Module example
AgentTransitionError Type @relkit/agents Module example
AgentWaitingRequest Type @relkit/agents Module example
AgentWaitingState Type @relkit/agents Module example
AppendJournalRequest Type @relkit/agents Module example
APPROVAL_STATES Value @relkit/agents Module example
ApprovalDeniedError Value @relkit/agents API example
ApprovalEffectError Value @relkit/agents Module example
ApprovalMetadata Type @relkit/agents Module example
ApprovalOptions Type @relkit/agents Module example
ApprovalPolicy Type @relkit/agents Module example
ApprovalRecord Type @relkit/agents Module example
ApprovalRequiredError Value @relkit/agents API example
ApprovalSideEffect Type @relkit/agents Module example
ApprovalState Type @relkit/agents Module example
ApprovalStateError Value @relkit/agents API example
approveApproval Value @relkit/agents API example
approveApprovalEffect Value @relkit/agents API example
ApprovedApproval Type @relkit/agents Module example
assertAgentDescriptor Value @relkit/agents API example
assertApprovalGranted Value @relkit/agents API example
assertApprovalGrantedEffect Value @relkit/agents API example
BrowserMessage Type @relkit/agents Source example
BrowserMessagePart Type @relkit/agents Module example
captureAgentContent Value @relkit/agents API example
captureAgentContentEffect Value @relkit/agents API example
ClaimControlRequest Type @relkit/agents Module example
ClaimRunRequest Type @relkit/agents Module example
clientPolicyCount Value @relkit/agents Module example
clientPolicyFailures Value @relkit/agents Module example
CompleteRunRequest Type @relkit/agents Module example
CompletionReceipt Type @relkit/agents Module example
ContinuationIdentity Type @relkit/agents Module example
ContinuationReceipt Type @relkit/agents Module example
ContinuationReceiptLookup Type @relkit/agents Module example
ControlClaim Type @relkit/agents Module example
ControlEffectOutcome Type @relkit/agents Module example
ControlLimits Type @relkit/agents Module example
ControlPage Type @relkit/agents Module example
ControlReceipt Type @relkit/agents Module example
ControlReceiptLookup Type @relkit/agents Module example
ControlRecord Type @relkit/agents Module example
ControlStatus Type @relkit/agents Module example
copyAgentChat Value @relkit/agents API example
copyAgentChatEffect Value @relkit/agents API example
copyAgentClientPolicy Value @relkit/agents API example
copyAgentClientPolicyEffect Value @relkit/agents API example
copyAgentControls Value @relkit/agents API example
copyAgentControlsEffect Value @relkit/agents API example
copyAgentLimits Value @relkit/agents API example
copyAgentLimitsEffect Value @relkit/agents API example
createAgentCapturePolicy Value @relkit/agents API example
createAgentCapturePolicyEffect Value @relkit/agents API example
createAgentSpanCapture Value @relkit/agents API example
createAgentSpanCaptureEffect Value @relkit/agents API example
createApproval Value @relkit/agents API example
createApprovalEffect Value @relkit/agents API example
createGeneratedAgentFunction Value @relkit/agents API example
createGeneratedAgentFunctionEffect Value @relkit/agents API example
CreateThreadReceipt Type @relkit/agents Module example
CreateThreadRequest Type @relkit/agents Module example
decideThreadTransition Value @relkit/agents Source example
decideThreadTransitionEffect Value @relkit/agents Source example
defineAgent Value @relkit/agents API example
defineAgentEffect Value @relkit/agents Module example
DefineAgentOptions Type @relkit/agents Module example
DeniedApproval Type @relkit/agents Module example
denyApproval Value @relkit/agents API example
denyApprovalEffect Value @relkit/agents API example
emitAgentEdge Value @relkit/agents API example
emitAgentEdgeEffect Value @relkit/agents API example
ExecutionClaim Type @relkit/agents Source example
GENERATED_AGENT_FUNCTION_PREFIX Value @relkit/agents Module example
GENERATED_AGENT_FUNCTION_SUFFIX Value @relkit/agents Module example
GeneratedAgentExecutor Type @relkit/agents Module example
GeneratedAgentFunction Type @relkit/agents Module example
generatedAgentFunctionId Value @relkit/agents API example
generatedAgentFunctionIdEffect Value @relkit/agents API example
GeneratedAgentFunctionMarker Type @relkit/agents Module example
GeneratedAgentFunctionUnboundError Value @relkit/agents Module example
InterruptionReceipt Type @relkit/agents Module example
InterruptOwnedRunRequest Type @relkit/agents Module example
isAgentDescriptor Value @relkit/agents API example
isApprovalRecord Value @relkit/agents API example
isApprovalRecordEffect Value @relkit/agents API example
isGeneratedAgentFunction Value @relkit/agents API example
isGeneratedAgentFunctionEffect Value @relkit/agents API example
JournalCheckpoint Type @relkit/agents Source example
JournalPage Type @relkit/agents Module example
JournalReceipt Type @relkit/agents Module example
JournalRecord Type @relkit/agents Source example
ListThreadsRequest Type @relkit/agents Module example
LoadThreadRequest Type @relkit/agents Module example
LookupContinuationReceiptRequest Type @relkit/agents Module example
LookupControlReceiptRequest Type @relkit/agents Module example
LookupRunReceiptRequest Type @relkit/agents Module example
MarkControlEffectStartedRequest Type @relkit/agents Module example
ModelProviderConfiguration Type @relkit/agents Module example
ModelSelectionEffectError Value @relkit/agents Module example
ModelSelectionError Value @relkit/agents API example
ModelSelectionErrorCode Type @relkit/agents Module example
normalizeModelSelector Value @relkit/agents API example
normalizeModelSelectorEffect Value @relkit/agents API example
observeAgent Value @relkit/agents API example
parseModelProviderConfiguration Value @relkit/agents API example
parseModelProviderConfigurationEffect Value @relkit/agents API example
PendingApproval Type @relkit/agents Source example
PromptInstructions Type @relkit/agents Module example
PromptTemplate Type @relkit/agents Module example
ReadControlsRequest Type @relkit/agents Module example
ReadJournalRequest Type @relkit/agents Module example
ReadSnapshotHistoryRequest Type @relkit/agents Module example
RecoverAbandonedControlRequest Type @relkit/agents Module example
RenewControlClaimRequest Type @relkit/agents Module example
RenewRunClaimRequest Type @relkit/agents Module example
requiresApproval Value @relkit/agents API example
requiresApprovalEffect Value @relkit/agents API example
ResolvedModelSelection Type @relkit/agents Module example
resolveModelSelector Value @relkit/agents API example
resolveModelSelectorEffect Value @relkit/agents API example
RunOwner Type @relkit/agents Module example
RunReceiptLookup Type @relkit/agents Module example
RunStatus Type @relkit/agents Module example
SettleControlRequest Type @relkit/agents Module example
SnapshotHistoryPage Type @relkit/agents Module example
StoredApproval Type @relkit/agents Module example
StoredRun Type @relkit/agents Module example
StoredRunRouting Type @relkit/agents Module example
StoredThread Type @relkit/agents Module example
SuspendRunRequest Type @relkit/agents Module example
SuspensionReceipt Type @relkit/agents Module example
ThreadAction Type @relkit/agents Source example
ThreadList Type @relkit/agents Module example
ThreadListItem Type @relkit/agents Module example
ThreadSnapshot Type @relkit/agents Source example
ThreadStatus Type @relkit/agents Source example
ThreadTransition Type @relkit/agents Module example
ToolPartState Type @relkit/agents Source example
WaitForControlsRequest Type @relkit/agents Module example
WaitForJournalRequest Type @relkit/agents Module example

agent-client-chat.ts

copyAgentChat

Copies a chat mapping for synchronous descriptor callers.

Throws

TypeError for a noncanonical mapping.

Example

import { copyAgentChat } from "@relkit/agents";

const chat = copyAgentChat({ input: "message", output: "answer" });
void chat;

Signature

declare const copyAgentChat: (value: unknown) => AgentChatMapping | undefined;

Source

copyAgentChatEffect

Validates the fixed chat input and output mapping.

Example

import { Effect } from "effect";
import { copyAgentChatEffect } from "@relkit/agents";

const chat = Effect.runSync(copyAgentChatEffect({ input: "message", output: "answer" }));
void chat;

Signature

declare const copyAgentChatEffect: (
  value: unknown,
) => Effect.Effect<
  Readonly<{ input: "message"; output: "answer" }> | undefined,
  AgentClientPolicyError,
  never
>;

Source

agent-client-controls.ts

copyAgentControls

Copies client controls for synchronous descriptor callers.

Throws

TypeError when an unsupported or duplicate control is present.

Example

import { copyAgentControls } from "@relkit/agents";

const controls = copyAgentControls(["stop"]);
void controls;

Signature

declare const copyAgentControls: (value: unknown) => readonly AgentControl[] | undefined;

Source

copyAgentControlsEffect

Validates and freezes client control capabilities.

Example

import { Effect } from "effect";
import { copyAgentControlsEffect } from "@relkit/agents";

const controls = Effect.runSync(copyAgentControlsEffect(["stop"]));
void controls;

Signature

declare const copyAgentControlsEffect: (
  value: unknown,
) => Effect.Effect<ReadonlyArray<AgentControl> | undefined, AgentClientPolicyError, never>;

Source

agent-client-error.ts

AgentClientPolicyError (class)

Expected client configuration failure in the Effect error channel.

Signature

declare class AgentClientPolicyError

Source

clientPolicyCount

Signature

declare const clientPolicyCount: Metric.Counter<number>;

Source

clientPolicyFailures

Signature

declare const clientPolicyFailures: Metric.Counter<number>;

Source

agent-client-policy.ts

copyAgentClientPolicy

Copies a client policy for synchronous descriptor callers.

Throws

TypeError for malformed access, state, or event declarations.

Example

import { copyAgentClientPolicy } from "@relkit/agents";

const policy = copyAgentClientPolicy({ public: true }, new Set<string>());
void policy;

Signature

declare const copyAgentClientPolicy: <StateKey extends string>(
  value: unknown,
  allowedStateKeys?: ReadonlySet<StateKey>,
) => AgentClientPolicy<(...args: any[]) => unknown, StateKey> | undefined;

Source

copyAgentClientPolicyEffect

Validates and freezes client access, state keys, and event schemas.

Example

import { Effect } from "effect";
import { copyAgentClientPolicyEffect } from "@relkit/agents";

const policy = Effect.runSync(copyAgentClientPolicyEffect({ public: true }, new Set<string>()));
void policy;

Signature

declare const copyAgentClientPolicyEffect: <StateKey extends string>(
  value: unknown,
  allowedStateKeys?: ReadonlySet<StateKey> | undefined,
) => Effect.Effect<
  | Readonly<{
      events?: Readonly<Record<string, StandardSchemaV1<unknown, unknown>>>;
      state?: ReadonlyArray<StateKey>;
      public: true;
    }>
  | Readonly<{
      events?: Readonly<Record<string, StandardSchemaV1<unknown, unknown>>>;
      state?: ReadonlyArray<StateKey>;
      authorize: (...args: any[]) => unknown;
    }>
  | undefined,
  AgentClientPolicyError,
  never
>;

Source

agent-client.ts

“./agent-client-chat.js” (namespace export)

Re-exports all named exports from the “./agent-client-chat.js” module.

Signature

export * from "./agent-client-chat.js";

Source

“./agent-client-controls.js” (namespace export)

Re-exports all named exports from the “./agent-client-controls.js” module.

Signature

export * from "./agent-client-controls.js";

Source

“./agent-client-error.js” (namespace export)

Re-exports all named exports from the “./agent-client-error.js” module.

Signature

export * from "./agent-client-error.js";

Source

“./agent-client-policy.js” (namespace export)

Re-exports all named exports from the “./agent-client-policy.js” module.

Signature

export * from "./agent-client-policy.js";

Source

AgentChatMapping

Signature

declare const AgentChatMapping: AgentChatMapping;

Source

AgentClientEvents

Signature

declare const AgentClientEvents: Readonly<Record<string, StandardSchemaV1<unknown, unknown>>>;

Source

AgentClientPolicy

Signature

declare const AgentClientPolicy: AgentClientPolicy<Guard, StateKey, Events>;

Source

AgentControl

Signature

declare const AgentControl: AgentControl;

Source

agent-client.types.ts

AgentChatMapping (interface)

Fixed input and output field mapping for an agent chat client.

Example

const chat: AgentChatMapping = { input: "message", output: "answer" };

Signature

export interface AgentChatMapping {
  readonly input: "message";
  readonly output: "answer";
}

Source

AgentClientEvents (type alias)

Named public events and their Standard Schema validators. Names must be nonempty before the policy is published.

Example

import { z } from "@relkit/schema";
const events: AgentClientEvents = { completed: z.string() };

Signature

type AgentClientEvents = Readonly<Record<string, StandardSchemaV1>>;

Source

AgentClientPolicy (type alias)

Client visibility, selected state, and public event schemas. Exactly one of public access and an authorization guard must be supplied.

Example

const policy: AgentClientPolicy = { public: true, state: ["answer"] };

Signature

type AgentClientPolicy<
  Guard = (...args: any[]) => unknown,
  StateKey extends string = string,
  Events extends AgentClientEvents = AgentClientEvents,
> = (
  | { readonly public: true; readonly authorize?: never }
  | { readonly authorize: Guard; readonly public?: never }
) & {
  readonly state?: readonly StateKey[];
  readonly events?: Events;
};

Source

AgentControl (type alias)

Durable control capabilities that may be exposed to an agent client.

Example

const control: AgentControl = "stop";

Signature

type AgentControl = "steer" | "follow-up" | "stop" | "approve";

Source

agent-telemetry.ts

AgentOperation

Signature

declare const AgentOperation: AgentOperation;

Source

AgentTelemetry (class)

Injectable telemetry boundary for agent operations.

Example

Effect.provide(observeAgent("capture.policy", Effect.void), AgentTelemetryLive);

Signature

declare class AgentTelemetry

Source

AgentTelemetryLive

Live metric observer for traced agent operations.

Example

Effect.runSync(Effect.provide(observeAgent("capture.policy", Effect.void), AgentTelemetryLive));

Signature

declare const AgentTelemetryLive: Layer.Layer<AgentTelemetry, never, never>;

Source

AgentTelemetryService

Signature

declare const AgentTelemetryService: AgentTelemetryService;

Source

observeAgent

Records a call, duration, and failure with a fixed operation label.

Example

observeAgent("capture.policy", Effect.succeed({ mode: "off" }));

Signature

declare const observeAgent: <A, E, R>(
  operation: AgentOperation,
  effect: Effect.Effect<A, E, R>,
) => Effect.Effect<A, E, R>;

Source

agent-telemetry.types.ts

AgentOperation (type alias)

Fixed operation labels for agent telemetry; no user value is a label.

Example

const operation: AgentOperation = "runtime.invoke-tool";

Signature

type AgentOperation =
  | "client.controls"
  | "client.chat"
  | "client.copy"
  | "validation.schema"
  | "validation.is-schema"
  | "validation.positive-integer"
  | "validation.is-positive-integer"
  | "validation.is-record"
  | "capture.policy"
  | "capture.content"
  | "capture.span"
  | "client-schema.merge"
  | "client-schema.select"
  | "client-schema.project"
  | "client-events.project"
  | "graph-state.select"
  | "graph-interruption.response"
  | "graph-interruption.requests"
  | "graph-interruption.is-error"
  | "thread-transition.decide"
  | "runtime.invoke"
  | "runtime.create"
  | "approval.requires"
  | "approval.create"
  | "approval.approve"
  | "approval.deny"
  | "approval.assert-granted"
  | "approval.is-record"
  | "model-selector.normalize"
  | "model-selector.parse"
  | "model-selector.resolve"
  | "persistence.release"
  | "persistence.resolve-graph"
  | "persistence.resolve-agent"
  | "bucket.list"
  | "bucket.delete"
  | "bucket.glob"
  | "bucket.grep"
  | "bucket.read-data"
  | "bucket.write-data"
  | "bucket.scoped-keys"
  | "bucket.info"
  | "bucket.read-raw"
  | "bucket.read"
  | "bucket.write"
  | "bucket.edit"
  | "bucket.upload"
  | "bucket.download"
  | "bucket.create"
  | "bucket.thread"
  | "definition.copy-instructions"
  | "definition.is-instructions"
  | "definition.is-descriptor"
  | "definition.assert-descriptor"
  | "definition.normalize-model"
  | "definition.copy-deep"
  | "definition.has-deep"
  | "definition.is-model"
  | "definition.copy-middleware"
  | "definition.state-keys"
  | "definition.copy-tools"
  | "definition.tool-refs"
  | "graph.validate-resume"
  | "graph.waiting"
  | "graph.config"
  | "graph.resume-command"
  | "graph-node.destinations"
  | "graph-node.copy-ends"
  | "graph-node.result"
  | "graph-node.input"
  | "graph-node.handle"
  | "graph-node.define"
  | "graph-node.is-descriptor"
  | "definition.copy-limits"
  | "definition.define"
  | "generated.id"
  | "generated.create"
  | "generated.is-function"
  | "persistence.is-resource"
  | "persistence.assert-protocol"
  | "persistence.define-checkpointer"
  | "persistence.define-memory"
  | "runtime.resolve-model"
  | "runtime.content-limits"
  | "graph.invoke"
  | "graph.workflow"
  | "graph.requires-persistence"
  | "graph.define"
  | "graph.execution"
  | "graph.is-descriptor"
  | "graph.subgraph-create"
  | "graph.subgraph-is-node"
  | "graph.subgraph-source"
  | "native-hitl.response-schema"
  | "native-hitl.is-request"
  | "native-hitl.public-request"
  | "native-hitl.is-decision"
  | "native-hitl.is-record"
  | "native-hitl.resume-command"
  | "native-hitl.waiting"
  | "native-hitl.validate-reply"
  | "graph.compile"
  | "graph.route"
  | "graph.edge-builder"
  | "graph.add-edge"
  | "graph.add-conditional-edge"
  | "graph.destination"
  | "graph.validate-route"
  | "graph.prepare-definition"
  | "runtime.validate-value"
  | "runtime.json-value"
  | "runtime.model-failure"
  | "runtime.selected-state-schemas"
  | "graph-node.validate-destinations"
  | "graph-node.command-update"
  | "graph-node.validated-update"
  | "graph-node.validated-value"
  | "bucket.context"
  | "bucket.virtual-path"
  | "bucket.key"
  | "bucket.file-path"
  | "bucket.page"
  | "bucket.control-failure"
  | "bucket.error-message"
  | "bucket.text-mime-type"
  | "runtime.collect-native-events"
  | "runtime.emit-native-tool-event"
  | "runtime.selected-state"
  | "runtime.select-state-fields"
  | "runtime.native-public-event"
  | "runtime.public-event-value"
  | "runtime.public-tool-value"
  | "runtime.message-update"
  | "runtime.native-limits"
  | "runtime.model-limit"
  | "runtime.tool-limit"
  | "runtime.combine-native-tools"
  | "runtime.native-instructions"
  | "runtime.load-deepagents"
  | "runtime.assert-dependencies"
  | "runtime.model-tool-name"
  | "runtime.find-model-tool"
  | "runtime.find-tool"
  | "runtime.run-tool"
  | "runtime.emit-tool"
  | "runtime.resolve-approval"
  | "runtime.create-tool-dispatcher"
  | "runtime.invoke-tool"
  | "graph.stream-compiled"
  | "graph.run-compiled"
  | "observability.emit-edge"
  | "runtime.create-native-tools"
  | "runtime.create-agent-tools"
  | "runtime.response-format"
  | "runtime.child-model"
  | "runtime.create-subagents"
  | "runtime.create-native-agent"
  | "runtime.native-messages"
  | "runtime.response-value"
  | "runtime.unwrap-native-cause"
  | "runtime.run-loop"
  | "signal.failure"
  | "signal.create"
  | "signal.acquire"
  | "signal.with-signal"
  | "client.agent-metadata"
  | "client.graph-metadata";

Source

AgentTelemetryService (interface)

Replaceable observer used by Effect operations and deterministic tests.

Signature

export interface AgentTelemetryService {
  /** Records an operation without changing its Effect channels.
   * @param operation - Fixed agent operation name.
   * @param effect - Work to instrument.
   * @returns The same success, error, and dependency channels.
   * @example telemetry.observe("capture.policy", Effect.succeed({ mode: "off" }));
   */
  readonly observe: <A, E, R>(
    operation: AgentOperation,
    effect: Effect.Effect<A, E, R>,
  ) => Effect.Effect<A, E, R>;
}

Source

agent-validation-error.ts

AgentValidationError (class)

Typed validation failure raised by an Effect agent-authoring operation.

Example

const error = new AgentValidationError({
  operation: "positiveInteger",
  message: "limit must be positive",
});

Signature

declare class AgentValidationError

Source

validationCount

Signature

declare const validationCount: Metric.Counter<number>;

Source

validationFailures

Signature

declare const validationFailures: Metric.Counter<number>;

Source

agent-validation-schema.ts

assertAgentSchema

Throws for an invalid schema in existing synchronous authoring calls.

Throws

TypeError when the value is not a Standard Schema v1 validator.

Example

assertAgentSchema(z.string(), "input");

Signature

declare const assertAgentSchema: (
  value: unknown,
  name: string,
) => asserts value is StandardSchemaV1;

Source

assertAgentSchemaEffect

Validates that a value implements the Standard Schema v1 protocol.

Example

const schema = Effect.runSync(assertAgentSchemaEffect(z.string(), "input"));

Signature

declare const assertAgentSchemaEffect: (
  value: unknown,
  name: string,
) => Effect.Effect<StandardSchemaV1<unknown, unknown>, AgentValidationError, never>;

Source

isAgentSchema

Checks whether a candidate implements Standard Schema v1.

Example

if (isAgentSchema(value)) value["~standard"].validate(input);

Signature

declare const isAgentSchema: (value: unknown) => value is StandardSchemaV1;

Source

isAgentSchemaEffect

Checks the Standard Schema v1 protocol without throwing.

Example

const valid = Effect.runSync(isAgentSchemaEffect(z.string()));

Signature

declare const isAgentSchemaEffect: (value: unknown) => Effect.Effect<boolean, never, never>;

Source

agent-validation-value.ts

isPositiveInteger

Checks a finite positive integer for existing synchronous callers.

Example

if (isPositiveInteger(value)) console.log(value + 1);

Signature

declare const isPositiveInteger: (value: unknown) => value is number;

Source

isPositiveIntegerEffect

Checks for a finite positive integer without throwing.

Example

const valid = Effect.runSync(isPositiveIntegerEffect(3));

Signature

declare const isPositiveIntegerEffect: (value: unknown) => Effect.Effect<boolean, never, never>;

Source

isRecord

Checks a record for existing synchronous callers.

Example

if (isRecord(value)) console.log(value.id);

Signature

declare const isRecord: (value: unknown) => value is Record<PropertyKey, unknown>;

Source

isRecordEffect

Checks a non-null, non-array record through an Effect operation.

Example

const valid = Effect.runSync(isRecordEffect({ id: "one" }));

Signature

declare const isRecordEffect: (value: unknown) => Effect.Effect<boolean, never, never>;

Source

positiveInteger

Validates a finite positive integer for existing synchronous callers.

Throws

TypeError when the value is not a finite positive integer.

Example

const limit = positiveInteger(3, "maxSteps");

Signature

declare const positiveInteger: (value: unknown, name: string) => number;

Source

positiveIntegerEffect

Validates a finite positive integer with a typed Effect failure.

Example

const limit = Effect.runSync(positiveIntegerEffect(3, "maxSteps"));

Signature

declare const positiveIntegerEffect: (
  value: unknown,
  name: string,
) => Effect.Effect<number, AgentValidationError, never>;

Source

agent-validation.ts

“./agent-validation-error.js” (namespace export)

Re-exports all named exports from the “./agent-validation-error.js” module.

Signature

export * from "./agent-validation-error.js";

Source

“./agent-validation-schema.js” (namespace export)

Re-exports all named exports from the “./agent-validation-schema.js” module.

Signature

export * from "./agent-validation-schema.js";

Source

“./agent-validation-value.js” (namespace export)

Re-exports all named exports from the “./agent-validation-value.js” module.

Signature

export * from "./agent-validation-value.js";

Source

approval-core.ts

APPROVAL_STATES

Signature

declare const APPROVAL_STATES: readonly ["pending", "approved", "denied"];

Source

approveApprovalValue

Grants a pending approval.

Throws

ApprovalStateError for an invalid transition.

Example

approveApprovalValue(pending);

Signature

declare const approveApprovalValue: (approval: ApprovalRecord) => ApprovedApproval;

Source

assertApprovalGrantedValue

Checks whether execution is approved.

Throws

ApprovalRequiredError, ApprovalDeniedError, or ApprovalStateError.

Example

assertApprovalGrantedValue(approved);

Signature

declare const assertApprovalGrantedValue: (
  approval: ApprovalRecord,
) => asserts approval is ApprovedApproval;

Source

createApprovalValue

Constructs a canonical approval record.

Throws

TypeError or ApprovalStateError for invalid metadata.

Example

createApprovalValue(options);

Signature

declare const createApprovalValue: (options: ApprovalOptions) => ApprovalRecord;

Source

denyApprovalValue

Denies a pending approval.

Throws

ApprovalStateError for an invalid transition.

Example

denyApprovalValue(pending);

Signature

declare const denyApprovalValue: (approval: ApprovalRecord) => DeniedApproval;

Source

isApprovalRecordValue

Recognizes canonical approval records.

Example

isApprovalRecordValue(value);

Signature

declare const isApprovalRecordValue: (value: unknown) => value is ApprovalRecord;

Source

requiresApprovalValue

Computes whether a policy requires approval.

Throws

TypeError for invalid inputs.

Example

requiresApprovalValue("always", "read");

Signature

declare const requiresApprovalValue: (
  policy: ApprovalPolicy,
  sideEffect: ApprovalSideEffect,
) => boolean;

Source

approval-effect-error.ts

ApprovalEffectError (class)

Tagged failure for an invalid approval or denied execution.

Signature

declare class ApprovalEffectError

Source

approvalEffectError

Preserves an approval error for typed Effect recovery and compatibility adapters.

Example

approvalEffectError(new ApprovalStateError("invalid state"));

Signature

declare const approvalEffectError: (cause: unknown) => ApprovalEffectError;

Source

approval-error.ts

ApprovalDeniedError (class)

Execution was attempted after an approval was denied.

Example

throw new ApprovalDeniedError(denied);

Signature

declare class ApprovalDeniedError { constructor(readonly approval: DeniedApproval) }

Source

code (property)

Signature

readonly code: "RELKIT_APPROVAL_DENIED"

Source

ApprovalRequiredError (class)

Execution was attempted while an approval remains pending.

Example

throw new ApprovalRequiredError(pending);

Signature

declare class ApprovalRequiredError { constructor(readonly approval: PendingApproval) }

Source

code (property)

Signature

readonly code: "RELKIT_APPROVAL_REQUIRED"

Source

ApprovalStateError (class)

A malformed approval or invalid state transition.

Example

throw new ApprovalStateError("Cannot transition approved approval");

Signature

declare class ApprovalStateError {
  constructor(message: string);
}

Source

code (property)

Signature

readonly code: "RELKIT_APPROVAL_STATE_INVALID"

Source

approval.ts

approveApproval

Moves a pending approval to the approved state.

Throws

ApprovalStateError for a malformed or final decision.

Example

import { approveApproval, createApproval } from "@relkit/app/agents";

const pending = createApproval({
  invocationId: "run",
  toolCallId: "call",
  toolId: "send",
  sideEffect: "write",
  policy: "always",
});
const approved = approveApproval(pending);
void approved;

Signature

declare const approveApproval: (approval: ApprovalRecord) => ApprovedApproval;

Source

Since v0.4.0

denyApproval

Moves a pending approval to the denied state.

Throws

ApprovalStateError for a malformed or final decision.

Example

import { createApproval, denyApproval } from "@relkit/app/agents";

const pending = createApproval({
  invocationId: "run",
  toolCallId: "call",
  toolId: "send",
  sideEffect: "write",
  policy: "always",
});
const denied = denyApproval(pending);
void denied;

Signature

declare const denyApproval: (approval: ApprovalRecord) => DeniedApproval;

Source

Since v0.4.0

“./approval.types.js” (namespace export)

Re-exports all named exports from the “./approval.types.js” module.

Signature

export * from "./approval.types.js";

Source

APPROVAL_STATES

Signature

declare const APPROVAL_STATES: readonly ["pending", "approved", "denied"];

Source

ApprovalDeniedError

Signature

declare const ApprovalDeniedError: typeof ApprovalDeniedError;

Source

ApprovalEffectError

Signature

declare const ApprovalEffectError: typeof ApprovalEffectError;

Source

ApprovalRequiredError

Signature

declare const ApprovalRequiredError: typeof ApprovalRequiredError;

Source

ApprovalStateError

Signature

declare const ApprovalStateError: typeof ApprovalStateError;

Source

approveApprovalEffect

Moves a pending approval to the approved state.

Example

Effect.runSync(approveApprovalEffect(pending));

Signature

declare const approveApprovalEffect: (
  approval: ApprovalRecord,
) => Effect.Effect<ApprovedApproval, ApprovalEffectError, never>;

Source

assertApprovalGranted

Rejects execution unless the record is approved.

Throws

ApprovalRequiredError, ApprovalDeniedError, or ApprovalStateError.

Example

assertApprovalGranted(approved);

Signature

declare const assertApprovalGranted: (
  approval: ApprovalRecord,
) => asserts approval is ApprovedApproval;

Source

assertApprovalGrantedEffect

Fails unless the record was approved.

Example

Effect.runSync(assertApprovalGrantedEffect(approved));

Signature

declare const assertApprovalGrantedEffect: (
  approval: ApprovalRecord,
) => Effect.Effect<void, ApprovalEffectError, never>;

Source

createApproval

Creates an immutable pending or policy-approved record.

Throws

TypeError or ApprovalStateError for invalid metadata.

Example

createApproval({
  invocationId: "run",
  toolCallId: "call",
  toolId: "send",
  sideEffect: "write",
  policy: "always",
});

Signature

declare const createApproval: (options: ApprovalOptions) => ApprovalRecord;

Source

createApprovalEffect

Creates an immutable pending or policy-approved record.

Example

Effect.runSync(createApprovalEffect(options));

Signature

declare const createApprovalEffect: (
  options: ApprovalOptions,
) => Effect.Effect<ApprovalRecord, ApprovalEffectError, never>;

Source

denyApprovalEffect

Moves a pending approval to the denied state.

Example

Effect.runSync(denyApprovalEffect(pending));

Signature

declare const denyApprovalEffect: (
  approval: ApprovalRecord,
) => Effect.Effect<DeniedApproval, ApprovalEffectError, never>;

Source

isApprovalRecord

Checks whether a value is a canonical approval record.

Example

if (isApprovalRecord(value)) console.log(value.state);

Signature

declare const isApprovalRecord: (value: unknown) => value is ApprovalRecord;

Source

isApprovalRecordEffect

Checks whether a value is a canonical approval record.

Example

Effect.runSync(isApprovalRecordEffect(value));

Signature

declare const isApprovalRecordEffect: (value: unknown) => Effect.Effect<boolean, never, never>;

Source

requiresApproval

Tests whether a tool call needs an explicit approval decision.

Throws

TypeError for an invalid policy or side effect.

Example

requiresApproval("on-write", "write");

Signature

declare const requiresApproval: (policy: ApprovalPolicy, sideEffect: ApprovalSideEffect) => boolean;

Source

requiresApprovalEffect

Tests whether a tool call needs an explicit approval decision.

Example

Effect.runSync(requiresApprovalEffect("on-write", "write"));

Signature

declare const requiresApprovalEffect: (
  policy: FunctionToolApproval,
  sideEffect: FunctionToolSideEffect,
) => Effect.Effect<boolean, ApprovalEffectError, never>;

Source

approval.types.ts

ApprovalMetadata (interface)

Argument-free metadata for one invocation and tool-call decision.

Signature

export interface ApprovalMetadata extends ApprovalOptions {
  readonly required: boolean;
  readonly state: ApprovalState;
}

Source

ApprovalOptions (interface)

Inputs used to create an approval record.

Signature

export interface ApprovalOptions {
  readonly invocationId: string;
  readonly toolCallId: string;
  readonly toolId: string;
  readonly sideEffect: ApprovalSideEffect;
  readonly policy: ApprovalPolicy;
}

Source

ApprovalPolicy (type alias)

Policy controlling which tool calls require approval.

Signature

type ApprovalPolicy = ToolApproval;

Source

ApprovalRecord (type alias)

Canonical approval record in any valid state.

Signature

type ApprovalRecord = PendingApproval | ApprovedApproval | DeniedApproval;

Source

ApprovalSideEffect (type alias)

Declared side effect of a tool call.

Signature

type ApprovalSideEffect = ToolSideEffect;

Source

ApprovalState (type alias)

One canonical approval state.

Signature

type ApprovalState = "pending" | "approved" | "denied";

Source

ApprovedApproval (interface)

Approval granted by policy or an explicit decision.

Signature

export interface ApprovedApproval extends ApprovalMetadata {
  readonly state: "approved";
}

Source

DeniedApproval (interface)

Approval explicitly denied.

Signature

export interface DeniedApproval extends ApprovalMetadata {
  readonly state: "denied";
}

Source

PendingApproval (interface)

Approval that must receive a decision before execution.

Signature

export interface PendingApproval extends ApprovalMetadata {
  readonly state: "pending";
}

Source

capture-content.ts

captureAgentContent

Captures redacted content for synchronous runtime callers.

Example

const record = captureAgentContent({ token: "secret" }, policy);

Signature

declare const captureAgentContent: (
  value: unknown,
  policy: AgentCapturePolicy,
) => AgentCaptureRecord | undefined;

Source

captureAgentContentEffect

Redacts and bounds a JSON-compatible agent value.

Example

const record = Effect.runSync(captureAgentContentEffect({ token: "secret" }, policy));

Signature

declare const captureAgentContentEffect: (
  value: unknown,
  policy: AgentCapturePolicy,
) => Effect.Effect<AgentCaptureRecord | undefined, never, never>;

Source

capture-policy.ts

AgentCapturePolicyError (class)

Invalid capture configuration in the Effect error channel.

Signature

declare class AgentCapturePolicyError

Source

createAgentCapturePolicy

Creates a capture policy for synchronous descriptor callers.

Throws

TypeError when mode, size, or redaction keys are invalid.

Example

const policy = createAgentCapturePolicy({ mode: "development-redacted", maxBytes: 1024 });

Signature

declare const createAgentCapturePolicy: (
  value: AgentCapturePolicy | undefined,
) => AgentCapturePolicy;

Source

createAgentCapturePolicyEffect

Validates and freezes a content capture policy.

Example

const policy = Effect.runSync(createAgentCapturePolicyEffect({ mode: "off" }));

Signature

declare const createAgentCapturePolicyEffect: (
  value: AgentCapturePolicy | undefined,
) => Effect.Effect<AgentCapturePolicy, AgentCapturePolicyError, never>;

Source

capture-span.ts

createAgentSpanCapture

Combines captured input and output for synchronous runtime callers.

Example

const capture = createAgentSpanCapture(input, output);

Signature

declare const createAgentSpanCapture: (
  input: AgentCaptureRecord | undefined,
  output: AgentCaptureRecord | undefined,
) => AgentSpanCapture | undefined;

Source

createAgentSpanCaptureEffect

Combines optional captured input and output for an agent span.

Example

const capture = Effect.runSync(createAgentSpanCaptureEffect(input, output));

Signature

declare const createAgentSpanCaptureEffect: (
  input: AgentCaptureRecord | undefined,
  output: AgentCaptureRecord | undefined,
) => Effect.Effect<
  Readonly<{ output?: AgentCaptureRecord; input?: AgentCaptureRecord }> | undefined,
  never,
  never
>;

Source

capture.ts

“./capture-content.js” (namespace export)

Re-exports all named exports from the “./capture-content.js” module.

Signature

export * from "./capture-content.js";

Source

“./capture-policy.js” (namespace export)

Re-exports all named exports from the “./capture-policy.js” module.

Signature

export * from "./capture-policy.js";

Source

“./capture-span.js” (namespace export)

Re-exports all named exports from the “./capture-span.js” module.

Signature

export * from "./capture-span.js";

Source

AgentCapturePolicy

Signature

declare const AgentCapturePolicy: AgentCapturePolicy;

Source

AgentCaptureRecord

Signature

declare const AgentCaptureRecord: AgentCaptureRecord;

Source

AgentSpanCapture

Signature

declare const AgentSpanCapture: AgentSpanCapture;

Source

capture.types.ts

AgentCapturePolicy (interface)

Controls whether an agent may retain redacted content in its spans. Development capture requires a positive byte limit; off ignores the other fields.

Example

const policy: AgentCapturePolicy = { mode: "development-redacted", maxBytes: 1024 };

Signature

export interface AgentCapturePolicy {
  readonly mode: "off" | "development-redacted";
  readonly maxBytes?: number;
  readonly redactKeys?: readonly string[];
}

Source

AgentCaptureRecord (interface)

Captured JSON and its encoded size, or a marker when capture was truncated. The content property is absent whenever truncated is true.

Example

const record: AgentCaptureRecord = { mode: "development-redacted", bytes: 0, truncated: true };

Signature

export interface AgentCaptureRecord {
  readonly mode: "development-redacted";
  readonly bytes: number;
  readonly truncated: boolean;
  readonly content?: JsonValue;
}

Source

AgentSpanCapture (interface)

Optional input and output captures attached to one agent span. Absent fields were disabled or unavailable at capture time.

Example

const capture: AgentSpanCapture = {
  input: { mode: "development-redacted", bytes: 0, truncated: true },
};

Signature

export interface AgentSpanCapture {
  readonly input?: AgentCaptureRecord;
  readonly output?: AgentCaptureRecord;
}

Source

client-contract-metadata.ts

Projects generic RELKIT tool references and public event schemas into client metadata. Native middleware, graph state and SDK schema projection remain in @relkit/langchain.

“./client-contract-metadata.types.js” (namespace export)

Re-exports all named exports from the “./client-contract-metadata.types.js” module.

Signature

export * from "./client-contract-metadata.types.js";

Source

agentClientContractMetadata

Projects generic metadata for synchronous authoring.

Throws

The original metadata projection error.

Signature

declare const agentClientContractMetadata: (
  options: AgentClientMetadataOptions,
) => AgentClientContractMetadata;

Source

agentClientContractMetadataEffect

Projects an ordinary agent’s public contract without evaluating native schemas.

Signature

declare const agentClientContractMetadataEffect: (
  options: AgentClientMetadataOptions,
) => Effect.Effect<AgentClientContractMetadata, AgentDefinitionFailure, never>;

Source

client-contract-metadata.types.ts

Declares serializable agent client contract metadata shared by SDK-free authoring, graph normalization and runtime client projections. This companion contains the shared planning contracts without executing work.

AgentClientContractMetadata (interface)

Complete metadata needed to generate an agent client contract.

Signature

export interface AgentClientContractMetadata {
  readonly tools: readonly ClientToolMetadata[];
  readonly state: readonly ClientTypeField[];
  readonly events: readonly ClientEventMetadata[];
  readonly scopes: readonly ClientScopeMetadata[];
  readonly waiting: readonly ClientWaitingMetadata[];
}

Source

AgentClientMetadataOptions (interface)

Inputs for native agent client metadata.

Signature

export interface AgentClientMetadataOptions {
  readonly id: string;
  readonly tools: readonly ToolRefAny[];
  readonly middleware?: readonly [];
  readonly client?: AgentClientPolicy;
  readonly subagents?: readonly SubagentMetadataSource[];
  readonly interruptOn?: Readonly<Record<string, unknown>>;
}

Source

ClientEventMetadata (type alias)

Client visible event schema or dynamic event marker.

Signature

type ClientEventMetadata = ClientTypeField | { readonly kind: "dynamic" };

Source

ClientScopeMetadata (interface)

Client visible agent, subagent, or graph node scope.

Signature

export interface ClientScopeMetadata {
  readonly kind: "agent" | "subagent" | "node" | "dynamic";
  readonly id?: string;
}

Source

ClientToolMetadata (type alias)

Client visible tool schema or dynamic tool marker.

Signature

type ClientToolMetadata =
  | {
      readonly id: string;
      readonly input: ClientSchemaMetadata;
      readonly output: ClientSchemaMetadata;
    }
  | { readonly kind: "dynamic" };

Source

ClientWaitingMetadata (interface)

Client visible continuation response schema.

Signature

export interface ClientWaitingMetadata {
  readonly scope: ClientScopeMetadata;
  readonly response: ClientSchemaMetadata;
}

Source

SubagentMetadataSource (interface)

Source of nested subagent scope identities.

Signature

export interface SubagentMetadataSource {
  readonly id: string;
  readonly subagents?: readonly SubagentMetadataSource[];
}

Source

client-contract-schema.ts

Describes Standard Schema input and output contracts for generic agent clients without importing a native model or graph SDK.

ClientSchemaMetadata

Signature

declare const ClientSchemaMetadata: ClientSchemaMetadata;

Source

ClientTypeField

Signature

declare const ClientTypeField: ClientTypeField;

Source

clientSchemaMetadata

Synchronously projects schema metadata for existing descriptor callers.

Example

const metadata = clientSchemaMetadata({ type: "string" });

Signature

declare const clientSchemaMetadata: (value: unknown) => ClientSchemaMetadata;

Source

clientSchemaMetadataEffect

Projects a schema-like value to safe client metadata.

Example

const metadata = Effect.runSync(clientSchemaMetadataEffect({ type: "string" }));

Signature

declare const clientSchemaMetadataEffect: (
  value: unknown,
) => Effect.Effect<ClientSchemaMetadata, never, never>;

Source

dynamicClientSchema

Marker for a schema that cannot be represented in the client contract.

Signature

declare const dynamicClientSchema: Readonly<{ kind: "dynamic" }>;

Source

mergeClientSchemas

Synchronously merges client schemas for existing descriptor callers.

Example

const schema = mergeClientSchemas([{ type: "object" }]);

Signature

declare const mergeClientSchemas: (values: readonly unknown[]) => ClientSchemaMetadata;

Source

mergeClientSchemasEffect

Merges projected object schemas while preserving input order.

Example

const schema = Effect.runSync(mergeClientSchemasEffect([{ type: "object" }]));

Signature

declare const mergeClientSchemasEffect: (
  values: ReadonlyArray<unknown>,
) => Effect.Effect<JsonValue, never, never>;

Source

selectedClientFields

Synchronously selects client fields for existing descriptor callers.

Example

const fields = selectedClientFields({ type: "object" }, ["name"]);

Signature

declare const selectedClientFields: (
  schema: ClientSchemaMetadata,
  keys?: readonly string[],
) => readonly ClientTypeField[];

Source

selectedClientFieldsEffect

Selects named client state fields from a projected object schema.

Example

const fields = Effect.runSync(selectedClientFieldsEffect({ type: "object" }, ["name"]));

Signature

declare const selectedClientFieldsEffect: (
  schema: ClientSchemaMetadata,
  keys?: ReadonlyArray<string> | undefined,
) => Effect.Effect<ReadonlyArray<ClientTypeField>, never, never>;

Source

client-contract-schema.types.ts

ClientSchemaMetadata (type alias)

A projected JSON Schema fragment or an intentionally dynamic field.

Signature

type ClientSchemaMetadata = JsonValue | { readonly kind: "dynamic" };

Source

ClientTypeField (interface)

One client-visible state field with its projected schema.

Signature

export interface ClientTypeField {
  readonly name: string;
  readonly schema: ClientSchemaMetadata;
  readonly optional?: true;
}

Source

client-events.ts

Projects durable agent journal records into bounded client lifecycle events while preserving tool identity and declared public values.

AgentClientEvent

Signature

declare const AgentClientEvent: AgentClientEvent;

Source

AgentProgressEvent

Signature

declare const AgentProgressEvent: AgentProgressEvent;

Source

AgentToolEvent

Signature

declare const AgentToolEvent: AgentToolEvent;

Source

agentClientEvents

Projects a journal record for existing synchronous client callers.

Example

const events = agentClientEvents(record);

Signature

declare const agentClientEvents: (record: JournalRecord) => readonly AgentClientEvent[];

Source

agentClientEventsEffect

Projects one journal record into ordered, public client events.

Example

const events = Effect.runSync(agentClientEventsEffect(record));

Signature

declare const agentClientEventsEffect: (
  record: JournalRecord,
) => Effect.Effect<ReadonlyArray<AgentClientEvent>, never, never>;

Source

client-tool-events.ts

Projects tool message parts into stable public event identities in authored order.

toolClientEvents

Signature

declare const toolClientEvents: (
  base: ClientEventBase,
  message: BrowserMessage,
) => readonly AgentClientEvent[];

Source

define-agent-build.ts

Validates generic authoring inputs before binding a descriptor identity. Native fields are rejected with their integration import so no capability is silently ignored.

prepareAgentDescriptor

Prepares immutable generic metadata before applying its stable identity.

Throws

TypeError for unsupported native fields or invalid generic inputs.

Signature

declare const prepareAgentDescriptor: <
  const Id extends string,
  const InputSchema extends StandardSchemaV1,
  const OutputSchema extends StandardSchemaV1,
  const Tools extends readonly ToolRefAny[],
>(
  options: DefineAgentOptions<Id, InputSchema, OutputSchema, Tools>,
) => (
  id: Id,
) => AgentDescriptor<
  Id,
  InferInput<InputSchema>,
  InferOutput<OutputSchema>,
  InputSchema,
  OutputSchema,
  Tools
>;

Source

define-agent-error.ts

AgentDefinitionFailure (class)

Tagged validation failure while copying an agent definition.

Signature

declare class AgentDefinitionFailure

Source

agentDefinitionFailure

Preserves the original authoring error in a tagged Effect failure.

Example

agentDefinitionFailure(new TypeError("invalid"));

Signature

declare const agentDefinitionFailure: (cause: unknown) => AgentDefinitionFailure;

Source

define-agent-limits.ts

copyAgentLimits

Copies limits for existing synchronous authoring callers.

Throws

The original invalid limits TypeError.

Example

const limits = copyAgentLimits({ maxSteps: 3, maxToolCalls: 2, timeoutMs: 1000 });

Signature

declare const copyAgentLimits: (value: unknown) => AgentLimits;

Source

copyAgentLimitsEffect

Validates and freezes an agent’s execution limits.

Example

Effect.runSync(copyAgentLimitsEffect({ maxSteps: 3, maxToolCalls: 2, timeoutMs: 1000 }));

Signature

declare const copyAgentLimitsEffect: (
  value: unknown,
) => Effect.Effect<
  Readonly<{ maxSteps: number; maxToolCalls: number; timeoutMs: number }>,
  AgentDefinitionFailure,
  never
>;

Source

define-agent-support.ts

copyAgentInstructions

Copies instructions for existing synchronous authoring callers.

Throws

The original invalid instruction error.

Example

const instructions = copyAgentInstructions("Answer clearly");

Signature

declare const copyAgentInstructions: (value: unknown) => AgentInstructions;

Source

copyAgentInstructionsEffect

Validates and freezes agent instructions.

Example

Effect.runSync(copyAgentInstructionsEffect("Answer clearly"));

Signature

declare const copyAgentInstructionsEffect: (
  value: unknown,
) => Effect.Effect<AgentInstructions, AgentDefinitionFailure, never>;

Source

isAgentInstructions

Checks instructions for existing synchronous authoring callers.

Example

if (isAgentInstructions(value)) use(value);

Signature

declare const isAgentInstructions: (value: unknown) => value is AgentInstructions;

Source

isAgentInstructionsEffect

Checks whether a value is an agent instruction descriptor.

Example

Effect.runSync(isAgentInstructionsEffect("Answer clearly"));

Signature

declare const isAgentInstructionsEffect: (value: unknown) => Effect.Effect<boolean, never, never>;

Source

define-agent-validation.ts

Validates generic agent descriptors and selector models before assembly, rejecting native execution options with an explicit integration import diagnostic.

assertAgentDescriptor

Requires a descriptor for existing synchronous authoring callers.

Throws

TypeError when the descriptor is invalid.

Example

assertAgentDescriptor(candidate);

Signature

declare const assertAgentDescriptor: (value: unknown) => asserts value is AgentAny;

Source

assertAgentDescriptorEffect

Requires a valid agent descriptor.

Example

Effect.runSync(assertAgentDescriptorEffect(agent));

Signature

declare const assertAgentDescriptorEffect: (
  value: unknown,
) => Effect.Effect<void, AgentDefinitionFailure, never>;

Source

isAgentDescriptor

Checks a descriptor for existing synchronous authoring callers.

Example

if (isAgentDescriptor(candidate)) use(candidate);

Signature

declare const isAgentDescriptor: (value: unknown) => value is AgentAny;

Source

isAgentDescriptorEffect

Checks the complete runtime shape of an agent descriptor.

Example

Effect.runSync(isAgentDescriptorEffect(candidate));

Signature

declare const isAgentDescriptorEffect: (value: unknown) => Effect.Effect<boolean, never, never>;

Source

normalizeAgentModel

Normalizes a model for existing synchronous authoring callers.

Throws

The original invalid selector error.

Example

const model = normalizeAgentModel("openai:gpt");

Signature

declare const normalizeAgentModel: (value: string | undefined) => string | undefined;

Source

normalizeAgentModelEffect

Normalizes the selector of a string model definition.

Example

Effect.runSync(normalizeAgentModelEffect("openai:gpt"));

Signature

declare const normalizeAgentModelEffect: (
  value: string | undefined,
) => Effect.Effect<string | undefined, AgentDefinitionFailure, never>;

Source

define-agent.ts

Builds plain agent descriptors without loading an execution SDK. The compiler selects native execution when an application actually declares agents.

defineAgent

Defines an SDK-independent agent using validated schemas and RELKIT tool references.

Throws

The original authoring validation or identity error.

Example

import { defineAgent } from "@relkit/app/agents";
import { z } from "@relkit/app/schema";

const support = defineAgent({
  id: "support",
  input: z.object({ message: z.string() }),
  output: z.object({ answer: z.string() }),
  instructions: "Reply briefly.",
  tools: [],
  limits: { maxSteps: 4, maxToolCalls: 2, timeoutMs: 30_000 },
});
void support;

Signature

declare const defineAgent: <
  const Id extends string,
  const InputSchema extends StandardSchemaV1,
  const OutputSchema extends StandardSchemaV1,
  const Tools extends readonly ToolRefAny[],
>(
  options: DefineAgentOptions<Id, InputSchema, OutputSchema, Tools>,
) => AgentDescriptor<
  Id,
  InferInput<InputSchema>,
  InferOutput<OutputSchema>,
  InputSchema,
  OutputSchema,
  Tools
>;

Source

Since v0.4.0

Backend and frontend example

This SDK-independent factory describes the client contract. The runnable example below uses defineAgent from @relkit/langchain to supply native execution; see agent setup for the required integration and runtime bindings.

Backend — these maintained files define the operation used by the frontend below.

/** Runs an offline greeting agent with RELKIT/native tools, todo middleware and public state observation. */
import { defineAgent } from "@relkit/langchain";
import { z } from "@relkit/app/schema";
import { FakeToolCallingModel, todoListMiddleware, tool } from "langchain";
import lookup from "@app/services/hello/tools/lookup.tool.js";

export const uppercase = tool(async ({ text }: { readonly text: string }) => text.toUpperCase(), {
  name: "uppercase",
  description: "Uppercase text without leaving the process",
  schema: z.object({ text: z.string() }),
});

export default defineAgent({
  id: "hello.assistant",

  input: z.object({ message: z.string().min(1) }),
  output: z.object({ answer: z.string() }),

  model: new FakeToolCallingModel({
    toolCalls: [
      [
        {
          name: "write_todos",
          args: { todos: [{ content: "Answer the greeting", status: "completed" }] },
          id: "todo-1",
        },
      ],
      [
        {
          name: "relkit_output",
          args: { value: { answer: "Hello from the offline LangChain model." } },
          id: "output-1",
        },
      ],
    ],
  }),
  instructions: "Answer greeting questions with the available tools.",
  tools: [lookup, uppercase],
  middleware: [todoListMiddleware()],
  stateProfile: "default",
  client: {
    public: true,
    state: ["todos"],
    events: { notice: z.object({ message: z.string() }) },
  },
  chat: { input: "message", output: "answer" },
  controls: ["stop"],

  limits: {
    maxSteps: 4,
    maxToolCalls: 4,
    timeoutMs: 10_000,
  },
});

Frontend

After frontend setup and pulling the greeting agent’s contract, render this component under the provider. Supply a stable business threadId owned by your application, such as the ID of the conversation the user opened:

"use client";

/** Sends one greeting to the documented hello.assistant agent and observes its typed answer. */
import { useAgent, useRelkitClient } from "@relkit/client/react";
import { useState } from "react";

/** Keeps the application-owned thread identity stable across rendering and observation.
 * @param props - Authorized conversation identity retained by the application.
 * @returns A greeting action, the observed answer, and explicit submission failure. */
export function Assistant({ threadId }: { readonly threadId: string }) {
  const { status } = useRelkitClient();
  const assistant = useAgent("hello.assistant");
  const [failure, setFailure] = useState("");

  /** Submits once and preserves uncertain outcomes for explicit recovery.
   * @returns Completion after acceptance or displaying the failure. */
  async function sendGreeting() {
    try {
      await assistant.send("Hello, RELKIT!", { threadId });
    } catch (error) {
      setFailure(String(error));
    }
  }

  return (
    <section>
      <button
        disabled={status !== "ready" || assistant.status !== "idle" || failure !== ""}
        onClick={sendGreeting}
      >
        Say hello
      </button>
      <p role="status">{assistant.output?.answer ?? assistant.status}</p>
      {failure && <p role="alert">{failure}. Check this thread before submitting again.</p>}
    </section>
  );
}

This is the same hello.assistant declaration: client.public exposes it, chat.input: "message" makes send accept a string, and chat.output: "answer" selects its typed answer. Mounting useAgent does not start a run. The backend owns models, credentials, tools, and authorization.

Reference: useAgent. Continue with streaming and controls or thread recovery.

“./define-agent.types.js” (namespace export)

Re-exports all named exports from the “./define-agent.types.js” module.

Signature

export * from "./define-agent.types.js";

Source

AgentChatMapping

Signature

declare const AgentChatMapping: AgentChatMapping;

Source

AgentClientPolicy

Signature

declare const AgentClientPolicy: AgentClientPolicy<Guard, StateKey, Events>;

Source

AgentControl

Signature

declare const AgentControl: AgentControl;

Source

assertAgentDescriptor

Signature

declare const assertAgentDescriptor: (value: unknown) => asserts value is AgentAny;

Source

copyAgentLimits

Signature

declare const copyAgentLimits: (value: unknown) => AgentLimits;

Source

copyAgentLimitsEffect

Signature

declare const copyAgentLimitsEffect: (
  value: unknown,
) => Effect.Effect<
  Readonly<{ maxSteps: number; maxToolCalls: number; timeoutMs: number }>,
  AgentDefinitionFailure,
  never
>;

Source

defineAgentEffect

Validates plain authoring inputs and preserves source identity generation.

Signature

declare const defineAgentEffect: <
  const Id extends string,
  const InputSchema extends StandardSchemaV1,
  const OutputSchema extends StandardSchemaV1,
  const Tools extends readonly ToolRefAny[],
>(
  options: DefineAgentOptions<Id, InputSchema, OutputSchema, Tools>,
) => Effect.Effect<
  AgentDescriptor<
    Id,
    InferInput<InputSchema>,
    InferOutput<OutputSchema>,
    InputSchema,
    OutputSchema,
    Tools
  >,
  AgentDefinitionFailure,
  never
>;

Source

isAgentDescriptor

Signature

declare const isAgentDescriptor: (value: unknown) => value is AgentAny;

Source

define-agent.types.ts

Defines the SDK-independent agent contract used by generic application authoring. Native model, middleware, graph and persistence APIs are owned by @relkit/langchain.

AgentDescriptor (interface)

Plain agent metadata; no execution SDK is evaluated by this declaration.

Signature

export interface AgentDescriptor<
  Id extends string,
  Input,
  Output,
  InputSchema extends StandardSchemaV1 = StandardSchemaV1,
  OutputSchema extends StandardSchemaV1 = StandardSchemaV1,
  Tools extends readonly ToolRefAny[] = readonly ToolRefAny[],
>
  extends DescriptorBase<"agent", Id>, AgentRef<Id, InputSchema, OutputSchema> {
  readonly model?: string;
  readonly instructions: AgentInstructions;
  readonly tools: AgentToolReferences<Tools>;
  readonly middleware: readonly [];
  readonly limits: AgentLimits;
  readonly stateProfile?: string;
  readonly client?: AgentClientPolicy<NonNullable<AgentClientPolicy["authorize"]>, never>;
  readonly chat?: AgentChatMapping;
  readonly controls?: readonly AgentControl[];
  readonly clientContract: AgentClientContractMetadata;
}

Source

AgentInstructions (type alias)

Signature

type AgentInstructions = string | PromptTemplate | PromptInstructions;

Source

AgentLimits (interface)

Limits retained by the selected execution integration.

Signature

export interface AgentLimits {
  readonly maxSteps: number;
  readonly maxToolCalls: number;
  readonly timeoutMs: number;
}

Source

AgentToolReferences (type alias)

Handler-free tool identities retaining each authored literal reference.

Signature

type AgentToolReferences<Tools extends readonly ToolRefAny[]> = {
  readonly [Index in keyof Tools]: Pick<Tools[Index], "ref">;
};

Source

DefineAgentOptions (interface)

Generic agent inputs; native capabilities use the explicit integration facade.

Signature

export interface DefineAgentOptions<
  Id extends string,
  InputSchema extends StandardSchemaV1,
  OutputSchema extends StandardSchemaV1,
  Tools extends readonly ToolRefAny[],
> extends DescriptorMetadata {
  readonly id?: Id;
  readonly input: InputSchema;
  readonly output: OutputSchema;
  readonly model?: string;
  readonly instructions: AgentInstructions;
  readonly tools: Tools;
  readonly middleware?: readonly [];
  readonly limits: AgentLimits;
  readonly stateProfile?: string;
  readonly client?: AgentClientPolicy<NonNullable<AgentClientPolicy["authorize"]>, never>;
  readonly chat?: AgentChatMapping;
  readonly controls?: readonly AgentControl[];
}

Source

PromptInstructions (interface)

Signature

export interface PromptInstructions {
  readonly kind: "prompt";
  readonly id: string;
  readonly ref: { readonly kind: "prompt"; readonly id: string };
  readonly value: string | readonly string[];
}

Source

PromptTemplate (interface)

Signature

export interface PromptTemplate {
  readonly template: string;
  readonly variables?: readonly string[];
}

Source

generated-function-error.ts

GeneratedAgentFunctionFailure (class)

Tagged invalid generated function identity or executor.

Signature

declare class GeneratedAgentFunctionFailure

Source

generatedAgentFunctionFailure

Preserves an invalid generated function error for Effect callers.

Example

generatedAgentFunctionFailure(new TypeError("invalid"));

Signature

declare const generatedAgentFunctionFailure: (cause: unknown) => GeneratedAgentFunctionFailure;

Source

generated-function.ts

“./generated-function.types.js” (namespace export)

Re-exports all named exports from the “./generated-function.types.js” module.

Signature

export * from "./generated-function.types.js";

Source

GENERATED_AGENT_FUNCTION_PREFIX

Signature

declare const GENERATED_AGENT_FUNCTION_PREFIX: "relkit.agent.";

Source

GENERATED_AGENT_FUNCTION_SUFFIX

Signature

declare const GENERATED_AGENT_FUNCTION_SUFFIX: ".invoke";

Source

GeneratedAgentFunctionUnboundError (class)

Raised when a generated identity is registered before the agent runtime binds an executor.

Signature

declare class GeneratedAgentFunctionUnboundError {
  constructor(functionId: string);
}

Source

code (property)

Signature

readonly code: "RELKIT_GENERATED_FUNCTION_UNBOUND"

Source

createGeneratedAgentFunction

Creates a marked handler for existing synchronous callers.

Throws

The original invalid identity or executor error.

Example

createGeneratedAgentFunction("support", executor);

Signature

declare const createGeneratedAgentFunction: (
  agentId: unknown,
  executor?: GeneratedAgentExecutor,
) => GeneratedAgentFunction;

Source

createGeneratedAgentFunctionEffect

Creates a marked function handler for a compiler-generated agent identity.

Example

Effect.runSync(createGeneratedAgentFunctionEffect("support", executor));

Signature

declare const createGeneratedAgentFunctionEffect: (
  agentId: unknown,
  executor?: GeneratedAgentExecutor | undefined,
) => Effect.Effect<GeneratedAgentFunction, GeneratedAgentFunctionFailure, never>;

Source

generatedAgentFunctionId

Derives the generated function ID for existing synchronous callers.

Throws

The original invalid identity error.

Example

generatedAgentFunctionId("support");

Signature

declare const generatedAgentFunctionId: (agentId: unknown) => string;

Source

generatedAgentFunctionIdEffect

Derives the stable generated function ID without using the source path.

Example

Effect.runSync(generatedAgentFunctionIdEffect("support"));

Signature

declare const generatedAgentFunctionIdEffect: (
  agentId: unknown,
) => Effect.Effect<string, GeneratedAgentFunctionFailure, never>;

Source

isGeneratedAgentFunction

Checks a generated marker for existing synchronous callers.

Example

if (isGeneratedAgentFunction(candidate)) use(candidate);

Signature

declare const isGeneratedAgentFunction: (value: unknown) => value is GeneratedAgentFunction;

Source

isGeneratedAgentFunctionEffect

Checks whether a callable has a valid generated agent marker.

Example

Effect.runSync(isGeneratedAgentFunctionEffect(candidate));

Signature

declare const isGeneratedAgentFunctionEffect: (
  value: unknown,
) => Effect.Effect<boolean, never, never>;

Source

generated-function.types.ts

GeneratedAgentExecutor (type alias)

Optional executor bound when the generated function is registered.

Signature

type GeneratedAgentExecutor = (input: unknown, context: unknown) => MaybePromise<unknown>;

Source

GeneratedAgentFunction (type alias)

Callable handler with a compiler-visible agent identity marker.

Signature

type GeneratedAgentFunction = ((...arguments_: readonly unknown[]) => MaybePromise<unknown>) &
  GeneratedAgentFunctionMarker;

Source

GeneratedAgentFunctionMarker (interface)

Serializable identity attached to an agent-generated function.

Signature

export interface GeneratedAgentFunctionMarker {
  readonly generated: true;
  readonly generatedBy: "agent";
  readonly agentId: string;
  readonly functionId: string;
}

Source

index.ts

Exposes generic agent authoring, client events and state contracts. Native models, graphs, middleware and execution are selected through @relkit/langchain.

“./agent-client.js” (namespace export)

Re-exports all named exports from the “./agent-client.js” module.

Signature

export * from "./agent-client.js";

Source

“./agent-telemetry.js” (namespace export)

Re-exports all named exports from the “./agent-telemetry.js” module.

Signature

export * from "./agent-telemetry.js";

Source

“./approval.js” (namespace export)

Re-exports all named exports from the “./approval.js” module.

Signature

export * from "./approval.js";

Source

“./client-events.js” (namespace export)

Re-exports all named exports from the “./client-events.js” module.

Signature

export * from "./client-events.js";

Source

“./define-agent.js” (namespace export)

Re-exports all named exports from the “./define-agent.js” module.

Signature

export * from "./define-agent.js";

Source

“./generated-function.js” (namespace export)

Re-exports all named exports from the “./generated-function.js” module.

Signature

export * from "./generated-function.js";

Source

“./model-selection.js” (namespace export)

Re-exports all named exports from the “./model-selection.js” module.

Signature

export * from "./model-selection.js";

Source

“./observability.js” (namespace export)

Re-exports all named exports from the “./observability.js” module.

Signature

export * from "./observability.js";

Source

“./runtime-contract.types.js” (namespace export)

Re-exports all named exports from the “./runtime-contract.types.js” module.

Signature

export * from "./runtime-contract.types.js";

Source

“./runtime-events.js” (namespace export)

Re-exports all named exports from the “./runtime-events.js” module.

Signature

export * from "./runtime-events.js";

Source

“./state-control-requests.types.js” (namespace export)

Re-exports all named exports from the “./state-control-requests.types.js” module.

Signature

export * from "./state-control-requests.types.js";

Source

“./state-provider.types.js” (namespace export)

Re-exports all named exports from the “./state-provider.types.js” module.

Signature

export * from "./state-provider.types.js";

Source

“./state-receipts.types.js” (namespace export)

Re-exports all named exports from the “./state-receipts.types.js” module.

Signature

export * from "./state-receipts.types.js";

Source

“./state-thread-requests.types.js” (namespace export)

Re-exports all named exports from the “./state-thread-requests.types.js” module.

Signature

export * from "./state-thread-requests.types.js";

Source

“./state.types.js” (namespace export)

Re-exports all named exports from the “./state.types.js” module.

Signature

export * from "./state.types.js";

Source

“./thread-transition.js” (namespace export)

Re-exports all named exports from the “./thread-transition.js” module.

Signature

export * from "./thread-transition.js";

Source

model-selection-core.ts

normalizeModelSelectorValue

Canonicalizes a selector after validating its syntax.

Throws

ModelSelectionError for malformed selectors.

Example

normalizeModelSelectorValue("openai:gpt");

Signature

declare const normalizeModelSelectorValue: (value: unknown) => string | undefined;

Source

parseModelProviderConfigurationValue

Validates and freezes provider defaults.

Throws

ModelSelectionError for missing or malformed settings.

Example

parseModelProviderConfigurationValue(config);

Signature

declare const parseModelProviderConfigurationValue: (value: unknown) => ModelProviderConfiguration;

Source

resolveModelSelectorValue

Selects a provider and model from validated configuration.

Throws

ModelSelectionError when a provider or model is unavailable.

Example

resolveModelSelectorValue("openai", config);

Signature

declare const resolveModelSelectorValue: (
  selector: unknown,
  configuration: ModelProviderConfiguration,
) => ResolvedModelSelection;

Source

model-selection-error.ts

ModelSelectionEffectError (class)

Recoverable Effect failure for invalid model selection.

Signature

declare class ModelSelectionEffectError

Source

ModelSelectionError (class)

Compatible synchronous error for invalid model selection.

Example

throw new ModelSelectionError("RELKIT_MODEL_SELECTOR_INVALID", "Invalid selector");

Signature

declare class ModelSelectionError { constructor(
    readonly code: ModelSelectionErrorCode,
    message: string,
  ) }

Source

name (property)

Signature

readonly name: "ModelSelectionError"

Source

modelSelectionEffectError

Captures a selector error for Effect recovery and public compatibility.

Example

modelSelectionEffectError(new ModelSelectionError("RELKIT_MODEL_SELECTOR_INVALID", "Invalid"));

Signature

declare const modelSelectionEffectError: (cause: unknown) => ModelSelectionEffectError;

Source

model-selection.ts

“./model-selection.types.js” (namespace export)

Re-exports all named exports from the “./model-selection.types.js” module.

Signature

export * from "./model-selection.types.js";

Source

ModelSelectionEffectError

Signature

declare const ModelSelectionEffectError: typeof ModelSelectionEffectError;

Source

ModelSelectionError

Signature

declare const ModelSelectionError: typeof ModelSelectionError;

Source

normalizeModelSelector

Normalizes an optional provider or provider:model selector.

Throws

ModelSelectionError for an invalid selector.

Example

normalizeModelSelector("openai:gpt");

Signature

declare const normalizeModelSelector: (value: unknown) => string | undefined;

Source

normalizeModelSelectorEffect

Normalizes an optional provider or provider:model selector.

Example

Effect.runSync(normalizeModelSelectorEffect("openai:gpt"));

Signature

declare const normalizeModelSelectorEffect: (
  value: unknown,
) => Effect.Effect<string | undefined, ModelSelectionEffectError, never>;

Source

parseModelProviderConfiguration

Parses and validates configured model providers.

Throws

ModelSelectionError for missing or invalid settings.

Example

parseModelProviderConfiguration(config);

Signature

declare const parseModelProviderConfiguration: (value: unknown) => ModelProviderConfiguration;

Source

parseModelProviderConfigurationEffect

Parses and validates configured model providers.

Example

Effect.runSync(parseModelProviderConfigurationEffect(config));

Signature

declare const parseModelProviderConfigurationEffect: (
  value: unknown,
) => Effect.Effect<ModelProviderConfiguration, ModelSelectionEffectError, never>;

Source

resolveModelSelector

Resolves a selector against provider defaults.

Throws

ModelSelectionError for missing providers or defaults.

Example

resolveModelSelector("openai", config);

Signature

declare const resolveModelSelector: (
  selector: unknown,
  configuration: ModelProviderConfiguration,
) => ResolvedModelSelection;

Source

resolveModelSelectorEffect

Resolves a selector against provider defaults.

Example

Effect.runSync(resolveModelSelectorEffect("openai", config));

Signature

declare const resolveModelSelectorEffect: (
  selector: unknown,
  configuration: ModelProviderConfiguration,
) => Effect.Effect<ResolvedModelSelection, ModelSelectionEffectError, never>;

Source

model-selection.types.ts

Stable error codes for model selector and provider configuration failures.

ModelProviderConfiguration (interface)

Normalized provider defaults used to resolve a model selector.

Signature

export interface ModelProviderConfiguration {
  readonly defaultProvider: string;
  readonly defaultModel: string;
  readonly providers: Readonly<Record<string, { readonly defaultModel?: string }>>;
}

Source

ModelSelectionErrorCode (type alias)

Stable error codes for model selector and provider configuration failures.

Signature

type ModelSelectionErrorCode =
  | "RELKIT_MODEL_PROVIDER_CONFIGURATION_INVALID"
  | "RELKIT_MODEL_SELECTOR_INVALID"
  | "RELKIT_MODEL_PROVIDER_UNKNOWN"
  | "RELKIT_MODEL_PROVIDER_DEFAULT_MISSING";

Source

ResolvedModelSelection (interface)

Selected provider, model, and combined stable identifier.

Signature

export interface ResolvedModelSelection {
  readonly provider: string;
  readonly model: string;
  readonly id: string;
}

Source

observability.ts

“./observability.types.js” (namespace export)

Re-exports all named exports from the “./observability.types.js” module.

Signature

export * from "./observability.types.js";

Source

AGENT_OBSERVABILITY_PROTOCOL

Signature

declare const AGENT_OBSERVABILITY_PROTOCOL: "relkit.observability.hooks";

Source

AGENT_OBSERVABILITY_VERSION

Signature

declare const AGENT_OBSERVABILITY_VERSION: 1;

Source

AgentCapturePolicy

Signature

declare const AgentCapturePolicy: AgentCapturePolicy;

Source

AgentCapturePolicyError

Signature

declare const AgentCapturePolicyError: typeof AgentCapturePolicyError;

Source

AgentCaptureRecord

Signature

declare const AgentCaptureRecord: AgentCaptureRecord;

Source

AgentSpanCapture

Signature

declare const AgentSpanCapture: AgentSpanCapture;

Source

captureAgentContent

Signature

declare const captureAgentContent: (
  value: unknown,
  policy: AgentCapturePolicy,
) => AgentCaptureRecord | undefined;

Source

captureAgentContentEffect

Signature

declare const captureAgentContentEffect: (
  value: unknown,
  policy: AgentCapturePolicy,
) => Effect.Effect<AgentCaptureRecord | undefined, never, never>;

Source

createAgentCapturePolicy

Signature

declare const createAgentCapturePolicy: (
  value: AgentCapturePolicy | undefined,
) => AgentCapturePolicy;

Source

createAgentCapturePolicyEffect

Signature

declare const createAgentCapturePolicyEffect: (
  value: AgentCapturePolicy | undefined,
) => Effect.Effect<AgentCapturePolicy, AgentCapturePolicyError, never>;

Source

createAgentSpanCapture

Signature

declare const createAgentSpanCapture: (
  input: AgentCaptureRecord | undefined,
  output: AgentCaptureRecord | undefined,
) => AgentSpanCapture | undefined;

Source

createAgentSpanCaptureEffect

Signature

declare const createAgentSpanCaptureEffect: (
  input: AgentCaptureRecord | undefined,
  output: AgentCaptureRecord | undefined,
) => Effect.Effect<
  Readonly<{ output?: AgentCaptureRecord; input?: AgentCaptureRecord }> | undefined,
  never,
  never
>;

Source

emitAgentEdge

Emits an observed relationship for existing synchronous tracing callers.

Example

emitAgentEdge(hooks, { relationship: "uses-tool", from: "agent", to: "tool" });

Signature

declare const emitAgentEdge: (
  hooks: AgentRuntimeHooks | undefined,
  edge: AgentObservedEdge,
) => void;

Source

emitAgentEdgeEffect

Best-effort emission of an observed relationship. The sink is intentionally detached because the caller’s synchronous tracing path cannot await it.

Example

Effect.runSync(emitAgentEdgeEffect(hooks, edge));

Signature

declare const emitAgentEdgeEffect: (
  hooks: AgentRuntimeHooks | undefined,
  edge: AgentObservedEdge,
) => Effect.Effect<void, never, never>;

Source

observability.types.ts

AgentEdgeRelationship (type alias)

Relationships reported by an agent’s runtime hooks.

Example

const relationship: AgentEdgeRelationship = "uses-tool";

Signature

type AgentEdgeRelationship =
  | "targets-function"
  | "calls-function"
  | "enqueues-job"
  | "publishes-event"
  | "listens-to-event"
  | "uses-bucket"
  | "uses-cache"
  | "invokes-agent"
  | "exposes-as-tool"
  | "uses-tool"
  | "uses-provider-profile";

Source

AgentObservabilitySink (interface)

Optional external sink for observed agent relationships.

Example

const sink: AgentObservabilitySink = { emit: (event) => send(event) };

Signature

export interface AgentObservabilitySink {
  /** Accepts a public relationship event.
   * @param event - Versioned observed edge.
   * @returns Completion of best-effort sink delivery.
   * @example sink.emit({ protocol: "relkit.observability.hooks", version: 1, type: "edge.observed", edge });
   */
  readonly emit: (event: {
    readonly protocol: typeof AGENT_OBSERVABILITY_PROTOCOL;
    readonly version: typeof AGENT_OBSERVABILITY_VERSION;
    readonly type: "edge.observed";
    readonly edge: AgentObservedEdge;
  }) => MaybePromise<void>;
}

Source

AgentObservedEdge (interface)

Directed relationship between two stable descriptors.

Example

const edge: AgentObservedEdge = { relationship: "uses-tool", from: "agent", to: "tool" };

Signature

export interface AgentObservedEdge {
  readonly relationship: AgentEdgeRelationship;
  readonly from: string;
  readonly to: string;
}

Source

AgentRuntimeHooks (interface)

Optional synchronous and asynchronous relationship observers.

Example

const hooks: AgentRuntimeHooks = { onObservedEdge: console.log };

Signature

export interface AgentRuntimeHooks {
  /** Receives one immutable edge synchronously.
   * @param edge - Observed relationship.
   * @returns Nothing.
   * @example hooks.onObservedEdge?.(edge);
   */
  readonly onObservedEdge?: (edge: AgentObservedEdge) => void;
  readonly observability?: AgentObservabilitySink;
}

Source

runtime-contract.types.ts

Carries SDK-independent conversation, approval and content callbacks between native execution and transports; callbacks retain the caller’s signal ownership.

AgentApprovalHandler (type alias)

Resolves a pending tool approval for an invocation.

Signature

type AgentApprovalHandler = (
  approval: import("./approval.js").PendingApproval,
) => MaybePromise<ApprovalDecision>;

Source

AgentContentSink (interface)

Sends agent output and events to the surrounding runtime.

Signature

export interface AgentContentSink {
  readonly emitOutput: (value: unknown, signal: AbortSignal) => MaybePromise<void>;
  readonly finishOutput?: (signal: AbortSignal) => MaybePromise<void>;
  readonly progressSinkForTool?: (tool: {
    readonly toolCallId: string;
    readonly toolId: string;
  }) => import("@relkit/invocation").ProgressSink;
  readonly emitTool?: (
    value: {
      readonly toolCallId: string;
      readonly toolId: string;
      readonly state: import("./state.types.js").ToolPartState;
      readonly value?: unknown;
    },
    signal: AbortSignal,
  ) => MaybePromise<void>;
  readonly emitEvent?: (
    value: import("./runtime-events.js").AgentExecutionEvent,
    signal: AbortSignal,
  ) => MaybePromise<void>;
  readonly emitMessage?: (
    value: import("@relkit/contracts").BrowserMessage,
    signal: AbortSignal,
  ) => MaybePromise<void>;
  readonly emitWaiting?: (
    value: Omit<import("./state.types.js").AgentWaitingState, "revision" | "runId">,
    signal: AbortSignal,
  ) => MaybePromise<void>;
}

Source

AgentConversationMessage (interface)

One user or assistant message in a native agent conversation.

Signature

export interface AgentConversationMessage {
  readonly role: "user" | "assistant";
  readonly content: string;
}

Source

AgentSteeringSource (interface)

Supplies queued steering messages to a running agent.

Signature

export interface AgentSteeringSource {
  readonly drain: () => MaybePromise<readonly string[]>;
}

Source

runtime-events.ts

AgentExecutionEvent

Signature

declare const AgentExecutionEvent: AgentExecutionEvent;

Source

AgentExecutionSnapshot

Signature

declare const AgentExecutionSnapshot: AgentExecutionSnapshot;

Source

state-control-requests.types.ts

Shared state contracts live below execution and provider implementations.

AcceptControlRequest

Signature

declare const AcceptControlRequest: AcceptControlRequest;

Source

AdmitContinuationRequest

Signature

declare const AdmitContinuationRequest: AdmitContinuationRequest;

Source

ClaimControlRequest

Signature

declare const ClaimControlRequest: ClaimControlRequest;

Source

ContinuationIdentity

Signature

declare const ContinuationIdentity: ContinuationIdentity;

Source

ControlLimits

Signature

declare const ControlLimits: ControlLimits;

Source

ControlPage

Signature

declare const ControlPage: ControlPage;

Source

LookupContinuationReceiptRequest

Signature

declare const LookupContinuationReceiptRequest: LookupContinuationReceiptRequest;

Source

LookupControlReceiptRequest

Signature

declare const LookupControlReceiptRequest: LookupControlReceiptRequest;

Source

MarkControlEffectStartedRequest

Signature

declare const MarkControlEffectStartedRequest: MarkControlEffectStartedRequest;

Source

ReadControlsRequest

Signature

declare const ReadControlsRequest: ReadControlsRequest;

Source

RecoverAbandonedControlRequest

Signature

declare const RecoverAbandonedControlRequest: RecoverAbandonedControlRequest;

Source

RenewControlClaimRequest

Signature

declare const RenewControlClaimRequest: RenewControlClaimRequest;

Source

SettleControlRequest

Signature

declare const SettleControlRequest: SettleControlRequest;

Source

WaitForControlsRequest

Signature

declare const WaitForControlsRequest: WaitForControlsRequest;

Source

state-provider.types.ts

Shared state contracts live below execution and provider implementations.

AgentStateProvider

Signature

declare const AgentStateProvider: AgentStateProvider;

Source

state-receipts.types.ts

Shared state contracts live below execution and provider implementations.

AcceptRunReceipt

Signature

declare const AcceptRunReceipt: AcceptRunReceipt;

Source

CompletionReceipt

Signature

declare const CompletionReceipt: CompletionReceipt;

Source

ContinuationReceipt

Signature

declare const ContinuationReceipt: ContinuationReceipt;

Source

ContinuationReceiptLookup

Signature

declare const ContinuationReceiptLookup: ContinuationReceiptLookup;

Source

ControlReceipt

Signature

declare const ControlReceipt: ControlReceipt;

Source

ControlReceiptLookup

Signature

declare const ControlReceiptLookup: ControlReceiptLookup;

Source

CreateThreadReceipt

Signature

declare const CreateThreadReceipt: CreateThreadReceipt;

Source

InterruptionReceipt

Signature

declare const InterruptionReceipt: InterruptionReceipt;

Source

JournalReceipt

Signature

declare const JournalReceipt: JournalReceipt;

Source

RunReceiptLookup

Signature

declare const RunReceiptLookup: RunReceiptLookup;

Source

SuspensionReceipt

Signature

declare const SuspensionReceipt: SuspensionReceipt;

Source

state-thread-requests.types.ts

Shared state contracts live below execution and provider implementations.

AcceptRunRequest

Signature

declare const AcceptRunRequest: AcceptRunRequest;

Source

AgentStateLimits

Signature

declare const AgentStateLimits: AgentStateLimits;

Source

AppendJournalRequest

Signature

declare const AppendJournalRequest: AppendJournalRequest;

Source

ClaimRunRequest

Signature

declare const ClaimRunRequest: ClaimRunRequest;

Source

CompleteRunRequest

Signature

declare const CompleteRunRequest: CompleteRunRequest;

Source

CreateThreadRequest

Signature

declare const CreateThreadRequest: CreateThreadRequest;

Source

InterruptOwnedRunRequest

Signature

declare const InterruptOwnedRunRequest: InterruptOwnedRunRequest;

Source

JournalPage

Signature

declare const JournalPage: JournalPage;

Source

ListThreadsRequest

Signature

declare const ListThreadsRequest: ListThreadsRequest;

Source

LoadThreadRequest

Signature

declare const LoadThreadRequest: LoadThreadRequest;

Source

LookupRunReceiptRequest

Signature

declare const LookupRunReceiptRequest: LookupRunReceiptRequest;

Source

ReadJournalRequest

Signature

declare const ReadJournalRequest: ReadJournalRequest;

Source

ReadSnapshotHistoryRequest

Signature

declare const ReadSnapshotHistoryRequest: ReadSnapshotHistoryRequest;

Source

RenewRunClaimRequest

Signature

declare const RenewRunClaimRequest: RenewRunClaimRequest;

Source

SnapshotHistoryPage

Signature

declare const SnapshotHistoryPage: SnapshotHistoryPage;

Source

SuspendRunRequest

Signature

declare const SuspendRunRequest: SuspendRunRequest;

Source

ThreadList

Signature

declare const ThreadList: ThreadList;

Source

WaitForJournalRequest

Signature

declare const WaitForJournalRequest: WaitForJournalRequest;

Source

state.types.ts

AgentObservation

Signature

declare const AgentObservation: AgentObservation;

Source

AgentProgressScope

Signature

declare const AgentProgressScope: AgentProgressScope;

Source

AgentRequestScope

Signature

declare const AgentRequestScope: AgentRequestScope;

Source

AgentWaitingRequest

Signature

declare const AgentWaitingRequest: AgentWaitingRequest;

Source

AgentWaitingState

Signature

declare const AgentWaitingState: AgentWaitingState;

Source

BrowserMessage

Signature

declare const BrowserMessage: BrowserMessage;

Source

BrowserMessagePart

Signature

declare const BrowserMessagePart: BrowserMessagePart;

Source

ControlClaim

Signature

declare const ControlClaim: ControlClaim;

Source

ControlEffectOutcome

Signature

declare const ControlEffectOutcome: ControlEffectOutcome;

Source

ControlRecord

Signature

declare const ControlRecord: ControlRecord;

Source

ControlStatus

Signature

declare const ControlStatus: ControlStatus;

Source

ExecutionClaim

Signature

declare const ExecutionClaim: ExecutionClaim;

Source

JournalCheckpoint

Signature

declare const JournalCheckpoint: JournalCheckpoint;

Source

JournalRecord

Signature

declare const JournalRecord: JournalRecord;

Source

RunOwner

Signature

declare const RunOwner: RunOwner;

Source

RunStatus

Signature

declare const RunStatus: RunStatus;

Source

StoredApproval

Signature

declare const StoredApproval: StoredApproval;

Source

StoredRun

Signature

declare const StoredRun: StoredRun;

Source

StoredRunRouting

Signature

declare const StoredRunRouting: StoredRunRouting;

Source

StoredThread

Signature

declare const StoredThread: StoredThread;

Source

ThreadListItem

Signature

declare const ThreadListItem: ThreadListItem;

Source

ThreadSnapshot

Signature

declare const ThreadSnapshot: ThreadSnapshot;

Source

ThreadStatus

Signature

declare const ThreadStatus: ThreadStatus;

Source

ToolPartState

Signature

declare const ToolPartState: ToolPartState;

Source

thread-transition.ts

Exposes the shared durable thread transition table through the existing agent telemetry boundary; provider implementations call the lower contracts owner.

AgentTransitionError

Signature

declare const AgentTransitionError: AgentTransitionError;

Source

ThreadAction

Signature

declare const ThreadAction: ThreadAction;

Source

ThreadTransition

Signature

declare const ThreadTransition: ThreadTransition;

Source

decideThreadTransition

Decides a thread action for synchronous framework callers.

Signature

declare const decideThreadTransition: (
  status: ThreadStatus,
  action: ThreadAction,
) => ThreadTransition;

Source

decideThreadTransitionEffect

Observes a shared thread decision without duplicating its state machine.

Signature

declare const decideThreadTransitionEffect: (
  status: ThreadStatus,
  action: ThreadAction,
) => Effect.Effect<ThreadTransition, never, never>;

Source

thread-transition.types.ts

Shared state contracts live below execution and provider implementations.

AgentTransitionError

Signature

declare const AgentTransitionError: AgentTransitionError;

Source

ThreadAction

Signature

declare const ThreadAction: ThreadAction;

Source

ThreadTransition

Signature

declare const ThreadTransition: ThreadTransition;

Source