New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

@strav/brain

Package Overview
Dependencies
Maintainers
1
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@strav/brain

AI module for the Strav framework

npmnpm
Version
0.1.6
Version published
Weekly downloads
20
122.22%
Maintainers
1
Weekly downloads
 
Created
Source

@strav/brain

AI module for the Strav framework. Provides a unified interface for AI providers with support for agents, threads, tool use, and multi-step workflows.

Install

bun add @strav/brain

Requires @strav/core as a peer dependency.

Providers

  • Anthropic (Claude)
  • OpenAI (GPT, also works with DeepSeek via custom baseUrl)

Usage

import { brain } from '@strav/brain'

// One-shot chat
const response = await brain.chat('Explain quantum computing')

// Streaming
for await (const chunk of brain.stream('Write a poem')) {
  process.stdout.write(chunk.text)
}

// Structured output with Zod
import { z } from 'zod'
const result = await brain.generate('List 3 colors', {
  schema: z.object({ colors: z.array(z.string()) }),
})

// Embeddings
const vectors = await brain.embed('Hello world')

Agents

import { Agent, defineTool } from '@strav/brain'

class ResearchAgent extends Agent {
  provider = 'anthropic'
  model = 'claude-sonnet-4-20250514'
  instructions = 'You are a research assistant.'
  tools = [searchTool, summarizeTool]
}

const result = await brain.agent(ResearchAgent).input('Find info on Bun').run()

Threads

Multi-turn conversations with serialization support:

const thread = brain.thread({ provider: 'anthropic', model: 'claude-sonnet-4-20250514' })
await thread.send('Hello')
await thread.send('Tell me more')
const saved = thread.serialize() // persist and restore later

Workflows

Orchestrate multi-agent pipelines:

const workflow = brain.workflow()
  .step('research', ResearchAgent)
  .step('summarize', SummaryAgent)
  .parallel('review', [FactCheckAgent, StyleAgent])

const result = await workflow.run('Analyze this topic')

License

MIT

FAQs

Package last updated on 02 Apr 2026

Related posts