agents 0.7.5 → 0.7.7
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/{client-CgXIwdcc.js → client-K8Z-u76l.js} +38 -12
- package/dist/client-K8Z-u76l.js.map +1 -0
- package/dist/client.js.map +1 -1
- package/dist/experimental/forever.d.ts +1 -1
- package/dist/experimental/forever.js +1 -1
- package/dist/experimental/forever.js.map +1 -1
- package/dist/experimental/memory/session/index.js.map +1 -1
- package/dist/experimental/workspace.d.ts +2 -2
- package/dist/experimental/workspace.js +6 -4
- package/dist/experimental/workspace.js.map +1 -1
- package/dist/{index-p1XLNvwQ.d.ts → index-DBW341gU.d.ts} +183 -62
- package/dist/index.d.ts +13 -9
- package/dist/index.js +299 -138
- package/dist/index.js.map +1 -1
- package/dist/mcp/client.d.ts +1 -1
- package/dist/mcp/client.js +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +59 -49
- package/dist/mcp/index.js.map +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/workflows.d.ts +1 -1
- package/dist/workflows.js +1 -1
- package/dist/workflows.js.map +1 -1
- package/package.json +17 -15
- package/dist/client-CgXIwdcc.js.map +0 -1
- package/dist/experimental/sub-agent.d.ts +0 -205
- package/dist/experimental/sub-agent.js +0 -190
- package/dist/experimental/sub-agent.js.map +0 -1
|
@@ -268,6 +268,7 @@ declare abstract class McpAgent<
|
|
|
268
268
|
Props extends Record<string, unknown> = Record<string, unknown>
|
|
269
269
|
> extends Agent<Env, State, Props> {
|
|
270
270
|
private _transport?;
|
|
271
|
+
private _pendingElicitations;
|
|
271
272
|
props?: Props;
|
|
272
273
|
shouldSendProtocolMessages(
|
|
273
274
|
_connection: Connection$1,
|
|
@@ -326,9 +327,7 @@ declare abstract class McpAgent<
|
|
|
326
327
|
message: string;
|
|
327
328
|
requestedSchema: unknown;
|
|
328
329
|
}): Promise<ElicitResult>;
|
|
329
|
-
/**
|
|
330
|
-
private _waitForElicitationResponse;
|
|
331
|
-
/** Handle elicitation responses */
|
|
330
|
+
/** Handle elicitation responses via in-memory resolver */
|
|
332
331
|
private _handleElicitationResponse;
|
|
333
332
|
/**
|
|
334
333
|
* Handle an RPC message for MCP
|
|
@@ -708,7 +707,7 @@ declare class MCPClientConnection {
|
|
|
708
707
|
*/
|
|
709
708
|
getTransport(
|
|
710
709
|
transportType: BaseTransportType
|
|
711
|
-
):
|
|
710
|
+
): SSEClientTransport | StreamableHTTPClientTransport | RPCClientTransport;
|
|
712
711
|
private tryConnect;
|
|
713
712
|
private _capabilityErrorHandler;
|
|
714
713
|
}
|
|
@@ -1126,13 +1125,7 @@ declare class MCPClientManager {
|
|
|
1126
1125
|
lastModified?: string | undefined;
|
|
1127
1126
|
}
|
|
1128
1127
|
| undefined;
|
|
1129
|
-
_meta
|
|
1130
|
-
* We need to delay loading ai sdk, because putting it in module scope is
|
|
1131
|
-
* causing issues with startup time.
|
|
1132
|
-
* The only place it's used is in getAITools, which only matters after
|
|
1133
|
-
* .connect() is called on at least one server.
|
|
1134
|
-
* So it's safe to delay loading it until .connect() is called.
|
|
1135
|
-
*/?: Record<string, unknown> | undefined;
|
|
1128
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1136
1129
|
}
|
|
1137
1130
|
| {
|
|
1138
1131
|
type: "resource";
|
|
@@ -1444,6 +1437,38 @@ declare class SqlError extends Error {
|
|
|
1444
1437
|
readonly query: string;
|
|
1445
1438
|
constructor(query: string, cause: unknown);
|
|
1446
1439
|
}
|
|
1440
|
+
/**
|
|
1441
|
+
* Constructor type for a sub-agent class.
|
|
1442
|
+
* Used by {@link Agent.subAgent} to reference the child class
|
|
1443
|
+
* via `ctx.exports`.
|
|
1444
|
+
*
|
|
1445
|
+
* The class name (`cls.name`) must match the export name in the
|
|
1446
|
+
* worker entry point — re-exports under a different name
|
|
1447
|
+
* (e.g. `export { Foo as Bar }`) are not supported.
|
|
1448
|
+
*/
|
|
1449
|
+
type SubAgentClass<T extends Agent = Agent> = {
|
|
1450
|
+
new (ctx: DurableObjectState, env: never): T;
|
|
1451
|
+
};
|
|
1452
|
+
/**
|
|
1453
|
+
* Wraps `T` in a `Promise` unless it already is one.
|
|
1454
|
+
*/
|
|
1455
|
+
type Promisify<T> = T extends Promise<unknown> ? T : Promise<T>;
|
|
1456
|
+
/**
|
|
1457
|
+
* A typed RPC stub for a sub-agent. Exposes all public instance methods
|
|
1458
|
+
* as callable RPC methods with Promise-wrapped return types.
|
|
1459
|
+
*
|
|
1460
|
+
* Methods inherited from `Agent` / `Server` / `DurableObject` internals
|
|
1461
|
+
* are excluded — only user-defined methods on the subclass are exposed.
|
|
1462
|
+
*/
|
|
1463
|
+
type SubAgentStub<T extends Agent> = {
|
|
1464
|
+
[K in keyof T as K extends keyof Agent
|
|
1465
|
+
? never
|
|
1466
|
+
: T[K] extends (...args: never[]) => unknown
|
|
1467
|
+
? K
|
|
1468
|
+
: never]: T[K] extends (...args: infer A) => infer R
|
|
1469
|
+
? (...args: A) => Promisify<R>
|
|
1470
|
+
: never;
|
|
1471
|
+
};
|
|
1447
1472
|
/**
|
|
1448
1473
|
* Decorator that marks a method as callable by clients
|
|
1449
1474
|
* @param metadata Optional metadata about the callable method
|
|
@@ -1638,6 +1663,8 @@ declare class Agent<
|
|
|
1638
1663
|
* - "none" → neither hook is overridden, skip entirely
|
|
1639
1664
|
*/
|
|
1640
1665
|
private _persistenceHookMode;
|
|
1666
|
+
/** True when this agent runs as a facet (sub-agent) inside a parent. */
|
|
1667
|
+
private _isFacet;
|
|
1641
1668
|
private _ParentClass;
|
|
1642
1669
|
readonly mcp: MCPClientManager;
|
|
1643
1670
|
/**
|
|
@@ -1688,6 +1715,16 @@ declare class Agent<
|
|
|
1688
1715
|
strings: TemplateStringsArray,
|
|
1689
1716
|
...values: (string | number | boolean | null)[]
|
|
1690
1717
|
): T[];
|
|
1718
|
+
/**
|
|
1719
|
+
* Create all internal tables and run migrations if needed.
|
|
1720
|
+
* Called by the constructor on every wake. Idempotent — skips DDL when
|
|
1721
|
+
* the stored schema version matches CURRENT_SCHEMA_VERSION.
|
|
1722
|
+
*
|
|
1723
|
+
* Protected so that test agents can re-run the real migration path
|
|
1724
|
+
* after manipulating DB state (since ctx.abort() is unavailable in
|
|
1725
|
+
* local dev and the constructor only runs once per DO instance).
|
|
1726
|
+
*/
|
|
1727
|
+
protected _ensureSchema(): void;
|
|
1691
1728
|
constructor(ctx: AgentContext, env: Env);
|
|
1692
1729
|
/**
|
|
1693
1730
|
* Check for workflows referencing unknown bindings and warn with migration suggestion.
|
|
@@ -1736,6 +1773,34 @@ declare class Agent<
|
|
|
1736
1773
|
* @returns True if the connection is readonly
|
|
1737
1774
|
*/
|
|
1738
1775
|
isConnectionReadonly(connection: Connection): boolean;
|
|
1776
|
+
/**
|
|
1777
|
+
* ⚠️ INTERNAL — DO NOT USE IN APPLICATION CODE. ⚠️
|
|
1778
|
+
*
|
|
1779
|
+
* Read an internal `_cf_`-prefixed flag from the raw connection state,
|
|
1780
|
+
* bypassing the user-facing state wrapper that strips internal keys.
|
|
1781
|
+
*
|
|
1782
|
+
* This exists for framework mixins (e.g. voice) that need to persist
|
|
1783
|
+
* flags in the connection attachment across hibernation. Application
|
|
1784
|
+
* code should use `connection.state` and `connection.setState()` instead.
|
|
1785
|
+
*
|
|
1786
|
+
* @internal
|
|
1787
|
+
*/
|
|
1788
|
+
_unsafe_getConnectionFlag(connection: Connection, key: string): unknown;
|
|
1789
|
+
/**
|
|
1790
|
+
* ⚠️ INTERNAL — DO NOT USE IN APPLICATION CODE. ⚠️
|
|
1791
|
+
*
|
|
1792
|
+
* Write an internal `_cf_`-prefixed flag to the raw connection state,
|
|
1793
|
+
* bypassing the user-facing state wrapper. The key must be registered
|
|
1794
|
+
* in `CF_INTERNAL_KEYS` so it is preserved across user `setState` calls
|
|
1795
|
+
* and hidden from `connection.state`.
|
|
1796
|
+
*
|
|
1797
|
+
* @internal
|
|
1798
|
+
*/
|
|
1799
|
+
_unsafe_setConnectionFlag(
|
|
1800
|
+
connection: Connection,
|
|
1801
|
+
key: string,
|
|
1802
|
+
value: unknown
|
|
1803
|
+
): void;
|
|
1739
1804
|
/**
|
|
1740
1805
|
* Override this method to determine if a connection should be readonly on connect
|
|
1741
1806
|
* @param _connection The connection that is being established
|
|
@@ -2066,6 +2131,60 @@ declare class Agent<
|
|
|
2066
2131
|
* See {@link https://developers.cloudflare.com/agents/api-reference/schedule-tasks/}
|
|
2067
2132
|
*/
|
|
2068
2133
|
alarm(): Promise<void>;
|
|
2134
|
+
/**
|
|
2135
|
+
* Marks this agent as running inside a facet (sub-agent). Once set,
|
|
2136
|
+
* scheduling methods throw a clear error instead of crashing on
|
|
2137
|
+
* `setAlarm()` (which is not supported in facets).
|
|
2138
|
+
* @internal
|
|
2139
|
+
*/
|
|
2140
|
+
_cf_markAsFacet(): Promise<void>;
|
|
2141
|
+
/**
|
|
2142
|
+
* Get or create a named sub-agent — a child Durable Object (facet)
|
|
2143
|
+
* with its own isolated SQLite storage running on the same machine.
|
|
2144
|
+
*
|
|
2145
|
+
* The child class must extend `Agent` and be exported from the worker
|
|
2146
|
+
* entry point. The first call for a given name triggers the child's
|
|
2147
|
+
* `onStart()`. Subsequent calls return the existing instance.
|
|
2148
|
+
*
|
|
2149
|
+
* @experimental Requires the `"experimental"` compatibility flag.
|
|
2150
|
+
*
|
|
2151
|
+
* @param cls The Agent subclass (must be exported from the worker)
|
|
2152
|
+
* @param name Unique name for this child instance
|
|
2153
|
+
* @returns A typed RPC stub for calling methods on the child
|
|
2154
|
+
*
|
|
2155
|
+
* @example
|
|
2156
|
+
* ```typescript
|
|
2157
|
+
* const searcher = await this.subAgent(SearchAgent, "main-search");
|
|
2158
|
+
* const results = await searcher.search("cloudflare agents");
|
|
2159
|
+
* ```
|
|
2160
|
+
*/
|
|
2161
|
+
subAgent<T extends Agent>(
|
|
2162
|
+
cls: SubAgentClass<T>,
|
|
2163
|
+
name: string
|
|
2164
|
+
): Promise<SubAgentStub<T>>;
|
|
2165
|
+
/**
|
|
2166
|
+
* Forcefully abort a running sub-agent. The child stops executing
|
|
2167
|
+
* immediately and will be restarted on next {@link subAgent} call.
|
|
2168
|
+
* Pending RPC calls receive the reason as an error.
|
|
2169
|
+
* Transitively aborts the child's own children.
|
|
2170
|
+
*
|
|
2171
|
+
* @experimental Requires the `"experimental"` compatibility flag.
|
|
2172
|
+
*
|
|
2173
|
+
* @param cls The Agent subclass used when creating the child
|
|
2174
|
+
* @param name Name of the child to abort
|
|
2175
|
+
* @param reason Error thrown to pending/future RPC callers
|
|
2176
|
+
*/
|
|
2177
|
+
abortSubAgent(cls: SubAgentClass, name: string, reason?: unknown): void;
|
|
2178
|
+
/**
|
|
2179
|
+
* Delete a sub-agent: abort it if running, then permanently wipe its
|
|
2180
|
+
* storage. Transitively deletes the child's own children.
|
|
2181
|
+
*
|
|
2182
|
+
* @experimental Requires the `"experimental"` compatibility flag.
|
|
2183
|
+
*
|
|
2184
|
+
* @param cls The Agent subclass used when creating the child
|
|
2185
|
+
* @param name Name of the child to delete
|
|
2186
|
+
*/
|
|
2187
|
+
deleteSubAgent(cls: SubAgentClass, name: string): void;
|
|
2069
2188
|
/**
|
|
2070
2189
|
* Destroy the Agent, removing all state and scheduled tasks
|
|
2071
2190
|
*/
|
|
@@ -2394,9 +2513,9 @@ declare class Agent<
|
|
|
2394
2513
|
* @param progress - Typed progress data (default: DefaultProgress)
|
|
2395
2514
|
*/
|
|
2396
2515
|
onWorkflowProgress(
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2516
|
+
workflowName: string,
|
|
2517
|
+
workflowId: string,
|
|
2518
|
+
progress: unknown
|
|
2400
2519
|
): Promise<void>;
|
|
2401
2520
|
/**
|
|
2402
2521
|
* Called when a workflow completes successfully.
|
|
@@ -2407,9 +2526,9 @@ declare class Agent<
|
|
|
2407
2526
|
* @param result - Optional result data
|
|
2408
2527
|
*/
|
|
2409
2528
|
onWorkflowComplete(
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2529
|
+
workflowName: string,
|
|
2530
|
+
workflowId: string,
|
|
2531
|
+
result?: unknown
|
|
2413
2532
|
): Promise<void>;
|
|
2414
2533
|
/**
|
|
2415
2534
|
* Called when a workflow encounters an error.
|
|
@@ -2420,9 +2539,9 @@ declare class Agent<
|
|
|
2420
2539
|
* @param error - Error message
|
|
2421
2540
|
*/
|
|
2422
2541
|
onWorkflowError(
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2542
|
+
workflowName: string,
|
|
2543
|
+
workflowId: string,
|
|
2544
|
+
error: string
|
|
2426
2545
|
): Promise<void>;
|
|
2427
2546
|
/**
|
|
2428
2547
|
* Called when a workflow sends a custom event.
|
|
@@ -2433,9 +2552,9 @@ declare class Agent<
|
|
|
2433
2552
|
* @param event - Custom event payload
|
|
2434
2553
|
*/
|
|
2435
2554
|
onWorkflowEvent(
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2555
|
+
workflowName: string,
|
|
2556
|
+
workflowId: string,
|
|
2557
|
+
event: unknown
|
|
2439
2558
|
): Promise<void>;
|
|
2440
2559
|
/**
|
|
2441
2560
|
* Handle a workflow callback via RPC.
|
|
@@ -2655,65 +2774,67 @@ declare class StreamingResponse {
|
|
|
2655
2774
|
}
|
|
2656
2775
|
//#endregion
|
|
2657
2776
|
export {
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2777
|
+
experimental_createMcpHandler as $,
|
|
2778
|
+
routeAgentRequest as A,
|
|
2779
|
+
RegisterServerOptions as B,
|
|
2780
|
+
SubAgentClass as C,
|
|
2781
|
+
getAgentByName as D,
|
|
2782
|
+
callable as E,
|
|
2783
|
+
MCPClientOAuthResult as F,
|
|
2784
|
+
RPCServerTransportOptions as G,
|
|
2785
|
+
RPCClientTransport as H,
|
|
2786
|
+
MCPConnectionResult as I,
|
|
2787
|
+
ElicitRequestSchema$1 as J,
|
|
2788
|
+
RPC_DO_PREFIX as K,
|
|
2789
|
+
MCPDiscoverResult as L,
|
|
2790
|
+
MCPClientManager as M,
|
|
2791
|
+
MCPClientManagerOptions as N,
|
|
2792
|
+
getCurrentAgent as O,
|
|
2793
|
+
MCPClientOAuthCallbackConfig as P,
|
|
2794
|
+
createMcpHandler as Q,
|
|
2795
|
+
MCPOAuthCallbackResult as R,
|
|
2677
2796
|
StreamingResponse as S,
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2797
|
+
WSMessage as T,
|
|
2798
|
+
RPCClientTransportOptions as U,
|
|
2799
|
+
getNamespacedData as V,
|
|
2800
|
+
RPCServerTransport as W,
|
|
2801
|
+
McpAgent as X,
|
|
2802
|
+
ElicitResult$1 as Y,
|
|
2803
|
+
CreateMcpHandlerOptions as Z,
|
|
2685
2804
|
RPCRequest as _,
|
|
2686
2805
|
AgentNamespace as a,
|
|
2687
|
-
|
|
2806
|
+
SSEEdgeClientTransport as at,
|
|
2688
2807
|
SqlError as b,
|
|
2689
2808
|
CallableMetadata as c,
|
|
2809
|
+
TransportType as ct,
|
|
2690
2810
|
DEFAULT_AGENT_STATIC_OPTIONS as d,
|
|
2691
|
-
|
|
2811
|
+
McpAuthContext as et,
|
|
2692
2812
|
EmailRoutingOptions as f,
|
|
2693
2813
|
QueueItem as g,
|
|
2694
2814
|
MCPServersState as h,
|
|
2695
2815
|
AgentContext as i,
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2816
|
+
WorkerTransportOptions as it,
|
|
2817
|
+
unstable_callable as j,
|
|
2818
|
+
routeAgentEmail as k,
|
|
2699
2819
|
Connection$1 as l,
|
|
2700
2820
|
MCPServerMessage as m,
|
|
2701
2821
|
AddRpcMcpServerOptions as n,
|
|
2702
|
-
|
|
2822
|
+
TransportState as nt,
|
|
2703
2823
|
AgentOptions as o,
|
|
2704
|
-
|
|
2824
|
+
StreamableHTTPEdgeClientTransport as ot,
|
|
2705
2825
|
MCPServer as p,
|
|
2706
|
-
|
|
2826
|
+
ElicitRequest$1 as q,
|
|
2707
2827
|
Agent as r,
|
|
2708
|
-
|
|
2828
|
+
WorkerTransport as rt,
|
|
2709
2829
|
AgentStaticOptions as s,
|
|
2830
|
+
McpClientOptions as st,
|
|
2710
2831
|
AddMcpServerOptions as t,
|
|
2711
|
-
|
|
2832
|
+
getMcpAuthContext as tt,
|
|
2712
2833
|
ConnectionContext$1 as u,
|
|
2713
2834
|
RPCResponse as v,
|
|
2714
|
-
|
|
2835
|
+
SubAgentStub as w,
|
|
2715
2836
|
StateUpdateMessage as x,
|
|
2716
2837
|
Schedule as y,
|
|
2717
|
-
|
|
2838
|
+
MCPServerOptions as z
|
|
2718
2839
|
};
|
|
2719
|
-
//# sourceMappingURL=index-
|
|
2840
|
+
//# sourceMappingURL=index-DBW341gU.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -2,37 +2,39 @@ import { r as __DO_NOT_USE_WILL_BREAK__agentContext } from "./internal_context-D
|
|
|
2
2
|
import { l as createHeaderBasedEmailResolver } from "./email-U_MG7UET.js";
|
|
3
3
|
import { t as RetryOptions } from "./retries-DXMQGhG3.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
A as routeAgentRequest,
|
|
6
|
+
C as SubAgentClass,
|
|
7
|
+
D as getAgentByName,
|
|
8
|
+
E as callable,
|
|
9
|
+
O as getCurrentAgent,
|
|
9
10
|
S as StreamingResponse,
|
|
10
|
-
T as
|
|
11
|
+
T as WSMessage,
|
|
11
12
|
_ as RPCRequest,
|
|
12
13
|
a as AgentNamespace,
|
|
13
14
|
b as SqlError,
|
|
14
15
|
c as CallableMetadata,
|
|
16
|
+
ct as TransportType,
|
|
15
17
|
d as DEFAULT_AGENT_STATIC_OPTIONS,
|
|
16
18
|
f as EmailRoutingOptions,
|
|
17
19
|
g as QueueItem,
|
|
18
20
|
h as MCPServersState,
|
|
19
21
|
i as AgentContext,
|
|
20
|
-
|
|
22
|
+
j as unstable_callable,
|
|
23
|
+
k as routeAgentEmail,
|
|
21
24
|
l as Connection,
|
|
22
25
|
m as MCPServerMessage,
|
|
23
26
|
n as AddRpcMcpServerOptions,
|
|
24
27
|
o as AgentOptions,
|
|
25
|
-
ot as TransportType,
|
|
26
28
|
p as MCPServer,
|
|
27
29
|
r as Agent,
|
|
28
30
|
s as AgentStaticOptions,
|
|
29
31
|
t as AddMcpServerOptions,
|
|
30
32
|
u as ConnectionContext,
|
|
31
33
|
v as RPCResponse,
|
|
32
|
-
w as
|
|
34
|
+
w as SubAgentStub,
|
|
33
35
|
x as StateUpdateMessage,
|
|
34
36
|
y as Schedule
|
|
35
|
-
} from "./index-
|
|
37
|
+
} from "./index-DBW341gU.js";
|
|
36
38
|
import {
|
|
37
39
|
n as AgentsOAuthProvider,
|
|
38
40
|
r as DurableObjectOAuthClientProvider,
|
|
@@ -65,6 +67,8 @@ export {
|
|
|
65
67
|
SqlError,
|
|
66
68
|
StateUpdateMessage,
|
|
67
69
|
StreamingResponse,
|
|
70
|
+
SubAgentClass,
|
|
71
|
+
SubAgentStub,
|
|
68
72
|
TransportType,
|
|
69
73
|
WSMessage,
|
|
70
74
|
__DO_NOT_USE_WILL_BREAK__agentContext,
|