@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, 03:37 UTC

main
ts 27 lines 1.13 KB
Raw
1 import * as Schema from "effect/Schema";
2
3 import { TrimmedNonEmptyString } from "./baseSchemas.ts";
4
5 // Separate module avoids an import cycle between settings and provider instance contracts.
6 // Final once shipped: older builds drop entries whose key fails here, and erase them on their next save.
7 // Unlike provider slugs it may start with a digit, so a provider named "1Password" fits.
8 export const SecretProviderSlug = TrimmedNonEmptyString.check(
9 Schema.isMaxLength(64),
10 Schema.isPattern(/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/),
11 );
12
13 export const SecretProviderId = SecretProviderSlug.pipe(Schema.brand("SecretProviderId"));
14 export type SecretProviderId = typeof SecretProviderId.Type;
15
16 // Provider-specific syntax is the secret provider driver's to check.
17 export const SecretReferencePath = TrimmedNonEmptyString.check(
18 Schema.isMaxLength(1024),
19 Schema.isPattern(/^[^\r\n]+$/),
20 );
21
22 /** Points at a secret held by a configured secret provider; the secret itself is never stored. */
23 export const SecretReference = Schema.Struct({
24 provider: SecretProviderId,
25 reference: SecretReferencePath,
26 });
27 export type SecretReference = typeof SecretReference.Type;