@roomi-fields/grillhouse 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +739 -0
  3. package/bin/grillhouse.mjs +79 -18
  4. package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
  5. package/cadre/templates/projet/CLAUDE.md +5 -1
  6. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  7. package/cadre/templates/projet/package.json +2 -2
  8. package/charte.md +24 -0
  9. package/dist/temporal/acte.d.ts +24 -0
  10. package/dist/temporal/acte.js +139 -0
  11. package/dist/temporal/acte.js.map +1 -0
  12. package/dist/temporal/attributs.d.ts +6 -0
  13. package/dist/temporal/attributs.js +15 -0
  14. package/dist/temporal/attributs.js.map +1 -0
  15. package/dist/temporal/circuit/activites.d.ts +13 -0
  16. package/dist/temporal/circuit/activites.js +33 -0
  17. package/dist/temporal/circuit/activites.js.map +1 -0
  18. package/dist/temporal/circuit/client.d.ts +72 -0
  19. package/dist/temporal/circuit/client.js +247 -0
  20. package/dist/temporal/circuit/client.js.map +1 -0
  21. package/dist/temporal/circuit/commande.d.ts +2 -0
  22. package/dist/temporal/circuit/commande.js +238 -0
  23. package/dist/temporal/circuit/commande.js.map +1 -0
  24. package/dist/temporal/circuit/contrat.d.ts +305 -0
  25. package/dist/temporal/circuit/contrat.js +24 -0
  26. package/dist/temporal/circuit/contrat.js.map +1 -0
  27. package/dist/temporal/circuit/deroule.d.ts +3 -0
  28. package/dist/temporal/circuit/deroule.js +540 -0
  29. package/dist/temporal/circuit/deroule.js.map +1 -0
  30. package/dist/temporal/client.d.ts +47 -0
  31. package/dist/temporal/client.js +69 -0
  32. package/dist/temporal/client.js.map +1 -0
  33. package/dist/temporal/commande.d.ts +2 -0
  34. package/dist/temporal/commande.js +95 -0
  35. package/dist/temporal/commande.js.map +1 -0
  36. package/dist/temporal/deroules.d.ts +5 -0
  37. package/dist/temporal/deroules.js +10 -0
  38. package/dist/temporal/deroules.js.map +1 -0
  39. package/dist/temporal/etat.d.ts +33 -0
  40. package/dist/temporal/etat.js +59 -0
  41. package/dist/temporal/etat.js.map +1 -0
  42. package/dist/temporal/file/activites.d.ts +10 -0
  43. package/dist/temporal/file/activites.js +25 -0
  44. package/dist/temporal/file/activites.js.map +1 -0
  45. package/dist/temporal/file/client.d.ts +4 -0
  46. package/dist/temporal/file/client.js +6 -0
  47. package/dist/temporal/file/client.js.map +1 -0
  48. package/dist/temporal/file/contrat.d.ts +158 -0
  49. package/dist/temporal/file/contrat.js +14 -0
  50. package/dist/temporal/file/contrat.js.map +1 -0
  51. package/dist/temporal/file/deroule.d.ts +15 -0
  52. package/dist/temporal/file/deroule.js +235 -0
  53. package/dist/temporal/file/deroule.js.map +1 -0
  54. package/dist/temporal/installation.d.ts +124 -0
  55. package/dist/temporal/installation.js +408 -0
  56. package/dist/temporal/installation.js.map +1 -0
  57. package/dist/temporal/places/activites.d.ts +8 -0
  58. package/dist/temporal/places/activites.js +13 -0
  59. package/dist/temporal/places/activites.js.map +1 -0
  60. package/dist/temporal/places/client.d.ts +28 -0
  61. package/dist/temporal/places/client.js +64 -0
  62. package/dist/temporal/places/client.js.map +1 -0
  63. package/dist/temporal/places/contrat.d.ts +106 -0
  64. package/dist/temporal/places/contrat.js +21 -0
  65. package/dist/temporal/places/contrat.js.map +1 -0
  66. package/dist/temporal/places/deroule.d.ts +3 -0
  67. package/dist/temporal/places/deroule.js +198 -0
  68. package/dist/temporal/places/deroule.js.map +1 -0
  69. package/dist/temporal/sonde/activites.d.ts +6 -0
  70. package/dist/temporal/sonde/activites.js +52 -0
  71. package/dist/temporal/sonde/activites.js.map +1 -0
  72. package/dist/temporal/sonde/contrat.d.ts +35 -0
  73. package/dist/temporal/sonde/contrat.js +10 -0
  74. package/dist/temporal/sonde/contrat.js.map +1 -0
  75. package/dist/temporal/sonde/deroule.d.ts +3 -0
  76. package/dist/temporal/sonde/deroule.js +39 -0
  77. package/dist/temporal/sonde/deroule.js.map +1 -0
  78. package/dist/temporal/tickets/activites.d.ts +7 -0
  79. package/dist/temporal/tickets/activites.js +81 -0
  80. package/dist/temporal/tickets/activites.js.map +1 -0
  81. package/dist/temporal/tickets/client.d.ts +10 -0
  82. package/dist/temporal/tickets/client.js +31 -0
  83. package/dist/temporal/tickets/client.js.map +1 -0
  84. package/dist/temporal/tickets/contrat.d.ts +56 -0
  85. package/dist/temporal/tickets/contrat.js +13 -0
  86. package/dist/temporal/tickets/contrat.js.map +1 -0
  87. package/dist/temporal/tickets/deroule.d.ts +3 -0
  88. package/dist/temporal/tickets/deroule.js +94 -0
  89. package/dist/temporal/tickets/deroule.js.map +1 -0
  90. package/dist/temporal/travailleur.d.ts +2 -0
  91. package/dist/temporal/travailleur.js +69 -0
  92. package/dist/temporal/travailleur.js.map +1 -0
  93. package/docs/ARCHITECTURE.md +609 -80
  94. package/docs/CADRE.md +17 -0
  95. package/docs/INTERFACE.md +134 -42
  96. package/hooks/crochet.mjs +19 -2
  97. package/hooks/hooks.json +11 -0
  98. package/package.json +16 -4
  99. package/scripts/activites.mjs +2182 -0
  100. package/scripts/aiguillage.d.mts +37 -0
  101. package/scripts/aiguillage.mjs +7 -3
  102. package/scripts/avancement.mjs +128 -16
  103. package/scripts/bilan.mjs +37 -19
  104. package/scripts/cadre.mjs +11 -2
  105. package/scripts/circuit.mjs +881 -4059
  106. package/scripts/circuits-cles.d.mts +4 -0
  107. package/scripts/circuits-cles.mjs +21 -0
  108. package/scripts/circuits-du-serveur.mjs +105 -0
  109. package/scripts/codes-de-sortie.mjs +9 -0
  110. package/scripts/commandes-composees.mjs +45 -41
  111. package/scripts/commandes-du-path.d.mts +7 -0
  112. package/scripts/commandes-du-path.mjs +25 -0
  113. package/scripts/composition-des-langages.mjs +16 -12
  114. package/scripts/conformite.mjs +6 -13
  115. package/scripts/copies-finies.mjs +52 -47
  116. package/scripts/depart-du-ticket.d.mts +53 -0
  117. package/scripts/depart-du-ticket.mjs +124 -0
  118. package/scripts/dependances-internes.mjs +115 -0
  119. package/scripts/dernier-vert.mjs +7 -15
  120. package/scripts/donnees-cles.mjs +228 -0
  121. package/scripts/droits.mjs +11 -1
  122. package/scripts/effets.mjs +352 -0
  123. package/scripts/enveloppe/enveloppe.mjs +119 -8
  124. package/scripts/enveloppe/lancer.sh +14 -18
  125. package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
  126. package/scripts/enveloppe/travail-de-la-copie.mjs +5 -1
  127. package/scripts/etapes.mjs +5 -2
  128. package/scripts/faits-du-circuit.mjs +493 -0
  129. package/scripts/file-des-tickets.d.mts +21 -0
  130. package/scripts/file-des-tickets.mjs +58 -0
  131. package/scripts/flux-des-paquets.mjs +187 -0
  132. package/scripts/gardes-du-cadre.mjs +12 -2
  133. package/scripts/integration/file.mjs +475 -420
  134. package/scripts/integration/integrer.mjs +17 -19
  135. package/scripts/integration/rejeu.mjs +19 -4
  136. package/scripts/jointure.d.ts +145 -27
  137. package/scripts/langages/cargo/commandes.mjs +289 -109
  138. package/scripts/langages/cargo/composants.mjs +130 -34
  139. package/scripts/langages/cargo/exemples.mjs +12 -21
  140. package/scripts/langages/cargo/index.mjs +18 -8
  141. package/scripts/langages/cargo/sccache.mjs +8 -14
  142. package/scripts/langages/python/commandes.mjs +216 -100
  143. package/scripts/langages/python/composants.mjs +53 -21
  144. package/scripts/langages/python/exemples.mjs +6 -16
  145. package/scripts/langages/python/index.mjs +24 -8
  146. package/scripts/langages/python/lot.mjs +1 -36
  147. package/scripts/langages/typescript/construire.mjs +6 -163
  148. package/scripts/langages/typescript/exemples.mjs +3 -11
  149. package/scripts/langages/typescript/frontieres.mjs +1 -1
  150. package/scripts/langages/typescript/index.mjs +43 -61
  151. package/scripts/langages/typescript/interfaces-contre-code.mjs +4 -4
  152. package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
  153. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +31 -0
  154. package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
  155. package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
  156. package/scripts/langages/typescript/tailles-des-tests.mjs +40 -9
  157. package/scripts/langages/typescript/tests-de-nuit.mjs +12 -9
  158. package/scripts/langages/typescript/tests.mjs +17 -8
  159. package/scripts/langages/typescript/titres-de-tests.mjs +297 -0
  160. package/scripts/langages/typescript/turbo-des-paquets.mjs +183 -38
  161. package/scripts/langages/typescript/verdict.mjs +1 -1
  162. package/scripts/langages/typescript/verifier.mjs +31 -11
  163. package/scripts/langages/typescript/vitest-config/base.mjs +22 -1
  164. package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
  165. package/scripts/langages/typescript/vitest-config/cibles.mjs +36 -14
  166. package/scripts/langages/typescript/vitest-config/delais.mjs +54 -0
  167. package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
  168. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +100 -0
  169. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +49 -63
  170. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +3 -0
  171. package/scripts/langages/typescript/vitest.nuit.config.mjs +4 -0
  172. package/scripts/mesure/pression.mjs +3 -3
  173. package/scripts/mesure-de-la-machine.d.mts +21 -0
  174. package/scripts/mesure-de-la-machine.mjs +76 -0
  175. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +8 -2
  176. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +120 -0
  177. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
  178. package/scripts/migrations.mjs +5 -0
  179. package/scripts/nuit.sh +10 -3
  180. package/scripts/outils-cles.d.mts +24 -0
  181. package/scripts/outils-cles.mjs +0 -1
  182. package/scripts/paquet-npm.mjs +147 -0
  183. package/scripts/paquet.mjs +73 -4
  184. package/scripts/paquets.mjs +34 -6
  185. package/scripts/passe-de-la-machine.mjs +66 -0
  186. package/scripts/places-de-la-machine.mjs +360 -0
  187. package/scripts/places-du-serveur.mjs +170 -0
  188. package/scripts/prefixe-des-tickets.mjs +68 -0
  189. package/scripts/preparation.mjs +10 -3
  190. package/scripts/registre.mjs +3 -2
  191. package/scripts/regles-des-places.d.mts +36 -0
  192. package/scripts/regles-des-places.mjs +70 -0
  193. package/scripts/reponses-du-circuit.d.mts +6 -0
  194. package/scripts/reponses-du-circuit.mjs +28 -0
  195. package/scripts/resultats.mjs +7 -9
  196. package/scripts/retirer-les-copies-finies.mjs +25 -0
  197. package/scripts/sans-reponse.d.mts +4 -0
  198. package/scripts/sans-reponse.mjs +13 -0
  199. package/scripts/seances.mjs +918 -0
  200. package/scripts/services-du-noyau.mjs +26 -8
  201. package/scripts/session-start.sh +2 -2
  202. package/scripts/sortie.mjs +3 -3
  203. package/scripts/sous-commandes.mjs +38 -9
  204. package/scripts/style-a-l-ecriture.mjs +229 -0
  205. package/scripts/superviseur.mjs +122 -111
  206. package/scripts/tableau.mjs +148 -110
  207. package/scripts/taches-du-graphe.mjs +328 -0
  208. package/scripts/ticket-du-circuit.mjs +206 -0
  209. package/scripts/transitions.d.mts +148 -0
  210. package/scripts/transitions.mjs +901 -0
  211. package/scripts/verrou-de-fichier.mjs +2 -2
  212. package/scripts/verrou-de-machine.mjs +28 -13
  213. package/skills/explorateur/SKILL.md +2 -1
  214. package/skills/pitmaster/SKILL.md +17 -18
  215. package/skills/pitmaster/references/consigne-agent.md +5 -1
  216. package/skills/release/SKILL.md +3 -3
  217. package/skills/relecteur/SKILL.md +4 -2
  218. package/skills/testwriter/SKILL.md +36 -24
  219. package/scripts/demon.mjs +0 -251
  220. package/scripts/integration/file-attente.mjs +0 -61
  221. package/scripts/langages/cargo/touches.mjs +0 -93
  222. package/scripts/langages/typescript/script-des-tests.mjs +0 -6
@@ -0,0 +1,408 @@
1
+ // The installation of the account's Temporal (`grillhouse temporal installer`): the program
2
+ // `temporal` at its pinned version, its archive checked against its pinned sum, laid down under
3
+ // ~/.cache/grillhouse/temporal/<version>/temporal; the units of the account's systemd (the server,
4
+ // the worker of the project, the worker of the machine), each started again by systemd; the
5
+ // variable TEMPORAL declared in `grillhouse.outils` of the project's package.json.
6
+ //
7
+ // - The pin (EPINGLE) is the version of the program and the SHA-256 of the archive of each
8
+ // platform, as its release publishes them (checksums.txt); an archive whose sum differs is
9
+ // refused before anything is laid down, the expected and the read sums named.
10
+ // - The server is Temporal's development server (`temporal server start-dev`), on the loopback
11
+ // only, its state in a file of the machine (~/.local/share/grillhouse/temporal/temporal.db), the
12
+ // frame's search attributes registered, its web interface on Temporal's port plus 1000. Its
13
+ // namespace `default` keeps a closed workflow 30 days (RETENTION), set at each start of the
14
+ // unit once the server answers (`temporal operator namespace update --retention`), where
15
+ // start-dev gives 24 h: a circuit stopped on a Friday reopens from its state on the Monday.
16
+ // - Each worker runs the frame's worker (dist/temporal/travailleur.js) on its task queue:
17
+ // `grillhouse-projet-<projet>` for the project's, `grillhouse-machine` for the machine's. A
18
+ // project that names its version of the frame (`grillhouse.outil`, scripts/aiguillage.mjs) runs
19
+ // the worker of that published version, installed under the cache of the home
20
+ // (~/.cache/grillhouse/outil/<version>/) when absent, as the circuit's command does; another, its
21
+ // own version (its node_modules/@roomi-fields/grillhouse), else this package.
22
+ // - Every refusal comes before any writing (the archive, an account's tool, a fault of
23
+ // `grillhouse.outils`, a published version without a worker), but the published version
24
+ // itself: it is laid down in its cache before its refusal, which reads it there.
25
+ // - A unit of systemd starts with a bare PATH: each worker's unit names the PATH of the account's
26
+ // tools a circuit runs (node, npm, claude, bd, gh), found in the installer's PATH, and the tools
27
+ // of the project (`grillhouse.outils`), each its variable; a tool of the account not found is
28
+ // refused by its name before anything is written.
29
+ // - Played again on an installation up to date, it changes nothing: the program of the pinned
30
+ // version is not downloaded again, a unit and the package.json are written only when they
31
+ // differ, and systemd is told only of what it has not applied yet (daemon-reload, enable,
32
+ // restart of those units). What systemd applied is kept apart from what is written: the sum of
33
+ // each unit's text once systemctl succeeded (~/.local/state/grillhouse/temporal/
34
+ // unites-appliquees.json), so that a systemctl that failed is played again at the next run.
35
+ // - `poserLeProgramme` lays down the program alone, no unit, no package.json, no systemd: the mode
36
+ // `--programme-seul` of the command, by which the CI gets the pinned program as a user does.
37
+ // - The home, the directory of the units and the project are parameters (`lieuxDe`), as systemctl,
38
+ // the download, the published version and the account's tools are: a test installs under a
39
+ // trial home, never in the account's systemd.
40
+ import { spawnSync } from 'node:child_process';
41
+ import { createHash } from 'node:crypto';
42
+ import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync, } from 'node:fs';
43
+ import os from 'node:os';
44
+ import path from 'node:path';
45
+ import { fileURLToPath } from 'node:url';
46
+ import { cacheDesOutils, installer as installerLOutil, versionDeLOutil, } from '../../scripts/aiguillage.mjs';
47
+ import { trouverDansLePath } from '../../scripts/commandes-du-path.mjs';
48
+ import { lireOutils } from '../../scripts/outils-cles.mjs';
49
+ import { ATTRIBUTS_DE_RECHERCHE } from './attributs.js';
50
+ /** The pin: temporal 1.9.1 (Server 1.32.0), its sums from the release's checksums.txt. */
51
+ export const EPINGLE = {
52
+ version: '1.9.1',
53
+ sommes: {
54
+ linux_amd64: '09a0326a51db84d02735e53542b9ebd8c4758daf47482a9ab0abce15844e60d5',
55
+ linux_arm64: '6c57c352d52fc3df34412376fd9ba6f74b7e3ace8e426e6cba8600156d36a145',
56
+ darwin_amd64: '48cdd6c84c56e27ae8e4d9a47052b89289a9c552dee029b49dd312c6fb72873f',
57
+ darwin_arm64: '41e0425378fcb4fb5766340b97435e20fe47bbff2d7bf644ec2d51f7662b7c56',
58
+ },
59
+ };
60
+ /** The port of the account's server, Temporal's, on the loopback. */
61
+ const PORT_DU_SERVEUR = 7233;
62
+ /** How long the server keeps a closed workflow: 30 days. */
63
+ const RETENTION = '720h';
64
+ /** The account's tools a circuit runs, whose folders each worker's PATH names. */
65
+ const OUTILS_DU_COMPTE = ['node', 'npm', 'claude', 'bd', 'gh'];
66
+ // The folders of the system, after the tools' own.
67
+ const PATH_DU_SYSTEME = ['/usr/local/bin', '/usr/bin', '/bin'];
68
+ /** The unit of the server. */
69
+ export const UNITE_DU_SERVEUR = 'grillhouse-temporal.service';
70
+ /** The unit of the worker of the machine. */
71
+ export const UNITE_DE_LA_MACHINE = 'grillhouse-travailleur-machine.service';
72
+ /** The task queue of the worker of the machine. */
73
+ export const FILE_DE_LA_MACHINE = 'grillhouse-machine';
74
+ /** The platform of Node's <platform> and <arch>; refused by its name when the pin has none. */
75
+ export function plateformeDe(platform = process.platform, arch = process.arch) {
76
+ const os = { linux: 'linux', darwin: 'darwin' }[platform];
77
+ const a = { x64: 'amd64', arm64: 'arm64' }[arch];
78
+ if (!os || !a) {
79
+ throw new Error(`temporal : aucune archive épinglée pour ${platform} ${arch}`);
80
+ }
81
+ return `${os}_${a}`;
82
+ }
83
+ /** The URL of the archive of <version> for <plateforme>, in the project's releases. */
84
+ export const urlDeLArchive = (version, plateforme) => `https://github.com/temporalio/cli/releases/download/v${version}/temporal_cli_${version}_${plateforme}.tar.gz`;
85
+ /** The places, each from the environment when absent: $HOME, its systemd/user, the cwd. */
86
+ export function lieuxDe({ maison, unites, racine } = {}, env = process.env) {
87
+ const m = path.resolve(maison ?? env.HOME ?? os.homedir());
88
+ return {
89
+ maison: m,
90
+ unites: path.resolve(unites ?? path.join(m, '.config/systemd/user')),
91
+ racine: path.resolve(racine ?? process.cwd()),
92
+ };
93
+ }
94
+ /** The program of <version> and the server's database file, under the home of <lieux>. */
95
+ export function cheminsDe(lieux, version) {
96
+ return {
97
+ programme: path.join(lieux.maison, '.cache/grillhouse/temporal', version, 'temporal'),
98
+ donnees: path.join(lieux.maison, '.local/share/grillhouse/temporal/temporal.db'),
99
+ appliquees: path.join(lieux.maison, '.local/state/grillhouse/temporal/unites-appliquees.json'),
100
+ };
101
+ }
102
+ // The name of the project at <racine>, for a unit and a task queue: its package's name, else its
103
+ // directory's, in lower case letters, digits and dashes.
104
+ function nomDuProjet(racine) {
105
+ let nom = path.basename(racine);
106
+ try {
107
+ const n = JSON.parse(readFileSync(path.join(racine, 'package.json'), 'utf8')).name;
108
+ if (typeof n === 'string' && n) {
109
+ nom = n;
110
+ }
111
+ }
112
+ catch {
113
+ // no package.json: the directory's name
114
+ }
115
+ return nom
116
+ .toLowerCase()
117
+ .replace(/[^a-z0-9]+/g, '-')
118
+ .replace(/^-+|-+$/g, '');
119
+ }
120
+ /** The unit of the worker of the project at <racine>. */
121
+ export const uniteDuProjet = (racine) => `grillhouse-travailleur-${nomDuProjet(racine)}.service`;
122
+ /** The task queue of the worker of the project at <racine>. */
123
+ export const fileDuProjet = (racine) => `grillhouse-projet-${nomDuProjet(racine)}`;
124
+ /** The three units, in their order: the server, the worker of the project, the machine's. */
125
+ export const unitesDe = (racine) => [
126
+ UNITE_DU_SERVEUR,
127
+ uniteDuProjet(racine),
128
+ UNITE_DE_LA_MACHINE,
129
+ ];
130
+ // An argument of ExecStart, quoted as systemd reads it when it holds a space or a quote.
131
+ const arg = (s) => (/[\s"\\]/.test(s) ? `"${s.replace(/["\\]/g, c => `\\${c}`)}"` : s);
132
+ /** The text of each unit of the account, by its file's name. */
133
+ export function textesDesUnites(lieux, { version, node, travailleur, chemin, outils }) {
134
+ const { programme, donnees } = cheminsDe(lieux, version);
135
+ const serveur = [
136
+ programme,
137
+ 'server',
138
+ 'start-dev',
139
+ '--db-filename',
140
+ donnees,
141
+ '--ip',
142
+ '127.0.0.1',
143
+ '--port',
144
+ String(PORT_DU_SERVEUR),
145
+ '--ui-port',
146
+ String(PORT_DU_SERVEUR + 1000),
147
+ ...Object.entries(ATTRIBUTS_DE_RECHERCHE).flatMap(([k, t]) => [
148
+ '--search-attribute',
149
+ `${k}=${t}`,
150
+ ]),
151
+ ];
152
+ // The retention set once the server answers, tried every second for 60 s; `$$` is systemd's `$`.
153
+ const retenir = [
154
+ 'i=0; until',
155
+ `'${programme}' operator namespace update --namespace default --retention ${RETENTION}`,
156
+ `--address 127.0.0.1:${PORT_DU_SERVEUR} >/dev/null;`,
157
+ 'do i=$$((i+1)); [ $$i -ge 60 ] && exit 1; sleep 1; done',
158
+ ].join(' ');
159
+ const service = (description, lignes, apres = []) => [
160
+ '[Unit]',
161
+ `Description=${description}`,
162
+ ...apres,
163
+ '',
164
+ '[Service]',
165
+ ...lignes,
166
+ 'Restart=always',
167
+ 'RestartSec=5',
168
+ '',
169
+ '[Install]',
170
+ 'WantedBy=default.target',
171
+ '',
172
+ ].join('\n');
173
+ const apres = [`After=${UNITE_DU_SERVEUR}`, `Wants=${UNITE_DU_SERVEUR}`];
174
+ const travailleurSur = (file) => [
175
+ `WorkingDirectory=${arg(lieux.racine)}`,
176
+ `Environment=TEMPORAL_ADDRESS=127.0.0.1:${PORT_DU_SERVEUR}`,
177
+ `Environment=${arg(`PATH=${chemin}`)}`,
178
+ ...Object.entries(outils).map(([k, v]) => `Environment=${arg(`${k}=${v}`)}`),
179
+ `ExecStart=${[node, travailleur, '--file', file].map(arg).join(' ')}`,
180
+ ];
181
+ return {
182
+ [UNITE_DU_SERVEUR]: service(`Grillhouse : le serveur Temporal du compte (temporal ${version})`, [`ExecStart=${serveur.map(arg).join(' ')}`, `ExecStartPost=/bin/sh -c ${arg(retenir)}`]),
183
+ [uniteDuProjet(lieux.racine)]: service(`Grillhouse : le travailleur du projet ${nomDuProjet(lieux.racine)}`, travailleurSur(fileDuProjet(lieux.racine)), apres),
184
+ [UNITE_DE_LA_MACHINE]: service('Grillhouse : le travailleur de la machine', travailleurSur(FILE_DE_LA_MACHINE), apres),
185
+ };
186
+ }
187
+ /** The package that runs: two levels above this module, in src/ as in dist/. */
188
+ const PAQUET = fileURLToPath(new URL('../..', import.meta.url));
189
+ const TRAVAILLEUR = 'dist/temporal/travailleur.js';
190
+ /**
191
+ * The frame's worker of the project at <racine>: that of the published version it names, laid down
192
+ * by <outil> (its folder), refused when that version carries none; else its own version of the
193
+ * frame, else this one.
194
+ */
195
+ export function travailleurDe(racine, outil) {
196
+ const version = versionDeLOutil(racine);
197
+ if (version !== null) {
198
+ const f = path.join(outil(version), 'node_modules/@roomi-fields/grillhouse', TRAVAILLEUR);
199
+ if (!existsSync(f)) {
200
+ throw new Error(`temporal : @roomi-fields/grillhouse@${version}, la version que nomme grillhouse.outil, ne porte pas de travailleur (${TRAVAILLEUR}).`);
201
+ }
202
+ return f;
203
+ }
204
+ const local = path.join(racine, 'node_modules/@roomi-fields/grillhouse');
205
+ return path.join(existsSync(local) ? realpathSync(local) : PAQUET, TRAVAILLEUR);
206
+ }
207
+ /**
208
+ * The PATH of each worker's unit: the folder of Node <node>, then those of the account's tools
209
+ * <trouver> finds, then the system's; a tool not found refused by its name.
210
+ */
211
+ export function cheminDesUnites(node, trouver) {
212
+ const dossiers = [path.dirname(node)];
213
+ for (const nom of OUTILS_DU_COMPTE) {
214
+ const f = trouver(nom);
215
+ if (!f) {
216
+ throw new Error(`temporal : l'outil ${nom} est introuvable dans PATH ; un circuit le lance, et l'unité de son travailleur le nomme.`);
217
+ }
218
+ dossiers.push(path.dirname(f));
219
+ }
220
+ return [...new Set([...dossiers, ...PATH_DU_SYSTEME])].join(':');
221
+ }
222
+ /** The account's systemctl, by the program <programme>. */
223
+ export const systemctlDuCompte = (programme = 'systemctl') => args => {
224
+ const r = spawnSync(programme, ['--user', ...args], { encoding: 'utf8' });
225
+ return { status: r.status, stdout: r.stdout ?? '', stderr: r.stderr ?? r.error?.message ?? '' };
226
+ };
227
+ /** The refusal of an archive whose sum differs from the pinned one. */
228
+ export class SommeRefusee extends Error {
229
+ url;
230
+ attendue;
231
+ lue;
232
+ constructor(url, attendue, lue) {
233
+ super(`temporal : l'archive ${url} est refusée : somme attendue ${attendue}, lue ${lue} ; rien n'est posé.`);
234
+ this.url = url;
235
+ this.attendue = attendue;
236
+ this.lue = lue;
237
+ this.name = 'SommeRefusee';
238
+ }
239
+ }
240
+ /** Downloads <url>, its redirections followed. */
241
+ async function telecharger(url) {
242
+ const r = await fetch(url);
243
+ if (!r.ok) {
244
+ throw new Error(`temporal : ${url} répond ${r.status}`);
245
+ }
246
+ return Buffer.from(await r.arrayBuffer());
247
+ }
248
+ // Lays down the program `temporal` of the archive <contenu> as <programme>: extracted under a
249
+ // directory beside its own, then renamed into its own, so that a broken extraction lays nothing.
250
+ function poser(contenu, programme) {
251
+ const dossier = path.dirname(programme);
252
+ const parent = path.dirname(dossier);
253
+ mkdirSync(parent, { recursive: true });
254
+ const tmp = mkdtempSync(path.join(parent, `.${path.basename(dossier)}-`));
255
+ try {
256
+ const archive = path.join(tmp, 'archive.tar.gz');
257
+ writeFileSync(archive, contenu);
258
+ const r = spawnSync('tar', ['-xzf', archive, '-C', tmp, 'temporal'], { encoding: 'utf8' });
259
+ if (r.status !== 0) {
260
+ throw new Error(`temporal : tar refuse l'archive : ${r.stderr ?? r.error?.message}`);
261
+ }
262
+ rmSync(archive);
263
+ chmodSync(path.join(tmp, 'temporal'), 0o755);
264
+ rmSync(dossier, { recursive: true, force: true });
265
+ renameSync(tmp, dossier);
266
+ }
267
+ finally {
268
+ rmSync(tmp, { recursive: true, force: true });
269
+ }
270
+ }
271
+ /** The value of TEMPORAL for <programme>: under `~` when it lies under the home <maison>. */
272
+ export function valeurDeLOutil(programme, maison) {
273
+ const rel = path.relative(maison, programme);
274
+ return rel && !rel.startsWith('..') && !path.isAbsolute(rel) ? `~/${rel}` : programme;
275
+ }
276
+ // Declares TEMPORAL in `grillhouse.outils` of the package.json of <racine>; whether it wrote it.
277
+ function declarerLOutil(racine, programme, maison) {
278
+ const f = path.join(racine, 'package.json');
279
+ const pkg = JSON.parse(readFileSync(f, 'utf8'));
280
+ const valeur = valeurDeLOutil(programme, maison);
281
+ if (pkg.grillhouse?.outils?.TEMPORAL === valeur) {
282
+ return false;
283
+ }
284
+ pkg.grillhouse = { ...pkg.grillhouse, outils: { ...pkg.grillhouse?.outils, TEMPORAL: valeur } };
285
+ writeFileSync(f, `${JSON.stringify(pkg, null, 2)}\n`);
286
+ return true;
287
+ }
288
+ // systemctl <args>, refused by its output when it fails.
289
+ function systemd(systemctl, args) {
290
+ const r = systemctl(args);
291
+ if (r.status !== 0) {
292
+ throw new Error(`temporal : systemctl --user ${args.join(' ')} échoue (${r.status}) : ${r.stderr.trim()}`);
293
+ }
294
+ }
295
+ /**
296
+ * The archive of the program `temporal` of the pin, checked against its pinned sum, nothing laid
297
+ * down: its content, or null when the program lies at the places <lieux> already.
298
+ */
299
+ async function obtenirLeProgramme({ lieux, epingle = EPINGLE, plateforme = plateformeDe(), obtenir = telecharger, }) {
300
+ const { programme } = cheminsDe(lieux, epingle.version);
301
+ if (existsSync(programme)) {
302
+ return { programme, contenu: null };
303
+ }
304
+ const attendue = epingle.sommes[plateforme];
305
+ if (!attendue) {
306
+ throw new Error(`temporal : aucune somme épinglée pour ${plateforme}`);
307
+ }
308
+ const url = urlDeLArchive(epingle.version, plateforme);
309
+ const contenu = await obtenir(url);
310
+ const lue = createHash('sha256').update(contenu).digest('hex');
311
+ if (lue !== attendue) {
312
+ throw new SommeRefusee(url, attendue, lue);
313
+ }
314
+ return { programme, contenu };
315
+ }
316
+ /**
317
+ * Lays down the program `temporal` of the pin at the places <lieux>, its archive checked against
318
+ * its pinned sum, unless it lies there already; whether it laid it down.
319
+ */
320
+ export async function poserLeProgramme(options) {
321
+ const { programme, contenu } = await obtenirLeProgramme(options);
322
+ if (contenu) {
323
+ poser(contenu, programme);
324
+ }
325
+ return { programme, pose: contenu !== null };
326
+ }
327
+ const sommeDe = (texte) => createHash('sha256').update(texte).digest('hex');
328
+ // The sum of each unit's text that systemd applied, from the file <f>; none without it.
329
+ function lireLesAppliquees(f) {
330
+ try {
331
+ return JSON.parse(readFileSync(f, 'utf8'));
332
+ }
333
+ catch {
334
+ return {};
335
+ }
336
+ }
337
+ /** Installs the account's Temporal at the places <lieux> (see the header). */
338
+ export async function installer({ lieux, systemctl, epingle = EPINGLE, plateforme = plateformeDe(), obtenir = telecharger, node = process.execPath, outil = v => installerLOutil(v, { cache: cacheDesOutils(lieux.maison) }).dossier, travailleur, trouver = nom => trouverDansLePath(nom), }) {
339
+ const { donnees, appliquees: fichierDesAppliquees } = cheminsDe(lieux, epingle.version);
340
+ // Every refusal before any writing: the archive, the account's tools, the project's tools (with
341
+ // TEMPORAL as it will be declared), then the worker of the published version, which lays that
342
+ // version down in its cache first.
343
+ const { programme, contenu } = await obtenirLeProgramme({ lieux, epingle, plateforme, obtenir });
344
+ const chemin = cheminDesUnites(node, trouver);
345
+ const pkg = JSON.parse(readFileSync(path.join(lieux.racine, 'package.json'), 'utf8'));
346
+ // The tools as written; TEMPORAL joins them only when they are an object (or absent), so that a
347
+ // faulty value is refused as it is written.
348
+ const brut = pkg.grillhouse?.outils;
349
+ const temporal = { TEMPORAL: valeurDeLOutil(programme, lieux.maison) };
350
+ const { outils, fautes } = lireOutils({
351
+ ...pkg,
352
+ grillhouse: {
353
+ ...pkg.grillhouse,
354
+ outils: brut === undefined || brut === null
355
+ ? temporal
356
+ : typeof brut === 'object' && !Array.isArray(brut)
357
+ ? { ...brut, ...temporal }
358
+ : brut,
359
+ },
360
+ }, { maison: lieux.maison, existe: p => p === programme || existsSync(p) });
361
+ if (fautes.length) {
362
+ throw new Error(`temporal : ${fautes.join(' ; ')}`);
363
+ }
364
+ const leTravailleur = travailleur ?? travailleurDe(lieux.racine, outil);
365
+ const pose = contenu !== null;
366
+ if (contenu) {
367
+ poser(contenu, programme);
368
+ }
369
+ mkdirSync(path.dirname(donnees), { recursive: true });
370
+ const outilEcrit = declarerLOutil(lieux.racine, programme, lieux.maison);
371
+ const textes = textesDesUnites(lieux, {
372
+ version: epingle.version,
373
+ node,
374
+ travailleur: leTravailleur,
375
+ chemin,
376
+ outils,
377
+ });
378
+ const unites = [];
379
+ for (const [nom, texte] of Object.entries(textes)) {
380
+ const f = path.join(lieux.unites, nom);
381
+ if (existsSync(f) && readFileSync(f, 'utf8') === texte) {
382
+ continue;
383
+ }
384
+ mkdirSync(lieux.unites, { recursive: true });
385
+ writeFileSync(f, texte);
386
+ unites.push(nom);
387
+ }
388
+ const deja = lireLesAppliquees(fichierDesAppliquees);
389
+ const enAttente = Object.keys(textes).filter(n => deja[n] !== sommeDe(textes[n]));
390
+ const appliquees = pose ? unitesDe(lieux.racine) : enAttente;
391
+ if (appliquees.length) {
392
+ systemd(systemctl, ['daemon-reload']);
393
+ systemd(systemctl, ['enable', ...unitesDe(lieux.racine)]);
394
+ systemd(systemctl, ['restart', ...appliquees]);
395
+ mkdirSync(path.dirname(fichierDesAppliquees), { recursive: true });
396
+ const sommes = Object.fromEntries(Object.entries(textes).map(([n, t]) => [n, sommeDe(t)]));
397
+ writeFileSync(fichierDesAppliquees, `${JSON.stringify(sommes, null, 2)}\n`);
398
+ }
399
+ return {
400
+ programme,
401
+ pose,
402
+ unites,
403
+ appliquees,
404
+ outil: outilEcrit,
405
+ change: pose || unites.length > 0 || outilEcrit || appliquees.length > 0,
406
+ };
407
+ }
408
+ //# sourceMappingURL=installation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installation.js","sourceRoot":"","sources":["../../src/temporal/installation.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,gGAAgG;AAChG,mGAAmG;AACnG,4FAA4F;AAC5F,mFAAmF;AACnF,EAAE;AACF,2FAA2F;AAC3F,6FAA6F;AAC7F,gFAAgF;AAChF,+FAA+F;AAC/F,mGAAmG;AACnG,8FAA8F;AAC9F,8FAA8F;AAC9F,2FAA2F;AAC3F,8FAA8F;AAC9F,0FAA0F;AAC1F,8FAA8F;AAC9F,kGAAkG;AAClG,gFAAgF;AAChF,oGAAoG;AACpG,gFAAgF;AAChF,uFAAuF;AACvF,0FAA0F;AAC1F,mFAAmF;AACnF,kGAAkG;AAClG,mGAAmG;AACnG,gGAAgG;AAChG,oDAAoD;AACpD,8FAA8F;AAC9F,4FAA4F;AAC5F,4FAA4F;AAC5F,iGAAiG;AACjG,mFAAmF;AACnF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AO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3F,aAAa,CAAC,oBAAoB,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO;QACL,SAAS;QACT,IAAI;QACJ,MAAM;QACN,UAAU;QACV,KAAK,EAAE,UAAU;QACjB,MAAM,EAAE,IAAI,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;KACzE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Mesure } from './contrat.js';
2
+ /** The machine now. */
3
+ export declare function mesurerLaMachine(): Promise<Mesure>;
4
+ /** For each process, whether it lives and is the one of its start. */
5
+ export declare function processusVivants(processus: {
6
+ pid: number;
7
+ depart: string | null;
8
+ }[]): Promise<boolean[]>;
@@ -0,0 +1,13 @@
1
+ // The activities of the workflow of the machine: what the machine gives now (its cores, its load,
2
+ // its free memory) and whether the process of each place still lives, both read by
3
+ // scripts/mesure-de-la-machine.mjs.
4
+ import { mesureDeLaMachine, processusVivant } from '../../../scripts/mesure-de-la-machine.mjs';
5
+ /** The machine now. */
6
+ export async function mesurerLaMachine() {
7
+ return Promise.resolve(mesureDeLaMachine());
8
+ }
9
+ /** For each process, whether it lives and is the one of its start. */
10
+ export async function processusVivants(processus) {
11
+ return Promise.resolve(processus.map(p => processusVivant(p)));
12
+ }
13
+ //# sourceMappingURL=activites.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activites.js","sourceRoot":"","sources":["../../../src/temporal/places/activites.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,mFAAmF;AACnF,oCAAoC;AACpC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAG/F,uBAAuB;AACvB,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED,sEAAsE;AACtE,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,SAAmD;IAEnD,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { Client } from '@temporalio/client';
2
+ import { type DemandeDePlace, type EntreeDesPlaces, type PlaceDonnee, type VueDesPlaces } from './contrat.js';
3
+ /** Starts the workflow of the machine on <file>, or leaves the one that runs. */
4
+ export declare function demarrerLesPlaces(client: Client, entree: EntreeDesPlaces, { file, id }?: {
5
+ file?: string;
6
+ id?: string;
7
+ }): Promise<void>;
8
+ /**
9
+ * Takes a place of the machine for <demande>: records the request under an id of its own, then
10
+ * reads it every <veilleMs> ms until the place is given. A request withdrawn, or whose process is
11
+ * gone, fails; <signal> aborted withdraws it.
12
+ */
13
+ export declare function prendreUnePlaceParTemporal(client: Client, demande: Omit<DemandeDePlace, 'id'>, { id, veilleMs, signal, }?: {
14
+ id?: string;
15
+ veilleMs?: number;
16
+ signal?: AbortSignal;
17
+ }): Promise<PlaceDonnee>;
18
+ /** The next rank of arrival of the machine, drawn at the launch of a circuit, which keeps it. */
19
+ export declare function tirerUnRangParTemporal(client: Client, id?: string): Promise<number>;
20
+ /** Gives the place <place> back, or withdraws the request <place> that waits. */
21
+ export declare function rendreLaPlace(client: Client, place: string, id?: string): Promise<void>;
22
+ /** Names <processus>, the process that now holds the place <place>. */
23
+ export declare function rattacherLaPlace(client: Client, place: string, processus: {
24
+ pid: number;
25
+ depart: string | null;
26
+ }, id?: string): Promise<void>;
27
+ /** The places of the machine as the board shows them: the ceiling, the places, the waits. */
28
+ export declare function lireLesPlaces(client: Client, id?: string): Promise<VueDesPlaces>;
@@ -0,0 +1,64 @@
1
+ // The client of the workflow of the machine (./deroule.ts): it starts the one workflow of the
2
+ // machine if it does not run, takes a place (the update PRENDRE records the request, then the
3
+ // query LA_DEMANDE tells once it is given), gives it back or withdraws the request (the signal
4
+ // RENDRE), names the process that holds it (the signal RATTACHER), and reads the places as the
5
+ // board shows them (the query LES_PLACES), from the server and the worker of the machine.
6
+ import { randomUUID } from 'node:crypto';
7
+ import { setTimeout as dormir } from 'node:timers/promises';
8
+ import { FILE_DE_LA_MACHINE } from '../installation.js';
9
+ import { ID_DES_PLACES, LA_DEMANDE, LES_PLACES, PLACES, PRENDRE, RATTACHER, RENDRE, TIRER_UN_RANG, } from './contrat.js';
10
+ /** Starts the workflow of the machine on <file>, or leaves the one that runs. */
11
+ export async function demarrerLesPlaces(client, entree, { file = FILE_DE_LA_MACHINE, id = ID_DES_PLACES } = {}) {
12
+ await client.workflow.start(PLACES, {
13
+ workflowId: id,
14
+ taskQueue: file,
15
+ args: [entree],
16
+ workflowIdConflictPolicy: 'USE_EXISTING',
17
+ });
18
+ }
19
+ /**
20
+ * Takes a place of the machine for <demande>: records the request under an id of its own, then
21
+ * reads it every <veilleMs> ms until the place is given. A request withdrawn, or whose process is
22
+ * gone, fails; <signal> aborted withdraws it.
23
+ */
24
+ export async function prendreUnePlaceParTemporal(client, demande, { id = ID_DES_PLACES, veilleMs = 250, signal, } = {}) {
25
+ const h = client.workflow.getHandle(id);
26
+ const place = randomUUID();
27
+ const { rang } = await h.executeUpdate(PRENDRE, {
28
+ args: [{ ...demande, id: place }],
29
+ updateId: place,
30
+ });
31
+ for (;;) {
32
+ if (signal?.aborted) {
33
+ await rendreLaPlace(client, place, id);
34
+ throw signal.reason ?? new Error(`la demande de place ${place} est retirée`);
35
+ }
36
+ const e = await h.query(LA_DEMANDE, place);
37
+ if (e.etat === 'donnee') {
38
+ return { id: place, rang };
39
+ }
40
+ if (e.etat === 'inconnue') {
41
+ throw new Error(`la demande de place ${place} n’est plus : retirée, ou son processus a disparu`);
42
+ }
43
+ await dormir(veilleMs);
44
+ }
45
+ }
46
+ /** The next rank of arrival of the machine, drawn at the launch of a circuit, which keeps it. */
47
+ export async function tirerUnRangParTemporal(client, id = ID_DES_PLACES) {
48
+ return client.workflow.getHandle(id).executeUpdate(TIRER_UN_RANG);
49
+ }
50
+ /** Gives the place <place> back, or withdraws the request <place> that waits. */
51
+ export async function rendreLaPlace(client, place, id = ID_DES_PLACES) {
52
+ await client.workflow.getHandle(id).signal(RENDRE, place);
53
+ }
54
+ /** Names <processus>, the process that now holds the place <place>. */
55
+ export async function rattacherLaPlace(client, place, processus, id = ID_DES_PLACES) {
56
+ await client.workflow
57
+ .getHandle(id)
58
+ .signal(RATTACHER, { id: place, ...processus });
59
+ }
60
+ /** The places of the machine as the board shows them: the ceiling, the places, the waits. */
61
+ export async function lireLesPlaces(client, id = ID_DES_PLACES) {
62
+ return client.workflow.getHandle(id).query(LES_PLACES);
63
+ }
64
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/temporal/places/client.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,8FAA8F;AAC9F,+FAA+F;AAC/F,+FAA+F;AAC/F,0FAA0F;AAC1F,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACL,aAAa,EACb,UAAU,EACV,UAAU,EACV,MAAM,EACN,OAAO,EACP,SAAS,EACT,MAAM,EACN,aAAa,GAOd,MAAM,cAAc,CAAC;AAEtB,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAc,EACd,MAAuB,EACvB,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