Client SDK · Reference

Exports.

Every class, interface, and type the client SDK package exports.

Default export

TypeScript
import Matilda from '@maincode-ai/matilda-client-sdk';

The Matilda class — the main SDK entry point.

Named exports

ExportTypeDescription
MatildaclassMain client class.
MatildaAPIErrorclassHTTP error (status, responseText).
SafetyReplaceErrorclassSafety filter replacement error (categories).
MatildaObjectParseErrorclassStructured output parse/validation failure (raw, cause).
MatildaClientOptionsinterfaceConstructor options (extends ClientConfig).
MatildaRequestOptionsinterfacePer-request options (signal, stallTimeoutMs, etc.).
ChatCreateParamsinterfaceChat request params (input, messages, conversationId, fileIds, responseMode, responseSchema).
MatildaChatStreamEventtypeDiscriminated union of 14 stream event types.
MatildaChatResponseinterfaceCollected response from chat.create().
MatildaObjectResponse<T>interfacechat.createObject() response (extends MatildaChatResponse, adds object).
MatildaObjectEvent<T>typechat.streamObject() events — all stream events, plus a final { type: 'object' }.
ChatResumeParamsinterfaceDurable stream resume params (streamId, lastEventId).
FileUploadOptionsinterfaceFile upload options (onProgress + request options).
BrowserLoginOptionsinterfaceBrowser login (PKCE) options.
DeviceLoginOptionsinterfaceDevice flow options.
CreateApiKeyOptionsinterfaceAPI key creation params (name, scopes, expiresAt).
ApiKeyinterfaceAPI key metadata (no secret).
ApiKeyWithSecretinterfaceAPI key with one-time secret.
TokenSetinterfaceOAuth token set (accessToken, refreshToken, idToken, expiresAt).
StorageAdapterinterfacePluggable token storage.
TokenManagerinterfaceToken manager interface.
LoginFlowEventtypeLogin flow state events.
DEFAULT_SUCCESS_REDIRECTconstDefault browser-login success redirect URL.
clientconstPre-created singleton Matilda instance (using default config).

Re-exported types

From @matilda/api-client:

ExportTypeDescription
MatildaCoreclassThe underlying HTTP client that powers all resource groups.
configureClientfunctionConfigure a shared client instance.
fetchPublicRuntimeConfigfunctionFetch runtime config from the server.
getClientConfigfunctionGet the current shared client config.
trustApiBaseUrlfunctionValidate and brand a URL as trusted.
ClientConfigBase client configuration.
RequestOptionsBase request options (fingerprint, accessToken).
ChatResponseMode'auto' | 'instant' | 'deep'.
ChatErrorCodeChat error code union.
GetTokenToken provider function type.
TrustedApiBaseUrlBranded trusted URL type.
TrustedApiBaseUrlPolicyURL validation policy.
PublicConfigEndpointPublic config endpoint union.
PublicRuntimeConfigRuntime config from server.

From @matilda/shared-types:

TypeDescription
ApiMessageWire-format message ({ role, content }).
ChatMessageDomain message with full metadata.
ConversationSummaryConversation list item.
ConversationListResponsePaginated conversation list.
ConversationRecordFull conversation with messages.
FileAttachmentFile metadata.
FileCompleteResponseUpload completion response.
PushDevicePush notification device.
UsageEventToken usage event.
ActiveStreamLookupActive stream check result.

Deprecated exports

ExportDescription
PkceLoginOptionsUse BrowserLoginOptions instead.
DeviceFlowOptionsUse DeviceLoginOptions instead.