Skip to content

Commit c33f3a8

Browse files
authored
Use packagemanagers for everything (#22506)
1 parent 4817c94 commit c33f3a8

File tree

70 files changed

+1428
-1639
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1428
-1639
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
import {
3+
PackageManagers as PackageManagersComponent,
4+
type PackageManagersProps,
5+
} from "starlight-package-managers";
6+
7+
type Props = PackageManagersProps;
8+
---
9+
10+
<PackageManagersComponent
11+
pkgManagers={["npm", "yarn", "pnpm", "bun"]}
12+
{...Astro.props}
13+
/>

src/components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
export * from "@astrojs/starlight/components";
33
export { Icon as StarlightIcon } from "@astrojs/starlight/components";
44
// Community packages
5-
export { PackageManagers } from "starlight-package-managers";
65
export { Icon as AstroIcon } from "astro-icon/components";
76
// Custom components
87
export { default as AnchorHeading } from "./AnchorHeading.astro";
@@ -34,6 +33,7 @@ export { default as ListTutorials } from "./ListTutorials.astro";
3433
export { default as Markdown } from "./Markdown.astro";
3534
export { default as MetaInfo } from "./MetaInfo.astro";
3635
export { default as NetworkMap } from "./NetworkMap.astro";
36+
export { default as PackageManagers } from "./PackageManagers.astro";
3737
export { default as PagesBuildEnvironment } from "./PagesBuildEnvironment.astro";
3838
export { default as PagesBuildEnvironmentLanguages } from "./PagesBuildEnvironmentLanguages.astro";
3939
export { default as PagesBuildEnvironmentTools } from "./PagesBuildEnvironmentTools.astro";

src/content/docs/agents/api-reference/browse-the-web.mdx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ sidebar:
55
order: 7
66
---
77

8-
import { MetaInfo, Render, Type, TypeScriptExample, WranglerConfig } from "~/components";
8+
import {
9+
MetaInfo,
10+
Render,
11+
Type,
12+
TypeScriptExample,
13+
WranglerConfig,
14+
PackageManagers,
15+
} from "~/components";
916

1017
Agents can browse the web using the [Browser Rendering](/browser-rendering/) API or your preferred headless browser service.
1118

@@ -30,8 +37,11 @@ export class MyAgent extends Agent<Env> {
3037
const page = await browser.newPage();
3138
await page.goto(url);
3239

33-
await page.waitForSelector('body');
34-
const bodyContent = await page.$eval('body', (element) => element.innerHTML);
40+
await page.waitForSelector("body");
41+
const bodyContent = await page.$eval(
42+
"body",
43+
(element) => element.innerHTML,
44+
);
3545
const client = new OpenAI({
3646
apiKey: this.env.OPENAI_API_KEY,
3747
});
@@ -40,12 +50,12 @@ export class MyAgent extends Agent<Env> {
4050
model: this.env.MODEL,
4151
messages: [
4252
{
43-
role: 'user',
53+
role: "user",
4454
content: `Return a JSON object with the product names, prices and URLs with the following format: { "name": "Product Name", "price": "Price", "url": "URL" } from the website content below. <content>${bodyContent}</content>`,
4555
},
4656
],
4757
response_format: {
48-
type: 'json_object',
58+
type: "json_object",
4959
},
5060
});
5161

@@ -62,19 +72,17 @@ export class MyAgent extends Agent<Env> {
6272

6373
You'll also need to add install the `@cloudflare/puppeteer` package and add the following to the wrangler configuration of your Agent:
6474

65-
```sh
66-
npm install @cloudflare/puppeteer --save-dev
67-
```
75+
<PackageManagers pkg="@cloudflare/puppeteer" dev />
6876

6977
<WranglerConfig>
7078

7179
```jsonc
7280
{
7381
// ...
7482
"browser": {
75-
"binding": "MYBROWSER"
76-
}
77-
// ...
83+
"binding": "MYBROWSER",
84+
},
85+
// ...
7886
}
7987
```
8088

@@ -90,6 +98,7 @@ Once you have your [Browserbase API key](https://docs.browserbase.com/integratio
9098
cd your-agent-project-folder
9199
npx wrangler@latest secret put BROWSERBASE_API_KEY
92100
```
101+
93102
```sh output
94103
Enter a secret value: ******
95104
Creating the secret for the Worker "agents-example"
@@ -98,9 +107,7 @@ Success! Uploaded secret BROWSERBASE_API_KEY
98107

99108
Install the `@cloudflare/puppeteer` package and use it from within your Agent to call the Browserbase API:
100109

101-
```sh
102-
npm install @cloudflare/puppeteer
103-
```
110+
<PackageManagers pkg="@cloudflare/puppeteer" />
104111

105112
<TypeScriptExample>
106113

0 commit comments

Comments
 (0)