Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export default defineConfig({
{ label: "Browserbase", slug: "integrations/browserbase" },
{ label: "Smithery", slug: "integrations/smithery" },
{ label: "Daytona", slug: "integrations/daytona" },
{ label: "Lightcone", slug: "integrations/tzafon" },
],
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ With AgentKit, you get:

🛠️ **Powerful tools building API** with support for [MCP as tools](/advanced-patterns/mcp).

🔌 **Integrates** with your favorite AI libraries and products (ex: [E2B](/integrations/e2b), [Browserbase](/integrations/browserbase), [Smithery](/integrations/smithery), [Daytona](/integrations/daytona)).
🔌 **Integrates** with your favorite AI libraries and products (ex: [E2B](/integrations/e2b), [Browserbase](/integrations/browserbase), [Smithery](/integrations/smithery), [Daytona](/integrations/daytona), [Lightcone](/integrations/tzafon)).

⚡ **Stream live updates** to your UI with [UI Streaming](/advanced-patterns/legacy-ui-streaming).

Expand Down
181 changes: 181 additions & 0 deletions docs/src/content/docs/integrations/tzafon.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
---
title: Using AgentKit with Lightcone
description: "Develop AI Agents that can browse the web using Lightcone"
---

import { Steps, Tabs, TabItem, LinkCard } from '@astrojs/starlight/components';

[Lightcone](https://docs.lightcone.ai) (by [Tzafon](https://www.tzafon.ai)) provides managed cloud browsers and computers to enable Agents to browse the web autonomously.

## Building AgentKit tools using Lightcone

Creating AgentKit [tools](/concepts/tools) using the Lightcone TypeScript SDK is straightforward.

<Steps>

1. **Install AgentKit**

Within an existing project, install AgentKit, Lightcone and Playwright core:

<Tabs>
<TabItem label="npm">
```shell
npm install @inngest/agent-kit inngest @tzafon/lightcone playwright-core
```
</TabItem>
<TabItem label="pnpm">
```shell
pnpm install @inngest/agent-kit inngest @tzafon/lightcone playwright-core
```
</TabItem>
<TabItem label="yarn">
```shell
yarn add @inngest/agent-kit inngest @tzafon/lightcone playwright-core
```
</TabItem>
</Tabs>

<details>
<summary>Don't have an existing project?</summary>

To create a new project, create a new directory then initialize using your package manager:

<Tabs>
<TabItem label="npm">
```shell
mkdir my-agent-kit-project && npm init
```
</TabItem>
<TabItem label="pnpm">
```shell
mkdir my-agent-kit-project && pnpm init
```
</TabItem>
<TabItem label="yarn">
```shell
mkdir my-agent-kit-project && yarn init
```
</TabItem>
</Tabs>

</details>

2. **Setup an AgentKit Network with an Agent**

Create an Agent and its associated Network, for example a Wikipedia Search Agent:

```typescript
import {
openai,
createAgent,
createNetwork,
} from "@inngest/agent-kit";

const searchAgent = createAgent({
name: "wikipedia_searcher",
description: "An agent that searches Wikipedia for relevant information",
system:
"You are a helpful assistant that searches Wikipedia for relevant information.",
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Attach the Lightcone tool in the guide snippet

Following the guide as written creates searchWikipedia in the next step but never adds it to searchAgent, so the documented network has an agent with no tools and cannot actually browse Wikipedia via Lightcone. The complete example includes tools: [searchWikipedia]; the integration guide should also instruct readers to add that property when defining or updating the agent.

Useful? React with 👍 / 👎.


// Create the network
const wikipediaSearchNetwork = createNetwork({
name: "wikipedia_search_network",
description: "A network that searches Wikipedia using Lightcone",
agents: [searchAgent],
maxIter: 2,
defaultModel: openai({
model: "gpt-4o-mini",
apiKey: process.env.OPENAI_API_KEY,
}),
});
```

3. **Create a Lightcone tool**

Let's configure the Lightcone SDK and create a tool that can search Wikipedia:

```typescript {5, 8-9, 11-13}
import {
openai,
createAgent,
createNetwork,
createTool,
} from "@inngest/agent-kit";
import { z } from "zod";
import { chromium } from "playwright-core";
import Lightcone from "@tzafon/lightcone";

const client = new Lightcone({
apiKey: process.env.LIGHTCONE_API_KEY as string,
});

const BASE_URL = "https://api.tzafon.ai";

// Create a tool to search Wikipedia using Lightcone
const searchWikipedia = createTool({
name: "search_wikipedia",
description: "Search Wikipedia for relevant information",
parameters: z.object({
query: z.string().describe("The search query for Wikipedia"),
}),
handler: async ({ query }, { step }) => {
return await step?.run("search-on-wikipedia", async () => {
// Spin up a cloud browser
const session = await client.computers.create({ kind: "browser" });

// Build the CDP URL from the session endpoint and connect
const cdpUrl = `${BASE_URL}${session.endpoints?.cdp}`;
const browser = await chromium.connectOverCDP(cdpUrl, {
headers: {
Authorization: `Bearer ${process.env.LIGHTCONE_API_KEY}`,
},
});

try {
const page = browser.contexts()[0].pages()[0];

await page.goto(
`https://en.wikipedia.org/w/index.php?search=${encodeURIComponent(query)}`,
{ waitUntil: "domcontentloaded" },
);

// If we landed on a results page, open the first result
const firstResult = page
.locator("ul.mw-search-results li div.mw-search-result-heading a")
.first();
if (await firstResult.count()) {
await firstResult.click();
await page.waitForLoadState("domcontentloaded");
}

const title = await page.title();
const content = await page.innerText("#mw-content-text");
return `${title}\n\n${content.slice(0, 4000)}`;
} finally {
await browser.close();
await client.computers.delete(session.id!);
}
});
},
});
```

:::note
Configure your `LIGHTCONE_API_KEY` in the `.env` file. You can find your API
key and setup instructions in the [Lightcone docs](https://docs.lightcone.ai).
:::

:::tip
We recommend building tools using Lightcone with Inngest's `step.run()` function. This ensures that the tool will only run once across multiple runs.

More information about using `step.run()` can be found in the [Multi steps tools](/advanced-patterns/multi-steps-tools) page.
:::

</Steps>

### Example: Wikipedia Search Agent using Lightcone

You will find a complete example of a Wikipedia search agent using Lightcone in the Wikipedia Search Agent example:

<LinkCard title="Wikipedia Search Agent using Lightcone" href="https://github.com/inngest/agent-kit/tree/main/examples/wikipedia-search-tzafon#readme" description="This example shows how to build tools using Lightcone to power a Wikipedia search agent." />
2 changes: 2 additions & 0 deletions examples/wikipedia-search-tzafon/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
OPENAI_API_KEY=your_openai_api_key # Get from https://platform.openai.com/api-keys
LIGHTCONE_API_KEY=your_lightcone_api_key # Get from https://docs.lightcone.ai
80 changes: 80 additions & 0 deletions examples/wikipedia-search-tzafon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Wikipedia Search Agent with Lightcone and Agent Kit

This example demonstrates how to build an AI-powered Wikipedia search agent using AgentKit and [Lightcone](https://docs.lightcone.ai) (by Tzafon). The agent can search Wikipedia for information using natural language queries and return relevant results.

## Features

- 🤖 AI-powered Wikipedia search using GPT-4o mini
- 🌐 Browser automation with Lightcone's managed cloud browsers
- 🔍 Semantic search capabilities
- ⚡️ Built with Inngest Agent Kit for robust agent orchestration

## Prerequisites

- Node.js (v20 or later)
- A [Lightcone](https://docs.lightcone.ai) account and API key. You can find more information in the [docs](https://docs.lightcone.ai).
- An OpenAI API key

## Setup

1. Install dependencies:

```bash
pnpm install
```

2. Create a `.env` file in the project root with the following variables:

```env
LIGHTCONE_API_KEY=your_lightcone_api_key
OPENAI_API_KEY=your_openai_api_key
```

## How It Works

The example consists of several key components:

1. **Wikipedia Search Tool**: A custom tool built with Lightcone that searches Wikipedia using browser automation.

2. **Search Agent**: An AI agent powered by GPT-4o mini that understands natural language queries and uses the Wikipedia search tool.

3. **Agent Network**: A network configuration that orchestrates the agent's behavior and manages the conversation flow.

The agent uses Lightcone to:

- Create browser sessions
- Navigate to Wikipedia's search interface
- Perform searches
- Extract relevant information

## Usage

1. Start the server:

```bash
pnpm dev
```

The server will start on port 3000.

2. Start the Inngest Dev Server

```bash
npx inngest-cli@latest dev
```

The Inngest Dev Server will start at [http://127.0.0.1:8288/](http://127.0.0.1:8288/).

3. Trigger the function

Navigate to the Inngest Dev Server runs view: [http://127.0.0.1:8288/functions](http://127.0.0.1:8288/functions).

From there, trigger the `wikipedia_search_network` function with your query:

```json
{
"data": {
"input": "Who won the super bowl in 2024?"
}
}
```
23 changes: 23 additions & 0 deletions examples/wikipedia-search-tzafon/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "wikipedia-search-tzafon",
"version": "1.0.0",
"description": "AgentKit + Lightcone Wikipedia search example",
"scripts": {
"dev": "tsx watch src/main.ts"
},
"keywords": [],
"author": "",
"license": "MIT",
"packageManager": "pnpm@10.26.2",
"dependencies": {
"@inngest/agent-kit": "^0.13.2",
"@tzafon/lightcone": "^0.19.0",
"dotenv": "^17.2.3",
"playwright-core": "^1.57.0",
"zod": "^4.2.1"
},
"devDependencies": {
"@types/node": "^25.0.3",
"tsx": "^4.21.0"
}
}
Loading