import { z } from "zod/v4";
/**
 * Cross-tier primitives — identity, status enums, opaque IDs.
 *
 * Anything that appears in WS messages, REST bodies, AND DB rows lives here so
 * the three contract files don't drift from each other.
 */
export const Uuid = z.string().uuid();
/** Short opaque ID like the existing src/agent/scheduler.ts uses (8 hex chars). */
export const ShortId = z.string().regex(/^[a-z0-9-]{6,32}$/);
/** Identifier used by Agent.registerFrontend in dp-worker (see §dp-worker-A in architecture.md). */
export const FrontendId = z.enum(["telegram", "center", "tui", "legacy"]);
export const LlmProtocol = z.enum(["openai", "claude"]);
export const ProxyProtocol = z.enum(["socks5", "socks4", "http", "https"]);
export const SocialPlatform = z.enum(["x", "youtube", "reddit", "instagram", "tiktok"]);
/** Process-axis status — written exclusively by dp-director (via PM events / heartbeat). */
export const ProcessStatus = z.enum(["running", "stopped", "crashed", "unknown"]);
/** Runtime/business-axis status — written exclusively by dp-worker (status_change). */
export const RuntimeStatus = z.enum(["idle", "busy", "error", "unknown"]);
/** Read-time derived status surfaced by the API; never stored. */
export const EffectiveWorkerStatus = z.enum([
    "offline", "crashed", "error", "busy", "idle", "unknown",
]);
export const EffectiveDirectorStatus = z.enum(["online", "offline"]);
export const DpWorkerRuntimeMode = z.enum(["npm", "dev-dist"]);
export const DpWorkerUpgradeStatus = z.enum([
    "idle",
    "checking",
    "installing",
    "building",
    "restarting",
    "success",
    "skipped",
    "failed",
]);
export const TaskSource = z.enum(["scheduled", "ad_hoc", "chat_replay"]);
export const TaskRunStatus = z.enum([
    "queued",
    "dispatched",
    "running",
    "success",
    "failed",
    "cancelled",
    "timeout",
]);
export const UserRole = z.enum(["admin", "operator", "viewer"]);
export const ChatScopeType = z.enum(["worker", "group"]);
export const ChatMessageRole = z.enum(["user", "assistant", "system", "tool"]);
/**
 * Opaque etag — dp-worker caches the latest etag locally; center bumps it whenever any
 * field a dp-worker would care about changes. dp-worker compares against its cached value
 * to decide whether to re-bootstrap.
 */
export const ConfigEtag = z.string().min(1);
/** Hex-encoded SHA-256 of the canonical session artifact; 64 chars. */
export const ContentHash = z.string().regex(/^[a-f0-9]{64}$/);
/**
 * An IANA-zone name string (e.g. "America/New_York", "Asia/Tokyo", "UTC").
 * Validated via the runtime `Intl.DateTimeFormat` constructor, which is
 * available in every target runtime: Node, browsers, and Cloudflare Workers
 * (V8 isolate). Invalid zone names throw RangeError on construction.
 *
 * Proxies carry one of these; a dp-worker bound to a proxy uses it as the
 * default cron timezone, while Chrome timezone spoofing is handled inside
 * the OmniFlow extension session imported into that browser profile.
 */
export const IanaTimezone = z
    .string()
    .min(1)
    .refine((tz) => {
    try {
        new Intl.DateTimeFormat(undefined, { timeZone: tz });
        return true;
    }
    catch {
        return false;
    }
}, {
    message: "must be a valid IANA timezone name (e.g. 'America/New_York', 'Asia/Tokyo', 'UTC')",
});
//# sourceMappingURL=domain.js.map