hono-agents 0.0.0-eede2bd → 0.0.0-ef38e84
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 +21 -16
- package/dist/index.d.ts +5 -3
- package/dist/index.js +2112 -32
- package/dist/index.js.map +1 -1
- package/package.json +32 -29
- package/src/index.ts +4 -5
package/README.md
CHANGED
|
@@ -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: "agents"
|
|
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
|
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
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
|