agents 0.0.0-e2d7b5c → 0.0.0-e31e26c
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 -27
- package/dist/_esm-LV5FJ3HK.js +3922 -0
- package/dist/_esm-LV5FJ3HK.js.map +1 -0
- package/dist/ai-chat-agent.d.ts +41 -10
- package/dist/ai-chat-agent.js +561 -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 +20 -0
- package/dist/ai-react.d.ts +78 -67
- package/dist/ai-react.js +259 -108
- package/dist/ai-react.js.map +1 -1
- package/dist/ai-types.d.ts +37 -19
- package/dist/ai-types.js +7 -0
- package/dist/ccip-CMBYN64O.js +15 -0
- package/dist/ccip-CMBYN64O.js.map +1 -0
- package/dist/chunk-5Y6BEZDY.js +276 -0
- package/dist/chunk-5Y6BEZDY.js.map +1 -0
- package/dist/chunk-BER7KXUJ.js +18 -0
- package/dist/chunk-BER7KXUJ.js.map +1 -0
- package/dist/chunk-C2OEBJZ2.js +113 -0
- package/dist/chunk-C2OEBJZ2.js.map +1 -0
- package/dist/chunk-JJBFIGUC.js +5202 -0
- package/dist/chunk-JJBFIGUC.js.map +1 -0
- package/dist/chunk-PR4QN5HX.js +43 -0
- package/dist/chunk-PR4QN5HX.js.map +1 -0
- package/dist/chunk-QEVM4BVL.js +116 -0
- package/dist/chunk-QEVM4BVL.js.map +1 -0
- package/dist/chunk-TYAY6AU6.js +159 -0
- package/dist/chunk-TYAY6AU6.js.map +1 -0
- package/dist/chunk-UJVEAURM.js +150 -0
- package/dist/chunk-UJVEAURM.js.map +1 -0
- package/dist/chunk-XGMKNUJA.js +1343 -0
- package/dist/chunk-XGMKNUJA.js.map +1 -0
- package/dist/chunk-ZMMHNOMZ.js +942 -0
- package/dist/chunk-ZMMHNOMZ.js.map +1 -0
- package/dist/client-D1Fa-xS_.d.ts +5120 -0
- package/dist/client.d.ts +16 -2
- package/dist/client.js +8 -126
- package/dist/client.js.map +1 -1
- package/dist/codemode/ai.d.ts +25 -0
- package/dist/codemode/ai.js +5200 -0
- package/dist/codemode/ai.js.map +1 -0
- package/dist/index.d.ts +268 -25
- package/dist/index.js +14 -3
- package/dist/mcp/client.d.ts +10 -775
- package/dist/mcp/client.js +2 -2
- package/dist/mcp/do-oauth-client-provider.d.ts +4 -3
- package/dist/mcp/do-oauth-client-provider.js +4 -103
- package/dist/mcp/do-oauth-client-provider.js.map +1 -1
- package/dist/mcp/index.d.ts +61 -56
- package/dist/mcp/index.js +975 -686
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/x402.d.ts +39 -0
- package/dist/mcp/x402.js +3195 -0
- package/dist/mcp/x402.js.map +1 -0
- package/dist/mcp-BH1fJeiU.d.ts +58 -0
- package/dist/observability/index.d.ts +34 -0
- package/dist/observability/index.js +12 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/react.d.ts +97 -9
- package/dist/react.js +123 -11
- package/dist/react.js.map +1 -1
- package/dist/schedule.d.ts +81 -7
- package/dist/schedule.js +20 -7
- package/dist/schedule.js.map +1 -1
- package/dist/secp256k1-M22GZP2U.js +2193 -0
- package/dist/secp256k1-M22GZP2U.js.map +1 -0
- package/dist/serializable.d.ts +32 -0
- package/dist/serializable.js +1 -0
- package/dist/serializable.js.map +1 -0
- package/package.json +98 -68
- package/src/index.ts +1243 -154
- package/dist/chunk-HD4VEHBA.js +0 -608
- package/dist/chunk-HD4VEHBA.js.map +0 -1
- package/dist/chunk-HMLY7DHA.js +0 -16
- package/dist/chunk-Q5ZBHY4Z.js +0 -456
- 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,11 +10,12 @@ 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
|
+
get clientUri(): string;
|
|
18
19
|
get redirectUrl(): string;
|
|
19
20
|
get clientId(): string;
|
|
20
21
|
set clientId(clientId_: string);
|
|
@@ -1,106 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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-C2OEBJZ2.js";
|
|
4
|
+
import "../chunk-PR4QN5HX.js";
|
|
104
5
|
export {
|
|
105
6
|
DurableObjectOAuthClientProvider
|
|
106
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,72 +1,77 @@
|
|
|
1
|
-
import { MCPClientManager } from './client.js';
|
|
2
|
-
import { DurableObject } from 'cloudflare:workers';
|
|
3
|
-
import { Connection, WSMessage } from 'partyserver';
|
|
4
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
6
|
-
import '
|
|
7
|
-
import '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { JSONRPCMessage, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
export { ElicitRequest, ElicitRequestSchema, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { Agent } from '../index.js';
|
|
6
|
+
import { M as MaybePromise, B as BaseTransportType, S as ServeOptions } from '../client-D1Fa-xS_.js';
|
|
7
|
+
export { d as MCPClientOAuthCallbackConfig, c as MCPClientOAuthResult, a as SSEEdgeClientTransport, b as StreamableHTTPEdgeClientTransport } from '../client-D1Fa-xS_.js';
|
|
8
|
+
import { Connection, ConnectionContext } from 'partyserver';
|
|
9
|
+
import 'cloudflare:workers';
|
|
8
10
|
import '@modelcontextprotocol/sdk/client/index.js';
|
|
11
|
+
import '../observability/index.js';
|
|
12
|
+
import '../mcp-BH1fJeiU.js';
|
|
13
|
+
import '../ai-types.js';
|
|
14
|
+
import 'ai';
|
|
15
|
+
import 'zod';
|
|
16
|
+
import '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
9
17
|
import '@modelcontextprotocol/sdk/client/sse.js';
|
|
18
|
+
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
10
19
|
import './do-oauth-client-provider.js';
|
|
11
20
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
12
21
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
13
|
-
import '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
14
|
-
import 'ai';
|
|
15
22
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
headers?: string;
|
|
20
|
-
maxAge?: number;
|
|
21
|
-
}
|
|
22
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
23
|
-
declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
|
|
24
|
-
#private;
|
|
25
|
-
get mcp(): MCPClientManager;
|
|
26
|
-
protected constructor(ctx: DurableObjectState, env: Env);
|
|
27
|
-
/**
|
|
28
|
-
* Agents API allowlist
|
|
29
|
-
*/
|
|
30
|
-
initialState: State;
|
|
31
|
-
get state(): State;
|
|
32
|
-
sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
|
|
33
|
-
setState(state: State): void;
|
|
34
|
-
onStateUpdate(state: State | undefined, source: Connection | "server"): void;
|
|
35
|
-
onStart(): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* McpAgent API
|
|
38
|
-
*/
|
|
23
|
+
declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
|
|
24
|
+
private _transport?;
|
|
25
|
+
props?: Props;
|
|
39
26
|
abstract server: MaybePromise<McpServer | Server>;
|
|
40
|
-
props: Props;
|
|
41
|
-
initRun: boolean;
|
|
42
27
|
abstract init(): Promise<void>;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
28
|
+
setInitializeRequest(initializeRequest: JSONRPCMessage): Promise<void>;
|
|
29
|
+
getInitializeRequest(): Promise<JSONRPCMessage | undefined>;
|
|
30
|
+
/** Read the transport type for this agent.
|
|
31
|
+
* This relies on the naming scheme being `sse:${sessionId}`
|
|
32
|
+
* or `streamable-http:${sessionId}`.
|
|
33
|
+
*/
|
|
34
|
+
getTransportType(): BaseTransportType;
|
|
35
|
+
/** Read the sessionId for this agent.
|
|
36
|
+
* This relies on the naming scheme being `sse:${sessionId}`
|
|
37
|
+
* or `streamable-http:${sessionId}`.
|
|
38
|
+
*/
|
|
39
|
+
getSessionId(): string;
|
|
40
|
+
/** Get the unique WebSocket. SSE transport only. */
|
|
41
|
+
private getWebSocket;
|
|
42
|
+
/** Returns a new transport matching the type of the Agent. */
|
|
43
|
+
private initTransport;
|
|
44
|
+
/** Update and store the props */
|
|
45
|
+
updateProps(props?: Props): Promise<void>;
|
|
46
|
+
reinitializeServer(): Promise<void>;
|
|
47
|
+
/** Sets up the MCP transport and server every time the Agent is started.*/
|
|
48
|
+
onStart(props?: Props): Promise<void>;
|
|
49
|
+
/** Validates new WebSocket connections. */
|
|
50
|
+
onConnect(conn: Connection, { request: req }: ConnectionContext): Promise<void>;
|
|
51
|
+
/** Handles MCP Messages for the legacy SSE transport. */
|
|
52
|
+
onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
|
|
53
|
+
/** Elicit user input with a message and schema */
|
|
54
|
+
elicitInput(params: {
|
|
55
|
+
message: string;
|
|
56
|
+
requestedSchema: unknown;
|
|
57
|
+
}): Promise<ElicitResult>;
|
|
58
|
+
/** Wait for elicitation response through storage polling */
|
|
59
|
+
private _waitForElicitationResponse;
|
|
60
|
+
/** Handle elicitation responses */
|
|
61
|
+
private _handleElicitationResponse;
|
|
62
|
+
/** Return a handler for the given path for this MCP.
|
|
63
|
+
* Defaults to Streamable HTTP transport.
|
|
64
|
+
*/
|
|
65
|
+
static serve(path: string, { binding, corsOptions, transport }?: ServeOptions): {
|
|
58
66
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
59
67
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Legacy api
|
|
70
|
+
**/
|
|
71
|
+
static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
|
|
64
72
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
65
73
|
};
|
|
66
|
-
static
|
|
67
|
-
binding?: string;
|
|
68
|
-
corsOptions?: CORSOptions;
|
|
69
|
-
}): {
|
|
74
|
+
static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
|
|
70
75
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
71
76
|
};
|
|
72
77
|
}
|