infraweaver 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 (524) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +244 -0
  3. package/dist/agents/claude.d.ts +113 -0
  4. package/dist/agents/claudePretoolGate.d.ts +137 -0
  5. package/dist/agents/dispatchMetrics.d.ts +77 -0
  6. package/dist/agents/gateServer.d.ts +7 -0
  7. package/dist/agents/index.d.ts +6 -0
  8. package/dist/agents/nativeFsDenies.d.ts +46 -0
  9. package/dist/agents/opencode.d.ts +284 -0
  10. package/dist/agents/opencodePlugin.d.ts +96 -0
  11. package/dist/agents/opencodeShared.d.ts +40 -0
  12. package/dist/agents/postRun.d.ts +126 -0
  13. package/dist/agents/reviewer.d.ts +41 -0
  14. package/dist/agents/sessionLabeler.d.ts +97 -0
  15. package/dist/agents/shared.d.ts +246 -0
  16. package/dist/agents/subagentModels.d.ts +19 -0
  17. package/dist/agents/tokenQuota.d.ts +118 -0
  18. package/dist/agents/writeGateSource.d.ts +22 -0
  19. package/dist/agents/writePolicy.d.ts +79 -0
  20. package/dist/brand.d.ts +67 -0
  21. package/dist/cli.mjs +247846 -0
  22. package/dist/external.d.ts +227 -0
  23. package/dist/i18n/scaffolding.d.ts +59 -0
  24. package/dist/index.d.ts +6 -0
  25. package/dist/index.js +247061 -0
  26. package/dist/internal/index.d.ts +18 -0
  27. package/dist/internal.js +2398 -0
  28. package/dist/lifecycle.d.ts +2 -0
  29. package/dist/main.d.ts +8 -0
  30. package/dist/mcp/arkConfig.d.ts +1 -0
  31. package/dist/mcp/assess.d.ts +157 -0
  32. package/dist/mcp/capabilityContext.d.ts +71 -0
  33. package/dist/mcp/changeSummary.d.ts +52 -0
  34. package/dist/mcp/checkSuite.d.ts +27 -0
  35. package/dist/mcp/checkout.d.ts +92 -0
  36. package/dist/mcp/comment.d.ts +127 -0
  37. package/dist/mcp/commitInfo.d.ts +11 -0
  38. package/dist/mcp/crosswalk.d.ts +178 -0
  39. package/dist/mcp/crosswalkDigest.d.ts +1 -0
  40. package/dist/mcp/cyberEssentials.d.ts +24 -0
  41. package/dist/mcp/dashboard.d.ts +125 -0
  42. package/dist/mcp/dependencies.d.ts +12 -0
  43. package/dist/mcp/frameworks.d.ts +74 -0
  44. package/dist/mcp/geminiSanitizer.d.ts +28 -0
  45. package/dist/mcp/git.d.ts +60 -0
  46. package/dist/mcp/guardrails.d.ts +222 -0
  47. package/dist/mcp/issue.d.ts +20 -0
  48. package/dist/mcp/issueComments.d.ts +11 -0
  49. package/dist/mcp/issueEvents.d.ts +11 -0
  50. package/dist/mcp/issueInfo.d.ts +11 -0
  51. package/dist/mcp/labels.d.ts +14 -0
  52. package/dist/mcp/localContext.d.ts +26 -0
  53. package/dist/mcp/moduleExtraction.d.ts +79 -0
  54. package/dist/mcp/moduleTests.d.ts +106 -0
  55. package/dist/mcp/modules.d.ts +198 -0
  56. package/dist/mcp/output.d.ts +16 -0
  57. package/dist/mcp/pathSafety.d.ts +14 -0
  58. package/dist/mcp/policy.d.ts +50 -0
  59. package/dist/mcp/pr.d.ts +64 -0
  60. package/dist/mcp/prInfo.d.ts +11 -0
  61. package/dist/mcp/providerSchema.d.ts +52 -0
  62. package/dist/mcp/review.d.ts +212 -0
  63. package/dist/mcp/reviewComments.d.ts +245 -0
  64. package/dist/mcp/roots.d.ts +60 -0
  65. package/dist/mcp/scope.d.ts +26 -0
  66. package/dist/mcp/selectMode.d.ts +20 -0
  67. package/dist/mcp/server.d.ts +61 -0
  68. package/dist/mcp/shared.d.ts +62 -0
  69. package/dist/mcp/shell.d.ts +58 -0
  70. package/dist/mcp/staleFix.d.ts +138 -0
  71. package/dist/mcp/terraform/azurePrices.d.ts +8 -0
  72. package/dist/mcp/terraform/baseline.d.ts +57 -0
  73. package/dist/mcp/terraform/concernResult.d.ts +38 -0
  74. package/dist/mcp/terraform/cost.d.ts +55 -0
  75. package/dist/mcp/terraform/cspm.d.ts +80 -0
  76. package/dist/mcp/terraform/currency.d.ts +110 -0
  77. package/dist/mcp/terraform/decisions.d.ts +178 -0
  78. package/dist/mcp/terraform/eidas.d.ts +100 -0
  79. package/dist/mcp/terraform/evidence.d.ts +343 -0
  80. package/dist/mcp/terraform/findings.d.ts +76 -0
  81. package/dist/mcp/terraform/fixMemory.d.ts +81 -0
  82. package/dist/mcp/terraform/governance.d.ts +56 -0
  83. package/dist/mcp/terraform/hcl.d.ts +115 -0
  84. package/dist/mcp/terraform/iacLanguages.d.ts +120 -0
  85. package/dist/mcp/terraform/idleFloor.d.ts +78 -0
  86. package/dist/mcp/terraform/keyless.d.ts +68 -0
  87. package/dist/mcp/terraform/moduleDocs.d.ts +56 -0
  88. package/dist/mcp/terraform/nativeRules.d.ts +38 -0
  89. package/dist/mcp/terraform/nativeScan.d.ts +11 -0
  90. package/dist/mcp/terraform/noiseProfile.d.ts +100 -0
  91. package/dist/mcp/terraform/normalization.d.ts +52 -0
  92. package/dist/mcp/terraform/oscal.d.ts +103 -0
  93. package/dist/mcp/terraform/packs/azurerm-3-4.d.ts +2 -0
  94. package/dist/mcp/terraform/packs/cloudflare-4-5.d.ts +2 -0
  95. package/dist/mcp/terraform/paths.d.ts +28 -0
  96. package/dist/mcp/terraform/plan.d.ts +157 -0
  97. package/dist/mcp/terraform/planDrift.d.ts +199 -0
  98. package/dist/mcp/terraform/policyAuthor.d.ts +191 -0
  99. package/dist/mcp/terraform/prowlerOcsf.d.ts +136 -0
  100. package/dist/mcp/terraform/refactor.d.ts +183 -0
  101. package/dist/mcp/terraform/registry.d.ts +108 -0
  102. package/dist/mcp/terraform/risk.d.ts +41 -0
  103. package/dist/mcp/terraform/scanSession.d.ts +116 -0
  104. package/dist/mcp/terraform/scannerCache.d.ts +15 -0
  105. package/dist/mcp/terraform/scannerEgress.d.ts +72 -0
  106. package/dist/mcp/terraform/scannerJson.d.ts +13 -0
  107. package/dist/mcp/terraform/scanners.d.ts +205 -0
  108. package/dist/mcp/terraform/signing.d.ts +61 -0
  109. package/dist/mcp/terraform/stateLocking.d.ts +18 -0
  110. package/dist/mcp/terraform/subprocess.d.ts +43 -0
  111. package/dist/mcp/terraform/suppressions.d.ts +90 -0
  112. package/dist/mcp/terraform/taxonomy.d.ts +39 -0
  113. package/dist/mcp/terraform/tfquery.d.ts +47 -0
  114. package/dist/mcp/terraform/toolchainIntegrity.d.ts +82 -0
  115. package/dist/mcp/terraform/tools/authorPolicy.d.ts +59 -0
  116. package/dist/mcp/terraform/tools/detectPlanDrift.d.ts +20 -0
  117. package/dist/mcp/terraform/tools/emitCost.d.ts +11 -0
  118. package/dist/mcp/terraform/tools/emitSarif.d.ts +14 -0
  119. package/dist/mcp/terraform/tools/fixMemory.d.ts +19 -0
  120. package/dist/mcp/terraform/tools/infracostDiff.d.ts +22 -0
  121. package/dist/mcp/terraform/tools/ingestExternalFindings.d.ts +21 -0
  122. package/dist/mcp/terraform/tools/moduleLookup.d.ts +14 -0
  123. package/dist/mcp/terraform/tools/moduleSearch.d.ts +23 -0
  124. package/dist/mcp/terraform/tools/plan.d.ts +59 -0
  125. package/dist/mcp/terraform/tools/providerUpgrade.d.ts +55 -0
  126. package/dist/mcp/terraform/tools/readFindings.d.ts +17 -0
  127. package/dist/mcp/terraform/tools/scan.d.ts +114 -0
  128. package/dist/mcp/terraform/tools/validate.d.ts +31 -0
  129. package/dist/mcp/terraform/tools/verifyRemediation.d.ts +31 -0
  130. package/dist/mcp/terraform/tools/versionCurrency.d.ts +5 -0
  131. package/dist/mcp/terraform/tools.d.ts +16 -0
  132. package/dist/mcp/terraform/transformPacks.d.ts +267 -0
  133. package/dist/mcp/terraform/types.d.ts +226 -0
  134. package/dist/mcp/terraform/verification.d.ts +81 -0
  135. package/dist/mcp/terraform/vex.d.ts +115 -0
  136. package/dist/mcp/terraform/writeOnly.d.ts +67 -0
  137. package/dist/mcp/terraform.d.ts +51 -0
  138. package/dist/mcp/terratest.d.ts +85 -0
  139. package/dist/mcp/untrustedContent.d.ts +76 -0
  140. package/dist/mcp/upload.d.ts +8 -0
  141. package/dist/models.d.ts +181 -0
  142. package/dist/modes/address-reviews.d.ts +2 -0
  143. package/dist/modes/assess.d.ts +2 -0
  144. package/dist/modes/build.d.ts +2 -0
  145. package/dist/modes/compliance-audit.d.ts +2 -0
  146. package/dist/modes/cost-optimization.d.ts +2 -0
  147. package/dist/modes/drift-detect.d.ts +2 -0
  148. package/dist/modes/fix.d.ts +2 -0
  149. package/dist/modes/incremental-review.d.ts +2 -0
  150. package/dist/modes/index.d.ts +24 -0
  151. package/dist/modes/modernize-deprecated.d.ts +2 -0
  152. package/dist/modes/plan.d.ts +2 -0
  153. package/dist/modes/policy-gate.d.ts +2 -0
  154. package/dist/modes/prFormats.d.ts +3 -0
  155. package/dist/modes/refactor.d.ts +2 -0
  156. package/dist/modes/refresh-remediation.d.ts +2 -0
  157. package/dist/modes/remediate-and-refactor.d.ts +2 -0
  158. package/dist/modes/remediate.d.ts +2 -0
  159. package/dist/modes/resolve-conflicts.d.ts +2 -0
  160. package/dist/modes/review.d.ts +2 -0
  161. package/dist/modes/summarize-pr.d.ts +2 -0
  162. package/dist/modes/task.d.ts +2 -0
  163. package/dist/modes/terraform-code-review.d.ts +2 -0
  164. package/dist/modes/types.d.ts +9 -0
  165. package/dist/modes/update-dependencies.d.ts +2 -0
  166. package/dist/prep/index.d.ts +7 -0
  167. package/dist/prep/installNodeDependencies.d.ts +2 -0
  168. package/dist/prep/installPythonDependencies.d.ts +2 -0
  169. package/dist/prep/types.d.ts +31 -0
  170. package/dist/reviewQuality.d.ts +107 -0
  171. package/dist/skills/terraform-best-practices/SKILL.md +379 -0
  172. package/dist/toolState.d.ts +123 -0
  173. package/dist/utils/activity.d.ts +40 -0
  174. package/dist/utils/agent.d.ts +47 -0
  175. package/dist/utils/agentHangReport.d.ts +38 -0
  176. package/dist/utils/annotations.d.ts +17 -0
  177. package/dist/utils/apiFetch.d.ts +11 -0
  178. package/dist/utils/apiKeys.d.ts +48 -0
  179. package/dist/utils/apiUrl.d.ts +28 -0
  180. package/dist/utils/assets.d.ts +8 -0
  181. package/dist/utils/baseRefConfig.d.ts +121 -0
  182. package/dist/utils/billingErrors.d.ts +85 -0
  183. package/dist/utils/body.d.ts +34 -0
  184. package/dist/utils/buildInfraweaverFooter.d.ts +29 -0
  185. package/dist/utils/byokFallback.d.ts +85 -0
  186. package/dist/utils/changeImpact.d.ts +101 -0
  187. package/dist/utils/claudeSubscription.d.ts +30 -0
  188. package/dist/utils/cli.d.ts +10 -0
  189. package/dist/utils/cloudClient.d.ts +33 -0
  190. package/dist/utils/cloudFetchCore.d.ts +42 -0
  191. package/dist/utils/cloudReport.d.ts +114 -0
  192. package/dist/utils/codexHome.d.ts +29 -0
  193. package/dist/utils/codexOAuth.d.ts +60 -0
  194. package/dist/utils/diffCoverage.d.ts +63 -0
  195. package/dist/utils/env.d.ts +46 -0
  196. package/dist/utils/errorReport.d.ts +17 -0
  197. package/dist/utils/exitHandler.d.ts +8 -0
  198. package/dist/utils/fixDoubleEscapedString.d.ts +1 -0
  199. package/dist/utils/gitAuth.d.ts +84 -0
  200. package/dist/utils/gitAuthServer.d.ts +24 -0
  201. package/dist/utils/github.d.ts +104 -0
  202. package/dist/utils/globals.d.ts +3 -0
  203. package/dist/utils/infraweaverConfig.d.ts +56 -0
  204. package/dist/utils/install.d.ts +37 -0
  205. package/dist/utils/instructions.d.ts +48 -0
  206. package/dist/utils/keylessOidc.d.ts +28 -0
  207. package/dist/utils/leapingComment.d.ts +11 -0
  208. package/dist/utils/learnings.d.ts +62 -0
  209. package/dist/utils/learningsTruncate.d.ts +25 -0
  210. package/dist/utils/lifecycle.d.ts +57 -0
  211. package/dist/utils/log.d.ts +111 -0
  212. package/dist/utils/modelResolver.d.ts +63 -0
  213. package/dist/utils/moduleFetch.d.ts +39 -0
  214. package/dist/utils/normalizeEnv.d.ts +30 -0
  215. package/dist/utils/openCodeModels.d.ts +11 -0
  216. package/dist/utils/openaiCompatible.d.ts +26 -0
  217. package/dist/utils/opentofuMcp.d.ts +50 -0
  218. package/dist/utils/overrides.d.ts +40 -0
  219. package/dist/utils/packageManager.d.ts +49 -0
  220. package/dist/utils/patchWorkflowRunFields.d.ts +29 -0
  221. package/dist/utils/payload.d.ts +249 -0
  222. package/dist/utils/prSummary.d.ts +61 -0
  223. package/dist/utils/presets.d.ts +36 -0
  224. package/dist/utils/progressComment.d.ts +146 -0
  225. package/dist/utils/providerErrors.d.ts +31 -0
  226. package/dist/utils/proxyModel.d.ts +76 -0
  227. package/dist/utils/rangeDiff.d.ts +51 -0
  228. package/dist/utils/redact.d.ts +33 -0
  229. package/dist/utils/registryAuth.d.ts +52 -0
  230. package/dist/utils/remediationCommand.d.ts +58 -0
  231. package/dist/utils/retry.d.ts +38 -0
  232. package/dist/utils/reviewCleanup.d.ts +14 -0
  233. package/dist/utils/run.d.ts +9 -0
  234. package/dist/utils/runContext.d.ts +112 -0
  235. package/dist/utils/runContextData.d.ts +42 -0
  236. package/dist/utils/runErrorRenderer.d.ts +64 -0
  237. package/dist/utils/runLifecycle.d.ts +89 -0
  238. package/dist/utils/runStartupLog.d.ts +15 -0
  239. package/dist/utils/secrets.d.ts +34 -0
  240. package/dist/utils/setup.d.ts +90 -0
  241. package/dist/utils/shell.d.ts +44 -0
  242. package/dist/utils/skills.d.ts +10 -0
  243. package/dist/utils/subprocess.d.ts +81 -0
  244. package/dist/utils/terraformMcp.d.ts +46 -0
  245. package/dist/utils/time.d.ts +15 -0
  246. package/dist/utils/timer.d.ts +23 -0
  247. package/dist/utils/todoTracking.d.ts +16 -0
  248. package/dist/utils/token.d.ts +52 -0
  249. package/dist/utils/toolLicensing.d.ts +56 -0
  250. package/dist/utils/toolSelection.d.ts +73 -0
  251. package/dist/utils/toon.d.ts +16 -0
  252. package/dist/utils/version.d.ts +2 -0
  253. package/dist/utils/versioning.d.ts +7 -0
  254. package/dist/utils/vertex.d.ts +16 -0
  255. package/dist/utils/workflow.d.ts +13 -0
  256. package/package.json +132 -0
  257. package/src/agents/claude.ts +1588 -0
  258. package/src/agents/claudePretoolGate.ts +286 -0
  259. package/src/agents/dispatchMetrics.ts +162 -0
  260. package/src/agents/gateServer.ts +178 -0
  261. package/src/agents/index.ts +10 -0
  262. package/src/agents/nativeFsDenies.ts +164 -0
  263. package/src/agents/opencode.ts +1600 -0
  264. package/src/agents/opencodePlugin.ts +304 -0
  265. package/src/agents/opencodeShared.ts +134 -0
  266. package/src/agents/postRun.ts +615 -0
  267. package/src/agents/reviewer.ts +134 -0
  268. package/src/agents/sessionLabeler.ts +185 -0
  269. package/src/agents/shared.ts +377 -0
  270. package/src/agents/subagentModels.ts +40 -0
  271. package/src/agents/tokenQuota.ts +203 -0
  272. package/src/agents/writeGateSource.ts +148 -0
  273. package/src/agents/writePolicy.ts +132 -0
  274. package/src/brand.ts +84 -0
  275. package/src/cli.ts +117 -0
  276. package/src/commands/gha.ts +188 -0
  277. package/src/commands/mcp.ts +126 -0
  278. package/src/commands/verifyEvidence.ts +100 -0
  279. package/src/entry.ts +7 -0
  280. package/src/entryPost.ts +109 -0
  281. package/src/external.ts +308 -0
  282. package/src/i18n/scaffolding.ts +191 -0
  283. package/src/index.ts +7 -0
  284. package/src/internal/index.ts +74 -0
  285. package/src/lifecycle.ts +2 -0
  286. package/src/main.ts +815 -0
  287. package/src/mcp/__fixtures__/infraweaver-scratch-pr-49-review-3485940013.json +110 -0
  288. package/src/mcp/__fixtures__/infraweaver-scratch-pr-64-review-3531000326.json +14 -0
  289. package/src/mcp/__fixtures__/infraweaver-test-repo-pr-1.diff.json +67 -0
  290. package/src/mcp/__snapshots__/checkout.test.ts.snap +109 -0
  291. package/src/mcp/__snapshots__/reviewComments.test.ts.snap +71 -0
  292. package/src/mcp/arkConfig.ts +7 -0
  293. package/src/mcp/assess.ts +723 -0
  294. package/src/mcp/capabilityContext.ts +80 -0
  295. package/src/mcp/changeSummary.ts +145 -0
  296. package/src/mcp/checkSuite.ts +261 -0
  297. package/src/mcp/checkout.ts +1015 -0
  298. package/src/mcp/comment.ts +683 -0
  299. package/src/mcp/commitInfo.ts +57 -0
  300. package/src/mcp/crosswalk.ts +1253 -0
  301. package/src/mcp/crosswalkDigest.ts +5 -0
  302. package/src/mcp/cyberEssentials.ts +60 -0
  303. package/src/mcp/dashboard.ts +232 -0
  304. package/src/mcp/dependencies.ts +190 -0
  305. package/src/mcp/frameworks.ts +236 -0
  306. package/src/mcp/geminiSanitizer.ts +212 -0
  307. package/src/mcp/git.ts +1116 -0
  308. package/src/mcp/guardrails.ts +771 -0
  309. package/src/mcp/issue.ts +74 -0
  310. package/src/mcp/issueComments.ts +48 -0
  311. package/src/mcp/issueEvents.ts +100 -0
  312. package/src/mcp/issueInfo.ts +72 -0
  313. package/src/mcp/labels.ts +35 -0
  314. package/src/mcp/localContext.ts +65 -0
  315. package/src/mcp/localServer.ts +217 -0
  316. package/src/mcp/moduleExtraction.ts +368 -0
  317. package/src/mcp/moduleTests.ts +421 -0
  318. package/src/mcp/modules.ts +752 -0
  319. package/src/mcp/output.ts +71 -0
  320. package/src/mcp/pathSafety.ts +28 -0
  321. package/src/mcp/policy.ts +226 -0
  322. package/src/mcp/pr.ts +238 -0
  323. package/src/mcp/prInfo.ts +91 -0
  324. package/src/mcp/providerSchema.ts +175 -0
  325. package/src/mcp/review.ts +1081 -0
  326. package/src/mcp/reviewComments.ts +1137 -0
  327. package/src/mcp/roots.ts +217 -0
  328. package/src/mcp/scope.ts +82 -0
  329. package/src/mcp/selectMode.ts +207 -0
  330. package/src/mcp/server.ts +498 -0
  331. package/src/mcp/shared.ts +120 -0
  332. package/src/mcp/shell.ts +631 -0
  333. package/src/mcp/staleFix.ts +557 -0
  334. package/src/mcp/terraform/__snapshots__/moduleDocs.test.ts.snap +40 -0
  335. package/src/mcp/terraform/azurePrices.ts +38 -0
  336. package/src/mcp/terraform/baseline.ts +172 -0
  337. package/src/mcp/terraform/concernResult.ts +111 -0
  338. package/src/mcp/terraform/cost.ts +175 -0
  339. package/src/mcp/terraform/cspm.ts +326 -0
  340. package/src/mcp/terraform/currency.ts +354 -0
  341. package/src/mcp/terraform/decisions.ts +590 -0
  342. package/src/mcp/terraform/eidas.ts +134 -0
  343. package/src/mcp/terraform/evidence.ts +771 -0
  344. package/src/mcp/terraform/findings.ts +383 -0
  345. package/src/mcp/terraform/fixMemory.ts +253 -0
  346. package/src/mcp/terraform/governance.ts +231 -0
  347. package/src/mcp/terraform/hcl.ts +273 -0
  348. package/src/mcp/terraform/iacLanguages.ts +431 -0
  349. package/src/mcp/terraform/idleFloor.ts +304 -0
  350. package/src/mcp/terraform/keyless.ts +123 -0
  351. package/src/mcp/terraform/moduleDocs.ts +303 -0
  352. package/src/mcp/terraform/nativeRules.ts +152 -0
  353. package/src/mcp/terraform/nativeScan.ts +67 -0
  354. package/src/mcp/terraform/noiseProfile.ts +183 -0
  355. package/src/mcp/terraform/normalization.ts +265 -0
  356. package/src/mcp/terraform/oscal.ts +283 -0
  357. package/src/mcp/terraform/packs/azurerm-3-4.ts +382 -0
  358. package/src/mcp/terraform/packs/cloudflare-4-5.ts +114 -0
  359. package/src/mcp/terraform/paths.ts +59 -0
  360. package/src/mcp/terraform/plan.ts +377 -0
  361. package/src/mcp/terraform/planDrift.ts +520 -0
  362. package/src/mcp/terraform/policyAuthor.ts +886 -0
  363. package/src/mcp/terraform/prowlerOcsf.ts +380 -0
  364. package/src/mcp/terraform/refactor.ts +879 -0
  365. package/src/mcp/terraform/registry.ts +317 -0
  366. package/src/mcp/terraform/risk.ts +99 -0
  367. package/src/mcp/terraform/scanSession.ts +242 -0
  368. package/src/mcp/terraform/scannerCache.ts +86 -0
  369. package/src/mcp/terraform/scannerEgress.ts +141 -0
  370. package/src/mcp/terraform/scannerJson.ts +22 -0
  371. package/src/mcp/terraform/scanners.ts +1134 -0
  372. package/src/mcp/terraform/signing.ts +151 -0
  373. package/src/mcp/terraform/stateLocking.ts +106 -0
  374. package/src/mcp/terraform/subprocess.ts +102 -0
  375. package/src/mcp/terraform/suppressions.ts +551 -0
  376. package/src/mcp/terraform/taxonomy.ts +0 -0
  377. package/src/mcp/terraform/tfquery.ts +159 -0
  378. package/src/mcp/terraform/toolchainIntegrity.ts +151 -0
  379. package/src/mcp/terraform/tools/authorPolicy.ts +185 -0
  380. package/src/mcp/terraform/tools/detectPlanDrift.ts +279 -0
  381. package/src/mcp/terraform/tools/emitCost.ts +130 -0
  382. package/src/mcp/terraform/tools/emitSarif.ts +108 -0
  383. package/src/mcp/terraform/tools/fixMemory.ts +82 -0
  384. package/src/mcp/terraform/tools/infracostDiff.ts +110 -0
  385. package/src/mcp/terraform/tools/ingestExternalFindings.ts +259 -0
  386. package/src/mcp/terraform/tools/moduleLookup.ts +86 -0
  387. package/src/mcp/terraform/tools/moduleSearch.ts +46 -0
  388. package/src/mcp/terraform/tools/plan.ts +384 -0
  389. package/src/mcp/terraform/tools/providerUpgrade.ts +217 -0
  390. package/src/mcp/terraform/tools/readFindings.ts +138 -0
  391. package/src/mcp/terraform/tools/scan.ts +303 -0
  392. package/src/mcp/terraform/tools/validate.ts +160 -0
  393. package/src/mcp/terraform/tools/verifyRemediation.ts +190 -0
  394. package/src/mcp/terraform/tools/versionCurrency.ts +64 -0
  395. package/src/mcp/terraform/tools.ts +62 -0
  396. package/src/mcp/terraform/transformPacks.ts +594 -0
  397. package/src/mcp/terraform/types.ts +382 -0
  398. package/src/mcp/terraform/verification.ts +150 -0
  399. package/src/mcp/terraform/vex.ts +367 -0
  400. package/src/mcp/terraform/writeOnly.ts +252 -0
  401. package/src/mcp/terraform.ts +52 -0
  402. package/src/mcp/terratest.ts +215 -0
  403. package/src/mcp/untrustedContent.ts +126 -0
  404. package/src/mcp/upload.ts +123 -0
  405. package/src/models.ts +753 -0
  406. package/src/modes/address-reviews.ts +35 -0
  407. package/src/modes/assess.ts +27 -0
  408. package/src/modes/build.ts +86 -0
  409. package/src/modes/compliance-audit.ts +25 -0
  410. package/src/modes/cost-optimization.ts +36 -0
  411. package/src/modes/drift-detect.ts +31 -0
  412. package/src/modes/fix.ts +29 -0
  413. package/src/modes/incremental-review.ts +103 -0
  414. package/src/modes/index.ts +94 -0
  415. package/src/modes/modernize-deprecated.ts +36 -0
  416. package/src/modes/plan.ts +21 -0
  417. package/src/modes/policy-gate.ts +27 -0
  418. package/src/modes/prFormats.ts +325 -0
  419. package/src/modes/refactor.ts +74 -0
  420. package/src/modes/refresh-remediation.ts +40 -0
  421. package/src/modes/remediate-and-refactor.ts +42 -0
  422. package/src/modes/remediate.ts +78 -0
  423. package/src/modes/resolve-conflicts.ts +32 -0
  424. package/src/modes/review.ts +135 -0
  425. package/src/modes/summarize-pr.ts +42 -0
  426. package/src/modes/task.ts +26 -0
  427. package/src/modes/terraform-code-review.ts +68 -0
  428. package/src/modes/types.ts +17 -0
  429. package/src/modes/update-dependencies.ts +44 -0
  430. package/src/prep/index.ts +96 -0
  431. package/src/prep/installNodeDependencies.ts +251 -0
  432. package/src/prep/installPythonDependencies.ts +235 -0
  433. package/src/prep/types.ts +38 -0
  434. package/src/reviewQuality.ts +237 -0
  435. package/src/runCli.ts +335 -0
  436. package/src/skills/terraform-best-practices/SKILL.md +379 -0
  437. package/src/toolState.ts +241 -0
  438. package/src/utils/activity.ts +210 -0
  439. package/src/utils/agent.ts +245 -0
  440. package/src/utils/agentHangReport.ts +180 -0
  441. package/src/utils/annotations.ts +56 -0
  442. package/src/utils/apiFetch.ts +19 -0
  443. package/src/utils/apiKeys.ts +305 -0
  444. package/src/utils/apiUrl.ts +42 -0
  445. package/src/utils/assets.ts +123 -0
  446. package/src/utils/baseRefConfig.ts +254 -0
  447. package/src/utils/billingErrors.ts +210 -0
  448. package/src/utils/body.ts +168 -0
  449. package/src/utils/buildInfraweaverFooter.ts +104 -0
  450. package/src/utils/byokFallback.ts +137 -0
  451. package/src/utils/changeImpact.ts +330 -0
  452. package/src/utils/claudeSubscription.ts +93 -0
  453. package/src/utils/cli.ts +36 -0
  454. package/src/utils/cloudClient.ts +57 -0
  455. package/src/utils/cloudFetchCore.ts +139 -0
  456. package/src/utils/cloudReport.ts +316 -0
  457. package/src/utils/codexHome.ts +204 -0
  458. package/src/utils/codexOAuth.ts +154 -0
  459. package/src/utils/codexRefreshDetect.ts +36 -0
  460. package/src/utils/diffCoverage.ts +404 -0
  461. package/src/utils/env.ts +84 -0
  462. package/src/utils/errorReport.ts +94 -0
  463. package/src/utils/exitHandler.ts +35 -0
  464. package/src/utils/fixDoubleEscapedString.ts +9 -0
  465. package/src/utils/ghaCore.ts +13 -0
  466. package/src/utils/gitAuth.ts +268 -0
  467. package/src/utils/gitAuthServer.ts +186 -0
  468. package/src/utils/github.ts +676 -0
  469. package/src/utils/globals.ts +9 -0
  470. package/src/utils/humanEditCapture.ts +198 -0
  471. package/src/utils/infraweaverConfig.ts +202 -0
  472. package/src/utils/install.ts +279 -0
  473. package/src/utils/instructions.ts +640 -0
  474. package/src/utils/keylessOidc.ts +47 -0
  475. package/src/utils/leapingComment.ts +20 -0
  476. package/src/utils/learnings.ts +145 -0
  477. package/src/utils/learningsTruncate.ts +42 -0
  478. package/src/utils/lifecycle.ts +198 -0
  479. package/src/utils/log.ts +452 -0
  480. package/src/utils/modelResolver.ts +105 -0
  481. package/src/utils/moduleFetch.ts +138 -0
  482. package/src/utils/normalizeEnv.ts +106 -0
  483. package/src/utils/openCodeModels.ts +86 -0
  484. package/src/utils/openaiCompatible.ts +52 -0
  485. package/src/utils/opentofuMcp.ts +61 -0
  486. package/src/utils/overrides.ts +100 -0
  487. package/src/utils/packageManager.ts +257 -0
  488. package/src/utils/patchWorkflowRunFields.ts +173 -0
  489. package/src/utils/payload.ts +1206 -0
  490. package/src/utils/prSummary.ts +148 -0
  491. package/src/utils/presets.ts +105 -0
  492. package/src/utils/progressComment.ts +266 -0
  493. package/src/utils/providerErrors.ts +189 -0
  494. package/src/utils/proxyModel.ts +239 -0
  495. package/src/utils/rangeDiff.ts +182 -0
  496. package/src/utils/redact.ts +86 -0
  497. package/src/utils/registryAuth.ts +115 -0
  498. package/src/utils/remediationCommand.ts +144 -0
  499. package/src/utils/retry.ts +180 -0
  500. package/src/utils/reviewCleanup.ts +116 -0
  501. package/src/utils/run.ts +100 -0
  502. package/src/utils/runContext.ts +276 -0
  503. package/src/utils/runContextData.ts +121 -0
  504. package/src/utils/runErrorRenderer.ts +282 -0
  505. package/src/utils/runFixture.ts +91 -0
  506. package/src/utils/runLifecycle.ts +360 -0
  507. package/src/utils/runStartupLog.ts +67 -0
  508. package/src/utils/secrets.ts +208 -0
  509. package/src/utils/setup.ts +368 -0
  510. package/src/utils/shell.ts +132 -0
  511. package/src/utils/skills.ts +67 -0
  512. package/src/utils/subprocess.ts +474 -0
  513. package/src/utils/terraformMcp.ts +99 -0
  514. package/src/utils/time.ts +59 -0
  515. package/src/utils/timer.ts +72 -0
  516. package/src/utils/todoTracking.ts +168 -0
  517. package/src/utils/token.ts +294 -0
  518. package/src/utils/toolLicensing.ts +152 -0
  519. package/src/utils/toolSelection.ts +239 -0
  520. package/src/utils/toon.ts +76 -0
  521. package/src/utils/version.ts +10 -0
  522. package/src/utils/versioning.ts +44 -0
  523. package/src/utils/vertex.ts +94 -0
  524. package/src/utils/workflow.ts +25 -0
@@ -0,0 +1,239 @@
1
+ /**
2
+ * Unified tool-selection config + the
3
+ * non-permissive-tool confirmation gate (built on [[toolLicensing]]).
4
+ *
5
+ * One declarative `tools_enabled` list replaces the previous mix of per-flag
6
+ * inputs and silent presence-detection: an operator names the scanners/engines
7
+ * they want, prefixing `-` to turn one off. The same list is how a non-permissive
8
+ * tool (tflint, terraform-mcp-server) is opted into — naming it is the explicit,
9
+ * licence-aware acknowledgement the gate requires.
10
+ *
11
+ * Resolution precedence, per tool (highest first):
12
+ * 1. the required substrate (`terraform`) → ON (exempt; never disablable)
13
+ * 2. an explicit `-tool` in the list → OFF (always wins over the rest)
14
+ * 3. an explicit `tool` / `+tool` → ON (this is the licence opt-in)
15
+ * 4. `all` base → ON (operator accepts every tool)
16
+ * 5. `none` base → only the explicitly/flag-enabled
17
+ * 6. default base:
18
+ * - licence-gated tool → ON only if its dedicated flag is set, else OFF
19
+ * - flag-opt-in tool → ON only if its dedicated flag is set, else OFF
20
+ * - permissive tool → ON
21
+ *
22
+ * The dedicated booleans (`gitleaks`, `terratest`, `terraform_mcp`) still work
23
+ * and count as an opt-in, so existing workflows keep running unchanged. Pure.
24
+ */
25
+
26
+ import { isLicenseGated, isPermissive, TOOL_LICENSES, type ToolId } from "#app/utils/toolLicensing";
27
+
28
+ /** the parsed `tools_enabled` input: a base posture + per-tool overrides. */
29
+ export interface ToolDirective {
30
+ /** `all` (enable everything) / `none` (enable nothing) / undefined (defaults). */
31
+ base?: "all" | "none" | undefined;
32
+ /** explicit per-tool overrides: true = enable, false = disable. */
33
+ explicit: Map<ToolId, boolean>;
34
+ /** tokens that matched no known tool — surfaced as a warning, never fatal. */
35
+ unknown: string[];
36
+ }
37
+
38
+ /** the dedicated booleans that pre-date the unified list. */
39
+ export interface ToolSelectionFlags {
40
+ toolsEnabled?: ToolDirective | undefined;
41
+ gitleaks?: boolean;
42
+ terratest?: boolean;
43
+ terraformMcp?: boolean;
44
+ opentofuMcp?: boolean;
45
+ }
46
+
47
+ /**
48
+ * Permissive tools that still default OFF — not for licence reasons but because
49
+ * each is an extra/heavier engine (or writes extra files) the operator opts into
50
+ * via its dedicated input. Listing keeps their long-standing behaviour intact
51
+ * while the unified list can also enable/disable them.
52
+ */
53
+ const FLAG_OPT_IN: ReadonlySet<ToolId> = new Set<ToolId>(["gitleaks", "terratest"]);
54
+
55
+ /** map a token to a canonical tool id (case-insensitive; common spellings). */
56
+ const TOKEN_ALIASES: Readonly<Record<string, ToolId>> = {
57
+ terraform: "terraform",
58
+ tf: "terraform",
59
+ "terraform-fmt": "terraform",
60
+ "terraform-validate": "terraform",
61
+ tflint: "tflint",
62
+ trivy: "trivy",
63
+ checkov: "checkov",
64
+ infracost: "infracost",
65
+ cost: "infracost",
66
+ gitleaks: "gitleaks",
67
+ conftest: "conftest",
68
+ opa: "conftest",
69
+ policy: "conftest",
70
+ terratest: "terratest",
71
+ terraform_mcp: "terraform_mcp",
72
+ "terraform-mcp": "terraform_mcp",
73
+ "terraform-mcp-server": "terraform_mcp",
74
+ opentofu_mcp: "opentofu_mcp",
75
+ "opentofu-mcp": "opentofu_mcp",
76
+ "opentofu-mcp-server": "opentofu_mcp",
77
+ tofu_mcp: "opentofu_mcp",
78
+ "tofu-mcp": "opentofu_mcp",
79
+ } as const;
80
+
81
+ /**
82
+ * Parse the `tools_enabled` input (comma- or newline-separated). Recognises the
83
+ * `all` / `none` bases and `tool` / `+tool` / `-tool` (also `!tool`) overrides.
84
+ * Returns undefined for an empty input so "unset" stays distinguishable from an
85
+ * explicit list (the consumer then applies the licence-aware defaults).
86
+ */
87
+ export function parseToolSelection(raw: string | undefined): ToolDirective | undefined {
88
+ if (!raw?.trim()) return undefined;
89
+ const explicit = new Map<ToolId, boolean>();
90
+ const unknown: string[] = [];
91
+ let base: "all" | "none" | undefined;
92
+
93
+ for (const token of raw.split(/[\n,]/)) {
94
+ const tok = token.trim();
95
+ if (!tok) continue;
96
+ const lower = tok.toLowerCase();
97
+ if (lower === "all" || lower === "*") {
98
+ base = "all";
99
+ continue;
100
+ }
101
+ if (lower === "none") {
102
+ base = "none";
103
+ continue;
104
+ }
105
+ let enable = true;
106
+ let name = lower;
107
+ if (name.startsWith("-") || name.startsWith("!")) {
108
+ enable = false;
109
+ name = name.slice(1).trim();
110
+ } else if (name.startsWith("+")) {
111
+ name = name.slice(1).trim();
112
+ }
113
+ const id = TOKEN_ALIASES[name];
114
+ if (!id) {
115
+ unknown.push(tok);
116
+ continue;
117
+ }
118
+ explicit.set(id, enable);
119
+ }
120
+ return { base, explicit, unknown };
121
+ }
122
+
123
+ function flagFor(id: ToolId, flags: ToolSelectionFlags): boolean {
124
+ switch (id) {
125
+ case "gitleaks":
126
+ return !!flags.gitleaks;
127
+ case "terratest":
128
+ return !!flags.terratest;
129
+ case "terraform_mcp":
130
+ return !!flags.terraformMcp;
131
+ case "opentofu_mcp":
132
+ return !!flags.opentofuMcp;
133
+ default:
134
+ return false;
135
+ }
136
+ }
137
+
138
+ interface Verdict {
139
+ on: boolean;
140
+ /** why a tool is OFF (for reporting); undefined when ON. */
141
+ reason?: string;
142
+ }
143
+
144
+ function decide(id: ToolId, flags: ToolSelectionFlags): Verdict {
145
+ const dir = flags.toolsEnabled;
146
+ const explicit = dir?.explicit.get(id);
147
+
148
+ // 1. the required substrate is the engine's reason to exist — never gated,
149
+ // never disablable (a Terraform fixer always has Terraform).
150
+ if (TOOL_LICENSES[id].required) return { on: true };
151
+ // 2. an explicit disable always wins.
152
+ if (explicit === false) return { on: false, reason: "disabled via tools_enabled" };
153
+ // 3. an explicit enable is the licence-aware opt-in.
154
+ if (explicit === true) return { on: true };
155
+ // 4 / 5. an `all` / `none` base.
156
+ if (dir?.base === "all") return { on: true };
157
+ if (dir?.base === "none") {
158
+ return flagFor(id, flags)
159
+ ? { on: true }
160
+ : { on: false, reason: "not in the tools_enabled allow-list" };
161
+ }
162
+ // 6. licence-aware defaults.
163
+ if (isLicenseGated(id)) {
164
+ if (flagFor(id, flags)) return { on: true };
165
+ const { license, name } = TOOL_LICENSES[id];
166
+ return {
167
+ on: false,
168
+ reason: `licence-gated (${name}, ${license}) — enable explicitly by naming "${id}" in tools_enabled`,
169
+ };
170
+ }
171
+ if (FLAG_OPT_IN.has(id)) {
172
+ return flagFor(id, flags)
173
+ ? { on: true }
174
+ : { on: false, reason: `opt-in — set the ${id} input or name "${id}" in tools_enabled` };
175
+ }
176
+ // permissive default-on (subject to the tool's own runtime presence checks).
177
+ return { on: true };
178
+ }
179
+
180
+ /** the resolved selection for a run — a deterministic verdict per tool. */
181
+ export interface ResolvedToolSelection {
182
+ enabled(id: ToolId): boolean;
183
+ /** the reason a tool is OFF (for the scan report / logs); undefined when ON. */
184
+ offReason(id: ToolId): string | undefined;
185
+ /** licence-gated tools that are OFF because they weren't opted into. */
186
+ gated: ToolId[];
187
+ /** tools explicitly turned off via `tools_enabled`. */
188
+ disabled: ToolId[];
189
+ /** unrecognised `tools_enabled` tokens (warn, never fatal). */
190
+ unknownTokens: string[];
191
+ }
192
+
193
+ /**
194
+ * Resolve the per-tool selection from the run's payload (the parsed
195
+ * `tools_enabled` directive + the dedicated booleans). Pure; safe to call from
196
+ * any consumer (the scan tool, the secret guardrail, the terraform-mcp resolver,
197
+ * the plan tool) so they all agree on which tools may run this run.
198
+ */
199
+ export function resolveToolSelection(flags: ToolSelectionFlags): ResolvedToolSelection {
200
+ const verdicts = new Map<ToolId, Verdict>();
201
+ const gated: ToolId[] = [];
202
+ const disabled: ToolId[] = [];
203
+ for (const id of Object.keys(TOOL_LICENSES) as ToolId[]) {
204
+ const verdict = decide(id, flags);
205
+ verdicts.set(id, verdict);
206
+ if (verdict.on) continue;
207
+ if (flags.toolsEnabled?.explicit.get(id) === false) disabled.push(id);
208
+ else if (isLicenseGated(id)) gated.push(id);
209
+ }
210
+ return {
211
+ enabled: (id) => verdicts.get(id)?.on ?? false,
212
+ offReason: (id) => verdicts.get(id)?.reason,
213
+ gated,
214
+ disabled,
215
+ unknownTokens: flags.toolsEnabled?.unknown ?? [],
216
+ };
217
+ }
218
+
219
+ /** map a `terraform_scan` scanner source to the tool id it belongs to (null for
220
+ * the `reviewer` pseudo-source, which the gate never governs). */
221
+ export function scannerToolId(source: string): ToolId | null {
222
+ switch (source) {
223
+ case "terraform-fmt":
224
+ case "terraform-validate":
225
+ return "terraform";
226
+ case "tflint":
227
+ return "tflint";
228
+ case "trivy":
229
+ return "trivy";
230
+ case "checkov":
231
+ return "checkov";
232
+ default:
233
+ return null;
234
+ }
235
+ }
236
+
237
+ export type { ToolId };
238
+ // re-exported so callers need only this module for the common path.
239
+ export { isPermissive, TOOL_LICENSES };
@@ -0,0 +1,76 @@
1
+ import { encode } from "@toon-format/toon";
2
+
3
+ /**
4
+ * TOON encoding for infraweaver, hardened against a behaviour change in
5
+ * `@toon-format/toon` 4.1.0.
6
+ *
7
+ * 4.1.0 made `encode` **throw** `TypeError` on any string value — or object
8
+ * key — containing an unpaired surrogate. 2.x encoded such strings through
9
+ * without complaint. Every payload we encode is attacker-influenced: PR and
10
+ * issue titles/bodies and label names (`buildEventMetadata`), `git status`
11
+ * output and remediation commands parsed from comments (`buildRuntimeContext`),
12
+ * and every MCP tool result (`handleToolSuccess`), which carries third-party
13
+ * scanner output and repository file content. A lone surrogate is trivially
14
+ * reachable — GitHub's API returns JSON, and `JSON.parse('"\\ud800"')` yields
15
+ * exactly that — so an unguarded `encode` lets a crafted PR title abort prompt
16
+ * assembly and fail the run. Availability, not a guardrail bypass, but
17
+ * attacker-triggered either way.
18
+ *
19
+ * The library's own `replacer` hook cannot fix this: the surrogate check runs
20
+ * during input normalization, BEFORE the replacer is applied (verified against
21
+ * 4.1.0 — a replacer is never invoked for a value that fails validation). The
22
+ * input therefore has to be well-formed before `encode` sees it.
23
+ *
24
+ * `String.prototype.toWellFormed()` (ES2024) replaces each lone surrogate with
25
+ * U+FFFD, which is the standard substitution and keeps the surrounding text
26
+ * intact — strictly more faithful than dropping the field or the whole run.
27
+ */
28
+
29
+ /**
30
+ * Plain objects only — anything with a custom prototype is passed through
31
+ * untouched so `toJSON` carriers (`Date`, class instances) keep the
32
+ * serialization TOON already gives them. Every payload we hand to
33
+ * {@link toonEncode} is a plain object or array of them, so this covers the
34
+ * real inputs; a `toJSON` that itself returns an ill-formed string would still
35
+ * throw, which is the correct place for it to surface.
36
+ */
37
+ function isPlainObject(value: unknown): value is Record<string, unknown> {
38
+ if (typeof value !== "object" || value === null) return false;
39
+ const proto = Object.getPrototypeOf(value);
40
+ return proto === Object.prototype || proto === null;
41
+ }
42
+
43
+ /**
44
+ * Recursively replaces lone surrogates in strings and object keys with U+FFFD.
45
+ * Exported for the tests; prefer {@link toonEncode}.
46
+ *
47
+ * Rebuilt with `Object.fromEntries`, which defines own data properties rather
48
+ * than assigning them — so a `__proto__` key in untrusted input cannot reach
49
+ * the prototype setter.
50
+ */
51
+ export function toWellFormedDeep<T>(value: T): T {
52
+ if (typeof value === "string") return value.toWellFormed() as T;
53
+ if (Array.isArray(value))
54
+ return value.map((item) => toWellFormedDeep(item)) as T;
55
+ if (isPlainObject(value)) {
56
+ return Object.fromEntries(
57
+ Object.entries(value).map(([key, item]) => [
58
+ key.toWellFormed(),
59
+ toWellFormedDeep(item),
60
+ ]),
61
+ ) as T;
62
+ }
63
+ return value;
64
+ }
65
+
66
+ /**
67
+ * `@toon-format/toon`'s `encode`, applied to well-formed input. Use this
68
+ * everywhere instead of importing `encode` directly — `knip` and the import
69
+ * guard keep the direct import to this module.
70
+ */
71
+ export function toonEncode(
72
+ input: unknown,
73
+ options?: Parameters<typeof encode>[1],
74
+ ): string {
75
+ return encode(toWellFormedDeep(input), options);
76
+ }
@@ -0,0 +1,10 @@
1
+ import semver from "semver";
2
+ import packageJson from "#package.json" with { type: "json" };
3
+
4
+ export function getDevDependencyVersion(name: keyof typeof packageJson.devDependencies): string {
5
+ const version = packageJson.devDependencies[name];
6
+ if (!semver.valid(version)) {
7
+ throw new Error(`dev dependency "${name}" must be a pinned version, got "${version}"`);
8
+ }
9
+ return version;
10
+ }
@@ -0,0 +1,44 @@
1
+ import semver from "semver";
2
+
3
+ type CompatibilityPolicy =
4
+ /**
5
+ * Strict policy: the action must support the same features as the payload version declares
6
+ * @example Payload version 1.2.3 => ^1.2.0 range of action versions supported
7
+ * @example Payload version 0.1.55 => ^0.1.55 range of action versions supported
8
+ */
9
+ | "same-features"
10
+ /**
11
+ * Loose policy: the action must have no breaking changes compared to the payload version
12
+ * @example Payload version 1.2.3 => ^1.0.0 range of action versions supported
13
+ * @example Payload version 0.1.55 => ^0.1.0 range of action versions supported
14
+ */
15
+ | "non-breaking";
16
+
17
+ const COMPATIBILITY_POLICY: CompatibilityPolicy = "non-breaking";
18
+
19
+ /**
20
+ * @throws Error if the action can't process payload
21
+ * The compatibility is determined according to the COMPATIBILITY_POLICY above.
22
+ * @param payloadVersion the version of the payload
23
+ * @param actionVersion the version of the action (recipient)
24
+ */
25
+ export function validateCompatibility(payloadVersion: string, actionVersion: string): void {
26
+ const payloadSemVer = semver.parse(payloadVersion);
27
+ if (!payloadSemVer)
28
+ throw new Error(`Payload version ${payloadVersion} is not a valid semantic version.`);
29
+ const major = payloadSemVer.major;
30
+ const minor = payloadSemVer.minor;
31
+ const patch = payloadSemVer.patch;
32
+
33
+ const compatibilityRange =
34
+ COMPATIBILITY_POLICY === "same-features"
35
+ ? `^${major}.${minor}.${major === 0 ? patch : 0}`
36
+ : `^${major}.${major === 0 ? minor : 0}.${major === 0 ? "x" : 0}`; // non-breaking
37
+
38
+ if (!semver.satisfies(actionVersion, compatibilityRange)) {
39
+ throw new Error(
40
+ `Payload version ${payloadVersion} is incompatible with action version ${actionVersion}. ` +
41
+ `Please update your workflow to use at least ${semver.minVersion(compatibilityRange)} version of the action.`,
42
+ );
43
+ }
44
+ }
@@ -0,0 +1,94 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { mkdirSync, rmSync, writeFileSync } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { PRODUCT_SLUG } from "#app/brand";
6
+ import { VERTEX_MODEL_ID_ENV } from "#app/models";
7
+ import { hasEnvVar } from "#app/utils/env";
8
+
9
+ export const VERTEX_SERVICE_ACCOUNT_JSON_ENV = "VERTEX_SERVICE_ACCOUNT_JSON";
10
+ export const GOOGLE_APPLICATION_CREDENTIALS_ENV =
11
+ "GOOGLE_APPLICATION_CREDENTIALS";
12
+ export const GOOGLE_CLOUD_PROJECT_ENV = "GOOGLE_CLOUD_PROJECT";
13
+ export const VERTEX_LOCATION_ENV = "VERTEX_LOCATION";
14
+
15
+ export type VertexCredentials = {
16
+ credentialsPath: string;
17
+ secretDir: string;
18
+ };
19
+
20
+ export function isVertexRoute(model: string | undefined): boolean {
21
+ const vertexId = process.env[VERTEX_MODEL_ID_ENV]?.trim();
22
+ return model !== undefined && vertexId !== undefined && vertexId === model;
23
+ }
24
+
25
+ export function readProjectIdFromVertexServiceAccountJson():
26
+ | string
27
+ | undefined {
28
+ const blob = process.env[VERTEX_SERVICE_ACCOUNT_JSON_ENV];
29
+ if (!blob) return undefined;
30
+
31
+ try {
32
+ const parsed: unknown = JSON.parse(blob);
33
+ if (!parsed || typeof parsed !== "object" || !("project_id" in parsed)) {
34
+ return undefined;
35
+ }
36
+ const projectId = parsed.project_id;
37
+ return typeof projectId === "string" && projectId.length > 0
38
+ ? projectId
39
+ : undefined;
40
+ } catch {
41
+ return undefined;
42
+ }
43
+ }
44
+
45
+ function createSecretDir(): string {
46
+ const base =
47
+ process.env.INFRAWEAVER_SECRET_HOME || process.env.HOME || homedir();
48
+ const secretDir = join(base, `.${PRODUCT_SLUG}`, "secrets", randomUUID());
49
+ mkdirSync(secretDir, { recursive: true, mode: 0o700 });
50
+ return secretDir;
51
+ }
52
+
53
+ export function materializeVertexCredentials(params: {
54
+ model: string | undefined;
55
+ }): VertexCredentials | undefined {
56
+ if (!isVertexRoute(params.model)) return undefined;
57
+
58
+ const blob = process.env[VERTEX_SERVICE_ACCOUNT_JSON_ENV];
59
+ if (!blob) return undefined;
60
+
61
+ const secretDir = createSecretDir();
62
+ const credentialsPath = join(secretDir, "vertex-sa.json");
63
+ writeFileSync(credentialsPath, blob, { mode: 0o600 });
64
+ process.env[GOOGLE_APPLICATION_CREDENTIALS_ENV] = credentialsPath;
65
+
66
+ const projectId = readProjectIdFromVertexServiceAccountJson();
67
+ if (projectId && !hasEnvVar(GOOGLE_CLOUD_PROJECT_ENV)) {
68
+ process.env[GOOGLE_CLOUD_PROJECT_ENV] = projectId;
69
+ }
70
+
71
+ return { credentialsPath, secretDir };
72
+ }
73
+
74
+ export function cleanupVertexCredentials(
75
+ credentials: VertexCredentials | undefined,
76
+ ): void {
77
+ if (!credentials) return;
78
+ rmSync(credentials.secretDir, { recursive: true, force: true });
79
+ delete process.env[GOOGLE_APPLICATION_CREDENTIALS_ENV];
80
+ }
81
+
82
+ export function applyClaudeVertexEnv(
83
+ env: Record<string, string | undefined>,
84
+ ): void {
85
+ env.CLAUDE_CODE_USE_VERTEX = "1";
86
+ env.ANTHROPIC_VERTEX_PROJECT_ID ??= env[GOOGLE_CLOUD_PROJECT_ENV];
87
+ env.CLOUD_ML_REGION ??= env[VERTEX_LOCATION_ENV];
88
+ }
89
+
90
+ export function resolveVertexOpenCodeModel(
91
+ model: string | undefined,
92
+ ): string | undefined {
93
+ return isVertexRoute(model) && model ? `google-vertex/${model}` : undefined;
94
+ }
@@ -0,0 +1,25 @@
1
+ import type { OctokitWithPlugins } from "#app/utils/github";
2
+
3
+ interface ResolveRunParams {
4
+ octokit: OctokitWithPlugins;
5
+ }
6
+
7
+ export interface ResolveRunResult {
8
+ runId: number | undefined;
9
+ }
10
+
11
+ /**
12
+ * Resolve GitHub Actions workflow run context.
13
+ * Uses GITHUB_REPOSITORY and GITHUB_RUN_ID env vars.
14
+ */
15
+ export async function resolveRun(_params: ResolveRunParams): Promise<ResolveRunResult> {
16
+ const runId = process.env.GITHUB_RUN_ID
17
+ ? Number.parseInt(process.env.GITHUB_RUN_ID, 10)
18
+ : undefined;
19
+ const githubRepo = process.env.GITHUB_REPOSITORY;
20
+ if (!githubRepo?.includes("/")) {
21
+ throw new Error(`GITHUB_REPOSITORY env var must be set to "owner/repo", got: ${githubRepo}`);
22
+ }
23
+
24
+ return { runId };
25
+ }