Skip to content

Commit ae31415

Browse files
committed
add generated code snippet to quickstart
1 parent 6424a0a commit ae31415

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

docs/getting-started/quickstart.mdx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,60 @@ icon: rocket
1212
npx create-magnitude-app
1313
```
1414
This script will create a project from a starter template based on your preferences. Simply follow the instructions to set up your project and configure an LLM.
15+
16+
<Accordion title="See example code">
17+
```typescript
18+
import { startBrowserAgent } from "magnitude-core";
19+
import z from 'zod';
20+
import dotenv from 'dotenv';
21+
22+
dotenv.config();
23+
24+
async function main() {
25+
const agent = await startBrowserAgent({
26+
// Starting URL for agent
27+
url: 'https://docs.magnitude.run/getting-started/quickstart',
28+
// Show thoughts and actions
29+
narrate: true,
30+
// LLM configuration
31+
llm: {
32+
provider: 'claude-code',
33+
options: {
34+
model: 'claude-sonnet-4-20250514'
35+
}
36+
},
37+
});
38+
39+
// Intelligently extract data based on the DOM content matching a provided zod schema
40+
const gettingStarted = await agent.extract('Extract how to get started with Magnitude', z.object({
41+
// Agent can extract existing data or new insights
42+
difficulty: z.enum(['easy', 'medium', 'hard']),
43+
steps: z.array(z.string()),
44+
}));
45+
46+
// Navigate to a new URL
47+
await agent.nav('https://magnitasks.com');
48+
49+
// Magnitude can handle high-level tasks
50+
await agent.act('Create a task', {
51+
// Optionally pass data that the agent will use where appropriate
52+
data: {
53+
title: 'Get started with Magnitude',
54+
description: gettingStarted.steps.map(step => `• ${step}`).join('\n')
55+
}
56+
});
57+
58+
// It can also handle low-level actions
59+
await agent.act('Drag "Get started with Magnitude" to the top of the in progress column');
60+
61+
// Stop agent and browser
62+
await agent.stop();
63+
}
64+
65+
main();
66+
67+
```
68+
</Accordion>
1569
</Step>
1670
<Step title="Run the example">
1771
```sh
@@ -25,6 +79,8 @@ icon: rocket
2579
</Step>
2680
</Steps>
2781

82+
83+
2884
🚀 Now you're ready to automate anything!
2985

3086
Continue reading docs to learn more about what you can do with the agent, or just keep building and let us know if you have any questions in our [Discord](https://discord.gg/VcdpMh9tTy)!

0 commit comments

Comments
 (0)