agents-sdk
Advanced tools
Comparing version 0.0.0-dae7e07 to 0.0.0-e1aa5b7
import { | ||
Agent | ||
} from "./chunk-X57WSUMB.js"; | ||
} from "./chunk-X3UUTPNL.js"; | ||
@@ -5,0 +5,0 @@ // src/ai-chat-agent.ts |
@@ -43,4 +43,4 @@ import { Server, Connection, PartyServerOptions } from "partyserver"; | ||
when: Date | string | number, | ||
callback: string, | ||
payload: T | ||
callback: keyof this, | ||
payload?: T | ||
): Promise<Schedule<T>>; | ||
@@ -47,0 +47,0 @@ getSchedule<T = string>(id: string): Promise<Schedule<T> | undefined>; |
@@ -7,3 +7,3 @@ import { | ||
routeAgentRequest | ||
} from "./chunk-X57WSUMB.js"; | ||
} from "./chunk-X3UUTPNL.js"; | ||
export { | ||
@@ -10,0 +10,0 @@ Agent, |
{ | ||
"name": "agents-sdk", | ||
"version": "0.0.0-dae7e07", | ||
"version": "0.0.0-e1aa5b7", | ||
"main": "src/index.ts", | ||
@@ -42,4 +42,12 @@ "type": "module", | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/cloudflare/agents.git", | ||
"directory": "packages/agents" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/cloudflare/agents/issues" | ||
}, | ||
"author": "Cloudflare Inc.", | ||
"license": "MIT", | ||
"description": "A home for your AI agents", | ||
@@ -46,0 +54,0 @@ "dependencies": { |
@@ -176,16 +176,6 @@ import { | ||
#warnedToImplementOnStateUpdate = false; | ||
onStateUpdate(state: State | undefined, source: Connection | "server") { | ||
if (!this.#warnedToImplementOnStateUpdate) { | ||
console.log( | ||
"state updated, implement onStateUpdate in your agent to handle this change" | ||
); | ||
this.#warnedToImplementOnStateUpdate = true; | ||
} | ||
// override this to handle state updates | ||
} | ||
// onMessage(connection: Connection, message: WSMessage) {} | ||
// onConnect(connection: Connection, ctx: ConnectionContext) {} | ||
onEmail(email: ForwardableEmailMessage) { | ||
@@ -200,7 +190,15 @@ throw new Error("Not implemented"); | ||
when: Date | string | number, | ||
callback: string, | ||
payload: T | ||
callback: keyof this, | ||
payload?: T | ||
): Promise<Schedule<T>> { | ||
const id = nanoid(9); | ||
if (typeof callback !== "string") { | ||
throw new Error("Callback must be a string"); | ||
} | ||
if (typeof this[callback] !== "function") { | ||
throw new Error(`this.${callback} is not a function`); | ||
} | ||
if (when instanceof Date) { | ||
@@ -219,4 +217,4 @@ const timestamp = Math.floor(when.getTime() / 1000); | ||
id, | ||
callback, | ||
payload, | ||
callback: callback, | ||
payload: payload as T, | ||
time: timestamp, | ||
@@ -240,4 +238,4 @@ type: "scheduled", | ||
id, | ||
callback, | ||
payload, | ||
callback: callback, | ||
payload: payload as T, | ||
delayInSeconds: when, | ||
@@ -262,4 +260,4 @@ time: timestamp, | ||
id, | ||
callback, | ||
payload, | ||
callback: callback, | ||
payload: payload as T, | ||
cron: when, | ||
@@ -266,0 +264,0 @@ time: timestamp, |
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
0
0
86980
1333