@rcpooley/concord 0.1.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 (176) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +318 -0
  3. package/bin/concord.service +69 -0
  4. package/dist/age.d.ts +20 -0
  5. package/dist/age.d.ts.map +1 -0
  6. package/dist/age.js +58 -0
  7. package/dist/age.js.map +1 -0
  8. package/dist/cli/main.d.ts +3 -0
  9. package/dist/cli/main.d.ts.map +1 -0
  10. package/dist/cli/main.js +301 -0
  11. package/dist/cli/main.js.map +1 -0
  12. package/dist/daemon.d.ts +4 -0
  13. package/dist/daemon.d.ts.map +1 -0
  14. package/dist/daemon.js +394 -0
  15. package/dist/daemon.js.map +1 -0
  16. package/dist/eval-config.d.ts +2 -0
  17. package/dist/eval-config.d.ts.map +1 -0
  18. package/dist/eval-config.js +45 -0
  19. package/dist/eval-config.js.map +1 -0
  20. package/dist/exec.d.ts +168 -0
  21. package/dist/exec.d.ts.map +1 -0
  22. package/dist/exec.js +313 -0
  23. package/dist/exec.js.map +1 -0
  24. package/dist/git.d.ts +59 -0
  25. package/dist/git.d.ts.map +1 -0
  26. package/dist/git.js +265 -0
  27. package/dist/git.js.map +1 -0
  28. package/dist/hook.d.ts +37 -0
  29. package/dist/hook.d.ts.map +1 -0
  30. package/dist/hook.js +89 -0
  31. package/dist/hook.js.map +1 -0
  32. package/dist/index.d.ts +18 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +15 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/init.d.ts +76 -0
  37. package/dist/init.d.ts.map +1 -0
  38. package/dist/init.js +236 -0
  39. package/dist/init.js.map +1 -0
  40. package/dist/loader.d.ts +35 -0
  41. package/dist/loader.d.ts.map +1 -0
  42. package/dist/loader.js +230 -0
  43. package/dist/loader.js.map +1 -0
  44. package/dist/module.d.ts +116 -0
  45. package/dist/module.d.ts.map +1 -0
  46. package/dist/module.js +100 -0
  47. package/dist/module.js.map +1 -0
  48. package/dist/modules/apt/index.d.ts +45 -0
  49. package/dist/modules/apt/index.d.ts.map +1 -0
  50. package/dist/modules/apt/index.js +249 -0
  51. package/dist/modules/apt/index.js.map +1 -0
  52. package/dist/modules/apt/schema.d.ts +63 -0
  53. package/dist/modules/apt/schema.d.ts.map +1 -0
  54. package/dist/modules/apt/schema.js +75 -0
  55. package/dist/modules/apt/schema.js.map +1 -0
  56. package/dist/modules/checkout/index.d.ts +88 -0
  57. package/dist/modules/checkout/index.d.ts.map +1 -0
  58. package/dist/modules/checkout/index.js +382 -0
  59. package/dist/modules/checkout/index.js.map +1 -0
  60. package/dist/modules/checkout/schema.d.ts +52 -0
  61. package/dist/modules/checkout/schema.d.ts.map +1 -0
  62. package/dist/modules/checkout/schema.js +132 -0
  63. package/dist/modules/checkout/schema.js.map +1 -0
  64. package/dist/modules/cloudflare/api.d.ts +64 -0
  65. package/dist/modules/cloudflare/api.d.ts.map +1 -0
  66. package/dist/modules/cloudflare/api.js +98 -0
  67. package/dist/modules/cloudflare/api.js.map +1 -0
  68. package/dist/modules/cloudflare/index.d.ts +74 -0
  69. package/dist/modules/cloudflare/index.d.ts.map +1 -0
  70. package/dist/modules/cloudflare/index.js +374 -0
  71. package/dist/modules/cloudflare/index.js.map +1 -0
  72. package/dist/modules/cloudflare/schema.d.ts +62 -0
  73. package/dist/modules/cloudflare/schema.d.ts.map +1 -0
  74. package/dist/modules/cloudflare/schema.js +85 -0
  75. package/dist/modules/cloudflare/schema.js.map +1 -0
  76. package/dist/modules/docker/index.d.ts +83 -0
  77. package/dist/modules/docker/index.d.ts.map +1 -0
  78. package/dist/modules/docker/index.js +470 -0
  79. package/dist/modules/docker/index.js.map +1 -0
  80. package/dist/modules/docker/registry.d.ts +35 -0
  81. package/dist/modules/docker/registry.d.ts.map +1 -0
  82. package/dist/modules/docker/registry.js +95 -0
  83. package/dist/modules/docker/registry.js.map +1 -0
  84. package/dist/modules/docker/render.d.ts +45 -0
  85. package/dist/modules/docker/render.d.ts.map +1 -0
  86. package/dist/modules/docker/render.js +162 -0
  87. package/dist/modules/docker/render.js.map +1 -0
  88. package/dist/modules/docker/schema.d.ts +231 -0
  89. package/dist/modules/docker/schema.d.ts.map +1 -0
  90. package/dist/modules/docker/schema.js +335 -0
  91. package/dist/modules/docker/schema.js.map +1 -0
  92. package/dist/modules/docker/sweeper.d.ts +64 -0
  93. package/dist/modules/docker/sweeper.d.ts.map +1 -0
  94. package/dist/modules/docker/sweeper.js +94 -0
  95. package/dist/modules/docker/sweeper.js.map +1 -0
  96. package/dist/modules/file/index.d.ts +79 -0
  97. package/dist/modules/file/index.d.ts.map +1 -0
  98. package/dist/modules/file/index.js +305 -0
  99. package/dist/modules/file/index.js.map +1 -0
  100. package/dist/modules/file/schema.d.ts +45 -0
  101. package/dist/modules/file/schema.d.ts.map +1 -0
  102. package/dist/modules/file/schema.js +114 -0
  103. package/dist/modules/file/schema.js.map +1 -0
  104. package/dist/modules/index.d.ts +20 -0
  105. package/dist/modules/index.d.ts.map +1 -0
  106. package/dist/modules/index.js +11 -0
  107. package/dist/modules/index.js.map +1 -0
  108. package/dist/modules/porkbun/api.d.ts +36 -0
  109. package/dist/modules/porkbun/api.d.ts.map +1 -0
  110. package/dist/modules/porkbun/api.js +62 -0
  111. package/dist/modules/porkbun/api.js.map +1 -0
  112. package/dist/modules/porkbun/index.d.ts +50 -0
  113. package/dist/modules/porkbun/index.d.ts.map +1 -0
  114. package/dist/modules/porkbun/index.js +236 -0
  115. package/dist/modules/porkbun/index.js.map +1 -0
  116. package/dist/modules/porkbun/schema.d.ts +38 -0
  117. package/dist/modules/porkbun/schema.d.ts.map +1 -0
  118. package/dist/modules/porkbun/schema.js +39 -0
  119. package/dist/modules/porkbun/schema.js.map +1 -0
  120. package/dist/modules/script/index.d.ts +43 -0
  121. package/dist/modules/script/index.d.ts.map +1 -0
  122. package/dist/modules/script/index.js +116 -0
  123. package/dist/modules/script/index.js.map +1 -0
  124. package/dist/modules/script/schema.d.ts +25 -0
  125. package/dist/modules/script/schema.d.ts.map +1 -0
  126. package/dist/modules/script/schema.js +63 -0
  127. package/dist/modules/script/schema.js.map +1 -0
  128. package/dist/modules/systemd/index.d.ts +93 -0
  129. package/dist/modules/systemd/index.d.ts.map +1 -0
  130. package/dist/modules/systemd/index.js +394 -0
  131. package/dist/modules/systemd/index.js.map +1 -0
  132. package/dist/modules/systemd/render.d.ts +41 -0
  133. package/dist/modules/systemd/render.d.ts.map +1 -0
  134. package/dist/modules/systemd/render.js +252 -0
  135. package/dist/modules/systemd/render.js.map +1 -0
  136. package/dist/modules/systemd/schema.d.ts +293 -0
  137. package/dist/modules/systemd/schema.d.ts.map +1 -0
  138. package/dist/modules/systemd/schema.js +302 -0
  139. package/dist/modules/systemd/schema.js.map +1 -0
  140. package/dist/modules/systemd/sweeper.d.ts +31 -0
  141. package/dist/modules/systemd/sweeper.d.ts.map +1 -0
  142. package/dist/modules/systemd/sweeper.js +77 -0
  143. package/dist/modules/systemd/sweeper.js.map +1 -0
  144. package/dist/plans.d.ts +132 -0
  145. package/dist/plans.d.ts.map +1 -0
  146. package/dist/plans.js +315 -0
  147. package/dist/plans.js.map +1 -0
  148. package/dist/records.d.ts +37 -0
  149. package/dist/records.d.ts.map +1 -0
  150. package/dist/records.js +100 -0
  151. package/dist/records.js.map +1 -0
  152. package/dist/registry.d.ts +38 -0
  153. package/dist/registry.d.ts.map +1 -0
  154. package/dist/registry.js +31 -0
  155. package/dist/registry.js.map +1 -0
  156. package/dist/runner.d.ts +48 -0
  157. package/dist/runner.d.ts.map +1 -0
  158. package/dist/runner.js +150 -0
  159. package/dist/runner.js.map +1 -0
  160. package/dist/scheduler.d.ts +36 -0
  161. package/dist/scheduler.d.ts.map +1 -0
  162. package/dist/scheduler.js +77 -0
  163. package/dist/scheduler.js.map +1 -0
  164. package/dist/schema.d.ts +762 -0
  165. package/dist/schema.d.ts.map +1 -0
  166. package/dist/schema.js +185 -0
  167. package/dist/schema.js.map +1 -0
  168. package/dist/secret.d.ts +24 -0
  169. package/dist/secret.d.ts.map +1 -0
  170. package/dist/secret.js +3 -0
  171. package/dist/secret.js.map +1 -0
  172. package/dist/ui.d.ts +62 -0
  173. package/dist/ui.d.ts.map +1 -0
  174. package/dist/ui.js +288 -0
  175. package/dist/ui.js.map +1 -0
  176. package/package.json +57 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;kBAyBZ,CAAA;AAEX,wEAAwE;AACxE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;mBAc3B,CAAA;AAEJ,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC,CAAA;AACpD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAU7D;;;;;;;;;;GAUG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,cAAc,IAAI,CAAA;AAE/B;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAS7B,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAA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,EAAE,MAAM,CAAC,CAAC,EAAE,CAAA;CAClE,CAAA"}
package/dist/schema.js ADDED
@@ -0,0 +1,185 @@
1
+ import { z } from 'zod';
2
+ import { SecretSchema } from './secret.js';
3
+ /**
4
+ * A machine Concord manages.
5
+ *
6
+ * There is deliberately NO `localhost` concept — every host is an ordinary
7
+ * entry and one of them merely carries `transport: 'local'`. Moving the primary
8
+ * is then a one-word change rather than a config migration.
9
+ *
10
+ * `local` exists at all (rather than SSHing to self for uniformity) because if
11
+ * sshd on the primary broke, Concord could no longer repair the host it runs
12
+ * on. Local exec always works.
13
+ */
14
+ export const HostSchema = z
15
+ .object({
16
+ ip: z.string().min(1),
17
+ user: z.string().min(1),
18
+ port: z.number().int().positive().max(65535).optional(),
19
+ transport: z.enum(['local', 'ssh']).default('ssh'),
20
+ /** Private key for ssh transport. Omit to use the invoking user's agent/identity. */
21
+ key: SecretSchema.optional(),
22
+ /**
23
+ * This machine sleeps (a laptop): an unreachable host SKIPS its modules
24
+ * instead of failing the run. A property of the MACHINE, not of any
25
+ * module — every other error still fails the run; this covers
26
+ * unreachability only.
27
+ */
28
+ skipIfUnreachable: z.boolean().default(false),
29
+ /**
30
+ * What this host's docker sweep may remove. `all` (the default) removes ANY container no module declares,
31
+ * labelled or not. `labelled` removes only containers carrying Concord's
32
+ * project label: Concord still cleans up after itself, but containers
33
+ * something else started are left alone. For a development machine, where
34
+ * sessions run `docker run` / `compose up` by hand and those containers
35
+ * are the work, not drift. A property of the MACHINE, like the flag above.
36
+ */
37
+ containerSweep: z.enum(['all', 'labelled']).default('all'),
38
+ })
39
+ .strict();
40
+ /** Hosts by name. Module `host` fields are typed against these keys. */
41
+ export const HostRegistrySchema = z
42
+ .record(z.string(), HostSchema)
43
+ // zod reports a bad record key as "Invalid key in record", which does not say
44
+ // WHICH key or why — so the shape is checked here instead.
45
+ .superRefine((reg, ctx) => {
46
+ for (const name of Object.keys(reg)) {
47
+ if (!/^[a-z0-9][a-z0-9-]*$/.test(name)) {
48
+ ctx.addIssue({
49
+ code: 'custom',
50
+ path: [name],
51
+ message: `host name "${name}" must be kebab-case, starting alphanumeric`,
52
+ });
53
+ }
54
+ }
55
+ });
56
+ import { AptConfigSchema } from './modules/apt/schema.js';
57
+ import { FileConfigSchema } from './modules/file/schema.js';
58
+ import { SystemdConfigSchema } from './modules/systemd/schema.js';
59
+ import { ScriptConfigSchema } from './modules/script/schema.js';
60
+ import { DockerConfigSchema } from './modules/docker/schema.js';
61
+ import { CheckoutConfigSchema } from './modules/checkout/schema.js';
62
+ import { PorkbunConfigSchema } from './modules/porkbun/schema.js';
63
+ import { CloudflareConfigSchema } from './modules/cloudflare/schema.js';
64
+ /**
65
+ * Bumped on any BREAKING change to the config shape.
66
+ *
67
+ * The config repo declares this as a LITERAL, and `ConcordConfig` types it as a
68
+ * literal — so when this bumps, a config pinned to the new concord fails to
69
+ * typecheck until it is updated. The number is enforced by the type system
70
+ * rather than by anyone remembering to change it.
71
+ *
72
+ * The reconciler additionally checks it at load time, which catches the case
73
+ * types cannot: a config authored against a NEWER concord than the one running.
74
+ */
75
+ /**
76
+ * 8: the docker sweep joined the v7 lifecycle — `sweep`/`protected` are GONE
77
+ * from the docker schema, and the loader synthesizes one DockerSweeper per
78
+ * registry host exactly like systemd's. Behavior-preserving for a
79
+ * config that already declared a sweep for every host — the change moves
80
+ * "always-on" from a convention configs had to follow into the engine's
81
+ * contract. `protected` died unused; an
82
+ * escape hatch with zero consumers returns as data when a real one
83
+ * appears. What did NOT change: the docker sweeper still removes ANY
84
+ * undeclared container, labelled or not — unlike the
85
+ * systemd sweeper, which only ever removes what carries Concord's tag.
86
+ * 7: systemd units became HOST-TRUTH, the way containers did in 6 — but as a
87
+ * property of the module KIND, not of the config. Every rendered unit
88
+ * carries `X-Concord=1`; the loader synthesizes one sweeper per host that
89
+ * withdraws any tagged unit no module writes. Nothing to declare, so
90
+ * systemd's `absent` is GONE — hand-written cruft is hand-removed, and
91
+ * Concord's own cruft removes itself. `skipIfHostUnreachable` MOVED from
92
+ * the five host-scoped modules to the host registry (`skipIfUnreachable`),
93
+ * reversing the per-module decision: the flag described the machines (machines
94
+ * that sleep) from the day it landed, config stamped it uniformly per
95
+ * host anyway, and synthesized sweepers need an answer for hosts that
96
+ * declare no modules at all.
97
+ * 6: containers became HOST-TRUTH. `docker` gained `sweep` — one module per
98
+ * host may declare the host's container set exclusive, and any live
99
+ * container no module declares (minus `sweep.protected`) is removed, volumes
100
+ * never included. The loader computes each sweep's keep-set across all
101
+ * docker modules on the host. `absent`/`removeVolumes` are GONE: both described
102
+ * history
103
+ * ("what used to run here") rather than desired state — the sweep derives
104
+ * the same removals from what is declared, which also covers the case
105
+ * `absent` never did: deleting an app file entirely.
106
+ * 5: the `container` module became `docker`, and gained `networks` — a network
107
+ * is now a declared RESOURCE with a real read(), not a side effect of
108
+ * starting a container. `type: 'container'` / `containers: [...]` become
109
+ * `type: 'docker'` / `containers: [...]` (the field keeps its name; it still
110
+ * lists containers). The module still does not install Docker: the engine,
111
+ * daemon.json and the apt repo belong to apt/file/systemd, just as a module
112
+ * is always named for the interface it drives, not what it provisions.
113
+ * 4: the `app` module became `container` — `type: 'app'` / `apps: [...]` are now
114
+ * `type: 'container'` / `containers: [...]`. Naming only: the module drives a
115
+ * slice of Docker (build an image, run one container), while Docker's own
116
+ * installation and daemon config belong to apt/file/systemd. The three
117
+ * `dev.concord.*` labels and the compose service name are DELIBERATELY
118
+ * unchanged — they are the join to containers that already exist, and
119
+ * changing them would make every running container invisible to read().
120
+ */
121
+ export const SCHEMA_VERSION = 8;
122
+ /**
123
+ * Every module's config, discriminated by `type`.
124
+ *
125
+ * Each module declares its schema once; the TypeScript type is inferred from
126
+ * it (`z.infer`), so the author-time type and the runtime validator cannot
127
+ * drift. `.strict()` on each schema is what rejects unknown keys — a property
128
+ * of the schema, not a hand-maintained list of field names.
129
+ */
130
+ export const ModuleConfigSchema = z.discriminatedUnion('type', [
131
+ PorkbunConfigSchema,
132
+ CloudflareConfigSchema,
133
+ AptConfigSchema,
134
+ FileConfigSchema,
135
+ SystemdConfigSchema,
136
+ ScriptConfigSchema,
137
+ DockerConfigSchema,
138
+ CheckoutConfigSchema,
139
+ ]);
140
+ /**
141
+ * Fleet-wide settings.
142
+ *
143
+ * Distinct from `/etc/concord.env`, which holds what Concord needs to RUN. This
144
+ * holds what it needs to DEPLOY: Concord works fine without a git token unless
145
+ * the config declares an app from a private repo, which makes it a property of
146
+ * what is being deployed rather than of Concord itself.
147
+ */
148
+ export const SettingsSchema = z
149
+ .object({
150
+ git: z
151
+ .object({
152
+ /**
153
+ * Used on the primary by `docker`, which fetches centrally and streams
154
+ * the tree, so a docker host holds no git credential at all.
155
+ *
156
+ * `checkout` is the exception, and deliberately: it drives git ON the
157
+ * target, so the token is transmitted there — inside a script body over
158
+ * stdin, exported to the shell, and referenced only by NAME in git's
159
+ * credential helper. It never reaches argv (world-readable in /proc)
160
+ * and it is never written into `.git/config`, which the hand-rolled
161
+ * `remote set-url https://x-access-token:$TOKEN@…` idiom it replaces
162
+ * did do, leaving the token in plaintext on disk.
163
+ *
164
+ * One token for the whole config today; per-repo tokens would nest here.
165
+ */
166
+ token: SecretSchema.optional(),
167
+ })
168
+ .strict()
169
+ .optional(),
170
+ })
171
+ .strict();
172
+ export const ConcordConfigSchema = z
173
+ .object({
174
+ schemaVersion: z.literal(SCHEMA_VERSION),
175
+ /**
176
+ * REQUIRED, including the machine Concord runs on. There is no implicit
177
+ * local host: if it is not registered it cannot be targeted, and a module
178
+ * cannot fall back to "wherever this happens to be running".
179
+ */
180
+ hosts: HostRegistrySchema,
181
+ settings: SettingsSchema.optional(),
182
+ modules: z.array(ModuleConfigSchema),
183
+ })
184
+ .strict();
185
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,YA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AM,CAAC;IACN,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;IACxC;;;;OAIG;IACH,KAAK,EAAE,kBAAkB;IACzB,QAAQ,EAAE,cAAc,CAAC,QAAQ,EAAE;IACnC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC;CACrC,CAAC;KACD,MAAM,EAAE,CAAA"}
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Secrets are age-encrypted at rest in the config repo and decrypted only
4
+ * inside the reconciler.
5
+ *
6
+ * Asymmetric on purpose: encrypting needs only the public key, so an agent can
7
+ * ADD or ROTATE a secret in the config repo while holding no ability to read
8
+ * any existing one.
9
+ */
10
+ declare const secretBrand: unique symbol;
11
+ /**
12
+ * An age ciphertext (base64). Branded so a module field expecting a secret
13
+ * cannot be handed a raw plaintext string by accident.
14
+ *
15
+ * The generated `secrets.ts` in the config repo brands its values with
16
+ * `as Secret` under a TYPE-ONLY import, so the config repo carries no runtime
17
+ * dependency on this package.
18
+ */
19
+ export type Secret = string & {
20
+ readonly [secretBrand]: true;
21
+ };
22
+ export declare const SecretSchema: z.ZodCustom<Secret, Secret>;
23
+ export {};
24
+ //# sourceMappingURL=secret.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret.d.ts","sourceRoot":"","sources":["../src/secret.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;GAOG;AAEH,OAAO,CAAC,MAAM,WAAW,EAAE,OAAO,MAAM,CAAA;AAExC;;;;;;;GAOG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,WAAW,CAAC,EAAE,IAAI,CAAA;CAAE,CAAA;AAE9D,eAAO,MAAM,YAAY,6BAGxB,CAAA"}
package/dist/secret.js ADDED
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ export const SecretSchema = z.custom((v) => typeof v === 'string' && v.length > 0, { message: 'must be a non-empty age ciphertext (see secrets.ts)' });
3
+ //# sourceMappingURL=secret.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret.js","sourceRoot":"","sources":["../src/secret.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAuBvB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAClC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAC5C,EAAE,OAAO,EAAE,qDAAqD,EAAE,CACnE,CAAA"}
package/dist/ui.d.ts ADDED
@@ -0,0 +1,62 @@
1
+ import { type IncomingMessage, type Server, type ServerResponse } from 'node:http';
2
+ import { type PlanService } from './plans.js';
3
+ /**
4
+ * The daemon's own UI and API: recent reconciles, plans on request.
5
+ *
6
+ * It listens on a unix socket SEPARATE from the webhook's. Expose it only on a
7
+ * private network (a VPN, a LAN, an ssh tunnel), never publicly. The two
8
+ * sockets are the whole security model: the public listener stays an HMAC
9
+ * check and a poke, and nothing here is reachable from the internet even if a
10
+ * route is misconfigured to point at the wrong one — the wrong one does not
11
+ * serve these paths.
12
+ *
13
+ * There is no auth beyond that private network, deliberately: nothing here
14
+ * changes production. The only write is "plan this branch", which reads.
15
+ *
16
+ * Like the webhook, this is never load-bearing: a dead listener means no UI,
17
+ * never a missed reconcile.
18
+ */
19
+ /** One real reconcile, as the daemon recorded it. */
20
+ export interface RunRecord {
21
+ id: string;
22
+ /** What asked for it: `interval`, `startup`, `webhook`, `SIGHUP`. */
23
+ trigger: string;
24
+ status: 'running' | 'converged' | 'changed' | 'aborted' | 'error';
25
+ startedAt: string;
26
+ finishedAt?: string;
27
+ /** Config commit that was reconciled. */
28
+ sha?: string;
29
+ totalOps?: number;
30
+ /** The closing line — "converged", "3 change(s) …", "ABORTED at …". */
31
+ summary?: string;
32
+ log: string[];
33
+ }
34
+ export type RunSummary = Omit<RunRecord, 'log'>;
35
+ export interface DaemonStatus {
36
+ startedAt: string;
37
+ intervalSeconds: number;
38
+ /** `sha` for a git checkout, `version` for an npm install. */
39
+ reconciler: {
40
+ sha?: string;
41
+ version?: string;
42
+ behind?: string;
43
+ };
44
+ reconciling: boolean;
45
+ /** When the next interval run is due, if the daemon is sleeping. */
46
+ nextRunAt?: string;
47
+ configRepo?: string;
48
+ }
49
+ export interface UiOptions {
50
+ socketPath: string;
51
+ status: () => DaemonStatus;
52
+ runs: {
53
+ list: (limit: number) => RunSummary[];
54
+ get: (id: string) => RunRecord | undefined;
55
+ };
56
+ plans: PlanService;
57
+ log: (scope: string, message: string) => void;
58
+ }
59
+ export declare function startUi(opts: UiOptions): Server;
60
+ export declare function handle(opts: UiOptions, req: IncomingMessage, res: ServerResponse): Promise<void>;
61
+ export declare function esc(s: unknown): string;
62
+ //# sourceMappingURL=ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,eAAe,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;AAEhG,OAAO,EAA+C,KAAK,WAAW,EAAoB,MAAM,YAAY,CAAA;AAE5G;;;;;;;;;;;;;;;GAeG;AAEH,qDAAqD;AACrD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;IACjE,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAA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createServer } from 'node:http';
4
+ import { isRecordId } from './records.js';
5
+ import { PlanError } from './plans.js';
6
+ const MAX_BODY = 16 * 1024;
7
+ /** Longest a `?wait=` may hold a request open, in seconds. */
8
+ const MAX_WAIT_S = 600;
9
+ export function startUi(opts) {
10
+ const { socketPath, log } = opts;
11
+ if (existsSync(socketPath)) {
12
+ try {
13
+ unlinkSync(socketPath);
14
+ }
15
+ catch {
16
+ /* listen() will say why */
17
+ }
18
+ }
19
+ const server = createServer((req, res) => {
20
+ handle(opts, req, res).catch((err) => {
21
+ log('ui', `error on ${req.method} ${req.url}: ${err instanceof Error ? err.message : String(err)}`);
22
+ if (!res.headersSent)
23
+ sendJson(res, 500, { error: 'internal error' });
24
+ else
25
+ res.end();
26
+ });
27
+ });
28
+ server.listen(socketPath, () => {
29
+ // A reverse proxy's workers (often in a container) run as their own uid.
30
+ // The socket is only reachable from this host and whatever mounts it; who
31
+ // can reach the proxy route is the real gate.
32
+ chmodSync(socketPath, 0o666);
33
+ log('ui', `listening on ${socketPath}`);
34
+ });
35
+ server.on('error', (err) => log('ui', `listener error: ${err.message}`));
36
+ return server;
37
+ }
38
+ // ----------------------------------------------------------------- routes ---
39
+ export async function handle(opts, req, res) {
40
+ const url = new URL(req.url ?? '/', 'http://concord.local');
41
+ const path = url.pathname.replace(/\/+$/, '') || '/';
42
+ const method = req.method ?? 'GET';
43
+ const parts = path.split('/').filter(Boolean);
44
+ if (method === 'GET' && path === '/healthz')
45
+ return sendText(res, 200, 'ok');
46
+ // --------------------------------------------------------------- API ---
47
+ if (parts[0] === 'api') {
48
+ if (method === 'GET' && path === '/api/status')
49
+ return sendJson(res, 200, opts.status());
50
+ if (method === 'GET' && path === '/api/runs') {
51
+ return sendJson(res, 200, { runs: opts.runs.list(limitParam(url)) });
52
+ }
53
+ if (method === 'GET' && parts[1] === 'runs' && parts.length === 3) {
54
+ const run = isRecordId(parts[2]) ? opts.runs.get(parts[2]) : undefined;
55
+ return run ? sendJson(res, 200, run) : sendJson(res, 404, { error: 'no such run' });
56
+ }
57
+ if (method === 'GET' && path === '/api/plans') {
58
+ return sendJson(res, 200, { plans: opts.plans.list(limitParam(url)) });
59
+ }
60
+ if (method === 'POST' && path === '/api/plans') {
61
+ const body = await readJson(req);
62
+ if (body === undefined)
63
+ return sendJson(res, 400, { error: 'body must be JSON: {"branch": "…", "sha"?: "…"}' });
64
+ try {
65
+ const plan = opts.plans.request(body.branch, body.sha);
66
+ const waitS = waitParam(url);
67
+ const done = waitS > 0 ? await opts.plans.wait(plan.id, waitS * 1000) : plan;
68
+ return sendJson(res, 202, withLinks(done ?? plan));
69
+ }
70
+ catch (err) {
71
+ if (err instanceof PlanError)
72
+ return sendJson(res, err.status, { error: err.message });
73
+ throw err;
74
+ }
75
+ }
76
+ if (method === 'GET' && parts[1] === 'plans' && parts.length === 3) {
77
+ const id = parts[2];
78
+ if (!isRecordId(id))
79
+ return sendJson(res, 404, { error: 'no such plan' });
80
+ const plan = await opts.plans.wait(id, waitParam(url) * 1000);
81
+ return plan ? sendJson(res, 200, withLinks(plan)) : sendJson(res, 404, { error: 'no such plan' });
82
+ }
83
+ return sendJson(res, 404, { error: 'not found' });
84
+ }
85
+ // ---------------------------------------------------------------- HTML ---
86
+ if (method === 'GET' && path === '/')
87
+ return sendHtml(res, 200, pageHome(opts));
88
+ if (method === 'POST' && path === '/plans') {
89
+ const form = await readForm(req);
90
+ try {
91
+ const plan = opts.plans.request(form.get('branch')?.trim(), form.get('sha')?.trim() || undefined);
92
+ res.writeHead(303, { location: `/plans/${plan.id}` });
93
+ return void res.end();
94
+ }
95
+ catch (err) {
96
+ if (err instanceof PlanError)
97
+ return sendHtml(res, err.status, pageError(err.message));
98
+ throw err;
99
+ }
100
+ }
101
+ if (method === 'GET' && parts[0] === 'plans' && parts.length === 2) {
102
+ const plan = isRecordId(parts[1]) ? opts.plans.get(parts[1]) : undefined;
103
+ return plan ? sendHtml(res, 200, pagePlan(plan)) : sendHtml(res, 404, pageError('No such plan.'));
104
+ }
105
+ if (method === 'GET' && parts[0] === 'runs' && parts.length === 2) {
106
+ const run = isRecordId(parts[1]) ? opts.runs.get(parts[1]) : undefined;
107
+ return run ? sendHtml(res, 200, pageRun(run)) : sendHtml(res, 404, pageError('No such run.'));
108
+ }
109
+ return sendHtml(res, 404, pageError('Not found.'));
110
+ }
111
+ function withLinks(plan) {
112
+ return { ...plan, url: `/plans/${plan.id}` };
113
+ }
114
+ function limitParam(url) {
115
+ const n = Number(url.searchParams.get('limit') ?? 20);
116
+ return Number.isInteger(n) && n > 0 ? Math.min(n, 100) : 20;
117
+ }
118
+ function waitParam(url) {
119
+ const n = Number(url.searchParams.get('wait') ?? 0);
120
+ return Number.isFinite(n) && n > 0 ? Math.min(n, MAX_WAIT_S) : 0;
121
+ }
122
+ // --------------------------------------------------------------- plumbing ---
123
+ function readBody(req) {
124
+ return new Promise((resolve) => {
125
+ const chunks = [];
126
+ let size = 0;
127
+ req.on('data', (c) => {
128
+ size += c.length;
129
+ if (size > MAX_BODY) {
130
+ resolve(undefined);
131
+ req.destroy();
132
+ return;
133
+ }
134
+ chunks.push(c);
135
+ });
136
+ req.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
137
+ req.on('error', () => resolve(undefined));
138
+ });
139
+ }
140
+ async function readJson(req) {
141
+ const body = await readBody(req);
142
+ if (body === undefined)
143
+ return undefined;
144
+ try {
145
+ const parsed = JSON.parse(body);
146
+ return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
147
+ ? parsed
148
+ : undefined;
149
+ }
150
+ catch {
151
+ return undefined;
152
+ }
153
+ }
154
+ async function readForm(req) {
155
+ return new URLSearchParams((await readBody(req)) ?? '');
156
+ }
157
+ function sendJson(res, code, body) {
158
+ res.writeHead(code, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
159
+ res.end(JSON.stringify(body, null, 2) + '\n');
160
+ }
161
+ function sendText(res, code, body) {
162
+ res.writeHead(code, { 'content-type': 'text/plain; charset=utf-8' });
163
+ res.end(body + '\n');
164
+ }
165
+ function sendHtml(res, code, body) {
166
+ res.writeHead(code, {
167
+ 'content-type': 'text/html; charset=utf-8',
168
+ 'cache-control': 'no-store',
169
+ // Nothing on these pages is meant to run script, load from elsewhere, or be framed.
170
+ 'content-security-policy': "default-src 'none'; style-src 'unsafe-inline'; form-action 'self'; frame-ancestors 'none'",
171
+ });
172
+ res.end(body);
173
+ }
174
+ // ------------------------------------------------------------------ pages ---
175
+ export function esc(s) {
176
+ return String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
177
+ }
178
+ const CSS = `
179
+ :root { color-scheme: light dark; --muted: #888; --ok: #2e9e5b; --warn: #c98a00; --bad: #d0453a; --run: #3a7bd5; }
180
+ body { font: 14px/1.45 system-ui, sans-serif; max-width: 1100px; margin: 24px auto; padding: 0 16px; }
181
+ h1 { font-size: 20px; margin: 0 0 4px } h2 { font-size: 16px; margin: 28px 0 8px }
182
+ a { color: inherit } .muted { color: var(--muted) } code, pre { font: 12px/1.4 ui-monospace, monospace }
183
+ table { border-collapse: collapse; width: 100% } td, th { text-align: left; padding: 4px 10px 4px 0; vertical-align: top; border-bottom: 1px solid #8883 }
184
+ pre { background: #8881; padding: 10px; overflow-x: auto; white-space: pre-wrap; word-break: break-all }
185
+ .pill { display: inline-block; padding: 0 8px; border-radius: 9px; font-size: 12px; color: #fff }
186
+ .s-converged, .s-planned { background: var(--ok) } .s-changed { background: var(--run) }
187
+ .s-running, .s-queued { background: var(--run) } .s-aborted, .s-error, .s-failed { background: var(--bad) }
188
+ .s-refused { background: var(--warn) }
189
+ .box { border: 1px solid #8884; border-radius: 6px; padding: 10px 14px; margin: 10px 0 }
190
+ .err { border-color: var(--bad) } .warn { border-color: var(--warn) }
191
+ form input[type=text] { font: inherit; padding: 4px 6px; width: 320px } form button { font: inherit; padding: 4px 12px }
192
+ ul.ops { margin: 4px 0; padding-left: 18px } .k-delete { color: var(--bad) } .k-create { color: var(--ok) }
193
+ `;
194
+ function layout(title, body, refresh = false) {
195
+ return `<!doctype html><html><head><meta charset="utf-8"><title>${esc(title)} · concord</title>
196
+ ${refresh ? '<meta http-equiv="refresh" content="3">' : ''}
197
+ <meta name="viewport" content="width=device-width, initial-scale=1"><style>${CSS}</style></head>
198
+ <body><p class="muted"><a href="/">concord</a> · ${esc(hostname())}</p>${body}</body></html>`;
199
+ }
200
+ const pill = (status) => `<span class="pill s-${esc(status)}">${esc(status)}</span>`;
201
+ const time = (iso) => (iso ? `<span title="${esc(iso)}">${esc(iso.replace('T', ' ').slice(0, 19))}Z</span>` : '');
202
+ const short = (sha) => (sha ? `<code>${esc(sha.slice(0, 10))}</code>` : '');
203
+ function duration(from, to) {
204
+ if (!from || !to)
205
+ return '';
206
+ const s = Math.round((Date.parse(to) - Date.parse(from)) / 1000);
207
+ return s >= 60 ? `${Math.floor(s / 60)}m${s % 60}s` : `${s}s`;
208
+ }
209
+ function pageHome(opts) {
210
+ const st = opts.status();
211
+ const runs = opts.runs.list(20);
212
+ const plans = opts.plans.list(20);
213
+ const busy = st.reconciling || plans.some((p) => p.status === 'queued' || p.status === 'running');
214
+ const statusBox = `<div class="box${st.reconciler.behind ? ' warn' : ''}">
215
+ <b>${st.reconciling ? 'Reconciling now' : 'Idle'}</b>${st.nextRunAt && !st.reconciling ? ` <span class="muted">· next interval run ${time(st.nextRunAt)}</span>` : ''}<br>
216
+ <span class="muted">reconciler</span> ${st.reconciler.version ? `<code>${esc(st.reconciler.version)}</code>` : short(st.reconciler.sha)}${st.reconciler.behind ? ` <b>⚠ ${esc(st.reconciler.behind)}</b> — update the reconciler on this host` : ''}
217
+ · <span class="muted">every</span> ${esc(st.intervalSeconds)}s · <span class="muted">up since</span> ${time(st.startedAt)}</div>`;
218
+ const planForm = `<form method="post" action="/plans" class="box">
219
+ <b>Plan a branch</b> of the config repo against the live fleet (read-only).<br>
220
+ <input type="text" name="branch" placeholder="my-change" required pattern="[A-Za-z0-9._/-]+">
221
+ <input type="text" name="sha" placeholder="expected sha (optional)" style="width:200px">
222
+ <button>Plan</button>
223
+ <div class="muted">The branch must contain the current main — a branch behind main is refused.</div></form>`;
224
+ return layout('concord', `<h1>Concord</h1>${statusBox}
225
+ <h2>Plans</h2>${planForm}${plansTable(plans)}
226
+ <h2>Reconciles</h2>${runsTable(runs)}`, busy);
227
+ }
228
+ function plansTable(plans) {
229
+ if (!plans.length)
230
+ return '<p class="muted">No plans yet.</p>';
231
+ return `<table><tr><th>requested</th><th>branch</th><th>commit</th><th>status</th><th>changes</th><th></th></tr>${plans
232
+ .map((p) => `<tr><td>${time(p.requestedAt)}</td><td><code>${esc(p.branch)}</code></td><td>${short(p.sha)}</td>
233
+ <td>${pill(p.status)}</td><td>${p.totalOps ?? ''}</td>
234
+ <td><a href="/plans/${esc(p.id)}">view</a>${p.error ? ` <span class="muted">${esc(truncate(p.error, 90))}</span>` : ''}</td></tr>`)
235
+ .join('')}</table>`;
236
+ }
237
+ function runsTable(runs) {
238
+ if (!runs.length)
239
+ return '<p class="muted">No reconciles recorded since this version was deployed.</p>';
240
+ return `<table><tr><th>started</th><th>trigger</th><th>config</th><th>status</th><th>took</th><th>summary</th></tr>${runs
241
+ .map((r) => `<tr><td><a href="/runs/${esc(r.id)}">${time(r.startedAt)}</a></td><td>${esc(r.trigger)}</td>
242
+ <td>${short(r.sha)}</td><td>${pill(r.status)}</td><td>${duration(r.startedAt, r.finishedAt)}</td>
243
+ <td class="muted">${esc(truncate(r.summary ?? '', 110))}</td></tr>`)
244
+ .join('')}</table>`;
245
+ }
246
+ function pagePlan(p) {
247
+ const live = p.status === 'queued' || p.status === 'running';
248
+ const r = p.result;
249
+ const changed = r?.modules.filter((m) => m.ops.length || m.error) ?? [];
250
+ const head = `<h1>Plan of <code>${esc(p.branch)}</code> ${pill(p.status)}</h1>
251
+ <p class="muted">${esc(p.id)} · requested ${time(p.requestedAt)}${p.finishedAt ? ` · took ${duration(p.startedAt, p.finishedAt)}` : ''}
252
+ ${p.sha ? ` · commit ${short(p.sha)}` : ''}${p.mainSha ? ` · main ${short(p.mainSha)}` : ''}</p>
253
+ ${p.error ? `<div class="box ${p.status === 'refused' ? 'warn' : 'err'}">${esc(p.error)}</div>` : ''}
254
+ ${p.overlappedRun ? '<div class="box warn">A real reconcile ran during this plan, so some state it read may have been mid-change. Plan again if anything looks odd.</div>' : ''}`;
255
+ const ahead = p.ahead?.length
256
+ ? `<h2>On the branch, not on main (${p.ahead.length})</h2><ul>${p.ahead
257
+ .map((c) => `<li>${short(c.sha)} ${esc(c.subject)}</li>`)
258
+ .join('')}</ul>`
259
+ : p.ahead
260
+ ? '<h2>On the branch, not on main</h2><p class="muted">Nothing — this is main.</p>'
261
+ : '';
262
+ const changes = r
263
+ ? `<h2>${r.totalOps} change(s)${r.failed ? ' before the plan aborted' : ''}</h2>
264
+ ${changed.length ? changed.map(moduleBlock).join('') : '<p>Nothing would change.</p>'}
265
+ ${r.unreachable.length ? `<div class="box warn">Not checked (host unreachable): ${esc(r.unreachable.join(', '))}</div>` : ''}
266
+ ${r.skipped.length ? `<div class="box err">Not evaluated (after the abort): ${esc(r.skipped.join(', '))}</div>` : ''}
267
+ ${r.warnings.map((w) => `<div class="box warn">${esc(w.scope)}: ${esc(w.message)}</div>`).join('')}`
268
+ : '';
269
+ return layout(`plan ${p.branch}`, `${head}${changes}${ahead}<h2>Log</h2><pre>${esc(p.log.join('\n'))}</pre>`, live);
270
+ }
271
+ function moduleBlock(m) {
272
+ return `<div class="box${m.error ? ' err' : ''}"><b><code>${esc(m.scope)}</code></b>${m.error ? `<br>ERROR: ${esc(m.error)}` : ''}<ul class="ops">${m.ops
273
+ .map((o) => `<li><span class="k-${esc(o.kind)}">[${esc(o.kind)}]</span> ${esc(o.summary)}</li>`)
274
+ .join('')}</ul></div>`;
275
+ }
276
+ function pageRun(r) {
277
+ return layout(`run ${r.id}`, `<h1>Reconcile ${pill(r.status)}</h1>
278
+ <p class="muted">${esc(r.id)} · ${esc(r.trigger)} · started ${time(r.startedAt)}${r.finishedAt ? ` · took ${duration(r.startedAt, r.finishedAt)}` : ''}${r.sha ? ` · config ${short(r.sha)}` : ''}</p>
279
+ ${r.summary ? `<div class="box${r.status === 'aborted' || r.status === 'error' ? ' err' : ''}">${esc(r.summary)}</div>` : ''}
280
+ <h2>Log</h2><pre>${esc(r.log.join('\n'))}</pre>`, r.status === 'running');
281
+ }
282
+ function pageError(message) {
283
+ return layout('error', `<div class="box err">${esc(message)}</div><p><a href="/">back</a></p>`);
284
+ }
285
+ function truncate(s, n) {
286
+ return s.length > n ? `${s.slice(0, n - 1)}…` : s;
287
+ }
288
+ //# sourceMappingURL=ui.js.map
package/dist/ui.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,YAAY,EAA0D,MAAM,WAAW,CAAA;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,SAAS,EAAwE,MAAM,YAAY,CAAA;AA2D5G,MAAM,QAAQ,GAAG,EAAE,GAAG,IAAI,CAAA;AAC1B,8DAA8D;AAC9D,MAAM,UAAU,GAAG,GAAG,CAAA;AAEtB,MAAM,UAAU,OAAO,CAAC,IAAe;IACrC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAEhC,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC;YACH,UAAU,CAAC,UAAU,CAAC,CAAA;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,2BAA2B;QAC7B,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,GAAG,EAAE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