Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.wazoo.dev/llms.txt

Use this file to discover all available pages before exploring further.

Mastra is an un-opinionated AI engine designed to run programmatic intelligence natively alongside your core application code. Since Mastra is built on Vercel AI SDK standards, Worlds tools work out of the box with Mastra agents.

Installation

Install both the Mastra core and Worlds AI SDK:
deno add jsr:@mastra/core jsr:@wazoo/worlds-ai-sdk

Usage

You can pass Worlds tools directly to a Mastra Agent.
import { Agent } from "@mastra/core/agent";
import { openai } from "@ai-sdk/openai";
import { Worlds } from "@wazoo/worlds-sdk";
import { createTools } from "@wazoo/worlds-ai-sdk";

const worlds = new Worlds({
  apiKey: process.env.WORLDS_API_KEY,
});

// Initialize the Worlds toolset
const { executeSparql, searchEntities } = createTools({
  worlds,
  sources: ["my-world-slug"],
});

// Create a Mastra agent with Worlds tools
const agent = new Agent({
  name: "WorldsAgent",
  instructions: "You are a knowledge graph assistant.",
  model: openai("gpt-4o"),
  tools: {
    executeSparql,
    searchEntities,
  },
});

const result = await agent.generate("Find all people in my world.");
console.log(result.text);

Granular selection

If you only need specific tools, you can import and initialize them individually:
import { Agent } from "@mastra/core/agent";
import { openai } from "@ai-sdk/openai";
import { Worlds } from "@wazoo/worlds-sdk";
import { createSearchEntitiesTool } from "@wazoo/worlds-ai-sdk";

const worlds = new Worlds({
  apiKey: process.env.WORLDS_API_KEY,
});

const sources = ["my-world-slug"];

const agent = new Agent({
  name: "SearchAgent",
  model: openai("gpt-4o"),
  tools: {
    search: createSearchEntitiesTool({ worlds, sources }),
  },
});