@wildo-ai/dev-companion 1.1.13 → 1.1.15

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 (363) hide show
  1. package/dist/esm/.tsbuildinfo +1 -1
  2. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts +89 -1
  3. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts.map +1 -1
  4. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js +114 -9
  5. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js.map +1 -1
  6. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.d.ts +46 -1
  7. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.d.ts.map +1 -1
  8. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.js +39 -2
  9. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.js.map +1 -1
  10. package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.d.ts +6 -0
  11. package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.d.ts.map +1 -1
  12. package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.js.map +1 -1
  13. package/dist/esm/claude-cli/models/verification-tool-availability.models.d.ts +19 -5
  14. package/dist/esm/claude-cli/models/verification-tool-availability.models.d.ts.map +1 -1
  15. package/dist/esm/claude-cli/models/verification-tool-availability.models.js +17 -5
  16. package/dist/esm/claude-cli/models/verification-tool-availability.models.js.map +1 -1
  17. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.d.ts +16 -1
  18. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.d.ts.map +1 -1
  19. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.js +53 -6
  20. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.js.map +1 -1
  21. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts +145 -6
  22. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts.map +1 -1
  23. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js +474 -47
  24. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js.map +1 -1
  25. package/dist/esm/claude-cli/services/git-change-set.companion.service.d.ts +6 -2
  26. package/dist/esm/claude-cli/services/git-change-set.companion.service.d.ts.map +1 -1
  27. package/dist/esm/claude-cli/services/git-change-set.companion.service.js +16 -39
  28. package/dist/esm/claude-cli/services/git-change-set.companion.service.js.map +1 -1
  29. package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts +14 -0
  30. package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts.map +1 -1
  31. package/dist/esm/claude-cli/services/research-evidence-store.companion.js +35 -0
  32. package/dist/esm/claude-cli/services/research-evidence-store.companion.js.map +1 -1
  33. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.d.ts +36 -0
  34. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.d.ts.map +1 -0
  35. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.js +134 -0
  36. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.js.map +1 -0
  37. package/dist/esm/code-compliance-check/check-raw-feature-id-literals.companion.js +31 -2
  38. package/dist/esm/code-compliance-check/check-raw-feature-id-literals.companion.js.map +1 -1
  39. package/dist/esm/companion-api/companion-api.schemas.d.ts +2 -0
  40. package/dist/esm/companion-api/companion-api.schemas.d.ts.map +1 -1
  41. package/dist/esm/companion-api/companion-api.schemas.js +8 -0
  42. package/dist/esm/companion-api/companion-api.schemas.js.map +1 -1
  43. package/dist/esm/companion-api/controllers/companion.controller.d.ts +7 -0
  44. package/dist/esm/companion-api/controllers/companion.controller.d.ts.map +1 -1
  45. package/dist/esm/companion-api/controllers/companion.controller.js +26 -12
  46. package/dist/esm/companion-api/controllers/companion.controller.js.map +1 -1
  47. package/dist/esm/companion-api/controllers/long-held-request.companion.d.ts +17 -0
  48. package/dist/esm/companion-api/controllers/long-held-request.companion.d.ts.map +1 -0
  49. package/dist/esm/companion-api/controllers/long-held-request.companion.js +33 -0
  50. package/dist/esm/companion-api/controllers/long-held-request.companion.js.map +1 -0
  51. package/dist/esm/core/introspection/resources/creation-home-projection.companion.d.ts +9 -0
  52. package/dist/esm/core/introspection/resources/creation-home-projection.companion.d.ts.map +1 -1
  53. package/dist/esm/core/introspection/resources/creation-home-projection.companion.js +12 -0
  54. package/dist/esm/core/introspection/resources/creation-home-projection.companion.js.map +1 -1
  55. package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.d.ts.map +1 -1
  56. package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.js +7 -1
  57. package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.js.map +1 -1
  58. package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts +8 -20
  59. package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts.map +1 -1
  60. package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js +37 -142
  61. package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js.map +1 -1
  62. package/dist/esm/core/introspection/services/introspection-source-walk.worker.d.ts +64 -0
  63. package/dist/esm/core/introspection/services/introspection-source-walk.worker.d.ts.map +1 -0
  64. package/dist/esm/core/introspection/services/introspection-source-walk.worker.js +304 -0
  65. package/dist/esm/core/introspection/services/introspection-source-walk.worker.js.map +1 -0
  66. package/dist/esm/core/introspection/services/translation-placement.companion.service.d.ts +3 -2
  67. package/dist/esm/core/introspection/services/translation-placement.companion.service.d.ts.map +1 -1
  68. package/dist/esm/core/introspection/services/translation-placement.companion.service.js.map +1 -1
  69. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.d.ts.map +1 -1
  70. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js +24 -14
  71. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js.map +1 -1
  72. package/dist/esm/core/introspection/workspace-element-index.companion.d.ts +42 -0
  73. package/dist/esm/core/introspection/workspace-element-index.companion.d.ts.map +1 -1
  74. package/dist/esm/core/introspection/workspace-element-index.companion.js +42 -0
  75. package/dist/esm/core/introspection/workspace-element-index.companion.js.map +1 -1
  76. package/dist/esm/core/runtime/companion-language-model-route.d.ts +16 -1
  77. package/dist/esm/core/runtime/companion-language-model-route.d.ts.map +1 -1
  78. package/dist/esm/core/runtime/companion-language-model-route.js +23 -1
  79. package/dist/esm/core/runtime/companion-language-model-route.js.map +1 -1
  80. package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts +53 -0
  81. package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts.map +1 -1
  82. package/dist/esm/core/runtime/dev-compile-quiet.companion.js +119 -2
  83. package/dist/esm/core/runtime/dev-compile-quiet.companion.js.map +1 -1
  84. package/dist/esm/core/runtime/services/start-companion-application.service.d.ts.map +1 -1
  85. package/dist/esm/core/runtime/services/start-companion-application.service.js +16 -3
  86. package/dist/esm/core/runtime/services/start-companion-application.service.js.map +1 -1
  87. package/dist/esm/core/runtime/utils/companion-platform-config.companion.d.ts +2 -2
  88. package/dist/esm/core/runtime/utils/companion-platform-config.companion.d.ts.map +1 -1
  89. package/dist/esm/core/runtime/utils/companion-platform-config.companion.js +6 -6
  90. package/dist/esm/core/runtime/utils/companion-platform-config.companion.js.map +1 -1
  91. package/dist/esm/core/utils/git-read-broker.companion.d.ts +62 -0
  92. package/dist/esm/core/utils/git-read-broker.companion.d.ts.map +1 -0
  93. package/dist/esm/core/utils/git-read-broker.companion.js +282 -0
  94. package/dist/esm/core/utils/git-read-broker.companion.js.map +1 -0
  95. package/dist/esm/core/utils/local-write-recording.companion.d.ts +8 -1
  96. package/dist/esm/core/utils/local-write-recording.companion.d.ts.map +1 -1
  97. package/dist/esm/core/utils/local-write-recording.companion.js +7 -23
  98. package/dist/esm/core/utils/local-write-recording.companion.js.map +1 -1
  99. package/dist/esm/email/services/email-template.companion.service.d.ts +5 -0
  100. package/dist/esm/email/services/email-template.companion.service.d.ts.map +1 -1
  101. package/dist/esm/email/services/email-template.companion.service.js +44 -11
  102. package/dist/esm/email/services/email-template.companion.service.js.map +1 -1
  103. package/dist/esm/email/utils/email-template-fs-discovery.utils.d.ts +26 -2
  104. package/dist/esm/email/utils/email-template-fs-discovery.utils.d.ts.map +1 -1
  105. package/dist/esm/email/utils/email-template-fs-discovery.utils.js +41 -2
  106. package/dist/esm/email/utils/email-template-fs-discovery.utils.js.map +1 -1
  107. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.d.ts +19 -0
  108. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.d.ts.map +1 -0
  109. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.js +171 -0
  110. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.js.map +1 -0
  111. package/dist/esm/email/utils/module-email-root.companion.utils.d.ts +75 -0
  112. package/dist/esm/email/utils/module-email-root.companion.utils.d.ts.map +1 -0
  113. package/dist/esm/email/utils/module-email-root.companion.utils.js +162 -0
  114. package/dist/esm/email/utils/module-email-root.companion.utils.js.map +1 -0
  115. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.en.d.ts +29 -0
  116. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.en.d.ts.map +1 -0
  117. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.en.js +29 -0
  118. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.en.js.map +1 -0
  119. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.fr.d.ts +29 -0
  120. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.fr.d.ts.map +1 -0
  121. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.fr.js +29 -0
  122. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.fr.js.map +1 -0
  123. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.d.ts +1 -0
  124. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.d.ts.map +1 -1
  125. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.js +1 -0
  126. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.js.map +1 -1
  127. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.d.ts +1 -0
  128. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.d.ts.map +1 -1
  129. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.js +1 -0
  130. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.js.map +1 -1
  131. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.en.d.ts +1 -0
  132. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.en.d.ts.map +1 -1
  133. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.en.js +2 -1
  134. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.en.js.map +1 -1
  135. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.fr.d.ts +1 -0
  136. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.fr.d.ts.map +1 -1
  137. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.fr.js +2 -1
  138. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.fr.js.map +1 -1
  139. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.en.d.ts +5 -2
  140. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.en.d.ts.map +1 -1
  141. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.en.js +5 -2
  142. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.en.js.map +1 -1
  143. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.fr.d.ts +5 -2
  144. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.fr.d.ts.map +1 -1
  145. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.fr.js +5 -2
  146. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.fr.js.map +1 -1
  147. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.en.d.ts +41 -0
  148. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.en.d.ts.map +1 -0
  149. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.en.js +41 -0
  150. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.en.js.map +1 -0
  151. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.fr.d.ts +41 -0
  152. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.fr.d.ts.map +1 -0
  153. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.fr.js +41 -0
  154. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.fr.js.map +1 -0
  155. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.en.d.ts +1 -0
  156. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.en.d.ts.map +1 -1
  157. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.en.js +2 -1
  158. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.en.js.map +1 -1
  159. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.fr.d.ts +1 -0
  160. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.fr.d.ts.map +1 -1
  161. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.fr.js +2 -1
  162. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.fr.js.map +1 -1
  163. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.en.d.ts +1 -0
  164. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.en.d.ts.map +1 -1
  165. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.en.js +2 -1
  166. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.en.js.map +1 -1
  167. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.fr.d.ts +1 -0
  168. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.fr.d.ts.map +1 -1
  169. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.fr.js +2 -1
  170. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.fr.js.map +1 -1
  171. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.en.d.ts +1 -0
  172. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.en.d.ts.map +1 -1
  173. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.en.js +2 -1
  174. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.en.js.map +1 -1
  175. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.fr.d.ts +1 -0
  176. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.fr.d.ts.map +1 -1
  177. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.fr.js +2 -1
  178. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.fr.js.map +1 -1
  179. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.en.d.ts +2 -0
  180. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.en.d.ts.map +1 -1
  181. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.en.js +3 -1
  182. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.en.js.map +1 -1
  183. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.fr.d.ts +2 -0
  184. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.fr.d.ts.map +1 -1
  185. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.fr.js +3 -1
  186. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.fr.js.map +1 -1
  187. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.en.d.ts +1 -1
  188. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.en.js +1 -1
  189. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.en.js.map +1 -1
  190. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.fr.d.ts +1 -1
  191. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.fr.js +1 -1
  192. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.fr.js.map +1 -1
  193. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.en.d.ts +2 -0
  194. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.en.d.ts.map +1 -1
  195. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.en.js +3 -1
  196. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.en.js.map +1 -1
  197. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.fr.d.ts +3 -1
  198. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.fr.d.ts.map +1 -1
  199. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.fr.js +4 -2
  200. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.fr.js.map +1 -1
  201. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.en.d.ts +17 -0
  202. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.en.d.ts.map +1 -1
  203. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.en.js +18 -1
  204. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.en.js.map +1 -1
  205. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.fr.d.ts +17 -0
  206. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.fr.d.ts.map +1 -1
  207. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.fr.js +18 -1
  208. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.fr.js.map +1 -1
  209. package/dist/esm/i18n/composite_views/app.creation-conversation.fr.d.ts +206 -195
  210. package/dist/esm/i18n/composite_views/app.creation-conversation.fr.d.ts.map +1 -1
  211. package/dist/esm/i18n/composite_views/app.creation-conversation.fr.js +206 -195
  212. package/dist/esm/i18n/composite_views/app.creation-conversation.fr.js.map +1 -1
  213. package/dist/esm/i18n/composite_views/app.creation-dossier.fr.d.ts +10 -0
  214. package/dist/esm/i18n/composite_views/app.creation-dossier.fr.d.ts.map +1 -1
  215. package/dist/esm/i18n/composite_views/app.creation-dossier.fr.js +12 -2
  216. package/dist/esm/i18n/composite_views/app.creation-dossier.fr.js.map +1 -1
  217. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.fr.d.ts +70 -0
  218. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.fr.d.ts.map +1 -1
  219. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.fr.js +70 -0
  220. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.fr.js.map +1 -1
  221. package/dist/esm/i18n/resources/wildoApplicationActorTasks.fr.d.ts +12 -2
  222. package/dist/esm/i18n/resources/wildoApplicationActorTasks.fr.d.ts.map +1 -1
  223. package/dist/esm/i18n/resources/wildoApplicationActorTasks.fr.js +12 -2
  224. package/dist/esm/i18n/resources/wildoApplicationActorTasks.fr.js.map +1 -1
  225. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.fr.d.ts +10 -0
  226. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.fr.d.ts.map +1 -1
  227. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.fr.js +10 -0
  228. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.fr.js.map +1 -1
  229. package/dist/esm/i18n/resources/workbenchAspects.en.d.ts.map +1 -1
  230. package/dist/esm/i18n/resources/workbenchAspects.en.js +4 -0
  231. package/dist/esm/i18n/resources/workbenchAspects.en.js.map +1 -1
  232. package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.fr.d.ts +25 -20
  233. package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.fr.d.ts.map +1 -1
  234. package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.fr.js +25 -20
  235. package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.fr.js.map +1 -1
  236. package/dist/esm/i18n/resources/workbenchBuildPlanTasks.fr.d.ts +32 -32
  237. package/dist/esm/i18n/resources/workbenchBuildPlanTasks.fr.js +32 -32
  238. package/dist/esm/i18n/resources/workbenchBuildPlanTasks.fr.js.map +1 -1
  239. package/dist/esm/i18n/resources/workbenchBuildTaskRecords.fr.d.ts +65 -65
  240. package/dist/esm/i18n/resources/workbenchBuildTaskRecords.fr.js +65 -65
  241. package/dist/esm/i18n/resources/workbenchBuildTaskRecords.fr.js.map +1 -1
  242. package/dist/esm/i18n/resources/workbenchDossierEntries.fr.d.ts +20 -0
  243. package/dist/esm/i18n/resources/workbenchDossierEntries.fr.d.ts.map +1 -1
  244. package/dist/esm/i18n/resources/workbenchDossierEntries.fr.js +20 -0
  245. package/dist/esm/i18n/resources/workbenchDossierEntries.fr.js.map +1 -1
  246. package/dist/esm/i18n/resources/workbenchGovernanceQuestions.fr.d.ts +12 -0
  247. package/dist/esm/i18n/resources/workbenchGovernanceQuestions.fr.d.ts.map +1 -1
  248. package/dist/esm/i18n/resources/workbenchGovernanceQuestions.fr.js +13 -1
  249. package/dist/esm/i18n/resources/workbenchGovernanceQuestions.fr.js.map +1 -1
  250. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts +35 -0
  251. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts.map +1 -1
  252. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js +12 -0
  253. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js.map +1 -1
  254. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.d.ts +536 -531
  255. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.d.ts.map +1 -1
  256. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.js +536 -531
  257. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.js.map +1 -1
  258. package/dist/esm/i18n/system_enums/application-creation.fr.d.ts +170 -170
  259. package/dist/esm/i18n/system_enums/application-creation.fr.js +170 -170
  260. package/dist/esm/i18n/system_enums/application-creation.fr.js.map +1 -1
  261. package/dist/esm/i18n/system_enums/flows-actors.fr.d.ts +22 -22
  262. package/dist/esm/i18n/system_enums/flows-actors.fr.js +22 -22
  263. package/dist/esm/i18n/system_enums/flows-actors.fr.js.map +1 -1
  264. package/dist/esm/i18n/system_enums/run-records.fr.d.ts +21 -21
  265. package/dist/esm/i18n/system_enums/run-records.fr.js +21 -21
  266. package/dist/esm/i18n/system_enums/run-records.fr.js.map +1 -1
  267. package/dist/esm/i18n/system_enums/workbench-build.en.d.ts +3 -2
  268. package/dist/esm/i18n/system_enums/workbench-build.en.d.ts.map +1 -1
  269. package/dist/esm/i18n/system_enums/workbench-build.en.js +3 -2
  270. package/dist/esm/i18n/system_enums/workbench-build.en.js.map +1 -1
  271. package/dist/esm/i18n/system_enums/workbench-build.fr.d.ts +37 -33
  272. package/dist/esm/i18n/system_enums/workbench-build.fr.d.ts.map +1 -1
  273. package/dist/esm/i18n/system_enums/workbench-build.fr.js +37 -33
  274. package/dist/esm/i18n/system_enums/workbench-build.fr.js.map +1 -1
  275. package/dist/esm/i18n/system_enums/workbench-creation-home.en.d.ts +1 -0
  276. package/dist/esm/i18n/system_enums/workbench-creation-home.en.d.ts.map +1 -1
  277. package/dist/esm/i18n/system_enums/workbench-creation-home.en.js +1 -0
  278. package/dist/esm/i18n/system_enums/workbench-creation-home.en.js.map +1 -1
  279. package/dist/esm/i18n/system_enums/workbench-creation-home.fr.d.ts +18 -17
  280. package/dist/esm/i18n/system_enums/workbench-creation-home.fr.d.ts.map +1 -1
  281. package/dist/esm/i18n/system_enums/workbench-creation-home.fr.js +18 -17
  282. package/dist/esm/i18n/system_enums/workbench-creation-home.fr.js.map +1 -1
  283. package/dist/esm/i18n/system_enums/workbench-dossier.fr.d.ts +7 -5
  284. package/dist/esm/i18n/system_enums/workbench-dossier.fr.d.ts.map +1 -1
  285. package/dist/esm/i18n/system_enums/workbench-dossier.fr.js +8 -6
  286. package/dist/esm/i18n/system_enums/workbench-dossier.fr.js.map +1 -1
  287. package/dist/esm/i18n/system_enums/workbench-secrets.fr.d.ts +12 -12
  288. package/dist/esm/i18n/system_enums/workbench-secrets.fr.js +12 -12
  289. package/dist/esm/i18n/system_enums/workbench-secrets.fr.js.map +1 -1
  290. package/dist/esm/i18n/system_enums/workbench-specification-artifact.fr.d.ts +1 -0
  291. package/dist/esm/i18n/system_enums/workbench-specification-artifact.fr.d.ts.map +1 -1
  292. package/dist/esm/i18n/system_enums/workbench-specification-artifact.fr.js +2 -1
  293. package/dist/esm/i18n/system_enums/workbench-specification-artifact.fr.js.map +1 -1
  294. package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.d.ts.map +1 -1
  295. package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.js +7 -3
  296. package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.js.map +1 -1
  297. package/dist/esm/i18n-labelling/services/labelling-planner.companion.service.d.ts.map +1 -1
  298. package/dist/esm/i18n-labelling/services/labelling-planner.companion.service.js +3 -4
  299. package/dist/esm/i18n-labelling/services/labelling-planner.companion.service.js.map +1 -1
  300. package/dist/esm/i18n-labelling/utils/declared-refusal-codes.utils.d.ts +11 -0
  301. package/dist/esm/i18n-labelling/utils/declared-refusal-codes.utils.d.ts.map +1 -1
  302. package/dist/esm/i18n-labelling/utils/declared-refusal-codes.utils.js +21 -0
  303. package/dist/esm/i18n-labelling/utils/declared-refusal-codes.utils.js.map +1 -1
  304. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.d.ts +9 -0
  305. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.d.ts.map +1 -1
  306. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.js +18 -2
  307. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.js.map +1 -1
  308. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts +153 -22
  309. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts.map +1 -1
  310. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js +970 -208
  311. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js.map +1 -1
  312. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.d.ts +115 -13
  313. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.d.ts.map +1 -1
  314. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.js +295 -56
  315. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.js.map +1 -1
  316. package/dist/esm/meta-workflows/services/application-build-landing-projection.companion.d.ts +3 -3
  317. package/dist/esm/meta-workflows/services/application-build-landing-projection.companion.js +3 -3
  318. package/dist/esm/meta-workflows/services/application-build-landing-projection.companion.js.map +1 -1
  319. package/dist/esm/meta-workflows/services/application-build-task-closure.companion.d.ts +9 -0
  320. package/dist/esm/meta-workflows/services/application-build-task-closure.companion.d.ts.map +1 -1
  321. package/dist/esm/meta-workflows/services/application-build-task-closure.companion.js +19 -0
  322. package/dist/esm/meta-workflows/services/application-build-task-closure.companion.js.map +1 -1
  323. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts +1 -1
  324. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts.map +1 -1
  325. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js +48 -26
  326. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js.map +1 -1
  327. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.d.ts +12 -0
  328. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.d.ts.map +1 -1
  329. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.js +30 -1
  330. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.js.map +1 -1
  331. package/dist/esm/meta-workflows/services/creation-intervention-ledger.companion.service.d.ts.map +1 -1
  332. package/dist/esm/meta-workflows/services/creation-intervention-ledger.companion.service.js +4 -5
  333. package/dist/esm/meta-workflows/services/creation-intervention-ledger.companion.service.js.map +1 -1
  334. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.d.ts.map +1 -1
  335. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js +12 -1
  336. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js.map +1 -1
  337. package/dist/esm/meta-workflows/services/foundation-executor.companion.service.d.ts.map +1 -1
  338. package/dist/esm/meta-workflows/services/foundation-executor.companion.service.js +6 -3
  339. package/dist/esm/meta-workflows/services/foundation-executor.companion.service.js.map +1 -1
  340. package/dist/esm/meta-workflows/services/playbook-run-write-register-window.companion.d.ts.map +1 -1
  341. package/dist/esm/meta-workflows/services/playbook-run-write-register-window.companion.js +3 -5
  342. package/dist/esm/meta-workflows/services/playbook-run-write-register-window.companion.js.map +1 -1
  343. package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts +8 -1
  344. package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts.map +1 -1
  345. package/dist/esm/meta-workflows/services/playbook-run.companion.service.js +119 -25
  346. package/dist/esm/meta-workflows/services/playbook-run.companion.service.js.map +1 -1
  347. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.d.ts +55 -1
  348. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.d.ts.map +1 -1
  349. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.js +157 -10
  350. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.js.map +1 -1
  351. package/dist/esm/module-layout/module-layout-convention.companion.d.ts +158 -0
  352. package/dist/esm/module-layout/module-layout-convention.companion.d.ts.map +1 -0
  353. package/dist/esm/module-layout/module-layout-convention.companion.js +272 -0
  354. package/dist/esm/module-layout/module-layout-convention.companion.js.map +1 -0
  355. package/dist/esm/module-layout/module-layout-inspection.companion.d.ts +42 -0
  356. package/dist/esm/module-layout/module-layout-inspection.companion.d.ts.map +1 -0
  357. package/dist/esm/module-layout/module-layout-inspection.companion.js +290 -0
  358. package/dist/esm/module-layout/module-layout-inspection.companion.js.map +1 -0
  359. package/dist/esm/module-layout/module-source-files.companion.d.ts +3 -0
  360. package/dist/esm/module-layout/module-source-files.companion.d.ts.map +1 -0
  361. package/dist/esm/module-layout/module-source-files.companion.js +45 -0
  362. package/dist/esm/module-layout/module-source-files.companion.js.map +1 -0
  363. package/package.json +18 -18
@@ -0,0 +1,304 @@
1
+ import { existsSync, promises as fsPromises } from 'node:fs';
2
+ import { basename, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { isMainThread, parentPort, Worker, workerData } from 'node:worker_threads';
5
+ import { describeCaughtError } from '@wildo-ai/saas-models/public-runtime';
6
+ /**
7
+ * The source-state sweep's directory walk, run on a WORKER THREAD (companion event-loop stalls, #3204).
8
+ *
9
+ * `IntrospectionSourceStateObserver` decides WHICH roots to walk (the change feed, the held walks) and turns the result
10
+ * into a token; this module only walks. It used to walk on the companion's main thread, and during a build that was the
11
+ * largest single cost there: every observation re-walks the application's package roots (about 14,000 entries on the
12
+ * reference application), because the build moves them constantly, and the per-file `stat` calls, their promises and
13
+ * their `Stats` objects are main-thread work even though the reads themselves run on libuv's pool. A 90 s CPU profile of
14
+ * the reference run's companion (2026-11-14) put 11.6 s of the main thread inside the sweep's `stat` calls and 15 s in
15
+ * the sweep overall, while every workbench request waited behind it. On a worker the same walk costs the main thread one
16
+ * message each way.
17
+ *
18
+ * The walk is the same code either way: {@link walkSourceRoots} is what the worker runs and what the companion runs in
19
+ * process when no worker can be had (a test harness, a failed start, a worker that died), so the two cannot disagree
20
+ * about what a token means.
21
+ *
22
+ * This module imports NOTHING but Node built-ins, deliberately: from source (the companion under test, or run from its
23
+ * `.ts`) the worker is started on this file directly and Node strips its types, which resolves no extensionless
24
+ * relative import and no package. Its concurrency bounds therefore arrive with each request rather than by import, and
25
+ * nothing here may use non-erasable TypeScript (an `enum`, a parameter property).
26
+ */
27
+ /**
28
+ * Directory names never descended into.
29
+ *
30
+ * `node_modules` is skipped during the walk and reached only through the explicit `@wildo-ai/*`
31
+ * roots the observer resolves: descending into it from an application package would sweep the app's entire
32
+ * dependency graph (hundreds of thousands of files) to learn nothing the resolved engine roots do
33
+ * not already say.
34
+ */
35
+ const SKIPPED_DIRECTORY_NAMES = new Set(['node_modules', '.git']);
36
+ /**
37
+ * The compiler's private output, never descended into when it sits in a package's `.wildo-runtime-signals` (#3452).
38
+ *
39
+ * A compile writes here first and publishes into `dist` once the emit is final, and nothing a derivation imports resolves
40
+ * here: every package's `exports` name `dist`, and no link in any dogfood application points into staging (measured
41
+ * 2026-11-08 over `examples/`). So a staging write cannot change a derivation, and the publication that can moves `dist`
42
+ * and the accepted-generation manifest beside it, which are still walked. It was about 40 % of what a sweep stat'ed
43
+ * (5,440 of Wonder Todos' 13,484 `backend-api` files). The change source ignores the same subtree.
44
+ */
45
+ const COMPILE_STAGING_DIRECTORY_NAME = 'compile-staging';
46
+ const RUNTIME_SIGNALS_DIRECTORY_NAME = '.wildo-runtime-signals';
47
+ /** A counting semaphore for the file-stat bound. */
48
+ class StatPermits {
49
+ available;
50
+ waiting = [];
51
+ constructor(permits) {
52
+ this.available = permits;
53
+ }
54
+ async run(operation) {
55
+ if (this.available > 0) {
56
+ this.available -= 1;
57
+ }
58
+ else {
59
+ // A released permit is handed straight to the next waiter, so `available` never rises while
60
+ // anyone is waiting and no waiter can be overtaken by a later caller.
61
+ await new Promise((resolveWait) => this.waiting.push(resolveWait));
62
+ }
63
+ try {
64
+ return await operation();
65
+ }
66
+ finally {
67
+ const next = this.waiting.shift();
68
+ if (next)
69
+ next();
70
+ else
71
+ this.available += 1;
72
+ }
73
+ }
74
+ }
75
+ /**
76
+ * Walk the roots and return one accumulator per root. Never rejects for a root that cannot be read: it contributes
77
+ * nothing, and when it appears later it is a new directory, which moves the counts.
78
+ */
79
+ export async function walkSourceRoots(request) {
80
+ const accumulators = request.roots.map(() => ({ fileCount: 0, directoryCount: 0, maximumMtimeMs: 0 }));
81
+ const totals = {
82
+ entryCount: request.entryCountBefore,
83
+ exceededCeiling: false,
84
+ maximumEntries: request.maximumEntries,
85
+ statPermits: new StatPermits(request.fileStatConcurrency),
86
+ };
87
+ await walk(request.roots.map((directory, index) => ({ directory, accumulator: accumulators[index] })), totals, request.directoryConcurrency);
88
+ return { accumulators, entryCount: totals.entryCount, exceededCeiling: totals.exceededCeiling };
89
+ }
90
+ /**
91
+ * Breadth-of-tree walk with a fixed directory concurrency.
92
+ *
93
+ * A worker-pool built over the ROOT list was written first and was wrong: it sizes its pool from
94
+ * the number of roots, so a single-root application would walk its whole tree one directory at a
95
+ * time, and a worker that finds the queue momentarily empty cannot tell "finished" from "another
96
+ * worker is about to push children". The pump below sizes on IN-FLIGHT directories instead, which
97
+ * is the quantity the concurrency limit is actually about, and terminates on the only condition
98
+ * that means finished: nothing queued and nothing running.
99
+ */
100
+ async function walk(roots, totals, directoryConcurrency) {
101
+ const pending = [...roots];
102
+ let inFlightDirectories = 0;
103
+ return new Promise((resolveWalk) => {
104
+ const pump = () => {
105
+ while (!totals.exceededCeiling && inFlightDirectories < directoryConcurrency && pending.length > 0) {
106
+ const next = pending.pop();
107
+ inFlightDirectories += 1;
108
+ void visitDirectory(next, totals, pending).then(() => {
109
+ inFlightDirectories -= 1;
110
+ pump();
111
+ });
112
+ }
113
+ if (inFlightDirectories === 0 && (pending.length === 0 || totals.exceededCeiling)) {
114
+ resolveWalk();
115
+ }
116
+ };
117
+ pump();
118
+ });
119
+ }
120
+ /**
121
+ * Read one directory: count it, fold its own mtime in, stat its files, and queue its children.
122
+ *
123
+ * Never rejects. A directory that cannot be read (an unbuilt `dist`, a permission) contributes
124
+ * nothing and is not an error — when it appears later it is a new directory, which moves the
125
+ * counts and invalidates every cached derivation.
126
+ */
127
+ async function visitDirectory({ directory, accumulator }, totals, pending) {
128
+ let entries;
129
+ try {
130
+ entries = await fsPromises.readdir(directory, { withFileTypes: true });
131
+ }
132
+ catch {
133
+ return;
134
+ }
135
+ accumulator.directoryCount += 1;
136
+ totals.entryCount += 1;
137
+ try {
138
+ const directoryStats = await fsPromises.stat(directory);
139
+ if (directoryStats.mtimeMs > accumulator.maximumMtimeMs) {
140
+ accumulator.maximumMtimeMs = directoryStats.mtimeMs;
141
+ }
142
+ }
143
+ catch {
144
+ // Counted above regardless: the directory demonstrably exists, we just read it.
145
+ }
146
+ const fileStats = [];
147
+ const insideRuntimeSignals = basename(directory) === RUNTIME_SIGNALS_DIRECTORY_NAME;
148
+ for (const entry of entries) {
149
+ if (SKIPPED_DIRECTORY_NAMES.has(entry.name))
150
+ continue;
151
+ if (insideRuntimeSignals && entry.name === COMPILE_STAGING_DIRECTORY_NAME)
152
+ continue;
153
+ const entryPath = join(directory, entry.name);
154
+ if (entry.isDirectory()) {
155
+ pending.push({ directory: entryPath, accumulator });
156
+ continue;
157
+ }
158
+ if (!entry.isFile()) {
159
+ // A symlink is counted but never followed — following one inside a package tree can walk
160
+ // back out into a dependency graph. Retargeting one rewrites its directory entry, which
161
+ // moves the parent directory's mtime, so the change is still observed.
162
+ accumulator.fileCount += 1;
163
+ totals.entryCount += 1;
164
+ continue;
165
+ }
166
+ totals.entryCount += 1;
167
+ fileStats.push(totals.statPermits.run(() => fsPromises.stat(entryPath)).then((entryStats) => {
168
+ accumulator.fileCount += 1;
169
+ if (entryStats.mtimeMs > accumulator.maximumMtimeMs) {
170
+ accumulator.maximumMtimeMs = entryStats.mtimeMs;
171
+ }
172
+ }, () => {
173
+ accumulator.fileCount += 1;
174
+ }));
175
+ }
176
+ await Promise.all(fileStats);
177
+ if (totals.entryCount > totals.maximumEntries) {
178
+ totals.exceededCeiling = true;
179
+ }
180
+ }
181
+ /** Marks a thread started by {@link SourceWalkWorker}, so importing this module elsewhere starts nothing. */
182
+ const SOURCE_WALK_WORKER_KIND = 'wildo.introspection-source-walk';
183
+ // The worker side: answer each request with the same function the companion would run in process.
184
+ if (!isMainThread && parentPort !== null && workerData?.kind === SOURCE_WALK_WORKER_KIND) {
185
+ const port = parentPort;
186
+ port.on('message', (message) => {
187
+ walkSourceRoots(message.request).then((result) => port.postMessage({ id: message.id, result }), (error) => port.postMessage({ id: message.id, error: describeCaughtError(error) }));
188
+ });
189
+ }
190
+ /**
191
+ * The companion's side: one long-lived worker thread, started on first use and shared by every observer (two sweep the
192
+ * same roots). Unreferenced, so it never keeps the process alive.
193
+ *
194
+ * Fails toward the in-process walk, never toward a wrong token: a worker that cannot start, errors or exits fails its
195
+ * pending walks with a {@link SourceWalkWorkerUnavailableError}, the caller walks in process, and the next walk starts
196
+ * a fresh worker. After {@link MAXIMUM_WORKER_FAILURES} consecutive failures it stops trying for the life of the process,
197
+ * so a worker that can never start costs one failed start per walk at most a few times, not on every observation.
198
+ */
199
+ export class SourceWalkWorker {
200
+ worker;
201
+ nextId = 1;
202
+ consecutiveFailures = 0;
203
+ pending = new Map();
204
+ // A plain field, not a parameter property: this file runs under type stripping, which refuses non-erasable syntax.
205
+ options;
206
+ constructor(options = {}) {
207
+ this.options = options;
208
+ }
209
+ /** The walk, on the worker; rejects with {@link SourceWalkWorkerUnavailableError} when no worker can do it. */
210
+ walk(request) {
211
+ const worker = this.ensureWorker();
212
+ if (worker === undefined)
213
+ return Promise.reject(new SourceWalkWorkerUnavailableError('no source-walk worker is available'));
214
+ const id = this.nextId;
215
+ this.nextId += 1;
216
+ return new Promise((resolve, reject) => {
217
+ this.pending.set(id, { resolve, reject });
218
+ // Referenced only while a walk is pending, so a running walk is never cut short by the process idling out.
219
+ if (this.pending.size === 1)
220
+ worker.ref();
221
+ worker.postMessage({ id, request });
222
+ });
223
+ }
224
+ /** Whether the worker has been given up on for this process. For tests and logs. */
225
+ get disabled() {
226
+ return this.consecutiveFailures >= MAXIMUM_WORKER_FAILURES;
227
+ }
228
+ /** Stop the worker (tests). A walk it was doing fails as unavailable, so its caller walks in process. */
229
+ async close() {
230
+ const worker = this.worker;
231
+ if (worker === undefined)
232
+ return;
233
+ this.failPending(worker, 'the source-walk worker was closed');
234
+ await worker.terminate();
235
+ }
236
+ ensureWorker() {
237
+ if (this.worker !== undefined)
238
+ return this.worker;
239
+ if (this.disabled)
240
+ return undefined;
241
+ let worker;
242
+ try {
243
+ worker = new Worker(this.options.entryPath ?? resolveSourceWalkWorkerEntry(), { workerData: { kind: SOURCE_WALK_WORKER_KIND } });
244
+ }
245
+ catch {
246
+ this.consecutiveFailures += 1;
247
+ return undefined;
248
+ }
249
+ worker.unref();
250
+ worker.on('message', (message) => {
251
+ const waiter = this.pending.get(message.id);
252
+ if (waiter === undefined)
253
+ return;
254
+ this.pending.delete(message.id);
255
+ if (this.pending.size === 0)
256
+ worker.unref();
257
+ if (message.result !== undefined) {
258
+ this.consecutiveFailures = 0;
259
+ waiter.resolve(message.result);
260
+ }
261
+ else {
262
+ waiter.reject(new SourceWalkWorkerUnavailableError(message.error ?? 'the source-walk worker answered nothing'));
263
+ }
264
+ });
265
+ const fail = (reason) => {
266
+ if (this.worker !== worker)
267
+ return;
268
+ this.consecutiveFailures += 1;
269
+ this.failPending(worker, reason);
270
+ // A failure that is not an exit (an error, an unreadable answer) leaves the thread running: stop the one it forgot.
271
+ void worker.terminate().catch(() => undefined);
272
+ };
273
+ worker.on('error', (error) => fail(`the source-walk worker failed: ${error.message}`));
274
+ worker.on('exit', (code) => fail(`the source-walk worker exited (code ${code})`));
275
+ // An answer that cannot be deserialized would otherwise leave its walk pending for good.
276
+ worker.on('messageerror', (error) => fail(`the source-walk worker's answer could not be read: ${error.message}`));
277
+ this.worker = worker;
278
+ return worker;
279
+ }
280
+ /** Forget the worker and fail every walk it was doing as unavailable, so each is walked in process. */
281
+ failPending(worker, reason) {
282
+ if (this.worker !== worker)
283
+ return;
284
+ this.worker = undefined;
285
+ const waiters = [...this.pending.values()];
286
+ this.pending.clear();
287
+ for (const waiter of waiters)
288
+ waiter.reject(new SourceWalkWorkerUnavailableError(reason));
289
+ }
290
+ }
291
+ /** A walk the worker could not do; the caller walks in process instead. */
292
+ export class SourceWalkWorkerUnavailableError extends Error {
293
+ name = 'SourceWalkWorkerUnavailableError';
294
+ }
295
+ /** Consecutive worker failures after which the companion walks in process for the rest of its life. */
296
+ export const MAXIMUM_WORKER_FAILURES = 3;
297
+ /** This module's own file: the compiled `.js` in a build, the `.ts` when the companion runs from source. */
298
+ function resolveSourceWalkWorkerEntry() {
299
+ const own = fileURLToPath(import.meta.url);
300
+ if (existsSync(own))
301
+ return own;
302
+ throw new SourceWalkWorkerUnavailableError(`the source-walk worker entry ${own} does not exist`);
303
+ }
304
+ //# sourceMappingURL=introspection-source-walk.worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"introspection-source-walk.worker.js","sourceRoot":"","sources":["../../../../../src/core/introspection/services/introspection-source-walk.worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC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CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,uCAAuC,IAAI,GAAG,CAAC,CAAC,CAAC;QAC1F,yFAAyF;QACzF,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,KAAY,EAAE,EAAE,CAAC,IAAI,CAAC,sDAAsD,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACzH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,uGAAuG;IAC/F,WAAW,CAAC,MAAc,EAAE,MAAc;QAChD,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM;YAAE,OAAO;QACnC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,KAAK,MAAM,MAAM,IAAI,OAAO;YAAE,MAAM,CAAC,MAAM,CAAC,IAAI,gCAAgC,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5F,CAAC;CACF;AAED,2EAA2E;AAC3E,MAAM,OAAO,gCAAiC,SAAQ,KAAK;IAChC,IAAI,GAAG,kCAAkC,CAAC;CACpE;AAED,uGAAuG;AACvG,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC,4GAA4G;AAC5G,SAAS,4BAA4B;IACnC,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IAChC,MAAM,IAAI,gCAAgC,CAAC,gCAAgC,GAAG,iBAAiB,CAAC,CAAC;AACnG,CAAC","sourcesContent":["import { existsSync, promises as fsPromises } from 'node:fs';\nimport { basename, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isMainThread, parentPort, Worker, workerData } from 'node:worker_threads';\nimport { describeCaughtError } from '@wildo-ai/saas-models/public-runtime';\n\n/**\n * The source-state sweep's directory walk, run on a WORKER THREAD (companion event-loop stalls, #3204).\n *\n * `IntrospectionSourceStateObserver` decides WHICH roots to walk (the change feed, the held walks) and turns the result\n * into a token; this module only walks. It used to walk on the companion's main thread, and during a build that was the\n * largest single cost there: every observation re-walks the application's package roots (about 14,000 entries on the\n * reference application), because the build moves them constantly, and the per-file `stat` calls, their promises and\n * their `Stats` objects are main-thread work even though the reads themselves run on libuv's pool. A 90 s CPU profile of\n * the reference run's companion (2026-11-14) put 11.6 s of the main thread inside the sweep's `stat` calls and 15 s in\n * the sweep overall, while every workbench request waited behind it. On a worker the same walk costs the main thread one\n * message each way.\n *\n * The walk is the same code either way: {@link walkSourceRoots} is what the worker runs and what the companion runs in\n * process when no worker can be had (a test harness, a failed start, a worker that died), so the two cannot disagree\n * about what a token means.\n *\n * This module imports NOTHING but Node built-ins, deliberately: from source (the companion under test, or run from its\n * `.ts`) the worker is started on this file directly and Node strips its types, which resolves no extensionless\n * relative import and no package. Its concurrency bounds therefore arrive with each request rather than by import, and\n * nothing here may use non-erasable TypeScript (an `enum`, a parameter property).\n */\n\n/**\n * Directory names never descended into.\n *\n * `node_modules` is skipped during the walk and reached only through the explicit `@wildo-ai/*`\n * roots the observer resolves: descending into it from an application package would sweep the app's entire\n * dependency graph (hundreds of thousands of files) to learn nothing the resolved engine roots do\n * not already say.\n */\nconst SKIPPED_DIRECTORY_NAMES = new Set(['node_modules', '.git']);\n\n/**\n * The compiler's private output, never descended into when it sits in a package's `.wildo-runtime-signals` (#3452).\n *\n * A compile writes here first and publishes into `dist` once the emit is final, and nothing a derivation imports resolves\n * here: every package's `exports` name `dist`, and no link in any dogfood application points into staging (measured\n * 2026-11-08 over `examples/`). So a staging write cannot change a derivation, and the publication that can moves `dist`\n * and the accepted-generation manifest beside it, which are still walked. It was about 40 % of what a sweep stat'ed\n * (5,440 of Wonder Todos' 13,484 `backend-api` files). The change source ignores the same subtree.\n */\nconst COMPILE_STAGING_DIRECTORY_NAME = 'compile-staging';\nconst RUNTIME_SIGNALS_DIRECTORY_NAME = '.wildo-runtime-signals';\n\n/** What one root's walk learned: the components of its token. */\nexport interface SourceWalkAccumulator {\n fileCount: number;\n directoryCount: number;\n maximumMtimeMs: number;\n}\n\n/** One walk: the roots, and the bounds the observer owns. */\nexport interface SourceWalkRequest {\n readonly roots: readonly string[];\n /** Entries the observation already counted (manifests, held roots), so the ceiling bounds the whole sweep. */\n readonly entryCountBefore: number;\n /** Past this the walk stops and reports `exceededCeiling`; see the observer's `MAXIMUM_OBSERVED_ENTRIES`. */\n readonly maximumEntries: number;\n /** `DIRECTORY_WALK_CONCURRENCY`, passed rather than imported (see the module comment). */\n readonly directoryConcurrency: number;\n /** `FILE_STAT_CONCURRENCY`, passed rather than imported (see the module comment). */\n readonly fileStatConcurrency: number;\n}\n\n/** {@link walkSourceRoots}'s answer: one accumulator per requested root, in request order. */\nexport interface SourceWalkResult {\n readonly accumulators: readonly SourceWalkAccumulator[];\n readonly entryCount: number;\n readonly exceededCeiling: boolean;\n}\n\n/** A directory still to visit, and the component its entries count towards. */\ninterface PendingDirectory {\n readonly directory: string;\n readonly accumulator: SourceWalkAccumulator;\n}\n\n/** The whole walk's running total, so the ceiling bounds the walk rather than any one root. */\ninterface WalkTotals {\n entryCount: number;\n exceededCeiling: boolean;\n readonly maximumEntries: number;\n /** Shared by every directory of the walk, so the bound is on the walk and not per directory. */\n readonly statPermits: StatPermits;\n}\n\n/** A counting semaphore for the file-stat bound. */\nclass StatPermits {\n private available: number;\n private readonly waiting: Array<() => void> = [];\n\n constructor(permits: number) {\n this.available = permits;\n }\n\n public async run<T>(operation: () => Promise<T>): Promise<T> {\n if (this.available > 0) {\n this.available -= 1;\n } else {\n // A released permit is handed straight to the next waiter, so `available` never rises while\n // anyone is waiting and no waiter can be overtaken by a later caller.\n await new Promise<void>((resolveWait) => this.waiting.push(resolveWait));\n }\n try {\n return await operation();\n } finally {\n const next = this.waiting.shift();\n if (next) next();\n else this.available += 1;\n }\n }\n}\n\n/**\n * Walk the roots and return one accumulator per root. Never rejects for a root that cannot be read: it contributes\n * nothing, and when it appears later it is a new directory, which moves the counts.\n */\nexport async function walkSourceRoots(request: SourceWalkRequest): Promise<SourceWalkResult> {\n const accumulators = request.roots.map((): SourceWalkAccumulator => ({ fileCount: 0, directoryCount: 0, maximumMtimeMs: 0 }));\n const totals: WalkTotals = {\n entryCount: request.entryCountBefore,\n exceededCeiling: false,\n maximumEntries: request.maximumEntries,\n statPermits: new StatPermits(request.fileStatConcurrency),\n };\n await walk(request.roots.map((directory, index) => ({ directory, accumulator: accumulators[index]! })), totals, request.directoryConcurrency);\n return { accumulators, entryCount: totals.entryCount, exceededCeiling: totals.exceededCeiling };\n}\n\n/**\n * Breadth-of-tree walk with a fixed directory concurrency.\n *\n * A worker-pool built over the ROOT list was written first and was wrong: it sizes its pool from\n * the number of roots, so a single-root application would walk its whole tree one directory at a\n * time, and a worker that finds the queue momentarily empty cannot tell \"finished\" from \"another\n * worker is about to push children\". The pump below sizes on IN-FLIGHT directories instead, which\n * is the quantity the concurrency limit is actually about, and terminates on the only condition\n * that means finished: nothing queued and nothing running.\n */\nasync function walk(roots: readonly PendingDirectory[], totals: WalkTotals, directoryConcurrency: number): Promise<void> {\n const pending: PendingDirectory[] = [...roots];\n let inFlightDirectories = 0;\n\n return new Promise<void>((resolveWalk) => {\n const pump = (): void => {\n while (!totals.exceededCeiling && inFlightDirectories < directoryConcurrency && pending.length > 0) {\n const next = pending.pop() as PendingDirectory;\n inFlightDirectories += 1;\n void visitDirectory(next, totals, pending).then(() => {\n inFlightDirectories -= 1;\n pump();\n });\n }\n\n if (inFlightDirectories === 0 && (pending.length === 0 || totals.exceededCeiling)) {\n resolveWalk();\n }\n };\n\n pump();\n });\n}\n\n/**\n * Read one directory: count it, fold its own mtime in, stat its files, and queue its children.\n *\n * Never rejects. A directory that cannot be read (an unbuilt `dist`, a permission) contributes\n * nothing and is not an error — when it appears later it is a new directory, which moves the\n * counts and invalidates every cached derivation.\n */\nasync function visitDirectory({ directory, accumulator }: PendingDirectory, totals: WalkTotals, pending: PendingDirectory[]): Promise<void> {\n let entries;\n try {\n entries = await fsPromises.readdir(directory, { withFileTypes: true });\n } catch {\n return;\n }\n\n accumulator.directoryCount += 1;\n totals.entryCount += 1;\n try {\n const directoryStats = await fsPromises.stat(directory);\n if (directoryStats.mtimeMs > accumulator.maximumMtimeMs) {\n accumulator.maximumMtimeMs = directoryStats.mtimeMs;\n }\n } catch {\n // Counted above regardless: the directory demonstrably exists, we just read it.\n }\n\n const fileStats: Promise<void>[] = [];\n const insideRuntimeSignals = basename(directory) === RUNTIME_SIGNALS_DIRECTORY_NAME;\n for (const entry of entries) {\n if (SKIPPED_DIRECTORY_NAMES.has(entry.name)) continue;\n if (insideRuntimeSignals && entry.name === COMPILE_STAGING_DIRECTORY_NAME) continue;\n const entryPath = join(directory, entry.name);\n if (entry.isDirectory()) {\n pending.push({ directory: entryPath, accumulator });\n continue;\n }\n if (!entry.isFile()) {\n // A symlink is counted but never followed — following one inside a package tree can walk\n // back out into a dependency graph. Retargeting one rewrites its directory entry, which\n // moves the parent directory's mtime, so the change is still observed.\n accumulator.fileCount += 1;\n totals.entryCount += 1;\n continue;\n }\n totals.entryCount += 1;\n fileStats.push(\n totals.statPermits.run(() => fsPromises.stat(entryPath)).then(\n (entryStats) => {\n accumulator.fileCount += 1;\n if (entryStats.mtimeMs > accumulator.maximumMtimeMs) {\n accumulator.maximumMtimeMs = entryStats.mtimeMs;\n }\n },\n () => {\n accumulator.fileCount += 1;\n },\n ),\n );\n }\n await Promise.all(fileStats);\n\n if (totals.entryCount > totals.maximumEntries) {\n totals.exceededCeiling = true;\n }\n}\n\n/** Marks a thread started by {@link SourceWalkWorker}, so importing this module elsewhere starts nothing. */\nconst SOURCE_WALK_WORKER_KIND = 'wildo.introspection-source-walk';\n\ninterface SourceWalkWorkerMessage {\n readonly id: number;\n readonly result?: SourceWalkResult;\n readonly error?: string;\n}\n\n// The worker side: answer each request with the same function the companion would run in process.\nif (!isMainThread && parentPort !== null && (workerData as { kind?: unknown } | undefined)?.kind === SOURCE_WALK_WORKER_KIND) {\n const port = parentPort;\n port.on('message', (message: { readonly id: number; readonly request: SourceWalkRequest }) => {\n walkSourceRoots(message.request).then(\n (result) => port.postMessage({ id: message.id, result } satisfies SourceWalkWorkerMessage),\n (error: unknown) => port.postMessage({ id: message.id, error: describeCaughtError(error) } satisfies SourceWalkWorkerMessage),\n );\n });\n}\n\n/**\n * The companion's side: one long-lived worker thread, started on first use and shared by every observer (two sweep the\n * same roots). Unreferenced, so it never keeps the process alive.\n *\n * Fails toward the in-process walk, never toward a wrong token: a worker that cannot start, errors or exits fails its\n * pending walks with a {@link SourceWalkWorkerUnavailableError}, the caller walks in process, and the next walk starts\n * a fresh worker. After {@link MAXIMUM_WORKER_FAILURES} consecutive failures it stops trying for the life of the process,\n * so a worker that can never start costs one failed start per walk at most a few times, not on every observation.\n */\nexport class SourceWalkWorker {\n private worker: Worker | undefined;\n private nextId = 1;\n private consecutiveFailures = 0;\n private readonly pending = new Map<number, { resolve: (result: SourceWalkResult) => void; reject: (error: Error) => void }>();\n // A plain field, not a parameter property: this file runs under type stripping, which refuses non-erasable syntax.\n private readonly options: { readonly entryPath?: string };\n\n public constructor(options: { readonly entryPath?: string } = {}) {\n this.options = options;\n }\n\n /** The walk, on the worker; rejects with {@link SourceWalkWorkerUnavailableError} when no worker can do it. */\n public walk(request: SourceWalkRequest): Promise<SourceWalkResult> {\n const worker = this.ensureWorker();\n if (worker === undefined) return Promise.reject(new SourceWalkWorkerUnavailableError('no source-walk worker is available'));\n const id = this.nextId;\n this.nextId += 1;\n return new Promise<SourceWalkResult>((resolve, reject) => {\n this.pending.set(id, { resolve, reject });\n // Referenced only while a walk is pending, so a running walk is never cut short by the process idling out.\n if (this.pending.size === 1) worker.ref();\n worker.postMessage({ id, request });\n });\n }\n\n /** Whether the worker has been given up on for this process. For tests and logs. */\n public get disabled(): boolean {\n return this.consecutiveFailures >= MAXIMUM_WORKER_FAILURES;\n }\n\n /** Stop the worker (tests). A walk it was doing fails as unavailable, so its caller walks in process. */\n public async close(): Promise<void> {\n const worker = this.worker;\n if (worker === undefined) return;\n this.failPending(worker, 'the source-walk worker was closed');\n await worker.terminate();\n }\n\n private ensureWorker(): Worker | undefined {\n if (this.worker !== undefined) return this.worker;\n if (this.disabled) return undefined;\n let worker: Worker;\n try {\n worker = new Worker(this.options.entryPath ?? resolveSourceWalkWorkerEntry(), { workerData: { kind: SOURCE_WALK_WORKER_KIND } });\n } catch {\n this.consecutiveFailures += 1;\n return undefined;\n }\n worker.unref();\n worker.on('message', (message: SourceWalkWorkerMessage) => {\n const waiter = this.pending.get(message.id);\n if (waiter === undefined) return;\n this.pending.delete(message.id);\n if (this.pending.size === 0) worker.unref();\n if (message.result !== undefined) {\n this.consecutiveFailures = 0;\n waiter.resolve(message.result);\n } else {\n waiter.reject(new SourceWalkWorkerUnavailableError(message.error ?? 'the source-walk worker answered nothing'));\n }\n });\n const fail = (reason: string): void => {\n if (this.worker !== worker) return;\n this.consecutiveFailures += 1;\n this.failPending(worker, reason);\n // A failure that is not an exit (an error, an unreadable answer) leaves the thread running: stop the one it forgot.\n void worker.terminate().catch(() => undefined);\n };\n worker.on('error', (error: Error) => fail(`the source-walk worker failed: ${error.message}`));\n worker.on('exit', (code: number) => fail(`the source-walk worker exited (code ${code})`));\n // An answer that cannot be deserialized would otherwise leave its walk pending for good.\n worker.on('messageerror', (error: Error) => fail(`the source-walk worker's answer could not be read: ${error.message}`));\n this.worker = worker;\n return worker;\n }\n\n /** Forget the worker and fail every walk it was doing as unavailable, so each is walked in process. */\n private failPending(worker: Worker, reason: string): void {\n if (this.worker !== worker) return;\n this.worker = undefined;\n const waiters = [...this.pending.values()];\n this.pending.clear();\n for (const waiter of waiters) waiter.reject(new SourceWalkWorkerUnavailableError(reason));\n }\n}\n\n/** A walk the worker could not do; the caller walks in process instead. */\nexport class SourceWalkWorkerUnavailableError extends Error {\n public override readonly name = 'SourceWalkWorkerUnavailableError';\n}\n\n/** Consecutive worker failures after which the companion walks in process for the rest of its life. */\nexport const MAXIMUM_WORKER_FAILURES = 3;\n\n/** This module's own file: the compiled `.js` in a build, the `.ts` when the companion runs from source. */\nfunction resolveSourceWalkWorkerEntry(): string {\n const own = fileURLToPath(import.meta.url);\n if (existsSync(own)) return own;\n throw new SourceWalkWorkerUnavailableError(`the source-walk worker entry ${own} does not exist`);\n}\n"]}
@@ -1,7 +1,8 @@
1
1
  import type { LoggerService } from '@wildo-ai/saas-backend-lib';
2
- import type { CompanionArtifactPlacementDescriptor, CompanionEmailTemplateOwnershipDescriptor, CompanionResourceOwnershipDescriptor } from '@wildo-ai/saas-models/companion';
2
+ import type { CompanionArtifactPlacementDescriptor, CompanionResourceOwnershipDescriptor } from '@wildo-ai/saas-models/companion';
3
3
  import type { CompanionContext } from '../../context/companion-context';
4
4
  import { CompanionIntrospectionService } from './companion-introspection.companion.service';
5
+ import type { EmailTemplateOwnershipPlacement } from '../../../email/utils/email-template-fs-discovery.utils';
5
6
  interface SharedTranslationPlacementInfo {
6
7
  carrierServiceKey: string;
7
8
  moduleIds: string[];
@@ -15,7 +16,7 @@ interface FrontendTranslationPlacementInfo {
15
16
  }
16
17
  interface BackendEmailPlacementInfo {
17
18
  serviceKey: string;
18
- emailTemplateOwnership: CompanionEmailTemplateOwnershipDescriptor[];
19
+ emailTemplateOwnership: EmailTemplateOwnershipPlacement[];
19
20
  }
20
21
  export interface TranslationPlacementSnapshot {
21
22
  declaredModuleIds: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"translation-placement.companion.service.d.ts","sourceRoot":"","sources":["../../../../../src/core/introspection/services/translation-placement.companion.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;A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EpF,6BAA6B,EAAE,6BAA6B;IAMlE,oBAAoB,CAC/B,OAAO,GAAE,mCAAwC,GAChD,OAAO,CAAC,4BAA4B,CAAC;IAgDxC,OAAO,CAAC,2BAA2B;YAgBrB,mBAAmB;YAwBnB,qBAAqB;YAkBrB,yBAAyB;YAkBzB,mBAAmB;CA0BlC"}
1
+ {"version":3,"file":"translation-placement.companion.service.d.ts","sourceRoot":"","sources":["../../../../../src/core/introspection/services/translation-placement.companion.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,KAAK,EACV,oCAAoC,EACpC,oCAAoC,EACrC,MAAM,iCAAiC,CAAC;AAGzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAG5F,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAC;AAE9G,UAAU,8BAA8B;IACtC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,qBAAqB,EAAE,MAAM,EAAE,CAAC;IAChC,kBAAkB,EAAE,oCAAoC,EAAE,CAAC;IAC3D,iBAAiB,EAAE,oCAAoC,EAAE,CAAC;CAC3D;AAED,UAAU,gCAAgC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,oCAAoC,EAAE,CAAC;CAC5D;AAED,UAAU,yBAAyB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB,EAAE,+BAA+B,EAAE,CAAC;CAC3D;AAED,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,MAAM,EAAE,8BAA8B,GAAG,IAAI,CAAC;IAC9C,QAAQ,EAAE,gCAAgC,EAAE,CAAC;IAC7C,YAAY,EAAE,yBAAyB,EAAE,CAAC;IAC1C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,mCAAmC;IAClD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,qBACa,oCAAoC;IAIV,OAAO,CAAC,QAAQ,CAAC,MAAM;IACR,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAEnF,OAAO,CAAC,QAAQ,CAAC,6BAA6B;IANhD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA+D;gBAGlC,MAAM,EAAE,aAAa,EACN,gBAAgB,EAAE,gBAAgB,EAEpF,6BAA6B,EAAE,6BAA6B;IAMlE,oBAAoB,CAC/B,OAAO,GAAE,mCAAwC,GAChD,OAAO,CAAC,4BAA4B,CAAC;IAgDxC,OAAO,CAAC,2BAA2B;YAgBrB,mBAAmB;YAwBnB,qBAAqB;YAkBrB,yBAAyB;YAkBzB,mBAAmB;CA0BlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"translation-placement.companion.service.js","sourceRoot":"","sources":["../../../../../src/core/introspection/services/translation-placement.companion.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAG,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAOrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAE5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAoCrF,IAAM,oCAAoC,GAA1C,MAAM,oCAAoC;IAIO;IACe;IAElD;IANF,QAAQ,CAA+D;IAExF,YACsD,MAAqB,EACN,gBAAkC,EAEpF,6BAA4D;QAHzB,WAAM,GAAN,MAAM,CAAe;QACN,qBAAgB,GAAhB,gBAAgB,CAA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AppFrontendType } from '@wildo-ai/platform-config-lib';\nimport type { LoggerService } from '@wildo-ai/saas-backend-lib';\nimport { SAAS_SERVICE_TYPES , describeCaughtError} from '@wildo-ai/saas-backend-lib';\nimport type {\n CompanionArtifactPlacementDescriptor,\n CompanionEmailTemplateOwnershipDescriptor,\n CompanionResourceOwnershipDescriptor,\n} from '@wildo-ai/saas-models/companion';\nimport { CompanionArtifactClass } from '@wildo-ai/saas-models/companion';\nimport { COMPANION_SERVICE_TYPES } from '../../inject/models/service-types';\nimport type { CompanionContext } from '../../context/companion-context';\nimport { CompanionIntrospectionService } from './companion-introspection.companion.service';\nimport type { CompanionIntrospectionBehaviorId } from '../models/companion-introspection.models';\n\ninterface SharedTranslationPlacementInfo {\n carrierServiceKey: string;\n moduleIds: string[];\n contributionModuleIds: string[];\n artifactPlacements: CompanionArtifactPlacementDescriptor[];\n resourceOwnership: CompanionResourceOwnershipDescriptor[];\n}\n\ninterface FrontendTranslationPlacementInfo {\n serviceKey: string;\n artifactPlacements: CompanionArtifactPlacementDescriptor[];\n}\n\ninterface BackendEmailPlacementInfo {\n serviceKey: string;\n emailTemplateOwnership: CompanionEmailTemplateOwnershipDescriptor[];\n}\n\nexport interface TranslationPlacementSnapshot {\n declaredModuleIds: string[];\n shared: SharedTranslationPlacementInfo | null;\n frontend: FrontendTranslationPlacementInfo[];\n backendEmail: BackendEmailPlacementInfo[];\n warnings: string[];\n}\n\nexport interface TranslationPlacementSnapshotOptions {\n includeShared?: boolean;\n includeFrontend?: boolean;\n includeBackendEmail?: boolean;\n}\n\n@injectable()\nexport class TranslationPlacementCompanionService {\n private readonly logDebug: (message: string, context?: Record<string, unknown>) => void;\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(COMPANION_SERVICE_TYPES.CompanionContext) private readonly companionContext: CompanionContext,\n @inject(COMPANION_SERVICE_TYPES.IntrospectionService)\n private readonly companionIntrospectionService: CompanionIntrospectionService,\n ) {\n this.logDebug = this.logger.debugByType('TranslationPlacementCompanionService');\n this.logger.setDebugTypeLogging('TranslationPlacementCompanionService', true);\n }\n\n public async getPlacementSnapshot(\n options: TranslationPlacementSnapshotOptions = {},\n ): Promise<TranslationPlacementSnapshot> {\n const warnings: string[] = [];\n const includeShared = options.includeShared ?? true;\n const includeFrontend = options.includeFrontend ?? true;\n const includeBackendEmail = options.includeBackendEmail ?? true;\n const serviceEntries = Object.entries(this.companionContext.servicesByKey);\n const backendServiceKeys = serviceEntries\n .filter(([, service]) => !service.frontendType)\n .map(([serviceKey]) => serviceKey);\n const frontendServiceKeys = serviceEntries\n .filter(([, service]) => service.frontendType === AppFrontendType.SAAS_APP)\n .map(([serviceKey]) => serviceKey);\n\n const sharedCarrierServiceKey = includeShared\n ? this.pickSharedCarrierServiceKey(\n backendServiceKeys,\n frontendServiceKeys,\n )\n : null;\n const shared = sharedCarrierServiceKey\n ? await this.loadSharedPlacement(sharedCarrierServiceKey, warnings)\n : null;\n\n const frontend = includeFrontend\n ? (\n await Promise.all(\n frontendServiceKeys.map((serviceKey) => this.loadFrontendPlacement(serviceKey, warnings)),\n )\n ).filter((entry): entry is FrontendTranslationPlacementInfo => entry !== null)\n : [];\n\n const backendEmail = includeBackendEmail\n ? (\n await Promise.all(\n backendServiceKeys.map((serviceKey) => this.loadBackendEmailPlacement(serviceKey, warnings)),\n )\n ).filter((entry): entry is BackendEmailPlacementInfo => entry !== null)\n : [];\n\n return {\n declaredModuleIds: this.companionContext.moduleIds,\n shared,\n frontend,\n backendEmail,\n warnings,\n };\n }\n\n private pickSharedCarrierServiceKey(\n backendServiceKeys: string[],\n frontendServiceKeys: string[],\n ): string | null {\n const candidates = [...backendServiceKeys, ...frontendServiceKeys];\n if (candidates.length === 0) {\n return null;\n }\n\n return [...candidates].sort((left, right) => {\n const leftCount = this.companionContext.moduleIdsByService[left]?.length ?? 0;\n const rightCount = this.companionContext.moduleIdsByService[right]?.length ?? 0;\n return rightCount - leftCount;\n })[0] ?? null;\n }\n\n private async loadSharedPlacement(\n serviceKey: string,\n warnings: string[],\n ): Promise<SharedTranslationPlacementInfo | null> {\n const data = await this.requestBehaviorData<{\n moduleIds?: string[];\n contributionModuleIds?: string[];\n artifactPlacements?: CompanionArtifactPlacementDescriptor[];\n resourceOwnership?: CompanionResourceOwnershipDescriptor[];\n }>(serviceKey, 'translation-needed-info', warnings);\n\n if (!data) {\n return null;\n }\n\n return {\n carrierServiceKey: serviceKey,\n moduleIds: data.moduleIds ?? [],\n contributionModuleIds: data.contributionModuleIds ?? [],\n artifactPlacements: data.artifactPlacements ?? [],\n resourceOwnership: data.resourceOwnership ?? [],\n };\n }\n\n private async loadFrontendPlacement(\n serviceKey: string,\n warnings: string[],\n ): Promise<FrontendTranslationPlacementInfo | null> {\n const data = await this.requestBehaviorData<{\n artifactPlacements?: CompanionArtifactPlacementDescriptor[];\n }>(serviceKey, 'frontend-artifact-placement-info', warnings);\n\n if (!data) {\n return null;\n }\n\n return {\n serviceKey,\n artifactPlacements: data.artifactPlacements ?? [],\n };\n }\n\n private async loadBackendEmailPlacement(\n serviceKey: string,\n warnings: string[],\n ): Promise<BackendEmailPlacementInfo | null> {\n const data = await this.requestBehaviorData<{\n emailTemplateOwnership?: CompanionEmailTemplateOwnershipDescriptor[];\n }>(serviceKey, 'email-template-placement-info', warnings);\n\n if (!data) {\n return null;\n }\n\n return {\n serviceKey,\n emailTemplateOwnership: data.emailTemplateOwnership ?? [],\n };\n }\n\n private async requestBehaviorData<T>(\n serviceKey: string,\n behavior: CompanionIntrospectionBehaviorId,\n warnings: string[],\n ): Promise<T | null> {\n try {\n const result = await this.companionIntrospectionService.requestInfo({\n serviceKey,\n behavior,\n });\n\n if (!result.success && 'error' in result) {\n warnings.push(\n `${serviceKey}:${behavior} failed: ${result.error.message}`,\n );\n return null;\n }\n\n return (result.data ?? null) as T | null;\n } catch (error) {\n const message = describeCaughtError(error);\n warnings.push(`${serviceKey}:${behavior} failed: ${message}`);\n this.logDebug('Placement behavior request failed', { serviceKey, behavior, message });\n return null;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"translation-placement.companion.service.js","sourceRoot":"","sources":["../../../../../src/core/introspection/services/translation-placement.companion.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAG,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAMrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAE5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAsCrF,IAAM,oCAAoC,GAA1C,MAAM,oCAAoC;IAIO;IACe;IAElD;IANF,QAAQ,CAA+D;IAExF,YACsD,MAAqB,EACN,gBAAkC,EAEpF,6BAA4D;QAHzB,WAAM,GAAN,MAAM,CAAe;QACN,qBAAgB,GAAhB,gBAAgB,CAAkB;QAEpF,kCAA6B,GAA7B,6BAA6B,CAA+B;QAE7E,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,sCAAsC,CAAC,CAAC;QAChF,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,sCAAsC,EAAE,IAAI,CAAC,CAAC;IAChF,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAC/B,UAA+C,EAAE;QAEjD,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC;QACpD,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC;QACxD,MAAM,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,IAAI,IAAI,CAAC;QAChE,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAC3E,MAAM,k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,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;YAC3C,QAAQ,CAAC,IAAI,CAAC,GAAG,UAAU,IAAI,QAAQ,YAAY,OAAO,EAAE,CAAC,CAAC;YAC9D,IAAI,CAAC,QAAQ,CAAC,mCAAmC,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;YACtF,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAA;AArKY,oCAAoC;IADhD,UAAU,EAAE;IAKR,WAAA,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;IACjC,WAAA,MAAM,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAA;IAChD,WAAA,MAAM,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,CAAA;uDACL,6BAA6B;GAPpE,oCAAoC,CAqKhD","sourcesContent":["import { inject, injectable } from 'inversify';\nimport { AppFrontendType } from '@wildo-ai/platform-config-lib';\nimport type { LoggerService } from '@wildo-ai/saas-backend-lib';\nimport { SAAS_SERVICE_TYPES , describeCaughtError} from '@wildo-ai/saas-backend-lib';\nimport type {\n CompanionArtifactPlacementDescriptor,\n CompanionResourceOwnershipDescriptor,\n} from '@wildo-ai/saas-models/companion';\nimport { CompanionArtifactClass } from '@wildo-ai/saas-models/companion';\nimport { COMPANION_SERVICE_TYPES } from '../../inject/models/service-types';\nimport type { CompanionContext } from '../../context/companion-context';\nimport { CompanionIntrospectionService } from './companion-introspection.companion.service';\nimport type { CompanionIntrospectionBehaviorId } from '../models/companion-introspection.models';\n// The owner as the placement introspection reports it, a business module's email layout included (#3904).\nimport type { EmailTemplateOwnershipPlacement } from '../../../email/utils/email-template-fs-discovery.utils';\n\ninterface SharedTranslationPlacementInfo {\n carrierServiceKey: string;\n moduleIds: string[];\n contributionModuleIds: string[];\n artifactPlacements: CompanionArtifactPlacementDescriptor[];\n resourceOwnership: CompanionResourceOwnershipDescriptor[];\n}\n\ninterface FrontendTranslationPlacementInfo {\n serviceKey: string;\n artifactPlacements: CompanionArtifactPlacementDescriptor[];\n}\n\ninterface BackendEmailPlacementInfo {\n serviceKey: string;\n emailTemplateOwnership: EmailTemplateOwnershipPlacement[];\n}\n\nexport interface TranslationPlacementSnapshot {\n declaredModuleIds: string[];\n shared: SharedTranslationPlacementInfo | null;\n frontend: FrontendTranslationPlacementInfo[];\n backendEmail: BackendEmailPlacementInfo[];\n warnings: string[];\n}\n\nexport interface TranslationPlacementSnapshotOptions {\n includeShared?: boolean;\n includeFrontend?: boolean;\n includeBackendEmail?: boolean;\n}\n\n@injectable()\nexport class TranslationPlacementCompanionService {\n private readonly logDebug: (message: string, context?: Record<string, unknown>) => void;\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(COMPANION_SERVICE_TYPES.CompanionContext) private readonly companionContext: CompanionContext,\n @inject(COMPANION_SERVICE_TYPES.IntrospectionService)\n private readonly companionIntrospectionService: CompanionIntrospectionService,\n ) {\n this.logDebug = this.logger.debugByType('TranslationPlacementCompanionService');\n this.logger.setDebugTypeLogging('TranslationPlacementCompanionService', true);\n }\n\n public async getPlacementSnapshot(\n options: TranslationPlacementSnapshotOptions = {},\n ): Promise<TranslationPlacementSnapshot> {\n const warnings: string[] = [];\n const includeShared = options.includeShared ?? true;\n const includeFrontend = options.includeFrontend ?? true;\n const includeBackendEmail = options.includeBackendEmail ?? true;\n const serviceEntries = Object.entries(this.companionContext.servicesByKey);\n const backendServiceKeys = serviceEntries\n .filter(([, service]) => !service.frontendType)\n .map(([serviceKey]) => serviceKey);\n const frontendServiceKeys = serviceEntries\n .filter(([, service]) => service.frontendType === AppFrontendType.SAAS_APP)\n .map(([serviceKey]) => serviceKey);\n\n const sharedCarrierServiceKey = includeShared\n ? this.pickSharedCarrierServiceKey(\n backendServiceKeys,\n frontendServiceKeys,\n )\n : null;\n const shared = sharedCarrierServiceKey\n ? await this.loadSharedPlacement(sharedCarrierServiceKey, warnings)\n : null;\n\n const frontend = includeFrontend\n ? (\n await Promise.all(\n frontendServiceKeys.map((serviceKey) => this.loadFrontendPlacement(serviceKey, warnings)),\n )\n ).filter((entry): entry is FrontendTranslationPlacementInfo => entry !== null)\n : [];\n\n const backendEmail = includeBackendEmail\n ? (\n await Promise.all(\n backendServiceKeys.map((serviceKey) => this.loadBackendEmailPlacement(serviceKey, warnings)),\n )\n ).filter((entry): entry is BackendEmailPlacementInfo => entry !== null)\n : [];\n\n return {\n declaredModuleIds: this.companionContext.moduleIds,\n shared,\n frontend,\n backendEmail,\n warnings,\n };\n }\n\n private pickSharedCarrierServiceKey(\n backendServiceKeys: string[],\n frontendServiceKeys: string[],\n ): string | null {\n const candidates = [...backendServiceKeys, ...frontendServiceKeys];\n if (candidates.length === 0) {\n return null;\n }\n\n return [...candidates].sort((left, right) => {\n const leftCount = this.companionContext.moduleIdsByService[left]?.length ?? 0;\n const rightCount = this.companionContext.moduleIdsByService[right]?.length ?? 0;\n return rightCount - leftCount;\n })[0] ?? null;\n }\n\n private async loadSharedPlacement(\n serviceKey: string,\n warnings: string[],\n ): Promise<SharedTranslationPlacementInfo | null> {\n const data = await this.requestBehaviorData<{\n moduleIds?: string[];\n contributionModuleIds?: string[];\n artifactPlacements?: CompanionArtifactPlacementDescriptor[];\n resourceOwnership?: CompanionResourceOwnershipDescriptor[];\n }>(serviceKey, 'translation-needed-info', warnings);\n\n if (!data) {\n return null;\n }\n\n return {\n carrierServiceKey: serviceKey,\n moduleIds: data.moduleIds ?? [],\n contributionModuleIds: data.contributionModuleIds ?? [],\n artifactPlacements: data.artifactPlacements ?? [],\n resourceOwnership: data.resourceOwnership ?? [],\n };\n }\n\n private async loadFrontendPlacement(\n serviceKey: string,\n warnings: string[],\n ): Promise<FrontendTranslationPlacementInfo | null> {\n const data = await this.requestBehaviorData<{\n artifactPlacements?: CompanionArtifactPlacementDescriptor[];\n }>(serviceKey, 'frontend-artifact-placement-info', warnings);\n\n if (!data) {\n return null;\n }\n\n return {\n serviceKey,\n artifactPlacements: data.artifactPlacements ?? [],\n };\n }\n\n private async loadBackendEmailPlacement(\n serviceKey: string,\n warnings: string[],\n ): Promise<BackendEmailPlacementInfo | null> {\n const data = await this.requestBehaviorData<{\n emailTemplateOwnership?: EmailTemplateOwnershipPlacement[];\n }>(serviceKey, 'email-template-placement-info', warnings);\n\n if (!data) {\n return null;\n }\n\n return {\n serviceKey,\n emailTemplateOwnership: data.emailTemplateOwnership ?? [],\n };\n }\n\n private async requestBehaviorData<T>(\n serviceKey: string,\n behavior: CompanionIntrospectionBehaviorId,\n warnings: string[],\n ): Promise<T | null> {\n try {\n const result = await this.companionIntrospectionService.requestInfo({\n serviceKey,\n behavior,\n });\n\n if (!result.success && 'error' in result) {\n warnings.push(\n `${serviceKey}:${behavior} failed: ${result.error.message}`,\n );\n return null;\n }\n\n return (result.data ?? null) as T | null;\n } catch (error) {\n const message = describeCaughtError(error);\n warnings.push(`${serviceKey}:${behavior} failed: ${message}`);\n this.logDebug('Placement behavior request failed', { serviceKey, behavior, message });\n return null;\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"companion-introspection-behavior-handlers.d.ts","sourceRoot":"","sources":["../../../../../src/core/introspection/subprocess/companion-introspection-behavior-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAYjG,OAAO,EAGL,gBAAgB,EAMjB,MAAM,uBAAuB,CAAC;AA+E/B,OAAO,EAEL,KAAK,gCAAgC,EACrC,KAAK,kCAAkC,EACvC,KAAK,gDAAgD,EACtD,MAAM,0CAA0C,CAAC;AAGlD,MAAM,WAAW,4CAA4C;IAC3D,OAAO,EAAE,kCAAkC,CAAC;IAC5C,QAAQ,EAAE,gDAAgD,CAAC;IAC3D,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,MAAM,MAAM,qCAAqC,GAAG,CAClD,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,4CAA4C,KAClD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAmDhC,wBAAgB,6BAA6B,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAMzE;AAED,eAAO,MAAM,iDAAiD,EAAE,OAAO,CACrE,MAAM,CAAC,gCAAgC,EAAE,qCAAqC,CAAC,CAozChF,CAAC;AAwWF;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG;IAC3D,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,CAAC;IAChD,yBAAyB,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACzD,CAqCA"}
1
+ {"version":3,"file":"companion-introspection-behavior-handlers.d.ts","sourceRoot":"","sources":["../../../../../src/core/introspection/subprocess/companion-introspection-behavior-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAcjG,OAAO,EAGL,gBAAgB,EAMjB,MAAM,uBAAuB,CAAC;AA+E/B,OAAO,EAEL,KAAK,gCAAgC,EACrC,KAAK,kCAAkC,EACvC,KAAK,gDAAgD,EACtD,MAAM,0CAA0C,CAAC;AAGlD,MAAM,WAAW,4CAA4C;IAC3D,OAAO,EAAE,kCAAkC,CAAC;IAC5C,QAAQ,EAAE,gDAAgD,CAAC;IAC3D,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,MAAM,MAAM,qCAAqC,GAAG,CAClD,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,4CAA4C,KAClD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAmDhC,wBAAgB,6BAA6B,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAMzE;AAED,eAAO,MAAM,iDAAiD,EAAE,OAAO,CACrE,MAAM,CAAC,gCAAgC,EAAE,qCAAqC,CAAC,CA6zChF,CAAC;AAwWF;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG;IAC3D,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,CAAC;IAChD,yBAAyB,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACzD,CAqCA"}
@@ -2,6 +2,7 @@ import { resolveCompanionContext } from '../../context/companion-context.js';
2
2
  import { answerSpecificationsCompanionData, loadCompleteResourceSpecifications, loadSpecificationsCompanionEvaluation, projectBackendCompanionData, } from '../../context/companion-package-loaders.companion.js';
3
3
  import { projectLabellingResourceSpecifications } from '../../../i18n-labelling/utils/labelling-resource-specification-facts.utils.js';
4
4
  import { basename, relative } from 'node:path';
5
+ import { moduleEmailTemplatePlacement } from '../../../email/utils/module-email-root.companion.utils.js';
5
6
  import { pathToFileURL } from 'node:url';
6
7
  import { generateDesignTokensCssFromSourceConfig } from '@wildo-ai/presets-components-models';
7
8
  import { buildSharedSaaSModulesRegistry, coreResourceShared_FieldIdentifierPriority, CoreResourceType, projectAgentAiUseDeclarations, Resources_SharedUtils, resourceInheritanceVariantSchemas, } from '@wildo-ai/saas-models';
@@ -683,20 +684,29 @@ export const COMPANION_INTROSPECTION_BUILTIN_BEHAVIOR_HANDLERS = {
683
684
  emailTemplateOwnership: backendModules
684
685
  .filter((ownedModule) => Object.keys(ownedModule.emailTemplateDefinitions ?? {}).length > 0
685
686
  || Object.keys(ownedModule.emailComponentLabels ?? {}).length > 0)
686
- .map((ownedModule) => ({
687
- ownerId: ownedModule.moduleId,
688
- artifactClass: ownedModule.kind === 'engine'
689
- ? CompanionArtifactClass.ENGINE
690
- : CompanionArtifactClass.DOMAIN_MODULE,
691
- rootsByRole: {
692
- backend: ownedModule.kind === 'engine'
693
- ? 'backend-api/src/engine/email'
694
- : `backend-api/src/modules/${ownedModule.moduleId}/emails`,
695
- },
696
- templateRefs: Object.keys(ownedModule.emailTemplateDefinitions ?? {}),
697
- // The shared components' words (#2884), planned by the translate lane as one unit per owner.
698
- declaresComponentLabels: Object.keys(ownedModule.emailComponentLabels ?? {}).length > 0,
699
- })),
687
+ .map((ownedModule) => {
688
+ /*
689
+ * A business module's root is where ITS definitions file scans (#3904), `emails/` when nothing scans yet, and
690
+ * its layout says which folder registers which refs, or why that cannot be read: the generation step writes
691
+ * nothing for an undetermined module rather than writing where nothing registers (review F2, F5).
692
+ */
693
+ const modulePlacement = ownedModule.kind === 'engine'
694
+ ? undefined
695
+ : moduleEmailTemplatePlacement({ applicationRoot: context.request.homes.appDeclarationRoot, backendPackageRoot: context.request.packageRoot, moduleId: ownedModule.moduleId });
696
+ return {
697
+ ownerId: ownedModule.moduleId,
698
+ artifactClass: ownedModule.kind === 'engine'
699
+ ? CompanionArtifactClass.ENGINE
700
+ : CompanionArtifactClass.DOMAIN_MODULE,
701
+ rootsByRole: {
702
+ backend: modulePlacement === undefined ? 'backend-api/src/engine/email' : modulePlacement.backend,
703
+ },
704
+ ...(modulePlacement === undefined ? {} : { backendEmailLayout: modulePlacement.layout }),
705
+ templateRefs: Object.keys(ownedModule.emailTemplateDefinitions ?? {}),
706
+ // The shared components' words (#2884), planned by the translate lane as one unit per owner.
707
+ declaresComponentLabels: Object.keys(ownedModule.emailComponentLabels ?? {}).length > 0,
708
+ };
709
+ }),
700
710
  };
701
711
  },
702
712
  'translation-needed-info': async (_input, context) => {