agents 0.0.0-5a71b74 → 0.0.0-5e80ca6

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.
Files changed (99) hide show
  1. package/README.md +5 -3
  2. package/dist/ai-chat-agent.d.ts +99 -20
  3. package/dist/ai-chat-agent.js +804 -644
  4. package/dist/ai-chat-agent.js.map +1 -1
  5. package/dist/ai-chat-v5-migration-BSiGZmYU.js +155 -0
  6. package/dist/ai-chat-v5-migration-BSiGZmYU.js.map +1 -0
  7. package/dist/ai-chat-v5-migration.d.ts +7 -4
  8. package/dist/ai-chat-v5-migration.js +3 -20
  9. package/dist/ai-react.d.ts +19 -24
  10. package/dist/ai-react.js +408 -349
  11. package/dist/ai-react.js.map +1 -1
  12. package/dist/ai-types-81H_-Uxh.d.ts +103 -0
  13. package/dist/ai-types-CrMqkwc_.js +24 -0
  14. package/dist/ai-types-CrMqkwc_.js.map +1 -0
  15. package/dist/ai-types.d.ts +6 -92
  16. package/dist/ai-types.js +3 -8
  17. package/dist/cli/index.d.ts +1 -0
  18. package/dist/cli/index.js +28 -0
  19. package/dist/cli/index.js.map +1 -0
  20. package/dist/client-B3SR12TQ.js +117 -0
  21. package/dist/client-B3SR12TQ.js.map +1 -0
  22. package/dist/client-BAQA84dr.d.ts +104 -0
  23. package/dist/client-CFhjXCiO.js +1093 -0
  24. package/dist/client-CFhjXCiO.js.map +1 -0
  25. package/dist/client-CwqTTb-B.d.ts +833 -0
  26. package/dist/client.d.ts +11 -92
  27. package/dist/client.js +4 -13
  28. package/dist/codemode/ai.d.ts +19 -17
  29. package/dist/codemode/ai.js +90 -5051
  30. package/dist/codemode/ai.js.map +1 -1
  31. package/dist/do-oauth-client-provider-C2CHH5x-.d.ts +55 -0
  32. package/dist/do-oauth-client-provider-CwqK5SXm.js +94 -0
  33. package/dist/do-oauth-client-provider-CwqK5SXm.js.map +1 -0
  34. package/dist/index-BUle9RiP.d.ts +58 -0
  35. package/dist/index-DJ4vV2-x.d.ts +587 -0
  36. package/dist/index.d.ts +55 -542
  37. package/dist/index.js +7 -32
  38. package/dist/mcp/client.d.ts +4 -12
  39. package/dist/mcp/client.js +4 -10
  40. package/dist/mcp/do-oauth-client-provider.d.ts +2 -42
  41. package/dist/mcp/do-oauth-client-provider.js +3 -8
  42. package/dist/mcp/index.d.ts +190 -76
  43. package/dist/mcp/index.js +1428 -1080
  44. package/dist/mcp/index.js.map +1 -1
  45. package/dist/mcp/x402.d.ts +22 -27
  46. package/dist/mcp/x402.js +190 -3187
  47. package/dist/mcp/x402.js.map +1 -1
  48. package/dist/{mcp-BH1fJeiU.d.ts → mcp-BwPscEiF.d.ts} +6 -3
  49. package/dist/observability/index.d.ts +3 -34
  50. package/dist/observability/index.js +7 -12
  51. package/dist/react-w4GT20p4.d.ts +113 -0
  52. package/dist/react.d.ts +10 -127
  53. package/dist/react.js +173 -200
  54. package/dist/react.js.map +1 -1
  55. package/dist/schedule.d.ts +13 -10
  56. package/dist/schedule.js +43 -33
  57. package/dist/schedule.js.map +1 -1
  58. package/dist/serializable-faDkMCai.d.ts +39 -0
  59. package/dist/serializable.d.ts +7 -32
  60. package/dist/serializable.js +1 -1
  61. package/dist/src-tXpYCgas.js +1184 -0
  62. package/dist/src-tXpYCgas.js.map +1 -0
  63. package/package.json +58 -32
  64. package/dist/_esm-LV5FJ3HK.js +0 -3922
  65. package/dist/_esm-LV5FJ3HK.js.map +0 -1
  66. package/dist/ai-chat-v5-migration.js.map +0 -1
  67. package/dist/ai-types.js.map +0 -1
  68. package/dist/ccip-CMBYN64O.js +0 -15
  69. package/dist/ccip-CMBYN64O.js.map +0 -1
  70. package/dist/chunk-254F4GDT.js +0 -1343
  71. package/dist/chunk-254F4GDT.js.map +0 -1
  72. package/dist/chunk-3OT2NNEW.js +0 -941
  73. package/dist/chunk-3OT2NNEW.js.map +0 -1
  74. package/dist/chunk-5Y6BEZDY.js +0 -276
  75. package/dist/chunk-5Y6BEZDY.js.map +0 -1
  76. package/dist/chunk-BER7KXUJ.js +0 -18
  77. package/dist/chunk-BER7KXUJ.js.map +0 -1
  78. package/dist/chunk-JJBFIGUC.js +0 -5202
  79. package/dist/chunk-JJBFIGUC.js.map +0 -1
  80. package/dist/chunk-PR4QN5HX.js +0 -43
  81. package/dist/chunk-PR4QN5HX.js.map +0 -1
  82. package/dist/chunk-QEVM4BVL.js +0 -116
  83. package/dist/chunk-QEVM4BVL.js.map +0 -1
  84. package/dist/chunk-TYAY6AU6.js +0 -159
  85. package/dist/chunk-TYAY6AU6.js.map +0 -1
  86. package/dist/chunk-UJVEAURM.js +0 -150
  87. package/dist/chunk-UJVEAURM.js.map +0 -1
  88. package/dist/chunk-Z44WASMA.js +0 -114
  89. package/dist/chunk-Z44WASMA.js.map +0 -1
  90. package/dist/client-D1Fa-xS_.d.ts +0 -5120
  91. package/dist/client.js.map +0 -1
  92. package/dist/index.js.map +0 -1
  93. package/dist/mcp/client.js.map +0 -1
  94. package/dist/mcp/do-oauth-client-provider.js.map +0 -1
  95. package/dist/observability/index.js.map +0 -1
  96. package/dist/secp256k1-M22GZP2U.js +0 -2193
  97. package/dist/secp256k1-M22GZP2U.js.map +0 -1
  98. package/dist/serializable.js.map +0 -1
  99. package/src/index.ts +0 -2031
@@ -0,0 +1,55 @@
1
+ import { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
2
+ import {
3
+ OAuthClientInformation,
4
+ OAuthClientInformationFull,
5
+ OAuthClientMetadata,
6
+ OAuthTokens
7
+ } from "@modelcontextprotocol/sdk/shared/auth.js";
8
+
9
+ //#region src/mcp/do-oauth-client-provider.d.ts
10
+ interface AgentsOAuthProvider extends OAuthClientProvider {
11
+ authUrl: string | undefined;
12
+ clientId: string | undefined;
13
+ serverId: string | undefined;
14
+ }
15
+ declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
16
+ storage: DurableObjectStorage;
17
+ clientName: string;
18
+ baseRedirectUrl: string;
19
+ private _authUrl_;
20
+ private _serverId_;
21
+ private _clientId_;
22
+ constructor(
23
+ storage: DurableObjectStorage,
24
+ clientName: string,
25
+ baseRedirectUrl: string
26
+ );
27
+ get clientMetadata(): OAuthClientMetadata;
28
+ get clientUri(): string;
29
+ get redirectUrl(): string;
30
+ get clientId(): string;
31
+ set clientId(clientId_: string);
32
+ get serverId(): string;
33
+ set serverId(serverId_: string);
34
+ keyPrefix(clientId: string): string;
35
+ clientInfoKey(clientId: string): string;
36
+ clientInformation(): Promise<OAuthClientInformation | undefined>;
37
+ saveClientInformation(
38
+ clientInformation: OAuthClientInformationFull
39
+ ): Promise<void>;
40
+ tokenKey(clientId: string): string;
41
+ tokens(): Promise<OAuthTokens | undefined>;
42
+ saveTokens(tokens: OAuthTokens): Promise<void>;
43
+ get authUrl(): string | undefined;
44
+ /**
45
+ * Because this operates on the server side (but we need browser auth), we send this url back to the user
46
+ * and require user interact to initiate the redirect flow
47
+ */
48
+ redirectToAuthorization(authUrl: URL): Promise<void>;
49
+ codeVerifierKey(clientId: string): string;
50
+ saveCodeVerifier(verifier: string): Promise<void>;
51
+ codeVerifier(): Promise<string>;
52
+ }
53
+ //#endregion
54
+ export { DurableObjectOAuthClientProvider as n, AgentsOAuthProvider as t };
55
+ //# sourceMappingURL=do-oauth-client-provider-C2CHH5x-.d.ts.map
@@ -0,0 +1,94 @@
1
+ import { nanoid } from "nanoid";
2
+
3
+ //#region src/mcp/do-oauth-client-provider.ts
4
+ var DurableObjectOAuthClientProvider = class {
5
+ constructor(storage, clientName, baseRedirectUrl) {
6
+ this.storage = storage;
7
+ this.clientName = clientName;
8
+ this.baseRedirectUrl = baseRedirectUrl;
9
+ if (!storage) throw new Error("DurableObjectOAuthClientProvider requires a valid DurableObjectStorage instance");
10
+ }
11
+ get clientMetadata() {
12
+ return {
13
+ client_name: this.clientName,
14
+ client_uri: this.clientUri,
15
+ grant_types: ["authorization_code", "refresh_token"],
16
+ redirect_uris: [this.redirectUrl],
17
+ response_types: ["code"],
18
+ token_endpoint_auth_method: "none"
19
+ };
20
+ }
21
+ get clientUri() {
22
+ return new URL(this.redirectUrl).origin;
23
+ }
24
+ get redirectUrl() {
25
+ return `${this.baseRedirectUrl}/${this.serverId}`;
26
+ }
27
+ get clientId() {
28
+ if (!this._clientId_) throw new Error("Trying to access clientId before it was set");
29
+ return this._clientId_;
30
+ }
31
+ set clientId(clientId_) {
32
+ this._clientId_ = clientId_;
33
+ }
34
+ get serverId() {
35
+ if (!this._serverId_) throw new Error("Trying to access serverId before it was set");
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_) return;
49
+ return await this.storage.get(this.clientInfoKey(this.clientId)) ?? void 0;
50
+ }
51
+ async saveClientInformation(clientInformation) {
52
+ await this.storage.put(this.clientInfoKey(clientInformation.client_id), clientInformation);
53
+ this.clientId = clientInformation.client_id;
54
+ }
55
+ tokenKey(clientId) {
56
+ return `${this.keyPrefix(clientId)}/token`;
57
+ }
58
+ async tokens() {
59
+ if (!this._clientId_) return;
60
+ return await this.storage.get(this.tokenKey(this.clientId)) ?? void 0;
61
+ }
62
+ async saveTokens(tokens) {
63
+ await this.storage.put(this.tokenKey(this.clientId), tokens);
64
+ }
65
+ get authUrl() {
66
+ return this._authUrl_;
67
+ }
68
+ /**
69
+ * Because this operates on the server side (but we need browser auth), we send this url back to the user
70
+ * and require user interact to initiate the redirect flow
71
+ */
72
+ async redirectToAuthorization(authUrl) {
73
+ const stateToken = nanoid();
74
+ authUrl.searchParams.set("state", stateToken);
75
+ this._authUrl_ = authUrl.toString();
76
+ }
77
+ codeVerifierKey(clientId) {
78
+ return `${this.keyPrefix(clientId)}/code_verifier`;
79
+ }
80
+ async saveCodeVerifier(verifier) {
81
+ const key = this.codeVerifierKey(this.clientId);
82
+ if (await this.storage.get(key)) return;
83
+ await this.storage.put(key, verifier);
84
+ }
85
+ async codeVerifier() {
86
+ const codeVerifier = await this.storage.get(this.codeVerifierKey(this.clientId));
87
+ if (!codeVerifier) throw new Error("No code verifier found");
88
+ return codeVerifier;
89
+ }
90
+ };
91
+
92
+ //#endregion
93
+ export { DurableObjectOAuthClientProvider as t };
94
+ //# sourceMappingURL=do-oauth-client-provider-CwqK5SXm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"do-oauth-client-provider-CwqK5SXm.js","names":["storage: DurableObjectStorage","clientName: string","baseRedirectUrl: 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\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}\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}/${this.serverId}`;\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 /**\n * Because this operates on the server side (but we need browser auth), we send this url back to the user\n * and require user interact to initiate the redirect flow\n */\n async redirectToAuthorization(authUrl: URL): Promise<void> {\n // Generate secure random token for state parameter\n const stateToken = nanoid();\n authUrl.searchParams.set(\"state\", stateToken);\n this._authUrl_ = authUrl.toString();\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"],"mappings":";;;AAiBA,IAAa,mCAAb,MAA6E;CAK3E,YACE,AAAOA,SACP,AAAOC,YACP,AAAOC,iBACP;EAHO;EACA;EACA;AAEP,MAAI,CAAC,QACH,OAAM,IAAI,MACR,kFACD;;CAIL,IAAI,iBAAsC;AACxC,SAAO;GACL,aAAa,KAAK;GAClB,YAAY,KAAK;GACjB,aAAa,CAAC,sBAAsB,gBAAgB;GACpD,eAAe,CAAC,KAAK,YAAY;GACjC,gBAAgB,CAAC,OAAO;GACxB,4BAA4B;GAC7B;;CAGH,IAAI,YAAY;AACd,SAAO,IAAI,IAAI,KAAK,YAAY,CAAC;;CAGnC,IAAI,cAAc;AAChB,SAAO,GAAG,KAAK,gBAAgB,GAAG,KAAK;;CAGzC,IAAI,WAAW;AACb,MAAI,CAAC,KAAK,WACR,OAAM,IAAI,MAAM,8CAA8C;AAEhE,SAAO,KAAK;;CAGd,IAAI,SAAS,WAAmB;AAC9B,OAAK,aAAa;;CAGpB,IAAI,WAAW;AACb,MAAI,CAAC,KAAK,WACR,OAAM,IAAI,MAAM,8CAA8C;AAEhE,SAAO,KAAK;;CAGd,IAAI,SAAS,WAAmB;AAC9B,OAAK,aAAa;;CAGpB,UAAU,UAAkB;AAC1B,SAAO,IAAI,KAAK,WAAW,GAAG,KAAK,SAAS,GAAG;;CAGjD,cAAc,UAAkB;AAC9B,SAAO,GAAG,KAAK,UAAU,SAAS,CAAC;;CAGrC,MAAM,oBAAiE;AACrE,MAAI,CAAC,KAAK,WACR;AAEF,SACG,MAAM,KAAK,QAAQ,IAClB,KAAK,cAAc,KAAK,SAAS,CAClC,IAAK;;CAIV,MAAM,sBACJ,mBACe;AACf,QAAM,KAAK,QAAQ,IACjB,KAAK,cAAc,kBAAkB,UAAU,EAC/C,kBACD;AACD,OAAK,WAAW,kBAAkB;;CAGpC,SAAS,UAAkB;AACzB,SAAO,GAAG,KAAK,UAAU,SAAS,CAAC;;CAGrC,MAAM,SAA2C;AAC/C,MAAI,CAAC,KAAK,WACR;AAEF,SACG,MAAM,KAAK,QAAQ,IAAiB,KAAK,SAAS,KAAK,SAAS,CAAC,IAClE;;CAIJ,MAAM,WAAW,QAAoC;AACnD,QAAM,KAAK,QAAQ,IAAI,KAAK,SAAS,KAAK,SAAS,EAAE,OAAO;;CAG9D,IAAI,UAAU;AACZ,SAAO,KAAK;;;;;;CAOd,MAAM,wBAAwB,SAA6B;EAEzD,MAAM,aAAa,QAAQ;AAC3B,UAAQ,aAAa,IAAI,SAAS,WAAW;AAC7C,OAAK,YAAY,QAAQ,UAAU;;CAGrC,gBAAgB,UAAkB;AAChC,SAAO,GAAG,KAAK,UAAU,SAAS,CAAC;;CAGrC,MAAM,iBAAiB,UAAiC;EACtD,MAAM,MAAM,KAAK,gBAAgB,KAAK,SAAS;AAI/C,MADiB,MAAM,KAAK,QAAQ,IAAY,IAAI,CAElD;AAGF,QAAM,KAAK,QAAQ,IAAI,KAAK,SAAS;;CAGvC,MAAM,eAAgC;EACpC,MAAM,eAAe,MAAM,KAAK,QAAQ,IACtC,KAAK,gBAAgB,KAAK,SAAS,CACpC;AACD,MAAI,CAAC,aACH,OAAM,IAAI,MAAM,yBAAyB;AAE3C,SAAO"}
@@ -0,0 +1,58 @@
1
+ import { n as BaseEvent, t as MCPObservabilityEvent } from "./mcp-BwPscEiF.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-BUle9RiP.d.ts.map