@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 33 lines 1.37 KB
Raw
1 import * as Cloudflare from "@alchemy.run/cloudflare";
2 import * as Effect from "effect/Effect";
3 import { DIMENSIONS } from "./vectors.ts";
4
5 /**
6 * Shared Vectorize resources used by BOTH the effect-worker and the
7 * async-worker binding styles. Keeping one index here (instead of one per
8 * worker) means both workers bind the SAME resource, so the driver test can
9 * deploy both styles in a single stack and exercise the identical client
10 * surface against shared data.
11 *
12 * Runtime-only vector helpers live in `vectors.ts` (no alchemy import) so the
13 * plain async Worker can use them without bundling the Effect graph.
14 */
15 export const TestIndex = Cloudflare.Vectorize.Index("VectorizeWorkerIndex", {
16 dimensions: DIMENSIONS,
17 metric: "cosine",
18 });
19
20 /**
21 * Declares the metadata index on the `kind` property of the resolved parent
22 * index. Must be yielded AFTER the parent index is resolved (its `indexName`
23 * Output is only populated on the resolved resource, not the class handle).
24 * Metadata indexes must exist before vectors are inserted for them to be
25 * queryable, so the stack yields this before any worker upserts.
26 */
27 export const ensureMetaIndex = Effect.fn(function* (index: Cloudflare.Vectorize.Index) {
28 return yield* Cloudflare.Vectorize.MetadataIndex("VectorizeWorkerKindMetaIndex", {
29 indexName: index.indexName,
30 propertyName: "kind",
31 indexType: "string",
32 });
33 });