SDK
SDK API reference
The public API of oortmem 0.6.0: what it exports, every createOort() option, the methods of a handle and the shapes they return.
Exports
| Import | Exports |
|---|---|
oortmem | createOort, formatForPrompt, VERSION, the error classes (SDK errors) and every type on this page. |
oortmem/ai-sdk | oortTools, oortObserve, oortInstructions. Experimental (SDK in agent frameworks). |
Deep imports such as oortmem/dist/… are blocked by the package's exports map.
createOort(options?)
Async, and returns an Oort handle. It makes no network request. Every option object is checked strictly: an unknown key, or an option the mode does not take, throws OortUsageError. Nothing is silently ignored.
mode- Type
'auto' | 'local' | 'cloud' - Modesall
- Default
'auto': what setup chose, else local home- Type
string - Modeslocal, auto
- Default
OORT_HOME, else~/.oort cwd- Type
string - Modesall
- Default
process.cwd(); only finds the project and its config project- Type
string | null - Modesall
- DefaultDerived from
cwdas the CLI does. A string becomescfg:<id>;nullmeans global memories only projectConfig- Type
boolean - Modeslocal, cloud
- Default
true.falseskips the repository'soort.config.json agent- Type
string - Modesall
- Default
OORT_AGENT, else anonymous (the Planet only) user- Type
string - Modeslocal
- DefaultUnset: the person. Setting it requires
org org- Type
string - Modeslocal
- Default
'local'. Required, and not'local', withuser keys- Type
{ voyage?, typesafe?, anthropic?, oort? } - Modeslocal; cloud (
oortonly) - Defaultnone
keySources- Type
('explicit' | 'env' | 'keychain')[] - Modesall
- DefaultAll three;
keychainis skipped withOORT_NO_KEYCHAIN=1 config- TypeA deep partial of the home config
- Modeslocal
- DefaultNone.
servecannot be set url- Type
string - Modescloud
- Default
OORT_CLOUD_URL, elsehttps://api.oortcloud.dev timeoutMs- Type
number - Modescloud
- Default30,000 per request
migrate- Type
boolean - Modeslocal
- Default
true.falserefuses an older store env- Type
Record<string, string | undefined> - Modesall
- Default
process.env fetch- Type
typeof fetch - Modescloud
- DefaultA keep-alive connection pool
judge- Type
{ role: 'agent' | 'expert'; operator?: string } - Modeslocal
- Default
{ role: 'agent' }
Each model role (embed, rerank, decide, write) uses the first key found: keys, then the vendor's environment variable, then the Keychain, then the Oort key through the Oort Pro relay. See Running in your own infrastructure for servers.
The handle
interface Oort {
readonly mode: 'local' | 'cloud';
readonly judge: OortJudge;
recall(query: string, opts?: RecallOptions): Promise<RecallResult>;
observe(turn: Turn, opts?: { signal?: AbortSignal }): Promise<ObserveResult>;
remember(facts: string | readonly string[], opts?: { type?: MemoryType }): Promise<RememberResult>;
forget(id: string, opts?: { everywhere?: boolean }): Promise<ForgetResult>;
pin(id: string): Promise<PinResult>;
unpin(id: string): Promise<PinResult>;
recent(opts?: { since?: string | Date; limit?: number }): Promise<{ memories: MemoryView[]; warnings: Warning[] }>;
explain(id: string): Promise<Explanation>;
whoami(): Promise<Whoami>;
consolidate(opts?: { budgetMs?: number; signal?: AbortSignal }): Promise<ConsolidateResult>;
scoped(s: ScopedOptions): Oort;
close(): Promise<void>;
[Symbol.asyncDispose](): Promise<void>;
}
interface OortJudge {
record(input: JudgmentInput): Promise<RecordJudgmentView>;
apply(item: string | JudgeItem, opts?: JudgeOptions): Promise<JudgeResult>;
list(opts?: { domain?: string; by?: string; all?: boolean; limit?: number }): Promise<{ judgments: (JudgmentView & { id: string })[] }>;
confirm(id: string): Promise<{ id: string; changed: boolean }>;
}recall,observe,remember,pin,unpin,recent,explain,whoami- Localyes
- Cloudyes
forget- Localyes
- Cloudyes;
everywhereis cloud only judge.record,judge.apply,judge.list- Localyes
- Cloudrefused (
local-only) judge.confirm- Localexpert role only
- Cloudrefused (
local-only) consolidate- Localyes
- Cloudrefused (
local-only) scoped- Localyes
- Cloud
projectandagentonly
- Ids. A full id, or a unique prefix of at least 8 characters. Several matches throw
OortAmbiguousIdError. An id outside the handle's scope isOortNotFoundError, exactly like an unknown one. - Concurrency. One handle is safe for concurrent calls.
- Lifecycle.
close()is idempotent; afterwards every call throwsOortUsageError(closed). A handle fromscoped()shares its root's engine: closing it does nothing, and closing the root closes everything.await usingcloses it for you. - observe runs the full write path and can take seconds: call it after answering. remember frames each fact as the user's statement.
recall options
limit- Type
number - What it does1 to 50, default 10.
mode- Type
'current' | 'as-of' | 'history' | 'known-at' - What it doesThe time view.
as-ofneedsasOf,known-atneedsknownAt. asOf- Type
string | Date - What it doesValid time: what was true then.
knownAt- Type
string | Date - What it doesTransaction time: what was known then. Not together with
asOf. include- Type
IncludeLevel[] - What it doesNarrows the levels read:
self,planet,star,constellation,galaxy. budgetChars- Type
number - What it doesThe default block size for
formatForPrompt. includeWithdrawn- Type
boolean - What it doesAlso withdrawn memories.
speed- Type
'full' | 'fast' | 'lexical' - What it does
full: embed and rerank.fast: no rerank.lexical: no model call. inferTime- Type
boolean - What it doesDefault true: "on 2 April" picks as-of, as the CLI does.
signal- Type
AbortSignal - What it doesStops waiting and rejects with its reason.
Inputs
interface Turn {
user: string;
assistant: string;
tools?: string[];
at?: string | Date;
sessionId?: string;
turnRef?: string;
}
interface ScopedOptions {
user?: string;
project?: string | null;
agent?: string;
judgeRole?: 'agent';
}interface JudgmentInput {
subject: string;
ref?: string;
verdict: string;
verdicts?: readonly string[];
reason: string;
criteria?: readonly string[];
domain: string;
by: string;
decidedAt?: string | Date;
}
interface JudgeItem {
summary: string;
details?: string;
ref?: string;
domain?: string;
by?: string;
}
interface JudgeOptions {
limit?: number;
threshold?: number;
minSimilarity?: number;
minAgreement?: number;
includeImported?: boolean;
includeAgentRecorded?: boolean;
}formatForPrompt(result, opts?)
A function, not a method: formatForPrompt(result, { budgetChars }) returns the <oort-memory> block as a string, 6,000 characters at most by default. It escapes every memory, so a stored memory can neither close the block nor forge a label.
Results
Plain objects. Ignore fields you do not know: new ones may appear in any release. Every memory's text is scrubbed of secrets again on the way out.
Recall
interface RecallResult {
memories: RecalledMemory[];
abstained: boolean;
temporal: { mode: RecallMode; asOf?: string; knownAt?: string; inferred: boolean };
read: string[];
degraded: string[];
warnings: Warning[];
}
interface MemoryView {
id: string;
text: string;
type: MemoryType;
tier: 'hot' | 'warm' | 'cold';
pinned: boolean;
status: MemoryStatus;
validFrom: string;
validTo: string | null;
recordedAt: string;
updatedAt: string;
entities: string[];
origin?: { level: IncludeLevel; space: string; author?: string; overriddenBy?: string };
judgment?: JudgmentView & { id: string };
}
interface RecalledMemory extends MemoryView {
score: number;
stale?: true;
why: { lexicalRank?: number; denseRank?: number; reranked?: number; coverage: number; dense?: number; activation: number; chain?: true }; // experimental
}
interface Warning {
code: string;
message: string;
}Writes and housekeeping
interface ObserveResult {
outcome: Outcome;
memories: { outcome: Outcome; id?: string; supersedes?: string; reason?: string }[];
counts: Partial<Record<Outcome, number>>;
duplicate?: true;
warnings: Warning[];
}
interface RememberResult {
results: { fact: number; outcome: Outcome; id?: string; supersedes?: string; reason?: string }[];
warnings: Warning[];
}
interface ForgetResult {
forgotten: string;
withdrawn?: string[];
}
interface PinResult {
id: string;
pinned: boolean;
changed: boolean | null;
}
interface ConsolidateResult {
promoted: string[];
demoted: string[];
evicted: string[];
expired: string[];
skipped: number;
complete: boolean;
}Explain and whoami
interface Explanation {
memory: MemoryView & { salience: number; activation: number; source: string };
decisions: { stage: string; question: string; answer: string; probability: number }[];
chain: { id: string; text: string; validFrom: string; validTo: string | null; endReason: 'superseded' | 'corrected' | 'expired' | null }[];
hiddenLinks: number;
}
interface Whoami {
mode: 'local' | 'cloud';
account: string | null;
agent: string | null;
project: string | null;
user: string | null;
reads: string[];
writesTo: string;
version: string;
routes: Record<'embed' | 'rerank' | 'decide' | 'write', RouteKind>;
}Judgments
interface RecordJudgmentView {
outcome: 'added' | 'corrected' | 'unchanged';
id: string;
corrects?: string;
status: 'agent-recorded' | 'recorded';
redacted: string[];
embedFailed?: true;
}
interface JudgeResult {
status: 'suggested' | 'needs-expert' | 'precedents-only';
why?: 'no-precedents' | 'too-far' | 'too-few' | 'precedents-disagree' | 'low-confidence' | 'no-decider' | 'decider-failed';
prediction?: { verdict: string; probability: number; probabilities: Record<string, number> };
precedents: Precedent[];
verdicts: string[];
agreement: Record<string, number>;
similarity: 'dense' | 'lexical';
threshold: number;
minSimilarity: number;
degraded?: string[];
decisions: { stage: string; question: string; answer: string; probability: number }[]; // experimental
importedExcluded?: number;
agentRecordedExcluded?: number;
}
interface Precedent {
id: string;
subject: { summary: string; ref?: string };
verdict: string;
reason: string;
criteria: string[];
domain: string;
by: string;
decidedAt: string;
similarity: number;
near: boolean;
agrees?: boolean;
via: JudgmentVia;
confirmed: boolean;
agentRecorded: boolean;
pack?: { id: string; name: string };
}
interface JudgmentView {
subject: { summary: string; ref?: string };
verdict: string;
verdicts: string[];
reason: string;
criteria: string[];
domain: string;
by: string;
decidedAt: string;
via: JudgmentVia;
status: MemoryStatus;
confirmed: boolean;
agentRecorded: boolean;
withdrawn?: { at: string; by: string };
pack?: { id: string; name: string };
}String values
| Type | Values |
|---|---|
MemoryType | semantic, episodic, procedural, preference, judgment |
MemoryStatus | current, superseded, corrected, expired, not-yet-valid, withdrawn |
Outcome | added, reinforced, updated, superseded, corrected, skipped |
IncludeLevel | self, planet, star, constellation, galaxy |
RecallMode | current, as-of, history, known-at |
JudgmentVia | cli, mcp, import, pack, sdk |
RouteKind | own-key, oort-pro, local, cloud, missing |
Reserved names
place (on turns, remember and memory views), near and within (on recall) are reserved for spatial memory. Passing any of them today is a usage error, never a silent drop.