agents 0.5.1 → 0.7.0
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/dist/agent-DnmmRjyv.d.ts +231 -0
- package/dist/{client-connection-CGMuV62J.js → client-connection-D3Wcd6Q6.js} +154 -23
- package/dist/client-connection-D3Wcd6Q6.js.map +1 -0
- package/dist/{client-storage-D633wI1S.d.ts → client-storage-tusTuoSF.d.ts} +262 -13
- package/dist/experimental/forever.d.ts +7 -18
- package/dist/experimental/forever.js +4 -38
- package/dist/experimental/forever.js.map +1 -1
- package/dist/experimental/memory/session/index.d.ts +251 -0
- package/dist/experimental/memory/session/index.js +385 -0
- package/dist/experimental/memory/session/index.js.map +1 -0
- package/dist/index.d.ts +84 -22
- package/dist/index.js +324 -250
- package/dist/index.js.map +1 -1
- package/dist/mcp/client.d.ts +51 -7
- package/dist/mcp/client.js +157 -32
- package/dist/mcp/client.js.map +1 -1
- package/dist/mcp/do-oauth-client-provider.js +1 -1
- package/dist/mcp/do-oauth-client-provider.js.map +1 -1
- package/dist/mcp/index.d.ts +27 -165
- package/dist/mcp/index.js +50 -10
- package/dist/mcp/index.js.map +1 -1
- package/dist/observability/index.d.ts +72 -6
- package/dist/observability/index.js +61 -16
- package/dist/observability/index.js.map +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/workflows.d.ts +15 -1
- package/dist/workflows.js +36 -3
- package/dist/workflows.js.map +1 -1
- package/package.json +16 -11
- package/dist/agent-B4_kEsdK.d.ts +0 -60
- package/dist/client-connection-CGMuV62J.js.map +0 -1
- package/dist/mcp-DA0kDE7K.d.ts +0 -61
package/dist/index.d.ts
CHANGED
|
@@ -5,14 +5,15 @@ import {
|
|
|
5
5
|
import { EmailResolver, createHeaderBasedEmailResolver } from "./email.js";
|
|
6
6
|
import { RetryOptions } from "./retries.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "./client-storage-
|
|
8
|
+
r as MCPConnectionState,
|
|
9
|
+
w as TransportType
|
|
10
|
+
} from "./client-storage-tusTuoSF.js";
|
|
11
11
|
import {
|
|
12
12
|
AgentMcpOAuthProvider,
|
|
13
13
|
AgentsOAuthProvider,
|
|
14
14
|
DurableObjectOAuthClientProvider
|
|
15
15
|
} from "./mcp/do-oauth-client-provider.js";
|
|
16
|
+
import { McpAgent } from "./mcp/index.js";
|
|
16
17
|
import { MCPClientManager } from "./mcp/client.js";
|
|
17
18
|
import {
|
|
18
19
|
RunWorkflowOptions,
|
|
@@ -204,6 +205,12 @@ type AddMcpServerOptions = {
|
|
|
204
205
|
} /** Retry options for connection and reconnection attempts */;
|
|
205
206
|
retry?: RetryOptions;
|
|
206
207
|
};
|
|
208
|
+
/**
|
|
209
|
+
* Options for adding an MCP server via RPC (Durable Object binding)
|
|
210
|
+
*/
|
|
211
|
+
type AddRpcMcpServerOptions = {
|
|
212
|
+
/** Props to pass to the McpAgent instance */ props?: Record<string, unknown>;
|
|
213
|
+
};
|
|
207
214
|
/**
|
|
208
215
|
* Default options for Agent configuration.
|
|
209
216
|
* Child classes can override specific options without spreading.
|
|
@@ -314,6 +321,11 @@ declare class Agent<
|
|
|
314
321
|
* The observability implementation to use for the Agent
|
|
315
322
|
*/
|
|
316
323
|
observability?: Observability;
|
|
324
|
+
/**
|
|
325
|
+
* Emit an observability event with auto-generated timestamp.
|
|
326
|
+
* @internal
|
|
327
|
+
*/
|
|
328
|
+
private _emit;
|
|
317
329
|
/**
|
|
318
330
|
* Execute SQL queries against the Agent's database
|
|
319
331
|
* @template T Type of the returned rows
|
|
@@ -625,6 +637,53 @@ declare class Agent<
|
|
|
625
637
|
* @returns true if the task was cancelled, false if the task was not found
|
|
626
638
|
*/
|
|
627
639
|
cancelSchedule(id: string): Promise<boolean>;
|
|
640
|
+
/**
|
|
641
|
+
* Keep the Durable Object alive via alarm heartbeats.
|
|
642
|
+
* Returns a disposer function that stops the heartbeat when called.
|
|
643
|
+
*
|
|
644
|
+
* Use this when you have long-running work and need to prevent the
|
|
645
|
+
* DO from going idle (eviction after ~70-140s of inactivity).
|
|
646
|
+
* The heartbeat fires every 30 seconds via the scheduling system.
|
|
647
|
+
*
|
|
648
|
+
* @experimental This API may change between releases.
|
|
649
|
+
*
|
|
650
|
+
* @example
|
|
651
|
+
* ```ts
|
|
652
|
+
* const dispose = await this.keepAlive();
|
|
653
|
+
* try {
|
|
654
|
+
* // ... long-running work ...
|
|
655
|
+
* } finally {
|
|
656
|
+
* dispose();
|
|
657
|
+
* }
|
|
658
|
+
* ```
|
|
659
|
+
*/
|
|
660
|
+
keepAlive(): Promise<() => void>;
|
|
661
|
+
/**
|
|
662
|
+
* Run an async function while keeping the Durable Object alive.
|
|
663
|
+
* The heartbeat is automatically stopped when the function completes
|
|
664
|
+
* (whether it succeeds or throws).
|
|
665
|
+
*
|
|
666
|
+
* This is the recommended way to use keepAlive — it guarantees cleanup
|
|
667
|
+
* so you cannot forget to dispose the heartbeat.
|
|
668
|
+
*
|
|
669
|
+
* @experimental This API may change between releases.
|
|
670
|
+
*
|
|
671
|
+
* @example
|
|
672
|
+
* ```ts
|
|
673
|
+
* const result = await this.keepAliveWhile(async () => {
|
|
674
|
+
* const data = await longRunningComputation();
|
|
675
|
+
* return data;
|
|
676
|
+
* });
|
|
677
|
+
* ```
|
|
678
|
+
*/
|
|
679
|
+
keepAliveWhile<T>(fn: () => Promise<T>): Promise<T>;
|
|
680
|
+
/**
|
|
681
|
+
* Internal no-op callback invoked by the keepAlive heartbeat schedule.
|
|
682
|
+
* Its only purpose is to keep the DO alive — the alarm machinery
|
|
683
|
+
* handles the rest.
|
|
684
|
+
* @internal
|
|
685
|
+
*/
|
|
686
|
+
_cf_keepAliveHeartbeat(): Promise<void>;
|
|
628
687
|
private _scheduleNextAlarm;
|
|
629
688
|
/**
|
|
630
689
|
* Method called when an alarm fires.
|
|
@@ -944,6 +1003,8 @@ declare class Agent<
|
|
|
944
1003
|
* Returns undefined if no match found - use options.agentBinding as fallback.
|
|
945
1004
|
*/
|
|
946
1005
|
private _findAgentBindingName;
|
|
1006
|
+
private _findBindingNameForNamespace;
|
|
1007
|
+
private _restoreRpcMcpServers;
|
|
947
1008
|
/**
|
|
948
1009
|
* Handle a callback from a workflow.
|
|
949
1010
|
* Called when the Agent receives a callback at /_workflow/callback.
|
|
@@ -1023,29 +1084,30 @@ declare class Agent<
|
|
|
1023
1084
|
state?: unknown
|
|
1024
1085
|
): void;
|
|
1025
1086
|
/**
|
|
1026
|
-
* Connect to a new MCP Server
|
|
1087
|
+
* Connect to a new MCP Server via RPC (Durable Object binding)
|
|
1027
1088
|
*
|
|
1028
|
-
*
|
|
1029
|
-
*
|
|
1030
|
-
* await this.addMcpServer("github", "https://mcp.github.com");
|
|
1089
|
+
* The binding name and props are persisted to storage so the connection
|
|
1090
|
+
* is automatically restored after Durable Object hibernation.
|
|
1031
1091
|
*
|
|
1032
1092
|
* @example
|
|
1033
|
-
*
|
|
1034
|
-
* await this.addMcpServer("
|
|
1035
|
-
|
|
1036
|
-
|
|
1093
|
+
* await this.addMcpServer("counter", env.MY_MCP);
|
|
1094
|
+
* await this.addMcpServer("counter", env.MY_MCP, { props: { userId: "123" } });
|
|
1095
|
+
*/
|
|
1096
|
+
addMcpServer<T extends McpAgent>(
|
|
1097
|
+
serverName: string,
|
|
1098
|
+
binding: DurableObjectNamespace<T>,
|
|
1099
|
+
options?: AddRpcMcpServerOptions
|
|
1100
|
+
): Promise<{
|
|
1101
|
+
id: string;
|
|
1102
|
+
state: typeof MCPConnectionState.READY;
|
|
1103
|
+
}>;
|
|
1104
|
+
/**
|
|
1105
|
+
* Connect to a new MCP Server via HTTP (SSE or Streamable HTTP)
|
|
1037
1106
|
*
|
|
1038
1107
|
* @example
|
|
1039
|
-
*
|
|
1040
|
-
* await this.addMcpServer("github",
|
|
1041
|
-
*
|
|
1042
|
-
* @param serverName Name of the MCP server
|
|
1043
|
-
* @param url MCP Server URL
|
|
1044
|
-
* @param callbackHostOrOptions Options object, or callback host string (legacy)
|
|
1045
|
-
* @param agentsPrefix agents routing prefix if not using `agents` (legacy)
|
|
1046
|
-
* @param options MCP client and transport options (legacy)
|
|
1047
|
-
* @returns Server id and state - either "authenticating" with authUrl, or "ready"
|
|
1048
|
-
* @throws If connection or discovery fails
|
|
1108
|
+
* await this.addMcpServer("github", "https://mcp.github.com");
|
|
1109
|
+
* await this.addMcpServer("github", "https://mcp.github.com", { transport: { type: "sse" } });
|
|
1110
|
+
* await this.addMcpServer("github", url, callbackHost, agentsPrefix, options); // legacy
|
|
1049
1111
|
*/
|
|
1050
1112
|
addMcpServer(
|
|
1051
1113
|
serverName: string,
|
|
@@ -1068,7 +1130,6 @@ declare class Agent<
|
|
|
1068
1130
|
| {
|
|
1069
1131
|
id: string;
|
|
1070
1132
|
state: typeof MCPConnectionState.READY;
|
|
1071
|
-
authUrl?: undefined;
|
|
1072
1133
|
}
|
|
1073
1134
|
>;
|
|
1074
1135
|
removeMcpServer(id: string): Promise<void>;
|
|
@@ -1223,6 +1284,7 @@ declare class StreamingResponse {
|
|
|
1223
1284
|
//#endregion
|
|
1224
1285
|
export {
|
|
1225
1286
|
AddMcpServerOptions,
|
|
1287
|
+
AddRpcMcpServerOptions,
|
|
1226
1288
|
Agent,
|
|
1227
1289
|
AgentContext,
|
|
1228
1290
|
type AgentMcpOAuthProvider,
|