Skip to content

Commit 04558c3

Browse files
committed
headers
1 parent 2f37e7f commit 04558c3

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class MyAgent extends Agent<Env, State> {
113113
}
114114
```
115115

116-
### WebSocket connection Handling
116+
### WebSocket connection handling
117117

118118
#### Connection
119119

@@ -166,7 +166,7 @@ interface ConnectionContext {
166166

167167
### State Management
168168

169-
#### State Management
169+
#### State management
170170

171171
Methods and types for managing Agent state.
172172

@@ -280,9 +280,9 @@ type Schedule<T = any> = {
280280
let task = await this.schedule(300, "methodToCall", { message: "data-to-send-to-method" });
281281
```
282282

283-
### SQL Database Access
283+
### SQL database
284284

285-
#### SQL Query API
285+
#### SQL query API
286286

287287
Execute SQL queries against the Agent's built-in SQLite database using the `this.sql` method within any method on your `Agent` class.
288288

@@ -359,7 +359,7 @@ function agentFetch(
359359
): Promise<Response>;
360360
```
361361

362-
### React Integration
362+
### React API
363363

364364
The `agents-sdk` provides a React API for simplifying connection and routing to Agents from front-end frameworks, including React Router (Remix), Next.js, and Astro.
365365

@@ -425,7 +425,7 @@ class AIChatAgent<Env = unknown> extends Agent<Env> {
425425
}
426426
```
427427

428-
### AI React Hooks
428+
### Chat Agent React API
429429

430430
#### useAgentChat
431431

@@ -471,7 +471,6 @@ To learn more about how to manage state within an Agent, refer to the documentat
471471

472472
:::
473473

474-
475474
### Next steps
476475

477476
* [Build a chat Agent](/agents/getting-started/build-a-chat-agent/) using the `agents-sdk` and deploy it to Workers.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { MetaInfo, Render, Type, TypeScriptExample, WranglerConfig } from "~/com
1010

1111
Learn how to call your Agents from Workers, including how to create Agents on-the-fly, address them, and route requests to specific instances of an Agent.
1212

13-
## Calling your Agent
13+
### Calling your Agent
1414

1515
Agents are created on-the-fly and can serve multiple requests concurrently. Each Agent instance is isolated from other instances, can maintain its own state, and has a unique address.
1616

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { MetaInfo, Render, Type, WranglerConfig } from "~/components";
99

1010
An Agent is configured like any other Cloudflare Workers project, and uses [a wrangler configuration](/workers/wrangler/configuration/) file to define where your code is and what services (bindings) it will use.
1111

12+
### Project structure
13+
1214
The typical file structure for an Agent project created from `npm create cloudflare@latest agents-starter -- --template cloudflare/agents-starter` follows:
1315

1416
```sh
@@ -28,6 +30,8 @@ The typical file structure for an Agent project created from `npm create cloudfl
2830
`-- wrangler.jsonc // your Workers & Agent configuration
2931
```
3032

33+
### Example configuration
34+
3135
Below is a minimal `wrangler.jsonc` file that defines the configuration for an Agent, including the entry point, `durable_object` namespace, and code `migrations`:
3236

3337
<WranglerConfig>
@@ -70,3 +74,5 @@ The configuration includes:
7074
- A `main` field that points to the entry point of your Agent, which is typically a TypeScript (or JavaScript) file.
7175
- A `durable_objects` field that defines the [Durable Object namespace](/durable-objects/reference/glossary/) that your Agents will run within.
7276
- A `migrations` field that defines the code migrations that your Agent will use. This field is mandatory and must contain at least one migration. The `new_sqlite_classes` field is mandatory for the Agent to store state.
77+
78+
Agents must define these fields in their `wrangler.jsonc` (or `wrangler.toml`) config file.

src/content/docs/agents/api-reference/http-sse.mdx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ import { MetaInfo, Render, Type, TypeScriptExample, WranglerConfig } from "~/com
1010

1111
The Agents SDK allows you to handle HTTP requests and has native support for [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) (SSE). This allows you build applications that can push data to clients, avoid buffering
1212

13-
## Handling HTTP requests
13+
### Handling HTTP requests
1414

1515
Agents can handle HTTP requests using the `onRequest` method, which is called whenever an HTTP request is received by the Agent instance. The method takes a `Request` object as a parameter and returns a `Response` object.
1616

17-
18-
1917
<TypeScriptExample>
2018

2119
```ts
@@ -99,7 +97,6 @@ export default {
9997

10098
</TypeScriptExample>
10199

102-
## WebSockets vs. Server-Sent Events
103-
104-
100+
### WebSockets vs. Server-Sent Events
105101

102+
TODO

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class ChatAgent extends Agent {
3838

3939
</TypeScriptExample>
4040

41-
## Connecting clients
41+
### Connecting clients
4242

4343
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:
4444

@@ -66,7 +66,7 @@ connection.send(
6666

6767
</TypeScriptExample>
6868

69-
## React clients
69+
### React clients
7070

7171
React-based applications can import `agents-sdk/react` and use the `useAgent` hook to connect to an instance of an Agent directly:
7272

@@ -107,7 +107,7 @@ function AgentInterface() {
107107

108108
The `useAgent` hook automatically handles the lifecycle of the connection, ensuring that it is properly initialized and cleaned up when the component mounts and unmounts. You can also [combine `useAgent` with `useState`](/agents/api-reference/store-and-sync-state/) to automatically synchronize state across all clients connected to your Agent.
109109

110-
## Handling WebSocket events
110+
### Handling WebSocket events
111111

112112
Define `onError` and `onClose` methods on your Agent to explicitly handle WebSocket client errors and close events. Log errors, clean up state, and/or emit metrics:
113113

0 commit comments

Comments
 (0)