@almadar/core 2.8.0 → 2.9.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/dist/index.d.ts +1 -1
- package/dist/index.js +149 -1
- package/dist/index.js.map +1 -1
- package/dist/state-machine/index.d.ts +56 -1
- package/dist/state-machine/index.js +149 -1
- package/dist/state-machine/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ResolvedIR, ResolvedEntity, ResolvedPage, ResolvedTrait, SchemaChange,
|
|
|
4
4
|
export { AppSummary, BINDING_CONTEXT_RULES, BINDING_DOCS, BindingContext, BindingSchema, ChangeAuthor, ChangeSetDocument, ChangeSummary, CreateFlow, DEFAULT_INTERACTION_MODELS, DeleteFlow, EditFlow, GitHubLink, HistoryMeta, InteractionModel, InteractionModelInput, InteractionModelSchema, LazyService, ListInteraction, OperatorName, PatternTypeSchema, PersistActionName, ResolvedEntityBinding, ResolvedField, ResolvedNavigation, ResolvedPattern, ResolvedSection, ResolvedSectionEvent, ResolvedTraitBinding, ResolvedTraitDataEntity, ResolvedTraitEvent, ResolvedTraitGuard, ResolvedTraitListener, ResolvedTraitState, ResolvedTraitTick, ResolvedTraitTransition, ResolvedTraitUIBinding, SaveOptions, SaveResult, ServiceAction, ServiceActionName, ServiceContract, ServiceEvents, SnapshotDocument, StatsView, StoreContract, StoreFilter, StoreFilterOp, TransitionFrom, ValidationDocument, ValidationIssue, ValidationMeta, ValidationResults, ViewFlow, createEmptyResolvedPage, createEmptyResolvedTrait, createLazyService, createResolvedField, createTypedEventBus, getAllOperators, getAllPatternTypes, getBindingExamples, getInteractionModelForDomain, inferTsType, isResolvedIR, validateBindingInContext } from './types/index.js';
|
|
5
5
|
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
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-j53THIou.js';
|
|
7
|
-
export { BFSNode, BFSPathNode, GraphTransition, GuardPayload, ReplayStep, ReplayTransition, StateEdge, buildGuardPayloads, buildReplayPaths, buildStateGraph, collectReachableStates, extractPayloadFieldRef, walkStatePairs } from './state-machine/index.js';
|
|
7
|
+
export { BFSNode, BFSPathNode, EdgeWalkTransition, GraphTransition, GuardPayload, ReplayStep, ReplayTransition, StateEdge, WalkStep, buildEdgeCoveringWalk, buildGuardPayloads, buildReplayPaths, buildStateGraph, collectReachableStates, extractPayloadFieldRef, walkStatePairs } from './state-machine/index.js';
|
|
8
8
|
export { CATEGORIES, CategoryMeta, OPERATORS, OPERATORS_SCHEMA, OPERATOR_NAMES, OperatorCategory, OperatorMeta, OperatorStats, OperatorsSchema, TargetPlatform, getOperatorMeta, getOperatorStats, getOperatorsByCategory, getOperatorsForTarget, isEffectOperator, isGuardOperator, isKnownOperator, validateOperatorArity } from '@almadar/operators';
|
|
9
9
|
export { PATTERN_TYPES, PatternConfig, PatternType, isValidPatternType } from '@almadar/patterns';
|
|
10
10
|
import 'zod';
|
package/dist/index.js
CHANGED
|
@@ -8080,6 +8080,154 @@ function buildReplayPaths(transitions, initialState, maxDepth = 3) {
|
|
|
8080
8080
|
return replayPaths;
|
|
8081
8081
|
}
|
|
8082
8082
|
|
|
8083
|
-
|
|
8083
|
+
// src/state-machine/edge-walk.ts
|
|
8084
|
+
function buildEdgeCoveringWalk(transitions, initialState) {
|
|
8085
|
+
const filtered = transitions.filter(
|
|
8086
|
+
(t) => t.from !== "*" && t.event !== "INIT"
|
|
8087
|
+
);
|
|
8088
|
+
const graph = /* @__PURE__ */ new Map();
|
|
8089
|
+
const allStates = /* @__PURE__ */ new Set();
|
|
8090
|
+
for (const t of filtered) {
|
|
8091
|
+
allStates.add(t.from);
|
|
8092
|
+
allStates.add(t.to);
|
|
8093
|
+
if (!graph.has(t.from)) graph.set(t.from, []);
|
|
8094
|
+
graph.get(t.from).push({ event: t.event, to: t.to, transition: t });
|
|
8095
|
+
}
|
|
8096
|
+
allStates.add(initialState);
|
|
8097
|
+
const uncovered = /* @__PURE__ */ new Set();
|
|
8098
|
+
const edgeMeta = /* @__PURE__ */ new Map();
|
|
8099
|
+
for (const t of filtered) {
|
|
8100
|
+
if (t.hasGuard) {
|
|
8101
|
+
const keyPass = `${t.from}+${t.event}->${t.to}[pass]`;
|
|
8102
|
+
const keyFail = `${t.from}+${t.event}->${t.to}[fail]`;
|
|
8103
|
+
uncovered.add(keyPass);
|
|
8104
|
+
uncovered.add(keyFail);
|
|
8105
|
+
edgeMeta.set(keyPass, { transition: t, guardCase: "pass" });
|
|
8106
|
+
edgeMeta.set(keyFail, { transition: t, guardCase: "fail" });
|
|
8107
|
+
} else {
|
|
8108
|
+
const key = `${t.from}+${t.event}->${t.to}`;
|
|
8109
|
+
uncovered.add(key);
|
|
8110
|
+
edgeMeta.set(key, { transition: t, guardCase: null });
|
|
8111
|
+
}
|
|
8112
|
+
}
|
|
8113
|
+
if (uncovered.size === 0) return [];
|
|
8114
|
+
const shortestPaths = /* @__PURE__ */ new Map();
|
|
8115
|
+
for (const state of allStates) {
|
|
8116
|
+
shortestPaths.set(state, bfsShortestPaths(state, graph));
|
|
8117
|
+
}
|
|
8118
|
+
const walk = [];
|
|
8119
|
+
let currentState = initialState;
|
|
8120
|
+
const maxIterations = uncovered.size * allStates.size * 2;
|
|
8121
|
+
let iterations = 0;
|
|
8122
|
+
while (uncovered.size > 0 && iterations < maxIterations) {
|
|
8123
|
+
iterations++;
|
|
8124
|
+
const outgoing = findUncoveredEdges(currentState, graph, uncovered);
|
|
8125
|
+
if (outgoing.length > 0) {
|
|
8126
|
+
const pick = outgoing[0];
|
|
8127
|
+
const payload = buildPayloadForEdge(pick.transition, pick.guardCase);
|
|
8128
|
+
walk.push({
|
|
8129
|
+
from: currentState,
|
|
8130
|
+
event: pick.transition.event,
|
|
8131
|
+
to: pick.transition.to,
|
|
8132
|
+
guardCase: pick.guardCase,
|
|
8133
|
+
payload,
|
|
8134
|
+
isRepositioning: false
|
|
8135
|
+
});
|
|
8136
|
+
uncovered.delete(pick.key);
|
|
8137
|
+
if (pick.guardCase !== "fail") {
|
|
8138
|
+
currentState = pick.transition.to;
|
|
8139
|
+
}
|
|
8140
|
+
} else {
|
|
8141
|
+
const target = findNearestUncoveredState(currentState, graph, uncovered, shortestPaths);
|
|
8142
|
+
if (!target) {
|
|
8143
|
+
break;
|
|
8144
|
+
}
|
|
8145
|
+
const repoPath = shortestPaths.get(currentState)?.get(target);
|
|
8146
|
+
if (!repoPath || repoPath.length === 0) break;
|
|
8147
|
+
for (const step of repoPath) {
|
|
8148
|
+
walk.push({
|
|
8149
|
+
from: currentState,
|
|
8150
|
+
event: step.event,
|
|
8151
|
+
to: step.to,
|
|
8152
|
+
guardCase: null,
|
|
8153
|
+
payload: {},
|
|
8154
|
+
isRepositioning: true
|
|
8155
|
+
});
|
|
8156
|
+
currentState = step.to;
|
|
8157
|
+
}
|
|
8158
|
+
}
|
|
8159
|
+
}
|
|
8160
|
+
return walk;
|
|
8161
|
+
}
|
|
8162
|
+
function bfsShortestPaths(source, graph) {
|
|
8163
|
+
const paths = /* @__PURE__ */ new Map();
|
|
8164
|
+
const visited = /* @__PURE__ */ new Set([source]);
|
|
8165
|
+
const queue = [
|
|
8166
|
+
{ state: source, path: [] }
|
|
8167
|
+
];
|
|
8168
|
+
while (queue.length > 0) {
|
|
8169
|
+
const { state, path } = queue.shift();
|
|
8170
|
+
const edges = graph.get(state) ?? [];
|
|
8171
|
+
for (const edge of edges) {
|
|
8172
|
+
if (visited.has(edge.to)) continue;
|
|
8173
|
+
visited.add(edge.to);
|
|
8174
|
+
const newPath = [...path, { event: edge.event, to: edge.to }];
|
|
8175
|
+
paths.set(edge.to, newPath);
|
|
8176
|
+
queue.push({ state: edge.to, path: newPath });
|
|
8177
|
+
}
|
|
8178
|
+
}
|
|
8179
|
+
return paths;
|
|
8180
|
+
}
|
|
8181
|
+
function findUncoveredEdges(state, graph, uncovered) {
|
|
8182
|
+
const edges = graph.get(state) ?? [];
|
|
8183
|
+
const result = [];
|
|
8184
|
+
for (const edge of edges) {
|
|
8185
|
+
if (edge.transition.hasGuard) {
|
|
8186
|
+
const keyPass = `${state}+${edge.event}->${edge.to}[pass]`;
|
|
8187
|
+
const keyFail = `${state}+${edge.event}->${edge.to}[fail]`;
|
|
8188
|
+
if (uncovered.has(keyPass)) {
|
|
8189
|
+
result.push({ key: keyPass, transition: edge.transition, guardCase: "pass" });
|
|
8190
|
+
}
|
|
8191
|
+
if (uncovered.has(keyFail)) {
|
|
8192
|
+
result.push({ key: keyFail, transition: edge.transition, guardCase: "fail" });
|
|
8193
|
+
}
|
|
8194
|
+
} else {
|
|
8195
|
+
const key = `${state}+${edge.event}->${edge.to}`;
|
|
8196
|
+
if (uncovered.has(key)) {
|
|
8197
|
+
result.push({ key, transition: edge.transition, guardCase: null });
|
|
8198
|
+
}
|
|
8199
|
+
}
|
|
8200
|
+
}
|
|
8201
|
+
return result;
|
|
8202
|
+
}
|
|
8203
|
+
function findNearestUncoveredState(currentState, graph, uncovered, shortestPaths) {
|
|
8204
|
+
const statesWithUncovered = /* @__PURE__ */ new Set();
|
|
8205
|
+
for (const key of uncovered) {
|
|
8206
|
+
const fromState = key.split("+")[0];
|
|
8207
|
+
statesWithUncovered.add(fromState);
|
|
8208
|
+
}
|
|
8209
|
+
if (statesWithUncovered.has(currentState)) return currentState;
|
|
8210
|
+
const paths = shortestPaths.get(currentState);
|
|
8211
|
+
if (!paths) return null;
|
|
8212
|
+
let nearestState = null;
|
|
8213
|
+
let nearestDist = Infinity;
|
|
8214
|
+
for (const target of statesWithUncovered) {
|
|
8215
|
+
const path = paths.get(target);
|
|
8216
|
+
if (path && path.length < nearestDist) {
|
|
8217
|
+
nearestDist = path.length;
|
|
8218
|
+
nearestState = target;
|
|
8219
|
+
}
|
|
8220
|
+
}
|
|
8221
|
+
return nearestState;
|
|
8222
|
+
}
|
|
8223
|
+
function buildPayloadForEdge(transition, guardCase) {
|
|
8224
|
+
if (!transition.hasGuard || !transition.guard || !guardCase) {
|
|
8225
|
+
return {};
|
|
8226
|
+
}
|
|
8227
|
+
const payloads = buildGuardPayloads(transition.guard);
|
|
8228
|
+
return guardCase === "pass" ? payloads.pass : payloads.fail;
|
|
8229
|
+
}
|
|
8230
|
+
|
|
8231
|
+
export { AGENT_DOMAIN_CATEGORIES, ALLOWED_CUSTOM_COMPONENTS, AgentDomainCategorySchema, AnimationDefSchema, AssetMapSchema, AssetMappingSchema, BINDING_CONTEXT_RULES, BINDING_DOCS, BindingSchema, CORE_BINDINGS, ComputedEventContractSchema, ComputedEventListenerSchema, CustomPatternDefinitionSchema, CustomPatternMapSchema, DEFAULT_INTERACTION_MODELS, DesignPreferencesSchema, DesignTokensSchema, DomainCategorySchema, DomainContextSchema, DomainVocabularySchema, EFFECT_REGISTRY, ENTITY_ROLES, EffectSchema, EntityFieldSchema, EntityPersistenceSchema, EntityRefSchema, EntityRefStringSchema, EntityRoleSchema, EntitySchema, EntitySemanticRoleSchema, EventListenerSchema, EventPayloadFieldSchema, EventSchema, EventScopeSchema, EventSemanticRoleSchema, EventSourceSchema, ExpressionSchema, FIELD_TYPE_REGISTRY, FieldFormatSchema, FieldSchema, FieldTypeSchema, GAME_TYPES, GUARD_REGISTRY, GameSubCategorySchema, GameTypeSchema, GuardSchema, InteractionModelSchema, KEYWORDS, Lexer, MULTI_WORD_KEYWORDS, McpServiceDefSchema, NodeClassificationSchema, OrbitalConfigSchema, OrbitalDefinitionSchema, OrbitalEntitySchema, OrbitalPageSchema, OrbitalPageStrictSchema, OrbitalSchemaSchema, OrbitalTraitRefSchema, OrbitalUnitSchema, OrbitalSchema as OrbitalZodSchema, PageRefObjectSchema, PageRefSchema, PageRefStringSchema, PageSchema, PageTraitRefSchema, PatternTypeSchema, PayloadFieldSchema, RelatedLinkSchema, RelationConfigSchema, RequiredFieldSchema, ResolvedAssetSchema, RestAuthConfigSchema, RestServiceDefSchema, SERVICE_TYPES, SExprAtomSchema, SExprSchema, SemanticAssetRefSchema, ServiceDefinitionSchema, ServiceRefSchema, ServiceRefStringSchema, ServiceTypeSchema, SocketEventsSchema, SocketServiceDefSchema, StateMachineSchema, StateSchema, StateSemanticRoleSchema, SuggestedGuardSchema, ThemeDefinitionSchema, ThemeRefSchema, ThemeRefStringSchema, ThemeTokensSchema, ThemeVariantSchema, TokenType, TraitCategorySchema, TraitDataEntitySchema, TraitEntityFieldSchema, TraitEventContractSchema, TraitEventListenerSchema, TraitRefSchema, TraitReferenceSchema, TraitSchema, TraitTickSchema, TransitionSchema, UISlotSchema, UI_SLOTS, UXHintsSchema, UseDeclarationSchema, UserPersonaSchema, VISUAL_STYLES, ViewTypeSchema, VisualStyleSchema, applyEventWiring, applySectionUpdate, atomic, buildEdgeCoveringWalk, buildGuardPayloads, buildReplayPaths, buildStateGraph, callService, categorizeRemovals, classifyWorkflow, clearSchemaCache, collectBindings, collectReachableStates, composeBehaviors, computeSchemaHash, convertDomainToSchema, convertEntitiesToDomain, convertPagesToDomain, convertSchemaToDomain, convertTraitsToDomain, createAssetKey, createEmptyResolvedPage, createEmptyResolvedTrait, createLazyService, createMappingStore, createResolvedField, createTypedEventBus, deleteSection, deref, deriveCollection, despawn, detectChanges, detectLayoutStrategy, detectPageContentReduction, diffSchemas, doEffects, domainKeywordToSchemaType, emit, extractPayloadFieldRef, findMapping, findMappingByPath, findMappingsByType, findService, formatBehaviorToDomain, formatBehaviorToSchema, formatDomainGuardToSchema, formatEntityToDomain, formatEntityToSchema, formatGuardConditionToDomain, formatGuardToDomain, formatGuardToSchema, formatMergeSummary, formatPageToDomain, formatPageToSchema, formatSchemaEntityToDomain, formatSchemaGuardToDomain, formatSchemaPageToDomain, formatSchemaTraitToDomain, generateDomainLanguageReference, generateSectionId, getAllOperators, getAllPatternTypes, getArgs, getBindingExamples, getDefaultAnimationsForRole, getEffectMapping, getEntity, getFieldTypeMapping, getGuardMapping, getInteractionModelForDomain, getOperator, getPage, getPages, getRegisteredEffects, getRegisteredFieldTypes, getRegisteredGuards, getRegistryStats, getRemovals, getSchemaCacheStats, getSchemaPath, getServiceNames, getTrait, getTraitConfig, getTraitName, hasSchemaChanged, hasService, hasSignificantPageReduction, inferTsType, isBinding, isCircuitEvent, isDestructiveChange, isEffect, isEffectRegistered, isEntityReference, isFieldTypeRegistered, isGuardRegistered, isImportedTraitRef, isInlineTrait, isMcpService, isOrbitalDefinition, isPageReference, isPageReferenceObject, isPageReferenceString, isResolvedIR, isRestService, isRuntimeEntity, isSExpr, isSExprAtom, isSExprCall, isSExprEffect, isServiceReference, isSingletonEntity, isSocketService, isThemeReference, isValidBinding, mergeDomainChunks, navigate, normalizeTraitRef, notify, parseAssetKey, parseBehavior, parseBinding, parseDomainEffect, parseDomainEffects, parseDomainGuard, parseEntity, parseEntityRef, parseGuard, parseImportedTraitRef, parseOrbitalSchema, parsePage, parsePageRef, parseSectionId, parseServiceRef, persist, ref, removeMapping, renderUI, requiresConfirmation, resolveConflict, safeParseOrbitalSchema, schemaEntityToDomainEntity, schemaPageToDomainPage, schemaToIR, schemaTraitToDomainBehavior, schemaTypeToDomainKeyword, set, sexpr, spawn, summarizeOrbital, summarizeSchema, swap, tokenize, updateMappingRange, updateSchemaHash, upsertMapping, validateAssetAnimations, validateBindingInContext, validateDomainChunk, walkSExpr, walkStatePairs, watch };
|
|
8084
8232
|
//# sourceMappingURL=index.js.map
|
|
8085
8233
|
//# sourceMappingURL=index.js.map
|