hono-agents 0.0.0-ff0679f → 0.0.0-ff431ff
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -19
- package/dist/index.d.ts +6 -4
- package/dist/index.js +1974 -37
- package/dist/index.js.map +1 -1
- package/package.json +32 -28
- package/src/index.ts +12 -22
package/README.md
CHANGED
|
@@ -7,15 +7,15 @@ Add intelligent, stateful AI agents to your Hono app. Create persistent AI agent
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install
|
|
10
|
+
npm install agents hono hono-agents
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { Hono } from "hono";
|
|
17
|
+
import { Agent } from "agents";
|
|
17
18
|
import { agentsMiddleware } from "hono-agents";
|
|
18
|
-
import { Agent } from "agents-sdk";
|
|
19
19
|
|
|
20
20
|
// Define your agent classes
|
|
21
21
|
export class ChatAgent extends Agent {
|
|
@@ -43,8 +43,8 @@ app.use(
|
|
|
43
43
|
const token = req.headers.get("authorization");
|
|
44
44
|
// validate token
|
|
45
45
|
if (!token) return new Response("Unauthorized", { status: 401 });
|
|
46
|
-
}
|
|
47
|
-
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
48
|
})
|
|
49
49
|
);
|
|
50
50
|
|
|
@@ -56,8 +56,8 @@ app.use(
|
|
|
56
56
|
"*",
|
|
57
57
|
agentsMiddleware({
|
|
58
58
|
options: {
|
|
59
|
-
prefix: "
|
|
60
|
-
}
|
|
59
|
+
prefix: "agents" // Handles /agents/* routes only
|
|
60
|
+
}
|
|
61
61
|
})
|
|
62
62
|
);
|
|
63
63
|
|
|
@@ -66,18 +66,23 @@ export default app;
|
|
|
66
66
|
|
|
67
67
|
## Configuration
|
|
68
68
|
|
|
69
|
-
To properly configure your Cloudflare Workers project to use agents,
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
To properly configure your Cloudflare Workers project to use agents, add bindings to your `wrangler.jsonc` file:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"durable_objects": {
|
|
74
|
+
"bindings": [
|
|
75
|
+
{ "name": "ChatAgent", "class_name": "ChatAgent" },
|
|
76
|
+
{ "name": "AssistantAgent", "class_name": "AssistantAgent" }
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"migrations": [
|
|
80
|
+
{
|
|
81
|
+
"tag": "v1",
|
|
82
|
+
"new_sqlite_classes": ["ChatAgent", "AssistantAgent"]
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
81
86
|
```
|
|
82
87
|
|
|
83
88
|
## How It Works
|
|
@@ -99,6 +104,6 @@ Agents can:
|
|
|
99
104
|
|
|
100
105
|
## License
|
|
101
106
|
|
|
102
|
-
Learn more about Cloudflare Agents at https://www.npmjs.com/package/agents
|
|
107
|
+
Learn more about Cloudflare Agents at https://www.npmjs.com/package/agents
|
|
103
108
|
|
|
104
109
|
ISC
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono0 from "hono";
|
|
2
2
|
import { Env } from "hono";
|
|
3
|
-
import { AgentOptions } from "agents
|
|
3
|
+
import { AgentOptions } from "agents";
|
|
4
4
|
|
|
5
|
+
//#region src/index.d.ts
|
|
5
6
|
/**
|
|
6
7
|
* Configuration options for the Cloudflare Agents middleware
|
|
7
8
|
*/
|
|
@@ -17,6 +18,7 @@ type AgentMiddlewareContext<E extends Env> = {
|
|
|
17
18
|
*/
|
|
18
19
|
declare function agentsMiddleware<E extends Env = Env>(
|
|
19
20
|
ctx?: AgentMiddlewareContext<E>
|
|
20
|
-
):
|
|
21
|
-
|
|
21
|
+
): hono0.MiddlewareHandler<Env, string, {}, Response>;
|
|
22
|
+
//#endregion
|
|
22
23
|
export { agentsMiddleware };
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|