fleet-memory/hindsight-integrations/ai-sdk
Nicolò Boschi 72c25c97e3
feat(typescript-client): Deno compatibility (#607)
* feat(typescript-client): add Deno compatibility

- Switch build from tsc to tsup for dual CJS + ESM output with proper exports field
- Add deno_setup.ts preload that injects Jest-compatible globals (describe/test/expect) via @std/testing/bdd and @std/expect
- Fix generated client.gen.ts: exclude hey-api internal `client` field from RequestInit spread to avoid conflict with Deno.HttpClient
- Add test:deno npm script using --unstable-sloppy-imports and --preload
- Add test-typescript-client-deno CI job using denoland/setup-deno@v2 (v2.x)
- Update docs: rename page to TypeScript / JavaScript Client, add Deno installation section

* feat: add Deno compatibility to ai-sdk and chat integrations

- Switch ai-sdk and chat builds from tsc to tsup (ESM bundle, eliminates
  extension-less import issues in Deno)
- Add deno.json import map to ai-sdk redirecting 'vitest' to a custom
  vitest-compat.ts shim and bare npm specifiers to npm: URLs
- Add vitest-compat.ts shim implementing vi.fn()/vi.spyOn()/vi.mocked()
  using @std/expect's Symbol.for("@MOCK") interface so toHaveBeenCalledWith
  and other mock matchers work under Deno
- Add test:deno script to ai-sdk (all 30 tests pass under Deno)

* ci: add Deno test job for ai-sdk integration

Adds a new test-ai-sdk-integration-deno CI job that runs the ai-sdk
unit tests under Deno LTS, verifying Deno compatibility of the package.

* fix: remove broken link to non-existent n8n blog post in streamlit post

* fix: patch client.gen.ts for Deno compatibility during generation

Add a post-generation patch step to generate-clients.sh that removes
the hey-api internal 'client' field from the RequestInit spread in
client.gen.ts. Deno's Request constructor rejects 'client' because it
conflicts with the Deno.HttpClient option name.
2026-03-18 14:25:35 +01:00
..
src feat: improve ai sdk tools (#394) 2026-02-18 13:06:03 +01:00
tests feat(typescript-client): Deno compatibility (#607) 2026-03-18 14:25:35 +01:00
.gitignore feat: ai sdk integration (#299) 2026-02-04 20:25:59 +01:00
deno.json feat(typescript-client): Deno compatibility (#607) 2026-03-18 14:25:35 +01:00
deno.lock feat(typescript-client): Deno compatibility (#607) 2026-03-18 14:25:35 +01:00
package-lock.json feat(typescript-client): Deno compatibility (#607) 2026-03-18 14:25:35 +01:00
package.json feat(typescript-client): Deno compatibility (#607) 2026-03-18 14:25:35 +01:00
README.md docs: add AI SDK integration documentation (#304) 2026-02-05 17:05:18 +01:00
tsconfig.json feat: ai sdk integration (#299) 2026-02-04 20:25:59 +01:00
tsup.config.ts feat(typescript-client): Deno compatibility (#607) 2026-03-18 14:25:35 +01:00
vitest.config.ts feat: ai sdk integration (#299) 2026-02-04 20:25:59 +01:00

Hindsight Memory Integration for Vercel AI SDK

Give your AI agents persistent, human-like memory using Hindsight with the Vercel AI SDK.

Quick Start

npm install @vectorize-io/hindsight-ai-sdk @vectorize-io/hindsight-client ai zod
import { HindsightClient } from '@vectorize-io/hindsight-client';
import { createHindsightTools } from '@vectorize-io/hindsight-ai-sdk';
import { generateText } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';

// 1. Initialize Hindsight client
const hindsightClient = new HindsightClient({
  apiUrl: 'http://localhost:8000',
});

// 2. Create memory tools
const tools = createHindsightTools({ client: hindsightClient });

// 3. Use with AI SDK
const result = await generateText({
  model: anthropic('claude-sonnet-4-20250514'),
  tools,
  system: `You have long-term memory. Use:
  - 'recall' to search past conversations
  - 'retain' to remember important information
  - 'reflect' to synthesize insights from memories`,
  prompt: 'Remember that Alice loves hiking and prefers spicy food',
});

console.log(result.text);

Features

Three Memory Tools: retain (store), recall (retrieve), and reflect (reason over memories) AI SDK 6 Native: Works with generateText, streamText, and ToolLoopAgent Multi-User Support: Dynamic bank IDs per call for multi-user scenarios Type-Safe: Full TypeScript support with Zod schemas Flexible Client: Works with the official TypeScript client or custom HTTP clients

Documentation

📖 Full Documentation

The complete documentation includes:

  • Detailed tool descriptions and parameters
  • Advanced usage patterns (streaming, multi-user, ToolLoopAgent)
  • HTTP client example (no dependencies)
  • TypeScript types and API reference
  • Best practices and system prompt examples

Running Hindsight Locally

# Install and run with embedded mode (no setup required)
uvx hindsight-embed@latest -p myapp daemon start

# The API will be available at http://localhost:8000

Examples

Full examples are available in the GitHub repository.

Support

License

MIT