agents 0.0.0-d3e7a68 → 0.0.0-d4257c1

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 (95) hide show
  1. package/dist/ai-chat-agent.d.ts +16 -17
  2. package/dist/ai-chat-agent.js +532 -644
  3. package/dist/ai-chat-agent.js.map +1 -1
  4. package/dist/ai-chat-v5-migration-gdyLiTd8.js +155 -0
  5. package/dist/ai-chat-v5-migration-gdyLiTd8.js.map +1 -0
  6. package/dist/ai-chat-v5-migration.d.ts +7 -4
  7. package/dist/ai-chat-v5-migration.js +3 -20
  8. package/dist/ai-react.d.ts +14 -23
  9. package/dist/ai-react.js +257 -349
  10. package/dist/ai-react.js.map +1 -1
  11. package/dist/ai-types-BWW4umHY.d.ts +95 -0
  12. package/dist/ai-types-UZlfLOYP.js +20 -0
  13. package/dist/ai-types-UZlfLOYP.js.map +1 -0
  14. package/dist/ai-types.d.ts +6 -92
  15. package/dist/ai-types.js +3 -8
  16. package/dist/client-C-nwz-3N.d.ts +5313 -0
  17. package/dist/client-CZBVDDoO.js +786 -0
  18. package/dist/client-CZBVDDoO.js.map +1 -0
  19. package/dist/client-CmMi85Sj.d.ts +104 -0
  20. package/dist/client-DjR-lC16.js +117 -0
  21. package/dist/client-DjR-lC16.js.map +1 -0
  22. package/dist/client.d.ts +11 -92
  23. package/dist/client.js +4 -13
  24. package/dist/codemode/ai.d.ts +27 -0
  25. package/dist/codemode/ai.js +151 -0
  26. package/dist/codemode/ai.js.map +1 -0
  27. package/dist/do-oauth-client-provider-B2jr6UNq.js +93 -0
  28. package/dist/do-oauth-client-provider-B2jr6UNq.js.map +1 -0
  29. package/dist/do-oauth-client-provider-CCwGwnrA.d.ts +55 -0
  30. package/dist/index-CkQU40oY.d.ts +558 -0
  31. package/dist/index-W4JUkafc.d.ts +54 -0
  32. package/dist/index.d.ts +55 -556
  33. package/dist/index.js +7 -32
  34. package/dist/mcp/client.d.ts +4 -11
  35. package/dist/mcp/client.js +3 -10
  36. package/dist/mcp/do-oauth-client-provider.d.ts +2 -50
  37. package/dist/mcp/do-oauth-client-provider.js +3 -8
  38. package/dist/mcp/index.d.ts +72 -75
  39. package/dist/mcp/index.js +830 -1082
  40. package/dist/mcp/index.js.map +1 -1
  41. package/dist/mcp/x402.d.ts +22 -27
  42. package/dist/mcp/x402.js +186 -3187
  43. package/dist/mcp/x402.js.map +1 -1
  44. package/dist/mcp-BEwaCsxO.d.ts +61 -0
  45. package/dist/observability/index.d.ts +3 -46
  46. package/dist/observability/index.js +7 -12
  47. package/dist/react-B4e1rDid.d.ts +113 -0
  48. package/dist/react.d.ts +10 -126
  49. package/dist/react.js +173 -200
  50. package/dist/react.js.map +1 -1
  51. package/dist/schedule.d.ts +13 -10
  52. package/dist/schedule.js +43 -33
  53. package/dist/schedule.js.map +1 -1
  54. package/dist/serializable-gtr9YMhp.d.ts +34 -0
  55. package/dist/serializable.d.ts +7 -32
  56. package/dist/serializable.js +1 -1
  57. package/dist/src-COfG--3R.js +1179 -0
  58. package/dist/src-COfG--3R.js.map +1 -0
  59. package/package.json +27 -9
  60. package/src/index.ts +97 -53
  61. package/dist/_esm-LV5FJ3HK.js +0 -3922
  62. package/dist/_esm-LV5FJ3HK.js.map +0 -1
  63. package/dist/ai-chat-v5-migration.js.map +0 -1
  64. package/dist/ai-types.js.map +0 -1
  65. package/dist/ccip-CMBYN64O.js +0 -15
  66. package/dist/ccip-CMBYN64O.js.map +0 -1
  67. package/dist/chunk-5Y6BEZDY.js +0 -276
  68. package/dist/chunk-5Y6BEZDY.js.map +0 -1
  69. package/dist/chunk-BER7KXUJ.js +0 -18
  70. package/dist/chunk-BER7KXUJ.js.map +0 -1
  71. package/dist/chunk-JJBFIGUC.js +0 -5202
  72. package/dist/chunk-JJBFIGUC.js.map +0 -1
  73. package/dist/chunk-PR4QN5HX.js +0 -43
  74. package/dist/chunk-PR4QN5HX.js.map +0 -1
  75. package/dist/chunk-QEPGNUG6.js +0 -650
  76. package/dist/chunk-QEPGNUG6.js.map +0 -1
  77. package/dist/chunk-QEVM4BVL.js +0 -116
  78. package/dist/chunk-QEVM4BVL.js.map +0 -1
  79. package/dist/chunk-RS5OCNEQ.js +0 -1323
  80. package/dist/chunk-RS5OCNEQ.js.map +0 -1
  81. package/dist/chunk-TYAY6AU6.js +0 -159
  82. package/dist/chunk-TYAY6AU6.js.map +0 -1
  83. package/dist/chunk-UJVEAURM.js +0 -150
  84. package/dist/chunk-UJVEAURM.js.map +0 -1
  85. package/dist/chunk-XFS5ERG3.js +0 -127
  86. package/dist/chunk-XFS5ERG3.js.map +0 -1
  87. package/dist/client-DNEb-lf3.d.ts +0 -5041
  88. package/dist/client.js.map +0 -1
  89. package/dist/index.js.map +0 -1
  90. package/dist/mcp/client.js.map +0 -1
  91. package/dist/mcp/do-oauth-client-provider.js.map +0 -1
  92. package/dist/observability/index.js.map +0 -1
  93. package/dist/secp256k1-M22GZP2U.js +0 -2193
  94. package/dist/secp256k1-M22GZP2U.js.map +0 -1
  95. package/dist/serializable.js.map +0 -1
@@ -0,0 +1,61 @@
1
+ //#region src/observability/base.d.ts
2
+ /**
3
+ * Base event structure for all observability events
4
+ */
5
+ type BaseEvent<
6
+ T extends string,
7
+ Payload extends Record<string, unknown> = {}
8
+ > = {
9
+ type: T;
10
+ /**
11
+ * The unique identifier for the event
12
+ */
13
+ id: string;
14
+ /**
15
+ * The message to display in the logs for this event, should the implementation choose to display
16
+ * a human-readable message.
17
+ */
18
+ displayMessage: string;
19
+ /**
20
+ * The payload of the event
21
+ */
22
+ payload: Payload & Record<string, unknown>;
23
+ /**
24
+ * The timestamp of the event in milliseconds since epoch
25
+ */
26
+ timestamp: number;
27
+ };
28
+ //#endregion
29
+ //#region src/observability/mcp.d.ts
30
+ /**
31
+ * MCP-specific observability events
32
+ * These track the lifecycle of MCP connections and operations
33
+ */
34
+ type MCPObservabilityEvent =
35
+ | BaseEvent<
36
+ "mcp:client:preconnect",
37
+ {
38
+ serverId: string;
39
+ }
40
+ >
41
+ | BaseEvent<
42
+ "mcp:client:connect",
43
+ {
44
+ url: string;
45
+ transport: string;
46
+ state: string;
47
+ error?: string;
48
+ }
49
+ >
50
+ | BaseEvent<
51
+ "mcp:client:authorize",
52
+ {
53
+ serverId: string;
54
+ authUrl: string;
55
+ clientId?: string;
56
+ }
57
+ >
58
+ | BaseEvent<"mcp:client:discover", {}>;
59
+ //#endregion
60
+ export { BaseEvent, MCPObservabilityEvent };
61
+ //# sourceMappingURL=mcp-BEwaCsxO.d.ts.map
@@ -1,46 +1,3 @@
1
- type BaseEvent<T extends string, Payload extends Record<string, unknown> = {}> = {
2
- type: T;
3
- /**
4
- * The unique identifier for the event
5
- */
6
- id: string;
7
- /**
8
- * The message to display in the logs for this event, should the implementation choose to display
9
- * a human-readable message.
10
- */
11
- displayMessage: string;
12
- /**
13
- * The payload of the event
14
- */
15
- payload: Payload;
16
- /**
17
- * The timestamp of the event in milliseconds since epoch
18
- */
19
- timestamp: number;
20
- };
21
- /**
22
- * The type of events that can be emitted by an Agent
23
- */
24
- type ObservabilityEvent = BaseEvent<"state:update", {}> | BaseEvent<"rpc", {
25
- method: string;
26
- streaming?: boolean;
27
- }> | BaseEvent<"message:request" | "message:response", {}> | BaseEvent<"message:clear"> | BaseEvent<"schedule:create" | "schedule:execute" | "schedule:cancel", {
28
- callback: string;
29
- id: string;
30
- }> | BaseEvent<"destroy"> | BaseEvent<"connect", {
31
- connectionId: string;
32
- }>;
33
- interface Observability {
34
- /**
35
- * Emit an event for the Agent's observability implementation to handle.
36
- * @param event - The event to emit
37
- * @param ctx - The execution context of the invocation
38
- */
39
- emit(event: ObservabilityEvent, ctx: DurableObjectState): void;
40
- }
41
- /**
42
- * A generic observability implementation that logs events to the console.
43
- */
44
- declare const genericObservability: Observability;
45
-
46
- export { type Observability, type ObservabilityEvent, genericObservability };
1
+ import "../mcp-BEwaCsxO.js";
2
+ import { Observability, ObservabilityEvent, genericObservability } from "../index-W4JUkafc.js";
3
+ export { Observability, ObservabilityEvent, genericObservability };
@@ -1,12 +1,7 @@
1
- import {
2
- genericObservability
3
- } from "../chunk-RS5OCNEQ.js";
4
- import "../chunk-QEPGNUG6.js";
5
- import "../chunk-XFS5ERG3.js";
6
- import "../chunk-QEVM4BVL.js";
7
- import "../chunk-BER7KXUJ.js";
8
- import "../chunk-PR4QN5HX.js";
9
- export {
10
- genericObservability
11
- };
12
- //# sourceMappingURL=index.js.map
1
+ import "../ai-types-UZlfLOYP.js";
2
+ import "../client-DjR-lC16.js";
3
+ import "../client-CZBVDDoO.js";
4
+ import "../do-oauth-client-provider-B2jr6UNq.js";
5
+ import { genericObservability } from "../src-COfG--3R.js";
6
+
7
+ export { genericObservability };
@@ -0,0 +1,113 @@
1
+ import { Agent, MCPServersState } from "./index-CkQU40oY.js";
2
+ import { Method, RPCMethod } from "./serializable-gtr9YMhp.js";
3
+ import { StreamOptions } from "./client-CmMi85Sj.js";
4
+ import { PartySocket } from "partysocket";
5
+ import { usePartySocket } from "partysocket/react";
6
+
7
+ //#region src/react.d.ts
8
+ type QueryObject = Record<string, string | null>;
9
+ /**
10
+ * Options for the useAgent hook
11
+ * @template State Type of the Agent's state
12
+ */
13
+ type UseAgentOptions<State = unknown> = Omit<
14
+ Parameters<typeof usePartySocket>[0],
15
+ "party" | "room" | "query"
16
+ > & {
17
+ /** Name of the agent to connect to */
18
+ agent: string;
19
+ /** Name of the specific Agent instance */
20
+ name?: string;
21
+ /** Query parameters - can be static object or async function */
22
+ query?: QueryObject | (() => Promise<QueryObject>);
23
+ /** Dependencies for async query caching */
24
+ queryDeps?: unknown[];
25
+ /** Cache TTL in milliseconds for auth tokens/time-sensitive data */
26
+ cacheTtl?: number;
27
+ /** Called when the Agent's state is updated */
28
+ onStateUpdate?: (state: State, source: "server" | "client") => void;
29
+ /** Called when MCP server state is updated */
30
+ onMcpUpdate?: (mcpServers: MCPServersState) => void;
31
+ };
32
+ type AllOptional<T> = T extends [infer A, ...infer R]
33
+ ? undefined extends A
34
+ ? AllOptional<R>
35
+ : false
36
+ : true;
37
+ type RPCMethods<T> = {
38
+ [K in keyof T as T[K] extends RPCMethod<T[K]> ? K : never]: RPCMethod<T[K]>;
39
+ };
40
+ type OptionalParametersMethod<T extends RPCMethod> =
41
+ AllOptional<Parameters<T>> extends true ? T : never;
42
+ type AgentMethods<T> = Omit<RPCMethods<T>, keyof Agent<any, any>>;
43
+ type OptionalAgentMethods<T> = {
44
+ [K in keyof AgentMethods<T> as AgentMethods<T>[K] extends OptionalParametersMethod<
45
+ AgentMethods<T>[K]
46
+ >
47
+ ? K
48
+ : never]: OptionalParametersMethod<AgentMethods<T>[K]>;
49
+ };
50
+ type RequiredAgentMethods<T> = Omit<
51
+ AgentMethods<T>,
52
+ keyof OptionalAgentMethods<T>
53
+ >;
54
+ type AgentPromiseReturnType<T, K extends keyof AgentMethods<T>> =
55
+ ReturnType<AgentMethods<T>[K]> extends Promise<any>
56
+ ? ReturnType<AgentMethods<T>[K]>
57
+ : Promise<ReturnType<AgentMethods<T>[K]>>;
58
+ type OptionalArgsAgentMethodCall<AgentT> = <
59
+ K extends keyof OptionalAgentMethods<AgentT>
60
+ >(
61
+ method: K,
62
+ args?: Parameters<OptionalAgentMethods<AgentT>[K]>,
63
+ streamOptions?: StreamOptions
64
+ ) => AgentPromiseReturnType<AgentT, K>;
65
+ type RequiredArgsAgentMethodCall<AgentT> = <
66
+ K extends keyof RequiredAgentMethods<AgentT>
67
+ >(
68
+ method: K,
69
+ args: Parameters<RequiredAgentMethods<AgentT>[K]>,
70
+ streamOptions?: StreamOptions
71
+ ) => AgentPromiseReturnType<AgentT, K>;
72
+ type AgentMethodCall<AgentT> = OptionalArgsAgentMethodCall<AgentT> &
73
+ RequiredArgsAgentMethodCall<AgentT>;
74
+ type UntypedAgentMethodCall = <T = unknown>(
75
+ method: string,
76
+ args?: unknown[],
77
+ streamOptions?: StreamOptions
78
+ ) => Promise<T>;
79
+ type AgentStub<T> = {
80
+ [K in keyof AgentMethods<T>]: (
81
+ ...args: Parameters<AgentMethods<T>[K]>
82
+ ) => AgentPromiseReturnType<AgentMethods<T>, K>;
83
+ };
84
+ type UntypedAgentStub = Record<string, Method>;
85
+ /**
86
+ * React hook for connecting to an Agent
87
+ */
88
+ declare function useAgent<State = unknown>(
89
+ options: UseAgentOptions<State>
90
+ ): PartySocket & {
91
+ agent: string;
92
+ name: string;
93
+ setState: (state: State) => void;
94
+ call: UntypedAgentMethodCall;
95
+ stub: UntypedAgentStub;
96
+ };
97
+ declare function useAgent<
98
+ AgentT extends {
99
+ get state(): State;
100
+ },
101
+ State
102
+ >(
103
+ options: UseAgentOptions<State>
104
+ ): PartySocket & {
105
+ agent: string;
106
+ name: string;
107
+ setState: (state: State) => void;
108
+ call: AgentMethodCall<AgentT>;
109
+ stub: AgentStub<AgentT>;
110
+ };
111
+ //#endregion
112
+ export { UseAgentOptions, useAgent };
113
+ //# sourceMappingURL=react-B4e1rDid.d.ts.map
package/dist/react.d.ts CHANGED
@@ -1,126 +1,10 @@
1
- import { PartySocket } from "partysocket";
2
- import { usePartySocket } from "partysocket/react";
3
- import { MCPServersState, Agent } from "./index.js";
4
- import { StreamOptions } from "./client.js";
5
- import { Method, RPCMethod } from "./serializable.js";
6
- import "cloudflare:workers";
7
- import "@modelcontextprotocol/sdk/client/index.js";
8
- import "@modelcontextprotocol/sdk/types.js";
9
- import "partyserver";
10
- import "./client-DNEb-lf3.js";
11
- import "zod";
12
- import "@modelcontextprotocol/sdk/shared/protocol.js";
13
- import "ai";
14
- import "@modelcontextprotocol/sdk/client/sse.js";
15
- import "@modelcontextprotocol/sdk/client/streamableHttp.js";
16
- import "./mcp/do-oauth-client-provider.js";
17
- import "@modelcontextprotocol/sdk/client/auth.js";
18
- import "@modelcontextprotocol/sdk/shared/auth.js";
19
- import "./observability/index.js";
20
- import "./ai-types.js";
21
-
22
- type QueryObject = Record<string, string | null>;
23
- /**
24
- * Options for the useAgent hook
25
- * @template State Type of the Agent's state
26
- */
27
- type UseAgentOptions<State = unknown> = Omit<
28
- Parameters<typeof usePartySocket>[0],
29
- "party" | "room" | "query"
30
- > & {
31
- /** Name of the agent to connect to */
32
- agent: string;
33
- /** Name of the specific Agent instance */
34
- name?: string;
35
- /** Query parameters - can be static object or async function */
36
- query?: QueryObject | (() => Promise<QueryObject>);
37
- /** Dependencies for async query caching */
38
- queryDeps?: unknown[];
39
- /** Cache TTL in milliseconds for auth tokens/time-sensitive data */
40
- cacheTtl?: number;
41
- /** Called when the Agent's state is updated */
42
- onStateUpdate?: (state: State, source: "server" | "client") => void;
43
- /** Called when MCP server state is updated */
44
- onMcpUpdate?: (mcpServers: MCPServersState) => void;
45
- };
46
- type AllOptional<T> = T extends [infer A, ...infer R]
47
- ? undefined extends A
48
- ? AllOptional<R>
49
- : false
50
- : true;
51
- type RPCMethods<T> = {
52
- [K in keyof T as T[K] extends RPCMethod<T[K]> ? K : never]: RPCMethod<T[K]>;
53
- };
54
- type OptionalParametersMethod<T extends RPCMethod> =
55
- AllOptional<Parameters<T>> extends true ? T : never;
56
- type AgentMethods<T> = Omit<RPCMethods<T>, keyof Agent<any, any>>;
57
- type OptionalAgentMethods<T> = {
58
- [K in keyof AgentMethods<T> as AgentMethods<T>[K] extends OptionalParametersMethod<
59
- AgentMethods<T>[K]
60
- >
61
- ? K
62
- : never]: OptionalParametersMethod<AgentMethods<T>[K]>;
63
- };
64
- type RequiredAgentMethods<T> = Omit<
65
- AgentMethods<T>,
66
- keyof OptionalAgentMethods<T>
67
- >;
68
- type AgentPromiseReturnType<T, K extends keyof AgentMethods<T>> =
69
- ReturnType<AgentMethods<T>[K]> extends Promise<any>
70
- ? ReturnType<AgentMethods<T>[K]>
71
- : Promise<ReturnType<AgentMethods<T>[K]>>;
72
- type OptionalArgsAgentMethodCall<AgentT> = <
73
- K extends keyof OptionalAgentMethods<AgentT>
74
- >(
75
- method: K,
76
- args?: Parameters<OptionalAgentMethods<AgentT>[K]>,
77
- streamOptions?: StreamOptions
78
- ) => AgentPromiseReturnType<AgentT, K>;
79
- type RequiredArgsAgentMethodCall<AgentT> = <
80
- K extends keyof RequiredAgentMethods<AgentT>
81
- >(
82
- method: K,
83
- args: Parameters<RequiredAgentMethods<AgentT>[K]>,
84
- streamOptions?: StreamOptions
85
- ) => AgentPromiseReturnType<AgentT, K>;
86
- type AgentMethodCall<AgentT> = OptionalArgsAgentMethodCall<AgentT> &
87
- RequiredArgsAgentMethodCall<AgentT>;
88
- type UntypedAgentMethodCall = <T = unknown>(
89
- method: string,
90
- args?: unknown[],
91
- streamOptions?: StreamOptions
92
- ) => Promise<T>;
93
- type AgentStub<T> = {
94
- [K in keyof AgentMethods<T>]: (
95
- ...args: Parameters<AgentMethods<T>[K]>
96
- ) => AgentPromiseReturnType<AgentMethods<T>, K>;
97
- };
98
- type UntypedAgentStub = Record<string, Method>;
99
- /**
100
- * React hook for connecting to an Agent
101
- */
102
- declare function useAgent<State = unknown>(
103
- options: UseAgentOptions<State>
104
- ): PartySocket & {
105
- agent: string;
106
- name: string;
107
- setState: (state: State) => void;
108
- call: UntypedAgentMethodCall;
109
- stub: UntypedAgentStub;
110
- };
111
- declare function useAgent<
112
- AgentT extends {
113
- get state(): State;
114
- },
115
- State
116
- >(
117
- options: UseAgentOptions<State>
118
- ): PartySocket & {
119
- agent: string;
120
- name: string;
121
- setState: (state: State) => void;
122
- call: AgentMethodCall<AgentT>;
123
- stub: AgentStub<AgentT>;
124
- };
125
-
126
- export { type UseAgentOptions, useAgent };
1
+ import "./client-C-nwz-3N.js";
2
+ import "./mcp-BEwaCsxO.js";
3
+ import "./do-oauth-client-provider-CCwGwnrA.js";
4
+ import "./index-W4JUkafc.js";
5
+ import "./ai-types-BWW4umHY.js";
6
+ import "./index-CkQU40oY.js";
7
+ import "./serializable-gtr9YMhp.js";
8
+ import "./client-CmMi85Sj.js";
9
+ import { UseAgentOptions, useAgent } from "./react-B4e1rDid.js";
10
+ export { UseAgentOptions, useAgent };