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

main
ts 35 lines 1.18 KB
Raw
1 import { expect } from "bun:test";
2 import * as AWS from "@alchemy.run/aws";
3 import * as Test from "@alchemy.run/test/Bun";
4 import * as Alchemy from "alchemy";
5 import * as Effect from "effect/Effect";
6 import * as HttpClient from "effect/http/HttpClient";
7 import * as Schedule from "effect/Schedule";
8 import Stack from "../alchemy.run.ts";
9
10 const { test, beforeAll, afterAll, deploy, destroy } = Test.make({
11 providers: AWS.providers(),
12 state: Alchemy.localState(),
13 });
14
15 const stack = beforeAll(deploy(Stack));
16 afterAll.skipIf(!!process.env.NO_DESTROY)(destroy(Stack));
17
18 test(
19 "generates text through Bedrock",
20 Effect.gen(function* () {
21 const out = (yield* stack) as { url: string };
22 const client = HttpClient.filterStatusOk(yield* HttpClient.HttpClient);
23
24 // Fresh function URLs take a few seconds to start serving 200s.
25 const res = yield* client.get(`${out.url}?prompt=${encodeURIComponent("Say pong.")}`).pipe(
26 Effect.retry({
27 schedule: Schedule.exponential("1 second"),
28 times: 10,
29 }),
30 );
31 const body = (yield* res.json) as { text: string; finishReason: string };
32 expect(body.text.length).toBeGreaterThan(0);
33 }),
34 { timeout: 300_000 },
35 );