agents 0.0.0-dfa677f → 0.0.0-e19fea6
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 +57 -7
- package/dist/ai-chat-agent.js +580 -95
- 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 +287 -120
- package/dist/ai-react.js.map +1 -1
- package/dist/ai-types.d.ts +41 -18
- 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-254F4GDT.js +1343 -0
- package/dist/chunk-254F4GDT.js.map +1 -0
- package/dist/chunk-3OT2NNEW.js +941 -0
- package/dist/chunk-3OT2NNEW.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-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-Z44WASMA.js +114 -0
- package/dist/chunk-Z44WASMA.js.map +1 -0
- package/dist/client-DVoPb3-C.d.ts +5120 -0
- package/dist/client.d.ts +16 -2
- package/dist/client.js +8 -133
- package/dist/client.js.map +1 -1
- package/dist/codemode/ai.d.ts +25 -0
- package/dist/codemode/ai.js +5112 -0
- package/dist/codemode/ai.js.map +1 -0
- package/dist/index.d.ts +275 -27
- package/dist/index.js +18 -8
- package/dist/mcp/client.d.ts +12 -0
- package/dist/mcp/client.js +10 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/do-oauth-client-provider.d.ts +42 -0
- package/dist/mcp/do-oauth-client-provider.js +8 -0
- package/dist/mcp/do-oauth-client-provider.js.map +1 -0
- package/dist/mcp/index.d.ts +79 -0
- package/dist/mcp/index.js +1099 -0
- package/dist/mcp/index.js.map +1 -0
- 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 +153 -34
- 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 +106 -50
- package/src/index.ts +1268 -162
- package/dist/chunk-HMLY7DHA.js +0 -16
- package/dist/chunk-KRBQHBPA.js +0 -599
- package/dist/chunk-KRBQHBPA.js.map +0 -1
- package/dist/mcp.d.ts +0 -58
- package/dist/mcp.js +0 -945
- package/dist/mcp.js.map +0 -1
- /package/dist/{chunk-HMLY7DHA.js.map → ai-chat-v5-migration.js.map} +0 -0
package/dist/client.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PartySocketOptions,
|
|
3
3
|
PartyFetchOptions,
|
|
4
|
-
PartySocket
|
|
4
|
+
PartySocket
|
|
5
5
|
} from "partysocket";
|
|
6
|
+
import { SerializableReturnValue, SerializableValue } from "./serializable.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Options for creating an AgentClient
|
|
@@ -38,17 +39,24 @@ type AgentClientFetchOptions = Omit<PartyFetchOptions, "party" | "room"> & {
|
|
|
38
39
|
/** Name of the specific Agent instance */
|
|
39
40
|
name?: string;
|
|
40
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Convert a camelCase string to a kebab-case string
|
|
44
|
+
* @param str The string to convert
|
|
45
|
+
* @returns The kebab-case string
|
|
46
|
+
*/
|
|
47
|
+
declare function camelCaseToKebabCase(str: string): string;
|
|
41
48
|
/**
|
|
42
49
|
* WebSocket client for connecting to an Agent
|
|
43
50
|
*/
|
|
44
51
|
declare class AgentClient<State = unknown> extends PartySocket {
|
|
45
|
-
#private;
|
|
46
52
|
/**
|
|
47
53
|
* @deprecated Use agentFetch instead
|
|
48
54
|
*/
|
|
49
55
|
static fetch(_opts: PartyFetchOptions): Promise<Response>;
|
|
50
56
|
agent: string;
|
|
51
57
|
name: string;
|
|
58
|
+
private options;
|
|
59
|
+
private _pendingCalls;
|
|
52
60
|
constructor(options: AgentClientOptions<State>);
|
|
53
61
|
setState(state: State): void;
|
|
54
62
|
/**
|
|
@@ -58,6 +66,11 @@ declare class AgentClient<State = unknown> extends PartySocket {
|
|
|
58
66
|
* @param streamOptions Options for handling streaming responses
|
|
59
67
|
* @returns Promise that resolves with the method's return value
|
|
60
68
|
*/
|
|
69
|
+
call<T extends SerializableReturnValue>(
|
|
70
|
+
method: string,
|
|
71
|
+
args?: SerializableValue[],
|
|
72
|
+
streamOptions?: StreamOptions
|
|
73
|
+
): Promise<T>;
|
|
61
74
|
call<T = unknown>(
|
|
62
75
|
method: string,
|
|
63
76
|
args?: unknown[],
|
|
@@ -81,4 +94,5 @@ export {
|
|
|
81
94
|
type AgentClientOptions,
|
|
82
95
|
type StreamOptions,
|
|
83
96
|
agentFetch,
|
|
97
|
+
camelCaseToKebabCase
|
|
84
98
|
};
|
package/dist/client.js
CHANGED
|
@@ -1,138 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
PartySocket
|
|
10
|
-
} from "partysocket";
|
|
11
|
-
var _options, _pendingCalls;
|
|
12
|
-
var AgentClient = class extends PartySocket {
|
|
13
|
-
constructor(options) {
|
|
14
|
-
super({
|
|
15
|
-
prefix: "agents",
|
|
16
|
-
party: options.agent,
|
|
17
|
-
room: options.name || "default",
|
|
18
|
-
...options
|
|
19
|
-
});
|
|
20
|
-
__privateAdd(this, _options);
|
|
21
|
-
__privateAdd(this, _pendingCalls, /* @__PURE__ */ new Map());
|
|
22
|
-
this.agent = options.agent;
|
|
23
|
-
this.name = options.name || "default";
|
|
24
|
-
__privateSet(this, _options, options);
|
|
25
|
-
if (this.agent !== this.agent.toLowerCase()) {
|
|
26
|
-
console.warn(
|
|
27
|
-
`Agent name: ${this.agent} should probably be in lowercase. Received: ${this.agent}`
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
if (this.name !== this.name.toLowerCase()) {
|
|
31
|
-
console.warn(
|
|
32
|
-
`Agent instance name: ${this.name} should probably be in lowercase. Received: ${this.name}`
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
this.addEventListener("message", (event) => {
|
|
36
|
-
if (typeof event.data === "string") {
|
|
37
|
-
let parsedMessage;
|
|
38
|
-
try {
|
|
39
|
-
parsedMessage = JSON.parse(event.data);
|
|
40
|
-
} catch (error) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (parsedMessage.type === "cf_agent_state") {
|
|
44
|
-
__privateGet(this, _options).onStateUpdate?.(parsedMessage.state, "server");
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
if (parsedMessage.type === "rpc") {
|
|
48
|
-
const response = parsedMessage;
|
|
49
|
-
const pending = __privateGet(this, _pendingCalls).get(response.id);
|
|
50
|
-
if (!pending) return;
|
|
51
|
-
if (!response.success) {
|
|
52
|
-
pending.reject(new Error(response.error));
|
|
53
|
-
__privateGet(this, _pendingCalls).delete(response.id);
|
|
54
|
-
pending.stream?.onError?.(response.error);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if ("done" in response) {
|
|
58
|
-
if (response.done) {
|
|
59
|
-
pending.resolve(response.result);
|
|
60
|
-
__privateGet(this, _pendingCalls).delete(response.id);
|
|
61
|
-
pending.stream?.onDone?.(response.result);
|
|
62
|
-
} else {
|
|
63
|
-
pending.stream?.onChunk?.(response.result);
|
|
64
|
-
}
|
|
65
|
-
} else {
|
|
66
|
-
pending.resolve(response.result);
|
|
67
|
-
__privateGet(this, _pendingCalls).delete(response.id);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* @deprecated Use agentFetch instead
|
|
75
|
-
*/
|
|
76
|
-
static fetch(_opts) {
|
|
77
|
-
throw new Error(
|
|
78
|
-
"AgentClient.fetch is not implemented, use agentFetch instead"
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
setState(state) {
|
|
82
|
-
this.send(JSON.stringify({ type: "cf_agent_state", state }));
|
|
83
|
-
__privateGet(this, _options).onStateUpdate?.(state, "client");
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Call a method on the Agent
|
|
87
|
-
* @param method Name of the method to call
|
|
88
|
-
* @param args Arguments to pass to the method
|
|
89
|
-
* @param streamOptions Options for handling streaming responses
|
|
90
|
-
* @returns Promise that resolves with the method's return value
|
|
91
|
-
*/
|
|
92
|
-
async call(method, args = [], streamOptions) {
|
|
93
|
-
return new Promise((resolve, reject) => {
|
|
94
|
-
const id = Math.random().toString(36).slice(2);
|
|
95
|
-
__privateGet(this, _pendingCalls).set(id, {
|
|
96
|
-
resolve: (value) => resolve(value),
|
|
97
|
-
reject,
|
|
98
|
-
stream: streamOptions,
|
|
99
|
-
type: null
|
|
100
|
-
});
|
|
101
|
-
const request = {
|
|
102
|
-
type: "rpc",
|
|
103
|
-
id,
|
|
104
|
-
method,
|
|
105
|
-
args
|
|
106
|
-
};
|
|
107
|
-
this.send(JSON.stringify(request));
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
_options = new WeakMap();
|
|
112
|
-
_pendingCalls = new WeakMap();
|
|
113
|
-
function agentFetch(opts, init) {
|
|
114
|
-
if (opts.agent !== opts.agent.toLowerCase()) {
|
|
115
|
-
console.warn(
|
|
116
|
-
`Agent name: ${opts.agent} should probably be in lowercase. Received: ${opts.agent}`
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
if (opts.name && opts.name !== opts.name.toLowerCase()) {
|
|
120
|
-
console.warn(
|
|
121
|
-
`Agent instance name: ${opts.name} should probably be in lowercase. Received: ${opts.name}`
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
return PartySocket.fetch(
|
|
125
|
-
{
|
|
126
|
-
prefix: "agents",
|
|
127
|
-
party: opts.agent,
|
|
128
|
-
room: opts.name || "default",
|
|
129
|
-
...opts
|
|
130
|
-
},
|
|
131
|
-
init
|
|
132
|
-
);
|
|
133
|
-
}
|
|
2
|
+
AgentClient,
|
|
3
|
+
agentFetch,
|
|
4
|
+
camelCaseToKebabCase
|
|
5
|
+
} from "./chunk-QEVM4BVL.js";
|
|
6
|
+
import "./chunk-BER7KXUJ.js";
|
|
7
|
+
import "./chunk-PR4QN5HX.js";
|
|
134
8
|
export {
|
|
135
9
|
AgentClient,
|
|
136
|
-
agentFetch
|
|
10
|
+
agentFetch,
|
|
11
|
+
camelCaseToKebabCase
|
|
137
12
|
};
|
|
138
13
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ToolSet } from 'ai';
|
|
2
|
+
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
3
|
+
|
|
4
|
+
declare class CodeModeProxy extends WorkerEntrypoint<Cloudflare.Env, {
|
|
5
|
+
binding: string;
|
|
6
|
+
name: string;
|
|
7
|
+
callback: string;
|
|
8
|
+
}> {
|
|
9
|
+
callFunction(options: {
|
|
10
|
+
functionName: string;
|
|
11
|
+
args: unknown[];
|
|
12
|
+
}): Promise<any>;
|
|
13
|
+
}
|
|
14
|
+
declare function experimental_codemode(options: {
|
|
15
|
+
tools: ToolSet;
|
|
16
|
+
prompt: string;
|
|
17
|
+
globalOutbound: Fetcher;
|
|
18
|
+
loader: WorkerLoader;
|
|
19
|
+
proxy: Fetcher<CodeModeProxy>;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
prompt: string;
|
|
22
|
+
tools: ToolSet;
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
export { CodeModeProxy, experimental_codemode };
|