Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

RaeaCloud type-checks under Cloudflare Workers' types as well as the DOM's, so a Worker can drive a box (raea-bot): write() casts its upload to Uint8Array<ArrayBuffer> instead of the DOM-only BlobPart, and the ACP socket uses addEventListener for open, error, message and close instead of the on* properties workers-types lacks. The box smoke test with the echo agent passes its ACP turn and refusal on the Mac; its two Mac-only failures (the symlink fixture, BSD tar) are as before.

shinyobjectz20379f2da86c
diff --git a/sdk/cloud/src/index.ts b/sdk/cloud/src/index.ts
index 9890be06..46e45419 100644
--- a/sdk/cloud/src/index.ts
+++ b/sdk/cloud/src/index.ts
@@ -119,7 +119,7 @@ export class RaeaCloud {
}
async write(path: string, data: string | Uint8Array): Promise<void> {
- await this.call(`/v1/files?path=${encodeURIComponent(path)}`, { method: "PUT", body: typeof data === "string" ? data : new Blob([data as BlobPart]) })
+ await this.call(`/v1/files?path=${encodeURIComponent(path)}`, { method: "PUT", body: typeof data === "string" ? data : new Blob([data as Uint8Array<ArrayBuffer>]) })
}
/** `raea ARGS` in the workspace (or `cwd` in it): resolves with its exit code; output goes to onOutput as it comes. */
@@ -218,8 +218,8 @@ export class RaeaCloud {
const q = new URLSearchParams({ token: this.token, ...(o.agent ? { agent: o.agent } : {}) })
const ws = new WebSocket(`${this.url.replace(/^http/, "ws")}/v1/acp?${q}`)
await new Promise((ok, no) => {
- ws.onopen = ok
- ws.onerror = () => no(new Error(`couldn't open the ACP socket at ${this.url}`))
+ ws.addEventListener("open", ok)
+ ws.addEventListener("error", () => no(new Error(`couldn't open the ACP socket at ${this.url}`)))
})
const s = new Session(ws, o.onPermission)
await s.request("initialize", { protocolVersion: 1, clientCapabilities: {} })
diff --git a/sdk/cloud/src/session.ts b/sdk/cloud/src/session.ts
index b4bbfb0c..59ae9dc9 100644
--- a/sdk/cloud/src/session.ts
+++ b/sdk/cloud/src/session.ts
@@ -27,7 +27,7 @@ export class Session {
constructor(ws: WebSocket, permit?: (p: Permission) => string | Promise<string>) {
this.ws = ws
this.permit = permit ?? allowOnce
- ws.onmessage = async (e) => {
+ ws.addEventListener("message", async (e: MessageEvent) => {
const m = JSON.parse(String(e.data))
if (m.id != null && !m.method && this.waiting.has(m.id)) {
const w = this.waiting.get(m.id)!
@@ -41,11 +41,11 @@ export class Session {
}
// a request this client doesn't serve (fs/*, terminal/*): it said so in initialize, but answer rather than hang
if (m.id != null && m.method) ws.send(JSON.stringify({ jsonrpc: "2.0", id: m.id, error: { code: -32601, message: `${m.method} isn't offered by this client` } }))
- }
- ws.onclose = (e) => {
+ })
+ ws.addEventListener("close", (e: CloseEvent) => {
for (const w of this.waiting.values()) w.no(new Error(`the ACP socket closed${e.reason ? `: ${e.reason}` : ""}`))
this.waiting.clear()
- }
+ })
}
request(method: string, params: unknown): Promise<unknown> {