@aviaratech/ai-delivery 0.3.35 → 0.3.36

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 (297) hide show
  1. package/CONTRIBUTING.md +12 -206
  2. package/README.md +57 -554
  3. package/dist/agent.d.ts +0 -2
  4. package/dist/agent.js +76 -16
  5. package/dist/agent.js.map +7 -1
  6. package/dist/agentReadiness.test.js +73 -67
  7. package/dist/agentReadiness.test.js.map +7 -1
  8. package/dist/boardReconcile.test.js +1651 -1590
  9. package/dist/boardReconcile.test.js.map +7 -1
  10. package/dist/build.test.js +130 -0
  11. package/dist/build.test.js.map +7 -0
  12. package/dist/callerErrors.test.js +105 -0
  13. package/dist/callerErrors.test.js.map +7 -0
  14. package/dist/cli.js +402 -515
  15. package/dist/cli.js.map +7 -1
  16. package/dist/cliResult.d.ts +2 -2
  17. package/dist/cliResult.js +42 -45
  18. package/dist/cliResult.js.map +7 -1
  19. package/dist/cliResult.test.js +424 -369
  20. package/dist/cliResult.test.js.map +7 -1
  21. package/dist/config/deliveryConfig.d.ts +288 -14
  22. package/dist/config/deliveryConfig.js +472 -390
  23. package/dist/config/deliveryConfig.js.map +7 -1
  24. package/dist/config/deliveryConfig.test.js +773 -649
  25. package/dist/config/deliveryConfig.test.js.map +7 -1
  26. package/dist/contributorChecks.test.js +1694 -916
  27. package/dist/contributorChecks.test.js.map +7 -1
  28. package/dist/currentConsumer.test.js +819 -737
  29. package/dist/currentConsumer.test.js.map +7 -1
  30. package/dist/currentTrackingScenario.test.js +499 -479
  31. package/dist/currentTrackingScenario.test.js.map +7 -1
  32. package/dist/delivery/common.js +160 -172
  33. package/dist/delivery/common.js.map +7 -1
  34. package/dist/delivery/delivery.test.js +509 -431
  35. package/dist/delivery/delivery.test.js.map +7 -1
  36. package/dist/delivery/evidence.d.ts +2 -2
  37. package/dist/delivery/evidence.js +133 -120
  38. package/dist/delivery/evidence.js.map +7 -1
  39. package/dist/delivery/index.js +7 -2
  40. package/dist/delivery/index.js.map +7 -1
  41. package/dist/delivery/legacy.js +65 -5
  42. package/dist/delivery/legacy.js.map +7 -1
  43. package/dist/delivery/policy.d.ts +10 -10
  44. package/dist/delivery/policy.js +211 -238
  45. package/dist/delivery/policy.js.map +7 -1
  46. package/dist/delivery/stage.d.ts +18 -18
  47. package/dist/delivery/stage.js +220 -235
  48. package/dist/delivery/stage.js.map +7 -1
  49. package/dist/deliveryBoard.d.ts +74 -0
  50. package/dist/deliveryBoard.js +644 -0
  51. package/dist/deliveryBoard.js.map +7 -0
  52. package/dist/deliveryBoard.test.js +649 -0
  53. package/dist/deliveryBoard.test.js.map +7 -0
  54. package/dist/deliveryHealth.test.js +179 -155
  55. package/dist/deliveryHealth.test.js.map +7 -1
  56. package/dist/dependencyCompatibility.test.js +154 -140
  57. package/dist/dependencyCompatibility.test.js.map +7 -1
  58. package/dist/directoryIndependent.test.js +417 -383
  59. package/dist/directoryIndependent.test.js.map +7 -1
  60. package/dist/dispatch.d.ts +16 -11
  61. package/dist/dispatch.js +329 -353
  62. package/dist/dispatch.js.map +7 -1
  63. package/dist/errors.d.ts +3 -3
  64. package/dist/errors.js +103 -96
  65. package/dist/errors.js.map +7 -1
  66. package/dist/fixtures/deliveryBoardReplay.d.ts +56 -0
  67. package/dist/fixtures/deliveryBoardReplay.js +617 -0
  68. package/dist/fixtures/deliveryBoardReplay.js.map +7 -0
  69. package/dist/fixtures/discovery.d.ts +59 -19
  70. package/dist/fixtures/discovery.js +96 -90
  71. package/dist/fixtures/discovery.js.map +7 -1
  72. package/dist/fixtures/inertEntrypointChild.js +57 -56
  73. package/dist/fixtures/inertEntrypointChild.js.map +7 -1
  74. package/dist/fixtures/inertEntrypoints.d.ts +1 -1
  75. package/dist/fixtures/inertEntrypoints.js +321 -276
  76. package/dist/fixtures/inertEntrypoints.js.map +7 -1
  77. package/dist/fixtures/inertTarget.d.ts +78 -7
  78. package/dist/fixtures/inertTarget.js +769 -691
  79. package/dist/fixtures/inertTarget.js.map +7 -1
  80. package/dist/fixtures/issue63.d.ts +4 -3
  81. package/dist/fixtures/issue63.js +260 -274
  82. package/dist/fixtures/issue63.js.map +7 -1
  83. package/dist/fixtures/issueProjectItems.d.ts +20 -0
  84. package/dist/fixtures/issueProjectItems.js +15 -0
  85. package/dist/fixtures/issueProjectItems.js.map +7 -0
  86. package/dist/fixtures/readView.d.ts +120 -0
  87. package/dist/fixtures/readView.js +172 -0
  88. package/dist/fixtures/readView.js.map +7 -0
  89. package/dist/fixtures/recordedGitHubFlows.d.ts +120 -0
  90. package/dist/fixtures/recordedGitHubFlows.js +109 -0
  91. package/dist/fixtures/recordedGitHubFlows.js.map +7 -0
  92. package/dist/genericCompatibility.test.js +64 -55
  93. package/dist/genericCompatibility.test.js.map +7 -1
  94. package/dist/git.js +73 -67
  95. package/dist/git.js.map +7 -1
  96. package/dist/gitProcess.d.ts +1 -1
  97. package/dist/gitProcess.js +58 -53
  98. package/dist/gitProcess.js.map +7 -1
  99. package/dist/github/client.d.ts +2 -2
  100. package/dist/github/client.js +484 -379
  101. package/dist/github/client.js.map +7 -1
  102. package/dist/github/commandIdentityPolicy.js +44 -52
  103. package/dist/github/commandIdentityPolicy.js.map +7 -1
  104. package/dist/github/discovery.d.ts +1 -0
  105. package/dist/github/discovery.js +197 -215
  106. package/dist/github/discovery.js.map +7 -1
  107. package/dist/github/discovery.test.js +223 -177
  108. package/dist/github/discovery.test.js.map +7 -1
  109. package/dist/github/issueHistory.d.ts +2 -2
  110. package/dist/github/issueHistory.js +117 -125
  111. package/dist/github/issueHistory.js.map +7 -1
  112. package/dist/github/machineAuth.d.ts +1 -1
  113. package/dist/github/machineAuth.js +126 -117
  114. package/dist/github/machineAuth.js.map +7 -1
  115. package/dist/github/machineAuth.test.js +755 -639
  116. package/dist/github/machineAuth.test.js.map +7 -1
  117. package/dist/github/nativeIssueMetadata.js +286 -273
  118. package/dist/github/nativeIssueMetadata.js.map +7 -1
  119. package/dist/github/projectDelivery.d.ts +18 -2
  120. package/dist/github/projectDelivery.js +615 -557
  121. package/dist/github/projectDelivery.js.map +7 -1
  122. package/dist/github/relationships.js +433 -389
  123. package/dist/github/relationships.js.map +7 -1
  124. package/dist/github/repo.d.ts +1 -0
  125. package/dist/github/repo.js +123 -96
  126. package/dist/github/repo.js.map +7 -1
  127. package/dist/index.js +3 -3
  128. package/dist/index.js.map +7 -1
  129. package/dist/issue.d.ts +40 -9
  130. package/dist/issue.js +2102 -1742
  131. package/dist/issue.js.map +7 -1
  132. package/dist/issue63History.test.js +40 -42
  133. package/dist/issue63History.test.js.map +7 -1
  134. package/dist/issue63Routes.test.js +154 -143
  135. package/dist/issue63Routes.test.js.map +7 -1
  136. package/dist/issueBatchUpdate.test.js +989 -885
  137. package/dist/issueBatchUpdate.test.js.map +7 -1
  138. package/dist/issueBlockerGuard.test.js +262 -226
  139. package/dist/issueBlockerGuard.test.js.map +7 -1
  140. package/dist/issueContract.d.ts +23 -4
  141. package/dist/issueContract.js +416 -395
  142. package/dist/issueContract.js.map +7 -1
  143. package/dist/issueContract.test.d.ts +4 -3
  144. package/dist/issueContract.test.js +358 -321
  145. package/dist/issueContract.test.js.map +7 -1
  146. package/dist/issueDates.test.js +235 -233
  147. package/dist/issueDates.test.js.map +7 -1
  148. package/dist/issueInfoReadback.test.js +304 -190
  149. package/dist/issueInfoReadback.test.js.map +7 -1
  150. package/dist/issueIntake.test.js +1945 -1732
  151. package/dist/issueIntake.test.js.map +7 -1
  152. package/dist/issueJournal.d.ts +40 -19
  153. package/dist/issueJournal.js +229 -138
  154. package/dist/issueJournal.js.map +7 -1
  155. package/dist/issueJournal.test.js +605 -422
  156. package/dist/issueJournal.test.js.map +7 -1
  157. package/dist/issueRollup.test.d.ts +1 -0
  158. package/dist/issueRollup.test.js +476 -0
  159. package/dist/issueRollup.test.js.map +7 -0
  160. package/dist/issueTracking.test.js +1059 -989
  161. package/dist/issueTracking.test.js.map +7 -1
  162. package/dist/issueWriteRecovery.test.d.ts +1 -0
  163. package/dist/issueWriteRecovery.test.js +260 -0
  164. package/dist/issueWriteRecovery.test.js.map +7 -0
  165. package/dist/lifecycle.test.js +112 -441
  166. package/dist/lifecycle.test.js.map +7 -1
  167. package/dist/logger.js +80 -74
  168. package/dist/logger.js.map +7 -1
  169. package/dist/mcp/index.js +116 -94
  170. package/dist/mcp/index.js.map +7 -1
  171. package/dist/mcp/tools.d.ts +264 -286
  172. package/dist/mcp/tools.js +267 -340
  173. package/dist/mcp/tools.js.map +7 -1
  174. package/dist/pluginAuthProbe.js +63 -52
  175. package/dist/pluginAuthProbe.js.map +7 -1
  176. package/dist/pluginAuthProbe.test.js +85 -62
  177. package/dist/pluginAuthProbe.test.js.map +7 -1
  178. package/dist/pluginCredentials.test.js +282 -259
  179. package/dist/pluginCredentials.test.js.map +7 -1
  180. package/dist/pluginDoctor.test.js +653 -588
  181. package/dist/pluginDoctor.test.js.map +7 -1
  182. package/dist/pluginInstaller.d.ts +7 -5
  183. package/dist/pluginInstaller.js +1173 -1229
  184. package/dist/pluginInstaller.js.map +7 -1
  185. package/dist/pluginInstaller.test.js +1842 -1423
  186. package/dist/pluginInstaller.test.js.map +7 -1
  187. package/dist/pluginPackaging.test.js +460 -409
  188. package/dist/pluginPackaging.test.js.map +7 -1
  189. package/dist/pr.d.ts +132 -94
  190. package/dist/pr.js +1521 -1323
  191. package/dist/pr.js.map +7 -1
  192. package/dist/pr.test.js +1678 -632
  193. package/dist/pr.test.js.map +7 -1
  194. package/dist/prAssociation.test.js +2419 -1788
  195. package/dist/prAssociation.test.js.map +7 -1
  196. package/dist/prDispatch.test.js +150 -89
  197. package/dist/prDispatch.test.js.map +7 -1
  198. package/dist/readView.d.ts +183 -0
  199. package/dist/readView.js +217 -0
  200. package/dist/readView.js.map +7 -0
  201. package/dist/readView.test.d.ts +1 -0
  202. package/dist/readView.test.js +119 -0
  203. package/dist/readView.test.js.map +7 -0
  204. package/dist/releaseReconciliation.test.js +267 -288
  205. package/dist/releaseReconciliation.test.js.map +7 -1
  206. package/dist/releaseWorkflow.test.js +2493 -422
  207. package/dist/releaseWorkflow.test.js.map +7 -1
  208. package/dist/review.d.ts +738 -2
  209. package/dist/review.js +601 -348
  210. package/dist/review.js.map +7 -1
  211. package/dist/review.test.js +1218 -812
  212. package/dist/review.test.js.map +7 -1
  213. package/dist/reviewSubmit.test.d.ts +1 -0
  214. package/dist/reviewSubmit.test.js +747 -0
  215. package/dist/reviewSubmit.test.js.map +7 -0
  216. package/dist/services/agentReadinessService.js +42 -37
  217. package/dist/services/agentReadinessService.js.map +7 -1
  218. package/dist/services/blockerGuardService.js +188 -188
  219. package/dist/services/blockerGuardService.js.map +7 -1
  220. package/dist/services/boardReconcileService.d.ts +125 -125
  221. package/dist/services/boardReconcileService.js +1295 -1421
  222. package/dist/services/boardReconcileService.js.map +7 -1
  223. package/dist/services/deliveryAdmission.js +131 -154
  224. package/dist/services/deliveryAdmission.js.map +7 -1
  225. package/dist/services/deliveryHealthService.js +197 -199
  226. package/dist/services/deliveryHealthService.js.map +7 -1
  227. package/dist/services/legacyIssueMigration.js +263 -277
  228. package/dist/services/legacyIssueMigration.js.map +7 -1
  229. package/dist/services/worktreeRegistry.d.ts +27 -119
  230. package/dist/services/worktreeRegistry.js +765 -1182
  231. package/dist/services/worktreeRegistry.js.map +7 -1
  232. package/dist/stagedChecks.test.js +396 -194
  233. package/dist/stagedChecks.test.js.map +7 -1
  234. package/dist/start.test.js +99 -95
  235. package/dist/start.test.js.map +7 -1
  236. package/dist/stdoutRegression.test.js +353 -352
  237. package/dist/stdoutRegression.test.js.map +7 -1
  238. package/dist/targetPolicyDiscovery.test.js +141 -143
  239. package/dist/targetPolicyDiscovery.test.js.map +7 -1
  240. package/dist/targetPolicyEntrypoints.test.js +308 -269
  241. package/dist/targetPolicyEntrypoints.test.js.map +7 -1
  242. package/dist/targetPolicyLocal.test.js +580 -1051
  243. package/dist/targetPolicyLocal.test.js.map +7 -1
  244. package/dist/targetPolicyRoutes.test.js +305 -281
  245. package/dist/targetPolicyRoutes.test.js.map +7 -1
  246. package/dist/targetRepositoryExecution.test.d.ts +1 -0
  247. package/dist/targetRepositoryExecution.test.js +463 -0
  248. package/dist/targetRepositoryExecution.test.js.map +7 -0
  249. package/dist/terminalMessages.js +41 -35
  250. package/dist/terminalMessages.js.map +7 -1
  251. package/dist/toolOutput.d.ts +2 -0
  252. package/dist/toolOutput.js +36 -0
  253. package/dist/toolOutput.js.map +7 -0
  254. package/dist/toolOutput.test.d.ts +1 -0
  255. package/dist/toolOutput.test.js +240 -0
  256. package/dist/toolOutput.test.js.map +7 -0
  257. package/dist/utils/atomicJson.js +84 -76
  258. package/dist/utils/atomicJson.js.map +7 -1
  259. package/dist/utils/filesystem.js +15 -18
  260. package/dist/utils/filesystem.js.map +7 -1
  261. package/dist/utils/lockfile.js +68 -71
  262. package/dist/utils/lockfile.js.map +7 -1
  263. package/dist/verification.d.ts +1 -19
  264. package/dist/verification.js +1020 -1939
  265. package/dist/verification.js.map +7 -1
  266. package/dist/verificationGate.test.js +127 -117
  267. package/dist/verificationGate.test.js.map +7 -1
  268. package/dist/version.js +23 -24
  269. package/dist/version.js.map +7 -1
  270. package/dist/worktree.d.ts +3 -15
  271. package/dist/worktree.js +97 -177
  272. package/dist/worktree.js.map +7 -1
  273. package/package.json +9 -8
  274. package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
  275. package/plugins/ai-delivery/README.md +47 -156
  276. package/plugins/ai-delivery/plugin.json +1 -1
  277. package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +238 -44
  278. package/plugins/ai-delivery/runtime/dist/cli.js +358 -115
  279. package/plugins/ai-delivery/runtime/package.json +1 -1
  280. package/plugins/ai-delivery/skills/intake-create/SKILL.md +14 -78
  281. package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +35 -36
  282. package/plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md +14 -15
  283. package/dist/investigationCompletion.test.js +0 -728
  284. package/dist/investigationCompletion.test.js.map +0 -1
  285. package/dist/setup.d.ts +0 -60
  286. package/dist/setup.js +0 -585
  287. package/dist/setup.js.map +0 -1
  288. package/dist/setup.test.js +0 -3329
  289. package/dist/setup.test.js.map +0 -1
  290. package/dist/worktreeTransition.d.ts +0 -211
  291. package/dist/worktreeTransition.js +0 -1037
  292. package/dist/worktreeTransition.js.map +0 -1
  293. package/dist/worktreeTransition.test.js +0 -1191
  294. package/dist/worktreeTransition.test.js.map +0 -1
  295. /package/dist/{investigationCompletion.test.d.ts → build.test.d.ts} +0 -0
  296. /package/dist/{setup.test.d.ts → callerErrors.test.d.ts} +0 -0
  297. /package/dist/{worktreeTransition.test.d.ts → deliveryBoard.test.d.ts} +0 -0
@@ -1,165 +1,142 @@
1
- import { createHash } from 'node:crypto';
2
- import { readFileSync, readdirSync, realpathSync } from 'node:fs';
3
- import { dirname, join } from 'node:path';
4
- import { z } from 'zod';
5
- import { loadDeliveryConfig } from '../config/deliveryConfig.js';
6
- import { assertPrivateFile } from '../delivery/common.js';
7
- import { digestValue } from '../delivery/index.js';
8
- import { DeliveryError } from '../errors.js';
9
- import { gitCommonDir, gitRoot } from '../git.js';
1
+ import { createHash } from "node:crypto";
2
+ import { readFileSync, readdirSync, realpathSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ import { z } from "zod";
5
+ import { loadDeliveryConfig } from "../config/deliveryConfig.js";
6
+ import { assertPrivateFile } from "../delivery/common.js";
7
+ import { digestValue } from "../delivery/index.js";
8
+ import { DeliveryError } from "../errors.js";
9
+ import { gitCommonDir, gitRoot } from "../git.js";
10
10
  const Sha256 = z.string().regex(/^sha256:[a-f0-9]{64}$/u);
11
11
  const CAPABILITY = 2;
12
- export const RuntimeAdmissionSchema = z
13
- .object({
14
- admissionId: Sha256,
15
- capability: z.object({ cli: z.number().int().positive(), mcp: z.number().int().positive() }).strict(),
16
- cliPath: z.string().min(1),
17
- cliSha256: Sha256,
18
- configDigest: Sha256,
19
- mcpLauncherPath: z.string().min(1),
20
- mcpLauncherSha256: Sha256,
21
- packageDistSha256: Sha256,
22
- packageManifestSha256: Sha256,
23
- packageVersion: z.string().min(1),
24
- pluginManifestPath: z.string().min(1),
25
- pluginManifestSha256: Sha256,
26
- repository: z.string().min(1),
27
- schemaVersion: z.literal('ai-delivery.runtime-admission@2'),
28
- sourceArchiveSha256: Sha256,
29
- sourceCommit: z.string().regex(/^[a-f0-9]{40}$/u),
30
- })
31
- .strict()
32
- .superRefine((value, context) => {
33
- const { admissionId, ...content } = value;
34
- if (admissionId !== digestValue(content)) {
35
- context.addIssue({ code: 'custom', message: 'Runtime admission identity is invalid.' });
36
- }
12
+ const RuntimeAdmissionSchema = z.object({
13
+ admissionId: Sha256,
14
+ capability: z.object({ cli: z.number().int().positive(), mcp: z.number().int().positive() }).strict(),
15
+ cliPath: z.string().min(1),
16
+ cliSha256: Sha256,
17
+ configDigest: Sha256,
18
+ mcpLauncherPath: z.string().min(1),
19
+ mcpLauncherSha256: Sha256,
20
+ packageDistSha256: Sha256,
21
+ packageManifestSha256: Sha256,
22
+ packageVersion: z.string().min(1),
23
+ pluginManifestPath: z.string().min(1),
24
+ pluginManifestSha256: Sha256,
25
+ repository: z.string().min(1),
26
+ schemaVersion: z.literal("ai-delivery.runtime-admission@2"),
27
+ sourceArchiveSha256: Sha256,
28
+ sourceCommit: z.string().regex(/^[a-f0-9]{40}$/u)
29
+ }).strict().superRefine((value, context) => {
30
+ const { admissionId, ...content } = value;
31
+ if (admissionId !== digestValue(content)) {
32
+ context.addIssue({ code: "custom", message: "Runtime admission identity is invalid." });
33
+ }
37
34
  });
38
- export function fileDigest(path) {
39
- return `sha256:${createHash('sha256').update(readFileSync(path)).digest('hex')}`;
35
+ function fileDigest(path) {
36
+ return `sha256:${createHash("sha256").update(readFileSync(path)).digest("hex")}`;
40
37
  }
41
- export function directoryDigest(path) {
42
- const entries = [];
43
- const visit = (directory, relative) => {
44
- for (const entry of readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0)) {
45
- const child = join(directory, entry.name);
46
- const childRelative = relative ? `${relative}/${entry.name}` : entry.name;
47
- if (entry.isDirectory())
48
- visit(child, childRelative);
49
- else if (entry.isFile())
50
- entries.push({ path: childRelative, sha256: fileDigest(child) });
51
- else
52
- throw new DeliveryError('Runtime distribution contains an unsupported link or file type.');
53
- }
54
- };
55
- visit(path, '');
56
- if (entries.length === 0)
57
- throw new DeliveryError('Runtime distribution is empty.');
58
- return digestValue(entries);
38
+ function directoryDigest(path) {
39
+ const entries = [];
40
+ const visit = (directory, relative) => {
41
+ for (const entry of readdirSync(directory, { withFileTypes: true }).sort(
42
+ (left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0
43
+ )) {
44
+ const child = join(directory, entry.name);
45
+ const childRelative = relative ? `${relative}/${entry.name}` : entry.name;
46
+ if (entry.isDirectory()) visit(child, childRelative);
47
+ else if (entry.isFile()) entries.push({ path: childRelative, sha256: fileDigest(child) });
48
+ else throw new DeliveryError("Runtime distribution contains an unsupported link or file type.");
49
+ }
50
+ };
51
+ visit(path, "");
52
+ if (entries.length === 0) throw new DeliveryError("Runtime distribution is empty.");
53
+ return digestValue(entries);
59
54
  }
60
55
  function manifest(path) {
61
- const value = JSON.parse(readFileSync(path, 'utf8'));
62
- if (typeof value !== 'object' || value === null || Array.isArray(value)) {
63
- throw new DeliveryError('Runtime package or plugin manifest is invalid.');
64
- }
65
- return value;
56
+ const value = JSON.parse(readFileSync(path, "utf8"));
57
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
58
+ throw new DeliveryError("Runtime package or plugin manifest is invalid.");
59
+ }
60
+ return value;
66
61
  }
67
- /**
68
- * An installer-owned, private, immutable admission binds the actual CLI and MCP
69
- * bytes to one source archive and the consuming repository configuration.
70
- * Neither invocation surface can refresh its own admission during a mutation.
71
- */
72
- export async function assertDeliveryRuntimeAdmitted(input) {
73
- const root = gitRoot(input.repoRoot);
74
- const loaded = input.configuration ??
75
- (await loadDeliveryConfig(root, input.personalAuth === undefined ? {} : { personalAuth: input.personalAuth }));
76
- const path = join(gitCommonDir(root), 'ai-delivery', 'runtime-admission.json');
77
- let admission;
78
- try {
79
- admission = RuntimeAdmissionSchema.parse(JSON.parse(assertPrivateFile(path).toString('utf8')));
80
- }
81
- catch {
82
- throw new DeliveryError('Missing or invalid private ai-delivery runtime admission; refresh the installed binding before lifecycle mutation.');
83
- }
84
- return validateRuntimeAdmission(admission, loaded, input.runtimeEntryPath);
62
+ async function assertDeliveryRuntimeAdmitted(input) {
63
+ const root = gitRoot(input.repoRoot);
64
+ const loaded = input.configuration ?? await loadDeliveryConfig(root, input.personalAuth === void 0 ? {} : { personalAuth: input.personalAuth });
65
+ const path = join(gitCommonDir(root), "ai-delivery", "runtime-admission.json");
66
+ let admission;
67
+ try {
68
+ admission = RuntimeAdmissionSchema.parse(JSON.parse(assertPrivateFile(path).toString("utf8")));
69
+ } catch {
70
+ throw new DeliveryError(
71
+ "Missing or invalid private ai-delivery runtime admission; refresh the installed binding before lifecycle mutation."
72
+ );
73
+ }
74
+ return validateRuntimeAdmission(admission, loaded, input.runtimeEntryPath);
85
75
  }
86
- /** @internal Shared installed-byte validation for explicit setup and lifecycle admission. */
87
- export function validateRuntimeAdmission(admission, loaded, runtimeEntryPath) {
88
- const entry = runtimeEntryPath ?? process.argv[1];
89
- if (!entry)
90
- throw new DeliveryError('Running ai-delivery entry path is unavailable.');
91
- try {
92
- const cliPath = realpathSync(entry);
93
- const launcherPath = realpathSync(admission.mcpLauncherPath);
94
- const pluginManifestPath = realpathSync(admission.pluginManifestPath);
95
- const distPath = dirname(cliPath);
96
- const packageManifestPath = join(dirname(distPath), 'package.json');
97
- const packageManifest = manifest(packageManifestPath);
98
- const pluginManifest = manifest(pluginManifestPath);
99
- // Preserve the original short-circuit order and refusal; expose only the first predicate's fixed name.
100
- const failedPredicate = (cliPath !== admission.cliPath && 'cliPath') ||
101
- (launcherPath !== admission.mcpLauncherPath && 'mcpLauncherPath') ||
102
- (pluginManifestPath !== admission.pluginManifestPath && 'pluginManifestPath') ||
103
- (realpathSync(join(dirname(dirname(launcherPath)), '.claude-plugin', 'plugin.json')) !== pluginManifestPath &&
104
- 'launcherPluginManifestPath') ||
105
- (fileDigest(cliPath) !== admission.cliSha256 && 'cliSha256') ||
106
- (fileDigest(launcherPath) !== admission.mcpLauncherSha256 && 'mcpLauncherSha256') ||
107
- (fileDigest(pluginManifestPath) !== admission.pluginManifestSha256 && 'pluginManifestSha256') ||
108
- (fileDigest(packageManifestPath) !== admission.packageManifestSha256 && 'packageManifestSha256') ||
109
- (directoryDigest(distPath) !== admission.packageDistSha256 && 'packageDistSha256') ||
110
- (admission.configDigest !== loaded.configDigest && 'configDigest') ||
111
- (admission.repository !== loaded.config.repository && 'repository') ||
112
- (admission.capability.cli !== CAPABILITY && 'cliCapability') ||
113
- (admission.capability.mcp !== CAPABILITY && 'mcpCapability') ||
114
- (packageManifest.name !== '@aviaratech/ai-delivery' && 'packageName') ||
115
- (packageManifest.version !== admission.packageVersion && 'packageVersion') ||
116
- (pluginManifest.name !== 'ai-delivery' && 'pluginName') ||
117
- (pluginManifest.packageVersion !== admission.packageVersion && 'pluginPackageVersion') ||
118
- (pluginManifest.deliveryCapabilityVersion !== CAPABILITY && 'pluginCapability');
119
- if (failedPredicate) {
120
- throw new DeliveryError(`Installed CLI/MCP source, capability or repository admission disagrees with the running delivery contract. Failed predicate: ${failedPredicate}.`);
121
- }
122
- }
123
- catch (error) {
124
- if (error instanceof DeliveryError)
125
- throw error;
126
- throw new DeliveryError('Installed CLI/MCP source or capability readback is unavailable.');
76
+ function validateRuntimeAdmission(admission, loaded, runtimeEntryPath) {
77
+ const entry = runtimeEntryPath ?? process.argv[1];
78
+ if (!entry) throw new DeliveryError("Running ai-delivery entry path is unavailable.");
79
+ try {
80
+ const cliPath = realpathSync(entry);
81
+ const launcherPath = realpathSync(admission.mcpLauncherPath);
82
+ const pluginManifestPath = realpathSync(admission.pluginManifestPath);
83
+ const distPath = dirname(cliPath);
84
+ const packageManifestPath = join(dirname(distPath), "package.json");
85
+ const packageManifest = manifest(packageManifestPath);
86
+ const pluginManifest = manifest(pluginManifestPath);
87
+ const failedPredicate = cliPath !== admission.cliPath && "cliPath" || launcherPath !== admission.mcpLauncherPath && "mcpLauncherPath" || pluginManifestPath !== admission.pluginManifestPath && "pluginManifestPath" || realpathSync(join(dirname(dirname(launcherPath)), ".claude-plugin", "plugin.json")) !== pluginManifestPath && "launcherPluginManifestPath" || fileDigest(cliPath) !== admission.cliSha256 && "cliSha256" || fileDigest(launcherPath) !== admission.mcpLauncherSha256 && "mcpLauncherSha256" || fileDigest(pluginManifestPath) !== admission.pluginManifestSha256 && "pluginManifestSha256" || fileDigest(packageManifestPath) !== admission.packageManifestSha256 && "packageManifestSha256" || directoryDigest(distPath) !== admission.packageDistSha256 && "packageDistSha256" || admission.configDigest !== loaded.configDigest && "configDigest" || admission.repository !== loaded.config.repository && "repository" || admission.capability.cli !== CAPABILITY && "cliCapability" || admission.capability.mcp !== CAPABILITY && "mcpCapability" || packageManifest.name !== "@aviaratech/ai-delivery" && "packageName" || packageManifest.version !== admission.packageVersion && "packageVersion" || pluginManifest.name !== "ai-delivery" && "pluginName" || pluginManifest.packageVersion !== admission.packageVersion && "pluginPackageVersion" || pluginManifest.deliveryCapabilityVersion !== CAPABILITY && "pluginCapability";
88
+ if (failedPredicate) {
89
+ throw new DeliveryError(
90
+ `Installed CLI/MCP source, capability or repository admission disagrees with the running delivery contract. Failed predicate: ${failedPredicate}.`
91
+ );
127
92
  }
128
- return admission;
93
+ } catch (error) {
94
+ if (error instanceof DeliveryError) throw error;
95
+ throw new DeliveryError("Installed CLI/MCP source or capability readback is unavailable.");
96
+ }
97
+ return admission;
129
98
  }
130
- /** @internal Build the existing schema from actual installed bytes, never caller-supplied hashes. */
131
- export function buildRuntimeAdmission(input) {
132
- for (const path of [input.cliPath, input.mcpLauncherPath, input.pluginManifestPath]) {
133
- if (realpathSync(path) !== path)
134
- throw new DeliveryError('Installed runtime paths must be canonical regular files.');
135
- }
136
- const dist = dirname(input.cliPath);
137
- const packagePath = join(dirname(dist), 'package.json');
138
- const packageManifest = manifest(packagePath);
139
- const bin = packageManifest.bin;
140
- if (typeof bin !== 'object' ||
141
- bin === null ||
142
- !('ai-delivery' in bin) ||
143
- bin['ai-delivery'] !== './dist/cli.js') {
144
- throw new DeliveryError('Installed package CLI entry is not the supported ai-delivery executable.');
145
- }
146
- const content = {
147
- capability: { cli: CAPABILITY, mcp: CAPABILITY },
148
- cliPath: input.cliPath,
149
- cliSha256: fileDigest(input.cliPath),
150
- configDigest: input.configuration.configDigest,
151
- mcpLauncherPath: input.mcpLauncherPath,
152
- mcpLauncherSha256: fileDigest(input.mcpLauncherPath),
153
- packageDistSha256: directoryDigest(dist),
154
- packageManifestSha256: fileDigest(packagePath),
155
- packageVersion: input.packageVersion,
156
- pluginManifestPath: input.pluginManifestPath,
157
- pluginManifestSha256: fileDigest(input.pluginManifestPath),
158
- repository: input.configuration.config.repository,
159
- schemaVersion: 'ai-delivery.runtime-admission@2',
160
- sourceArchiveSha256: input.sourceArchiveSha256,
161
- sourceCommit: input.sourceCommit,
162
- };
163
- return validateRuntimeAdmission(RuntimeAdmissionSchema.parse({ ...content, admissionId: digestValue(content) }), input.configuration, input.cliPath);
99
+ function buildRuntimeAdmission(input) {
100
+ for (const path of [input.cliPath, input.mcpLauncherPath, input.pluginManifestPath]) {
101
+ if (realpathSync(path) !== path)
102
+ throw new DeliveryError("Installed runtime paths must be canonical regular files.");
103
+ }
104
+ const dist = dirname(input.cliPath);
105
+ const packagePath = join(dirname(dist), "package.json");
106
+ const packageManifest = manifest(packagePath);
107
+ const bin = packageManifest.bin;
108
+ if (typeof bin !== "object" || bin === null || !("ai-delivery" in bin) || bin["ai-delivery"] !== "./dist/cli.js") {
109
+ throw new DeliveryError("Installed package CLI entry is not the supported ai-delivery executable.");
110
+ }
111
+ const content = {
112
+ capability: { cli: CAPABILITY, mcp: CAPABILITY },
113
+ cliPath: input.cliPath,
114
+ cliSha256: fileDigest(input.cliPath),
115
+ configDigest: input.configuration.configDigest,
116
+ mcpLauncherPath: input.mcpLauncherPath,
117
+ mcpLauncherSha256: fileDigest(input.mcpLauncherPath),
118
+ packageDistSha256: directoryDigest(dist),
119
+ packageManifestSha256: fileDigest(packagePath),
120
+ packageVersion: input.packageVersion,
121
+ pluginManifestPath: input.pluginManifestPath,
122
+ pluginManifestSha256: fileDigest(input.pluginManifestPath),
123
+ repository: input.configuration.config.repository,
124
+ schemaVersion: "ai-delivery.runtime-admission@2",
125
+ sourceArchiveSha256: input.sourceArchiveSha256,
126
+ sourceCommit: input.sourceCommit
127
+ };
128
+ return validateRuntimeAdmission(
129
+ RuntimeAdmissionSchema.parse({ ...content, admissionId: digestValue(content) }),
130
+ input.configuration,
131
+ input.cliPath
132
+ );
164
133
  }
165
- //# sourceMappingURL=deliveryAdmission.js.map
134
+ export {
135
+ RuntimeAdmissionSchema,
136
+ assertDeliveryRuntimeAdmitted,
137
+ buildRuntimeAdmission,
138
+ directoryDigest,
139
+ fileDigest,
140
+ validateRuntimeAdmission
141
+ };
142
+ //# sourceMappingURL=deliveryAdmission.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"deliveryAdmission.js","sourceRoot":"","sources":["../../src/services/deliveryAdmission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAsD,MAAM,6BAA6B,CAAC;AACrH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;A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E,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE;QAChD,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC;QACpC,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC,YAAY;QAC9C,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,iBAAiB,EAAE,UAAU,CAAC,KAAK,CAAC,eAAe,CAAC;QACpD,iBAAiB,EAAE,eAAe,CAAC,IAAI,CAAC;QACxC,qBAAqB,EAAE,UAAU,CAAC,WAAW,CAAC;QAC9C,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;QAC5C,oBAAoB,EAAE,UAAU,CAAC,KAAK,CAAC,kBAAkB,CAAC;QAC1D,UAAU,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU;QACjD,aAAa,EAAE,iCAA0C;QACzD,mBAAmB,EAAE,KAAK,CAAC,mBAAmB;QAC9C,YAAY,EAAE,KAAK,CAAC,YAAY;KACjC,CAAC;IACF,OAAO,wBAAwB,CAC7B,sBAAsB,CAAC,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,EAC/E,KAAK,CAAC,aAAa,EACnB,KAAK,CAAC,OAAO,CACd,CAAC;AACJ,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/services/deliveryAdmission.ts"],
4
+ "sourcesContent": ["import { createHash } from 'node:crypto';\nimport { readFileSync, readdirSync, realpathSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { z } from 'zod';\n\nimport { loadDeliveryConfig, type LoadedDeliveryConfig, type LoadedGitHubConfig } from '../config/deliveryConfig.js';\nimport { assertPrivateFile } from '../delivery/common.js';\nimport { digestValue } from '../delivery/index.js';\nimport { DeliveryError } from '../errors.js';\nimport { gitCommonDir, gitRoot } from '../git.js';\n\nconst Sha256 = z.string().regex(/^sha256:[a-f0-9]{64}$/u);\nconst CAPABILITY = 2;\nexport const RuntimeAdmissionSchema = z\n .object({\n admissionId: Sha256,\n capability: z.object({ cli: z.number().int().positive(), mcp: z.number().int().positive() }).strict(),\n cliPath: z.string().min(1),\n cliSha256: Sha256,\n configDigest: Sha256,\n mcpLauncherPath: z.string().min(1),\n mcpLauncherSha256: Sha256,\n packageDistSha256: Sha256,\n packageManifestSha256: Sha256,\n packageVersion: z.string().min(1),\n pluginManifestPath: z.string().min(1),\n pluginManifestSha256: Sha256,\n repository: z.string().min(1),\n schemaVersion: z.literal('ai-delivery.runtime-admission@2'),\n sourceArchiveSha256: Sha256,\n sourceCommit: z.string().regex(/^[a-f0-9]{40}$/u),\n })\n .strict()\n .superRefine((value, context) => {\n const { admissionId, ...content } = value;\n if (admissionId !== digestValue(content)) {\n context.addIssue({ code: 'custom', message: 'Runtime admission identity is invalid.' });\n }\n });\n\nexport type RuntimeAdmission = z.infer<typeof RuntimeAdmissionSchema>;\n\nexport function fileDigest(path: string): string {\n return `sha256:${createHash('sha256').update(readFileSync(path)).digest('hex')}`;\n}\n\nexport function directoryDigest(path: string): string {\n const entries: { path: string; sha256: string }[] = [];\n const visit = (directory: string, relative: string): void => {\n for (const entry of readdirSync(directory, { withFileTypes: true }).sort((left, right) =>\n left.name < right.name ? -1 : left.name > right.name ? 1 : 0,\n )) {\n const child = join(directory, entry.name);\n const childRelative = relative ? `${relative}/${entry.name}` : entry.name;\n if (entry.isDirectory()) visit(child, childRelative);\n else if (entry.isFile()) entries.push({ path: childRelative, sha256: fileDigest(child) });\n else throw new DeliveryError('Runtime distribution contains an unsupported link or file type.');\n }\n };\n visit(path, '');\n if (entries.length === 0) throw new DeliveryError('Runtime distribution is empty.');\n return digestValue(entries);\n}\n\nfunction manifest(path: string): Record<string, unknown> {\n const value: unknown = JSON.parse(readFileSync(path, 'utf8')) as unknown;\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new DeliveryError('Runtime package or plugin manifest is invalid.');\n }\n return value as Record<string, unknown>;\n}\n\n/**\n * An installer-owned, private, immutable admission binds the actual CLI and MCP\n * bytes to one source archive and the consuming repository configuration.\n * Neither invocation surface can refresh its own admission during a mutation.\n */\nexport async function assertDeliveryRuntimeAdmitted(input: {\n repoRoot: string;\n runtimeEntryPath?: string;\n personalAuth?: boolean;\n configuration?: LoadedDeliveryConfig | LoadedGitHubConfig;\n}): Promise<RuntimeAdmission> {\n const root = gitRoot(input.repoRoot);\n const loaded =\n input.configuration ??\n (await loadDeliveryConfig(root, input.personalAuth === undefined ? {} : { personalAuth: input.personalAuth }));\n const path = join(gitCommonDir(root), 'ai-delivery', 'runtime-admission.json');\n let admission: RuntimeAdmission;\n try {\n admission = RuntimeAdmissionSchema.parse(JSON.parse(assertPrivateFile(path).toString('utf8')) as unknown);\n } catch {\n throw new DeliveryError(\n 'Missing or invalid private ai-delivery runtime admission; refresh the installed binding before lifecycle mutation.',\n );\n }\n return validateRuntimeAdmission(admission, loaded, input.runtimeEntryPath);\n}\n\n/** @internal Shared installed-byte validation for explicit setup and lifecycle admission. */\nexport function validateRuntimeAdmission(\n admission: RuntimeAdmission,\n loaded: LoadedDeliveryConfig | LoadedGitHubConfig,\n runtimeEntryPath?: string,\n): RuntimeAdmission {\n const entry = runtimeEntryPath ?? process.argv[1];\n if (!entry) throw new DeliveryError('Running ai-delivery entry path is unavailable.');\n try {\n const cliPath = realpathSync(entry);\n const launcherPath = realpathSync(admission.mcpLauncherPath);\n const pluginManifestPath = realpathSync(admission.pluginManifestPath);\n const distPath = dirname(cliPath);\n const packageManifestPath = join(dirname(distPath), 'package.json');\n const packageManifest = manifest(packageManifestPath);\n const pluginManifest = manifest(pluginManifestPath);\n // Preserve the original short-circuit order and refusal; expose only the first predicate's fixed name.\n const failedPredicate =\n (cliPath !== admission.cliPath && 'cliPath') ||\n (launcherPath !== admission.mcpLauncherPath && 'mcpLauncherPath') ||\n (pluginManifestPath !== admission.pluginManifestPath && 'pluginManifestPath') ||\n (realpathSync(join(dirname(dirname(launcherPath)), '.claude-plugin', 'plugin.json')) !== pluginManifestPath &&\n 'launcherPluginManifestPath') ||\n (fileDigest(cliPath) !== admission.cliSha256 && 'cliSha256') ||\n (fileDigest(launcherPath) !== admission.mcpLauncherSha256 && 'mcpLauncherSha256') ||\n (fileDigest(pluginManifestPath) !== admission.pluginManifestSha256 && 'pluginManifestSha256') ||\n (fileDigest(packageManifestPath) !== admission.packageManifestSha256 && 'packageManifestSha256') ||\n (directoryDigest(distPath) !== admission.packageDistSha256 && 'packageDistSha256') ||\n (admission.configDigest !== loaded.configDigest && 'configDigest') ||\n (admission.repository !== loaded.config.repository && 'repository') ||\n (admission.capability.cli !== CAPABILITY && 'cliCapability') ||\n (admission.capability.mcp !== CAPABILITY && 'mcpCapability') ||\n (packageManifest.name !== '@aviaratech/ai-delivery' && 'packageName') ||\n (packageManifest.version !== admission.packageVersion && 'packageVersion') ||\n (pluginManifest.name !== 'ai-delivery' && 'pluginName') ||\n (pluginManifest.packageVersion !== admission.packageVersion && 'pluginPackageVersion') ||\n (pluginManifest.deliveryCapabilityVersion !== CAPABILITY && 'pluginCapability');\n if (failedPredicate) {\n throw new DeliveryError(\n `Installed CLI/MCP source, capability or repository admission disagrees with the running delivery contract. Failed predicate: ${failedPredicate}.`,\n );\n }\n } catch (error) {\n if (error instanceof DeliveryError) throw error;\n throw new DeliveryError('Installed CLI/MCP source or capability readback is unavailable.');\n }\n return admission;\n}\n\n/** @internal Build the existing schema from actual installed bytes, never caller-supplied hashes. */\nexport function buildRuntimeAdmission(input: {\n cliPath: string;\n mcpLauncherPath: string;\n pluginManifestPath: string;\n packageVersion: string;\n sourceArchiveSha256: string;\n sourceCommit: string;\n configuration: LoadedDeliveryConfig | LoadedGitHubConfig;\n}): RuntimeAdmission {\n for (const path of [input.cliPath, input.mcpLauncherPath, input.pluginManifestPath]) {\n if (realpathSync(path) !== path)\n throw new DeliveryError('Installed runtime paths must be canonical regular files.');\n }\n const dist = dirname(input.cliPath);\n const packagePath = join(dirname(dist), 'package.json');\n const packageManifest = manifest(packagePath);\n const bin = packageManifest.bin;\n if (\n typeof bin !== 'object' ||\n bin === null ||\n !('ai-delivery' in bin) ||\n (bin as Record<string, unknown>)['ai-delivery'] !== './dist/cli.js'\n ) {\n throw new DeliveryError('Installed package CLI entry is not the supported ai-delivery executable.');\n }\n const content = {\n capability: { cli: CAPABILITY, mcp: CAPABILITY },\n cliPath: input.cliPath,\n cliSha256: fileDigest(input.cliPath),\n configDigest: input.configuration.configDigest,\n mcpLauncherPath: input.mcpLauncherPath,\n mcpLauncherSha256: fileDigest(input.mcpLauncherPath),\n packageDistSha256: directoryDigest(dist),\n packageManifestSha256: fileDigest(packagePath),\n packageVersion: input.packageVersion,\n pluginManifestPath: input.pluginManifestPath,\n pluginManifestSha256: fileDigest(input.pluginManifestPath),\n repository: input.configuration.config.repository,\n schemaVersion: 'ai-delivery.runtime-admission@2' as const,\n sourceArchiveSha256: input.sourceArchiveSha256,\n sourceCommit: input.sourceCommit,\n };\n return validateRuntimeAdmission(\n RuntimeAdmissionSchema.parse({ ...content, admissionId: digestValue(content) }),\n input.configuration,\n input.cliPath,\n );\n}\n"],
5
+ "mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,cAAc,aAAa,oBAAoB;AACxD,SAAS,SAAS,YAAY;AAC9B,SAAS,SAAS;AAElB,SAAS,0BAA8E;AACvF,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,cAAc,eAAe;AAEtC,MAAM,SAAS,EAAE,OAAO,EAAE,MAAM,wBAAwB;AACxD,MAAM,aAAa;AACZ,MAAM,yBAAyB,EACnC,OAAO;AAAA,EACN,aAAa;AAAA,EACb,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS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