@enterstellar-ai/types 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +196 -0
- package/NOTICE +17 -0
- package/README.md +119 -0
- package/dist/index.cjs +458 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2297 -0
- package/dist/index.d.ts +2297 -0
- package/dist/index.js +428 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/version.ts","../src/errors.ts","../src/brands.ts","../src/contract.ts","../src/token.ts","../src/intent.ts","../src/compiler.ts","../src/trace.ts","../src/config.ts","../src/telemetry.ts","../src/state.ts","../src/connection.ts","../src/semantic-index.ts","../src/forge.ts","../src/guards.ts"],"names":["z"],"mappings":";;;AASO,IAAM,0BAAA,GAA6B;;;AC4JnC,IAAM,iBAAA,GAAN,MAAM,kBAAA,SAA0B,KAAA,CAAM;AAAA;AAAA;AAAA;AAAA;AAAA,EAKzB,IAAA;AAAA;AAAA,EAGA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWhB,YACI,IAAA,EACA,MAAA,EACA,OAAA,EACA,WAAA,GAAuB,OACvB,KAAA,EACF;AACE,IAAA,KAAA,CAAM,OAAA,EAAS,EAAE,KAAA,EAAO,CAAA;AACxB,IAAA,IAAA,CAAK,IAAA,GAAO,mBAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,WAAA,GAAc,WAAA;AACnB,IAAA,IAAA,CAAK,SAAA,GAAA,iBAAY,IAAI,IAAA,EAAK,EAAE,WAAA,EAAY;AAGxC,IAAA,IAAI,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KAAM,QAAA,IAC5B,OAAO,GAAA,CAAI,SAAS,CAAA,KAAM,QAAA,IAC1B,GAAA,CAAI,SAAS,CAAA,KAAM,IAAA,IACnB,OAAO,GAAA,CAAI,WAAW,CAAA,KAAM,QAAA;AAEpC","file":"index.js","sourcesContent":["/**\n * @module @enterstellar-ai/types/version\n * @description Enterstellar Types package version constant.\n *\n * Exported for runtime compatibility checks and DevTools version display.\n * @see Design Choice T14\n */\n\n/** Current version of the @enterstellar-ai/types package. Follows semver. */\nexport const ENTERSTELLAR_TYPES_VERSION = '0.1.0' as const;\n","/**\n * @module @enterstellar-ai/types/errors\n * @description Enterstellar error class and error code taxonomy.\n *\n * All Enterstellar errors extend `EnterstellarError`, carrying a machine-readable `code`,\n * the originating `module`, and whether the error is `recoverable`.\n *\n * Error code ranges:\n * - `ENS-1xxx` — Registry errors\n * - `ENS-2xxx` — Compiler errors\n * - `ENS-3xxx` — Lifecycle / Zone errors\n * - `ENS-4xxx` — Forge / State errors\n * - `ENS-5xxx` — Cloud / Index errors\n * - `ENS-6xxx` — Normalizer errors\n * - `ENS-7xxx` — Adapter errors\n * - `ENS-8xxx` — Agent SDK errors\n * - `ENS-9xxx` — CLI errors\n *\n * @see Coding Rules — Error Taxonomy\n * @see Design Choice C14\n */\n\n// ---------------------------------------------------------------------------\n// Error Code Type\n// ---------------------------------------------------------------------------\n\n/**\n * Machine-readable error code following the `ENS-XXXX` convention.\n * Each code maps to documentation at `enterstellar.dev/errors/ENS-XXXX`.\n */\nexport type EnterstellarErrorCode =\n // Registry (1xxx)\n | 'ENS-1001'\n | 'ENS-1002'\n | 'ENS-1003'\n | 'ENS-1004'\n | 'ENS-1005'\n | 'ENS-1006'\n | 'ENS-1007'\n | 'ENS-1008'\n | 'ENS-1009'\n | 'ENS-1010'\n // Compiler (2xxx)\n | 'ENS-2001'\n | 'ENS-2002'\n | 'ENS-2003'\n | 'ENS-2004'\n | 'ENS-2005'\n | 'ENS-2006'\n | 'ENS-2007'\n | 'ENS-2008'\n | 'ENS-2009'\n | 'ENS-2010'\n // Lifecycle / Zone (3xxx)\n | 'ENS-3001'\n | 'ENS-3002'\n | 'ENS-3003'\n | 'ENS-3004'\n | 'ENS-3005'\n | 'ENS-3010'\n // Forge / State (4xxx)\n | 'ENS-4001'\n | 'ENS-4002'\n | 'ENS-4003'\n | 'ENS-4004'\n | 'ENS-4005'\n | 'ENS-4006'\n | 'ENS-4007'\n // Cloud / Index / Test (5xxx)\n | 'ENS-5001'\n | 'ENS-5002'\n | 'ENS-5003'\n | 'ENS-5004'\n | 'ENS-5005'\n | 'ENS-5006'\n | 'ENS-5007'\n | 'ENS-5008'\n | 'ENS-5009'\n | 'ENS-5010'\n // Semantic Index (5020–5025)\n | 'ENS-5020'\n | 'ENS-5021'\n | 'ENS-5022'\n | 'ENS-5023'\n | 'ENS-5024'\n | 'ENS-5025'\n // Normalizer (6xxx)\n | 'ENS-6001'\n | 'ENS-6002'\n | 'ENS-6003'\n | 'ENS-6004'\n | 'ENS-6005'\n // Adapters (7xxx)\n | 'ENS-7001'\n | 'ENS-7002'\n | 'ENS-7003'\n | 'ENS-7004'\n | 'ENS-7005'\n // Agent SDK (8xxx)\n | 'ENS-8001'\n | 'ENS-8002'\n | 'ENS-8003'\n | 'ENS-8004'\n | 'ENS-8005'\n // CLI (9xxx)\n | 'ENS-9001'\n | 'ENS-9002'\n | 'ENS-9003'\n | 'ENS-9004'\n | 'ENS-9005'\n | 'ENS-9006'\n // Global Index (5030–5039)\n | 'ENS-5030'\n | 'ENS-5031'\n | 'ENS-5032'\n | 'ENS-5033'\n | 'ENS-5034'\n | 'ENS-5035';\n\n// ---------------------------------------------------------------------------\n// Error Module Type\n// ---------------------------------------------------------------------------\n\n/** The Enterstellar module that originated the error. */\nexport type EnterstellarErrorModule =\n | 'types'\n | 'registry'\n | 'compiler'\n | 'state'\n | 'telemetry'\n | 'react'\n | 'connection'\n | 'lifecycle'\n | 'normalizer'\n | 'forge'\n | 'cache'\n | 'semantic-index'\n | 'cloud'\n | 'global-index'\n | 'agent-sdk'\n | 'devtools'\n | 'test'\n | 'cli'\n | 'adapters';\n\n// ---------------------------------------------------------------------------\n// EnterstellarError Class\n// ---------------------------------------------------------------------------\n\n/**\n * Base error class for all Enterstellar errors.\n *\n * Extends the native `Error` with structured metadata for observability,\n * DevTools integration, and programmatic error handling.\n *\n * @example\n * ```ts\n * throw new EnterstellarError(\n * 'ENS-1001',\n * 'registry',\n * 'Component \"Foo\" is already registered.',\n * true, // recoverable\n * );\n * ```\n */\nexport class EnterstellarError extends Error {\n /**\n * Machine-readable error code.\n * Maps to documentation at `enterstellar.dev/errors/{code}`.\n */\n public readonly code: EnterstellarErrorCode;\n\n /** The Enterstellar module that originated this error. */\n public readonly module: EnterstellarErrorModule;\n\n /**\n * Whether the error is recoverable.\n * Recoverable errors can be retried or handled gracefully.\n * Non-recoverable errors indicate fatal conditions.\n */\n public readonly recoverable: boolean;\n\n /**\n * ISO 8601 timestamp of when the error was created.\n * Useful for trace correlation and debugging.\n */\n public readonly timestamp: string;\n\n /**\n * Creates a new `EnterstellarError`.\n *\n * @param code - Machine-readable error code (e.g., `'ENS-1001'`).\n * @param module - The Enterstellar module that originated the error.\n * @param message - Human-readable error message.\n * @param recoverable - Whether the error can be retried or handled gracefully.\n * @param cause - Optional underlying error that caused this error.\n */\n constructor(\n code: EnterstellarErrorCode,\n module: EnterstellarErrorModule,\n message: string,\n recoverable: boolean = false,\n cause?: unknown,\n ) {\n super(message, { cause });\n this.name = 'EnterstellarError';\n this.code = code;\n this.module = module;\n this.recoverable = recoverable;\n this.timestamp = new Date().toISOString();\n\n // Preserve proper stack trace in V8 environments\n if ('captureStackTrace' in Error) {\n (Error as unknown as { captureStackTrace: (target: object, ctor: (...args: unknown[]) => unknown) => void }).captureStackTrace(this, EnterstellarError as unknown as (...args: unknown[]) => unknown);\n }\n }\n\n /**\n * Serializes the error to a plain object for logging, telemetry, or DevTools.\n *\n * @returns A plain object representation of the error.\n */\n public toJSON(): {\n name: string;\n code: EnterstellarErrorCode;\n module: EnterstellarErrorModule;\n message: string;\n recoverable: boolean;\n timestamp: string;\n stack: string | undefined;\n } {\n return {\n name: this.name,\n code: this.code,\n module: this.module,\n message: this.message,\n recoverable: this.recoverable,\n timestamp: this.timestamp,\n stack: this.stack,\n };\n }\n}\n","/**\n * @module @enterstellar-ai/types/brands\n * @description Branded types for type-safe identifiers across the Enterstellar ecosystem.\n *\n * Branded types prevent accidentally passing a zone name where a component ID\n * is expected, or using a plain string where a trace ID is required.\n *\n * @see Design Choice T10\n *\n * @example\n * ```ts\n * import { createComponentId, createZoneId, createTraceId } from '@enterstellar-ai/types';\n *\n * const compId = createComponentId('PatientVitals');\n * const zoneId = createZoneId('main-content');\n * const traceId = createTraceId();\n * ```\n */\n\nimport { EnterstellarError } from './errors.js';\n\n// ---------------------------------------------------------------------------\n// Branded Type Definitions\n// ---------------------------------------------------------------------------\n\n/**\n * A branded string identifying a registered component.\n * Prevents accidental misuse of plain strings as component identifiers.\n */\nexport type ComponentId = string & { readonly __brand: 'ComponentId' };\n\n/**\n * A branded string identifying an Zone instance.\n * Ensures zone references are explicit and type-checked.\n */\nexport type ZoneId = string & { readonly __brand: 'ZoneId' };\n\n/**\n * A branded string identifying an AgentTrace record.\n * Guarantees trace references are unique and type-safe.\n */\nexport type TraceId = string & { readonly __brand: 'TraceId' };\n\n// ---------------------------------------------------------------------------\n// Constructor Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Creates a type-safe `ComponentId` from a PascalCase component name.\n *\n * @param name - PascalCase component name, must be non-empty.\n * @returns A branded `ComponentId`.\n * @throws {EnterstellarError} `ENS-1009` if `name` is empty or contains only whitespace.\n *\n * @example\n * ```ts\n * const id = createComponentId('PatientVitals');\n * ```\n */\nexport function createComponentId(name: string): ComponentId {\n if (!name.trim()) {\n throw new EnterstellarError(\n 'ENS-1009',\n 'types',\n '[ENS-1009] ComponentId name must be a non-empty string.',\n false,\n );\n }\n return name as ComponentId;\n}\n\n/**\n * Creates a type-safe `ZoneId` from a zone name.\n *\n * @param name - Zone name, must be non-empty. Typically kebab-case.\n * @returns A branded `ZoneId`.\n * @throws {EnterstellarError} `ENS-1009` if `name` is empty or contains only whitespace.\n *\n * @example\n * ```ts\n * const id = createZoneId('patient-sidebar');\n * ```\n */\nexport function createZoneId(name: string): ZoneId {\n if (!name.trim()) {\n throw new EnterstellarError(\n 'ENS-1009',\n 'types',\n '[ENS-1009] ZoneId name must be a non-empty string.',\n false,\n );\n }\n return name as ZoneId;\n}\n\n/**\n * Creates a type-safe `TraceId` using a UUIDv4.\n *\n * @returns A branded `TraceId` backed by a cryptographically random UUID.\n *\n * @example\n * ```ts\n * const id = createTraceId();\n * // e.g., \"c0a80164-b1c2-4d3e-a456-789012345678\"\n * ```\n */\nexport function createTraceId(): TraceId {\n return globalThis.crypto.randomUUID() as TraceId;\n}\n","/**\n * @module @enterstellar-ai/types/contract\n * @description ComponentContract — the canonical data shape for registering\n * a component in the Enterstellar ecosystem.\n *\n * A `ComponentContract` is pure data: schema, metadata, accessibility, and\n * design tokens. It has **no `render` field** — rendering is handled by\n * platform-specific renderer packages (`@enterstellar-ai/react`, `@enterstellar-ai/render-native`, etc.)\n * per Design Choice R6.\n *\n * @see Bible §3.1\n * @see Design Choices R1–R20, T1, T5, T9, T11\n */\n\nimport { z } from 'zod';\n\nimport type { ComponentId } from './brands.js';\n\n// ---------------------------------------------------------------------------\n// String Union Types\n// ---------------------------------------------------------------------------\n\n/**\n * Predefined component categories.\n * Extensible via `custom:{name}` prefix for domain-specific categories.\n *\n * @see Design Choice R11\n */\nexport type ComponentCategory =\n | 'clinical'\n | 'admin'\n | 'navigation'\n | 'data-display'\n | 'form'\n | 'feedback'\n | 'layout'\n | 'utility'\n | `custom:${string}`;\n\n// ---------------------------------------------------------------------------\n// Nested Data Types (per T11 — standalone named types)\n// ---------------------------------------------------------------------------\n\n/**\n * Origin metadata for contracts fetched from federated registries.\n * Populated when a contract is published or discovered remotely.\n */\nexport type ContractOrigin = {\n /** URL of the remote registry that published this contract. */\n readonly registryUrl: string;\n /** Publisher identifier (e.g., org name or developer handle). */\n readonly publisher: string;\n /** ISO 8601 timestamp when the contract was verified. */\n readonly verifiedAt?: string;\n};\n\n/**\n * Internal metadata attached to every contract.\n * Used for DevTools, telemetry, and Forge tracking.\n */\nexport type ContractMeta = {\n /** Whether this contract was generated by the Forge. */\n readonly forged: boolean;\n /** Semantic version of the contract definition. */\n readonly version: string;\n /** ISO 8601 timestamp when the contract was created. */\n readonly createdAt: string;\n};\n\n/**\n * Accessibility configuration for a component.\n * Enforced by the compiler's accessibility audit step.\n */\nexport type ComponentAccessibility = {\n /** WAI-ARIA role for the component's root element. */\n readonly role: string;\n /** Accessible label describing the component. */\n readonly ariaLabel: string;\n /** Whether screen readers should announce dynamic updates. */\n readonly announceOnUpdate: boolean;\n};\n\n/**\n * Data source configuration for adapter-driven data fetching.\n * Optional — components without a data source receive props directly.\n */\nexport type ComponentDataSource = {\n /** Adapter type used to fetch data (e.g., `'supabase'`, `'firebase'`). */\n readonly adapter: string;\n /** The resource/table/collection to query. */\n readonly resource: string;\n /** Static query parameters merged with runtime params. */\n readonly params?: Readonly<Record<string, unknown>>;\n};\n\n/**\n * Auth requirements for rendering a component.\n * When defined, the `AuthAdapter` gates component visibility.\n */\nexport type ComponentAuth = {\n /** Whether the user must be authenticated to view this component. */\n readonly required: boolean;\n /** Roles permitted to view this component. Empty = any authenticated user. */\n readonly roles: readonly string[];\n};\n\n/**\n * Example data for a component contract.\n * Powers the test harness, semantic index warmup, and DevTools previews.\n *\n * @see Design Choice R10\n */\nexport type ComponentExample = {\n /** Machine-readable canonical intent query for this component. */\n readonly intent: string;\n /** Example props matching the component's schema. */\n readonly props: Readonly<Record<string, unknown>>;\n};\n\n/**\n * Lifecycle state renderers — each component must declare placeholder\n * content for all four lifecycle states.\n *\n * @see Principle L9\n */\nexport type ComponentStates = {\n /** Renderer key or content for the loading state. */\n readonly loading: string;\n /** Renderer key or content for the error state. */\n readonly error: string;\n /** Renderer key or content for the empty state. */\n readonly empty: string;\n /** Renderer key or content for the ready state. */\n readonly ready: string;\n};\n\n// ---------------------------------------------------------------------------\n// ComponentContract Type\n// ---------------------------------------------------------------------------\n\n/**\n * The canonical data shape for a registered Enterstellar component.\n *\n * A `ComponentContract` is the \"API surface\" of a UI component within the\n * Enterstellar ecosystem. It declares the component's schema (via Zod), semantics,\n * accessibility requirements, design tokens, and lifecycle states.\n *\n * **Important:** This type has NO `render` field. Rendering is decoupled\n * from the contract and handled by platform-specific renderers (L15, R6).\n *\n * @see Bible §3.1\n */\nexport type ComponentContract = {\n /** PascalCase component name, unique within the registry. */\n readonly name: string;\n /** Branded component identifier derived from the name. */\n readonly id: ComponentId;\n /** Concise human-readable description. Max 120 characters (R2). */\n readonly description: string;\n /** Component category for classification and Forge routing. */\n readonly category: ComponentCategory;\n /** Semantic tags for fuzzy matching. Overlap between components is expected (R12). */\n readonly tags: readonly string[];\n /**\n * Zod schema defining the component's prop interface.\n * Used by the compiler for validation and self-correction.\n */\n readonly props: z.ZodType;\n /** Design tokens referenced by this component. Values are symbolic (e.g., `'token:danger'`). */\n readonly tokens: Readonly<Record<string, string>>;\n /** Accessibility configuration. Enforced by the compiler. */\n readonly accessibility: ComponentAccessibility;\n /** Lifecycle state renderers. All four states are required (L9). */\n readonly states: ComponentStates;\n /** Example data for testing, warmup, and previews. */\n readonly examples: readonly ComponentExample[];\n /** Optional data source configuration for adapter-driven fetching. */\n readonly dataSource?: ComponentDataSource;\n /** Optional auth requirements for gating component visibility. */\n readonly auth?: ComponentAuth;\n /** Optional origin metadata for federated/remote contracts. */\n readonly origin?: ContractOrigin;\n /** Internal metadata for DevTools and telemetry. */\n readonly _meta: ContractMeta;\n};\n\n// ---------------------------------------------------------------------------\n// Zod Schema\n// ---------------------------------------------------------------------------\n\n/**\n * Zod schema for validating `ComponentContract` data at runtime.\n *\n * Used by consumers to validate contracts fetched from remote registries,\n * and internally by `@enterstellar-ai/registry` during registration.\n *\n * @see Design Choice T7\n */\nexport const ComponentContractSchema = z.object({\n name: z.string().min(1, 'Component name is required.'),\n id: z.string().min(1, 'Component ID is required.'),\n description: z\n .string()\n .min(1, 'Description is required.')\n .max(120, 'Description must be 120 characters or fewer (R2).'),\n category: z.string().min(1, 'Category is required.'),\n tags: z.array(z.string()).min(1, 'At least one tag is required (R3).'),\n props: z.unknown(),\n tokens: z.record(z.string(), z.string()),\n accessibility: z.object({\n role: z.string().min(1, 'Accessibility role is required.'),\n ariaLabel: z.string().min(1, 'Accessibility ariaLabel is required.'),\n announceOnUpdate: z.boolean(),\n }),\n states: z.object({\n loading: z.string().min(1),\n error: z.string().min(1),\n empty: z.string().min(1),\n ready: z.string().min(1),\n }),\n examples: z.array(\n z.object({\n intent: z.string().min(1),\n props: z.record(z.string(), z.unknown()),\n }),\n ),\n dataSource: z\n .object({\n adapter: z.string().min(1),\n resource: z.string().min(1),\n params: z.record(z.string(), z.unknown()).optional(),\n })\n .optional(),\n auth: z\n .object({\n required: z.boolean(),\n roles: z.array(z.string()),\n })\n .optional(),\n origin: z\n .object({\n registryUrl: z.url(),\n publisher: z.string().min(1),\n verifiedAt: z.string().optional(),\n })\n .optional(),\n _meta: z.object({\n forged: z.boolean(),\n version: z.string().min(1),\n createdAt: z.string().min(1),\n }),\n});\n","/**\n * @module @enterstellar-ai/types/token\n * @description Design token types and resolver interface.\n *\n * Design tokens are symbolic references (e.g., `'token:danger'`) that the\n * compiler validates and the renderer resolves to concrete CSS values at\n * render time. This keeps contracts platform-agnostic and theme-portable.\n *\n * @see Bible §3.1b\n * @see Design Choices R13, R14\n * @see Appendix F T3 (W3C DTCG compliance)\n */\n\nimport { z } from 'zod';\n\n// ---------------------------------------------------------------------------\n// Design Token Set\n// ---------------------------------------------------------------------------\n\n/**\n * A map of token names to symbolic token values.\n *\n * Values follow the `token:{name}` convention (e.g., `'token:danger'`,\n * `'token:card-bg'`). Actual CSS values are resolved at render time\n * by the platform-specific `TokenResolver`.\n *\n * @see Design Choice R13 — tokens resolved at render time, not registration.\n * @see Design Choice R14 — no theming in DesignTokenSet; renderer handles themes.\n */\nexport type DesignTokenSet = Readonly<Record<string, string>>;\n\n/**\n * Zod schema for validating a `DesignTokenSet` at runtime.\n * Ensures all values are non-empty strings.\n */\nexport const DesignTokenSetSchema: z.ZodType<Record<string, string>> = z.record(\n z.string(),\n z.string().min(1, 'Token value must be a non-empty string.'),\n);\n\n// ---------------------------------------------------------------------------\n// Token Resolution Context\n// ---------------------------------------------------------------------------\n\n/**\n * Contextual information provided to the `TokenResolver` during\n * token resolution. Enables platform-aware and theme-aware lookups.\n */\nexport type TokenResolverContext = {\n /** Active platform for resolution (e.g., `'web'`, `'native'`, `'desktop'`). */\n readonly platform?: string;\n /** Active theme (e.g., `'light'`, `'dark'`). */\n readonly theme?: string;\n /** Display density (e.g., `'compact'`, `'comfortable'`, `'spacious'`). */\n readonly density?: string;\n};\n\n// ---------------------------------------------------------------------------\n// Token Resolver Interface\n// ---------------------------------------------------------------------------\n\n/**\n * Resolves symbolic design token paths to concrete CSS (or platform-specific) values.\n *\n * Implementations map W3C DTCG-compliant token paths to concrete values\n * based on the active platform, theme, and density context.\n *\n * @see Appendix F T3 — W3C DTCG path mapping.\n * @see Design Choice R13 — resolution happens at render time.\n * @see Design Choice R14 — the resolver handles light/dark mode, not the contract.\n *\n * @example\n * ```ts\n * const resolver: TokenResolver = {\n * resolve: (path, ctx) => {\n * if (path === 'token:danger') {\n * return ctx?.theme === 'dark' ? '#ff4444' : '#ff0000';\n * }\n * return undefined;\n * },\n * validate: (path) => path.startsWith('token:'),\n * };\n * ```\n */\nexport interface TokenResolver {\n /**\n * Resolves a token path to a concrete value.\n *\n * @param tokenPath - The symbolic token path (e.g., `'token:danger'`).\n * @param context - Optional resolution context (platform, theme, density).\n * @returns The resolved concrete value, or `undefined` if the token is unknown.\n */\n resolve(tokenPath: string, context?: TokenResolverContext): string | undefined;\n\n /**\n * Validates whether a token path exists in the active token set.\n *\n * @param tokenPath - The symbolic token path to validate.\n * @returns `true` if the token path is known and resolvable.\n */\n validate(tokenPath: string): boolean;\n}\n","/**\n * @module @enterstellar-ai/types/intent\n * @description ComponentIntent — the normalized message from an AI agent\n * to the Enterstellar rendering pipeline.\n *\n * A `ComponentIntent` is what the normalizer produces from any protocol\n * (AG-UI, A2UI, MCP, WebSocket, SSE). It is the universal input to the\n * compiler.\n *\n * @see Bible §3.2\n * @see Design Choices T3, T11\n * @see Appendix E P2 (correlationId), P8 (mode, interaction)\n */\n\nimport { z } from 'zod';\n\n// ---------------------------------------------------------------------------\n// String Union Types\n// ---------------------------------------------------------------------------\n\n/**\n * Protocol that produced this intent.\n * Each normalizer handles one protocol.\n *\n * @see Bible §4.9 — Normalizer\n */\nexport type IntentProtocol =\n | 'ag-ui'\n | 'a2ui'\n | 'mcp'\n | 'websocket'\n | 'sse'\n | 'custom';\n\n/**\n * Layout hint for multi-zone rendering.\n * Used by the resolver to position components within a zone.\n */\nexport type IntentLayout =\n | 'single'\n | 'split'\n | 'grid'\n | 'stack'\n | 'tabs';\n\n/**\n * Interaction mode for the component.\n * Closed enum — 3 values are exhaustive.\n *\n * @see Appendix E P8\n */\nexport type IntentInteraction =\n | 'read-only'\n | 'editable'\n | 'actionable';\n\n// ---------------------------------------------------------------------------\n// Nested Data Types (per T11)\n// ---------------------------------------------------------------------------\n\n/**\n * Source metadata injected by the normalizer.\n * Preserves protocol-specific context for tracing and debugging.\n */\nexport type IntentSource = {\n /** The protocol that produced this intent. */\n readonly protocol: IntentProtocol;\n /** Raw event ID from the source protocol, if available. */\n readonly rawEventId?: string;\n /**\n * Correlation ID tying related events across a multi-step interaction chain.\n * Extracted from the protocol (AG-UI `runId`, MCP `requestId`) or UUIDv4-generated.\n *\n * @see Appendix E P2\n */\n readonly correlationId?: string;\n /** Raw payload from the source protocol, preserved for debugging. */\n readonly raw?: unknown;\n};\n\n// ---------------------------------------------------------------------------\n// ComponentIntent Type\n// ---------------------------------------------------------------------------\n\n/**\n * The normalized message from an AI agent to the Enterstellar rendering pipeline.\n *\n * Produced by the normalizer from any supported protocol. Consumed by the\n * compiler for validation, token enforcement, and accessibility auditing.\n *\n * @see Bible §3.2\n */\nexport type ComponentIntent = {\n /** PascalCase name of the target component in the registry. */\n readonly component: string;\n /** Props to pass to the component, validated by the compiler against the contract schema. */\n readonly props: Readonly<Record<string, unknown>>;\n /**\n * Confidence score from the agent (0.0–1.0).\n * Used by the compiler for fallback decisions and trace reporting.\n */\n readonly confidence: number;\n /** Optional layout hint for multi-zone rendering. */\n readonly layout?: IntentLayout;\n /**\n * Display mode hint for disambiguation.\n * Open type — allows domain-specific modes without requiring `@enterstellar-ai/types` releases.\n * Recommended values: `'snapshot'`, `'time-series'`, `'comparison'`, `'detail'`,\n * `'summary'`, `'list'`.\n *\n * @see Appendix E P8\n */\n readonly mode?: string;\n /**\n * Interaction mode for the component.\n * Helps the semantic index disambiguate (e.g., \"show vitals\" vs \"edit vitals\").\n *\n * @see Appendix E P8\n */\n readonly interaction?: IntentInteraction;\n /** Protocol-specific source metadata injected by the normalizer. */\n readonly _source?: IntentSource;\n};\n\n// ---------------------------------------------------------------------------\n// Zod Schema\n// ---------------------------------------------------------------------------\n\n/**\n * Zod schema for validating `ComponentIntent` data at runtime.\n *\n * @see Design Choice T7\n */\nexport const ComponentIntentSchema = z.object({\n component: z.string().min(1, 'Component name is required.'),\n props: z.record(z.string(), z.unknown()),\n confidence: z\n .number()\n .min(0, 'Confidence must be >= 0.')\n .max(1, 'Confidence must be <= 1.'),\n layout: z\n .enum(['single', 'split', 'grid', 'stack', 'tabs'])\n .optional(),\n mode: z.string().optional(),\n interaction: z\n .enum(['read-only', 'editable', 'actionable'])\n .optional(),\n _source: z\n .object({\n protocol: z.enum([\n 'ag-ui',\n 'a2ui',\n 'mcp',\n 'websocket',\n 'sse',\n 'custom',\n ]),\n rawEventId: z.string().optional(),\n correlationId: z.string().optional(),\n raw: z.unknown().optional(),\n })\n .optional(),\n});\n","/**\n * @module @enterstellar-ai/types/compiler\n * @description Compilation result types — the output of the Enterstellar UI Compiler.\n *\n * After the compiler validates a `ComponentIntent` against its\n * `ComponentContract`, it produces a `CompilationResult` with provenance,\n * validation status, and any errors encountered.\n *\n * @see Bible §3.3\n * @see Design Choices C1–C20, T1, T5, T11\n */\n\nimport { z } from 'zod';\n\n// ---------------------------------------------------------------------------\n// String Union Types\n// ---------------------------------------------------------------------------\n\n/**\n * Compilation outcome status.\n * - `'pass'` — intent validated successfully, component is safe to render.\n * - `'fail'` — validation failed, fallback should be rendered.\n * - `'corrected'` — LLM self-correction fixed the original errors.\n */\nexport type CompilationStatus = 'pass' | 'fail' | 'corrected';\n\n// ---------------------------------------------------------------------------\n// Nested Data Types (per T11 — standalone named types)\n// ---------------------------------------------------------------------------\n\n/**\n * Provenance metadata attached to every compilation result.\n * Tracks the agent, registry, and compiler that produced the result\n * for auditability and the trust frame.\n *\n * @see Design Choice C12 — consumer passes `agent` via explicit parameter.\n */\nexport type CompilationProvenance = {\n /** Identifier of the AI agent/model that generated the intent (e.g., `'gpt-4o'`). */\n readonly agent: string;\n /** URL or name of the registry used for component resolution. */\n readonly registry: string;\n /** ISO 8601 timestamp when compilation occurred. */\n readonly compiledAt: string;\n /** Semantic version of the compiler that produced this result. */\n readonly compilerVersion: string;\n /** Forge mode used, if the component was forged. `undefined` for registry components. */\n readonly forgeMode?: 'local' | 'cloud';\n /** Origin metadata for the resolved contract, if it came from a remote registry. */\n readonly contractOrigin?: {\n /** URL of the originating registry. */\n readonly registryUrl: string;\n /** Publisher of the contract. */\n readonly publisher: string;\n };\n};\n\n/**\n * Machine-readable suggestion for fixing a compilation error.\n * Enables auto-fix in DevTools, self-correction loops, and CI reporting.\n *\n * @see Design Choice C15\n */\nexport type CompilationFix = {\n /** The prop field path that should be changed (e.g., `'tokens.color'`). */\n readonly field: string;\n /** The invalid value that was provided. */\n readonly was: unknown;\n /** The correct value that should be used instead. */\n readonly shouldBe: unknown;\n};\n\n/**\n * A single compilation error with a machine-readable code, path, and optional fix.\n *\n * @see Design Choice C14 — `ENS-2xxx` codes for compiler errors.\n * @see Design Choice C15 — all errors include a `fix` suggestion where applicable.\n */\nexport type CompilationError = {\n /** Machine-readable error code (e.g., `'ENS-2001'`). */\n readonly code: string;\n /** Dot-path to the invalid field (e.g., `'props.riskLevel'`). */\n readonly path: string;\n /** Human-readable error message. */\n readonly message: string;\n /** The value that was received. */\n readonly received?: unknown;\n /** The value that was expected. */\n readonly expected?: unknown;\n /** Machine-readable fix suggestion, if applicable. */\n readonly fix?: CompilationFix;\n};\n\n// ---------------------------------------------------------------------------\n// CompilationResult Type\n// ---------------------------------------------------------------------------\n\n/**\n * The output of the Enterstellar UI Compiler after validating a `ComponentIntent`.\n *\n * Contains the resolved component name, validated props, compilation status,\n * provenance for auditability, and any errors encountered during validation.\n *\n * @see Bible §3.3\n */\nexport type CompilationResult = {\n /** PascalCase name of the resolved component. */\n readonly componentName: string;\n /** Validated props after schema parsing, token enforcement, and accessibility injection. */\n readonly props: Readonly<Record<string, unknown>>;\n /** Compilation outcome status. */\n readonly status: CompilationStatus;\n /** Provenance metadata for tracing and the trust frame. */\n readonly provenance: CompilationProvenance;\n /** Validation errors encountered during compilation. Empty if `status === 'pass'`. */\n readonly errors: readonly CompilationError[];\n /** Number of self-correction attempts made before final result. */\n readonly selfCorrectionAttempts: number;\n /**\n * Diff between raw LLM props and final compiled props.\n * Included when `includeDiff` config flag is `true` (default in dev, off in prod).\n *\n * @see Design Choice C13\n */\n readonly diff?: {\n /** The raw props as received from the agent. */\n readonly raw: Readonly<Record<string, unknown>>;\n /** The final compiled props after correction, stripping, and injection. */\n readonly compiled: Readonly<Record<string, unknown>>;\n };\n /**\n * Correction trace for DevTools and performance profiling.\n *\n * Populated when `selfCorrection.trace === true` in the compiler config.\n * Each entry records a single correction applied by Tier 1 (deterministic)\n * or Tier 2 (template), including the field, original value, corrected value,\n * and the strategy used.\n *\n * Default: omitted in production. Enabled automatically when DevTools are\n * attached, or explicitly via `selfCorrection: { trace: true }`.\n *\n * @see Design Choice SC-11 — correction trace entry design.\n * @see Design Choice SC-08 — `trace` flag in `SelfCorrectionConfig`.\n */\n readonly correctionTrace?: readonly {\n /** Which tier applied this correction (`1` = deterministic, `2` = template). */\n readonly tier: 1 | 2;\n /** The error code that was corrected (e.g., `'ENS-2001'`). */\n readonly errorCode: string;\n /** The field path that was corrected. */\n readonly field: string;\n /** The original invalid value. */\n readonly was: unknown;\n /** The corrected value. */\n readonly correctedTo: unknown;\n /** The correction strategy used (e.g., `'type-coercion'`, `'enum-nearest'`). */\n readonly strategy: string;\n }[];\n};\n\n// ---------------------------------------------------------------------------\n// Zod Schemas\n// ---------------------------------------------------------------------------\n\n/**\n * Zod schema for validating a `CompilationError` at runtime.\n *\n * @see Design Choice T7\n */\nexport const CompilationErrorSchema = z.object({\n code: z.string().min(1, 'Error code is required.'),\n path: z.string(),\n message: z.string().min(1, 'Error message is required.'),\n received: z.unknown().optional(),\n expected: z.unknown().optional(),\n fix: z\n .object({\n field: z.string().min(1),\n was: z.unknown(),\n shouldBe: z.unknown(),\n })\n .optional(),\n});\n\n/**\n * Zod schema for validating a `CompilationResult` at runtime.\n *\n * @see Design Choice T7\n */\nexport const CompilationResultSchema = z.object({\n componentName: z.string().min(1, 'Component name is required.'),\n props: z.record(z.string(), z.unknown()),\n status: z.enum(['pass', 'fail', 'corrected']),\n provenance: z.object({\n agent: z.string().min(1),\n registry: z.string().min(1),\n compiledAt: z.string().min(1),\n compilerVersion: z.string().min(1),\n forgeMode: z.enum(['local', 'cloud']).optional(),\n contractOrigin: z\n .object({\n registryUrl: z.string(),\n publisher: z.string(),\n })\n .optional(),\n }),\n errors: z.array(CompilationErrorSchema),\n selfCorrectionAttempts: z.number().int().min(0),\n diff: z\n .object({\n raw: z.record(z.string(), z.unknown()),\n compiled: z.record(z.string(), z.unknown()),\n })\n .optional(),\n correctionTrace: z\n .array(\n z.object({\n tier: z.union([z.literal(1), z.literal(2)]),\n errorCode: z.string().min(1),\n field: z.string().min(1),\n was: z.unknown(),\n correctedTo: z.unknown(),\n strategy: z.string().min(1),\n }),\n )\n .optional(),\n});\n","/**\n * @module @enterstellar-ai/types/trace\n * @description AgentTrace — the observability record for every Enterstellar pipeline execution.\n *\n * Every intent processed by Enterstellar produces an `AgentTrace` capturing intent,\n * resolution, compilation, determinism, and performance metrics. Traces power\n * the DevTools timeline, validation log, and performance profiler.\n *\n * @see Bible §3.4\n * @see Design Choices T5, T11\n * @see Appendix E P2 (correlationId), consent fields\n */\n\nimport { z } from 'zod';\n\nimport type { TraceId } from './brands.js';\nimport type { ComponentIntent } from './intent.js';\nimport type { CompilationProvenance, CompilationStatus, CompilationError } from './compiler.js';\nimport { CompilationErrorSchema } from './compiler.js';\nimport { ComponentIntentSchema } from './intent.js';\n\n// ---------------------------------------------------------------------------\n// Nested Data Types (per T11)\n// ---------------------------------------------------------------------------\n\n/**\n * Intent data captured in the trace.\n * Records what the agent requested.\n */\nexport type TraceIntent = {\n /** Raw intent string or component name from the agent. */\n readonly raw: string;\n /** Parsed component name after normalization. */\n readonly component: string;\n /** Confidence score from the agent (0.0–1.0). */\n readonly confidence: number;\n /** Display mode, if provided. */\n readonly mode?: string;\n /** Interaction type, if provided. */\n readonly interaction?: string;\n};\n\n/**\n * Resolution data captured in the trace.\n * Records how the intent was resolved to a component.\n */\nexport type TraceResolution = {\n /** How the component was resolved. */\n readonly strategy: 'exact' | 'semantic' | 'forge' | 'fallback';\n /** Name of the resolved component. */\n readonly resolvedComponent: string;\n /** Semantic similarity score, if semantic search was used. */\n readonly similarityScore?: number;\n /** Number of candidate components considered before selection. */\n readonly candidatesConsidered: number;\n};\n\n/**\n * Compilation data captured in the trace.\n * Records the compiler's validation outcome.\n */\nexport type TraceCompilation = {\n /** Final compilation status. */\n readonly status: 'pass' | 'fail' | 'corrected';\n /** Number of validation errors encountered (including self-corrected ones). */\n readonly errorCount: number;\n /** Number of self-correction attempts made. */\n readonly selfCorrectionAttempts: number;\n /** Whether design token enforcement was applied. */\n readonly tokensValidated: boolean;\n /** Whether accessibility attributes were auto-injected. */\n readonly accessibilityInjected: boolean;\n};\n\n/**\n * Determinism data captured in the trace.\n * Records the zone's determinism configuration at render time.\n */\nexport type TraceDeterminism = {\n /** Zone determinism level (0.0–1.0). */\n readonly level: number;\n /** Whether a cached result was used. */\n readonly cacheHit: boolean;\n /** The zone name this trace belongs to. */\n readonly zone: string;\n};\n\n/**\n * Performance metrics captured in the trace.\n * Powers the DevTools performance profiler.\n */\nexport type TraceMetrics = {\n /** Total pipeline latency in milliseconds (intent → rendered). */\n readonly totalMs: number;\n /** Time from intent reception to resolution in milliseconds. */\n readonly resolutionMs: number;\n /** Time from resolution to compilation completion in milliseconds. */\n readonly compilationMs: number;\n /** Time from compilation to rendered output in milliseconds. */\n readonly renderMs: number;\n};\n\n/**\n * User consent state for trace aggregation.\n * Required for Enterstellar Cloud's trace aggregation API (opt-in).\n *\n * @see Appendix E — TL10 (ForgeSignal vs AgentTrace consent distinction)\n */\nexport type TraceConsent = {\n /** Whether this trace can be aggregated anonymously for analytics. */\n readonly anonymizedAggregation: boolean;\n};\n\n// ---------------------------------------------------------------------------\n// ZoneTrace Type (Zone-level precursor)\n// ---------------------------------------------------------------------------\n\n/**\n * Partial trace produced by `Zone` during compilation.\n *\n * `ZoneTrace` captures what the zone actually has at compile time:\n * intent, compilation status/errors, provenance, and zone-level metrics.\n * It does NOT include `resolution`, `determinism`, or `consent` fields —\n * those require the full compiler/lifecycle pipeline to produce.\n *\n * The fully resolved `AgentTrace` is assembled downstream by\n * `@enterstellar-ai/lifecycle` when all pipeline stages are complete.\n *\n * @see {@link AgentTrace} — the fully resolved trace with all pipeline stages.\n * @see Bible §5.3 — Zone specification.\n * @see Design Choice RE18 — `onError` callback receives this trace type.\n */\nexport type ZoneTrace = {\n /** Unique zone-trace identifier (format: `{zoneName}-{compilationId}-{timestamp}`). */\n readonly id: string;\n /** The raw `ComponentIntent` that triggered compilation. */\n readonly intent: ComponentIntent;\n /**\n * Compilation outcome data — status, errors, and self-correction attempts.\n * This is a subset of the full `TraceCompilation` shape.\n */\n readonly compilation: {\n /** Final compilation status (`pass`, `fail`, or `corrected`). */\n readonly status: CompilationStatus;\n /** Validation errors encountered during compilation. */\n readonly errors: readonly CompilationError[];\n /** Number of self-correction attempts made before final result. */\n readonly selfCorrectionAttempts: number;\n };\n /** Provenance metadata from the `CompilationResult`. */\n readonly provenance: CompilationProvenance;\n /**\n * Zone-level performance metrics.\n *\n * Unlike `TraceMetrics` (which breaks down resolution/compilation/render),\n * this only captures total latency and retry attempt count.\n */\n readonly metrics: {\n /** Total time from intent reception to render in milliseconds. */\n readonly totalMs: number;\n /** Current retry attempt number (0-indexed). */\n readonly retryAttempt: number;\n };\n /** ISO 8601 timestamp when this trace was created. */\n readonly timestamp: string;\n};\n\n// ---------------------------------------------------------------------------\n// ZoneTrace Zod Schema (T7 — co-located schema for ZoneTrace)\n// ---------------------------------------------------------------------------\n\n/**\n * Zod schema for validating a `ZoneTrace` at runtime.\n *\n * This is the **canonical single-source-of-truth** for `ZoneTrace` validation.\n * Used by:\n * - `Provider` to register the `'traces'` store extension (S2).\n * - DevTools for trace data integrity validation.\n * - Tests for fixture construction.\n *\n * The schema reuses `ComponentIntentSchema` and `CompilationErrorSchema`\n * from their respective modules (T7: co-located schemas, no duplication).\n *\n * @see Design Choice T7 — every type has a co-located Zod schema.\n * @see Design Choice S2 — typed `store.extend()` requires a Zod schema.\n * @see {@link ZoneTrace} — the TypeScript type this schema validates.\n */\nexport const ZoneTraceSchema = z.object({\n /** Unique zone-trace identifier. */\n id: z.string().min(1, 'Zone trace ID is required.'),\n\n /** The raw ComponentIntent that triggered compilation. */\n intent: ComponentIntentSchema,\n\n /**\n * Compilation outcome data — status, errors, and self-correction attempts.\n * Subset of the full TraceCompilation shape.\n */\n compilation: z.object({\n /** Final compilation status. */\n status: z.enum(['pass', 'fail', 'corrected']),\n /** Validation errors encountered during compilation. */\n errors: z.array(CompilationErrorSchema),\n /** Number of self-correction attempts made before final result. */\n selfCorrectionAttempts: z.number().int().min(0),\n }),\n\n /**\n * Provenance metadata from the CompilationResult.\n * Mirrors the CompilationProvenance type shape exactly.\n */\n provenance: z.object({\n /** Identifier of the AI agent/model. */\n agent: z.string().min(1),\n /** URL or name of the registry used. */\n registry: z.string().min(1),\n /** ISO 8601 timestamp when compilation occurred. */\n compiledAt: z.string().min(1),\n /** Semantic version of the compiler. */\n compilerVersion: z.string().min(1),\n /** Forge mode used, if the component was forged. */\n forgeMode: z.enum(['local', 'cloud']).optional(),\n /** Origin metadata for remote contracts. */\n contractOrigin: z\n .object({\n registryUrl: z.string(),\n publisher: z.string(),\n })\n .optional(),\n }),\n\n /** Zone-level performance metrics. */\n metrics: z.object({\n /** Total time from intent reception to render in milliseconds. */\n totalMs: z.number().min(0),\n /** Current retry attempt number (0-indexed). */\n retryAttempt: z.number().int().min(0),\n }),\n\n /** ISO 8601 timestamp when this trace was created. */\n timestamp: z.string().min(1, 'Timestamp is required.'),\n});\n\n// ---------------------------------------------------------------------------\n// AgentTrace Type\n// ---------------------------------------------------------------------------\n\n/**\n * The complete observability record for a single Enterstellar pipeline execution.\n *\n * Produced on every `compile()` call. Stored in `EnterstellarStore.traces[]`.\n * Consumed by DevTools (timeline, inspector, profiler, replay) and\n * optionally by Enterstellar Cloud for aggregated analytics.\n *\n * @see Bible §3.4\n * @see {@link ZoneTrace} — the zone-level precursor trace produced by `Zone`.\n */\nexport type AgentTrace = {\n /** Unique trace identifier. */\n readonly id: TraceId;\n /** ISO 8601 timestamp when the trace was created. */\n readonly timestamp: string;\n /**\n * Correlation ID tying related events across a multi-step interaction chain.\n * Enables DevTools Trace Timeline to group related events.\n *\n * @see Appendix E P2\n */\n readonly correlationId?: string;\n /** Intent data: what the agent requested. */\n readonly intent: TraceIntent;\n /** Resolution data: how the component was found. */\n readonly resolution: TraceResolution;\n /** Compilation data: the compiler's validation outcome. */\n readonly compilation: TraceCompilation;\n /** Determinism data: the zone's configuration at render time. */\n readonly determinism: TraceDeterminism;\n /** Performance metrics: latency breakdown. */\n readonly metrics: TraceMetrics;\n /** User consent state for trace aggregation. */\n readonly consent: TraceConsent;\n};\n\n// ---------------------------------------------------------------------------\n// Zod Schema\n// ---------------------------------------------------------------------------\n\n/**\n * Zod schema for validating an `AgentTrace` at runtime.\n *\n * @see Design Choice T7\n */\nexport const AgentTraceSchema = z.object({\n id: z.string().min(1, 'Trace ID is required.'),\n timestamp: z.string().min(1, 'Timestamp is required.'),\n correlationId: z.string().optional(),\n intent: z.object({\n raw: z.string(),\n component: z.string().min(1),\n confidence: z.number().min(0).max(1),\n mode: z.string().optional(),\n interaction: z.string().optional(),\n }),\n resolution: z.object({\n strategy: z.enum(['exact', 'semantic', 'forge', 'fallback']),\n resolvedComponent: z.string().min(1),\n similarityScore: z.number().min(0).max(1).optional(),\n candidatesConsidered: z.number().int().min(0),\n }),\n compilation: z.object({\n status: z.enum(['pass', 'fail', 'corrected']),\n errorCount: z.number().int().min(0),\n selfCorrectionAttempts: z.number().int().min(0),\n tokensValidated: z.boolean(),\n accessibilityInjected: z.boolean(),\n }),\n determinism: z.object({\n level: z.number().min(0).max(1),\n cacheHit: z.boolean(),\n zone: z.string().min(1),\n }),\n metrics: z.object({\n totalMs: z.number().min(0),\n resolutionMs: z.number().min(0),\n compilationMs: z.number().min(0),\n renderMs: z.number().min(0),\n }),\n consent: z.object({\n anonymizedAggregation: z.boolean(),\n }),\n});\n","/**\n * @module @enterstellar-ai/types/config\n * @description ZoneConfig — configuration for an Zone instance.\n *\n * A `ZoneConfig` defines the behavior, constraints, and rendering rules\n * for a specific Zone. The `determinism` dial (0.0–1.0) controls\n * how much AI influence the zone allows.\n *\n * @see Bible §3.5\n * @see Design Choices T13 (determinism as raw number), RE5–RE8\n */\n\nimport { z } from 'zod';\n\nimport type { ZoneId } from './brands.js';\n\n// ---------------------------------------------------------------------------\n// Nested Data Types\n// ---------------------------------------------------------------------------\n\n/**\n * Cache configuration for a zone.\n * Controls whether and how the zone caches compiled results.\n */\nexport type ZoneCacheConfig = {\n /** Whether caching is enabled for this zone. */\n readonly enabled: boolean;\n /** Time-to-live for cached entries in seconds. Default: 3600. */\n readonly ttl: number;\n};\n\n// ---------------------------------------------------------------------------\n// ZoneConfig Type\n// ---------------------------------------------------------------------------\n\n/**\n * Configuration for an Zone instance.\n *\n * The `determinism` value is the primary control:\n * - `0.0` → fully static, agent never called (compliance zones)\n * - `0.0–1.0` → hybrid: fixed layout with agent-selected components in slots\n * - `1.0` → fully dynamic, agent controls everything in the zone\n *\n * @see Bible §3.5\n * @see Design Choice T13 — raw number with Zod validation, not branded type.\n */\nexport type ZoneConfig = {\n /** Branded zone identifier. */\n readonly id: ZoneId;\n /** Human-readable zone name (e.g., `'patient-sidebar'`). */\n readonly name: string;\n /**\n * Determinism level (0.0–1.0).\n * Controls AI influence over the zone's content.\n *\n * @see Design Choice T13 — validated via `z.number().min(0).max(1)`.\n */\n readonly determinism: number;\n /** Whitelist of component names allowed in this zone. Empty = all allowed. */\n readonly allowedComponents: readonly string[];\n /** Fallback component name to render when the agent fails or times out. */\n readonly fallbackComponent: string;\n /** Maximum time in milliseconds to wait for the agent before rendering fallback. */\n readonly agentTimeoutMs: number;\n /** Cache configuration for this zone. */\n readonly cache: ZoneCacheConfig;\n /**\n * Zone activation strategy.\n * - `'mount'` — call agent on component mount (default).\n * - `'visible'` — call agent when zone enters viewport (IntersectionObserver).\n * - `'manual'` — consumer calls `zone.activate()` programmatically.\n *\n * @see Design Choice RE6\n */\n readonly activateOn: 'mount' | 'visible' | 'manual';\n};\n\n// ---------------------------------------------------------------------------\n// Zod Schema\n// ---------------------------------------------------------------------------\n\n/**\n * Zod schema for validating `ZoneConfig` data at runtime.\n *\n * @see Design Choice T7, T13\n */\nexport const ZoneConfigSchema = z.object({\n id: z.string().min(1, 'Zone ID is required.'),\n name: z.string().min(1, 'Zone name is required.'),\n determinism: z\n .number()\n .min(0, 'Determinism must be >= 0.')\n .max(1, 'Determinism must be <= 1.'),\n allowedComponents: z.array(z.string()),\n fallbackComponent: z.string().min(1, 'Fallback component is required.'),\n agentTimeoutMs: z.number().int().positive('Agent timeout must be positive.'),\n cache: z.object({\n enabled: z.boolean(),\n ttl: z.number().int().positive('TTL must be positive.'),\n }),\n activateOn: z.enum(['mount', 'visible', 'manual']),\n});\n","/**\n * @module @enterstellar-ai/types/telemetry\n * @description ForgeSignal — the mandatory telemetry payload for every compilation.\n *\n * ForgeSignals are the atomic unit of the ForgeSignal Corpus (M2 moat).\n * They contain ZERO PII — only hashed intents, component names, and metrics.\n * Every render emits a ForgeSignal; this is non-negotiable (L12).\n *\n * @see Bible §3.7\n * @see Design Choices TL1–TL12, T12\n * @see Principle L12\n */\n\nimport { z } from 'zod';\n\n// ---------------------------------------------------------------------------\n// String Union Types\n// ---------------------------------------------------------------------------\n\n/**\n * Classification of the intent that produced this signal.\n * Fixed set — not consumer-extensible. Updated only in `@enterstellar-ai/types` releases.\n *\n * @see Design Choice T12\n */\nexport type IntentCategory =\n | 'clinical'\n | 'admin'\n | 'navigation'\n | 'data-display'\n | 'form'\n | 'feedback'\n | 'utility';\n\n/**\n * Forge mode that generated the component (if forged).\n * `'none'` indicates the component came from the registry (no forge).\n */\nexport type ForgeMode = 'none' | 'local' | 'cloud';\n\n/**\n * Platform that produced this signal.\n * Auto-set by the renderer package — never consumer-configured (P9).\n */\nexport type SignalPlatform = 'web' | 'native' | 'desktop' | 'cli' | 'unknown';\n\n// ---------------------------------------------------------------------------\n// ForgeSignal Type\n// ---------------------------------------------------------------------------\n\n/**\n * The mandatory telemetry payload emitted after every Enterstellar compilation.\n *\n * ForgeSignals are the training data for the Intent Router (M4) and\n * Forge Model (M5). They power the self-reinforcing data flywheel.\n *\n * **PII policy:** Zero PII. The `intentHash` is a SHA-256 of the raw intent —\n * the raw string never leaves the device.\n *\n * @see Bible §3.7\n * @see Design Choice TL3 — hashing happens in `record()`, not caller.\n */\nexport type ForgeSignal = {\n /** SHA-256 hash of the raw intent string. No PII. */\n readonly intentHash: string;\n /** PascalCase name of the resolved component. */\n readonly componentName: string;\n /** Classification of the intent. */\n readonly intentCategory: IntentCategory;\n /** Whether compilation passed, failed, or was corrected. */\n readonly compilationStatus: 'pass' | 'fail' | 'corrected';\n /** Whether the Forge was used, and which mode. */\n readonly forgeMode: ForgeMode;\n /** Whether the Forge was invoked at all. */\n readonly forgeUsed: boolean;\n /** Total pipeline latency from intent to rendered output, in milliseconds. */\n readonly latencyMs: number;\n /** Number of self-correction attempts before final result. */\n readonly selfCorrectionAttempts: number;\n /**\n * Token usage for self-correction calls, if any.\n * Tracked for cost observability, not enforced with a hard budget (C7).\n */\n readonly correctionTokensUsed: number;\n /** ISO 8601 timestamp when the signal was recorded. */\n readonly timestamp: string;\n /** Semantic version of the Enterstellar SDK that produced this signal. */\n readonly sdkVersion: string;\n /** Number of components in the registry at the time of this signal. */\n readonly registrySize: number;\n /** Platform that produced this signal. */\n readonly platform: SignalPlatform;\n};\n\n// ---------------------------------------------------------------------------\n// Zod Schema\n// ---------------------------------------------------------------------------\n\n/**\n * Zod schema for validating a `ForgeSignal` at runtime.\n *\n * @see Design Choice T7\n */\nexport const ForgeSignalSchema = z.object({\n intentHash: z.string().min(1, 'Intent hash is required.'),\n componentName: z.string().min(1, 'Component name is required.'),\n intentCategory: z.enum([\n 'clinical',\n 'admin',\n 'navigation',\n 'data-display',\n 'form',\n 'feedback',\n 'utility',\n ]),\n compilationStatus: z.enum(['pass', 'fail', 'corrected']),\n forgeMode: z.enum(['none', 'local', 'cloud']),\n forgeUsed: z.boolean(),\n latencyMs: z.number().min(0),\n selfCorrectionAttempts: z.number().int().min(0),\n correctionTokensUsed: z.number().int().min(0),\n timestamp: z.string().min(1, 'Timestamp is required.'),\n sdkVersion: z.string().min(1, 'SDK version is required.'),\n registrySize: z.number().int().min(0),\n platform: z.enum(['web', 'native', 'desktop', 'cli', 'unknown']),\n});\n","/**\n * @module @enterstellar-ai/types/state\n * @description EnterstellarStore — the framework-agnostic persistent state container.\n *\n * The EnterstellarStore is the \"OS's memory.\" It holds zone state, trace history,\n * and session metadata. It is a pure TypeScript interface with zero\n * framework dependencies (L15).\n *\n * @see Bible §3.8\n * @see Design Choices S1–S15, T1, T5\n * @see Appendix E P3 (threadId)\n * @see Appendix D Ruling 3\n */\n\nimport { z } from 'zod';\n\n// ---------------------------------------------------------------------------\n// Nested Data Types\n// ---------------------------------------------------------------------------\n\n/**\n * State of a single zone within the store.\n * Auto-populated when an `Zone` mounts (S15).\n */\nexport type ZoneState = {\n /** Zone name. */\n readonly name: string;\n /** Current lifecycle state. */\n readonly lifecycleState: 'loading' | 'ready' | 'streaming' | 'error' | 'empty';\n /** Determinism level at mount time. */\n readonly determinism: number;\n /** Last compiled component name, if any. */\n readonly lastComponent?: string;\n /** ISO 8601 timestamp of the last update. */\n readonly lastUpdated: string;\n};\n\n/**\n * Session metadata within the store.\n * Ephemeral session data + optional persistent `threadId`.\n */\nexport type SessionState = {\n /** Ephemeral session ID generated on app mount. Lost on refresh. */\n readonly id: string;\n /**\n * Persistent conversation thread ID that survives across sessions.\n * Passed via `<Provider threadId=\"...\">`.\n * When `undefined`, Enterstellar operates in stateless mode (no conversation resumption).\n *\n * @see Appendix E P3\n */\n readonly threadId?: string;\n /** ISO 8601 timestamp when the session started. */\n readonly startedAt: string;\n};\n\n/**\n * Serializable representation of the full store state.\n * Produced by `snapshot()`, consumed by `restore()`.\n */\nexport type SerializedState = {\n /** Semver string for schema versioning (e.g., `\"1.0.0\"`). */\n readonly schemaVersion: string;\n /** Zone state map, keyed by zone name. */\n readonly zones: Readonly<Record<string, ZoneState>>;\n /** Trace ID history (most recent first). */\n readonly traceIds: readonly string[];\n /** Session metadata. */\n readonly session: SessionState;\n /** Extension data from `store.extend()`. Keyed by extension name. */\n readonly extensions: Readonly<Record<string, unknown>>;\n};\n\n/**\n * Configuration for a store state migration.\n * Migrations chain sequentially from older versions to current.\n *\n * @see Design Choice S5 (amended v2)\n */\nexport type MigrationConfig = {\n /** Source schema version (semver). */\n readonly from: string;\n /** Target schema version (semver). */\n readonly to: string;\n /** Migration function that transforms the state. */\n readonly migrate: (state: SerializedState) => SerializedState;\n};\n\n/**\n * Persistence strategy for the store.\n * Determines where state is stored between sessions.\n *\n * @see Design Choices S5–S7\n */\nexport type PersistenceStrategy = 'memory' | 'local-storage' | 'indexed-db' | 'custom';\n\n/**\n * Configuration for cross-device state sync.\n *\n * @see Design Choices S9–S12\n */\nexport type SyncConfig = {\n /** Whether sync is enabled. */\n readonly enabled: boolean;\n /** Endpoint URL for state synchronization. */\n readonly endpoint: string;\n /** Sync debounce interval in milliseconds. Default: 100ms. */\n readonly debounceMs: number;\n};\n\n// ---------------------------------------------------------------------------\n// EnterstellarStore Interface\n// ---------------------------------------------------------------------------\n\n/**\n * Framework-agnostic persistent state container — the OS's memory.\n *\n * This is an **interface** (not a type) because it has methods.\n * Implementations are provided by `@enterstellar-ai/state` (`createEnterstellarStore()`).\n * React binding is provided by `@enterstellar-ai/react` (`useEnterstellarStore()` hook via\n * `useSyncExternalStore`).\n *\n * @see Bible §3.8\n * @see Design Choice T1 — interfaces for objects with methods.\n * @see Design Choice S1 — single global store per app.\n */\nexport interface EnterstellarStore {\n /**\n * Gets a value from the store by key.\n * In development mode, validates against the registered Zod schema.\n *\n * @param key - The store key to read.\n * @returns The stored value, or `undefined` if not found.\n *\n * @see Design Choice S3\n */\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- Deliberate: consumer-facing generic for type-safe reads (e.g., store.get<ZoneState>('zones'))\n get<T = unknown>(key: string): T | undefined;\n\n /**\n * Sets a value in the store.\n * Updates memory immediately; persistence is write-behind (debounced, S8).\n * Fires subscriptions only on actual value change (shallow equality, S4).\n *\n * @param key - The store key to write.\n * @param value - The value to store.\n */\n set(key: string, value: unknown): void;\n\n /**\n * Subscribes to store changes.\n * Callback fires only on actual value change (shallow equality check, S4).\n *\n * @param callback - Called when any store value changes.\n * @returns An unsubscribe function.\n */\n subscribe(callback: () => void): () => void;\n\n /**\n * Extends the store with a named, schema-validated section.\n * Prevents untyped global state.\n *\n * The `schema` parameter is intentionally `z.ZodType` (unparameterized)\n * to allow consumers to register any valid Zod schema shape.\n *\n * @param name - Extension name (e.g., `'preferences'`).\n * @param schema - Zod schema for the extension's value shape.\n *\n * @see Design Choice S2\n */\n extend(name: string, schema: z.ZodType): void;\n\n /**\n * Checks whether a named extension has been registered via `extend()`.\n *\n * Use this to guard idempotent extension registration in components that\n * may mount multiple times (e.g., `Provider` re-renders). This method\n * returns `true` only for extension keys — fixed schema keys (`zones`,\n * `traceIds`, `session`) are NOT considered extensions and always return\n * `false`.\n *\n * @param name - Extension name to check (e.g., `'traces'`, `'preferences'`).\n * @returns `true` if `extend(name, schema)` was previously called for this name.\n *\n * @example\n * ```ts\n * if (!store.hasExtension('traces')) {\n * store.extend('traces', z.array(ZoneTraceSchema));\n * }\n * ```\n *\n * @see Design Choice S2 — typed extension point.\n */\n hasExtension(name: string): boolean;\n\n /**\n * Serializes the entire store state for cross-device transfer.\n * Zone configs only — NOT render trees (S9, max 1MB).\n *\n * @returns A `SerializedState` snapshot with `schemaVersion`.\n * @throws {EnterstellarError} If state exceeds 1MB (ENS-4006).\n */\n snapshot(): SerializedState;\n\n /**\n * Restores state from a snapshot. Full overwrite, not merge (S10).\n * Applies chained migrations if snapshot version is older.\n * Hard-rejects major version forward jumps (ENS-4007).\n *\n * @param state - The serialized state to restore.\n * @throws {EnterstellarError} If major version is ahead (ENS-4007).\n *\n * @see Design Choice S5 (amended v2)\n */\n restore(state: SerializedState): void;\n\n /**\n * Registers a migration for handling older state snapshots.\n *\n * @param config - Migration config with `from`, `to`, and `migrate` function.\n */\n registerMigration(config: MigrationConfig): void;\n\n /**\n * Returns the full store snapshot for `useSyncExternalStore` compatibility.\n * React's `useSyncExternalStore` requires a `getSnapshot` function.\n */\n getSnapshot(): SerializedState;\n\n /**\n * Destroys the store, clearing all state and subscriptions.\n * Called when `Provider` unmounts.\n */\n destroy(): void;\n}\n\n// ---------------------------------------------------------------------------\n// Zod Schema\n// ---------------------------------------------------------------------------\n\n/**\n * Zod schema for validating `ZoneState` at runtime.\n *\n * @see Design Choice T7\n */\nexport const ZoneStateSchema = z.object({\n name: z.string().min(1),\n lifecycleState: z.enum(['loading', 'ready', 'streaming', 'error', 'empty']),\n determinism: z.number().min(0).max(1),\n lastComponent: z.string().optional(),\n lastUpdated: z.string().min(1),\n});\n\n/**\n * Zod schema for validating `SessionState` at runtime.\n *\n * @see Design Choice T7\n */\nexport const SessionStateSchema = z.object({\n id: z.string().min(1),\n threadId: z.string().optional(),\n startedAt: z.string().min(1),\n});\n\n/**\n * Zod schema for validating `SerializedState` at runtime.\n * Used by `restore()` to validate snapshots before applying.\n *\n * @see Design Choice T7, S5\n */\nexport const SerializedStateSchema = z.object({\n schemaVersion: z.string().min(1, 'Schema version is required.'),\n zones: z.record(z.string(), ZoneStateSchema),\n traceIds: z.array(z.string()),\n session: SessionStateSchema,\n extensions: z.record(z.string(), z.unknown()),\n});\n","/**\n * @module @enterstellar-ai/types/connection\n * @description UserSignal and EnterstellarAgentConnection — the contract between\n * the UI layer and AI agents.\n *\n * `UserSignal` is the fire-and-forget message from a user interaction\n * (click, submit, input) back to the agent. `EnterstellarAgentConnection` is the\n * transport-agnostic interface for bidirectional agent communication.\n *\n * @see Bible §3.9, §3.10\n * @see Appendix E P1 (UserSignal), P7 (event whitelist), P11 (connection factory)\n */\n\nimport { z } from 'zod';\n\n// ---------------------------------------------------------------------------\n// String Union Types\n// ---------------------------------------------------------------------------\n\n/**\n * Type of user interaction signal dispatched to the agent.\n *\n * @see Appendix E P1\n */\nexport type UserSignalType =\n | 'click'\n | 'submit'\n | 'input'\n | 'custom';\n\n/**\n * Agent-to-UI event types that trigger zone re-renders.\n * Internal agent events (graph node transitions, reducer internals)\n * are NOT surfaced.\n *\n * @see Appendix E P7\n */\nexport type AgentEventType =\n | 'intent'\n | 'lifecycle'\n | 'data'\n | 'message'\n | 'reconnect';\n\n// ---------------------------------------------------------------------------\n// UserSignal Type\n// ---------------------------------------------------------------------------\n\n/**\n * A user interaction signal dispatched from an Zone to the agent.\n *\n * Dispatched via `EnterstellarAgentConnection.dispatch()`. Fire-and-forget with\n * enqueue guarantee — the promise resolves when the signal is queued,\n * NOT when the agent processes it.\n *\n * @see Bible §3.9\n * @see Appendix E P1\n */\nexport type UserSignal = {\n /** Type of user interaction. */\n readonly type: UserSignalType;\n /** Name of the zone that originated this signal. */\n readonly zone: string;\n /** Name of the component that originated this signal. */\n readonly component: string;\n /** Arbitrary payload from the interaction (form data, click target, etc.). */\n readonly payload: Readonly<Record<string, unknown>>;\n /** ISO 8601 timestamp of when the interaction occurred. */\n readonly timestamp: string;\n /**\n * Optional correlation ID for tying this signal to an ongoing interaction chain.\n *\n * @see Appendix E P2\n */\n readonly correlationId?: string;\n};\n\n// ---------------------------------------------------------------------------\n// EnterstellarAgentConnection Interface\n// ---------------------------------------------------------------------------\n\n/**\n * Transport-agnostic interface for bidirectional agent communication.\n *\n * Implementations are provided by `@enterstellar-ai/connection` (`createAgentConnection()`)\n * or custom consumer implementations. The connection is created and owned by\n * the consumer, not by Enterstellar (RE3).\n *\n * This is an **interface** (not a type) because it has methods.\n *\n * @see Bible §3.10\n * @see Design Choices RE3, P1, P5, P7, P11, P12\n * @see Design Choice T1 — interfaces for objects with methods.\n */\nexport interface EnterstellarAgentConnection {\n /**\n * Dispatches a user interaction signal to the agent.\n * Fire-and-forget: resolves when enqueued in the outbound queue,\n * NOT when the agent processes it.\n *\n * @param signal - The user signal to dispatch.\n * @param options - Optional dispatch options.\n * @returns Resolves when the signal is enqueued.\n *\n * @see Appendix E P1, P6 (debounce)\n */\n dispatch(\n signal: UserSignal,\n options?: { readonly immediate?: boolean },\n ): Promise<void>;\n\n /**\n * Subscribes to agent-to-UI events.\n * Only whitelisted event types are surfaced (P7).\n *\n * @param event - The event type to listen for.\n * @param callback - Called when the event fires.\n * @returns An unsubscribe function.\n *\n * @see Appendix E P7\n */\n on(event: AgentEventType, callback: (data: unknown) => void): () => void;\n\n /**\n * Subscribes to ALL raw agent events, including internal ones.\n * Escape hatch for custom DevTools panels and advanced use cases.\n *\n * @param callback - Called for every raw event.\n * @returns An unsubscribe function.\n *\n * @see Appendix E P7\n */\n onRawEvent(callback: (event: unknown) => void): () => void;\n\n /** Whether the connection is currently active. */\n readonly connected: boolean;\n\n /**\n * Disconnects the agent connection.\n * Queued signals are flushed before disconnecting.\n */\n disconnect(): Promise<void>;\n}\n\n// ---------------------------------------------------------------------------\n// Zod Schema\n// ---------------------------------------------------------------------------\n\n/**\n * Zod schema for validating a `UserSignal` at runtime.\n *\n * @see Design Choice T7\n */\nexport const UserSignalSchema = z.object({\n type: z.enum(['click', 'submit', 'input', 'custom']),\n zone: z.string().min(1, 'Zone name is required.'),\n component: z.string().min(1, 'Component name is required.'),\n payload: z.record(z.string(), z.unknown()),\n timestamp: z.string().min(1, 'Timestamp is required.'),\n correlationId: z.string().optional(),\n});\n","/**\n * @module @enterstellar-ai/types/semantic-index\n * @description Semantic Index types — search results and related data shapes\n * for the embedding-based component retrieval engine.\n *\n * The Semantic Index reduces the LLM context window from ~50K tokens to ~200\n * by selecting only the most relevant components for a given intent.\n *\n * **Naming:** Types for data shapes (`SemanticSearchResult`), not interfaces —\n * per Design Choice T1 (interfaces for objects with methods).\n *\n * **L15 compliance:** Zero framework imports. Pure data types only.\n *\n * @see Implementation Bible §4.7\n * @see Design Choices SI1–SI12\n */\n\nimport { z } from 'zod';\n\nimport { ComponentContractSchema } from './contract.js';\nimport type { ComponentContract } from './contract.js';\n\n// ---------------------------------------------------------------------------\n// SemanticSearchResult\n// ---------------------------------------------------------------------------\n\n/**\n * A single result from a semantic index search.\n *\n * Returned by `SemanticIndex.search()` — each result pairs a component\n * with its cosine similarity score to the queried intent.\n *\n * @see Design Choice SI8 — similarity scores included in manifest entries.\n * @see Design Choice SI5 — default `topK: 5`, max 20.\n * @see Design Choice SI6 — below `noMatchThreshold` (0.4) → Forge activates.\n */\nexport type SemanticSearchResult = {\n /** PascalCase name of the matched component. */\n readonly componentName: string;\n\n /**\n * Cosine similarity score between the intent embedding and\n * the component's embedding vector. Range: 0.0–1.0.\n *\n * Scores above `noMatchThreshold` (default 0.4) indicate viable matches.\n * Scores below trigger Forge activation (caller's responsibility).\n */\n readonly similarity: number;\n\n /**\n * The full `ComponentContract` of the matched component.\n * Provides immediate access to props schema, tokens, and metadata\n * without a second registry lookup.\n */\n readonly contract: ComponentContract;\n};\n\n// ---------------------------------------------------------------------------\n// Zod Schema (T7)\n// ---------------------------------------------------------------------------\n\n/**\n * Zod schema for `SemanticSearchResult`.\n *\n * Enables runtime validation of search results — useful for\n * cross-boundary data validation (e.g., results received from\n * a cloud semantic index endpoint).\n *\n * @see Design Choice T7 — export both TS type and Zod schema.\n */\nexport const SemanticSearchResultSchema = z.object({\n /** PascalCase name of the matched component. */\n componentName: z.string().min(1),\n\n /**\n * Cosine similarity score. Clamped to [0.0, 1.0].\n */\n similarity: z.number().min(0).max(1),\n\n /** The matched component's full contract. */\n contract: ComponentContractSchema,\n});\n","/**\n * @module @enterstellar-ai/types/forge\n * @description Forge types — runtime component generation and Cold Path pipeline.\n *\n * The Forge generates temporary ComponentContracts when the registry has\n * no match. LocalForge uses templates (free), CloudForge uses LLM (metered).\n *\n * @see Bible §4.10 — Forge\n * @see Design Choices F1–F14\n * @see Appendix D Ruling 7\n */\n\nimport { z } from 'zod';\n\nimport type { ComponentContract } from './contract.js';\nimport type { CompilationResult } from './compiler.js';\n\n// ---------------------------------------------------------------------------\n// Forge Result Type\n// ---------------------------------------------------------------------------\n\n/**\n * The output of a Forge invocation.\n * Contains the generated contract (if successful), compilation status,\n * and which forge mode was used.\n *\n * @see Bible §4.10\n * @see Design Choice F8 (auto-routing)\n */\nexport type ForgeResult = {\n /** Whether the forge successfully generated a valid contract. */\n readonly success: boolean;\n /**\n * The generated ComponentContract, or `null` on failure.\n * Marked with `_meta.forged = true`.\n * Named with prefix `__forged_{name}_{8-char-hash}` (F13).\n */\n readonly contract: ComponentContract | null;\n /** Compilation result — forged contracts MUST pass the compiler (L3, L13). */\n readonly compilationResult: CompilationResult | null;\n /** Whether the fallback component was used instead. */\n readonly fallbackUsed: boolean;\n /**\n * Which forge mode generated this contract.\n *\n * @see Appendix D Ruling 7\n */\n readonly forgeMode: 'local' | 'cloud';\n};\n\n/**\n * Trace record for Cold Path intent clustering.\n * Every forge invocation is logged for clustering analysis.\n *\n * @see Bible §4.10 — Cold Path Rules\n */\nexport type ForgeTraceRecord = {\n /** Slugified intent name. */\n readonly intentSlug: string;\n /** Raw intent string hash (SHA-256). */\n readonly intentHash: string;\n /** Which forge mode was used. */\n readonly forgeMode: 'local' | 'cloud';\n /** Whether the forge succeeded. */\n readonly success: boolean;\n /** ISO 8601 timestamp. */\n readonly timestamp: string;\n /** Optional context provided during forge invocation. */\n readonly context?: Readonly<Record<string, unknown>>;\n};\n\n/**\n * Configuration for the Forge's Cold Path pipeline.\n *\n * @see Design Choices F10–F12\n */\nexport type ColdPathConfig = {\n /** Whether the Cold Path is enabled. */\n readonly enabled: boolean;\n /** Minimum occurrences of a similar intent before clustering. Default: 5 (F11). */\n readonly clusterThreshold: number;\n /** Whether to auto-queue clustered contracts for HITL review. */\n readonly autoPromote: boolean;\n};\n\n// ---------------------------------------------------------------------------\n// Zod Schema\n// ---------------------------------------------------------------------------\n\n/**\n * Zod schema for validating a `ForgeResult` at runtime.\n *\n * @see Design Choice T7\n */\nexport const ForgeResultSchema = z.object({\n success: z.boolean(),\n /**\n * `z.unknown().nullable()` instead of `ComponentContractSchema.nullable()`\n * to avoid circular schema references (forge → contract → compiler).\n * TS type is properly typed as `ComponentContract | null`.\n */\n contract: z.unknown().nullable(),\n /**\n * `z.unknown().nullable()` for the same reason — avoids circular\n * schema dependency with `CompilationResultSchema`.\n * TS type is properly typed as `CompilationResult | null`.\n */\n compilationResult: z.unknown().nullable(),\n fallbackUsed: z.boolean(),\n forgeMode: z.enum(['local', 'cloud']),\n});\n\n/**\n * Zod schema for validating a `ForgeTraceRecord` at runtime.\n */\nexport const ForgeTraceRecordSchema = z.object({\n intentSlug: z.string().min(1),\n intentHash: z.string().min(1),\n forgeMode: z.enum(['local', 'cloud']),\n success: z.boolean(),\n timestamp: z.string().min(1),\n context: z.record(z.string(), z.unknown()).optional(),\n});\n","/**\n * @module @enterstellar-ai/types/guards\n * @description Type guard functions for runtime type narrowing.\n *\n * Type guards are lightweight checks (one `typeof` + field existence)\n * for branded types and discriminated unions. Full Zod-based validation\n * remains in consumer modules (e.g., `@enterstellar-ai/registry`).\n *\n * @see Design Choice T17\n */\n\nimport type { ComponentId, ZoneId, TraceId } from './brands.js';\nimport type { ForgeSignal } from './telemetry.js';\nimport type { CompilationResult } from './compiler.js';\nimport type { ComponentIntent } from './intent.js';\nimport type { AgentTrace } from './trace.js';\nimport type { UserSignal } from './connection.js';\n\n// ---------------------------------------------------------------------------\n// Branded Type Guards\n// ---------------------------------------------------------------------------\n\n/**\n * Checks whether a value is a valid `ComponentId`.\n * Validates that the value is a non-empty string.\n *\n * @param value - The value to check.\n * @returns `true` if the value is a valid `ComponentId`.\n */\nexport function isComponentId(value: unknown): value is ComponentId {\n return typeof value === 'string' && value.length > 0;\n}\n\n/**\n * Checks whether a value is a valid `ZoneId`.\n * Validates that the value is a non-empty string.\n *\n * @param value - The value to check.\n * @returns `true` if the value is a valid `ZoneId`.\n */\nexport function isZoneId(value: unknown): value is ZoneId {\n return typeof value === 'string' && value.length > 0;\n}\n\n/**\n * Checks whether a value is a valid `TraceId`.\n * Validates that the value is a non-empty string.\n *\n * @param value - The value to check.\n * @returns `true` if the value is a valid `TraceId`.\n */\nexport function isTraceId(value: unknown): value is TraceId {\n return typeof value === 'string' && value.length > 0;\n}\n\n// ---------------------------------------------------------------------------\n// Data Shape Type Guards\n// ---------------------------------------------------------------------------\n\n/**\n * Checks whether a value is a valid `ForgeSignal` shape.\n * Lightweight structural check — NOT full Zod validation.\n *\n * @param value - The value to check.\n * @returns `true` if the value has the shape of a `ForgeSignal`.\n */\nexport function isForgeSignal(value: unknown): value is ForgeSignal {\n if (typeof value !== 'object' || value === null) return false;\n const obj = value as Record<string, unknown>;\n return (\n typeof obj['intentHash'] === 'string' &&\n typeof obj['componentName'] === 'string' &&\n typeof obj['compilationStatus'] === 'string' &&\n typeof obj['forgeMode'] === 'string' &&\n typeof obj['latencyMs'] === 'number' &&\n typeof obj['timestamp'] === 'string'\n );\n}\n\n/**\n * Checks whether a value is a valid `CompilationResult` shape.\n * Lightweight structural check — NOT full Zod validation.\n *\n * @param value - The value to check.\n * @returns `true` if the value has the shape of a `CompilationResult`.\n */\nexport function isCompilationResult(value: unknown): value is CompilationResult {\n if (typeof value !== 'object' || value === null) return false;\n const obj = value as Record<string, unknown>;\n return (\n typeof obj['componentName'] === 'string' &&\n typeof obj['status'] === 'string' &&\n typeof obj['provenance'] === 'object' &&\n obj['provenance'] !== null &&\n Array.isArray(obj['errors'])\n );\n}\n\n/**\n * Checks whether a value is a valid `ComponentIntent` shape.\n * Lightweight structural check — NOT full Zod validation.\n *\n * @param value - The value to check.\n * @returns `true` if the value has the shape of a `ComponentIntent`.\n */\nexport function isComponentIntent(value: unknown): value is ComponentIntent {\n if (typeof value !== 'object' || value === null) return false;\n const obj = value as Record<string, unknown>;\n return (\n typeof obj['component'] === 'string' &&\n typeof obj['props'] === 'object' &&\n obj['props'] !== null &&\n typeof obj['confidence'] === 'number'\n );\n}\n\n/**\n * Checks whether a value is a valid `AgentTrace` shape.\n * Lightweight structural check — NOT full Zod validation.\n *\n * @param value - The value to check.\n * @returns `true` if the value has the shape of an `AgentTrace`.\n */\nexport function isAgentTrace(value: unknown): value is AgentTrace {\n if (typeof value !== 'object' || value === null) return false;\n const obj = value as Record<string, unknown>;\n return (\n typeof obj['id'] === 'string' &&\n typeof obj['timestamp'] === 'string' &&\n typeof obj['intent'] === 'object' &&\n obj['intent'] !== null &&\n typeof obj['resolution'] === 'object' &&\n obj['resolution'] !== null &&\n typeof obj['compilation'] === 'object' &&\n obj['compilation'] !== null\n );\n}\n\n/**\n * Checks whether a value is a valid `UserSignal` shape.\n * Lightweight structural check — NOT full Zod validation.\n *\n * @param value - The value to check.\n * @returns `true` if the value has the shape of a `UserSignal`.\n */\nexport function isUserSignal(value: unknown): value is UserSignal {\n if (typeof value !== 'object' || value === null) return false;\n const obj = value as Record<string, unknown>;\n return (\n typeof obj['type'] === 'string' &&\n typeof obj['zone'] === 'string' &&\n typeof obj['component'] === 'string' &&\n typeof obj['payload'] === 'object' &&\n obj['payload'] !== null &&\n typeof obj['timestamp'] === 'string'\n );\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@enterstellar-ai/types",
|
|
3
|
+
"description": "Shared type definitions, Zod schemas, and type guards for the Enterstellar ecosystem.",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"author": "Enterstellar",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"homepage": "https://enterstellar.dev",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/enterstellar-ai/enterstellar.git",
|
|
11
|
+
"directory": "packages/types"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/enterstellar-ai/enterstellar/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"types",
|
|
18
|
+
"zod",
|
|
19
|
+
"typescript",
|
|
20
|
+
"generative-ui",
|
|
21
|
+
"enterstellar"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"private": false,
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"main": "./dist/index.cjs",
|
|
30
|
+
"module": "./dist/index.js",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"default": "./dist/index.js"
|
|
37
|
+
},
|
|
38
|
+
"require": {
|
|
39
|
+
"types": "./dist/index.d.cts",
|
|
40
|
+
"default": "./dist/index.cjs"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"LICENSE",
|
|
46
|
+
"NOTICE",
|
|
47
|
+
"dist"
|
|
48
|
+
],
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"zod": "^4.3.6"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"expect-type": "^1.1.0"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup",
|
|
57
|
+
"typecheck": "tsc --noEmit",
|
|
58
|
+
"lint": "eslint src/",
|
|
59
|
+
"test": "vitest run",
|
|
60
|
+
"test:watch": "vitest"
|
|
61
|
+
}
|
|
62
|
+
}
|