agents 0.0.0-b30ffda → 0.0.0-b803d5e

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,37 @@
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
- #private;
25
+ private _status;
26
+ private _transport?;
27
+ private _transportType;
28
+ private _requestIdToConnectionId;
29
+ /**
30
+ * Since McpAgent's _aren't_ yet real "Agents", let's only expose a couple of the methods
31
+ * to the outer class: initialState/state/setState/onStateUpdate/sql
32
+ */
33
+ private _agent;
34
+ get mcp(): MCPClientManager;
13
35
  protected constructor(ctx: DurableObjectState, env: Env);
14
36
  /**
15
37
  * Agents API allowlist
@@ -23,14 +45,19 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
23
45
  /**
24
46
  * McpAgent API
25
47
  */
26
- abstract server: McpServer;
48
+ abstract server: MaybePromise<McpServer | Server>;
27
49
  props: Props;
28
50
  initRun: boolean;
29
51
  abstract init(): Promise<void>;
30
52
  _init(props: Props): Promise<void>;
53
+ setInitialized(): Promise<void>;
54
+ isInitialized(): Promise<boolean>;
55
+ private _initialize;
31
56
  fetch(request: Request): Promise<Response>;
32
57
  getWebSocket(): WebSocket | null;
33
- onMCPMessage(sessionId: string, request: Request): Promise<Response>;
58
+ getWebSocketForResponseID(id: string): WebSocket | null;
59
+ onMessage(connection: Connection, event: WSMessage): Promise<void>;
60
+ onSSEMcpMessage(sessionId: string, request: Request): Promise<Error | null>;
34
61
  webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
35
62
  webSocketError(ws: WebSocket, error: unknown): Promise<void>;
36
63
  webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
@@ -38,7 +65,19 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
38
65
  binding?: string;
39
66
  corsOptions?: CORSOptions;
40
67
  }): {
41
- fetch: (request: Request, env: Record<string, DurableObjectNamespace<McpAgent>>, ctx: ExecutionContext) => Promise<Response | undefined>;
68
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
69
+ };
70
+ static serveSSE(path: string, { binding, corsOptions, }?: {
71
+ binding?: string;
72
+ corsOptions?: CORSOptions;
73
+ }): {
74
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
75
+ };
76
+ static serve(path: string, { binding, corsOptions, }?: {
77
+ binding?: string;
78
+ corsOptions?: CORSOptions;
79
+ }): {
80
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
42
81
  };
43
82
  }
44
83