@vectoriox/iox-ui 5.52.0 → 5.53.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.
@@ -9979,6 +9979,147 @@ function buildStepFacts(plan, actions = {}) {
9979
9979
  };
9980
9980
  }
9981
9981
 
9982
+ /**
9983
+ * The AI pipeline's WIRE vocabulary (AI plan §3c, §3n, M0): what iox-cms's `ai` API answers and what every client
9984
+ * of it reads — the steps a model works on, who pays (IOX credits or the studio's own key), a model of the vetted
9985
+ * list with its price per token class, the one cost → credits rule (1 credit = 1 US cent of what the AI cost, D4),
9986
+ * the refusals (board 11) and a generation's stages. ONE definition: iox-cms meters and refuses with it, the
9987
+ * Settings ▸ AI screen and the wizard show it. Pure types, enums and helpers; no transport, no prices typed here.
9988
+ */
9989
+ var AiProviderId;
9990
+ (function (AiProviderId) {
9991
+ AiProviderId["Anthropic"] = "anthropic";
9992
+ AiProviderId["OpenRouter"] = "openrouter";
9993
+ })(AiProviderId || (AiProviderId = {}));
9994
+ /** Who pays: the platform's credits, or the studio's own provider key (metered for display, never charged). */
9995
+ var AiKeyMode;
9996
+ (function (AiKeyMode) {
9997
+ AiKeyMode["Platform"] = "platform";
9998
+ AiKeyMode["Own"] = "own";
9999
+ })(AiKeyMode || (AiKeyMode = {}));
10000
+ /** The steps a model works on (board 9's rows), in screen order. */
10001
+ var AiStep;
10002
+ (function (AiStep) {
10003
+ AiStep["ReadMessage"] = "read";
10004
+ AiStep["PlanSite"] = "plan";
10005
+ AiStep["ChangePlan"] = "change";
10006
+ AiStep["MakePictures"] = "pictures";
10007
+ AiStep["NameStructures"] = "scan";
10008
+ })(AiStep || (AiStep = {}));
10009
+ const AI_STEPS = Object.values(AiStep);
10010
+ /** What a model must be able to do for a step to run on it. */
10011
+ var AiCapability;
10012
+ (function (AiCapability) {
10013
+ AiCapability["StructuredOutput"] = "structured-output";
10014
+ AiCapability["ImageInput"] = "image-input";
10015
+ AiCapability["ImageOutput"] = "image-output";
10016
+ })(AiCapability || (AiCapability = {}));
10017
+ const AI_STEP_NEEDS = {
10018
+ [AiStep.ReadMessage]: [AiCapability.StructuredOutput, AiCapability.ImageInput],
10019
+ [AiStep.PlanSite]: [AiCapability.StructuredOutput],
10020
+ [AiStep.ChangePlan]: [AiCapability.StructuredOutput],
10021
+ [AiStep.MakePictures]: [AiCapability.ImageOutput],
10022
+ [AiStep.NameStructures]: [AiCapability.StructuredOutput],
10023
+ };
10024
+ /** Tokens a typical use of a step reads and writes (plan §3d "Where credits go") — what a shown estimate is made of. */
10025
+ const AI_STEP_TYPICAL_TOKENS = {
10026
+ [AiStep.ReadMessage]: { input: 8_800, output: 1_500, cacheWrite: 0, cacheRead: 0 },
10027
+ [AiStep.PlanSite]: { input: 12_000, output: 7_000, cacheWrite: 0, cacheRead: 0 },
10028
+ [AiStep.ChangePlan]: { input: 6_000, output: 500, cacheWrite: 0, cacheRead: 0 },
10029
+ [AiStep.MakePictures]: { input: 1_120, output: 0, cacheWrite: 0, cacheRead: 0 },
10030
+ [AiStep.NameStructures]: { input: 80_000, output: 10_000, cacheWrite: 0, cacheRead: 0 },
10031
+ };
10032
+ /** 1 credit = 1 US cent of what the AI actually cost (decision D4). */
10033
+ const CREDITS_PER_USD = 100;
10034
+ const TOKENS_PER_PRICE_UNIT = 1_000_000;
10035
+ const CREDIT_PRECISION = 1e6;
10036
+ const NO_TOKENS = Object.freeze({ input: 0, output: 0, cacheWrite: 0, cacheRead: 0 });
10037
+ /** What `tokens` cost at `price`, in US dollars. */
10038
+ function costUsd(tokens, price) {
10039
+ const perToken = (perMillion, fallback) => (perMillion ?? fallback) / TOKENS_PER_PRICE_UNIT;
10040
+ return tokens.input * perToken(price.input, 0)
10041
+ + tokens.output * perToken(price.output, 0)
10042
+ + tokens.cacheWrite * perToken(price.cacheWrite, price.input)
10043
+ + tokens.cacheRead * perToken(price.cacheRead, price.input);
10044
+ }
10045
+ /** Dollars → credits, kept to a millionth of a credit (a short read costs a fraction of one). */
10046
+ function creditsOfUsd(usd) {
10047
+ return Math.round(usd * CREDITS_PER_USD * CREDIT_PRECISION) / CREDIT_PRECISION;
10048
+ }
10049
+ /** The credits a typical use of `step` costs on a model of `price` — never typed, always computed (§3d). */
10050
+ function estimateStepCredits(step, price, tokens = AI_STEP_TYPICAL_TOKENS[step]) {
10051
+ return creditsOfUsd(costUsd(tokens, price));
10052
+ }
10053
+ /** Can `model` do `step`? The step's needs against the model's capabilities. */
10054
+ function modelCanDo(model, step) {
10055
+ return AI_STEP_NEEDS[step].every(need => model.capabilities.includes(need));
10056
+ }
10057
+ /** Why AI did not run (board 11). The server refuses with these BEFORE any model call. */
10058
+ var AiRefusalCode;
10059
+ (function (AiRefusalCode) {
10060
+ AiRefusalCode["NotInPlan"] = "ai.notInPlan";
10061
+ AiRefusalCode["OutOfCredits"] = "ai.outOfCredits";
10062
+ AiRefusalCode["CapReached"] = "ai.capReached";
10063
+ AiRefusalCode["NotConnected"] = "ai.notConnected";
10064
+ AiRefusalCode["KeyInvalid"] = "ai.keyInvalid";
10065
+ AiRefusalCode["PlanUnknown"] = "ai.planUnknown";
10066
+ })(AiRefusalCode || (AiRefusalCode = {}));
10067
+ /** The HTTP status each refusal answers with (board 11). */
10068
+ const AI_REFUSAL_STATUS = {
10069
+ [AiRefusalCode.NotInPlan]: 403,
10070
+ [AiRefusalCode.OutOfCredits]: 402,
10071
+ [AiRefusalCode.CapReached]: 402,
10072
+ [AiRefusalCode.NotConnected]: 409,
10073
+ [AiRefusalCode.KeyInvalid]: 409,
10074
+ [AiRefusalCode.PlanUnknown]: 503,
10075
+ };
10076
+ /** What a refusal offers next. */
10077
+ var AiNextKind;
10078
+ (function (AiNextKind) {
10079
+ /** Ask IOX (a prefilled email to the operator, until a plan can be bought — D2). */
10080
+ AiNextKind["Contact"] = "contact";
10081
+ /** Open Settings ▸ AI. */
10082
+ AiNextKind["Settings"] = "settings";
10083
+ /** Try again later, or with less. */
10084
+ AiNextKind["Retry"] = "retry";
10085
+ })(AiNextKind || (AiNextKind = {}));
10086
+ const AI_REFUSAL_NEXT = {
10087
+ [AiRefusalCode.NotInPlan]: AiNextKind.Contact,
10088
+ [AiRefusalCode.OutOfCredits]: AiNextKind.Contact,
10089
+ [AiRefusalCode.CapReached]: AiNextKind.Retry,
10090
+ [AiRefusalCode.NotConnected]: AiNextKind.Settings,
10091
+ [AiRefusalCode.KeyInvalid]: AiNextKind.Settings,
10092
+ [AiRefusalCode.PlanUnknown]: AiNextKind.Retry,
10093
+ };
10094
+ /** A generation's stages (§3d). The runner works while `task` is set; otherwise the owner has the next move. */
10095
+ var AiGenerationStage;
10096
+ (function (AiGenerationStage) {
10097
+ AiGenerationStage["Reading"] = "reading";
10098
+ AiGenerationStage["Analysis"] = "analysis";
10099
+ AiGenerationStage["Design"] = "design";
10100
+ AiGenerationStage["Plan"] = "plan";
10101
+ AiGenerationStage["Build"] = "build";
10102
+ AiGenerationStage["Done"] = "done";
10103
+ AiGenerationStage["Failed"] = "failed";
10104
+ AiGenerationStage["Cancelled"] = "cancelled";
10105
+ })(AiGenerationStage || (AiGenerationStage = {}));
10106
+ /** The stages nothing advances any more. */
10107
+ const FINAL_GENERATION_STAGES = [AiGenerationStage.Done, AiGenerationStage.Failed, AiGenerationStage.Cancelled];
10108
+ /** How one model call ended — a ledger row's status. */
10109
+ var AiCallStatus;
10110
+ (function (AiCallStatus) {
10111
+ /** Written before the call: a reservation at the estimate until the call settles. */
10112
+ AiCallStatus["Started"] = "started";
10113
+ AiCallStatus["Ok"] = "ok";
10114
+ /** The answer came back and the shared validator refused it (with a path). */
10115
+ AiCallStatus["Invalid"] = "invalid";
10116
+ /** The model declined (a provider refusal) — charged what the provider reports. */
10117
+ AiCallStatus["Refused"] = "refused";
10118
+ AiCallStatus["Error"] = "error";
10119
+ /** The process died during the call: charged at the estimate, since what it cost was never reported. */
10120
+ AiCallStatus["Interrupted"] = "interrupted";
10121
+ })(AiCallStatus || (AiCallStatus = {}));
10122
+
9982
10123
  /**
9983
10124
  * @vectoriox/iox-ui/generation-core — the shared, FRAMEWORK-FREE site-plan core (design-system plan
9984
10125
  * §6b, W1): the Site Plan shape + its validator, the pattern library and the Studio template (both
@@ -9995,5 +10136,5 @@ function buildStepFacts(plan, actions = {}) {
9995
10136
  * Generated bundle index. Do not edit.
9996
10137
  */
9997
10138
 
9998
- export { ACTIVE_BUILD_STATUSES, BAR_ITEMS_MAX, BAR_ITEMS_MIN, BASELINE_ROLES, BUILD_STEPS, BaselineRole, BindScope, BuildNoticeCode, BuildStep, CardBindTarget, ComposeError, ComposeIssueCode, ContentTypeAction, CreatedKind, DANGLING_LINK_CODES, DEFAULT_PHONE_MENU_BREAKPOINT, ENTRANCE_EASING, ENTRANCE_ORIGIN_LOOK, ENTRANCE_TRIGGER, EntrancePart, FACT_KEYS, GlobalSlot, KeptReason, NAV_PART_LABELS, NAV_SHAPE_COPY, NEUTRAL_STYLE_PROPS, NODE_BASELINES, NavPagesSource, NavRole, NavShape, NavShapeError, PRICING_PATTERN, PUBLISH_BLOCKING_PLACEHOLDERS, PageDataKind, PathIssueCollector, PatternDirective, PatternGlobalPosition, PatternOpens, PatternPlaceholder, PatternRecipe, PhoneMenuBreakpoint, PlaceholderKind, PlanDataSourceMode, PlanDataSourceType, PreflightRefusalCode, RelativeOp, SAMPLE_IMAGE_REF, SITE_FACT_LABELS, SITE_HEADER_PATTERN, SITE_PATTERNS, SITE_PLAN_VERSION, SITE_TEMPLATES, SPEC_SITE_FACTS, SPEC_SITE_LIBRARY, SPEC_SITE_PATTERNS, SPEC_SITE_PLAN_SHAPE, SPEC_SITE_TEMPLATES, STUDIO_TEMPLATE, SiteBuildKind, SiteBuildStatus, SitePlanError, SitePlanIssueCode, SitePlanSourceKind, SiteTemplateError, SiteTemplateId, StepState, addBarItem, altSourceScopes, assertStyleSlots, assertValidSitePlan, barIconForRoute, blocksPublish, buildKeys, buildStepFacts, builtHomePageId, composeNavHeader, composeSection, composeSite, createSerializedNode, describePlanData, entranceAction, entranceInteraction, failedBuildStep, findNavRoot, isActiveBuild, isNonEmptyString, isPlainObject, moveBarItem, navPages, navShapeBreakpoint, navShapeOf, nextSourceOf, nodeBindPaths, parseSampleImageRef, pathAt, patternById, patternNeedsBinding, patternNodes, patternOptionalParts, patternScopes, patternSlots, patternTakesBinding, phoneMenuPages, planFromTemplate, planNavShape, releasedLayoutDefaults, removeBarItem, requiredShapeKeys, routeParams, sampleImageRef, sectionEntrances, setStyleProps, shapeKeys, siteNavPages, staggerDelay, validateSitePlan, walkSerialized };
10139
+ export { ACTIVE_BUILD_STATUSES, AI_REFUSAL_NEXT, AI_REFUSAL_STATUS, AI_STEPS, AI_STEP_NEEDS, AI_STEP_TYPICAL_TOKENS, AiCallStatus, AiCapability, AiGenerationStage, AiKeyMode, AiNextKind, AiProviderId, AiRefusalCode, AiStep, BAR_ITEMS_MAX, BAR_ITEMS_MIN, BASELINE_ROLES, BUILD_STEPS, BaselineRole, BindScope, BuildNoticeCode, BuildStep, CREDITS_PER_USD, CardBindTarget, ComposeError, ComposeIssueCode, ContentTypeAction, CreatedKind, DANGLING_LINK_CODES, DEFAULT_PHONE_MENU_BREAKPOINT, ENTRANCE_EASING, ENTRANCE_ORIGIN_LOOK, ENTRANCE_TRIGGER, EntrancePart, FACT_KEYS, FINAL_GENERATION_STAGES, GlobalSlot, KeptReason, NAV_PART_LABELS, NAV_SHAPE_COPY, NEUTRAL_STYLE_PROPS, NODE_BASELINES, NO_TOKENS, NavPagesSource, NavRole, NavShape, NavShapeError, PRICING_PATTERN, PUBLISH_BLOCKING_PLACEHOLDERS, PageDataKind, PathIssueCollector, PatternDirective, PatternGlobalPosition, PatternOpens, PatternPlaceholder, PatternRecipe, PhoneMenuBreakpoint, PlaceholderKind, PlanDataSourceMode, PlanDataSourceType, PreflightRefusalCode, RelativeOp, SAMPLE_IMAGE_REF, SITE_FACT_LABELS, SITE_HEADER_PATTERN, SITE_PATTERNS, SITE_PLAN_VERSION, SITE_TEMPLATES, SPEC_SITE_FACTS, SPEC_SITE_LIBRARY, SPEC_SITE_PATTERNS, SPEC_SITE_PLAN_SHAPE, SPEC_SITE_TEMPLATES, STUDIO_TEMPLATE, SiteBuildKind, SiteBuildStatus, SitePlanError, SitePlanIssueCode, SitePlanSourceKind, SiteTemplateError, SiteTemplateId, StepState, addBarItem, altSourceScopes, assertStyleSlots, assertValidSitePlan, barIconForRoute, blocksPublish, buildKeys, buildStepFacts, builtHomePageId, composeNavHeader, composeSection, composeSite, costUsd, createSerializedNode, creditsOfUsd, describePlanData, entranceAction, entranceInteraction, estimateStepCredits, failedBuildStep, findNavRoot, isActiveBuild, isNonEmptyString, isPlainObject, modelCanDo, moveBarItem, navPages, navShapeBreakpoint, navShapeOf, nextSourceOf, nodeBindPaths, parseSampleImageRef, pathAt, patternById, patternNeedsBinding, patternNodes, patternOptionalParts, patternScopes, patternSlots, patternTakesBinding, phoneMenuPages, planFromTemplate, planNavShape, releasedLayoutDefaults, removeBarItem, requiredShapeKeys, routeParams, sampleImageRef, sectionEntrances, setStyleProps, shapeKeys, siteNavPages, staggerDelay, validateSitePlan, walkSerialized };
9999
10140
  //# sourceMappingURL=vectoriox-iox-ui-generation-core.mjs.map