agents 0.0.0-20a8689 → 0.0.0-25aeaf2

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.
@@ -1,15 +1,29 @@
1
+ import { MCPClientManager } from './client.js';
1
2
  import { DurableObject } from 'cloudflare:workers';
3
+ import { Connection, WSMessage } from 'partyserver';
2
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
- import { Connection } from 'partyserver';
5
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
+ import 'zod';
7
+ import '@modelcontextprotocol/sdk/types.js';
8
+ import '@modelcontextprotocol/sdk/client/index.js';
9
+ import '@modelcontextprotocol/sdk/client/sse.js';
10
+ import './do-oauth-client-provider.js';
11
+ import '@modelcontextprotocol/sdk/client/auth.js';
12
+ import '@modelcontextprotocol/sdk/shared/auth.js';
13
+ import '@modelcontextprotocol/sdk/shared/protocol.js';
14
+ import 'ai';
4
15
 
5
16
  interface CORSOptions {
6
17
  origin?: string;
7
18
  methods?: string;
8
19
  headers?: string;
9
20
  maxAge?: number;
21
+ exposeHeaders?: string;
10
22
  }
23
+ type MaybePromise<T> = T | Promise<T>;
11
24
  declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
12
25
  #private;
26
+ get mcp(): MCPClientManager;
13
27
  protected constructor(ctx: DurableObjectState, env: Env);
14
28
  /**
15
29
  * Agents API allowlist
@@ -23,14 +37,18 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
23
37
  /**
24
38
  * McpAgent API
25
39
  */
26
- abstract server: McpServer;
40
+ abstract server: MaybePromise<McpServer | Server>;
27
41
  props: Props;
28
42
  initRun: boolean;
29
43
  abstract init(): Promise<void>;
30
44
  _init(props: Props): Promise<void>;
45
+ setInitialized(): Promise<void>;
46
+ isInitialized(): Promise<boolean>;
31
47
  fetch(request: Request): Promise<Response>;
32
48
  getWebSocket(): WebSocket | null;
33
- onMCPMessage(sessionId: string, request: Request): Promise<Response>;
49
+ getWebSocketForResponseID(id: string): WebSocket | null;
50
+ onMessage(connection: Connection, event: WSMessage): Promise<void>;
51
+ onSSEMcpMessage(sessionId: string, request: Request): Promise<Error | null>;
34
52
  webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
35
53
  webSocketError(ws: WebSocket, error: unknown): Promise<void>;
36
54
  webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
@@ -38,7 +56,19 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
38
56
  binding?: string;
39
57
  corsOptions?: CORSOptions;
40
58
  }): {
41
- fetch: (request: Request, env: Record<string, DurableObjectNamespace<McpAgent>>, ctx: ExecutionContext) => Promise<Response | undefined>;
59
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
60
+ };
61
+ static serveSSE(path: string, { binding, corsOptions, }?: {
62
+ binding?: string;
63
+ corsOptions?: CORSOptions;
64
+ }): {
65
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
66
+ };
67
+ static serve(path: string, { binding, corsOptions, }?: {
68
+ binding?: string;
69
+ corsOptions?: CORSOptions;
70
+ }): {
71
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
42
72
  };
43
73
  }
44
74