agents 0.0.0-b24b302 → 0.0.0-b30ffda
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/ai-chat-agent.d.ts +31 -23
- package/dist/ai-chat-agent.js +168 -0
- package/dist/ai-chat-agent.js.map +1 -0
- package/dist/ai-react.d.ts +72 -44
- package/dist/ai-react.js +192 -0
- package/dist/ai-react.js.map +1 -0
- package/dist/ai-types.d.ts +60 -40
- package/dist/ai-types.js +1 -0
- package/dist/ai-types.js.map +1 -0
- package/dist/chunk-HMLY7DHA.js +16 -0
- package/dist/chunk-HMLY7DHA.js.map +1 -0
- package/dist/chunk-XG52S6YY.js +591 -0
- package/dist/chunk-XG52S6YY.js.map +1 -0
- package/dist/client.d.ts +57 -37
- package/dist/client.js +131 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +220 -177
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/client.d.ts +121 -33
- package/dist/mcp/client.js +408 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/do-oauth-client-provider.d.ts +41 -0
- package/dist/mcp/do-oauth-client-provider.js +107 -0
- package/dist/mcp/do-oauth-client-provider.js.map +1 -0
- package/dist/mcp/index.js +349 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/react.d.ts +24 -15
- package/dist/react.js +104 -0
- package/dist/react.js.map +1 -0
- package/dist/schedule.d.ts +30 -20
- package/dist/schedule.js +73 -0
- package/dist/schedule.js.map +1 -0
- package/package.json +12 -4
- package/src/index.ts +0 -7
package/dist/react.d.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { PartySocket } from
|
|
2
|
-
import { usePartySocket } from
|
|
3
|
-
import { StreamOptions } from
|
|
1
|
+
import { PartySocket } from "partysocket";
|
|
2
|
+
import { usePartySocket } from "partysocket/react";
|
|
3
|
+
import { StreamOptions } from "./client.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Options for the useAgent hook
|
|
7
7
|
* @template State Type of the Agent's state
|
|
8
8
|
*/
|
|
9
|
-
type UseAgentOptions<State = unknown> = Omit<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
type UseAgentOptions<State = unknown> = Omit<
|
|
10
|
+
Parameters<typeof usePartySocket>[0],
|
|
11
|
+
"party" | "room"
|
|
12
|
+
> & {
|
|
13
|
+
/** Name of the agent to connect to */
|
|
14
|
+
agent: string;
|
|
15
|
+
/** Name of the specific Agent instance */
|
|
16
|
+
name?: string;
|
|
17
|
+
/** Called when the Agent's state is updated */
|
|
18
|
+
onStateUpdate?: (state: State, source: "server" | "client") => void;
|
|
16
19
|
};
|
|
17
20
|
/**
|
|
18
21
|
* React hook for connecting to an Agent
|
|
@@ -20,11 +23,17 @@ type UseAgentOptions<State = unknown> = Omit<Parameters<typeof usePartySocket>[0
|
|
|
20
23
|
* @param options Connection options
|
|
21
24
|
* @returns WebSocket connection with setState and call methods
|
|
22
25
|
*/
|
|
23
|
-
declare function useAgent<State = unknown>(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
declare function useAgent<State = unknown>(
|
|
27
|
+
options: UseAgentOptions<State>
|
|
28
|
+
): PartySocket & {
|
|
29
|
+
agent: string;
|
|
30
|
+
name: string;
|
|
31
|
+
setState: (state: State) => void;
|
|
32
|
+
call: <T = unknown>(
|
|
33
|
+
method: string,
|
|
34
|
+
args?: unknown[],
|
|
35
|
+
streamOptions?: StreamOptions
|
|
36
|
+
) => Promise<T>;
|
|
28
37
|
};
|
|
29
38
|
|
|
30
39
|
export { type UseAgentOptions, useAgent };
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import "./chunk-HMLY7DHA.js";
|
|
2
|
+
|
|
3
|
+
// src/react.tsx
|
|
4
|
+
import { usePartySocket } from "partysocket/react";
|
|
5
|
+
import { useCallback, useRef } from "react";
|
|
6
|
+
function camelCaseToKebabCase(str) {
|
|
7
|
+
if (str === str.toUpperCase() && str !== str.toLowerCase()) {
|
|
8
|
+
return str.toLowerCase().replace(/_/g, "-");
|
|
9
|
+
}
|
|
10
|
+
let kebabified = str.replace(
|
|
11
|
+
/[A-Z]/g,
|
|
12
|
+
(letter) => `-${letter.toLowerCase()}`
|
|
13
|
+
);
|
|
14
|
+
kebabified = kebabified.startsWith("-") ? kebabified.slice(1) : kebabified;
|
|
15
|
+
return kebabified.replace(/_/g, "-").replace(/-$/, "");
|
|
16
|
+
}
|
|
17
|
+
function useAgent(options) {
|
|
18
|
+
const agentNamespace = camelCaseToKebabCase(options.agent);
|
|
19
|
+
const pendingCallsRef = useRef(
|
|
20
|
+
/* @__PURE__ */ new Map()
|
|
21
|
+
);
|
|
22
|
+
const agent = usePartySocket({
|
|
23
|
+
prefix: "agents",
|
|
24
|
+
party: agentNamespace,
|
|
25
|
+
room: options.name || "default",
|
|
26
|
+
...options,
|
|
27
|
+
onMessage: (message) => {
|
|
28
|
+
if (typeof message.data === "string") {
|
|
29
|
+
let parsedMessage;
|
|
30
|
+
try {
|
|
31
|
+
parsedMessage = JSON.parse(message.data);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return options.onMessage?.(message);
|
|
34
|
+
}
|
|
35
|
+
if (parsedMessage.type === "cf_agent_state") {
|
|
36
|
+
options.onStateUpdate?.(parsedMessage.state, "server");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (parsedMessage.type === "rpc") {
|
|
40
|
+
const response = parsedMessage;
|
|
41
|
+
const pending = pendingCallsRef.current.get(response.id);
|
|
42
|
+
if (!pending) return;
|
|
43
|
+
if (!response.success) {
|
|
44
|
+
pending.reject(new Error(response.error));
|
|
45
|
+
pendingCallsRef.current.delete(response.id);
|
|
46
|
+
pending.stream?.onError?.(response.error);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if ("done" in response) {
|
|
50
|
+
if (response.done) {
|
|
51
|
+
pending.resolve(response.result);
|
|
52
|
+
pendingCallsRef.current.delete(response.id);
|
|
53
|
+
pending.stream?.onDone?.(response.result);
|
|
54
|
+
} else {
|
|
55
|
+
pending.stream?.onChunk?.(response.result);
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
pending.resolve(response.result);
|
|
59
|
+
pendingCallsRef.current.delete(response.id);
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
options.onMessage?.(message);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const call = useCallback(
|
|
68
|
+
(method, args = [], streamOptions) => {
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
const id = Math.random().toString(36).slice(2);
|
|
71
|
+
pendingCallsRef.current.set(id, {
|
|
72
|
+
resolve,
|
|
73
|
+
reject,
|
|
74
|
+
stream: streamOptions
|
|
75
|
+
});
|
|
76
|
+
const request = {
|
|
77
|
+
type: "rpc",
|
|
78
|
+
id,
|
|
79
|
+
method,
|
|
80
|
+
args
|
|
81
|
+
};
|
|
82
|
+
agent.send(JSON.stringify(request));
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
[agent]
|
|
86
|
+
);
|
|
87
|
+
agent.setState = (state) => {
|
|
88
|
+
agent.send(JSON.stringify({ type: "cf_agent_state", state }));
|
|
89
|
+
options.onStateUpdate?.(state, "client");
|
|
90
|
+
};
|
|
91
|
+
agent.call = call;
|
|
92
|
+
agent.agent = agentNamespace;
|
|
93
|
+
agent.name = options.name || "default";
|
|
94
|
+
if (agent.agent !== agent.agent.toLowerCase()) {
|
|
95
|
+
console.warn(
|
|
96
|
+
`Agent name: ${agent.agent} should probably be in lowercase. Received: ${agent.agent}`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return agent;
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
useAgent
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.tsx"],"sourcesContent":["import type { PartySocket } from \"partysocket\";\nimport { usePartySocket } from \"partysocket/react\";\nimport { useCallback, useRef } from \"react\";\nimport type { RPCRequest, RPCResponse } from \"./\";\nimport type { StreamOptions } from \"./client\";\n\n/**\n * Convert a camelCase string to a kebab-case string\n * @param str The string to convert\n * @returns The kebab-case string\n */\nfunction camelCaseToKebabCase(str: string): string {\n // If string is all uppercase, convert to lowercase\n if (str === str.toUpperCase() && str !== str.toLowerCase()) {\n return str.toLowerCase().replace(/_/g, \"-\");\n }\n\n // Otherwise handle camelCase to kebab-case\n let kebabified = str.replace(\n /[A-Z]/g,\n (letter) => `-${letter.toLowerCase()}`\n );\n kebabified = kebabified.startsWith(\"-\") ? kebabified.slice(1) : kebabified;\n // Convert any remaining underscores to hyphens and remove trailing -'s\n return kebabified.replace(/_/g, \"-\").replace(/-$/, \"\");\n}\n\n/**\n * Options for the useAgent hook\n * @template State Type of the Agent's state\n */\nexport type UseAgentOptions<State = unknown> = Omit<\n Parameters<typeof usePartySocket>[0],\n \"party\" | \"room\"\n> & {\n /** Name of the agent to connect to */\n agent: string;\n /** Name of the specific Agent instance */\n name?: string;\n /** Called when the Agent's state is updated */\n onStateUpdate?: (state: State, source: \"server\" | \"client\") => void;\n};\n\n/**\n * React hook for connecting to an Agent\n * @template State Type of the Agent's state\n * @param options Connection options\n * @returns WebSocket connection with setState and call methods\n */\nexport function useAgent<State = unknown>(\n options: UseAgentOptions<State>\n): PartySocket & {\n agent: string;\n name: string;\n setState: (state: State) => void;\n call: <T = unknown>(\n method: string,\n args?: unknown[],\n streamOptions?: StreamOptions\n ) => Promise<T>;\n} {\n const agentNamespace = camelCaseToKebabCase(options.agent);\n // Keep track of pending RPC calls\n const pendingCallsRef = useRef(\n new Map<\n string,\n {\n resolve: (value: unknown) => void;\n reject: (error: Error) => void;\n stream?: StreamOptions;\n }\n >()\n );\n\n // TODO: if options.query is a function, then use\n // \"use()\" to get the value and pass it\n // as a query parameter to usePartySocket\n const agent = usePartySocket({\n prefix: \"agents\",\n party: agentNamespace,\n room: options.name || \"default\",\n ...options,\n onMessage: (message) => {\n if (typeof message.data === \"string\") {\n let parsedMessage: Record<string, unknown>;\n try {\n parsedMessage = JSON.parse(message.data);\n } catch (error) {\n // silently ignore invalid messages for now\n // TODO: log errors with log levels\n return options.onMessage?.(message);\n }\n if (parsedMessage.type === \"cf_agent_state\") {\n options.onStateUpdate?.(parsedMessage.state as State, \"server\");\n return;\n }\n if (parsedMessage.type === \"rpc\") {\n const response = parsedMessage as RPCResponse;\n const pending = pendingCallsRef.current.get(response.id);\n if (!pending) return;\n\n if (!response.success) {\n pending.reject(new Error(response.error));\n pendingCallsRef.current.delete(response.id);\n pending.stream?.onError?.(response.error);\n return;\n }\n\n // Handle streaming responses\n if (\"done\" in response) {\n if (response.done) {\n pending.resolve(response.result);\n pendingCallsRef.current.delete(response.id);\n pending.stream?.onDone?.(response.result);\n } else {\n pending.stream?.onChunk?.(response.result);\n }\n } else {\n // Non-streaming response\n pending.resolve(response.result);\n pendingCallsRef.current.delete(response.id);\n }\n return;\n }\n }\n options.onMessage?.(message);\n },\n }) as PartySocket & {\n agent: string;\n name: string;\n setState: (state: State) => void;\n call: <T = unknown>(\n method: string,\n args?: unknown[],\n streamOptions?: StreamOptions\n ) => Promise<T>;\n };\n // Create the call method\n const call = useCallback(\n <T = unknown,>(\n method: string,\n args: unknown[] = [],\n streamOptions?: StreamOptions\n ): Promise<T> => {\n return new Promise((resolve, reject) => {\n const id = Math.random().toString(36).slice(2);\n pendingCallsRef.current.set(id, {\n resolve: resolve as (value: unknown) => void,\n reject,\n stream: streamOptions,\n });\n\n const request: RPCRequest = {\n type: \"rpc\",\n id,\n method,\n args,\n };\n\n agent.send(JSON.stringify(request));\n });\n },\n [agent]\n );\n\n agent.setState = (state: State) => {\n agent.send(JSON.stringify({ type: \"cf_agent_state\", state }));\n options.onStateUpdate?.(state, \"client\");\n };\n\n agent.call = call;\n agent.agent = agentNamespace;\n agent.name = options.name || \"default\";\n\n // warn if agent isn't in lowercase\n if (agent.agent !== agent.agent.toLowerCase()) {\n console.warn(\n `Agent name: ${agent.agent} should probably be in lowercase. Received: ${agent.agent}`\n );\n }\n\n return agent;\n}\n"],"mappings":"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","names":[]}
|
package/dist/schedule.d.ts
CHANGED
|
@@ -1,43 +1,53 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
3
|
type Schedule = z.infer<typeof unstable_scheduleSchema>;
|
|
4
|
-
declare function unstable_getSchedulePrompt(event: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
declare const unstable_scheduleSchema: z.ZodObject<{
|
|
4
|
+
declare function unstable_getSchedulePrompt(event: { date: Date }): string;
|
|
5
|
+
declare const unstable_scheduleSchema: z.ZodObject<
|
|
6
|
+
{
|
|
8
7
|
description: z.ZodString;
|
|
9
|
-
when: z.ZodObject<
|
|
8
|
+
when: z.ZodObject<
|
|
9
|
+
{
|
|
10
10
|
type: z.ZodEnum<["scheduled", "delayed", "cron", "no-schedule"]>;
|
|
11
11
|
date: z.ZodOptional<z.ZodDate>;
|
|
12
12
|
delayInSeconds: z.ZodOptional<z.ZodNumber>;
|
|
13
13
|
cron: z.ZodOptional<z.ZodString>;
|
|
14
|
-
|
|
14
|
+
},
|
|
15
|
+
"strip",
|
|
16
|
+
z.ZodTypeAny,
|
|
17
|
+
{
|
|
15
18
|
type: "scheduled" | "delayed" | "cron" | "no-schedule";
|
|
16
19
|
cron?: string | undefined;
|
|
17
20
|
delayInSeconds?: number | undefined;
|
|
18
21
|
date?: Date | undefined;
|
|
19
|
-
|
|
22
|
+
},
|
|
23
|
+
{
|
|
20
24
|
type: "scheduled" | "delayed" | "cron" | "no-schedule";
|
|
21
25
|
cron?: string | undefined;
|
|
22
26
|
delayInSeconds?: number | undefined;
|
|
23
27
|
date?: Date | undefined;
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
}
|
|
29
|
+
>;
|
|
30
|
+
},
|
|
31
|
+
"strip",
|
|
32
|
+
z.ZodTypeAny,
|
|
33
|
+
{
|
|
26
34
|
description: string;
|
|
27
35
|
when: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
type: "scheduled" | "delayed" | "cron" | "no-schedule";
|
|
37
|
+
cron?: string | undefined;
|
|
38
|
+
delayInSeconds?: number | undefined;
|
|
39
|
+
date?: Date | undefined;
|
|
32
40
|
};
|
|
33
|
-
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
34
43
|
description: string;
|
|
35
44
|
when: {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
type: "scheduled" | "delayed" | "cron" | "no-schedule";
|
|
46
|
+
cron?: string | undefined;
|
|
47
|
+
delayInSeconds?: number | undefined;
|
|
48
|
+
date?: Date | undefined;
|
|
40
49
|
};
|
|
41
|
-
}
|
|
50
|
+
}
|
|
51
|
+
>;
|
|
42
52
|
|
|
43
53
|
export { type Schedule, unstable_getSchedulePrompt, unstable_scheduleSchema };
|
package/dist/schedule.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import "./chunk-HMLY7DHA.js";
|
|
2
|
+
|
|
3
|
+
// src/schedule.ts
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
function unstable_getSchedulePrompt(event) {
|
|
6
|
+
return `
|
|
7
|
+
[Schedule Parser Component]
|
|
8
|
+
|
|
9
|
+
Current time: ${event.date.toUTCString()}
|
|
10
|
+
|
|
11
|
+
This component parses natural language scheduling requests into a structured format. It extracts:
|
|
12
|
+
1. A clean task description (without timing information)
|
|
13
|
+
2. Scheduling details in one of these formats:
|
|
14
|
+
- scheduled: Specific date/time events
|
|
15
|
+
- delayed: Relative time delays (in seconds)
|
|
16
|
+
- cron: Recurring patterns
|
|
17
|
+
- no-schedule: Tasks without timing
|
|
18
|
+
|
|
19
|
+
Rules:
|
|
20
|
+
- Task descriptions should be clean and focused on the action
|
|
21
|
+
- Use numbers (0-6) for days in cron patterns (0=Sunday)
|
|
22
|
+
- For recurring tasks, use standard cron syntax
|
|
23
|
+
- For relative times, convert to seconds
|
|
24
|
+
- For specific dates, use the current time as reference
|
|
25
|
+
|
|
26
|
+
Example outputs:
|
|
27
|
+
{
|
|
28
|
+
"description": "meeting with team",
|
|
29
|
+
"when": {
|
|
30
|
+
"type": "scheduled",
|
|
31
|
+
"date": "tomorrow at 14:00"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
{
|
|
36
|
+
"description": "backup database",
|
|
37
|
+
"when": {
|
|
38
|
+
"type": "cron",
|
|
39
|
+
"cron": "0 0 * * *"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
{
|
|
44
|
+
"description": "send report",
|
|
45
|
+
"when": {
|
|
46
|
+
"type": "delayed",
|
|
47
|
+
"delayInSeconds": 1800
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[End Schedule Parser Component]
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
54
|
+
var unstable_scheduleSchema = z.object({
|
|
55
|
+
description: z.string().describe("A description of the task"),
|
|
56
|
+
when: z.object({
|
|
57
|
+
type: z.enum(["scheduled", "delayed", "cron", "no-schedule"]).describe("The type of scheduling details"),
|
|
58
|
+
date: z.coerce.date().optional().describe(
|
|
59
|
+
"execute task at the specified date and time (only use if the type is scheduled)"
|
|
60
|
+
),
|
|
61
|
+
delayInSeconds: z.number().optional().describe(
|
|
62
|
+
"execute task after a delay in seconds (only use if the type is delayed)"
|
|
63
|
+
),
|
|
64
|
+
cron: z.string().optional().describe(
|
|
65
|
+
"execute task on a recurring interval specified as cron syntax (only use if the type is cron)"
|
|
66
|
+
)
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
export {
|
|
70
|
+
unstable_getSchedulePrompt,
|
|
71
|
+
unstable_scheduleSchema
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=schedule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schedule.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport type Schedule = z.infer<typeof unstable_scheduleSchema>;\n\nexport function unstable_getSchedulePrompt(event: { date: Date }) {\n return `\n[Schedule Parser Component]\n\nCurrent time: ${event.date.toUTCString()}\n\nThis component parses natural language scheduling requests into a structured format. It extracts:\n1. A clean task description (without timing information)\n2. Scheduling details in one of these formats:\n - scheduled: Specific date/time events\n - delayed: Relative time delays (in seconds)\n - cron: Recurring patterns\n - no-schedule: Tasks without timing\n\nRules:\n- Task descriptions should be clean and focused on the action\n- Use numbers (0-6) for days in cron patterns (0=Sunday)\n- For recurring tasks, use standard cron syntax\n- For relative times, convert to seconds\n- For specific dates, use the current time as reference\n\nExample outputs:\n{\n \"description\": \"meeting with team\",\n \"when\": {\n \"type\": \"scheduled\",\n \"date\": \"tomorrow at 14:00\"\n }\n}\n\n{\n \"description\": \"backup database\",\n \"when\": {\n \"type\": \"cron\",\n \"cron\": \"0 0 * * *\"\n }\n}\n\n{\n \"description\": \"send report\",\n \"when\": {\n \"type\": \"delayed\",\n \"delayInSeconds\": 1800\n }\n}\n\n[End Schedule Parser Component]\n`;\n}\n\nexport const unstable_scheduleSchema = z.object({\n description: z.string().describe(\"A description of the task\"),\n when: z.object({\n type: z\n .enum([\"scheduled\", \"delayed\", \"cron\", \"no-schedule\"])\n .describe(\"The type of scheduling details\"),\n date: z.coerce\n .date()\n .optional()\n .describe(\n \"execute task at the specified date and time (only use if the type is scheduled)\"\n ),\n delayInSeconds: z\n .number()\n .optional()\n .describe(\n \"execute task after a delay in seconds (only use if the type is delayed)\"\n ),\n cron: z\n .string()\n .optional()\n .describe(\n \"execute task on a recurring interval specified as cron syntax (only use if the type is cron)\"\n ),\n }),\n});\n"],"mappings":";;;AAAA,SAAS,SAAS;AAIX,SAAS,2BAA2B,OAAuB;AAChE,SAAO;AAAA;AAAA;AAAA,gBAGO,MAAM,KAAK,YAAY,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4CxC;AAEO,IAAM,0BAA0B,EAAE,OAAO;AAAA,EAC9C,aAAa,EAAE,OAAO,EAAE,SAAS,2BAA2B;AAAA,EAC5D,MAAM,EAAE,OAAO;AAAA,IACb,MAAM,EACH,KAAK,CAAC,aAAa,WAAW,QAAQ,aAAa,CAAC,EACpD,SAAS,gCAAgC;AAAA,IAC5C,MAAM,EAAE,OACL,KAAK,EACL,SAAS,EACT;AAAA,MACC;AAAA,IACF;AAAA,IACF,gBAAgB,EACb,OAAO,EACP,SAAS,EACT;AAAA,MACC;AAAA,IACF;AAAA,IACF,MAAM,EACH,OAAO,EACP,SAAS,EACT;AAAA,MACC;AAAA,IACF;AAAA,EACJ,CAAC;AACH,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agents",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-b30ffda",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
"require": "./dist/ai-chat-agent.js",
|
|
39
39
|
"import": "./dist/ai-chat-agent.js"
|
|
40
40
|
},
|
|
41
|
+
"./ai-types": {
|
|
42
|
+
"types": "./dist/ai-types.d.ts",
|
|
43
|
+
"require": "./dist/ai-types.js",
|
|
44
|
+
"import": "./dist/ai-types.js"
|
|
45
|
+
},
|
|
41
46
|
"./schedule": {
|
|
42
47
|
"types": "./dist/schedule.d.ts",
|
|
43
48
|
"require": "./dist/schedule.js",
|
|
@@ -52,6 +57,11 @@
|
|
|
52
57
|
"types": "./dist/mcp/client.d.ts",
|
|
53
58
|
"require": "./dist/mcp/client.js",
|
|
54
59
|
"import": "./dist/mcp/client.js"
|
|
60
|
+
},
|
|
61
|
+
"./mcp/do-oauth-client-provider": {
|
|
62
|
+
"types": "./dist/mcp/do-oauth-client-provider.d.ts",
|
|
63
|
+
"require": "./dist/mcp/do-oauth-client-provider.js",
|
|
64
|
+
"import": "./dist/mcp/do-oauth-client-provider.js"
|
|
55
65
|
}
|
|
56
66
|
},
|
|
57
67
|
"keywords": [],
|
|
@@ -67,12 +77,10 @@
|
|
|
67
77
|
"license": "MIT",
|
|
68
78
|
"description": "A home for your AI agents",
|
|
69
79
|
"dependencies": {
|
|
80
|
+
"@modelcontextprotocol/sdk": "^1.9.0",
|
|
70
81
|
"cron-schedule": "^5.0.4",
|
|
71
82
|
"nanoid": "^5.1.5",
|
|
72
83
|
"partyserver": "^0.0.66",
|
|
73
84
|
"partysocket": "1.1.3"
|
|
74
|
-
},
|
|
75
|
-
"devDependencies": {
|
|
76
|
-
"@modelcontextprotocol/sdk": "^1.8.0"
|
|
77
85
|
}
|
|
78
86
|
}
|
package/src/index.ts
CHANGED
|
@@ -15,8 +15,6 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
15
15
|
|
|
16
16
|
export type { Connection, WSMessage, ConnectionContext } from "partyserver";
|
|
17
17
|
|
|
18
|
-
import { WorkflowEntrypoint as CFWorkflowEntrypoint } from "cloudflare:workers";
|
|
19
|
-
|
|
20
18
|
/**
|
|
21
19
|
* RPC request message from client
|
|
22
20
|
*/
|
|
@@ -119,11 +117,6 @@ export function unstable_callable(metadata: CallableMetadata = {}) {
|
|
|
119
117
|
};
|
|
120
118
|
}
|
|
121
119
|
|
|
122
|
-
/**
|
|
123
|
-
* A class for creating workflow entry points that can be used with Cloudflare Workers
|
|
124
|
-
*/
|
|
125
|
-
export class WorkflowEntrypoint extends CFWorkflowEntrypoint {}
|
|
126
|
-
|
|
127
120
|
/**
|
|
128
121
|
* Represents a scheduled task within an Agent
|
|
129
122
|
* @template T Type of the payload data
|