MemMesh — persistent, self-improving memory for AI agents. Get started →
IntegrationsTypeScript SDK

TypeScript SDK

When you’re building your own agent rather than wiring an editor, use the MemMesh TypeScript SDK to call the engine directly — observe and recall memory, predict any target, and discover behaviors, without going through MCP.

Install

npm install @thinkfleet/memory-sdk

Configure

import { ThinkFleetMemory } from "@thinkfleet/memory-sdk";
 
const tf = new ThinkFleetMemory({
  apiKey: process.env.THINKFLEET_API_KEY!,   // sk-...
  projectId: process.env.THINKFLEET_PROJECT_ID!,
  baseUrl: "https://app.memmesh.ai",          // optional — this is the default
});

See Scopes for what projectId and the other identifiers mean.

Observe & recall

observe takes a structured object — a subject (so mining can attribute the observation), the free-text content, and an optional activityType. Semantic search lives on the admin sub-resource.

// Observe — let the engine decide what to keep
await tf.memory.observe({
  subject: { kind: "workspace", externalId: "monorepo" },
  content: "We standardized on pnpm across all repos.",
  activityType: "decision",
});
 
// Semantic search / recall
const hits = await tf.memory.admin.search({
  query: "package manager convention",
  limit: 10,
});

Predict anything

Declare what to predict and the engine predicts it from the subject’s history — calibrated, with provenance, and abstaining when there isn’t enough signal. The kind selects the model; you never pick one.

const p = await tf.lattice.predictTarget(
  { kind: "customer", externalId: "acct-42" },
  { kind: "event_occurrence", eventType: "subscription_cancelled" },
  { horizonDays: 90 },
);
 
if (p.abstained) {
  console.log("not enough signal —", p.abstentionReason);
} else {
  console.log(
    `churn risk ${(p.probability * 100).toFixed(0)}% ` +
    `[${(p.probabilityLower * 100).toFixed(0)}–${(p.probabilityUpper * 100).toFixed(0)}%]`,
  );
  console.log("why:", p.explanation, "| evidence:", p.evidenceMemoryIds);
}

Target kind is one of event_occurrence | numeric | event_time | anomaly, and the kind selects the result fields (probability* / value* / expectedAt* / anomalyScore). See Predictions for the full model.

⚠️

Always check abstained first — an abstention means unknown, never low risk.

Discover behaviors

Find behaviors nobody predefined — cohesive groups of subjects that act alike — each with prevalence, stability, members, and explainable evidence.

const { behaviors } = await tf.behaviors.discover();
 
for (const b of behaviors) {
  console.log(
    `${b.label} — ${(b.prevalence * 100).toFixed(0)}% of subjects, ` +
    `stability ${b.stability.toFixed(2)}`,
  );
  console.log("  evidence:", b.exemplarEvidence.join(", "));
}

An empty result means the engine abstained — not enough signal to assert a behavior — never “there are no behaviors”. See Behavior discovery for the full model.

Resources reference

The client groups methods into resources. The most-used ones:

tf.memory

MethodPurpose
observe(body) / observeImage / observeVoice / observeDocumentFeed the engine raw input (a { subject, content, activityType? } object); it decides what to keep.
ingestMedia(body)Ingest image/audio/document, extract text, and run the observe pipeline.
mine(params?)List the current user’s memories across scopes.
explain(id)Provenance for a memory — the raw sources behind a pattern.
submitFeedback(body)Reinforce or flag a memory item.
delete(id)Delete one of your own memory items.

tf.memory.admin

Full admin surface — requires READ_MEMORY / WRITE_MEMORY permission.

MethodPurpose
search({ query, limit })Semantic search across visible scopes.
list / listPlatform / listPendingReview / statsRead + admin views.
create(body) / update / confirm / promote / deleteExplicit memory writes + lifecycle.
consolidate / dedup / reflect / backfillEmbeddingsQuality + extraction passes.
prefetchRelated(body)Anticipatory graph retrieval.

tf.lattice

MethodPurpose
predict(body)Pattern projection, or declared-target prediction (pass target).
predictTarget(subject, target, opts)Typed predict-anything helper.
getProfile(subject)Behavioral profile snapshot.
getCohort / predictByCohort”People like X” cohorts + cohort-aggregated predictions.
extractPatterns / mineMemories(Re)mine behavior patterns.
getCalibrationConfidence-vs-realized reliability report.

tf.behaviors

MethodPurpose
discover(params?)Emergent behavior discovery.

tf.typed — typed attributes

Register typed attribute schemas and ingest numeric/typed observations that feed numeric / anomaly predictions.

await tf.typed.registerAttribute({ key: "order_total", dataType: "number" });
await tf.typed.ingest({ subject, attributeKey: "order_total", value: 42.0 });
const rows = await tf.typed.queryObservations({ subject, attributeKey: "order_total" });

Also: listAttributes, enqueue, accumulator.

tf.financial — financial vertical

Ingest market data and read calibrated signals (requires the finance entitlement).

await tf.financial.ingestPrices(prices);
const profile = await tf.financial.getProfile(subject);   // indicators + portfolio risk
const calls = await tf.financial.predict({ subject });    // calibrated buy/sell/hold

Also: ingestPrice, ingestFundamentals, ingestHolding, ingestNews, reconcile, getCalibration.

tf.health — health vertical

Record signals and read decision-support estimates — never a diagnosis (requires the health entitlement).

await tf.health.recordBiomarker(subject, { name: "hba1c", value: 5.6 });
const profile = await tf.health.getProfile(subject);
const risk = await tf.health.getCohortRisk({ /* … */ });

Also: recordDemographics, recordCondition.

The financial and health resources are gated by their vertical entitlements (included on Pro / Enterprise). See Licensing & caps.