agents 0.0.0-eede2bd → 0.0.0-f0c6dce
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 +131 -25
- package/dist/ai-chat-agent.d.ts +40 -10
- package/dist/ai-chat-agent.js +246 -143
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/ai-chat-v5-migration.d.ts +152 -0
- package/dist/ai-chat-v5-migration.js +19 -0
- package/dist/ai-react.d.ts +71 -67
- package/dist/ai-react.js +160 -55
- package/dist/ai-react.js.map +1 -1
- package/dist/ai-types.d.ts +36 -19
- package/dist/ai-types.js +6 -0
- package/dist/chunk-AVYJQSLW.js +17 -0
- package/dist/chunk-AVYJQSLW.js.map +1 -0
- package/dist/chunk-MWQSU7GK.js +1301 -0
- package/dist/chunk-MWQSU7GK.js.map +1 -0
- package/dist/chunk-PVQZBKN7.js +106 -0
- package/dist/chunk-PVQZBKN7.js.map +1 -0
- package/dist/chunk-QEVM4BVL.js +116 -0
- package/dist/chunk-QEVM4BVL.js.map +1 -0
- package/dist/chunk-UJVEAURM.js +150 -0
- package/dist/chunk-UJVEAURM.js.map +1 -0
- package/dist/{chunk-Q5ZBHY4Z.js → chunk-VYENMKFS.js} +209 -53
- package/dist/chunk-VYENMKFS.js.map +1 -0
- package/dist/client-B9tFv5gX.d.ts +4607 -0
- package/dist/client.d.ts +16 -2
- package/dist/client.js +7 -126
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +264 -23
- package/dist/index.js +13 -3
- package/dist/mcp/client.d.ts +9 -775
- package/dist/mcp/client.js +1 -2
- package/dist/mcp/do-oauth-client-provider.d.ts +3 -3
- package/dist/mcp/do-oauth-client-provider.js +3 -103
- package/dist/mcp/do-oauth-client-provider.js.map +1 -1
- package/dist/mcp/index.d.ts +49 -11
- package/dist/mcp/index.js +330 -184
- package/dist/mcp/index.js.map +1 -1
- package/dist/observability/index.d.ts +46 -0
- package/dist/observability/index.js +11 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/react.d.ts +89 -5
- package/dist/react.js +23 -9
- package/dist/react.js.map +1 -1
- package/dist/schedule.d.ts +81 -7
- package/dist/schedule.js +19 -8
- package/dist/schedule.js.map +1 -1
- package/dist/serializable.d.ts +32 -0
- package/dist/serializable.js +1 -0
- package/dist/serializable.js.map +1 -0
- package/package.json +83 -68
- package/src/index.ts +1132 -145
- package/dist/chunk-5W7ZWKOP.js +0 -617
- package/dist/chunk-5W7ZWKOP.js.map +0 -1
- package/dist/chunk-HMLY7DHA.js +0 -16
- package/dist/chunk-Q5ZBHY4Z.js.map +0 -1
- /package/dist/{chunk-HMLY7DHA.js.map → ai-chat-v5-migration.js.map} +0 -0
package/dist/mcp/client.js
CHANGED
|
@@ -10,9 +10,9 @@ declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
|
|
|
10
10
|
storage: DurableObjectStorage;
|
|
11
11
|
clientName: string;
|
|
12
12
|
baseRedirectUrl: string;
|
|
13
|
-
private
|
|
14
|
-
private
|
|
15
|
-
private
|
|
13
|
+
private _authUrl_;
|
|
14
|
+
private _serverId_;
|
|
15
|
+
private _clientId_;
|
|
16
16
|
constructor(storage: DurableObjectStorage, clientName: string, baseRedirectUrl: string);
|
|
17
17
|
get clientMetadata(): OAuthClientMetadata;
|
|
18
18
|
get redirectUrl(): string;
|
|
@@ -1,106 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var DurableObjectOAuthClientProvider = class {
|
|
5
|
-
constructor(storage, clientName, baseRedirectUrl) {
|
|
6
|
-
this.storage = storage;
|
|
7
|
-
this.clientName = clientName;
|
|
8
|
-
this.baseRedirectUrl = baseRedirectUrl;
|
|
9
|
-
}
|
|
10
|
-
get clientMetadata() {
|
|
11
|
-
return {
|
|
12
|
-
redirect_uris: [this.redirectUrl],
|
|
13
|
-
token_endpoint_auth_method: "none",
|
|
14
|
-
grant_types: ["authorization_code", "refresh_token"],
|
|
15
|
-
response_types: ["code"],
|
|
16
|
-
client_name: this.clientName,
|
|
17
|
-
client_uri: "example.com"
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
get redirectUrl() {
|
|
21
|
-
return `${this.baseRedirectUrl}/${this.serverId}`;
|
|
22
|
-
}
|
|
23
|
-
get clientId() {
|
|
24
|
-
if (!this.clientId_) {
|
|
25
|
-
throw new Error("Trying to access clientId before it was set");
|
|
26
|
-
}
|
|
27
|
-
return this.clientId_;
|
|
28
|
-
}
|
|
29
|
-
set clientId(clientId_) {
|
|
30
|
-
this.clientId_ = clientId_;
|
|
31
|
-
}
|
|
32
|
-
get serverId() {
|
|
33
|
-
if (!this.serverId_) {
|
|
34
|
-
throw new Error("Trying to access serverId before it was set");
|
|
35
|
-
}
|
|
36
|
-
return this.serverId_;
|
|
37
|
-
}
|
|
38
|
-
set serverId(serverId_) {
|
|
39
|
-
this.serverId_ = serverId_;
|
|
40
|
-
}
|
|
41
|
-
keyPrefix(clientId) {
|
|
42
|
-
return `/${this.clientName}/${this.serverId}/${clientId}`;
|
|
43
|
-
}
|
|
44
|
-
clientInfoKey(clientId) {
|
|
45
|
-
return `${this.keyPrefix(clientId)}/client_info/`;
|
|
46
|
-
}
|
|
47
|
-
async clientInformation() {
|
|
48
|
-
if (!this.clientId_) {
|
|
49
|
-
return void 0;
|
|
50
|
-
}
|
|
51
|
-
return await this.storage.get(
|
|
52
|
-
this.clientInfoKey(this.clientId)
|
|
53
|
-
) ?? void 0;
|
|
54
|
-
}
|
|
55
|
-
async saveClientInformation(clientInformation) {
|
|
56
|
-
await this.storage.put(
|
|
57
|
-
this.clientInfoKey(clientInformation.client_id),
|
|
58
|
-
clientInformation
|
|
59
|
-
);
|
|
60
|
-
this.clientId = clientInformation.client_id;
|
|
61
|
-
}
|
|
62
|
-
tokenKey(clientId) {
|
|
63
|
-
return `${this.keyPrefix(clientId)}/token`;
|
|
64
|
-
}
|
|
65
|
-
async tokens() {
|
|
66
|
-
if (!this.clientId_) {
|
|
67
|
-
return void 0;
|
|
68
|
-
}
|
|
69
|
-
return await this.storage.get(this.tokenKey(this.clientId)) ?? void 0;
|
|
70
|
-
}
|
|
71
|
-
async saveTokens(tokens) {
|
|
72
|
-
await this.storage.put(this.tokenKey(this.clientId), tokens);
|
|
73
|
-
}
|
|
74
|
-
get authUrl() {
|
|
75
|
-
return this.authUrl_;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Because this operates on the server side (but we need browser auth), we send this url back to the user
|
|
79
|
-
* and require user interact to initiate the redirect flow
|
|
80
|
-
*/
|
|
81
|
-
async redirectToAuthorization(authUrl) {
|
|
82
|
-
const client_id = authUrl.searchParams.get("client_id");
|
|
83
|
-
if (client_id) {
|
|
84
|
-
authUrl.searchParams.append("state", client_id);
|
|
85
|
-
}
|
|
86
|
-
this.authUrl_ = authUrl.toString();
|
|
87
|
-
}
|
|
88
|
-
codeVerifierKey(clientId) {
|
|
89
|
-
return `${this.keyPrefix(clientId)}/code_verifier`;
|
|
90
|
-
}
|
|
91
|
-
async saveCodeVerifier(verifier) {
|
|
92
|
-
await this.storage.put(this.codeVerifierKey(this.clientId), verifier);
|
|
93
|
-
}
|
|
94
|
-
async codeVerifier() {
|
|
95
|
-
const codeVerifier = await this.storage.get(
|
|
96
|
-
this.codeVerifierKey(this.clientId)
|
|
97
|
-
);
|
|
98
|
-
if (!codeVerifier) {
|
|
99
|
-
throw new Error("No code verifier found");
|
|
100
|
-
}
|
|
101
|
-
return codeVerifier;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
DurableObjectOAuthClientProvider
|
|
3
|
+
} from "../chunk-PVQZBKN7.js";
|
|
104
4
|
export {
|
|
105
5
|
DurableObjectOAuthClientProvider
|
|
106
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,27 +1,39 @@
|
|
|
1
|
-
import { MCPClientManager } from '
|
|
1
|
+
import { M as MCPClientManager } from '../client-B9tFv5gX.js';
|
|
2
|
+
export { S as SSEEdgeClientTransport, a as StreamableHTTPEdgeClientTransport } from '../client-B9tFv5gX.js';
|
|
2
3
|
import { DurableObject } from 'cloudflare:workers';
|
|
3
|
-
import { Connection, WSMessage } from 'partyserver';
|
|
4
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
4
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
5
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
+
import { ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
export { ElicitRequest, ElicitRequestSchema, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
+
import { Connection, WSMessage } from 'partyserver';
|
|
6
9
|
import 'zod';
|
|
7
|
-
import '@modelcontextprotocol/sdk/types.js';
|
|
8
10
|
import '@modelcontextprotocol/sdk/client/index.js';
|
|
11
|
+
import '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
12
|
+
import 'ai';
|
|
9
13
|
import '@modelcontextprotocol/sdk/client/sse.js';
|
|
14
|
+
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
10
15
|
import './do-oauth-client-provider.js';
|
|
11
16
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
12
17
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
13
|
-
import '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
14
|
-
import 'ai';
|
|
15
18
|
|
|
16
19
|
interface CORSOptions {
|
|
17
20
|
origin?: string;
|
|
18
21
|
methods?: string;
|
|
19
22
|
headers?: string;
|
|
20
23
|
maxAge?: number;
|
|
24
|
+
exposeHeaders?: string;
|
|
21
25
|
}
|
|
22
26
|
type MaybePromise<T> = T | Promise<T>;
|
|
23
27
|
declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
|
|
24
|
-
|
|
28
|
+
private _status;
|
|
29
|
+
private _transport?;
|
|
30
|
+
private _transportType;
|
|
31
|
+
private _requestIdToConnectionId;
|
|
32
|
+
/**
|
|
33
|
+
* Since McpAgent's _aren't_ yet real "Agents", let's only expose a couple of the methods
|
|
34
|
+
* to the outer class: initialState/state/setState/onStateUpdate/sql
|
|
35
|
+
*/
|
|
36
|
+
private _agent;
|
|
25
37
|
get mcp(): MCPClientManager;
|
|
26
38
|
protected constructor(ctx: DurableObjectState, env: Env);
|
|
27
39
|
/**
|
|
@@ -31,6 +43,13 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
31
43
|
get state(): State;
|
|
32
44
|
sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
|
|
33
45
|
setState(state: State): void;
|
|
46
|
+
/**
|
|
47
|
+
* Elicit user input with a message and schema
|
|
48
|
+
*/
|
|
49
|
+
elicitInput(params: {
|
|
50
|
+
message: string;
|
|
51
|
+
requestedSchema: unknown;
|
|
52
|
+
}): Promise<ElicitResult>;
|
|
34
53
|
onStateUpdate(state: State | undefined, source: Connection | "server"): void;
|
|
35
54
|
onStart(): Promise<void>;
|
|
36
55
|
/**
|
|
@@ -40,30 +59,49 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
40
59
|
props: Props;
|
|
41
60
|
initRun: boolean;
|
|
42
61
|
abstract init(): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Handle errors that occur during initialization or operation.
|
|
64
|
+
* Override this method to provide custom error handling.
|
|
65
|
+
* @param error - The error that occurred
|
|
66
|
+
* @returns An error response object with status code and message
|
|
67
|
+
*/
|
|
68
|
+
onError(error: Error): {
|
|
69
|
+
status: number;
|
|
70
|
+
message: string;
|
|
71
|
+
};
|
|
43
72
|
_init(props: Props): Promise<void>;
|
|
44
73
|
setInitialized(): Promise<void>;
|
|
45
74
|
isInitialized(): Promise<boolean>;
|
|
75
|
+
updateProps(props: Props): Promise<void>;
|
|
76
|
+
private _initialize;
|
|
46
77
|
fetch(request: Request): Promise<Response>;
|
|
47
78
|
getWebSocket(): WebSocket | null;
|
|
48
79
|
getWebSocketForResponseID(id: string): WebSocket | null;
|
|
49
80
|
onMessage(connection: Connection, event: WSMessage): Promise<void>;
|
|
50
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Wait for elicitation response through storage polling
|
|
83
|
+
*/
|
|
84
|
+
private _waitForElicitationResponse;
|
|
85
|
+
/**
|
|
86
|
+
* Handle elicitation responses */
|
|
87
|
+
private _handleElicitationResponse;
|
|
88
|
+
onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
|
|
51
89
|
webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
|
|
52
90
|
webSocketError(ws: WebSocket, error: unknown): Promise<void>;
|
|
53
91
|
webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
|
|
54
|
-
static mount(path: string, { binding, corsOptions
|
|
92
|
+
static mount(path: string, { binding, corsOptions }?: {
|
|
55
93
|
binding?: string;
|
|
56
94
|
corsOptions?: CORSOptions;
|
|
57
95
|
}): {
|
|
58
96
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
59
97
|
};
|
|
60
|
-
static serveSSE(path: string, { binding, corsOptions
|
|
98
|
+
static serveSSE(path: string, { binding, corsOptions }?: {
|
|
61
99
|
binding?: string;
|
|
62
100
|
corsOptions?: CORSOptions;
|
|
63
101
|
}): {
|
|
64
102
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
65
103
|
};
|
|
66
|
-
static serve(path: string, { binding, corsOptions
|
|
104
|
+
static serve(path: string, { binding, corsOptions }?: {
|
|
67
105
|
binding?: string;
|
|
68
106
|
corsOptions?: CORSOptions;
|
|
69
107
|
}): {
|