You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
12
12
13
13
<TypeScriptExample>
14
14
15
15
```ts
16
-
import { Agent } from"@cloudflare/agents";
16
+
import { Agent } from"agents-sdk";
17
17
18
18
classMyAgentextendsAgent {
19
19
// Define methods on the Agent
@@ -30,14 +30,14 @@ Instances of an Agent are addressed by a unique identifier: that identifier (ID)
30
30
31
31
## The Agent class
32
32
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.
34
34
35
35
An Agent has the following class methods:
36
36
37
37
<TypeScriptExample>
38
38
39
39
```ts
40
-
import { Agent } from"@cloudflare/agents";
40
+
import { Agent } from"agents-sdk";
41
41
42
42
interfaceEnv {
43
43
// Define environment variables & bindings here
@@ -87,7 +87,7 @@ class MyAgent extends Agent<Env> {
87
87
}
88
88
89
89
// 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.
91
91
async onStateUpdate(state:any) {
92
92
// 'state' will be typed if you supply a type parameter to the Agent class.
93
93
}
@@ -121,7 +121,7 @@ These three patterns are shown below: we recommend using either `routeAgentReque
@@ -55,12 +55,12 @@ export class ChatAgent extends Agent {
55
55
56
56
## Connecting clients
57
57
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:
Copy file name to clipboardExpand all lines: src/content/docs/agents/getting-started/testing-your-agent.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Because Agents run on Cloudflare Workers and Durable Objects, they can be tested
16
16
17
17
:::note
18
18
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.
0 commit comments