Types Reference

March 6, 2026 ยท View on GitHub

This document provides a reference for all TypeScript types exported by KODE SDK.


Message Types

MessageRole

type MessageRole = 'user' | 'assistant' | 'system';

Message

interface Message {
  role: MessageRole;
  content: ContentBlock[];
  metadata?: MessageMetadata;
}

MessageMetadata

interface MessageMetadata {
  content_blocks?: ContentBlock[];
  transport?: 'provider' | 'text' | 'omit';
}

Content Blocks

ContentBlock

Union type for all content block types.

type ContentBlock =
  | { type: 'text'; text: string }
  | { type: 'image_url'; image_url: { url: string } }
  | { type: 'tool_use'; id: string; name: string; input: any; meta?: Record<string, any> }
  | { type: 'tool_result'; tool_use_id: string; content: any; is_error?: boolean }
  | ReasoningContentBlock
  | ImageContentBlock
  | AudioContentBlock
  | FileContentBlock;

ReasoningContentBlock

type ReasoningContentBlock = {
  type: 'reasoning';
  reasoning: string;
  meta?: Record<string, any>;
};

ImageContentBlock

type ImageContentBlock = {
  type: 'image';
  url?: string;
  file_id?: string;
  base64?: string;
  mime_type?: string;
  meta?: Record<string, any>;
};

AudioContentBlock

type AudioContentBlock = {
  type: 'audio';
  url?: string;
  file_id?: string;
  base64?: string;
  mime_type?: string;
  meta?: Record<string, any>;
};

FileContentBlock

type FileContentBlock = {
  type: 'file';
  url?: string;
  file_id?: string;
  filename?: string;
  base64?: string;
  mime_type?: string;
  meta?: Record<string, any>;
};

Agent State Types

AgentRuntimeState

type AgentRuntimeState = 'READY' | 'WORKING' | 'PAUSED';
StateDescription
READYAgent is idle and ready to receive messages
WORKINGAgent is processing a message
PAUSEDAgent is paused waiting for permission decision

BreakpointState

type BreakpointState =
  | 'READY'
  | 'PRE_MODEL'
  | 'STREAMING_MODEL'
  | 'TOOL_PENDING'
  | 'AWAITING_APPROVAL'
  | 'PRE_TOOL'
  | 'TOOL_EXECUTING'
  | 'POST_TOOL';

AgentStatus

interface AgentStatus {
  agentId: string;
  state: AgentRuntimeState;
  stepCount: number;
  lastSfpIndex: number;
  lastBookmark?: Bookmark;
  cursor: number;
  breakpoint: BreakpointState;
}

AgentInfo

interface AgentInfo {
  agentId: string;
  templateId: string;
  createdAt: string;
  lineage: string[];
  configVersion: string;
  messageCount: number;
  lastSfpIndex: number;
  lastBookmark?: Bookmark;
  breakpoint?: BreakpointState;
  metadata?: Record<string, any>;
}

Tool Call Types

ToolCallState

type ToolCallState =
  | 'PENDING'
  | 'APPROVAL_REQUIRED'
  | 'APPROVED'
  | 'EXECUTING'
  | 'COMPLETED'
  | 'FAILED'
  | 'DENIED'
  | 'SEALED';
StateDescription
PENDINGTool call received, not yet processed
APPROVAL_REQUIREDWaiting for user approval
APPROVEDApproved, ready to execute
EXECUTINGCurrently executing
COMPLETEDExecution completed successfully
FAILEDExecution failed
DENIEDUser denied the tool call
SEALEDAuto-sealed during resume

ToolCallRecord

interface ToolCallRecord {
  id: string;
  name: string;
  input: any;
  state: ToolCallState;
  approval: ToolCallApproval;
  result?: any;
  error?: string;
  isError?: boolean;
  startedAt?: number;
  completedAt?: number;
  durationMs?: number;
  createdAt: number;
  updatedAt: number;
  auditTrail: ToolCallAuditEntry[];
}

ToolCallSnapshot

type ToolCallSnapshot = Pick<
  ToolCallRecord,
  'id' | 'name' | 'state' | 'approval' | 'result' | 'error' | 'isError' | 'durationMs' | 'startedAt' | 'completedAt'
> & {
  inputPreview?: any;
  auditTrail?: ToolCallAuditEntry[];
};

ToolCallApproval

interface ToolCallApproval {
  required: boolean;
  decision?: 'allow' | 'deny';
  decidedBy?: string;
  decidedAt?: number;
  note?: string;
  meta?: Record<string, any>;
}

ToolCallAuditEntry

interface ToolCallAuditEntry {
  state: ToolCallState;
  timestamp: number;
  note?: string;
}

ToolOutcome

interface ToolOutcome {
  id: string;
  name: string;
  ok: boolean;
  content: any;
  durationMs?: number;
}

ToolCall

interface ToolCall {
  id: string;
  name: string;
  args: any;
  agentId: string;
}

ToolContext

interface ToolContext {
  agentId: string;
  sandbox: Sandbox;
  agent: any;
  services?: Record<string, any>;
  signal?: AbortSignal;
  emit?: (eventType: string, data?: any) => void;
}

Event Types

Bookmark

interface Bookmark {
  seq: number;
  timestamp: number;
}

AgentChannel

type AgentChannel = 'progress' | 'control' | 'monitor';

AgentEvent

type AgentEvent = ProgressEvent | ControlEvent | MonitorEvent;

AgentEventEnvelope

interface AgentEventEnvelope<T extends AgentEvent = AgentEvent> {
  cursor: number;
  bookmark: Bookmark;
  event: T;
}

Timeline

interface Timeline {
  cursor: number;
  bookmark: Bookmark;
  event: AgentEvent;
}

Snapshot Types

SnapshotId

type SnapshotId = string;

Snapshot

interface Snapshot {
  id: SnapshotId;
  messages: Message[];
  lastSfpIndex: number;
  lastBookmark: Bookmark;
  createdAt: string;
  metadata?: Record<string, any>;
}

Hook Types

HookDecision

type HookDecision =
  | { decision: 'ask'; meta?: any }
  | { decision: 'deny'; reason?: string; toolResult?: any }
  | { result: any }
  | void;

PostHookResult

type PostHookResult =
  | void
  | { update: Partial<ToolOutcome> }
  | { replace: ToolOutcome };

Configuration Types

PermissionConfig

interface PermissionConfig {
  mode: PermissionDecisionMode;
  requireApprovalTools?: string[];
  allowTools?: string[];
  denyTools?: string[];
  metadata?: Record<string, any>;
}

PermissionDecisionMode

type PermissionDecisionMode = 'auto' | 'approval' | 'readonly' | (string & {});
ModeDescription
autoAutomatically allow all tool calls
approvalRequire approval for all tool calls
readonlyAllow read-only tools, require approval for others

SubAgentConfig

interface SubAgentConfig {
  templates?: string[];
  depth: number;
  inheritConfig?: boolean;
  overrides?: {
    permission?: PermissionConfig;
    todo?: TodoConfig;
  };
}

TodoConfig

interface TodoConfig {
  enabled: boolean;
  remindIntervalSteps?: number;
  storagePath?: string;
  reminderOnStart?: boolean;
}

SandboxConfig

interface SandboxConfig {
  kind: SandboxKind;
  workDir?: string;
  enforceBoundary?: boolean;
  allowPaths?: string[];
  watchFiles?: boolean;
  [key: string]: any;
}

SandboxKind

type SandboxKind = 'local' | 'docker' | 'k8s' | 'remote' | 'vfs' | 'e2b' | 'opensandbox';

Resume Types

ResumeStrategy

type ResumeStrategy = 'crash' | 'manual';
StrategyDescription
crashAuto-seal incomplete tools and emit agent_resumed event
manualLeave incomplete tools as-is for manual handling

Reminder Types

ReminderOptions

interface ReminderOptions {
  skipStandardEnding?: boolean;
  priority?: 'low' | 'medium' | 'high';
  category?: 'file' | 'todo' | 'security' | 'performance' | 'general';
}

E2B Types

E2BSandboxOptions

interface E2BSandboxOptions {
  apiKey?: string;
  template?: string;
  timeoutMs?: number;
  workDir?: string;
  envs?: Record<string, string>;
  metadata?: Record<string, string>;
  allowInternetAccess?: boolean;
  execTimeoutMs?: number;
  sandboxId?: string;
  domain?: string;
}

E2BTemplateConfig

interface E2BTemplateConfig {
  alias: string;
  base: 'python' | 'node' | 'debian' | 'ubuntu' | 'custom';
  baseVersion?: string;
  dockerfile?: string;
  aptPackages?: string[];
  pipPackages?: string[];
  npmPackages?: string[];
  buildCommands?: string[];
  workDir?: string;
  cpuCount?: number;
  memoryMB?: number;
}

OpenSandbox Types

OpenSandboxWatchMode

type OpenSandboxWatchMode = 'native' | 'polling' | 'off';

OpenSandboxOptions

interface OpenSandboxOptions {
  kind: 'opensandbox';
  apiKey?: string;
  endpoint?: string;
  domain?: string;
  protocol?: 'http' | 'https';
  sandboxId?: string;
  image?: string;
  template?: string;
  workDir?: string;
  timeoutMs?: number;
  execTimeoutMs?: number;
  requestTimeoutSeconds?: number;
  useServerProxy?: boolean;
  env?: Record<string, string>;
  metadata?: Record<string, string>;
  resource?: Record<string, string>;
  networkPolicy?: Record<string, any>;
  skipHealthCheck?: boolean;
  readyTimeoutSeconds?: number;
  healthCheckPollingInterval?: number;
  watch?: {
    mode?: OpenSandboxWatchMode;
    pollIntervalMs?: number;
  };
  lifecycle?: {
    disposeAction?: 'close' | 'kill';
  };
}

References