@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 56 lines 2.07 KB
Raw
1 import type * as s3vectors from "@distilled.cloud/aws/s3vectors";
2 import * as Binding from "alchemy/Binding";
3 import type * as Effect from "effect/Effect";
4 import type { Index } from "./VectorIndex.ts";
5
6 /** Fields the binding injects from the bound {@link Index}. */
7 type IndexRef = "vectorBucketName" | "indexName" | "indexArn";
8
9 export interface PutVectorsRequest extends Omit<s3vectors.PutVectorsInput, IndexRef> {}
10 export interface DeleteVectorsRequest extends Omit<s3vectors.DeleteVectorsInput, IndexRef> {}
11
12 /**
13 * The write-only runtime client returned by binding an {@link Index} via
14 * {@link VectorsWrite}. All calls target the bound index (its ARN is
15 * injected); pass raw distilled request shapes minus the index identifier.
16 */
17 export interface WriteVectorsClient {
18 /** Insert or overwrite vectors (keyed by `key`). */
19 readonly put: (
20 request: PutVectorsRequest,
21 ) => Effect.Effect<s3vectors.PutVectorsOutput, s3vectors.PutVectorsError>;
22 /** Delete vectors by key. */
23 readonly delete: (
24 request: DeleteVectorsRequest,
25 ) => Effect.Effect<s3vectors.DeleteVectorsOutput, s3vectors.DeleteVectorsError>;
26 }
27
28 /**
29 * Write-only runtime binding for the S3 Vectors data plane — insert and
30 * delete vectors in a bound {@link Index}.
31 *
32 * Grants only `s3vectors:PutVectors` and `s3vectors:DeleteVectors` on
33 * exactly the bound index's ARN — the least-privilege choice for ingestion
34 * pipelines that write embeddings but never query them. Provide the
35 * implementation with `Effect.provide(AWS.S3Vectors.VectorsWriteHttp)`.
36 *
37 * ### Writing Vectors
38 * **Example:** Insert Embeddings (write-only)
39 * ```typescript
40 * // init
41 * const vectors = yield* AWS.S3Vectors.VectorsWrite(index);
42 *
43 * // runtime
44 * yield* vectors.put({
45 * vectors: [{ key: "doc-1", data: { float32: [0.1, 0.2, 0.3] } }],
46 * });
47 * ```
48 *
49 * @binding
50 */
51 export interface VectorsWrite extends Binding.Service<
52 VectorsWrite,
53 "AWS.S3Vectors.VectorsWrite",
54 <I extends Index>(index: I) => Effect.Effect<WriteVectorsClient>
55 > {}
56 export const VectorsWrite = Binding.Service<VectorsWrite>("AWS.S3Vectors.VectorsWrite");