Skip to content
NorthstarPlatformPricingLogin
Integrations

Mastra

Use Lightcone computer actions as tools in Mastra AI workflows.

Use Lightcone with Mastra, a TypeScript framework for building AI workflows, agents, and RAG pipelines.

Terminal window
npm install mastra @ai-sdk/openai @tzafon/lightcone
import { Agent } from "mastra";
import { createOpenAI } from "@ai-sdk/openai";
import Lightcone from "@tzafon/lightcone";
const tzafon = createOpenAI({
baseURL: "https://api.tzafon.ai/v1",
apiKey: process.env.TZAFON_API_KEY!,
});
const lightcone = new Lightcone();
const browseWebTool = {
name: "browse_web",
description: "Visit a URL, interact with the page, and take a screenshot",
parameters: {
url: { type: "string" as const, description: "URL to visit" },
},
execute: async ({ url }: { url: string }) => {
const computer = await lightcone.computers.create({ kind: "browser" });
const id = computer.id!;
await lightcone.computers.navigate(id, { url });
const result = await lightcone.computers.screenshot(id);
await lightcone.computers.delete(id);
return { screenshot: result.result?.screenshot_url };
},
};
const agent = new Agent({
name: "Web Researcher",
instructions: "You are a helpful assistant that can browse the web.",
model: tzafon("tzafon.northstar-cua-fast"),
tools: { browse_web: browseWebTool },
});
const response = await agent.generate(
"Visit https://news.ycombinator.com and describe the top stories"
);
console.log(response.text);

Mastra agents use tools to interact with external systems. Lightcone’s computer actions are wrapped as Mastra tools. When the model decides it needs to visit a web page, it calls the tool, which creates a computer session, performs actions, and returns results.