English
API Reference
This page inventories the public package surface. The root entry exposes the default createAgent() facade. Lower-level Session APIs live under /advanced, browser contracts under /browser, and deployment runtime components under /server/infra.
/server/infra targets Node.js server processes, not edge runtimes. PostgreSQL, non-bundled provider adapters, and native Node enhancements are optional peers. PostgreSQL uses a dedicated adapter subpath so canonical entrypoints do not load an absent peer. Some packages can still be present transitively through base dependencies.
The package also ships the create-blade-agent executable. Its --preset <local|web|production> option selects the generated project topology, while --verify enables post-installation verification. Omitting --preset generates the default local starter. It is an npm binary, not a JavaScript package export.
Entry points
| Entry | Runtime | Contents |
|---|---|---|
@blade-ai/agent-sdk | Node.js | Default createAgent, tool authoring, and public type entry |
@blade-ai/agent-sdk/browser | Browser and Node.js | AgentClient, protocol schemas, parsers, events, and constants |
@blade-ai/agent-sdk/protocol | Browser and Node.js | Wire protocol schemas and parsers |
@blade-ai/agent-sdk/server/infra | Node.js server | AgentServer, Workers, and Runtime Store contracts |
@blade-ai/agent-sdk/server/postgres | Node.js server | PostgresRuntimeStore adapter |
@blade-ai/agent-sdk/advanced | Node.js | Local/server Sessions, SessionRunner, execution hosts, and Node adapters |
The former /node, /server, /core, /model, /session, /middleware, and /tools compatibility aliases have been removed. The optional PostgreSQL adapter lives at /server/postgres, so canonical imports do not force-load pg. The package is ESM-only. Browser calls to server-only APIs resolve to explicit stubs.
Agent
Runtime:
createAgentAgentResponse
Types:
Agent, AgentOptions, AgentAdvancedOptions, AgentProfile, AgentFilesystemOptions, AgentPermission, AgentPermissionPreset, AgentPermissionRequest, AgentPermissionDecision, AgentResponseEvent, AgentResponseEventType, AgentResponseListener, AgentResponseSubmission, InlineHooks, SessionHookEvent, UserMessageContent, SkillActivationContext, SkillDefinition, SkillMetadata, and SkillRegistryConfig.
Session
Functions:
| Export | Purpose |
|---|---|
createSession | Create a Session |
resumeSession | Restore persisted state |
forkSession | Fork persisted state |
prompt | Run a one-shot request |
Types:
AgentDefinition, BuiltinProviderType, ModelServiceConfig, ExecutionContext, ForkOptions, ForkSessionOptions, ForkSessionResult, HookCallback, HookInput, HookOutput, InputSubmission, ISession, McpServerStatus, McpToolInfo, ModelIdentity, ModelInfo, PendingSessionInput, PromptResult, ProviderAdapter, ProviderConnectionConfig, ProviderRegistryErrorCode, ProviderType, ResumeOptions, SendOptions, SessionHandoffErrorCode, SessionHandoffResult, SessionOptions, SessionRepository, SessionEventStore, SessionStreamEvent, StreamOptions, SubagentInfo, TokenUsage, ToolExecutionRecord, ToolDefinition, and ToolResult.
Repository support types:
SessionRepositoryMessageMetadata, SessionRepositoryCompactionMetadata, SessionRepositorySubagentInfo, SessionRepositorySubagentRef, SessionRepositoryHealth, and SessionRepositoryStorageStats.
Errors:
SessionHandoffError
Constants:
InputPriorityInputIdRequestIdSessionIdEventIdEventSequenceCommandIdTurnIdModelAttemptIdToolAttemptIdPermissionRequestIdWorkerIdExecutionLeaseIdFencingTokenAgentIdMessageIdPartIdToolUseIdTraceIdSpanIdTraceEventId
These ID exports are branded identifiers, not arbitrary strings.
Server Runtime
Runtime:
AgentServerInProcessSessionExecutorSdkSessionRunnerExecutionHostSessionRunnerAgentWorkerAgentClientRemoteAgentSessionInMemoryAgentServerStoreRuntimeStoreErrorTenantAdmissionControllerJsonlSessionRepository(/advanced)AgentProtocolErrorAGENT_PROTOCOL_VERSIONAgentCommandTypeparseAgentCommandparseAgentCommandResultparseAgentEventCursorparseAgentServerEventagentInitializationDataSchema
Types:
AgentServerOptionsAgentServerSessionContextSessionExecutorSessionExecutorCommandContextSessionExecutorEventPublisherSessionExecutorReadResultInProcessSessionExecutorOptionsAgentServerStoreRuntimeStoreRuntimeTenantStoreRUNTIME_STORE_SCHEMA_VERSIONRuntimeWorkerRecordRuntimeWorkerRegistrationRuntimeSessionRouteRuntimeSessionClaimRuntimeSessionClaimOptionsRuntimeSessionStateRuntimeSessionTransitionRuntimeSessionSettlementRuntimeRecoveryResultSessionRunnerSessionRunnerContextSessionRunResultWorkerRuntimeStoreWorkerRuntimeErrorAgentWorkerHealthAgentWorkerMetricsAgentWorkerSnapshotAgentWorkerTelemetryAgentWorkerErrorMetricAgentCommandClaimAgentServerSessionRecordAgentServerTelemetryAgentServerAuditRecordAgentClientOptionsAgentClientCommandOptionsAgentClientEventOptionsAgentCommandAgentCommandResultAgentServerEventAgentEventCursorAgentEventPageAgentPrincipalAgentServerScopeAgentProtocolCapabilitiesAgentInitializationDataAgentClientCapabilitiesAgentProtocolErrorCode
PostgresRuntimeStore is exported by /server/postgres. AgentServerTelemetry and AgentWorkerTelemetry are injection ports exported by /server/infra; the SDK does not bind them to a specific backend.
See Server Runtime, Runtime Store, Worker Runtime, and Execution Host for deployment and failure semantics.
Execution Host
Runtime:
ExecutionHostErrorDockerExecutionHost(/advanced)ExecutionIdExecutionCheckpointId
Types:
ExecutionHostExecutionProvisionRequestExecutionHandleExecutionExecRequestExecutionExecResultExecutionCheckpointExecutionRestoreRequestExecutionResourceLimitsExecutionNetworkPolicyExecutionWorkspaceSourceExecutionHostErrorCodeDockerExecutionHostOptions(/advanced)
Durable Events
Runtime:
DurableExecutionLeaseDurableExecutionLeaseErrorexecutionFenceDURABLE_EXECUTION_LEASE_FORMATJsonlDurableEventStore(/advanced)DurableEventSubscriptiondurableEventCursorparseDurableEventCursorDURABLE_EVENT_CURSOR_VERSIONDurableSessionJournalDurableSessionRecoveryCoordinatorDurableEventTypeDURABLE_EVENT_SCHEMA_VERSIONDURABLE_EVENT_LOG_FORMATparseDurableEventDraftparseDurableEventEnvelopeparsePersistedDurableEventBatchisDurableEventTypeprojectDurableSessionplanDurableSessionRecoveryDurableSessionProjector
Types and errors:
DurableExecutionLeaseOptionsDurableExecutionLeaseStoreDurableExecutionLeaseSnapshotDurableExecutionFenceDurableExecutionLeaseErrorCodeDurableEventStoreJsonlDurableEventStoreOptions(/advanced)DurableEventCursorDurableEventSubscriptionOptionsDurableEventSubscriptionMessageDurableEventSubscriptionErrorDurableEventSubscriptionErrorCodeDurableSessionJournalOptionsDurableSessionCommandDurableCommandEventDraftDurableCommandCommitOptionsDurableCommandCommitResultDurableCommandCommitStatusDurableSessionJournalErrorDurableSessionJournalErrorCodeDurableSessionRecoveryErrorDurableSessionRecoveryErrorCodeDurableCommandConflictErrorDurableCommandOutcomeUnknownErrorDurableEventEnvelopeDurableEventDraftDurableEventDataMapDurableEventErrorDurableEventSchemaVersionDurableEventOfTypeDurableModelResponseDurableModelToolCallDurableModelUsageDurableTokenUsageDurableInputPriorityDurablePermissionDecisionDurableRequestInterruptReasonDurableRequestRecoveryOriginDurableModelRequestAbortReasonDurableTurnAbortReasonDurableToolInterruptBehaviorDurableToolCancelReasonDurableToolOutcomeUnknownReasonDurableSessionCloseReasonDurableEventAppendOptionsDurableEventAppendResultDurableEventReadOptionsDurableEventPagePersistedDurableEventBatchDurableEventSequenceConflictErrorDurableEventStoreErrorDurableEventStoreErrorCodeDurableEventProjectionErrorDurableSessionRecoveryRequiredErrorDurableRequestRolloverCommandDurableRequestRolloverResultDurableRequestOutcomeReconciliationDurableRequestOutcomeReconciliationCommandDurableModelOutcomeReconciliationDurableModelOutcomeReconciliationCommandDurableRequestRecoveryKindDurableTurnRecoveryCommandDurableTurnRecoveryResultSessionDurableRecorderErrorDurablePermissionProjectionDurablePermissionStatusDurableRequestProjectionDurableRequestStatusDurableSessionProjectionDurableSessionProjectionStatusDurableSessionRecoveryActionDurableSessionRecoveryPlanDurableAcceptedRequestRecoveryDurableSessionResumeDecisionDurableToolOutcomeReconciliationDurableToolOutcomeReconciliationCommandDurableToolStartCommandDurablePermissionResolutionCommandDurableRecoveryCommitResultDurableToolAttemptProjectionDurableToolAttemptStatusDurableModelAttemptProjectionDurableModelAttemptStatusDurableTurnProjectionDurableTurnStatus
The JSONL adapter is Node-only and exported from /advanced. Event contracts, constants, errors, and parsers are browser-safe through /browser.
Tools
Authoring and execution:
| Export | Purpose |
|---|---|
defineTool | Define a TypeBox-validated async tool that returns JSON data |
collectToolExecution | Drain a generator and return its terminal result |
completeToolExecution | Wrap a terminal result in a generator |
getBuiltinTools | Build the /advanced local tool set |
memoryReadTool | Static opt-in memory reader (/advanced) |
memoryWriteTool | Static opt-in memory writer (/advanced) |
Types:
BuiltinToolGroup, ConfirmationDetails, ConfirmationHandler, ConfirmationResponse, ToolBehavior, ToolDefinition, ToolDefinitionInput, ToolDescription, ToolDisplayContent, ToolEffect, ToolEffectYield, ToolError, ToolExecution, ToolExecutionLifecycle, ToolExecutionStartedLifecycle, ToolInvocationLifecycle, ToolScheduledLifecycle, ToolSettledLifecycle, ToolPermissionResolution, ToolExposureConfig, ToolExposureMode, ToolMessage, ToolModelContent, ToolProgress, ToolSideEffect, RuntimeAccess, ToolServiceMap, ToolServiceName, ToolExecutionUpdate, and ToolYield.
Constants:
ToolKind:ReadOnly,Write, andExecuteToolSideEffect:PURE,IDEMPOTENT, andNON_IDEMPOTENTToolErrorType: validation, permission, execution, interruption, timeout, and network errors
ToolDefinition defaults to non_idempotent when sideEffect is omitted. The resolved value determines whether a started tool can be replayed during durable recovery.
Compiled tools and invocation snapshots remain runtime-internal; hook or permission input updates trigger a fresh validation and preparation pass.
Tool source policy
Types:
ToolSourcePolicyToolSourceKindToolTrustLevelWebFetchSecurityPolicy
Source kinds are builtin, custom, mcp, and session. Trust levels are trusted, workspace, and remote.
MCP
Runtime:
createSdkMcpServertool
Types:
McpServerConfigMcpToolCallResponseMcpToolDefinitionMcpToolResponseSdkMcpServerHandleSdkTool
SdkMcpServerHandle is discriminated by type: 'in-process'.
There is no @blade-ai/agent-sdk/mcp entry point. Import these exports from /advanced.
Memory
Runtime:
FileSystemMemoryStore(/advanced)MemoryManager(/advanced)
Types:
MemoryMemoryInputMemoryStoreMemoryType
Memory tools are opt-in.
memoryReadTool and memoryWriteTool are static Tool instances. Set SessionOptions.memoryManager to register them and inject that manager only into the tools that declare the service.
Providers
Runtime:
ProviderRegistryProviderRegistryError
Types:
BuiltinProviderTypeProviderTypePROVIDER_TYPESisBuiltinProviderTypeProviderConnectionConfigProviderAdapterProviderRegistryErrorCodeModelConfigModelServiceConfigModelServiceModelMessageConversationMessageConversationMessageSourceCONVERSATION_MESSAGE_SOURCESisConversationMessageSourceModelContentModelTextContentModelImageContentModelToolCallModelToolCallDeltaModelStreamToolCallModelResponseModelStreamChunkModelToolDefinitionModelProviderOptionsModelMessageProviderOptionsModelSideQueryOptionsModelRetryConfigModelRetryEventQuerySourceModelIdentityModelUsageTokenUsageresolveModelIdentitynormalizeModelUsage
See Providers and Logging for adapter registration and routing semantics, and Type Architecture for ownership and boundary rules.
Permissions
Helpers:
createCompositePermissionHandlercreateModePermissionHandlercreatePathSafetyPermissionHandlercreateRuleBasedPermissionHandler
Types:
ConfirmationDetails(abortSignalis the active Request signal)ConfirmationHandlerConfirmationResponsePermissionHandlerPermissionHandlerRequestPermissionResultPermissionRuleValuePermissionsConfigPermissionUpdate
Constants:
PermissionModePermissionDecision
Hooks
Types and constants:
HookCallbackHookInputHookOutputHookEvent
HookEvent, AgentOptions.advanced.hooks, and SessionOptions.hooks use the eight events in SessionHookEvent; see Hooks.
Middleware and plugins
Runtime:
composeMiddlewaredefinePluginwrapModelService
Types:
Middleware/MiddlewareNextAgentMiddlewareConfigAgentPluginModelMiddlewareModelChatRequest/ModelSideQueryRequestModelStreamRequest/ModelRetryRequestToolMiddleware/ToolMiddlewareRequest
Runtime context
Helpers:
createContextSnapshothasFilesystemCapabilitymergeContext
Types:
ContextSnapshotRuntimeContextRuntimeContextPatchRuntimeHookEventRuntimeHookRegistrationRuntimeModelOverrideRuntimePatchRuntimePatchScopeRuntimePatchSkillInfoRuntimeToolDiscoveryPatchRuntimeToolPolicyPatch
Subagents
Runtime:
SubagentExecutorSubagentRegistry
Types:
AgentSessionRepository— storage capability for subagent Sessions; inject a repository-backed implementation so subagent state can survive a move between hosts instead of only a restart on the same oneSubagentColorSubagentConfigSubagentContextSubagentResultSubagentSource
AgentDefinition, used by SessionOptions.agents, is intentionally smaller than lower-level SubagentConfig.
Observability
Types:
AgentTraceObservabilityOptionsTraceEventTracePayloadSummaryTraceSinkTraceSpanTraceSpanKindTraceStatus
Token budgets
TokenBudgetConfigTokenBudgetSnapshot
DeepSeek helpers
Functions and constants:
normalizeDeepSeekModeloptimizeDeepSeekCachePrefixresolveDeepSeekBaseUrlsanitizeDeepSeekStrictSchemaDEEPSEEK_BETA_BASE_URLDEEPSEEK_DEFAULT_BASE_URLDEEPSEEK_DEFAULT_MODEL
Types:
DeepSeekCacheOptimizationOptions and DeepSeekProviderOptions.
Errors
Classes:
SdkErrorAbortErrorConfigErrorHookTimeoutErrorModelTimeoutErrorPermissionDeniedErrorProviderRegistryErrorSessionInputErrorToolExecutionError
Types and helpers:
SdkErrorOptionsHookTimeoutErrorCodeModelTimeoutErrorCodeSessionInputErrorCodegetErrorCodegetErrorMessagegetErrorNametoError
Lifecycle
registerCleanupgracefulShutdownresetCleanupRegistryCleanupFnCleanupHandleGracefulShutdownOptions
Common contracts
Types:
JsonObjectJsonValueOutputFormatSandboxSettingsAgentLoggerLogEntryLogLevelName
Constants:
MessageRoleSessionStreamEventType
Utility:
lazySingleton