Skip to content

Commit ae05a2e

Browse files
committed
@cloudflare/agents -> agents-sdk
1 parent c90c75c commit ae05a2e

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

src/content/docs/agents/api-reference/sdk.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ sidebar:
88

99
import { MetaInfo, Render, Type, TypeScriptExample, WranglerConfig } from "~/components";
1010

11-
At its most basic, an Agent is a JavaScript class that extends the `Agent` class from the `@cloudflare/agents` package. An Agent encapsulates all of the logic for an Agent, including how clients can connect to it, how it stores state, the methods it exposes, and any error handling.
11+
At its most basic, an Agent is a JavaScript class that extends the `Agent` class from the `agents-sdk` package. An Agent encapsulates all of the logic for an Agent, including how clients can connect to it, how it stores state, the methods it exposes, and any error handling.
1212

1313
<TypeScriptExample>
1414

1515
```ts
16-
import { Agent } from "@cloudflare/agents";
16+
import { Agent } from "agents-sdk";
1717

1818
class MyAgent extends Agent {
1919
// Define methods on the Agent
@@ -30,14 +30,14 @@ Instances of an Agent are addressed by a unique identifier: that identifier (ID)
3030

3131
## The Agent class
3232

33-
Writing an Agent requires you to define a class that extends the `Agent` class from the `@cloudflare/agents` package. An Agent encapsulates all of the logic for an Agent, including how clients can connect to it, how it stores state, the methods it exposes, and any error handling.
33+
Writing an Agent requires you to define a class that extends the `Agent` class from the `agents-sdk` package. An Agent encapsulates all of the logic for an Agent, including how clients can connect to it, how it stores state, the methods it exposes, and any error handling.
3434

3535
An Agent has the following class methods:
3636

3737
<TypeScriptExample>
3838

3939
```ts
40-
import { Agent } from "@cloudflare/agents";
40+
import { Agent } from "agents-sdk";
4141

4242
interface Env {
4343
// Define environment variables & bindings here
@@ -87,7 +87,7 @@ class MyAgent extends Agent<Env> {
8787
}
8888

8989
// Called when the Agent's state is updated
90-
// via this.setState or the useAgent hook from the @cloudflare/agents/react package.
90+
// via this.setState or the useAgent hook from the agents-sdk/react package.
9191
async onStateUpdate(state: any) {
9292
// 'state' will be typed if you supply a type parameter to the Agent class.
9393
}
@@ -121,7 +121,7 @@ These three patterns are shown below: we recommend using either `routeAgentReque
121121
<TypeScriptExample>
122122

123123
```ts
124-
import { Agent, AgentNamespace, getAgentByName, routeAgentRequest } from '@cloudflare/agents';
124+
import { Agent, AgentNamespace, getAgentByName, routeAgentRequest } from 'agents-sdk';
125125

126126
interface Env {
127127
// Define your Agent on the environment here
@@ -134,7 +134,7 @@ export default {
134134
async fetch(request, env, ctx): Promise<Response> {
135135
// Routed addressing
136136
// Automatically routes HTTP requests and/or WebSocket connections to /agents/:agent/:name
137-
// Best for: connecting React apps directly to Agents using useAgent from @cloudflare/agents/react
137+
// Best for: connecting React apps directly to Agents using useAgent from agents-sdk/react
138138
(await routeAgentRequest(request, env)) || Response.json({ msg: 'no agent here' }, { status: 404 });
139139

140140
// Named addressing

src/content/docs/agents/examples/manage-and-sync-state.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Every Agent has built-in state management capabilities. You can set and update t
2323
<TypeScriptExample>
2424

2525
```ts
26-
import { Agent } from "@cloudflare/agents";
26+
import { Agent } from "agents-sdk";
2727

2828
export class MyAgent extends Agent {
2929
// Update state in response to events
@@ -58,7 +58,7 @@ If you're using TypeScript, you can also provide a type for your Agent's state b
5858
<TypeScriptExample>
5959

6060
```ts
61-
import { Agent } from "@cloudflare/agents";
61+
import { Agent } from "agents-sdk";
6262

6363
interface Env {}
6464

@@ -92,15 +92,15 @@ export class MyAgent extends Agent<Env, FlightRecord> {
9292

9393
### Synchronizing state
9494

95-
Clients can connect to an Agent and stay synchronized with its state using the React hooks provided as part of `@cloudflare/agents/react`.
95+
Clients can connect to an Agent and stay synchronized with its state using the React hooks provided as part of `agents-sdk/react`.
9696

9797
A React application can call `useAgent` to connect to a named Agent over WebSockets at
9898

9999
<TypeScriptExample>
100100

101101
```ts
102102
import { useState } from "react";
103-
import { useAgent } from "@cloudflare/agents/react";
103+
import { useAgent } from "agents-sdk/react";
104104

105105
function StateInterface() {
106106
const [state, setState] = useState({ counter: 0 });

src/content/docs/agents/examples/schedule-tasks.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ You can call `this.schedule` within any method on an Agent, and schedule tens-of
1818
<TypeScriptExample>
1919

2020
```ts
21-
import { Agent } from "@cloudflare/agents"
21+
import { Agent } from "agents-sdk"
2222

2323
export class SchedulingAgent extends Agent {
2424
async onRequest(request) {

src/content/docs/agents/examples/using-ai-models.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Instead of buffering the entire response, or risking the client disconecting, yo
2929
<TypeScriptExample file="src/index.ts">
3030

3131
```ts
32-
import { Agent } from "@cloudflare/agents"
32+
import { Agent } from "agents-sdk"
3333
import { OpenAI } from "openai"
3434

3535
export class MyAgent extends Agent<Env> {
@@ -88,7 +88,7 @@ Workers AI supports streaming responses out-of-the-box by setting `stream: true`
8888
<TypeScriptExample file="src/index.ts">
8989

9090
```ts
91-
import { Agent } from "@cloudflare/agents"
91+
import { Agent } from "agents-sdk"
9292

9393
interface Env {
9494
AI: Ai;
@@ -138,7 +138,7 @@ Model routing allows you to route requests to different AI models based on wheth
138138
<TypeScriptExample file="src/index.ts">
139139

140140
```ts
141-
import { Agent } from "@cloudflare/agents"
141+
import { Agent } from "agents-sdk"
142142

143143
interface Env {
144144
AI: Ai;
@@ -192,7 +192,7 @@ npm install ai @ai-sdk/openai
192192
<TypeScriptExample file="src/index.ts">
193193

194194
```ts
195-
import { Agent } from "@cloudflare/agents"
195+
import { Agent } from "agents-sdk"
196196
import { generateText } from 'ai';
197197
import { openai } from '@ai-sdk/openai';
198198

@@ -219,7 +219,7 @@ Agents can stream responses back over HTTP using Server Sent Events (SSE) from w
219219
<TypeScriptExample file="src/index.ts">
220220

221221
```ts
222-
import { Agent } from "@cloudflare/agents"
222+
import { Agent } from "agents-sdk"
223223
import { OpenAI } from "openai"
224224

225225
export class MyAgent extends Agent<Env> {

src/content/docs/agents/examples/websockets.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Here's an example of an Agent that echoes back any message it receives:
2020
<TypeScriptExample>
2121

2222
```ts
23-
import { Agent, Connection } from "@cloudflare/agents";
23+
import { Agent, Connection } from "agents-sdk";
2424

2525
export class ChatAgent extends Agent {
2626
async onConnect(connection: Connection, ctx: ConnectionContext) {
@@ -55,12 +55,12 @@ export class ChatAgent extends Agent {
5555

5656
## Connecting clients
5757

58-
The Agent framework includes a useful helper package for connecting directly to your Agent (or other Agents) from a client application. Import `@cloudflare/agents/client`, create an instance of `AgentClient` and use it to connect to an instance of your Agent:
58+
The Agent framework includes a useful helper package for connecting directly to your Agent (or other Agents) from a client application. Import `agents-sdk/client`, create an instance of `AgentClient` and use it to connect to an instance of your Agent:
5959

6060
<TypeScriptExample>
6161

6262
```ts
63-
import { AgentClient } from "@cloudflare/agents/client";
63+
import { AgentClient } from "agents-sdk/client";
6464

6565
const connection = new AgentClient({
6666
agent: "dialogue-agent",
@@ -83,12 +83,12 @@ connection.send(
8383

8484
## React clients
8585

86-
React-based applications can import `@cloudflare/agents/react` and use the `useAgent` hook to connect to an instance of an Agent directly:
86+
React-based applications can import `agents-sdk/react` and use the `useAgent` hook to connect to an instance of an Agent directly:
8787

8888
<TypeScriptExample>
8989

9090
```ts
91-
import { useAgent } from "@cloudflare/agents/react";
91+
import { useAgent } from "agents-sdk/react";
9292

9393
function AgentInterface() {
9494
const connection = useAgent({
@@ -129,7 +129,7 @@ Define `onError` and `onClose` methods on your Agent to explicitly handle WebSoc
129129
<TypeScriptExample>
130130

131131
```ts
132-
import { Agent, Connection } from "@cloudflare/agents";
132+
import { Agent, Connection } from "agents-sdk";
133133

134134
export class ChatAgent extends Agent {
135135
// onConnect and onMessage methods

src/content/docs/agents/getting-started/quick-start.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Open up `src/index.ts` in your favorite text editor:
5757
<TypeScriptExample filename="src/index.ts">
5858

5959
```ts
60-
import { Agent } from "@cloudflare/agents";
60+
import { Agent } from "agents-sdk";
6161

6262
export class MyAgent extends Agent {
6363

src/content/docs/agents/getting-started/testing-your-agent.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Because Agents run on Cloudflare Workers and Durable Objects, they can be tested
1616

1717
:::note
1818

19-
The `@cloudflare/agents-starter` template and new Cloudflare Workers projects already include the relevant `vitest` and `@cloudflare/vitest-pool-workers` packages, as well as a valid `vitest.config.js` file.
19+
The `agents-sdk-starter` template and new Cloudflare Workers projects already include the relevant `vitest` and `@cloudflare/vitest-pool-workers` packages, as well as a valid `vitest.config.js` file.
2020

2121
:::
2222

src/content/docs/agents/guides/human-in-the-loop.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ external_link: https://github.com/cloudflare/agents/tree/main/guides/anthropic-p
55
sidebar:
66
order: 3
77
head: []
8-
description: Implement common agent patterns using the `@cloudflare/agents` framework.
8+
description: Implement common agent patterns using the `agents-sdk` framework.
99
---

0 commit comments

Comments
 (0)