@semacode/cli 2.2.0 → 2.3.1

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.
Files changed (252) hide show
  1. package/LICENSE +39 -39
  2. package/README.md +251 -141
  3. package/dist/agentContext.d.ts +1 -1
  4. package/dist/agentContextPack.js +6 -1
  5. package/dist/agentContextTipos.d.ts +4 -2
  6. package/dist/agentContextTipos.js +7 -0
  7. package/dist/agentEntryPoints.js +551 -499
  8. package/dist/angular-consumer-standalone.d.ts +3 -1
  9. package/dist/angular-consumer-standalone.js +12 -8
  10. package/dist/comandos.js +4 -0
  11. package/dist/discovery/catalog.d.ts +11 -0
  12. package/dist/discovery/catalog.js +521 -0
  13. package/dist/discovery/command.d.ts +11 -0
  14. package/dist/discovery/command.js +226 -0
  15. package/dist/discovery/index.d.ts +5 -0
  16. package/dist/discovery/index.js +8 -0
  17. package/dist/discovery/ranker.d.ts +3 -0
  18. package/dist/discovery/ranker.js +310 -0
  19. package/dist/discovery/redaction.d.ts +2 -0
  20. package/dist/discovery/redaction.js +21 -0
  21. package/dist/discovery/render.d.ts +2 -0
  22. package/dist/discovery/render.js +100 -0
  23. package/dist/discovery/types.d.ts +119 -0
  24. package/dist/discovery/types.js +13 -0
  25. package/dist/drift.part01.d.ts +32 -2
  26. package/dist/drift.part01.js +2 -0
  27. package/dist/drift.part04.d.ts +3 -2
  28. package/dist/drift.part04.js +6 -3
  29. package/dist/drift.part05.d.ts +2 -1
  30. package/dist/drift.part05.js +4 -3
  31. package/dist/drift.part06.d.ts +2 -1
  32. package/dist/drift.part06.js +9 -5
  33. package/dist/drift.part07.d.ts +11 -10
  34. package/dist/drift.part07.js +40 -30
  35. package/dist/drift.part08.d.ts +2 -1
  36. package/dist/drift.part08.js +4 -3
  37. package/dist/drift.part11.js +71 -6
  38. package/dist/drift.part12.js +14 -1
  39. package/dist/drift.part13.d.ts +42 -7
  40. package/dist/drift.part13.js +660 -36
  41. package/dist/driftCache.d.ts +49 -0
  42. package/dist/driftCache.js +311 -0
  43. package/dist/driftCacheIncremental.d.ts +98 -0
  44. package/dist/driftCacheIncremental.js +596 -0
  45. package/dist/driftCatalogo.d.ts +91 -0
  46. package/dist/driftCatalogo.js +657 -0
  47. package/dist/driftCatalogoPersistente.d.ts +8 -0
  48. package/dist/driftCatalogoPersistente.js +77 -0
  49. package/dist/driftEscopo.d.ts +23 -0
  50. package/dist/driftEscopo.js +563 -0
  51. package/dist/driftEscopoReferencias.d.ts +4 -0
  52. package/dist/driftEscopoReferencias.js +265 -0
  53. package/dist/driftOrcamento.d.ts +12 -0
  54. package/dist/driftOrcamento.js +19 -3
  55. package/dist/execucoesExternas.js +5 -19
  56. package/dist/exemplosOficiais.js +29 -8
  57. package/dist/iaPrompts.d.ts +1 -1
  58. package/dist/iaPrompts.js +310 -307
  59. package/dist/index.d.ts +2 -0
  60. package/dist/index.js +23 -5
  61. package/dist/index.part01.d.ts +17 -2
  62. package/dist/index.part01.js +119 -8
  63. package/dist/index.part02.js +21 -21
  64. package/dist/index.part03.d.ts +2 -2
  65. package/dist/index.part03.js +14 -3
  66. package/dist/index.part04.d.ts +2 -2
  67. package/dist/index.part04.js +113 -101
  68. package/dist/index.part05.d.ts +1 -1
  69. package/dist/index.part05.js +99 -22
  70. package/dist/index.part06.js +6 -2
  71. package/dist/index.part07.js +24 -24
  72. package/dist/index.part08.js +1 -1
  73. package/dist/init/templates.part01.js +393 -393
  74. package/dist/init/templates.part02.js +189 -189
  75. package/dist/initTemplatesBackend.js +73 -73
  76. package/dist/initTemplatesBase.js +81 -80
  77. package/dist/initTemplatesFlutter.js +137 -137
  78. package/dist/initTemplatesRuntime.js +350 -350
  79. package/dist/initTemplatesWeb.js +309 -309
  80. package/dist/pipelineConteudo/command.js +1 -36
  81. package/dist/profileArtefatoValidadores.d.ts +3 -2
  82. package/dist/profileArtefatoValidadores.js +81 -0
  83. package/dist/profileAuthorTipos.d.ts +4 -3
  84. package/dist/profileCatalogo.d.ts +5 -5
  85. package/dist/profileCatalogo.js +30 -0
  86. package/dist/profileCommand.d.ts +8 -2
  87. package/dist/profileCommand.js +15 -5
  88. package/dist/profileRegras.d.ts +5 -5
  89. package/dist/profileRegras.js +13 -1
  90. package/dist/profileRulePacks.js +68 -0
  91. package/dist/projeto.d.ts +1 -1
  92. package/dist/projetoCarregar.d.ts +2 -2
  93. package/dist/projetoCarregar.js +47 -24
  94. package/dist/projetoCatalogo.d.ts +7 -0
  95. package/dist/projetoCatalogo.js +125 -0
  96. package/dist/projetoTipos.d.ts +14 -5
  97. package/dist/sistemasInterativos/adapterProtocol.d.ts +3 -0
  98. package/dist/sistemasInterativos/adapterProtocol.js +240 -0
  99. package/dist/sistemasInterativos/advancedCatalog.d.ts +5 -0
  100. package/dist/sistemasInterativos/advancedCatalog.js +442 -0
  101. package/dist/sistemasInterativos/autonomy.d.ts +230 -0
  102. package/dist/sistemasInterativos/autonomy.js +753 -0
  103. package/dist/sistemasInterativos/canonical.d.ts +3 -0
  104. package/dist/sistemasInterativos/canonical.js +43 -0
  105. package/dist/sistemasInterativos/catalog.d.ts +116 -0
  106. package/dist/sistemasInterativos/catalog.js +543 -0
  107. package/dist/sistemasInterativos/command.d.ts +7 -0
  108. package/dist/sistemasInterativos/command.js +311 -0
  109. package/dist/sistemasInterativos/controlRun.d.ts +56 -0
  110. package/dist/sistemasInterativos/controlRun.js +391 -0
  111. package/dist/sistemasInterativos/evidence.d.ts +5 -0
  112. package/dist/sistemasInterativos/evidence.js +306 -0
  113. package/dist/sistemasInterativos/experienceIr.d.ts +12 -0
  114. package/dist/sistemasInterativos/experienceIr.js +895 -0
  115. package/dist/sistemasInterativos/experienceIrSemantics.d.ts +30 -0
  116. package/dist/sistemasInterativos/experienceIrSemantics.js +368 -0
  117. package/dist/sistemasInterativos/experienceIrTypes.d.ts +370 -0
  118. package/dist/sistemasInterativos/experienceIrTypes.js +5 -0
  119. package/dist/sistemasInterativos/extensionCommand.d.ts +391 -0
  120. package/dist/sistemasInterativos/extensionCommand.js +383 -0
  121. package/dist/sistemasInterativos/index.d.ts +19 -0
  122. package/dist/sistemasInterativos/index.js +22 -0
  123. package/dist/sistemasInterativos/operations.d.ts +40 -0
  124. package/dist/sistemasInterativos/operations.js +1167 -0
  125. package/dist/sistemasInterativos/operationsTypes.d.ts +297 -0
  126. package/dist/sistemasInterativos/operationsTypes.js +11 -0
  127. package/dist/sistemasInterativos/planner.d.ts +2 -0
  128. package/dist/sistemasInterativos/planner.js +159 -0
  129. package/dist/sistemasInterativos/portability.d.ts +164 -0
  130. package/dist/sistemasInterativos/portability.js +539 -0
  131. package/dist/sistemasInterativos/render.d.ts +3 -0
  132. package/dist/sistemasInterativos/render.js +179 -0
  133. package/dist/sistemasInterativos/temporal.d.ts +183 -0
  134. package/dist/sistemasInterativos/temporal.js +543 -0
  135. package/dist/sistemasInterativos/types.d.ts +215 -0
  136. package/dist/sistemasInterativos/types.js +4 -0
  137. package/dist/sistemasInterativos/validator.d.ts +2 -0
  138. package/dist/sistemasInterativos/validator.js +305 -0
  139. package/dist/sync/index.js +35 -35
  140. package/docs/README.md +34 -28
  141. package/docs/ai-onboarding.md +62 -62
  142. package/docs/ai-workflow.md +9 -4
  143. package/docs/auth.md +26 -26
  144. package/docs/cli.md +79 -79
  145. package/docs/commands.md +47 -2
  146. package/docs/database.md +15 -15
  147. package/docs/deploy.md +41 -41
  148. package/docs/descoberta-capacidades.md +106 -0
  149. package/docs/documentation.md +39 -39
  150. package/docs/env.md +16 -16
  151. package/docs/frontend.md +41 -41
  152. package/docs/getting-started.md +57 -57
  153. package/docs/i18n.md +15 -15
  154. package/docs/pipeline-conteudo.md +246 -246
  155. package/docs/profiles.md +54 -45
  156. package/docs/repositories.md +43 -43
  157. package/docs/rollback.md +31 -31
  158. package/docs/security.md +32 -32
  159. package/docs/sistemas-interativos.md +376 -0
  160. package/docs/support.md +8 -8
  161. package/docs/testing.md +51 -35
  162. package/docs/vocabulary.md +29 -29
  163. package/exemplos/agendamento.sema +1 -1
  164. package/exemplos/assinatura.sema +1 -1
  165. package/exemplos/auditoria.sema +1 -1
  166. package/exemplos/autenticacao.sema +1 -1
  167. package/exemplos/author_obra_comum.sema +1 -1
  168. package/exemplos/author_tema_sensivel.sema +1 -1
  169. package/exemplos/automacao.sema +1 -1
  170. package/exemplos/cadastro_usuario.sema +1 -1
  171. package/exemplos/calculadora.sema +1 -1
  172. package/exemplos/crud_simples.sema +1 -1
  173. package/exemplos/estoque.sema +1 -1
  174. package/exemplos/exportacao.sema +1 -1
  175. package/exemplos/fila.sema +1 -1
  176. package/exemplos/integracao_externa.sema +1 -1
  177. package/exemplos/multi_tenant.sema +1 -1
  178. package/exemplos/notificacao.sema +1 -1
  179. package/exemplos/operacao_estrategia.sema +132 -132
  180. package/exemplos/operacao_estrategia_discovery.sema +220 -220
  181. package/exemplos/operacao_estrategia_fluxo.sema +114 -114
  182. package/exemplos/operacao_estrategia_gates.sema +106 -106
  183. package/exemplos/operacao_estrategia_quarentena.sema +133 -133
  184. package/exemplos/operacao_estrategia_rollout.sema +124 -124
  185. package/exemplos/pagamento.sema +1 -1
  186. package/exemplos/pagamento_dominio.sema +1 -1
  187. package/exemplos/pedido.sema +1 -1
  188. package/exemplos/permissao.sema +1 -1
  189. package/exemplos/persistencia_vendor_first.sema +1 -1
  190. package/exemplos/pipeline-conteudo/README.md +44 -44
  191. package/exemplos/pipeline-conteudo/alvos.json +23 -23
  192. package/exemplos/pipeline-conteudo/definicao.json +136 -136
  193. package/exemplos/profile_conversas.sema +165 -165
  194. package/exemplos/profile_game.sema +1 -1
  195. package/exemplos/profile_legal.sema +1 -1
  196. package/exemplos/profile_ops.sema +1 -1
  197. package/exemplos/profile_research.sema +1 -1
  198. package/exemplos/profile_simulation.sema +211 -0
  199. package/exemplos/profile_software.sema +1 -1
  200. package/exemplos/profile_workflow_n8n.sema +1 -1
  201. package/exemplos/relatorio.sema +1 -1
  202. package/exemplos/replica_analitica_erp.sema +1 -1
  203. package/exemplos/sistemas-interativos/README.md +100 -0
  204. package/exemplos/sistemas-interativos/advanced/acceptance-context-evaluate-valid.json +5 -0
  205. package/exemplos/sistemas-interativos/advanced/acceptance-lock-valid.json +16 -0
  206. package/exemplos/sistemas-interativos/advanced/asset-provenance-valid.json +32 -0
  207. package/exemplos/sistemas-interativos/advanced/autonomy-repair-valid.json +93 -0
  208. package/exemplos/sistemas-interativos/advanced/control-run-definition-valid.json +78 -0
  209. package/exemplos/sistemas-interativos/advanced/control-run-valid.json +27 -0
  210. package/exemplos/sistemas-interativos/advanced/distributed-workers-valid.json +79 -0
  211. package/exemplos/sistemas-interativos/advanced/editor-state-valid.json +42 -0
  212. package/exemplos/sistemas-interativos/advanced/engine-snapshot-after-valid.json +32 -0
  213. package/exemplos/sistemas-interativos/advanced/engine-snapshot-before-valid.json +23 -0
  214. package/exemplos/sistemas-interativos/advanced/job-orchestration-valid.json +39 -0
  215. package/exemplos/sistemas-interativos/advanced/multimodal-evidence-valid.json +46 -0
  216. package/exemplos/sistemas-interativos/advanced/multiplayer-authority-valid.json +39 -0
  217. package/exemplos/sistemas-interativos/advanced/playtest-fuzz-valid.json +37 -0
  218. package/exemplos/sistemas-interativos/advanced/portability-valid.json +104 -0
  219. package/exemplos/sistemas-interativos/advanced/temporal-evidence-valid.json +27 -0
  220. package/exemplos/sistemas-interativos/advanced/temporal-valid.json +118 -0
  221. package/exemplos/sistemas-interativos/experience-ir-valid.json +459 -0
  222. package/exemplos/sistemas-interativos/game-2d.json +83 -0
  223. package/exemplos/sistemas-interativos/game-3d-human.json +81 -0
  224. package/exemplos/sistemas-interativos/game-pixel-16-bit.json +97 -0
  225. package/exemplos/sistemas-interativos/game-pixel-8-bit.json +94 -0
  226. package/exemplos/sistemas-interativos/game-xr-human.json +80 -0
  227. package/exemplos/sistemas-interativos/hybrid-2-5d.json +108 -0
  228. package/exemplos/sistemas-interativos/protocol-mutating-rollback-valid.json +75 -0
  229. package/exemplos/sistemas-interativos/protocol-read-only-valid.json +58 -0
  230. package/exemplos/sistemas-interativos/simulation-2d-controlled.json +97 -0
  231. package/exemplos/sistemas-interativos/simulation-3d-calibrated-autonomous.json +141 -0
  232. package/exemplos/sistemas-interativos/simulation-headless-autonomous-batch.json +112 -0
  233. package/exemplos/sistemas-interativos/simulation-pixel-16-bit.json +103 -0
  234. package/exemplos/sistemas-interativos/simulation-text-controlled.json +95 -0
  235. package/exemplos/testes_embutidos.sema +1 -1
  236. package/exemplos/tratamento_erro.sema +1 -1
  237. package/exemplos/upload_arquivo.sema +1 -1
  238. package/exemplos/webhook.sema +1 -1
  239. package/node_modules/@sema/gerador-cpp/dist/index.js +176 -176
  240. package/node_modules/@sema/gerador-cpp/package.json +1 -1
  241. package/node_modules/@sema/gerador-css/dist/index.part01.js +10 -10
  242. package/node_modules/@sema/gerador-css/dist/index.part02.js +460 -460
  243. package/node_modules/@sema/gerador-dotnet/dist/index.js +169 -169
  244. package/node_modules/@sema/gerador-dotnet/package.json +1 -1
  245. package/node_modules/@sema/gerador-html/dist/index.js +17 -17
  246. package/node_modules/@sema/gerador-lua/dist/index.js +76 -47
  247. package/node_modules/@sema/gerador-lua/dist/index.js.map +1 -1
  248. package/node_modules/@sema/gerador-php/dist/index.js +113 -113
  249. package/node_modules/@sema/gerador-python/dist/index.part02.js +3 -3
  250. package/node_modules/@sema/gerador-typescript/dist/index.part02.js +11 -11
  251. package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js +42 -42
  252. package/package.json +3 -3
@@ -0,0 +1,30 @@
1
+ import type { ExperienceIrKind, ExperienceIrSemanticRole, ExperienceIrSemanticRoleSchema } from "./experienceIrTypes.js";
2
+ export declare const EXPERIENCE_IR_SEMANTIC_ROLES_SCHEMA_VERSION: "sema.experience-ir.semantic-roles/v1";
3
+ export declare const EXPERIENCE_IR_SEMANTIC_ROLE_SCHEMA: ExperienceIrSemanticRoleSchema;
4
+ export interface ExperienceIrSemanticNodeProjection {
5
+ readonly kind: ExperienceIrKind;
6
+ readonly value: Record<string, unknown>;
7
+ readonly path: string;
8
+ }
9
+ export interface ExperienceIrSemanticIssue {
10
+ readonly code: string;
11
+ readonly path: string;
12
+ readonly message: string;
13
+ }
14
+ export interface ExperienceIrConceptReference {
15
+ readonly id: string;
16
+ readonly expectedKinds: readonly ExperienceIrKind[];
17
+ readonly path: string;
18
+ }
19
+ export interface ExperienceIrSemanticValidationResult {
20
+ readonly valido: boolean;
21
+ readonly semanticRoles: readonly ExperienceIrSemanticRole[];
22
+ readonly issues: readonly ExperienceIrSemanticIssue[];
23
+ readonly executed: false;
24
+ readonly workspaceMutated: false;
25
+ readonly authoritative: false;
26
+ }
27
+ export declare function valorSensivelExperienceIr(value: string): boolean;
28
+ export declare function obterPapeisSemanticosExperienceIr(value: Record<string, unknown>, kind: ExperienceIrKind): readonly ExperienceIrSemanticRole[];
29
+ export declare function obterReferenciasConceituaisExperienceIr(node: ExperienceIrSemanticNodeProjection): readonly ExperienceIrConceptReference[];
30
+ export declare function validarSemanticaExperienceIr(nodes: readonly ExperienceIrSemanticNodeProjection[]): ExperienceIrSemanticValidationResult;
@@ -0,0 +1,368 @@
1
+ // SEMA-GOVERNED: sema.produto.sistemas_interativos.ir_semantica
2
+ // Contratos: contratos/sema/sistemas_interativos_ir.sema e sistemas_interativos_ir_semantica.sema
3
+ // Descrição: papéis tipados e invariantes transversais, sem executar ou ecoar valores controlados.
4
+ export const EXPERIENCE_IR_SEMANTIC_ROLES_SCHEMA_VERSION = "sema.experience-ir.semantic-roles/v1";
5
+ export const EXPERIENCE_IR_SEMANTIC_ROLE_SCHEMA = Object.freeze({
6
+ schemaVersion: EXPERIENCE_IR_SEMANTIC_ROLES_SCHEMA_VERSION,
7
+ compatibility: "OPTIONAL_TYPED_ROLES",
8
+ nodeKindCount: 20,
9
+ mappings: Object.freeze([
10
+ { role: "LEVEL", containerKind: "SCENE", field: "semanticRole", cardinality: "ONE" },
11
+ { role: "PIVOT", containerKind: "TRANSFORM", field: "semanticRole", cardinality: "ONE" },
12
+ { role: "COLLIDER", containerKind: "PHYSICS", field: "colliders", cardinality: "MANY" },
13
+ { role: "EMITTER", containerKind: "VFX", field: "emitters", cardinality: "MANY" },
14
+ { role: "TRACK", containerKind: "TIMELINE", field: "tracks[].semanticRole", cardinality: "MANY" },
15
+ { role: "CLIP", containerKind: "TIMELINE", field: "tracks[].clips", cardinality: "MANY" },
16
+ { role: "EVENT", containerKind: "TIMELINE", field: "tracks[].events", cardinality: "MANY" },
17
+ { role: "GAME_STATE", containerKind: "SAVE", field: "semanticRole", cardinality: "ONE" },
18
+ ]),
19
+ });
20
+ const VALOR_SENSIVEL = /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\bBearer\s+[A-Za-z0-9._~+/=-]+|\b(?:sk|ghp|github_pat)_[A-Za-z0-9_-]{12,}/iu;
21
+ const QUERY_URI_SENSIVEL = /[?&](?:access[_-]?token|api[_-]?key|token|signature|sig|credential|x-amz-[a-z0-9-]+)=/iu;
22
+ const ID_LOCAL = /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)+$/u;
23
+ const ALL_KINDS = [
24
+ "PROJECT", "WORLD", "SCENE", "ENTITY", "COMPONENT", "TRANSFORM", "CAMERA", "LIGHT", "MATERIAL",
25
+ "TEXTURE", "AUDIO", "PHYSICS", "CONSTRAINT", "ANIMATION", "VFX", "TIMELINE", "INPUT",
26
+ "SAVE", "NETWORK", "BUILD",
27
+ ];
28
+ const TARGET_KINDS = ALL_KINDS.filter((kind) => kind !== "PROJECT");
29
+ const KIND_SET = new Set(ALL_KINDS);
30
+ const ROLE_ORDER = EXPERIENCE_IR_SEMANTIC_ROLE_SCHEMA.mappings.map((item) => item.role);
31
+ export function valorSensivelExperienceIr(value) {
32
+ return VALOR_SENSIVEL.test(value) || QUERY_URI_SENSIVEL.test(value);
33
+ }
34
+ function contemValorSensivel(value) {
35
+ const pending = [value];
36
+ const seen = new WeakSet();
37
+ let inspected = 0;
38
+ while (pending.length > 0) {
39
+ const current = pending.pop();
40
+ if (typeof current === "string" && valorSensivelExperienceIr(current))
41
+ return true;
42
+ if (current === null || typeof current !== "object" || seen.has(current))
43
+ continue;
44
+ seen.add(current);
45
+ inspected += 1;
46
+ if (inspected > 100_000)
47
+ return true;
48
+ try {
49
+ Object.values(Object.getOwnPropertyDescriptors(current)).forEach((descriptor) => {
50
+ if ("value" in descriptor)
51
+ pending.push(descriptor.value);
52
+ });
53
+ }
54
+ catch {
55
+ return true;
56
+ }
57
+ }
58
+ return false;
59
+ }
60
+ function record(value) {
61
+ return value !== null && typeof value === "object" && !Array.isArray(value);
62
+ }
63
+ function finite(value, positive = false) {
64
+ return typeof value === "number" && Number.isFinite(value) && (!positive || value > 0);
65
+ }
66
+ function addUnknownFields(value, allowed, path, issues) {
67
+ const accepted = new Set(allowed);
68
+ Object.keys(value).sort().forEach((key, index) => {
69
+ if (!accepted.has(key))
70
+ issues.push({
71
+ code: "IR_CONCEPT_UNKNOWN_FIELD",
72
+ path: `${path}.*[${index}]`,
73
+ message: "Unknown typed semantic-role field.",
74
+ });
75
+ });
76
+ }
77
+ function validateRole(value, expected, path, issues, optional = false) {
78
+ if (value === undefined && optional)
79
+ return false;
80
+ if (value !== expected) {
81
+ issues.push({ code: "IR_SEMANTIC_ROLE", path, message: "Typed semantic role is invalid for its container." });
82
+ return false;
83
+ }
84
+ return true;
85
+ }
86
+ function validateLocalId(value, prefix, path, issues, seen) {
87
+ if (typeof value !== "string" || !ID_LOCAL.test(value) || !value.startsWith(`${prefix}.`)) {
88
+ issues.push({ code: "IR_CONCEPT_ID", path, message: "Typed semantic-role ID is invalid." });
89
+ }
90
+ else if (seen.has(value)) {
91
+ issues.push({ code: "IR_CONCEPT_ID_DUPLICATE", path, message: "Typed semantic-role IDs must be unique." });
92
+ }
93
+ else
94
+ seen.add(value);
95
+ }
96
+ function validateColliders(node, issues) {
97
+ const { colliders } = node.value;
98
+ if (colliders === undefined)
99
+ return;
100
+ if (!Array.isArray(colliders)) {
101
+ issues.push({ code: "IR_COLLIDERS", path: `${node.path}.colliders`, message: "Colliders must be an array." });
102
+ return;
103
+ }
104
+ const ids = new Set();
105
+ colliders.forEach((item, index) => {
106
+ const path = `${node.path}.colliders[${index}]`;
107
+ if (!record(item)) {
108
+ issues.push({ code: "IR_COLLIDER", path, message: "Collider must be a typed object." });
109
+ return;
110
+ }
111
+ addUnknownFields(item, [
112
+ "semanticRole", "colliderId", "shape", "trigger", "halfExtentsMeters", "radiusMeters", "heightMeters",
113
+ ], path, issues);
114
+ validateRole(item.semanticRole, "COLLIDER", `${path}.semanticRole`, issues);
115
+ validateLocalId(item.colliderId, "collider", `${path}.colliderId`, issues, ids);
116
+ if (typeof item.trigger !== "boolean")
117
+ issues.push({ code: "IR_COLLIDER_TRIGGER", path: `${path}.trigger`, message: "Collider trigger must be boolean." });
118
+ if (item.shape === "BOX") {
119
+ if (!Array.isArray(item.halfExtentsMeters) || item.halfExtentsMeters.length !== 3
120
+ || !item.halfExtentsMeters.every((value) => finite(value, true))
121
+ || item.radiusMeters !== undefined || item.heightMeters !== undefined) {
122
+ issues.push({ code: "IR_COLLIDER_SHAPE", path: `${path}.halfExtentsMeters`, message: "BOX collider dimensions are invalid." });
123
+ }
124
+ }
125
+ else if (item.shape === "SPHERE") {
126
+ if (!finite(item.radiusMeters, true) || item.halfExtentsMeters !== undefined || item.heightMeters !== undefined) {
127
+ issues.push({ code: "IR_COLLIDER_SHAPE", path: `${path}.radiusMeters`, message: "SPHERE collider radius is invalid." });
128
+ }
129
+ }
130
+ else if (item.shape === "CAPSULE") {
131
+ if (!finite(item.radiusMeters, true) || !finite(item.heightMeters, true) || item.halfExtentsMeters !== undefined) {
132
+ issues.push({ code: "IR_COLLIDER_SHAPE", path, message: "CAPSULE collider dimensions are invalid." });
133
+ }
134
+ }
135
+ else
136
+ issues.push({ code: "IR_COLLIDER_SHAPE", path: `${path}.shape`, message: "Collider shape is invalid." });
137
+ });
138
+ }
139
+ function validateEmitters(node, issues) {
140
+ const { emitters } = node.value;
141
+ if (emitters === undefined)
142
+ return;
143
+ if (!Array.isArray(emitters)) {
144
+ issues.push({ code: "IR_EMITTERS", path: `${node.path}.emitters`, message: "Emitters must be an array." });
145
+ return;
146
+ }
147
+ const ids = new Set();
148
+ emitters.forEach((item, index) => {
149
+ const path = `${node.path}.emitters[${index}]`;
150
+ if (!record(item)) {
151
+ issues.push({ code: "IR_EMITTER", path, message: "Emitter must be a typed object." });
152
+ return;
153
+ }
154
+ addUnknownFields(item, ["semanticRole", "emitterId", "ratePerSecond", "maxParticles", "enabled"], path, issues);
155
+ validateRole(item.semanticRole, "EMITTER", `${path}.semanticRole`, issues);
156
+ validateLocalId(item.emitterId, "emitter", `${path}.emitterId`, issues, ids);
157
+ if (!finite(item.ratePerSecond) || item.ratePerSecond < 0)
158
+ issues.push({ code: "IR_EMITTER_RATE", path: `${path}.ratePerSecond`, message: "Emitter rate is invalid." });
159
+ if (!Number.isInteger(item.maxParticles) || !finite(item.maxParticles, true))
160
+ issues.push({ code: "IR_EMITTER_BUDGET", path: `${path}.maxParticles`, message: "Emitter particle budget is invalid." });
161
+ if (typeof item.enabled !== "boolean")
162
+ issues.push({ code: "IR_EMITTER_ENABLED", path: `${path}.enabled`, message: "Emitter enabled state must be boolean." });
163
+ });
164
+ }
165
+ function validateTimelineConcepts(node, issues, references) {
166
+ if (!Array.isArray(node.value.tracks))
167
+ return;
168
+ const clipIds = new Set();
169
+ const eventIds = new Set();
170
+ const duration = finite(node.value.durationSeconds) ? node.value.durationSeconds : null;
171
+ node.value.tracks.forEach((track, trackIndex) => {
172
+ const trackPath = `${node.path}.tracks[${trackIndex}]`;
173
+ if (!record(track))
174
+ return;
175
+ const hasTypedChildren = Array.isArray(track.clips) || Array.isArray(track.events);
176
+ validateRole(track.semanticRole, "TRACK", `${trackPath}.semanticRole`, issues, !hasTypedChildren);
177
+ if (track.trackType !== undefined && ![
178
+ "ANIMATION", "AUDIO", "VFX", "EVENT", "GAME_STATE", "CUSTOM",
179
+ ].includes(track.trackType)) {
180
+ issues.push({ code: "IR_TRACK_TYPE", path: `${trackPath}.trackType`, message: "Timeline track type is invalid." });
181
+ }
182
+ if (track.clips !== undefined && !Array.isArray(track.clips)) {
183
+ issues.push({ code: "IR_CLIPS", path: `${trackPath}.clips`, message: "Timeline clips must be an array." });
184
+ }
185
+ if (Array.isArray(track.clips))
186
+ track.clips.forEach((clip, clipIndex) => {
187
+ const path = `${trackPath}.clips[${clipIndex}]`;
188
+ if (!record(clip)) {
189
+ issues.push({ code: "IR_CLIP", path, message: "Timeline clip must be a typed object." });
190
+ return;
191
+ }
192
+ addUnknownFields(clip, ["semanticRole", "clipId", "targetId", "startSeconds", "endSeconds"], path, issues);
193
+ validateRole(clip.semanticRole, "CLIP", `${path}.semanticRole`, issues);
194
+ validateLocalId(clip.clipId, "clip", `${path}.clipId`, issues, clipIds);
195
+ const start = finite(clip.startSeconds) ? clip.startSeconds : null;
196
+ const end = finite(clip.endSeconds) ? clip.endSeconds : null;
197
+ if (start === null || end === null || start < 0 || end <= start || (duration !== null && end > duration)) {
198
+ issues.push({ code: "IR_CLIP_TIME", path, message: "Timeline clip range is invalid." });
199
+ }
200
+ if (typeof clip.targetId !== "string" || !ID_LOCAL.test(clip.targetId)) {
201
+ issues.push({ code: "IR_CLIP_TARGET", path: `${path}.targetId`, message: "Timeline clip target is invalid." });
202
+ }
203
+ else
204
+ references.push({ id: clip.targetId, expectedKinds: TARGET_KINDS, path: `${path}.targetId` });
205
+ });
206
+ if (track.events !== undefined && !Array.isArray(track.events)) {
207
+ issues.push({ code: "IR_EVENTS", path: `${trackPath}.events`, message: "Timeline events must be an array." });
208
+ }
209
+ if (Array.isArray(track.events))
210
+ track.events.forEach((event, eventIndex) => {
211
+ const path = `${trackPath}.events[${eventIndex}]`;
212
+ if (!record(event)) {
213
+ issues.push({ code: "IR_EVENT", path, message: "Timeline event must be a typed object." });
214
+ return;
215
+ }
216
+ addUnknownFields(event, ["semanticRole", "eventId", "eventType", "atSeconds", "payload"], path, issues);
217
+ validateRole(event.semanticRole, "EVENT", `${path}.semanticRole`, issues);
218
+ validateLocalId(event.eventId, "event", `${path}.eventId`, issues, eventIds);
219
+ if (typeof event.eventType !== "string" || event.eventType.trim().length === 0)
220
+ issues.push({ code: "IR_EVENT_TYPE", path: `${path}.eventType`, message: "Timeline event type is invalid." });
221
+ if (!finite(event.atSeconds) || event.atSeconds < 0 || (duration !== null && event.atSeconds > duration))
222
+ issues.push({ code: "IR_EVENT_TIME", path: `${path}.atSeconds`, message: "Timeline event time is invalid." });
223
+ if (!record(event.payload))
224
+ issues.push({ code: "IR_EVENT_PAYLOAD", path: `${path}.payload`, message: "Timeline event payload must be an object." });
225
+ });
226
+ });
227
+ }
228
+ function validateNetwork(node, issues) {
229
+ const { mode, authority, replicatedSemanticIds, tickRateHz } = node.value;
230
+ if (!Array.isArray(replicatedSemanticIds) || typeof mode !== "string" || typeof authority !== "string"
231
+ || typeof tickRateHz !== "number" || !Number.isFinite(tickRateHz))
232
+ return;
233
+ const onlineTick = Number.isInteger(tickRateHz) && tickRateHz > 0;
234
+ const hasReplication = replicatedSemanticIds.length > 0;
235
+ const valid = mode === "OFFLINE"
236
+ ? authority === "NONE" && !hasReplication && tickRateHz === 0
237
+ : mode === "CLIENT_SERVER"
238
+ ? authority === "SERVER" && hasReplication && onlineTick
239
+ : mode === "PEER_TO_PEER"
240
+ ? (authority === "OWNER" || authority === "DISTRIBUTED") && hasReplication && onlineTick
241
+ : mode === "LOCKSTEP" && authority === "DISTRIBUTED" && hasReplication && onlineTick;
242
+ if (!valid)
243
+ issues.push({
244
+ code: "IR_NETWORK_POLICY",
245
+ path: `${node.path}.mode`,
246
+ message: "Network mode, authority, replication and tick policy are inconsistent.",
247
+ });
248
+ }
249
+ function hierarchyHasCycle(nodes, kind, parentField) {
250
+ const parents = new Map();
251
+ nodes.filter((node) => node.kind === kind).forEach((node) => {
252
+ const id = node.value.semanticId;
253
+ const parent = node.value[parentField];
254
+ if (typeof id === "string" && typeof parent === "string")
255
+ parents.set(id, parent);
256
+ });
257
+ const completed = new Set();
258
+ for (const start of parents.keys()) {
259
+ const active = new Set();
260
+ let current = start;
261
+ while (current !== undefined && parents.has(current) && !completed.has(current)) {
262
+ if (active.has(current))
263
+ return true;
264
+ active.add(current);
265
+ current = parents.get(current);
266
+ }
267
+ active.forEach((id) => completed.add(id));
268
+ }
269
+ return false;
270
+ }
271
+ export function obterPapeisSemanticosExperienceIr(value, kind) {
272
+ const roles = new Set();
273
+ if (kind === "SCENE" && value.semanticRole === "LEVEL")
274
+ roles.add("LEVEL");
275
+ if (kind === "TRANSFORM" && value.semanticRole === "PIVOT")
276
+ roles.add("PIVOT");
277
+ if (kind === "SAVE" && value.semanticRole === "GAME_STATE")
278
+ roles.add("GAME_STATE");
279
+ if (kind === "PHYSICS" && Array.isArray(value.colliders)
280
+ && value.colliders.some((item) => record(item) && item.semanticRole === "COLLIDER"))
281
+ roles.add("COLLIDER");
282
+ if (kind === "VFX" && Array.isArray(value.emitters)
283
+ && value.emitters.some((item) => record(item) && item.semanticRole === "EMITTER"))
284
+ roles.add("EMITTER");
285
+ if (kind === "TIMELINE" && Array.isArray(value.tracks))
286
+ value.tracks.forEach((track) => {
287
+ if (!record(track))
288
+ return;
289
+ if (track.semanticRole === "TRACK")
290
+ roles.add("TRACK");
291
+ if (Array.isArray(track.clips) && track.clips.some((item) => record(item) && item.semanticRole === "CLIP"))
292
+ roles.add("CLIP");
293
+ if (Array.isArray(track.events) && track.events.some((item) => record(item) && item.semanticRole === "EVENT"))
294
+ roles.add("EVENT");
295
+ });
296
+ return ROLE_ORDER.filter((role) => roles.has(role));
297
+ }
298
+ export function obterReferenciasConceituaisExperienceIr(node) {
299
+ if (node.kind !== "TIMELINE")
300
+ return [];
301
+ const references = [];
302
+ const ignored = [];
303
+ validateTimelineConcepts(node, ignored, references);
304
+ return references;
305
+ }
306
+ export function validarSemanticaExperienceIr(nodes) {
307
+ const issues = [];
308
+ const roles = new Set();
309
+ const normalizedNodes = [];
310
+ if (!Array.isArray(nodes)) {
311
+ issues.push({ code: "IR_SEMANTIC_NODES", path: "$", message: "Semantic nodes must be an array." });
312
+ }
313
+ else
314
+ nodes.forEach((candidate, index) => {
315
+ if (!record(candidate) || !KIND_SET.has(candidate.kind) || !record(candidate.value)) {
316
+ issues.push({ code: "IR_SEMANTIC_NODE", path: `$.nodes[${index}]`, message: "Semantic node projection is invalid." });
317
+ return;
318
+ }
319
+ normalizedNodes.push({
320
+ kind: candidate.kind,
321
+ value: candidate.value,
322
+ path: `$.nodes[${index}]`,
323
+ });
324
+ });
325
+ if (normalizedNodes.some((node) => contemValorSensivel(node.value)))
326
+ issues.push({
327
+ code: "IR_SENSITIVE_VALUE", path: "$", message: "Sensitive string values are not accepted in Experience IR.",
328
+ });
329
+ normalizedNodes.forEach((node) => {
330
+ if (node.kind === "SCENE")
331
+ validateRole(node.value.semanticRole, "LEVEL", `${node.path}.semanticRole`, issues, true);
332
+ if (node.kind === "TRANSFORM")
333
+ validateRole(node.value.semanticRole, "PIVOT", `${node.path}.semanticRole`, issues, true);
334
+ if (node.kind === "SAVE") {
335
+ const hasRole = validateRole(node.value.semanticRole, "GAME_STATE", `${node.path}.semanticRole`, issues, true);
336
+ if (hasRole && (!Array.isArray(node.value.stateSemanticIds) || node.value.stateSemanticIds.length === 0)) {
337
+ issues.push({ code: "IR_GAME_STATE", path: `${node.path}.stateSemanticIds`, message: "GAME_STATE requires declared state semantic IDs." });
338
+ }
339
+ }
340
+ if (node.kind === "PHYSICS")
341
+ validateColliders(node, issues);
342
+ if (node.kind === "VFX")
343
+ validateEmitters(node, issues);
344
+ if (node.kind === "TIMELINE")
345
+ validateTimelineConcepts(node, issues, []);
346
+ if (node.kind === "NETWORK")
347
+ validateNetwork(node, issues);
348
+ obterPapeisSemanticosExperienceIr(node.value, node.kind).forEach((role) => roles.add(role));
349
+ });
350
+ if (hierarchyHasCycle(normalizedNodes, "ENTITY", "parentEntityId"))
351
+ issues.push({
352
+ code: "IR_ENTITY_HIERARCHY_CYCLE", path: "$.entities", message: "Entity parent hierarchy must be acyclic.",
353
+ });
354
+ if (hierarchyHasCycle(normalizedNodes, "TRANSFORM", "parentTransformId"))
355
+ issues.push({
356
+ code: "IR_TRANSFORM_HIERARCHY_CYCLE", path: "$.transforms", message: "Transform parent hierarchy must be acyclic.",
357
+ });
358
+ const sorted = [...issues].sort((a, b) => a.path.localeCompare(b.path, "en") || a.code.localeCompare(b.code, "en"));
359
+ return {
360
+ valido: sorted.length === 0,
361
+ semanticRoles: ROLE_ORDER.filter((role) => roles.has(role)),
362
+ issues: sorted,
363
+ executed: false,
364
+ workspaceMutated: false,
365
+ authoritative: false,
366
+ };
367
+ }
368
+ //# sourceMappingURL=experienceIrSemantics.js.map