The best way to control Claude Code, Codex and more from any computer or phone

main
ts 55 lines 1.91 KB
Raw
1 import * as Cloudflare from "@alchemy.run/cloudflare";
2 import { expect } from "@alchemy.run/test";
3 import * as Test from "@alchemy.run/test/Alchemy";
4 import { Action } from "alchemy/Action";
5 import * as Effect from "effect/Effect";
6 import { MinimumLogLevel } from "effect/References";
7
8 const { test } = Test.make({ providers: Cloudflare.providers() });
9
10 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
11
12 // Driving Cloudflare Browser Rendering inside an Action via `BrowserLocal` —
13 // the local (current-credentials) implementation of the `Browser` binding.
14 // Browser Rendering is account-scoped and has no backing cloud resource, so the
15 // Action runs the REST quick actions directly against a stable page.
16 test.provider(
17 "BrowserLocal: render a page to markdown and content from an Action",
18 (stack) =>
19 Effect.gen(function* () {
20 yield* stack.destroy();
21
22 const out = yield* stack.deploy(
23 Effect.gen(function* () {
24 const Render = Action(
25 "Render",
26 Effect.gen(function* () {
27 const browser = yield* Cloudflare.Browser("BROWSER");
28
29 return Effect.fn(function* () {
30 const md = yield* browser.markdown({
31 url: "https://example.com",
32 });
33 const html = yield* browser.content({
34 url: "https://example.com",
35 });
36
37 return { markdown: md.result, content: html.result };
38 });
39 }).pipe(Effect.provide(Cloudflare.Workers.BrowserLocal)),
40 );
41
42 return yield* Render({});
43 }),
44 );
45
46 expect(out.markdown.toLowerCase()).toContain("example");
47 expect(out.content.toLowerCase()).toContain("example");
48
49 yield* stack.destroy();
50 }).pipe(logLevel),
51 {
52 tags: ["provider:cloudflare", "provider:cloudflare:worker", "live"],
53 timeout: 120_000,
54 },
55 );