agents 0.0.0-197e86a → 0.0.0-1a3d226
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 +255 -10
- package/dist/ai-chat-agent.d.ts +238 -31
- package/dist/ai-chat-agent.js +1118 -260
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/ai-chat-v5-migration.d.ts +155 -0
- package/dist/ai-chat-v5-migration.js +155 -0
- package/dist/ai-chat-v5-migration.js.map +1 -0
- package/dist/ai-react.d.ts +197 -86
- package/dist/ai-react.js +574 -199
- package/dist/ai-react.js.map +1 -1
- package/dist/ai-types-0OnT3FHg.d.ts +127 -0
- package/dist/ai-types-DEtF_8Km.js +28 -0
- package/dist/ai-types-DEtF_8Km.js.map +1 -0
- package/dist/ai-types.d.ts +6 -74
- package/dist/ai-types.js +3 -1
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +28 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client-BINtT7y-.d.ts +834 -0
- package/dist/client-CdM5I962.d.ts +104 -0
- package/dist/client-DjTPRM8-.js +117 -0
- package/dist/client-DjTPRM8-.js.map +1 -0
- package/dist/client-QZa2Rq0l.js +1105 -0
- package/dist/client-QZa2Rq0l.js.map +1 -0
- package/dist/client.d.ts +10 -92
- package/dist/client.js +3 -11
- package/dist/codemode/ai.d.ts +27 -0
- package/dist/codemode/ai.js +151 -0
- package/dist/codemode/ai.js.map +1 -0
- package/dist/context-BkKbAa1R.js +8 -0
- package/dist/context-BkKbAa1R.js.map +1 -0
- package/dist/context-DcbQ8o7k.d.ts +24 -0
- package/dist/context.d.ts +6 -0
- package/dist/context.js +3 -0
- package/dist/do-oauth-client-provider--To1Tsjj.d.ts +70 -0
- package/dist/do-oauth-client-provider-B1fVIshX.js +155 -0
- package/dist/do-oauth-client-provider-B1fVIshX.js.map +1 -0
- package/dist/{index-BCJclX6q.d.ts → index-CfZ2mfMI.d.ts} +131 -170
- package/dist/index-DLuxm_9W.d.ts +58 -0
- package/dist/index.d.ts +66 -40
- package/dist/index.js +7 -28
- package/dist/mcp/client.d.ts +2 -11
- package/dist/mcp/client.js +4 -9
- package/dist/mcp/do-oauth-client-provider.d.ts +2 -41
- package/dist/mcp/do-oauth-client-provider.js +3 -7
- package/dist/mcp/index.d.ts +197 -109
- package/dist/mcp/index.js +1429 -942
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/x402.d.ts +34 -0
- package/dist/mcp/x402.js +198 -0
- package/dist/mcp/x402.js.map +1 -0
- package/dist/mcp-CPSfGUgd.d.ts +61 -0
- package/dist/observability/index.d.ts +2 -14
- package/dist/observability/index.js +7 -10
- package/dist/react.d.ts +48 -35
- package/dist/react.js +183 -110
- package/dist/react.js.map +1 -1
- package/dist/schedule.d.ts +61 -38
- package/dist/schedule.js +46 -21
- package/dist/schedule.js.map +1 -1
- package/dist/serializable-Crsj26mx.d.ts +39 -0
- package/dist/serializable.d.ts +7 -32
- package/dist/serializable.js +1 -1
- package/dist/src-BZDh910Z.js +1181 -0
- package/dist/src-BZDh910Z.js.map +1 -0
- package/package.json +93 -29
- package/dist/ai-types.js.map +0 -1
- package/dist/chunk-HY7ZLHJB.js +0 -598
- package/dist/chunk-HY7ZLHJB.js.map +0 -1
- package/dist/chunk-JXN5WZFQ.js +0 -1287
- package/dist/chunk-JXN5WZFQ.js.map +0 -1
- package/dist/chunk-KUH345EY.js +0 -116
- package/dist/chunk-KUH345EY.js.map +0 -1
- package/dist/chunk-PVQZBKN7.js +0 -106
- package/dist/chunk-PVQZBKN7.js.map +0 -1
- package/dist/client-DgyzBU_8.d.ts +0 -4601
- package/dist/client.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mcp/client.js.map +0 -1
- package/dist/mcp/do-oauth-client-provider.js.map +0 -1
- package/dist/observability/index.js.map +0 -1
- package/dist/serializable.js.map +0 -1
- package/src/index.ts +0 -1917
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { nanoid } from "nanoid";
|
|
2
|
+
|
|
3
|
+
//#region src/mcp/do-oauth-client-provider.ts
|
|
4
|
+
const STATE_EXPIRATION_MS = 600 * 1e3;
|
|
5
|
+
var DurableObjectOAuthClientProvider = class {
|
|
6
|
+
constructor(storage, clientName, baseRedirectUrl) {
|
|
7
|
+
this.storage = storage;
|
|
8
|
+
this.clientName = clientName;
|
|
9
|
+
this.baseRedirectUrl = baseRedirectUrl;
|
|
10
|
+
if (!storage) throw new Error("DurableObjectOAuthClientProvider requires a valid DurableObjectStorage instance");
|
|
11
|
+
}
|
|
12
|
+
get clientMetadata() {
|
|
13
|
+
return {
|
|
14
|
+
client_name: this.clientName,
|
|
15
|
+
client_uri: this.clientUri,
|
|
16
|
+
grant_types: ["authorization_code", "refresh_token"],
|
|
17
|
+
redirect_uris: [this.redirectUrl],
|
|
18
|
+
response_types: ["code"],
|
|
19
|
+
token_endpoint_auth_method: "none"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
get clientUri() {
|
|
23
|
+
return new URL(this.redirectUrl).origin;
|
|
24
|
+
}
|
|
25
|
+
get redirectUrl() {
|
|
26
|
+
return this.baseRedirectUrl;
|
|
27
|
+
}
|
|
28
|
+
get clientId() {
|
|
29
|
+
if (!this._clientId_) throw new Error("Trying to access clientId before it was set");
|
|
30
|
+
return this._clientId_;
|
|
31
|
+
}
|
|
32
|
+
set clientId(clientId_) {
|
|
33
|
+
this._clientId_ = clientId_;
|
|
34
|
+
}
|
|
35
|
+
get serverId() {
|
|
36
|
+
if (!this._serverId_) throw new Error("Trying to access serverId before it was set");
|
|
37
|
+
return this._serverId_;
|
|
38
|
+
}
|
|
39
|
+
set serverId(serverId_) {
|
|
40
|
+
this._serverId_ = serverId_;
|
|
41
|
+
}
|
|
42
|
+
keyPrefix(clientId) {
|
|
43
|
+
return `/${this.clientName}/${this.serverId}/${clientId}`;
|
|
44
|
+
}
|
|
45
|
+
clientInfoKey(clientId) {
|
|
46
|
+
return `${this.keyPrefix(clientId)}/client_info/`;
|
|
47
|
+
}
|
|
48
|
+
async clientInformation() {
|
|
49
|
+
if (!this._clientId_) return;
|
|
50
|
+
return await this.storage.get(this.clientInfoKey(this.clientId)) ?? void 0;
|
|
51
|
+
}
|
|
52
|
+
async saveClientInformation(clientInformation) {
|
|
53
|
+
await this.storage.put(this.clientInfoKey(clientInformation.client_id), clientInformation);
|
|
54
|
+
this.clientId = clientInformation.client_id;
|
|
55
|
+
}
|
|
56
|
+
tokenKey(clientId) {
|
|
57
|
+
return `${this.keyPrefix(clientId)}/token`;
|
|
58
|
+
}
|
|
59
|
+
async tokens() {
|
|
60
|
+
if (!this._clientId_) return;
|
|
61
|
+
return await this.storage.get(this.tokenKey(this.clientId)) ?? void 0;
|
|
62
|
+
}
|
|
63
|
+
async saveTokens(tokens) {
|
|
64
|
+
await this.storage.put(this.tokenKey(this.clientId), tokens);
|
|
65
|
+
}
|
|
66
|
+
get authUrl() {
|
|
67
|
+
return this._authUrl_;
|
|
68
|
+
}
|
|
69
|
+
stateKey(nonce) {
|
|
70
|
+
return `/${this.clientName}/${this.serverId}/state/${nonce}`;
|
|
71
|
+
}
|
|
72
|
+
async state() {
|
|
73
|
+
const nonce = nanoid();
|
|
74
|
+
const state = `${nonce}.${this.serverId}`;
|
|
75
|
+
const storedState = {
|
|
76
|
+
nonce,
|
|
77
|
+
serverId: this.serverId,
|
|
78
|
+
createdAt: Date.now()
|
|
79
|
+
};
|
|
80
|
+
await this.storage.put(this.stateKey(nonce), storedState);
|
|
81
|
+
return state;
|
|
82
|
+
}
|
|
83
|
+
async checkState(state) {
|
|
84
|
+
const parts = state.split(".");
|
|
85
|
+
if (parts.length !== 2) return {
|
|
86
|
+
valid: false,
|
|
87
|
+
error: "Invalid state format"
|
|
88
|
+
};
|
|
89
|
+
const [nonce, serverId] = parts;
|
|
90
|
+
const key = this.stateKey(nonce);
|
|
91
|
+
const storedState = await this.storage.get(key);
|
|
92
|
+
if (!storedState) return {
|
|
93
|
+
valid: false,
|
|
94
|
+
error: "State not found or already used"
|
|
95
|
+
};
|
|
96
|
+
if (storedState.serverId !== serverId) {
|
|
97
|
+
await this.storage.delete(key);
|
|
98
|
+
return {
|
|
99
|
+
valid: false,
|
|
100
|
+
error: "State serverId mismatch"
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (Date.now() - storedState.createdAt > STATE_EXPIRATION_MS) {
|
|
104
|
+
await this.storage.delete(key);
|
|
105
|
+
return {
|
|
106
|
+
valid: false,
|
|
107
|
+
error: "State expired"
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
valid: true,
|
|
112
|
+
serverId
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
async consumeState(state) {
|
|
116
|
+
const parts = state.split(".");
|
|
117
|
+
if (parts.length !== 2) {
|
|
118
|
+
console.warn(`[OAuth] consumeState called with invalid state format: ${state.substring(0, 20)}...`);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const [nonce] = parts;
|
|
122
|
+
await this.storage.delete(this.stateKey(nonce));
|
|
123
|
+
}
|
|
124
|
+
async redirectToAuthorization(authUrl) {
|
|
125
|
+
this._authUrl_ = authUrl.toString();
|
|
126
|
+
}
|
|
127
|
+
async invalidateCredentials(scope) {
|
|
128
|
+
if (!this._clientId_) return;
|
|
129
|
+
const deleteKeys = [];
|
|
130
|
+
if (scope === "all" || scope === "client") deleteKeys.push(this.clientInfoKey(this.clientId));
|
|
131
|
+
if (scope === "all" || scope === "tokens") deleteKeys.push(this.tokenKey(this.clientId));
|
|
132
|
+
if (scope === "all" || scope === "verifier") deleteKeys.push(this.codeVerifierKey(this.clientId));
|
|
133
|
+
if (deleteKeys.length > 0) await this.storage.delete(deleteKeys);
|
|
134
|
+
}
|
|
135
|
+
codeVerifierKey(clientId) {
|
|
136
|
+
return `${this.keyPrefix(clientId)}/code_verifier`;
|
|
137
|
+
}
|
|
138
|
+
async saveCodeVerifier(verifier) {
|
|
139
|
+
const key = this.codeVerifierKey(this.clientId);
|
|
140
|
+
if (await this.storage.get(key)) return;
|
|
141
|
+
await this.storage.put(key, verifier);
|
|
142
|
+
}
|
|
143
|
+
async codeVerifier() {
|
|
144
|
+
const codeVerifier = await this.storage.get(this.codeVerifierKey(this.clientId));
|
|
145
|
+
if (!codeVerifier) throw new Error("No code verifier found");
|
|
146
|
+
return codeVerifier;
|
|
147
|
+
}
|
|
148
|
+
async deleteCodeVerifier() {
|
|
149
|
+
await this.storage.delete(this.codeVerifierKey(this.clientId));
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
//#endregion
|
|
154
|
+
export { DurableObjectOAuthClientProvider as t };
|
|
155
|
+
//# sourceMappingURL=do-oauth-client-provider-B1fVIshX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"do-oauth-client-provider-B1fVIshX.js","names":["storage: DurableObjectStorage","clientName: string","baseRedirectUrl: string","storedState: StoredState","deleteKeys: string[]"],"sources":["../src/mcp/do-oauth-client-provider.ts"],"sourcesContent":["import type { OAuthClientProvider } from \"@modelcontextprotocol/sdk/client/auth.js\";\nimport type {\n OAuthClientInformation,\n OAuthClientInformationFull,\n OAuthClientMetadata,\n OAuthTokens\n} from \"@modelcontextprotocol/sdk/shared/auth.js\";\nimport { nanoid } from \"nanoid\";\n\nconst STATE_EXPIRATION_MS = 10 * 60 * 1000; // 10 minutes\n\ninterface StoredState {\n nonce: string;\n serverId: string;\n createdAt: number;\n}\n\n// A slight extension to the standard OAuthClientProvider interface because `redirectToAuthorization` doesn't give us the interface we need\n// This allows us to track authentication for a specific server and associated dynamic client registration\nexport interface AgentsOAuthProvider extends OAuthClientProvider {\n authUrl: string | undefined;\n clientId: string | undefined;\n serverId: string | undefined;\n checkState(\n state: string\n ): Promise<{ valid: boolean; serverId?: string; error?: string }>;\n consumeState(state: string): Promise<void>;\n deleteCodeVerifier(): Promise<void>;\n}\n\nexport class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {\n private _authUrl_: string | undefined;\n private _serverId_: string | undefined;\n private _clientId_: string | undefined;\n\n constructor(\n public storage: DurableObjectStorage,\n public clientName: string,\n public baseRedirectUrl: string\n ) {\n if (!storage) {\n throw new Error(\n \"DurableObjectOAuthClientProvider requires a valid DurableObjectStorage instance\"\n );\n }\n }\n\n get clientMetadata(): OAuthClientMetadata {\n return {\n client_name: this.clientName,\n client_uri: this.clientUri,\n grant_types: [\"authorization_code\", \"refresh_token\"],\n redirect_uris: [this.redirectUrl],\n response_types: [\"code\"],\n token_endpoint_auth_method: \"none\"\n };\n }\n\n get clientUri() {\n return new URL(this.redirectUrl).origin;\n }\n\n get redirectUrl() {\n return this.baseRedirectUrl;\n }\n\n get clientId() {\n if (!this._clientId_) {\n throw new Error(\"Trying to access clientId before it was set\");\n }\n return this._clientId_;\n }\n\n set clientId(clientId_: string) {\n this._clientId_ = clientId_;\n }\n\n get serverId() {\n if (!this._serverId_) {\n throw new Error(\"Trying to access serverId before it was set\");\n }\n return this._serverId_;\n }\n\n set serverId(serverId_: string) {\n this._serverId_ = serverId_;\n }\n\n keyPrefix(clientId: string) {\n return `/${this.clientName}/${this.serverId}/${clientId}`;\n }\n\n clientInfoKey(clientId: string) {\n return `${this.keyPrefix(clientId)}/client_info/`;\n }\n\n async clientInformation(): Promise<OAuthClientInformation | undefined> {\n if (!this._clientId_) {\n return undefined;\n }\n return (\n (await this.storage.get<OAuthClientInformation>(\n this.clientInfoKey(this.clientId)\n )) ?? undefined\n );\n }\n\n async saveClientInformation(\n clientInformation: OAuthClientInformationFull\n ): Promise<void> {\n await this.storage.put(\n this.clientInfoKey(clientInformation.client_id),\n clientInformation\n );\n this.clientId = clientInformation.client_id;\n }\n\n tokenKey(clientId: string) {\n return `${this.keyPrefix(clientId)}/token`;\n }\n\n async tokens(): Promise<OAuthTokens | undefined> {\n if (!this._clientId_) {\n return undefined;\n }\n return (\n (await this.storage.get<OAuthTokens>(this.tokenKey(this.clientId))) ??\n undefined\n );\n }\n\n async saveTokens(tokens: OAuthTokens): Promise<void> {\n await this.storage.put(this.tokenKey(this.clientId), tokens);\n }\n\n get authUrl() {\n return this._authUrl_;\n }\n\n stateKey(nonce: string) {\n return `/${this.clientName}/${this.serverId}/state/${nonce}`;\n }\n\n async state(): Promise<string> {\n const nonce = nanoid();\n const state = `${nonce}.${this.serverId}`;\n const storedState: StoredState = {\n nonce,\n serverId: this.serverId,\n createdAt: Date.now()\n };\n await this.storage.put(this.stateKey(nonce), storedState);\n return state;\n }\n\n async checkState(\n state: string\n ): Promise<{ valid: boolean; serverId?: string; error?: string }> {\n const parts = state.split(\".\");\n if (parts.length !== 2) {\n return { valid: false, error: \"Invalid state format\" };\n }\n\n const [nonce, serverId] = parts;\n const key = this.stateKey(nonce);\n const storedState = await this.storage.get<StoredState>(key);\n\n if (!storedState) {\n return { valid: false, error: \"State not found or already used\" };\n }\n\n if (storedState.serverId !== serverId) {\n await this.storage.delete(key);\n return { valid: false, error: \"State serverId mismatch\" };\n }\n\n const age = Date.now() - storedState.createdAt;\n if (age > STATE_EXPIRATION_MS) {\n await this.storage.delete(key);\n return { valid: false, error: \"State expired\" };\n }\n\n return { valid: true, serverId };\n }\n\n async consumeState(state: string): Promise<void> {\n const parts = state.split(\".\");\n if (parts.length !== 2) {\n // This should never happen since checkState validates format first.\n // Log for debugging but don't throw - state consumption is best-effort.\n console.warn(\n `[OAuth] consumeState called with invalid state format: ${state.substring(0, 20)}...`\n );\n return;\n }\n const [nonce] = parts;\n await this.storage.delete(this.stateKey(nonce));\n }\n\n async redirectToAuthorization(authUrl: URL): Promise<void> {\n this._authUrl_ = authUrl.toString();\n }\n\n async invalidateCredentials(\n scope: \"all\" | \"client\" | \"tokens\" | \"verifier\"\n ): Promise<void> {\n if (!this._clientId_) return;\n\n const deleteKeys: string[] = [];\n\n if (scope === \"all\" || scope === \"client\") {\n deleteKeys.push(this.clientInfoKey(this.clientId));\n }\n if (scope === \"all\" || scope === \"tokens\") {\n deleteKeys.push(this.tokenKey(this.clientId));\n }\n if (scope === \"all\" || scope === \"verifier\") {\n deleteKeys.push(this.codeVerifierKey(this.clientId));\n }\n\n if (deleteKeys.length > 0) {\n await this.storage.delete(deleteKeys);\n }\n }\n\n codeVerifierKey(clientId: string) {\n return `${this.keyPrefix(clientId)}/code_verifier`;\n }\n\n async saveCodeVerifier(verifier: string): Promise<void> {\n const key = this.codeVerifierKey(this.clientId);\n\n // Don't overwrite existing verifier to preserve first PKCE verifier\n const existing = await this.storage.get<string>(key);\n if (existing) {\n return;\n }\n\n await this.storage.put(key, verifier);\n }\n\n async codeVerifier(): Promise<string> {\n const codeVerifier = await this.storage.get<string>(\n this.codeVerifierKey(this.clientId)\n );\n if (!codeVerifier) {\n throw new Error(\"No code verifier found\");\n }\n return codeVerifier;\n }\n\n async deleteCodeVerifier(): Promise<void> {\n await this.storage.delete(this.codeVerifierKey(this.clientId));\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,88 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as AgentEmail } from "./context-DcbQ8o7k.js";
|
|
2
|
+
import {
|
|
3
|
+
h as TransportType,
|
|
4
|
+
t as MCPClientManager,
|
|
5
|
+
u as MCPConnectionState
|
|
6
|
+
} from "./client-BINtT7y-.js";
|
|
7
|
+
import { t as Observability } from "./index-DLuxm_9W.js";
|
|
8
|
+
import { n as MessageType } from "./ai-types-0OnT3FHg.js";
|
|
9
|
+
import {
|
|
10
|
+
Connection,
|
|
11
|
+
Connection as Connection$1,
|
|
12
|
+
ConnectionContext,
|
|
13
|
+
PartyServerOptions,
|
|
14
|
+
Server,
|
|
15
|
+
WSMessage
|
|
16
|
+
} from "partyserver";
|
|
2
17
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
3
18
|
import {
|
|
4
|
-
ServerCapabilities,
|
|
5
|
-
Tool,
|
|
6
19
|
Prompt,
|
|
7
|
-
Resource
|
|
20
|
+
Resource,
|
|
21
|
+
ServerCapabilities,
|
|
22
|
+
Tool
|
|
8
23
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
9
|
-
import { Server, Connection, PartyServerOptions } from "partyserver";
|
|
10
|
-
import { M as MCPClientManager } from "./client-DgyzBU_8.js";
|
|
11
|
-
import { Message } from "ai";
|
|
12
24
|
|
|
13
|
-
|
|
14
|
-
T extends string,
|
|
15
|
-
Payload extends Record<string, unknown> = {}
|
|
16
|
-
> = {
|
|
17
|
-
type: T;
|
|
18
|
-
/**
|
|
19
|
-
* The unique identifier for the event
|
|
20
|
-
*/
|
|
21
|
-
id: string;
|
|
22
|
-
/**
|
|
23
|
-
* The message to display in the logs for this event, should the implementation choose to display
|
|
24
|
-
* a human-readable message.
|
|
25
|
-
*/
|
|
26
|
-
displayMessage: string;
|
|
27
|
-
/**
|
|
28
|
-
* The payload of the event
|
|
29
|
-
*/
|
|
30
|
-
payload: Payload;
|
|
31
|
-
/**
|
|
32
|
-
* The timestamp of the event in milliseconds since epoch
|
|
33
|
-
*/
|
|
34
|
-
timestamp: number;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* The type of events that can be emitted by an Agent
|
|
38
|
-
*/
|
|
39
|
-
type ObservabilityEvent =
|
|
40
|
-
| BaseEvent<
|
|
41
|
-
"state:update",
|
|
42
|
-
{
|
|
43
|
-
state: unknown;
|
|
44
|
-
previousState: unknown;
|
|
45
|
-
}
|
|
46
|
-
>
|
|
47
|
-
| BaseEvent<
|
|
48
|
-
"rpc",
|
|
49
|
-
{
|
|
50
|
-
method: string;
|
|
51
|
-
args: unknown[];
|
|
52
|
-
streaming?: boolean;
|
|
53
|
-
success: boolean;
|
|
54
|
-
}
|
|
55
|
-
>
|
|
56
|
-
| BaseEvent<
|
|
57
|
-
"message:request" | "message:response",
|
|
58
|
-
{
|
|
59
|
-
message: Message[];
|
|
60
|
-
}
|
|
61
|
-
>
|
|
62
|
-
| BaseEvent<"message:clear">
|
|
63
|
-
| BaseEvent<
|
|
64
|
-
"schedule:create" | "schedule:execute" | "schedule:cancel",
|
|
65
|
-
Schedule<unknown>
|
|
66
|
-
>
|
|
67
|
-
| BaseEvent<"destroy">
|
|
68
|
-
| BaseEvent<
|
|
69
|
-
"connect",
|
|
70
|
-
{
|
|
71
|
-
connectionId: string;
|
|
72
|
-
}
|
|
73
|
-
>;
|
|
74
|
-
interface Observability {
|
|
75
|
-
/**
|
|
76
|
-
* Emit an event for the Agent's observability implementation to handle.
|
|
77
|
-
* @param event - The event to emit
|
|
78
|
-
* @param ctx - The execution context of the invocation
|
|
79
|
-
*/
|
|
80
|
-
emit(event: ObservabilityEvent, ctx: DurableObjectState): void;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* A generic observability implementation that logs events to the console.
|
|
84
|
-
*/
|
|
85
|
-
declare const genericObservability: Observability;
|
|
25
|
+
//#region src/index.d.ts
|
|
86
26
|
|
|
87
27
|
/**
|
|
88
28
|
* RPC request message from client
|
|
@@ -97,14 +37,14 @@ type RPCRequest = {
|
|
|
97
37
|
* State update message from client
|
|
98
38
|
*/
|
|
99
39
|
type StateUpdateMessage = {
|
|
100
|
-
type:
|
|
40
|
+
type: MessageType.CF_AGENT_STATE;
|
|
101
41
|
state: unknown;
|
|
102
42
|
};
|
|
103
43
|
/**
|
|
104
44
|
* RPC response message to client
|
|
105
45
|
*/
|
|
106
46
|
type RPCResponse = {
|
|
107
|
-
type:
|
|
47
|
+
type: MessageType.RPC;
|
|
108
48
|
id: string;
|
|
109
49
|
} & (
|
|
110
50
|
| {
|
|
@@ -135,16 +75,22 @@ type CallableMetadata = {
|
|
|
135
75
|
* Decorator that marks a method as callable by clients
|
|
136
76
|
* @param metadata Optional metadata about the callable method
|
|
137
77
|
*/
|
|
138
|
-
declare function
|
|
78
|
+
declare function callable(
|
|
139
79
|
metadata?: CallableMetadata
|
|
140
80
|
): <This, Args extends unknown[], Return>(
|
|
141
81
|
target: (this: This, ...args: Args) => Return,
|
|
142
82
|
context: ClassMethodDecoratorContext
|
|
143
83
|
) => (this: This, ...args: Args) => Return;
|
|
84
|
+
/**
|
|
85
|
+
* Decorator that marks a method as callable by clients
|
|
86
|
+
* @deprecated this has been renamed to callable, and unstable_callable will be removed in the next major version
|
|
87
|
+
* @param metadata Optional metadata about the callable method
|
|
88
|
+
*/
|
|
89
|
+
declare const unstable_callable: (metadata?: CallableMetadata) => void;
|
|
144
90
|
type QueueItem<T = string> = {
|
|
145
91
|
id: string;
|
|
146
92
|
payload: T;
|
|
147
|
-
callback: keyof Agent<
|
|
93
|
+
callback: keyof Agent<Cloudflare.Env>;
|
|
148
94
|
created_at: number;
|
|
149
95
|
};
|
|
150
96
|
/**
|
|
@@ -186,27 +132,33 @@ type Schedule<T = string> = {
|
|
|
186
132
|
* MCP Server state update message from server -> Client
|
|
187
133
|
*/
|
|
188
134
|
type MCPServerMessage = {
|
|
189
|
-
type:
|
|
135
|
+
type: MessageType.CF_AGENT_MCP_SERVERS;
|
|
190
136
|
mcp: MCPServersState;
|
|
191
137
|
};
|
|
192
138
|
type MCPServersState = {
|
|
193
139
|
servers: {
|
|
194
140
|
[id: string]: MCPServer;
|
|
195
141
|
};
|
|
196
|
-
tools: Tool
|
|
197
|
-
|
|
198
|
-
|
|
142
|
+
tools: (Tool & {
|
|
143
|
+
serverId: string;
|
|
144
|
+
})[];
|
|
145
|
+
prompts: (Prompt & {
|
|
146
|
+
serverId: string;
|
|
147
|
+
})[];
|
|
148
|
+
resources: (Resource & {
|
|
149
|
+
serverId: string;
|
|
150
|
+
})[];
|
|
199
151
|
};
|
|
200
152
|
type MCPServer = {
|
|
201
153
|
name: string;
|
|
202
154
|
server_url: string;
|
|
203
155
|
auth_url: string | null;
|
|
204
|
-
state:
|
|
156
|
+
state: MCPConnectionState;
|
|
205
157
|
instructions: string | null;
|
|
206
158
|
capabilities: ServerCapabilities | null;
|
|
207
159
|
};
|
|
208
160
|
declare function getCurrentAgent<
|
|
209
|
-
T extends Agent<
|
|
161
|
+
T extends Agent<Cloudflare.Env> = Agent<Cloudflare.Env>
|
|
210
162
|
>(): {
|
|
211
163
|
agent: T | undefined;
|
|
212
164
|
connection: Connection | undefined;
|
|
@@ -218,10 +170,16 @@ declare function getCurrentAgent<
|
|
|
218
170
|
* @template Env Environment type containing bindings
|
|
219
171
|
* @template State State type to store within the Agent
|
|
220
172
|
*/
|
|
221
|
-
declare class Agent<
|
|
173
|
+
declare class Agent<
|
|
174
|
+
Env extends Cloudflare.Env = Cloudflare.Env,
|
|
175
|
+
State = unknown,
|
|
176
|
+
Props extends Record<string, unknown> = Record<string, unknown>
|
|
177
|
+
> extends Server<Env, Props> {
|
|
222
178
|
private _state;
|
|
179
|
+
private _disposables;
|
|
180
|
+
private _destroyed;
|
|
223
181
|
private _ParentClass;
|
|
224
|
-
mcp: MCPClientManager;
|
|
182
|
+
readonly mcp: MCPClientManager;
|
|
225
183
|
/**
|
|
226
184
|
* Initial state for the Agent
|
|
227
185
|
* Override to provide default state values
|
|
@@ -373,7 +331,7 @@ declare class Agent<Env = typeof env, State = unknown> extends Server<Env> {
|
|
|
373
331
|
/**
|
|
374
332
|
* Cancel a scheduled task
|
|
375
333
|
* @param id ID of the task to cancel
|
|
376
|
-
* @returns true if the task was cancelled, false
|
|
334
|
+
* @returns true if the task was cancelled, false if the task was not found
|
|
377
335
|
*/
|
|
378
336
|
cancelSchedule(id: string): Promise<boolean>;
|
|
379
337
|
private _scheduleNextAlarm;
|
|
@@ -398,61 +356,68 @@ declare class Agent<Env = typeof env, State = unknown> extends Server<Env> {
|
|
|
398
356
|
/**
|
|
399
357
|
* Connect to a new MCP Server
|
|
400
358
|
*
|
|
359
|
+
* @param serverName Name of the MCP server
|
|
401
360
|
* @param url MCP Server SSE URL
|
|
402
|
-
* @param callbackHost Base host for the agent, used for the redirect URI.
|
|
361
|
+
* @param callbackHost Base host for the agent, used for the redirect URI. If not provided, will be derived from the current request.
|
|
403
362
|
* @param agentsPrefix agents routing prefix if not using `agents`
|
|
404
|
-
* @param options MCP client and transport
|
|
405
|
-
* @returns authUrl
|
|
363
|
+
* @param options MCP client and transport options
|
|
364
|
+
* @returns Server id and state - either "authenticating" with authUrl, or "ready"
|
|
365
|
+
* @throws If connection or discovery fails
|
|
406
366
|
*/
|
|
407
367
|
addMcpServer(
|
|
408
368
|
serverName: string,
|
|
409
369
|
url: string,
|
|
410
|
-
callbackHost
|
|
370
|
+
callbackHost?: string,
|
|
411
371
|
agentsPrefix?: string,
|
|
412
372
|
options?: {
|
|
413
373
|
client?: ConstructorParameters<typeof Client>[1];
|
|
414
|
-
transport?: {
|
|
415
|
-
headers: HeadersInit;
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
): Promise<{
|
|
419
|
-
id: string;
|
|
420
|
-
authUrl: string | undefined;
|
|
421
|
-
}>;
|
|
422
|
-
_connectToMcpServerInternal(
|
|
423
|
-
_serverName: string,
|
|
424
|
-
url: string,
|
|
425
|
-
callbackUrl: string,
|
|
426
|
-
options?: {
|
|
427
|
-
client?: ConstructorParameters<typeof Client>[1];
|
|
428
|
-
/**
|
|
429
|
-
* We don't expose the normal set of transport options because:
|
|
430
|
-
* 1) we can't serialize things like the auth provider or a fetch function into the DB for reconnection purposes
|
|
431
|
-
* 2) We probably want these options to be agnostic to the transport type (SSE vs Streamable)
|
|
432
|
-
*
|
|
433
|
-
* This has the limitation that you can't override fetch, but I think headers should handle nearly all cases needed (i.e. non-standard bearer auth).
|
|
434
|
-
*/
|
|
435
374
|
transport?: {
|
|
436
375
|
headers?: HeadersInit;
|
|
376
|
+
type?: TransportType;
|
|
437
377
|
};
|
|
438
|
-
},
|
|
439
|
-
reconnect?: {
|
|
440
|
-
id: string;
|
|
441
|
-
oauthClientId?: string;
|
|
442
378
|
}
|
|
443
|
-
): Promise<
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
379
|
+
): Promise<
|
|
380
|
+
| {
|
|
381
|
+
id: string;
|
|
382
|
+
state: typeof MCPConnectionState.AUTHENTICATING;
|
|
383
|
+
authUrl: string;
|
|
384
|
+
}
|
|
385
|
+
| {
|
|
386
|
+
id: string;
|
|
387
|
+
state: typeof MCPConnectionState.READY;
|
|
388
|
+
authUrl?: undefined;
|
|
389
|
+
}
|
|
390
|
+
>;
|
|
448
391
|
removeMcpServer(id: string): Promise<void>;
|
|
449
392
|
getMcpServers(): MCPServersState;
|
|
393
|
+
private broadcastMcpServers;
|
|
394
|
+
/**
|
|
395
|
+
* Handle MCP OAuth callback request if it's an OAuth callback.
|
|
396
|
+
*
|
|
397
|
+
* This method encapsulates the entire OAuth callback flow:
|
|
398
|
+
* 1. Checks if the request is an MCP OAuth callback
|
|
399
|
+
* 2. Processes the OAuth code exchange
|
|
400
|
+
* 3. Establishes the connection if successful
|
|
401
|
+
* 4. Broadcasts MCP server state updates
|
|
402
|
+
* 5. Returns the appropriate HTTP response
|
|
403
|
+
*
|
|
404
|
+
* @param request The incoming HTTP request
|
|
405
|
+
* @returns Response if this was an OAuth callback, null otherwise
|
|
406
|
+
*/
|
|
407
|
+
private handleMcpOAuthCallback;
|
|
408
|
+
/**
|
|
409
|
+
* Handle OAuth callback response using MCPClientManager configuration
|
|
410
|
+
* @param result OAuth callback result
|
|
411
|
+
* @param request The original request (needed for base URL)
|
|
412
|
+
* @returns Response for the OAuth callback
|
|
413
|
+
*/
|
|
414
|
+
private handleOAuthCallbackResponse;
|
|
450
415
|
}
|
|
451
416
|
/**
|
|
452
417
|
* Namespace for creating Agent instances
|
|
453
418
|
* @template Agentic Type of the Agent class
|
|
454
419
|
*/
|
|
455
|
-
type AgentNamespace<Agentic extends Agent<
|
|
420
|
+
type AgentNamespace<Agentic extends Agent<Cloudflare.Env>> =
|
|
456
421
|
DurableObjectNamespace<Agentic>;
|
|
457
422
|
/**
|
|
458
423
|
* Agent's durable context
|
|
@@ -519,21 +484,11 @@ type EmailRoutingOptions<Env> = AgentOptions<Env> & {
|
|
|
519
484
|
* @param options The options for routing the email
|
|
520
485
|
* @returns A promise that resolves when the email has been routed
|
|
521
486
|
*/
|
|
522
|
-
declare function routeAgentEmail<Env>(
|
|
487
|
+
declare function routeAgentEmail<Env extends Cloudflare.Env = Cloudflare.Env>(
|
|
523
488
|
email: ForwardableEmailMessage,
|
|
524
489
|
env: Env,
|
|
525
490
|
options: EmailRoutingOptions<Env>
|
|
526
491
|
): Promise<void>;
|
|
527
|
-
type AgentEmail = {
|
|
528
|
-
from: string;
|
|
529
|
-
to: string;
|
|
530
|
-
getRaw: () => Promise<Uint8Array>;
|
|
531
|
-
headers: Headers;
|
|
532
|
-
rawSize: number;
|
|
533
|
-
setReject: (reason: string) => void;
|
|
534
|
-
forward: (rcptTo: string, headers?: Headers) => Promise<void>;
|
|
535
|
-
reply: (options: { from: string; to: string; raw: string }) => Promise<void>;
|
|
536
|
-
};
|
|
537
492
|
type EmailSendOptions = {
|
|
538
493
|
to: string;
|
|
539
494
|
subject: string;
|
|
@@ -554,12 +509,17 @@ type EmailSendOptions = {
|
|
|
554
509
|
* @param options Options for Agent creation
|
|
555
510
|
* @returns Promise resolving to an Agent instance stub
|
|
556
511
|
*/
|
|
557
|
-
declare function getAgentByName<
|
|
512
|
+
declare function getAgentByName<
|
|
513
|
+
Env extends Cloudflare.Env = Cloudflare.Env,
|
|
514
|
+
T extends Agent<Env> = Agent<Env>,
|
|
515
|
+
Props extends Record<string, unknown> = Record<string, unknown>
|
|
516
|
+
>(
|
|
558
517
|
namespace: AgentNamespace<T>,
|
|
559
518
|
name: string,
|
|
560
519
|
options?: {
|
|
561
520
|
jurisdiction?: DurableObjectJurisdiction;
|
|
562
521
|
locationHint?: DurableObjectLocationHint;
|
|
522
|
+
props?: Props;
|
|
563
523
|
}
|
|
564
524
|
): Promise<DurableObjectStub<T>>;
|
|
565
525
|
/**
|
|
@@ -581,35 +541,36 @@ declare class StreamingResponse {
|
|
|
581
541
|
*/
|
|
582
542
|
end(finalChunk?: unknown): void;
|
|
583
543
|
}
|
|
584
|
-
|
|
544
|
+
//#endregion
|
|
585
545
|
export {
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
546
|
+
createCatchAllEmailResolver as C,
|
|
547
|
+
routeAgentEmail as D,
|
|
548
|
+
getCurrentAgent as E,
|
|
549
|
+
routeAgentRequest as O,
|
|
550
|
+
createAddressBasedEmailResolver as S,
|
|
551
|
+
getAgentByName as T,
|
|
552
|
+
Schedule as _,
|
|
553
|
+
CallableMetadata as a,
|
|
554
|
+
WSMessage as b,
|
|
555
|
+
EmailResolver as c,
|
|
556
|
+
MCPServer as d,
|
|
557
|
+
MCPServerMessage as f,
|
|
558
|
+
RPCResponse as g,
|
|
559
|
+
RPCRequest as h,
|
|
560
|
+
AgentOptions as i,
|
|
561
|
+
unstable_callable as k,
|
|
562
|
+
EmailRoutingOptions as l,
|
|
563
|
+
QueueItem as m,
|
|
564
|
+
AgentContext as n,
|
|
565
|
+
Connection$1 as o,
|
|
566
|
+
MCPServersState as p,
|
|
567
|
+
AgentNamespace as r,
|
|
568
|
+
ConnectionContext as s,
|
|
569
|
+
Agent as t,
|
|
570
|
+
EmailSendOptions as u,
|
|
571
|
+
StateUpdateMessage as v,
|
|
572
|
+
createHeaderBasedEmailResolver as w,
|
|
573
|
+
callable as x,
|
|
574
|
+
StreamingResponse as y
|
|
615
575
|
};
|
|
576
|
+
//# sourceMappingURL=index-CfZ2mfMI.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { n as BaseEvent, t as MCPObservabilityEvent } from "./mcp-CPSfGUgd.js";
|
|
2
|
+
|
|
3
|
+
//#region src/observability/agent.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Agent-specific observability events
|
|
7
|
+
* These track the lifecycle and operations of an Agent
|
|
8
|
+
*/
|
|
9
|
+
type AgentObservabilityEvent =
|
|
10
|
+
| BaseEvent<"state:update", {}>
|
|
11
|
+
| BaseEvent<
|
|
12
|
+
"rpc",
|
|
13
|
+
{
|
|
14
|
+
method: string;
|
|
15
|
+
streaming?: boolean;
|
|
16
|
+
}
|
|
17
|
+
>
|
|
18
|
+
| BaseEvent<"message:request" | "message:response", {}>
|
|
19
|
+
| BaseEvent<"message:clear">
|
|
20
|
+
| BaseEvent<
|
|
21
|
+
"schedule:create" | "schedule:execute" | "schedule:cancel",
|
|
22
|
+
{
|
|
23
|
+
callback: string;
|
|
24
|
+
id: string;
|
|
25
|
+
}
|
|
26
|
+
>
|
|
27
|
+
| BaseEvent<"destroy">
|
|
28
|
+
| BaseEvent<
|
|
29
|
+
"connect",
|
|
30
|
+
{
|
|
31
|
+
connectionId: string;
|
|
32
|
+
}
|
|
33
|
+
>;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/observability/index.d.ts
|
|
36
|
+
/**
|
|
37
|
+
* Union of all observability event types from different domains
|
|
38
|
+
*/
|
|
39
|
+
type ObservabilityEvent = AgentObservabilityEvent | MCPObservabilityEvent;
|
|
40
|
+
interface Observability {
|
|
41
|
+
/**
|
|
42
|
+
* Emit an event for the Agent's observability implementation to handle.
|
|
43
|
+
* @param event - The event to emit
|
|
44
|
+
* @param ctx - The execution context of the invocation (optional)
|
|
45
|
+
*/
|
|
46
|
+
emit(event: ObservabilityEvent, ctx?: DurableObjectState): void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A generic observability implementation that logs events to the console.
|
|
50
|
+
*/
|
|
51
|
+
declare const genericObservability: Observability;
|
|
52
|
+
//#endregion
|
|
53
|
+
export {
|
|
54
|
+
ObservabilityEvent as n,
|
|
55
|
+
genericObservability as r,
|
|
56
|
+
Observability as t
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=index-DLuxm_9W.d.ts.map
|