Skip to content

Commit 40bfbef

Browse files
committed
fix client.fetch
1 parent 4189ff4 commit 40bfbef

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

.changeset/great-pans-jump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/agents": patch
3+
---
4+
5+
fix client.fetch

packages/agents/src/client.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,36 @@ import {
44
type PartyFetchOptions,
55
} from "partysocket";
66

7-
export type AgentClientOptions = Omit<PartySocketOptions, "prefix" | "room"> & {
8-
room?: string;
7+
export type AgentClientOptions = Omit<PartySocketOptions, "party" | "room"> & {
8+
agent: string;
9+
name?: string;
910
};
1011

1112
export type AgentClientFetchOptions = Omit<
1213
PartyFetchOptions,
13-
"prefix" | "room"
14+
"party" | "room"
1415
> & {
15-
room?: string;
16+
agent: string;
17+
name?: string;
1618
};
1719

1820
export class AgentClient extends PartySocket {
19-
static fetch(opts: AgentClientFetchOptions) {
20-
return PartySocket.fetch({
21-
prefix: "agents",
22-
room: "default",
23-
...opts,
24-
});
25-
}
2621
constructor(opts: AgentClientOptions) {
2722
super({
2823
prefix: "agents",
29-
room: "default",
24+
party: opts.agent,
25+
room: opts.name || "default",
3026
...opts,
3127
});
3228
}
3329
}
30+
31+
// @ts-ignore I don't know typescript
32+
AgentClient.fetch = (opts: AgentClientFetchOptions) => {
33+
return PartySocket.fetch({
34+
prefix: "agents",
35+
party: opts.agent,
36+
room: opts.name || "default",
37+
...opts,
38+
});
39+
};

0 commit comments

Comments
 (0)