import {
  __esm
} from "./chunk-KFQGP6VL.js";

// ../types/dist/index.mjs
import { z } from "zod";
import { z as z2 } from "zod";
import { z as z3 } from "zod";
function Ok(value) {
  return { ok: true, value };
}
function Err(error) {
  return { ok: false, error };
}
function isOk(result) {
  return result.ok === true;
}
function isErr(result) {
  return result.ok === false;
}
var STANDARD_COGNITIVE_MODES, DEFAULT_SKILL_CONTEXT_BUDGET, SESSION_SECTION_NAMES, TrajectoryMetadataSchema, PromptCacheStatsSchema, OTLPKeyValueSchema, OTLPSpanSchema, TokenScopeSchema, BridgeKindSchema, AuthTokenSchema, AuthTokenPublicSchema, AuthAuditEntrySchema, WebhookSubscriptionSchema, WebhookSubscriptionPublicSchema, GatewayEventSchema, WebhookDeliveryStatusSchema, WebhookDeliverySchema;
var init_dist = __esm({
  "../types/dist/index.mjs"() {
    STANDARD_COGNITIVE_MODES = [
      "adversarial-reviewer",
      "constructive-architect",
      "meticulous-implementer",
      "diagnostic-investigator",
      "advisory-guide",
      "meticulous-verifier"
    ];
    DEFAULT_SKILL_CONTEXT_BUDGET = {
      max_tokens: 4e3,
      priority: 3
    };
    SESSION_SECTION_NAMES = [
      "terminology",
      "decisions",
      "constraints",
      "risks",
      "openQuestions",
      "evidence"
    ];
    TrajectoryMetadataSchema = z.object({
      turnsCount: z.number().int().nonnegative(),
      toolCallCount: z.number().int().nonnegative(),
      modelTokenSpend: z.object({
        input: z.number().int().nonnegative(),
        output: z.number().int().nonnegative(),
        cacheRead: z.number().int().nonnegative(),
        cacheCreation: z.number().int().nonnegative()
      }),
      promptCacheHit: z.number().int().nonnegative(),
      promptCacheMiss: z.number().int().nonnegative(),
      totalDurationMs: z.number().int().nonnegative(),
      phasesReached: z.array(z.string())
    });
    PromptCacheStatsSchema = z.object({
      totalRequests: z.number().int().nonnegative(),
      hits: z.number().int().nonnegative(),
      misses: z.number().int().nonnegative(),
      hitRate: z.number().min(0).max(1),
      byBackend: z.record(
        z.string(),
        z.object({
          hits: z.number().int().nonnegative(),
          misses: z.number().int().nonnegative()
        })
      ),
      windowStartedAt: z.number().int()
    });
    OTLPKeyValueSchema = z.object({
      key: z.string(),
      value: z.object({
        stringValue: z.string().optional(),
        intValue: z.string().optional(),
        doubleValue: z.number().optional(),
        boolValue: z.boolean().optional()
      })
    });
    OTLPSpanSchema = z.object({
      traceId: z.string().length(32),
      // 16-byte hex
      spanId: z.string().length(16),
      // 8-byte hex
      parentSpanId: z.string().length(16).optional(),
      name: z.string(),
      kind: z.number().int(),
      // SpanKind enum (1=INTERNAL, 2=SERVER, 3=CLIENT, 4=PRODUCER, 5=CONSUMER)
      startTimeUnixNano: z.string(),
      // decimal nanoseconds as string (int64 unsafe in JSON)
      endTimeUnixNano: z.string(),
      attributes: z.array(OTLPKeyValueSchema),
      status: z.object({ code: z.number().int() }).optional()
    });
    TokenScopeSchema = z2.enum([
      "admin",
      "trigger-job",
      "read-status",
      "resolve-interaction",
      "subscribe-webhook",
      "modify-roadmap",
      "read-telemetry"
    ]);
    BridgeKindSchema = z2.enum(["slack", "discord", "github-app", "custom"]);
    AuthTokenSchema = z2.object({
      id: z2.string().regex(/^tok_[a-f0-9]{16}$/),
      name: z2.string().min(1).max(100),
      scopes: z2.array(TokenScopeSchema).min(1),
      bridgeKind: BridgeKindSchema.optional(),
      tenantId: z2.string().optional(),
      hashedSecret: z2.string().min(1),
      createdAt: z2.string().datetime(),
      lastUsedAt: z2.string().datetime().optional(),
      expiresAt: z2.string().datetime().optional()
    });
    AuthTokenPublicSchema = AuthTokenSchema.omit({ hashedSecret: true });
    AuthAuditEntrySchema = z2.object({
      timestamp: z2.string().datetime(),
      tokenId: z2.string(),
      tenantId: z2.string().optional(),
      route: z2.string(),
      method: z2.string(),
      status: z2.number().int()
    });
    WebhookSubscriptionSchema = z3.object({
      id: z3.string().regex(/^whk_[a-f0-9]{16}$/),
      tokenId: z3.string(),
      // owning auth token (audit / revocation chain)
      url: z3.string().url().startsWith("https://"),
      // https-only at registration
      events: z3.array(z3.string().min(1)).min(1),
      // glob patterns: "maintenance.completed", "interaction.*"
      secret: z3.string().min(32),
      // 32-byte base64url (44 chars)
      createdAt: z3.string().datetime()
    });
    WebhookSubscriptionPublicSchema = WebhookSubscriptionSchema.omit({ secret: true });
    GatewayEventSchema = z3.object({
      id: z3.string().regex(/^evt_[a-f0-9]+$/),
      type: z3.string().min(1),
      timestamp: z3.string().datetime(),
      data: z3.unknown(),
      correlationId: z3.string().optional()
    });
    WebhookDeliveryStatusSchema = z3.enum([
      "pending",
      "in_flight",
      "failed",
      "delivered",
      "dead"
    ]);
    WebhookDeliverySchema = z3.object({
      id: z3.string().regex(/^dlv_[a-f0-9]{16}$/),
      subscriptionId: z3.string(),
      eventType: z3.string(),
      payload: z3.string(),
      attempt: z3.number().int().min(0).max(5),
      status: WebhookDeliveryStatusSchema,
      nextAttemptAt: z3.number().int().nullable(),
      lastError: z3.string().nullable().optional(),
      deliveredAt: z3.number().int().nullable().optional()
    });
  }
});

export {
  Ok,
  Err,
  isOk,
  isErr,
  STANDARD_COGNITIVE_MODES,
  DEFAULT_SKILL_CONTEXT_BUDGET,
  SESSION_SECTION_NAMES,
  TrajectoryMetadataSchema,
  PromptCacheStatsSchema,
  OTLPKeyValueSchema,
  OTLPSpanSchema,
  TokenScopeSchema,
  BridgeKindSchema,
  AuthTokenSchema,
  AuthTokenPublicSchema,
  AuthAuditEntrySchema,
  WebhookSubscriptionSchema,
  WebhookSubscriptionPublicSchema,
  GatewayEventSchema,
  WebhookDeliveryStatusSchema,
  WebhookDeliverySchema,
  init_dist
};
