@almadar/core 6.0.0 → 7.2.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.
@@ -0,0 +1,221 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * S-Expression Types
5
+ *
6
+ * Defines the S-Expression type system for guards, effects, and computed values.
7
+ * S-expressions are JSON arrays where the first element is an operator string.
8
+ *
9
+ * @example
10
+ * // Guard: health > 0
11
+ * [">", "@entity.health", 0]
12
+ *
13
+ * // Effect: set x to x + vx
14
+ * ["set", "@entity.x", ["+", "@entity.x", "@entity.vx"]]
15
+ *
16
+ * @packageDocumentation
17
+ */
18
+
19
+ /**
20
+ * S-Expression type - recursive structure representing expressions.
21
+ *
22
+ * An S-expression is either:
23
+ * - A literal value (string, number, boolean, null)
24
+ * - An object literal (for payload data, props, etc.)
25
+ * - A binding reference (string starting with @)
26
+ * - A call expression (array with operator as first element)
27
+ */
28
+ type SExprAtom = string | number | boolean | null | Record<string, unknown>;
29
+ type SExpr = SExprAtom | SExpr[];
30
+ /**
31
+ * Expression type - S-expressions only.
32
+ * Used for guards, computed values, and effect expressions.
33
+ *
34
+ * NOTE: Legacy string format is no longer supported.
35
+ * All expressions must be S-expression arrays.
36
+ */
37
+ type Expression = SExpr;
38
+ /**
39
+ * Schema for atomic S-expression values (non-array)
40
+ * Includes objects for payload data, props, etc.
41
+ */
42
+ declare const SExprAtomSchema: z.ZodType<SExprAtom>;
43
+ /**
44
+ * Recursive schema for S-expressions.
45
+ * Validates that arrays have at least one element and first element is a string (operator).
46
+ */
47
+ declare const SExprSchema: z.ZodType<SExpr>;
48
+ /**
49
+ * Schema for Expression type - S-expressions only.
50
+ * S-expressions are arrays with operator as first element.
51
+ *
52
+ * NOTE: Legacy string format is no longer supported.
53
+ */
54
+ declare const ExpressionSchema: z.ZodType<Expression>;
55
+ /**
56
+ * Type guard for S-expression detection.
57
+ * 100% reliable - structural check, no regex or keyword matching.
58
+ *
59
+ * @param value - Value to check
60
+ * @returns true if value is an S-expression (array with string operator)
61
+ */
62
+ declare function isSExpr(value: unknown): value is SExpr[];
63
+ /**
64
+ * Type guard for S-expression atoms (non-array values).
65
+ *
66
+ * Validates that a value is an S-expression atom (literal value).
67
+ * Includes null, strings, numbers, booleans, and objects. Used to
68
+ * distinguish atomic values from S-expression calls (arrays).
69
+ *
70
+ * @param {unknown} value - Value to check
71
+ * @returns {boolean} True if value is an S-expression atom, false otherwise
72
+ *
73
+ * @example
74
+ * isSExprAtom('hello'); // returns true
75
+ * isSExprAtom(42); // returns true
76
+ * isSExprAtom(null); // returns true
77
+ * isSExprAtom({ key: 'value' }); // returns true
78
+ * isSExprAtom(['+', 1, 2]); // returns false
79
+ */
80
+ declare function isSExprAtom(value: unknown): value is SExprAtom;
81
+ /**
82
+ * Checks if a value is a binding reference.
83
+ *
84
+ * Validates that a string is a binding reference (starts with @).
85
+ * Bindings reference runtime values like @entity.health, @payload.amount, @now.
86
+ * Used for identifying bindings in S-expressions and validation.
87
+ *
88
+ * @param {unknown} value - Value to check
89
+ * @returns {boolean} True if value is a binding reference, false otherwise
90
+ *
91
+ * @example
92
+ * isBinding('@entity.health'); // returns true
93
+ * isBinding('@payload.amount'); // returns true
94
+ * isBinding('not-a-binding'); // returns false
95
+ * isBinding(123); // returns false
96
+ */
97
+ declare function isBinding(value: unknown): value is string;
98
+ /**
99
+ * Checks if a value is a valid S-expression call (array with operator).
100
+ *
101
+ * Alias for isSExpr() - validates S-expression call structure.
102
+ * Used to distinguish between S-expression calls and atom values.
103
+ *
104
+ * @param {unknown} value - Value to check
105
+ * @returns {boolean} True if value is a valid S-expression call, false otherwise
106
+ *
107
+ * @example
108
+ * isSExprCall(['+', 1, 2]); // returns true
109
+ * isSExprCall(['set', '@entity.health', 100]); // returns true
110
+ * isSExprCall('not-a-call'); // returns false
111
+ */
112
+ declare function isSExprCall(value: unknown): value is SExpr[];
113
+ /**
114
+ * Parsed binding reference
115
+ */
116
+ interface ParsedBinding {
117
+ /** Type of binding: core (@entity, @payload, @state, @now) or entity (@EntityName) */
118
+ type: 'core' | 'entity';
119
+ /** The root binding name (entity, payload, state, now, or EntityName) */
120
+ root: string;
121
+ /** Path segments after the root (e.g., ['health'] for @entity.health) */
122
+ path: string[];
123
+ /** Full original binding string */
124
+ original: string;
125
+ }
126
+ /**
127
+ * Core bindings that are always available.
128
+ * Phase 4.5 adds: config, computed, trait (for behavior support)
129
+ */
130
+ declare const CORE_BINDINGS: readonly ["entity", "payload", "state", "now", "config", "computed", "trait"];
131
+ type CoreBinding = (typeof CORE_BINDINGS)[number];
132
+ /**
133
+ * Parses a binding reference into its components.
134
+ *
135
+ * Deconstructs a binding string (e.g., '@entity.health') into its constituent
136
+ * parts: type, root, path, and original string. Does NOT use regex - uses
137
+ * structured string operations for reliability and maintainability.
138
+ *
139
+ * @param {string} binding - Binding string starting with @
140
+ * @returns {ParsedBinding | null} Parsed binding object or null if invalid
141
+ *
142
+ * @example
143
+ * parseBinding('@entity.health'); // returns { type: 'core', root: 'entity', path: ['health'], original: '@entity.health' }
144
+ * parseBinding('@User.name'); // returns { type: 'entity', root: 'User', path: ['name'], original: '@User.name' }
145
+ * parseBinding('not-a-binding'); // returns null
146
+ */
147
+ declare function parseBinding(binding: string): ParsedBinding | null;
148
+ /**
149
+ * Validate a binding reference format.
150
+ *
151
+ * @param binding - Binding string to validate
152
+ * @returns true if valid binding format
153
+ */
154
+ declare function isValidBinding(binding: string): boolean;
155
+ /**
156
+ * Get the operator from an S-expression call.
157
+ *
158
+ * @param expr - S-expression array
159
+ * @returns The operator string or null if not a valid call
160
+ */
161
+ declare function getOperator(expr: SExpr): string | null;
162
+ /**
163
+ * Get the arguments from an S-expression call.
164
+ *
165
+ * @param expr - S-expression array
166
+ * @returns Array of arguments (empty if not a valid call)
167
+ */
168
+ declare function getArgs(expr: SExpr): SExpr[];
169
+ /**
170
+ * Create an S-expression call.
171
+ *
172
+ * @param operator - The operator string
173
+ * @param args - Arguments to the operator
174
+ * @returns S-expression array
175
+ */
176
+ declare function sexpr(operator: string, ...args: SExpr[]): SExpr[];
177
+ /**
178
+ * Walk an S-expression tree and apply a visitor function to each node.
179
+ *
180
+ * @param expr - S-expression to walk
181
+ * @param visitor - Function to call on each node
182
+ */
183
+ declare function walkSExpr(expr: SExpr, visitor: (node: SExpr, parent: SExpr[] | null, index: number) => void, parent?: SExpr[] | null, index?: number): void;
184
+ /**
185
+ * Collect all bindings referenced in an S-expression.
186
+ *
187
+ * @param expr - S-expression to analyze
188
+ * @returns Array of binding strings found
189
+ */
190
+ declare function collectBindings(expr: SExpr): string[];
191
+ type SExprInput = z.input<typeof SExprSchema>;
192
+ type ExpressionInput = z.input<typeof ExpressionSchema>;
193
+ /** Evaluation context for guards and s-expressions. Recursive. */
194
+ interface EvalContext {
195
+ [key: string]: string | number | boolean | Date | null | string[] | EvalContext | undefined;
196
+ }
197
+ /**
198
+ * A single value carried by an event payload field. The top-level payload
199
+ * is always an object; the VALUES in that object can be primitives, nested
200
+ * objects, or arrays of the same. Arrays are allowed so real-world emits
201
+ * like `{ files: [{ name, size, type }, ...] }` or `{ selected: string[] }`
202
+ * are typed natively instead of forcing consumers to wrap at every call.
203
+ *
204
+ * `Date` is included so `EntityRow` (whose values are `FieldValue`, which
205
+ * includes `Date`) is assignable to a payload field without a cast —
206
+ * emitted entity rows flow through the bus without boundary widening.
207
+ */
208
+ type EventPayloadValue = string | number | boolean | Date | null | undefined | EventPayload | readonly EventPayloadValue[];
209
+ /**
210
+ * Typed event payload. Object-shaped so it's assignable to the bus's
211
+ * `EventPayload` parameter without casts.
212
+ */
213
+ interface EventPayload {
214
+ [key: string]: EventPayloadValue;
215
+ }
216
+ /** Structured log/event metadata. Recursive to support nested log data. */
217
+ interface LogMeta {
218
+ [key: string]: string | number | boolean | null | undefined | Error | LogMeta;
219
+ }
220
+
221
+ export { CORE_BINDINGS as C, type EvalContext as E, type LogMeta as L, type ParsedBinding as P, type SExpr as S, type CoreBinding as a, type EventPayload as b, type EventPayloadValue as c, type Expression as d, type ExpressionInput as e, ExpressionSchema as f, type SExprAtom as g, SExprAtomSchema as h, type SExprInput as i, SExprSchema as j, collectBindings as k, getArgs as l, getOperator as m, isBinding as n, isSExpr as o, isSExprAtom as p, isSExprCall as q, isValidBinding as r, parseBinding as s, sexpr as t, walkSExpr as w };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { h as OrbitalSchema, m as State, O as OrbitalDefinition } from './schema-DnLtWO4e.js';
2
- export { A as AGENT_DOMAIN_CATEGORIES, n as ALLOWED_CUSTOM_COMPONENTS, o as AgentDomainCategory, p as AgentDomainCategorySchema, q as AgentEffect, r as AllowedCustomComponent, s as AnimationDef, t as AnimationDefInput, u as AnimationDefSchema, v as AssetMap, w as AssetMapInput, x as AssetMapSchema, y as AssetMapping, z as AssetMappingInput, B as AssetMappingSchema, C as AtomicEffect, D as CORE_BINDINGS, F as CallServiceConfig, G as CallServiceEffect, H as ComputedEventContract, I as ComputedEventContractSchema, J as ComputedEventListener, K as ComputedEventListenerSchema, L as CoreBinding, M as CustomPatternDefinition, N as CustomPatternDefinitionInput, Q as CustomPatternDefinitionSchema, R as CustomPatternMap, V as CustomPatternMapInput, W as CustomPatternMapSchema, X as DerefEffect, Y as DesignPreferences, Z as DesignPreferencesInput, _ as DesignPreferencesSchema, $ as DesignTokens, a0 as DesignTokensInput, a1 as DesignTokensSchema, a2 as DespawnEffect, a3 as DoEffect, a4 as DomainCategory, a5 as DomainCategorySchema, a6 as DomainContext, a7 as DomainContextInput, a8 as DomainContextSchema, a9 as DomainVocabulary, aa as DomainVocabularySchema, ab as ENTITY_ROLES, ac as Effect, ad as EffectInput, ae as EffectSchema, af as EmitConfig, ag as EmitEffect, E as Entity, ah as EntityCall, ai as EntityCallSchema, aj as EntityData, c as EntityField, ak as EntityFieldInput, al as EntityFieldSchema, d as EntityPersistence, am as EntityPersistenceSchema, f as EntityRef, an as EntityRefSchema, ao as EntityRefStringSchema, ap as EntityRole, aq as EntityRoleSchema, e as EntityRow, ar as EntitySchema, as as EntitySemanticRole, at as EntitySemanticRoleSchema, au as EvalContext, av as Event, aw as EventInput, ax as EventListener, ay as EventListenerSchema, az as EventPayload, aA as EventPayloadField, aB as EventPayloadFieldSchema, aC as EventPayloadValue, aD as EventSchema, aE as EventScope, aF as EventScopeSchema, aG as EventSemanticRole, aH as EventSemanticRoleSchema, aI as EventSource, aJ as EventSourceSchema, aK as Expression, aL as ExpressionInput, aM as ExpressionSchema, aN as FetchEffect, aO as Field, aP as FieldFormat, aQ as FieldFormatSchema, aR as FieldSchema, aS as FieldType, aT as FieldTypeSchema, aU as FieldValue, aV as FullOrbitalUnit, aW as GAME_TYPES, aX as GameSubCategory, aY as GameSubCategorySchema, aZ as GameType, a_ as GameTypeSchema, a$ as Guard, b0 as GuardInput, b1 as GuardSchema, b2 as ListenSource, b3 as ListenSourceSchema, b4 as LogEffect, b5 as LogMeta, b6 as McpServiceDef, b7 as McpServiceDefSchema, b8 as NavigateEffect, b9 as NodeClassification, ba as NodeClassificationSchema, bb as NotifyEffect, aV as Orbital, bc as OrbitalConfig, bd as OrbitalConfigInput, be as OrbitalConfigSchema, bf as OrbitalDefinitionSchema, bg as OrbitalEntity, bh as OrbitalEntityInput, bi as OrbitalEntitySchema, bj as OrbitalInput, bk as OrbitalPage, bl as OrbitalPageInput, bm as OrbitalPageSchema, bn as OrbitalPageStrictInput, bo as OrbitalPageStrictSchema, bp as OrbitalSchemaInput, bq as OrbitalSchemaSchema, br as OrbitalTraitRef, bs as OrbitalTraitRefSchema, bt as OrbitalUnit, bu as OrbitalUnitSchema, bv as OrbitalZodSchema, j as Page, P as PageRef, k as PageRefObject, bw as PageRefObjectSchema, bx as PageRefSchema, by as PageRefStringSchema, bz as PageSchema, bA as PageTraitRef, bB as PageTraitRefSchema, bC as ParsedBinding, bD as PayloadField, bE as PayloadFieldSchema, bF as PersistEffect, bG as PresentationType, bH as RefEffect, bI as RelatedLink, bJ as RelatedLinkSchema, bK as RelationConfig, bL as RelationConfigSchema, bM as RenderItemLambda, bN as RenderUIConfig, bO as RenderUIEffect, bP as RenderUINode, bQ as RequiredField, bR as RequiredFieldSchema, bS as ResolvedAsset, bT as ResolvedAssetInput, bU as ResolvedAssetSchema, bV as ResolvedPatternProps, bW as RestAuthConfig, bX as RestAuthConfigSchema, bY as RestServiceDef, bZ as RestServiceDefSchema, b_ as SERVICE_TYPES, S as SExpr, b$ as SExprAtom, c0 as SExprAtomSchema, c1 as SExprInput, c2 as SExprSchema, c3 as SemanticAssetRef, c4 as SemanticAssetRefInput, c5 as SemanticAssetRefSchema, c6 as ServiceDefinition, c7 as ServiceDefinitionSchema, c8 as ServiceParams, c9 as ServiceRef, ca as ServiceRefObject, cb as ServiceRefObjectSchema, cc as ServiceRefSchema, cd as ServiceRefStringSchema, ce as ServiceType, cf as ServiceTypeSchema, cg as SetEffect, ch as SocketEvents, ci as SocketEventsSchema, cj as SocketServiceDef, ck as SocketServiceDefSchema, cl as SpawnEffect, cm as StateInput, cn as StateMachine, co as StateMachineInput, cp as StateMachineSchema, cq as StateSchema, cr as StateSemanticRole, cs as StateSemanticRoleSchema, ct as SuggestedGuard, cu as SuggestedGuardSchema, cv as SwapEffect, cw as ThemeDefinition, cx as ThemeDefinitionSchema, cy as ThemeRef, cz as ThemeRefSchema, cA as ThemeRefStringSchema, cB as ThemeTokens, cC as ThemeTokensSchema, cD as ThemeVariant, cE as ThemeVariantSchema, i as Trait, cF as TraitCategory, cG as TraitCategorySchema, b as TraitConfig, cH as TraitConfigObject, cI as TraitConfigSchema, cJ as TraitConfigValue, cK as TraitConfigValueSchema, cL as TraitDataEntity, cM as TraitDataEntitySchema, cN as TraitEntityField, cO as TraitEntityFieldSchema, T as TraitEventContract, cP as TraitEventContractSchema, a as TraitEventListener, cQ as TraitEventListenerSchema, cR as TraitInput, g as TraitRef, cS as TraitRefSchema, l as TraitReference, cT as TraitReferenceInput, cU as TraitReferenceSchema, cV as TraitSchema, cW as TraitTick, cX as TraitTickSchema, cY as TraitUIBinding, cZ as Transition, c_ as TransitionInput, c$ as TransitionSchema, d0 as TypedEffect, d1 as UISlot, d2 as UISlotSchema, d3 as UI_SLOTS, d4 as UXHints, d5 as UXHintsSchema, U as UseDeclaration, d6 as UseDeclarationSchema, d7 as UserPersona, d8 as UserPersonaInput, d9 as UserPersonaSchema, da as VISUAL_STYLES, db as ViewType, dc as ViewTypeSchema, dd as VisualStyle, de as VisualStyleSchema, df as WatchEffect, dg as WatchOptions, dh as atomic, di as callService, dj as collectBindings, dk as createAssetKey, dl as deref, dm as deriveCollection, dn as despawn, dp as doEffects, dq as emit, dr as findService, ds as getArgs, dt as getDefaultAnimationsForRole, du as getOperator, dv as getServiceNames, dw as getTraitConfig, dx as getTraitName, dy as hasService, dz as isBinding, dA as isCircuitEvent, dB as isEffect, dC as isEntityCall, dD as isEntityReference, dE as isEntityReferenceAny, dF as isImportedTraitRef, dG as isInlineTrait, dH as isMcpService, dI as isOrbitalDefinition, dJ as isPageReference, dK as isPageReferenceObject, dL as isPageReferenceString, dM as isRestService, dN as isRuntimeEntity, dO as isSExpr, dP as isSExprAtom, dQ as isSExprCall, dR as isSExprEffect, dS as isServiceReference, dT as isServiceReferenceObject, dU as isSingletonEntity, dV as isSocketService, dW as isThemeReference, dX as isValidBinding, dY as navigate, dZ as normalizeTraitRef, d_ as notify, d$ as parseAssetKey, e0 as parseBinding, e1 as parseEntityRef, e2 as parseImportedTraitRef, e3 as parseOrbitalSchema, e4 as parsePageRef, e5 as parseServiceRef, e6 as persist, e7 as ref, e8 as renderUI, e9 as safeParseOrbitalSchema, ea as set, eb as sexpr, ec as spawn, ed as swap, ee as validateAssetAnimations, ef as walkSExpr, eg as watch } from './schema-DnLtWO4e.js';
1
+ import { h as OrbitalSchema, S as State, O as OrbitalDefinition } from './schema-OhIbVaYu.js';
2
+ export { A as AGENT_DOMAIN_CATEGORIES, m as ALLOWED_CUSTOM_COMPONENTS, n as AgentDomainCategory, o as AgentDomainCategorySchema, p as AgentEffect, q as AllowedCustomComponent, r as AnimationDef, s as AnimationDefInput, t as AnimationDefSchema, u as AssetMap, v as AssetMapInput, w as AssetMapSchema, x as AssetMapping, y as AssetMappingInput, z as AssetMappingSchema, B as AtomicEffect, C as CallServiceConfig, D as CallServiceEffect, F as ComputedEventContract, G as ComputedEventContractSchema, H as ComputedEventListener, I as ComputedEventListenerSchema, J as CustomPatternDefinition, K as CustomPatternDefinitionInput, L as CustomPatternDefinitionSchema, M as CustomPatternMap, N as CustomPatternMapInput, Q as CustomPatternMapSchema, R as DerefEffect, V as DesignPreferences, W as DesignPreferencesInput, X as DesignPreferencesSchema, Y as DesignTokens, Z as DesignTokensInput, _ as DesignTokensSchema, $ as DespawnEffect, a0 as DoEffect, a1 as DomainCategory, a2 as DomainCategorySchema, a3 as DomainContext, a4 as DomainContextInput, a5 as DomainContextSchema, a6 as DomainVocabulary, a7 as DomainVocabularySchema, a8 as ENTITY_ROLES, a9 as Effect, aa as EffectInput, ab as EffectSchema, ac as EmitConfig, ad as EmitEffect, E as Entity, ae as EntityCall, af as EntityCallSchema, ag as EntityData, c as EntityField, ah as EntityFieldInput, ai as EntityFieldSchema, d as EntityPersistence, aj as EntityPersistenceSchema, f as EntityRef, ak as EntityRefSchema, al as EntityRefStringSchema, am as EntityRole, an as EntityRoleSchema, e as EntityRow, ao as EntitySchema, ap as EntitySemanticRole, aq as EntitySemanticRoleSchema, ar as Event, as as EventInput, at as EventListener, au as EventListenerSchema, av as EventPayloadField, aw as EventPayloadFieldSchema, ax as EventSchema, ay as EventScope, az as EventScopeSchema, aA as EventSemanticRole, aB as EventSemanticRoleSchema, aC as EventSource, aD as EventSourceSchema, aE as FetchEffect, aF as Field, aG as FieldFormat, aH as FieldFormatSchema, aI as FieldSchema, aJ as FieldType, aK as FieldTypeSchema, aL as FieldValue, aM as FullOrbitalUnit, aN as GAME_TYPES, aO as GameSubCategory, aP as GameSubCategorySchema, aQ as GameType, aR as GameTypeSchema, aS as Guard, aT as GuardInput, aU as GuardSchema, aV as ListenSource, aW as ListenSourceSchema, aX as LogEffect, aY as McpServiceDef, aZ as McpServiceDefSchema, a_ as NavigateEffect, a$ as NodeClassification, b0 as NodeClassificationSchema, b1 as NotifyEffect, aM as Orbital, b2 as OrbitalConfig, b3 as OrbitalConfigInput, b4 as OrbitalConfigSchema, b5 as OrbitalDefinitionSchema, b6 as OrbitalEntity, b7 as OrbitalEntityInput, b8 as OrbitalEntitySchema, b9 as OrbitalInput, ba as OrbitalPage, bb as OrbitalPageInput, bc as OrbitalPageSchema, bd as OrbitalPageStrictInput, be as OrbitalPageStrictSchema, bf as OrbitalSchemaInput, bg as OrbitalSchemaSchema, bh as OrbitalTraitRef, bi as OrbitalTraitRefSchema, bj as OrbitalUnit, bk as OrbitalUnitSchema, bl as OrbitalZodSchema, j as Page, P as PageRef, k as PageRefObject, bm as PageRefObjectSchema, bn as PageRefSchema, bo as PageRefStringSchema, bp as PageSchema, bq as PageTraitRef, br as PageTraitRefSchema, bs as PayloadField, bt as PayloadFieldSchema, bu as PersistEffect, bv as PresentationType, bw as RefEffect, bx as RelatedLink, by as RelatedLinkSchema, bz as RelationConfig, bA as RelationConfigSchema, bB as RenderItemLambda, bC as RenderUIConfig, bD as RenderUIEffect, bE as RenderUINode, bF as RequiredField, bG as RequiredFieldSchema, bH as ResolvedAsset, bI as ResolvedAssetInput, bJ as ResolvedAssetSchema, bK as ResolvedPatternProps, bL as RestAuthConfig, bM as RestAuthConfigSchema, bN as RestServiceDef, bO as RestServiceDefSchema, bP as SERVICE_TYPES, bQ as SemanticAssetRef, bR as SemanticAssetRefInput, bS as SemanticAssetRefSchema, bT as ServiceDefinition, bU as ServiceDefinitionSchema, bV as ServiceParams, bW as ServiceRef, bX as ServiceRefObject, bY as ServiceRefObjectSchema, bZ as ServiceRefSchema, b_ as ServiceRefStringSchema, b$ as ServiceType, c0 as ServiceTypeSchema, c1 as SetEffect, c2 as SocketEvents, c3 as SocketEventsSchema, c4 as SocketServiceDef, c5 as SocketServiceDefSchema, c6 as SpawnEffect, c7 as StateInput, c8 as StateMachine, c9 as StateMachineInput, ca as StateMachineSchema, cb as StateSchema, cc as StateSemanticRole, cd as StateSemanticRoleSchema, ce as SuggestedGuard, cf as SuggestedGuardSchema, cg as SwapEffect, ch as ThemeDefinition, ci as ThemeDefinitionSchema, cj as ThemeRef, ck as ThemeRefSchema, cl as ThemeRefStringSchema, cm as ThemeTokens, cn as ThemeTokensSchema, co as ThemeVariant, cp as ThemeVariantSchema, i as Trait, cq as TraitCategory, cr as TraitCategorySchema, b as TraitConfig, cs as TraitConfigObject, ct as TraitConfigSchema, cu as TraitConfigValue, cv as TraitConfigValueSchema, cw as TraitDataEntity, cx as TraitDataEntitySchema, cy as TraitEntityField, cz as TraitEntityFieldSchema, T as TraitEventContract, cA as TraitEventContractSchema, a as TraitEventListener, cB as TraitEventListenerSchema, cC as TraitInput, g as TraitRef, cD as TraitRefSchema, l as TraitReference, cE as TraitReferenceInput, cF as TraitReferenceSchema, cG as TraitSchema, cH as TraitTick, cI as TraitTickSchema, cJ as TraitUIBinding, cK as Transition, cL as TransitionInput, cM as TransitionSchema, cN as TypedEffect, cO as UISlot, cP as UISlotSchema, cQ as UI_SLOTS, cR as UXHints, cS as UXHintsSchema, U as UseDeclaration, cT as UseDeclarationSchema, cU as UserPersona, cV as UserPersonaInput, cW as UserPersonaSchema, cX as VISUAL_STYLES, cY as ViewType, cZ as ViewTypeSchema, c_ as VisualStyle, c$ as VisualStyleSchema, d0 as WatchEffect, d1 as WatchOptions, d2 as atomic, d3 as callService, d4 as createAssetKey, d5 as deref, d6 as deriveCollection, d7 as despawn, d8 as doEffects, d9 as emit, da as findService, db as getDefaultAnimationsForRole, dc as getServiceNames, dd as getTraitConfig, de as getTraitName, df as hasService, dg as isCircuitEvent, dh as isEffect, di as isEntityCall, dj as isEntityReference, dk as isEntityReferenceAny, dl as isImportedTraitRef, dm as isInlineTrait, dn as isMcpService, dp as isOrbitalDefinition, dq as isPageReference, dr as isPageReferenceObject, ds as isPageReferenceString, dt as isRestService, du as isRuntimeEntity, dv as isSExprEffect, dw as isServiceReference, dx as isServiceReferenceObject, dy as isSingletonEntity, dz as isSocketService, dA as isThemeReference, dB as navigate, dC as normalizeTraitRef, dD as notify, dE as parseAssetKey, dF as parseEntityRef, dG as parseImportedTraitRef, dH as parseOrbitalSchema, dI as parsePageRef, dJ as parseServiceRef, dK as persist, dL as ref, dM as renderUI, dN as safeParseOrbitalSchema, dO as set, dP as spawn, dQ as swap, dR as validateAssetAnimations, dS as watch } from './schema-OhIbVaYu.js';
3
+ export { C as CORE_BINDINGS, a as CoreBinding, E as EvalContext, b as EventPayload, c as EventPayloadValue, d as Expression, e as ExpressionInput, f as ExpressionSchema, L as LogMeta, P as ParsedBinding, S as SExpr, g as SExprAtom, h as SExprAtomSchema, i as SExprInput, j as SExprSchema, k as collectBindings, l as getArgs, m as getOperator, n as isBinding, o as isSExpr, p as isSExprAtom, q as isSExprCall, r as isValidBinding, s as parseBinding, t as sexpr, w as walkSExpr } from './expression-eBO9-SQM.js';
3
4
  import { ResolvedIR, ResolvedEntity, ResolvedPage, ResolvedTrait, SchemaChange, CategorizedRemovals, PageContentReduction, SemanticSchemaChange } from './types/index.js';
4
5
  export { AgentCodeSearchResult, AgentCompactResult, AgentCompactStrategy, AgentContext, AgentGenerateOptions, AgentMemoryCategory, AgentMemoryRecord, AppSummary, AssetLoadStatus, BINDING_CONTEXT_RULES, BINDING_DOCS, BINDING_ROOTS, BindingContext, BindingRoot, BindingSchema, BridgeHealth, BusEvent, BusEventListener, BusEventSource, ChangeAuthor, ChangeSetDocument, ChangeSummary, CheckStatus, ContextExtensions, CreateFlow, DEFAULT_INTERACTION_MODELS, DeleteFlow, EditFlow, EffectTrace, EventKey, EventLogEntry, GitHubLink, HistoryMeta, InteractionModel, InteractionModelInput, InteractionModelSchema, LazyService, ListInteraction, OrbitalVerificationAPI, PatternTypeSchema, PersistActionName, ResolvedEntityBinding, ResolvedField, ResolvedNavigation, ResolvedPattern, ResolvedSection, ResolvedSectionEvent, ResolvedTraitBinding, ResolvedTraitDataEntity, ResolvedTraitEvent, ResolvedTraitGuard, ResolvedTraitListener, ResolvedTraitState, ResolvedTraitTick, ResolvedTraitTransition, ResolvedTraitUIBinding, SaveOptions, SaveResult, SemanticChangeKind, ServerResponseTrace, ServiceAction, ServiceActionName, ServiceContract, ServiceEvents, SnapshotDocument, StatsView, StoreContract, StoreFilter, StoreFilterOp, TraitStateSnapshot, TransitionFrom, TransitionTrace, Unsubscribe, ValidationDocument, ValidationIssue, ValidationMeta, ValidationResults, VerificationCheck, VerificationSnapshot, VerificationSummary, ViewFlow, createEmptyResolvedPage, createEmptyResolvedTrait, createLazyService, createResolvedField, createTypedEventBus, getAllPatternTypes, getBindingExamples, getInteractionModelForDomain, inferTsType, isResolvedIR, toBindingRoot, validateBindingInContext } from './types/index.js';
5
6
  export { ASTNode, ComparisonCondition, ComparisonOperator, DomainBehavior, DomainChunk, DomainDocument, DomainEffect, DomainEntity, DomainField, DomainFieldType, DomainGuard, DomainPage, DomainPageAction, DomainPageSection, DomainRelationship, DomainTick, DomainToSchemaResult, DomainTransition, EFFECT_REGISTRY, EffectMapping, EffectType, FIELD_TYPE_REGISTRY, FieldCheckCondition, FieldReference, FieldTypeMapping, GUARD_REGISTRY, GuardCondition, GuardMapping, KEYWORDS, Lexer, LogicalCondition, LogicalOperator, MULTI_WORD_KEYWORDS, MappingStore, MergeResult, ParseError, ParseResult, RelationshipType, SchemaToDomainResult, SectionMapping, SourceLocation, SourceRange, Token, TokenType, UserCheckCondition, applySectionUpdate, computeSchemaHash, convertDomainToSchema, convertEntitiesToDomain, convertPagesToDomain, convertSchemaToDomain, convertTraitsToDomain, createMappingStore, deleteSection, detectChanges, domainKeywordToSchemaType, findMapping, findMappingByPath, findMappingsByType, formatBehaviorToDomain, formatBehaviorToSchema, formatDomainGuardToSchema, formatEntityToDomain, formatEntityToSchema, formatGuardConditionToDomain, formatGuardToDomain, formatGuardToSchema, formatMergeSummary, formatPageToDomain, formatPageToSchema, formatSchemaEntityToDomain, formatSchemaGuardToDomain, formatSchemaPageToDomain, formatSchemaTraitToDomain, generateDomainLanguageReference, generateSectionId, getEffectMapping, getFieldTypeMapping, getGuardMapping, getRegisteredEffects, getRegisteredFieldTypes, getRegisteredGuards, getRegistryStats, getSchemaPath, hasSchemaChanged, isEffectRegistered, isFieldTypeRegistered, isGuardRegistered, mergeDomainChunks, parseBehavior, parseDomainEffect, parseDomainEffects, parseDomainGuard, parseEntity, parseGuard, parsePage, parseSectionId, removeMapping, resolveConflict, schemaEntityToDomainEntity, schemaPageToDomainPage, schemaTraitToDomainBehavior, schemaTypeToDomainKeyword, tokenize, updateMappingRange, updateSchemaHash, upsertMapping, validateDomainChunk } from './domain-language/index.js';
6
- export { C as ComposeBehaviorsInput, a as ComposeBehaviorsResult, E as EventWiringEntry, L as LayoutStrategy, b as applyEventWiring, c as composeBehaviors, d as detectLayoutStrategy } from './compose-behaviors-BLX6CbU3.js';
7
+ export { C as ComposeBehaviorsInput, a as ComposeBehaviorsResult, E as EventWiringEntry, L as LayoutStrategy, b as applyEventWiring, c as composeBehaviors, d as detectLayoutStrategy } from './compose-behaviors-DPPX5a_s.js';
7
8
  export { BFSNode, BFSPathNode, EdgeWalkTransition, GraphTransition, GuardPayload, ReplayStep, ReplayTransition, StateEdge, WalkStep, buildEdgeCoveringWalk, buildGuardPayloads, buildReplayPaths, buildStateGraph, collectReachableStates, extractPayloadFieldRef, walkStatePairs } from './state-machine/index.js';
8
9
  export { PATTERN_TYPES, PatternConfig, PatternType, isValidPatternType } from '@almadar/patterns';
9
10
  import 'zod';
package/dist/index.js CHANGED
@@ -67,7 +67,7 @@ var EntityFieldSchema = z.lazy(
67
67
  return input;
68
68
  },
69
69
  z.object({
70
- name: z.string().min(1, "Field name is required"),
70
+ name: z.string().min(1, "Field name is required").optional(),
71
71
  type: FieldTypeSchema,
72
72
  required: z.boolean().optional(),
73
73
  default: z.unknown().optional(),
@@ -429,7 +429,7 @@ var StateSchema = z.object({
429
429
  });
430
430
  var PayloadFieldSchema = z.object({
431
431
  name: z.string().min(1),
432
- type: z.enum(["string", "number", "boolean", "object", "array"]),
432
+ type: z.string().min(1),
433
433
  required: z.boolean().optional()
434
434
  });
435
435
  var EventSchema = z.object({
@@ -533,15 +533,32 @@ var TraitTickSchema = z.object({
533
533
  var EventScopeSchema = z.enum(["internal", "external"]);
534
534
  var EventPayloadFieldSchema = z.object({
535
535
  name: z.string().min(1),
536
- type: z.enum(["string", "number", "boolean", "object", "array", "entity"]),
536
+ /**
537
+ * Field type. Mirrors the Rust validator's acceptance: any non-empty
538
+ * string. Primitives ('string' | 'number' | 'boolean' | 'object' |
539
+ * 'array') are the canonical values; entity-name references like
540
+ * 'ModalRecord' and array-of-entity references like '[ModalRecord]'
541
+ * are also valid because the Rust IR's PayloadField.field_type is
542
+ * just a String. Only enforced narrowly at the call site (e.g.
543
+ * emit-literal type-mismatch warnings in
544
+ * orbital-compiler/phases/validation/emit_payload.rs) — not here.
545
+ */
546
+ type: z.string().min(1),
537
547
  required: z.boolean().optional(),
538
548
  description: z.string().optional(),
539
549
  entityType: z.string().optional()
540
550
  });
541
551
  var TraitEventContractSchema = z.object({
552
+ /**
553
+ * Event name. Mirrors the Rust validator's `is_valid_event_identifier`:
554
+ * starts with a letter, then any letters / digits / underscores. Both
555
+ * UPPER_SNAKE_CASE and PascalCase shapes are valid identifiers in the
556
+ * post-Phase 2.5 nominal-event type system (events declared via
557
+ * `type X = Event<T>`).
558
+ */
542
559
  event: z.string().min(1).regex(
543
- /^[A-Z][A-Z0-9_]*$/,
544
- "Event name must be UPPER_SNAKE_CASE"
560
+ /^[A-Za-z][A-Za-z0-9_]*$/,
561
+ "Event name must start with a letter and contain only letters, digits, and underscores"
545
562
  ),
546
563
  description: z.string().optional(),
547
564
  payloadSchema: z.array(EventPayloadFieldSchema).optional(),
@@ -1016,6 +1033,7 @@ var EntityCallSchema = z.object({
1016
1033
  if (!call.fields) return true;
1017
1034
  const seen = /* @__PURE__ */ new Set();
1018
1035
  for (const field of call.fields) {
1036
+ if (field.name === void 0) continue;
1019
1037
  if (seen.has(field.name)) return false;
1020
1038
  seen.add(field.name);
1021
1039
  }
@@ -1209,16 +1227,16 @@ var BINDING_DOCS = {
1209
1227
  };
1210
1228
  var BINDING_CONTEXT_RULES = {
1211
1229
  guard: {
1212
- allowed: ["entity", "payload", "state", "now"],
1213
- description: "Guards can access entity fields, event payload, current state, and time"
1230
+ allowed: ["entity", "payload", "state", "now", "config"],
1231
+ description: `Guards can access entity fields, event payload, current state, time, and the call-site trait config (@config.X). Config access lets atoms write mode-aware guards \u2014 e.g. std-modal's OPEN can require @payload.row only when @config.mode equals "edit", letting create-mode legitimately fire OPEN with no row. Like effects, @config.X is substituted at molecule/organism inline time with the literal call-site value; at atom-scope validate, @config is allowed-but-unresolved.`
1214
1232
  },
1215
1233
  effect: {
1216
1234
  allowed: ["entity", "payload", "state", "now", "trait", "config"],
1217
1235
  description: "Effects can access and modify entity fields, use payload data, embed another trait's live frame via @trait.X inside render-ui children, and read trait config values (@config.X) for atoms parameterized by their call-site. At molecule/organism inline time, @config.X is substituted with the literal value from the call-site config block; at atom-scope validate, @config is allowed-but-unresolved."
1218
1236
  },
1219
1237
  tick: {
1220
- allowed: ["entity", "state", "now"],
1221
- description: "Ticks can access entity fields, current state, and time (no payload)"
1238
+ allowed: ["entity", "state", "now", "config"],
1239
+ description: "Ticks can access entity fields, current state, time, and trait config (@config.X) for parameterized atoms. Same substitution semantics as guards/effects."
1222
1240
  }
1223
1241
  };
1224
1242
  function validateBindingInContext(binding, context) {
@@ -1435,7 +1453,9 @@ function schemaToIR(schema, useCache = true) {
1435
1453
  // eslint-disable-next-line almadar/no-record-string-unknown -- icon is an optional extension not on Entity type
1436
1454
  icon: entityDef.icon,
1437
1455
  collection: entityDef.collection || entityDef.name.toLowerCase() + "s",
1438
- fields: (entityDef.fields || []).map((field) => ({
1456
+ fields: (entityDef.fields || []).filter(
1457
+ (field) => typeof field.name === "string" && field.name.length > 0
1458
+ ).map((field) => ({
1439
1459
  name: field.name,
1440
1460
  type: field.type,
1441
1461
  tsType: inferTsType2(field.type),
@@ -8331,6 +8351,10 @@ function extractPayloadFieldRef(ref2) {
8331
8351
  return match ? match[1] : null;
8332
8352
  }
8333
8353
  function buildGuardPayloads(guard) {
8354
+ if (typeof guard === "string") {
8355
+ const field = extractPayloadFieldRef(guard);
8356
+ if (field) return { pass: { [field]: { id: "mock-test-id", name: "mock-test-name" } }, fail: { [field]: null } };
8357
+ }
8334
8358
  if (!Array.isArray(guard) || guard.length === 0) {
8335
8359
  return { pass: {}, fail: {} };
8336
8360
  }
@@ -8389,11 +8413,12 @@ function buildGuardPayloads(guard) {
8389
8413
  if (subs.length === 1) return buildGuardPayloads(subs[0]);
8390
8414
  }
8391
8415
  if (op === "or") {
8392
- const subs = guard.slice(1).filter(Array.isArray);
8416
+ const subs = guard.slice(1);
8393
8417
  if (subs.length >= 2) {
8394
8418
  const s1 = buildGuardPayloads(subs[0]);
8395
8419
  const s2 = buildGuardPayloads(subs[1]);
8396
- return { pass: s1.pass, fail: { ...s1.fail, ...s2.fail } };
8420
+ const combinedPass = Object.keys(s1.pass).length > 0 ? s1.pass : s2.pass;
8421
+ return { pass: combinedPass, fail: { ...s1.fail, ...s2.fail } };
8397
8422
  }
8398
8423
  if (subs.length === 1) return buildGuardPayloads(subs[0]);
8399
8424
  }