Files
moltbot/src/gateway/protocol/schema/primitives.ts
2026-03-08 16:22:48 +00:00

40 lines
1.2 KiB
TypeScript

import { Type } from "@sinclair/typebox";
import { SESSION_LABEL_MAX_LENGTH } from "../../../sessions/session-label.js";
import { GATEWAY_CLIENT_IDS, GATEWAY_CLIENT_MODES } from "../client-info.js";
export const NonEmptyString = Type.String({ minLength: 1 });
export const CHAT_SEND_SESSION_KEY_MAX_LENGTH = 512;
export const ChatSendSessionKeyString = Type.String({
minLength: 1,
maxLength: CHAT_SEND_SESSION_KEY_MAX_LENGTH,
});
export const SessionLabelString = Type.String({
minLength: 1,
maxLength: SESSION_LABEL_MAX_LENGTH,
});
export const GatewayClientIdSchema = Type.Union(
Object.values(GATEWAY_CLIENT_IDS).map((value) => Type.Literal(value)),
);
export const GatewayClientModeSchema = Type.Union(
Object.values(GATEWAY_CLIENT_MODES).map((value) => Type.Literal(value)),
);
export const SecretRefSourceSchema = Type.Union([
Type.Literal("env"),
Type.Literal("file"),
Type.Literal("exec"),
]);
export const SecretRefSchema = Type.Object(
{
source: SecretRefSourceSchema,
provider: NonEmptyString,
id: NonEmptyString,
},
{ additionalProperties: false },
);
export const SecretInputSchema = Type.Union([Type.String(), SecretRefSchema]);