thevoidforge 21.0.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 (328) hide show
  1. package/dist/scripts/vault-read.d.ts +11 -0
  2. package/dist/scripts/vault-read.js +89 -0
  3. package/dist/scripts/voidforge.d.ts +20 -0
  4. package/dist/scripts/voidforge.js +404 -0
  5. package/dist/tsconfig.tsbuildinfo +1 -0
  6. package/dist/wizard/api/auth.d.ts +5 -0
  7. package/dist/wizard/api/auth.js +133 -0
  8. package/dist/wizard/api/blueprint.d.ts +45 -0
  9. package/dist/wizard/api/blueprint.js +184 -0
  10. package/dist/wizard/api/cloud-providers.d.ts +16 -0
  11. package/dist/wizard/api/cloud-providers.js +363 -0
  12. package/dist/wizard/api/credentials.d.ts +1 -0
  13. package/dist/wizard/api/credentials.js +258 -0
  14. package/dist/wizard/api/danger-room.d.ts +18 -0
  15. package/dist/wizard/api/danger-room.js +401 -0
  16. package/dist/wizard/api/deploy.d.ts +4 -0
  17. package/dist/wizard/api/deploy.js +164 -0
  18. package/dist/wizard/api/prd.d.ts +1 -0
  19. package/dist/wizard/api/prd.js +363 -0
  20. package/dist/wizard/api/project.d.ts +1 -0
  21. package/dist/wizard/api/project.js +239 -0
  22. package/dist/wizard/api/projects.d.ts +6 -0
  23. package/dist/wizard/api/projects.js +648 -0
  24. package/dist/wizard/api/provision.d.ts +4 -0
  25. package/dist/wizard/api/provision.js +535 -0
  26. package/dist/wizard/api/terminal.d.ts +25 -0
  27. package/dist/wizard/api/terminal.js +241 -0
  28. package/dist/wizard/api/users.d.ts +6 -0
  29. package/dist/wizard/api/users.js +244 -0
  30. package/dist/wizard/api/war-room.d.ts +14 -0
  31. package/dist/wizard/api/war-room.js +45 -0
  32. package/dist/wizard/lib/ad-platform-core.d.ts +6 -0
  33. package/dist/wizard/lib/ad-platform-core.js +1 -0
  34. package/dist/wizard/lib/adapters/index.d.ts +52 -0
  35. package/dist/wizard/lib/adapters/index.js +38 -0
  36. package/dist/wizard/lib/adapters/sandbox-bank.d.ts +17 -0
  37. package/dist/wizard/lib/adapters/sandbox-bank.js +77 -0
  38. package/dist/wizard/lib/adapters/sandbox.d.ts +39 -0
  39. package/dist/wizard/lib/adapters/sandbox.js +174 -0
  40. package/dist/wizard/lib/adapters/stripe.d.ts +19 -0
  41. package/dist/wizard/lib/adapters/stripe.js +143 -0
  42. package/dist/wizard/lib/adapters/types.d.ts +9 -0
  43. package/dist/wizard/lib/adapters/types.js +10 -0
  44. package/dist/wizard/lib/agent-memory.d.ts +36 -0
  45. package/dist/wizard/lib/agent-memory.js +114 -0
  46. package/dist/wizard/lib/anomaly-detection.d.ts +59 -0
  47. package/dist/wizard/lib/anomaly-detection.js +122 -0
  48. package/dist/wizard/lib/anthropic.d.ts +21 -0
  49. package/dist/wizard/lib/anthropic.js +105 -0
  50. package/dist/wizard/lib/asset-scanner.d.ts +23 -0
  51. package/dist/wizard/lib/asset-scanner.js +107 -0
  52. package/dist/wizard/lib/audit-log.d.ts +23 -0
  53. package/dist/wizard/lib/audit-log.js +70 -0
  54. package/dist/wizard/lib/autonomy-controller.d.ts +76 -0
  55. package/dist/wizard/lib/autonomy-controller.js +183 -0
  56. package/dist/wizard/lib/body-parser.d.ts +2 -0
  57. package/dist/wizard/lib/body-parser.js +36 -0
  58. package/dist/wizard/lib/build-analytics.d.ts +39 -0
  59. package/dist/wizard/lib/build-analytics.js +91 -0
  60. package/dist/wizard/lib/build-step.d.ts +21 -0
  61. package/dist/wizard/lib/build-step.js +104 -0
  62. package/dist/wizard/lib/campaign-proposer.d.ts +39 -0
  63. package/dist/wizard/lib/campaign-proposer.js +180 -0
  64. package/dist/wizard/lib/campaign-state-machine.d.ts +63 -0
  65. package/dist/wizard/lib/campaign-state-machine.js +114 -0
  66. package/dist/wizard/lib/ci-generator.d.ts +14 -0
  67. package/dist/wizard/lib/ci-generator.js +187 -0
  68. package/dist/wizard/lib/claude-merge.d.ts +38 -0
  69. package/dist/wizard/lib/claude-merge.js +115 -0
  70. package/dist/wizard/lib/codegen/erd-gen.d.ts +16 -0
  71. package/dist/wizard/lib/codegen/erd-gen.js +98 -0
  72. package/dist/wizard/lib/codegen/integrations.d.ts +18 -0
  73. package/dist/wizard/lib/codegen/integrations.js +189 -0
  74. package/dist/wizard/lib/codegen/openapi-gen.d.ts +15 -0
  75. package/dist/wizard/lib/codegen/openapi-gen.js +79 -0
  76. package/dist/wizard/lib/codegen/prisma-types.d.ts +15 -0
  77. package/dist/wizard/lib/codegen/prisma-types.js +44 -0
  78. package/dist/wizard/lib/codegen/seed-gen.d.ts +16 -0
  79. package/dist/wizard/lib/codegen/seed-gen.js +128 -0
  80. package/dist/wizard/lib/compliance.d.ts +51 -0
  81. package/dist/wizard/lib/compliance.js +112 -0
  82. package/dist/wizard/lib/correlation-engine.d.ts +59 -0
  83. package/dist/wizard/lib/correlation-engine.js +151 -0
  84. package/dist/wizard/lib/cost-estimator.d.ts +22 -0
  85. package/dist/wizard/lib/cost-estimator.js +72 -0
  86. package/dist/wizard/lib/cost-tracker.d.ts +27 -0
  87. package/dist/wizard/lib/cost-tracker.js +37 -0
  88. package/dist/wizard/lib/daemon-aggregator.d.ts +71 -0
  89. package/dist/wizard/lib/daemon-aggregator.js +204 -0
  90. package/dist/wizard/lib/daemon-core.d.ts +6 -0
  91. package/dist/wizard/lib/daemon-core.js +5 -0
  92. package/dist/wizard/lib/dashboard-data.d.ts +132 -0
  93. package/dist/wizard/lib/dashboard-data.js +336 -0
  94. package/dist/wizard/lib/dashboard-ws.d.ts +25 -0
  95. package/dist/wizard/lib/dashboard-ws.js +91 -0
  96. package/dist/wizard/lib/deep-current.d.ts +77 -0
  97. package/dist/wizard/lib/deep-current.js +234 -0
  98. package/dist/wizard/lib/deploy-coordinator.d.ts +40 -0
  99. package/dist/wizard/lib/deploy-coordinator.js +86 -0
  100. package/dist/wizard/lib/deploy-log.d.ts +28 -0
  101. package/dist/wizard/lib/deploy-log.js +52 -0
  102. package/dist/wizard/lib/desktop-notify.d.ts +27 -0
  103. package/dist/wizard/lib/desktop-notify.js +98 -0
  104. package/dist/wizard/lib/dns/cloudflare-dns.d.ts +35 -0
  105. package/dist/wizard/lib/dns/cloudflare-dns.js +216 -0
  106. package/dist/wizard/lib/dns/cloudflare-registrar.d.ts +31 -0
  107. package/dist/wizard/lib/dns/cloudflare-registrar.js +148 -0
  108. package/dist/wizard/lib/dns/types.d.ts +22 -0
  109. package/dist/wizard/lib/dns/types.js +4 -0
  110. package/dist/wizard/lib/document-discovery.d.ts +33 -0
  111. package/dist/wizard/lib/document-discovery.js +145 -0
  112. package/dist/wizard/lib/env-validator.d.ts +14 -0
  113. package/dist/wizard/lib/env-validator.js +205 -0
  114. package/dist/wizard/lib/env-writer.d.ts +13 -0
  115. package/dist/wizard/lib/env-writer.js +26 -0
  116. package/dist/wizard/lib/exec.d.ts +30 -0
  117. package/dist/wizard/lib/exec.js +52 -0
  118. package/dist/wizard/lib/experiment.d.ts +70 -0
  119. package/dist/wizard/lib/experiment.js +169 -0
  120. package/dist/wizard/lib/extensions.d.ts +20 -0
  121. package/dist/wizard/lib/extensions.js +183 -0
  122. package/dist/wizard/lib/financial/adapter-factory.d.ts +47 -0
  123. package/dist/wizard/lib/financial/adapter-factory.js +225 -0
  124. package/dist/wizard/lib/financial/billing/base.d.ts +6 -0
  125. package/dist/wizard/lib/financial/billing/base.js +1 -0
  126. package/dist/wizard/lib/financial/billing/google-billing.d.ts +56 -0
  127. package/dist/wizard/lib/financial/billing/google-billing.js +298 -0
  128. package/dist/wizard/lib/financial/billing/meta-billing.d.ts +54 -0
  129. package/dist/wizard/lib/financial/billing/meta-billing.js +243 -0
  130. package/dist/wizard/lib/financial/billing/tiktok-billing.d.ts +54 -0
  131. package/dist/wizard/lib/financial/billing/tiktok-billing.js +260 -0
  132. package/dist/wizard/lib/financial/campaign/base.d.ts +13 -0
  133. package/dist/wizard/lib/financial/campaign/base.js +1 -0
  134. package/dist/wizard/lib/financial/campaign/google-campaign.d.ts +42 -0
  135. package/dist/wizard/lib/financial/campaign/google-campaign.js +388 -0
  136. package/dist/wizard/lib/financial/campaign/meta-campaign.d.ts +41 -0
  137. package/dist/wizard/lib/financial/campaign/meta-campaign.js +311 -0
  138. package/dist/wizard/lib/financial/campaign/sandbox-campaign.d.ts +45 -0
  139. package/dist/wizard/lib/financial/campaign/sandbox-campaign.js +261 -0
  140. package/dist/wizard/lib/financial/campaign/tiktok-campaign.d.ts +40 -0
  141. package/dist/wizard/lib/financial/campaign/tiktok-campaign.js +350 -0
  142. package/dist/wizard/lib/financial/funding-auto.d.ts +44 -0
  143. package/dist/wizard/lib/financial/funding-auto.js +52 -0
  144. package/dist/wizard/lib/financial/funding-policy.d.ts +60 -0
  145. package/dist/wizard/lib/financial/funding-policy.js +179 -0
  146. package/dist/wizard/lib/financial/platform-planner.d.ts +47 -0
  147. package/dist/wizard/lib/financial/platform-planner.js +134 -0
  148. package/dist/wizard/lib/financial/reconciliation-engine.d.ts +78 -0
  149. package/dist/wizard/lib/financial/reconciliation-engine.js +193 -0
  150. package/dist/wizard/lib/financial/registry.d.ts +22 -0
  151. package/dist/wizard/lib/financial/registry.js +26 -0
  152. package/dist/wizard/lib/financial/reporting.d.ts +96 -0
  153. package/dist/wizard/lib/financial/reporting.js +198 -0
  154. package/dist/wizard/lib/financial/stablecoin/base.d.ts +6 -0
  155. package/dist/wizard/lib/financial/stablecoin/base.js +1 -0
  156. package/dist/wizard/lib/financial/stablecoin/circle.d.ts +54 -0
  157. package/dist/wizard/lib/financial/stablecoin/circle.js +367 -0
  158. package/dist/wizard/lib/financial/stablecoin/mercury.d.ts +24 -0
  159. package/dist/wizard/lib/financial/stablecoin/mercury.js +171 -0
  160. package/dist/wizard/lib/financial/stablecoin/sandbox-stablecoin.d.ts +47 -0
  161. package/dist/wizard/lib/financial/stablecoin/sandbox-stablecoin.js +202 -0
  162. package/dist/wizard/lib/financial/treasury-planner.d.ts +52 -0
  163. package/dist/wizard/lib/financial/treasury-planner.js +128 -0
  164. package/dist/wizard/lib/financial-core.d.ts +6 -0
  165. package/dist/wizard/lib/financial-core.js +5 -0
  166. package/dist/wizard/lib/financial-vault.d.ts +34 -0
  167. package/dist/wizard/lib/financial-vault.js +199 -0
  168. package/dist/wizard/lib/frontmatter.d.ts +30 -0
  169. package/dist/wizard/lib/frontmatter.js +96 -0
  170. package/dist/wizard/lib/gap-analysis.d.ts +37 -0
  171. package/dist/wizard/lib/gap-analysis.js +218 -0
  172. package/dist/wizard/lib/github.d.ts +22 -0
  173. package/dist/wizard/lib/github.js +261 -0
  174. package/dist/wizard/lib/headless-deploy.d.ts +14 -0
  175. package/dist/wizard/lib/headless-deploy.js +452 -0
  176. package/dist/wizard/lib/health-monitor.d.ts +15 -0
  177. package/dist/wizard/lib/health-monitor.js +91 -0
  178. package/dist/wizard/lib/health-poller.d.ts +9 -0
  179. package/dist/wizard/lib/health-poller.js +123 -0
  180. package/dist/wizard/lib/heartbeat.d.ts +15 -0
  181. package/dist/wizard/lib/heartbeat.js +827 -0
  182. package/dist/wizard/lib/http-helpers.d.ts +9 -0
  183. package/dist/wizard/lib/http-helpers.js +24 -0
  184. package/dist/wizard/lib/image-gen.d.ts +56 -0
  185. package/dist/wizard/lib/image-gen.js +159 -0
  186. package/dist/wizard/lib/instance-sizing.d.ts +26 -0
  187. package/dist/wizard/lib/instance-sizing.js +51 -0
  188. package/dist/wizard/lib/kongo/analytics.d.ts +29 -0
  189. package/dist/wizard/lib/kongo/analytics.js +179 -0
  190. package/dist/wizard/lib/kongo/campaigns.d.ts +52 -0
  191. package/dist/wizard/lib/kongo/campaigns.js +91 -0
  192. package/dist/wizard/lib/kongo/client.d.ts +58 -0
  193. package/dist/wizard/lib/kongo/client.js +221 -0
  194. package/dist/wizard/lib/kongo/jobs.d.ts +57 -0
  195. package/dist/wizard/lib/kongo/jobs.js +122 -0
  196. package/dist/wizard/lib/kongo/pages.d.ts +60 -0
  197. package/dist/wizard/lib/kongo/pages.js +150 -0
  198. package/dist/wizard/lib/kongo/provisioner.d.ts +64 -0
  199. package/dist/wizard/lib/kongo/provisioner.js +116 -0
  200. package/dist/wizard/lib/kongo/seed.d.ts +49 -0
  201. package/dist/wizard/lib/kongo/seed.js +237 -0
  202. package/dist/wizard/lib/kongo/types.d.ts +323 -0
  203. package/dist/wizard/lib/kongo/types.js +11 -0
  204. package/dist/wizard/lib/kongo/variants.d.ts +57 -0
  205. package/dist/wizard/lib/kongo/variants.js +88 -0
  206. package/dist/wizard/lib/kongo/webhooks.d.ts +41 -0
  207. package/dist/wizard/lib/kongo/webhooks.js +112 -0
  208. package/dist/wizard/lib/marker.d.ts +28 -0
  209. package/dist/wizard/lib/marker.js +79 -0
  210. package/dist/wizard/lib/migrator.d.ts +35 -0
  211. package/dist/wizard/lib/migrator.js +190 -0
  212. package/dist/wizard/lib/natural-language-deploy.d.ts +30 -0
  213. package/dist/wizard/lib/natural-language-deploy.js +186 -0
  214. package/dist/wizard/lib/network.d.ts +22 -0
  215. package/dist/wizard/lib/network.js +72 -0
  216. package/dist/wizard/lib/oauth-core.d.ts +6 -0
  217. package/dist/wizard/lib/oauth-core.js +5 -0
  218. package/dist/wizard/lib/open-browser.d.ts +1 -0
  219. package/dist/wizard/lib/open-browser.js +26 -0
  220. package/dist/wizard/lib/patterns/ad-billing-adapter.d.ts +209 -0
  221. package/dist/wizard/lib/patterns/ad-billing-adapter.js +269 -0
  222. package/dist/wizard/lib/patterns/ad-platform-adapter.d.ts +200 -0
  223. package/dist/wizard/lib/patterns/ad-platform-adapter.js +212 -0
  224. package/dist/wizard/lib/patterns/daemon-process.d.ts +88 -0
  225. package/dist/wizard/lib/patterns/daemon-process.js +271 -0
  226. package/dist/wizard/lib/patterns/financial-transaction.d.ts +161 -0
  227. package/dist/wizard/lib/patterns/financial-transaction.js +132 -0
  228. package/dist/wizard/lib/patterns/funding-plan.d.ts +136 -0
  229. package/dist/wizard/lib/patterns/funding-plan.js +200 -0
  230. package/dist/wizard/lib/patterns/oauth-token-lifecycle.d.ts +94 -0
  231. package/dist/wizard/lib/patterns/oauth-token-lifecycle.js +139 -0
  232. package/dist/wizard/lib/patterns/outbound-rate-limiter.d.ts +67 -0
  233. package/dist/wizard/lib/patterns/outbound-rate-limiter.js +216 -0
  234. package/dist/wizard/lib/patterns/revenue-source-adapter.d.ts +96 -0
  235. package/dist/wizard/lib/patterns/revenue-source-adapter.js +182 -0
  236. package/dist/wizard/lib/patterns/stablecoin-adapter.d.ts +218 -0
  237. package/dist/wizard/lib/patterns/stablecoin-adapter.js +264 -0
  238. package/dist/wizard/lib/prd-validator.d.ts +39 -0
  239. package/dist/wizard/lib/prd-validator.js +137 -0
  240. package/dist/wizard/lib/project-init.d.ts +24 -0
  241. package/dist/wizard/lib/project-init.js +193 -0
  242. package/dist/wizard/lib/project-registry.d.ts +86 -0
  243. package/dist/wizard/lib/project-registry.js +359 -0
  244. package/dist/wizard/lib/provision-manifest.d.ts +44 -0
  245. package/dist/wizard/lib/provision-manifest.js +164 -0
  246. package/dist/wizard/lib/provisioner-registry.d.ts +15 -0
  247. package/dist/wizard/lib/provisioner-registry.js +34 -0
  248. package/dist/wizard/lib/provisioners/aws-vps.d.ts +6 -0
  249. package/dist/wizard/lib/provisioners/aws-vps.js +643 -0
  250. package/dist/wizard/lib/provisioners/cloudflare.d.ts +6 -0
  251. package/dist/wizard/lib/provisioners/cloudflare.js +300 -0
  252. package/dist/wizard/lib/provisioners/docker.d.ts +6 -0
  253. package/dist/wizard/lib/provisioners/docker.js +75 -0
  254. package/dist/wizard/lib/provisioners/http-client.d.ts +20 -0
  255. package/dist/wizard/lib/provisioners/http-client.js +79 -0
  256. package/dist/wizard/lib/provisioners/railway.d.ts +6 -0
  257. package/dist/wizard/lib/provisioners/railway.js +413 -0
  258. package/dist/wizard/lib/provisioners/scripts/caddyfile.d.ts +10 -0
  259. package/dist/wizard/lib/provisioners/scripts/caddyfile.js +54 -0
  260. package/dist/wizard/lib/provisioners/scripts/deploy-vps.d.ts +10 -0
  261. package/dist/wizard/lib/provisioners/scripts/deploy-vps.js +112 -0
  262. package/dist/wizard/lib/provisioners/scripts/docker-compose.d.ts +11 -0
  263. package/dist/wizard/lib/provisioners/scripts/docker-compose.js +91 -0
  264. package/dist/wizard/lib/provisioners/scripts/dockerfile.d.ts +5 -0
  265. package/dist/wizard/lib/provisioners/scripts/dockerfile.js +185 -0
  266. package/dist/wizard/lib/provisioners/scripts/ecosystem-config.d.ts +10 -0
  267. package/dist/wizard/lib/provisioners/scripts/ecosystem-config.js +36 -0
  268. package/dist/wizard/lib/provisioners/scripts/provision-vps.d.ts +14 -0
  269. package/dist/wizard/lib/provisioners/scripts/provision-vps.js +202 -0
  270. package/dist/wizard/lib/provisioners/scripts/rollback-vps.d.ts +10 -0
  271. package/dist/wizard/lib/provisioners/scripts/rollback-vps.js +67 -0
  272. package/dist/wizard/lib/provisioners/self-deploy.d.ts +41 -0
  273. package/dist/wizard/lib/provisioners/self-deploy.js +185 -0
  274. package/dist/wizard/lib/provisioners/static-s3.d.ts +6 -0
  275. package/dist/wizard/lib/provisioners/static-s3.js +235 -0
  276. package/dist/wizard/lib/provisioners/types.d.ts +40 -0
  277. package/dist/wizard/lib/provisioners/types.js +4 -0
  278. package/dist/wizard/lib/provisioners/vercel.d.ts +6 -0
  279. package/dist/wizard/lib/provisioners/vercel.js +287 -0
  280. package/dist/wizard/lib/pty-manager.d.ts +42 -0
  281. package/dist/wizard/lib/pty-manager.js +231 -0
  282. package/dist/wizard/lib/rate-limiter-core.d.ts +5 -0
  283. package/dist/wizard/lib/rate-limiter-core.js +5 -0
  284. package/dist/wizard/lib/reconciliation.d.ts +43 -0
  285. package/dist/wizard/lib/reconciliation.js +173 -0
  286. package/dist/wizard/lib/revenue-types.d.ts +5 -0
  287. package/dist/wizard/lib/revenue-types.js +1 -0
  288. package/dist/wizard/lib/route-optimizer.d.ts +28 -0
  289. package/dist/wizard/lib/route-optimizer.js +93 -0
  290. package/dist/wizard/lib/s3-deploy.d.ts +19 -0
  291. package/dist/wizard/lib/s3-deploy.js +156 -0
  292. package/dist/wizard/lib/safety-tiers.d.ts +76 -0
  293. package/dist/wizard/lib/safety-tiers.js +134 -0
  294. package/dist/wizard/lib/sentry-generator.d.ts +15 -0
  295. package/dist/wizard/lib/sentry-generator.js +116 -0
  296. package/dist/wizard/lib/server-config.d.ts +13 -0
  297. package/dist/wizard/lib/server-config.js +23 -0
  298. package/dist/wizard/lib/service-install.d.ts +18 -0
  299. package/dist/wizard/lib/service-install.js +182 -0
  300. package/dist/wizard/lib/site-scanner.d.ts +80 -0
  301. package/dist/wizard/lib/site-scanner.js +262 -0
  302. package/dist/wizard/lib/ssh-deploy.d.ts +25 -0
  303. package/dist/wizard/lib/ssh-deploy.js +225 -0
  304. package/dist/wizard/lib/templates.d.ts +24 -0
  305. package/dist/wizard/lib/templates.js +219 -0
  306. package/dist/wizard/lib/totp.d.ts +35 -0
  307. package/dist/wizard/lib/totp.js +276 -0
  308. package/dist/wizard/lib/tower-auth.d.ts +43 -0
  309. package/dist/wizard/lib/tower-auth.js +352 -0
  310. package/dist/wizard/lib/tower-rate-limit.d.ts +14 -0
  311. package/dist/wizard/lib/tower-rate-limit.js +61 -0
  312. package/dist/wizard/lib/tower-session.d.ts +28 -0
  313. package/dist/wizard/lib/tower-session.js +119 -0
  314. package/dist/wizard/lib/treasury-backup.d.ts +23 -0
  315. package/dist/wizard/lib/treasury-backup.js +126 -0
  316. package/dist/wizard/lib/treasury-heartbeat.d.ts +82 -0
  317. package/dist/wizard/lib/treasury-heartbeat.js +1104 -0
  318. package/dist/wizard/lib/updater.d.ts +29 -0
  319. package/dist/wizard/lib/updater.js +190 -0
  320. package/dist/wizard/lib/user-manager.d.ts +39 -0
  321. package/dist/wizard/lib/user-manager.js +182 -0
  322. package/dist/wizard/lib/vault.d.ts +26 -0
  323. package/dist/wizard/lib/vault.js +161 -0
  324. package/dist/wizard/router.d.ts +5 -0
  325. package/dist/wizard/router.js +15 -0
  326. package/dist/wizard/server.d.ts +18 -0
  327. package/dist/wizard/server.js +436 -0
  328. package/package.json +59 -0
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Anomaly Detection — Spend spikes, traffic drops, conversion changes (§9.17).
3
+ *
4
+ * Runs hourly as a heartbeat daemon scheduled job.
5
+ * Compares current metrics against rolling averages.
6
+ * Alerts when deviations exceed thresholds.
7
+ *
8
+ * PRD Reference: §9.7 (hourly anomaly detection), §9.17 (thresholds)
9
+ */
10
+ type Cents = number & {
11
+ readonly __brand: 'Cents';
12
+ };
13
+ type AnomalyType = 'spend_spike' | 'traffic_drop' | 'conversion_change' | 'roas_drop';
14
+ type AnomalySeverity = 'warning' | 'alert' | 'critical';
15
+ interface Anomaly {
16
+ type: AnomalyType;
17
+ severity: AnomalySeverity;
18
+ platform?: string;
19
+ metric: string;
20
+ currentValue: number;
21
+ expectedValue: number;
22
+ deviationPercent: number;
23
+ message: string;
24
+ timestamp: string;
25
+ }
26
+ declare const THRESHOLDS: {
27
+ spendSpikeWarning: number;
28
+ spendSpikeAlert: number;
29
+ spendSpikeCritical: number;
30
+ trafficDropWarning: number;
31
+ trafficDropAlert: number;
32
+ trafficDropCritical: number;
33
+ conversionChangeThreshold: number;
34
+ roasDropWarning: number;
35
+ roasDropAlert: number;
36
+ };
37
+ /** Run all anomaly checks for the current period */
38
+ export declare function runAnomalyDetection(metrics: {
39
+ spendByPlatform: Array<{
40
+ platform: string;
41
+ currentHour: Cents;
42
+ avgHourly: Cents;
43
+ }>;
44
+ traffic: {
45
+ currentDay: number;
46
+ avgDaily: number;
47
+ };
48
+ conversion: {
49
+ currentRate: number;
50
+ avgRate: number;
51
+ };
52
+ roasByPlatform: Array<{
53
+ platform: string;
54
+ current: number;
55
+ avg: number;
56
+ }>;
57
+ }): Anomaly[];
58
+ export type { Anomaly, AnomalyType, AnomalySeverity };
59
+ export { THRESHOLDS };
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Anomaly Detection — Spend spikes, traffic drops, conversion changes (§9.17).
3
+ *
4
+ * Runs hourly as a heartbeat daemon scheduled job.
5
+ * Compares current metrics against rolling averages.
6
+ * Alerts when deviations exceed thresholds.
7
+ *
8
+ * PRD Reference: §9.7 (hourly anomaly detection), §9.17 (thresholds)
9
+ */
10
+ // ── Thresholds ────────────────────────────────────────
11
+ const THRESHOLDS = {
12
+ // Spend spike: current hour spend > X% of daily average hourly spend
13
+ spendSpikeWarning: 50, // 50% above average
14
+ spendSpikeAlert: 100, // 100% above average (double)
15
+ spendSpikeCritical: 200, // 200% above average (triple)
16
+ // Traffic drop: current day traffic > X% below 7-day average
17
+ trafficDropWarning: 20, // 20% below average
18
+ trafficDropAlert: 40, // 40% below average
19
+ trafficDropCritical: 60, // 60% below average
20
+ // Conversion rate change: > X% from 7-day average
21
+ conversionChangeThreshold: 20, // 20% change in either direction
22
+ // ROAS drop: current < X% of 7-day average
23
+ roasDropWarning: 20, // 20% below average
24
+ roasDropAlert: 40, // 40% below average
25
+ };
26
+ // ── Detection Functions ───────────────────────────────
27
+ function detectSpendSpike(currentHourSpend, avgHourlySpend, platform) {
28
+ if (avgHourlySpend === 0)
29
+ return null;
30
+ const deviation = ((currentHourSpend - avgHourlySpend) / avgHourlySpend) * 100;
31
+ if (deviation < THRESHOLDS.spendSpikeWarning)
32
+ return null;
33
+ const severity = deviation >= THRESHOLDS.spendSpikeCritical ? 'critical' :
34
+ deviation >= THRESHOLDS.spendSpikeAlert ? 'alert' : 'warning';
35
+ return {
36
+ type: 'spend_spike',
37
+ severity,
38
+ platform,
39
+ metric: 'hourly_spend',
40
+ currentValue: currentHourSpend,
41
+ expectedValue: avgHourlySpend,
42
+ deviationPercent: Math.round(deviation),
43
+ message: `Spend spike on ${platform}: $${(currentHourSpend / 100).toFixed(2)}/hr vs $${(avgHourlySpend / 100).toFixed(2)}/hr average (+${Math.round(deviation)}%)`,
44
+ timestamp: new Date().toISOString(),
45
+ };
46
+ }
47
+ function detectTrafficDrop(currentDayTraffic, avgDailyTraffic) {
48
+ if (avgDailyTraffic === 0)
49
+ return null;
50
+ const deviation = ((avgDailyTraffic - currentDayTraffic) / avgDailyTraffic) * 100;
51
+ if (deviation < THRESHOLDS.trafficDropWarning)
52
+ return null;
53
+ const severity = deviation >= THRESHOLDS.trafficDropCritical ? 'critical' :
54
+ deviation >= THRESHOLDS.trafficDropAlert ? 'alert' : 'warning';
55
+ return {
56
+ type: 'traffic_drop',
57
+ severity,
58
+ metric: 'daily_traffic',
59
+ currentValue: currentDayTraffic,
60
+ expectedValue: avgDailyTraffic,
61
+ deviationPercent: -Math.round(deviation),
62
+ message: `Traffic drop: ${currentDayTraffic} visitors today vs ${avgDailyTraffic} average (-${Math.round(deviation)}%)`,
63
+ timestamp: new Date().toISOString(),
64
+ };
65
+ }
66
+ function detectConversionChange(currentRate, avgRate) {
67
+ if (avgRate === 0)
68
+ return null;
69
+ const deviation = ((currentRate - avgRate) / avgRate) * 100;
70
+ if (Math.abs(deviation) < THRESHOLDS.conversionChangeThreshold)
71
+ return null;
72
+ return {
73
+ type: 'conversion_change',
74
+ severity: Math.abs(deviation) >= 40 ? 'alert' : 'warning',
75
+ metric: 'conversion_rate',
76
+ currentValue: currentRate,
77
+ expectedValue: avgRate,
78
+ deviationPercent: Math.round(deviation),
79
+ message: `Conversion rate ${deviation > 0 ? 'increase' : 'decrease'}: ${currentRate.toFixed(1)}% vs ${avgRate.toFixed(1)}% average (${deviation > 0 ? '+' : ''}${Math.round(deviation)}%)`,
80
+ timestamp: new Date().toISOString(),
81
+ };
82
+ }
83
+ function detectRoasDrop(currentRoas, avgRoas, platform) {
84
+ if (avgRoas === 0)
85
+ return null;
86
+ const deviation = ((avgRoas - currentRoas) / avgRoas) * 100;
87
+ if (deviation < THRESHOLDS.roasDropWarning)
88
+ return null;
89
+ return {
90
+ type: 'roas_drop',
91
+ severity: deviation >= THRESHOLDS.roasDropAlert ? 'alert' : 'warning',
92
+ platform,
93
+ metric: 'roas',
94
+ currentValue: currentRoas,
95
+ expectedValue: avgRoas,
96
+ deviationPercent: -Math.round(deviation),
97
+ message: `ROAS drop on ${platform}: ${currentRoas.toFixed(1)}x vs ${avgRoas.toFixed(1)}x average (-${Math.round(deviation)}%)`,
98
+ timestamp: new Date().toISOString(),
99
+ };
100
+ }
101
+ /** Run all anomaly checks for the current period */
102
+ export function runAnomalyDetection(metrics) {
103
+ const anomalies = [];
104
+ for (const s of metrics.spendByPlatform) {
105
+ const a = detectSpendSpike(s.currentHour, s.avgHourly, s.platform);
106
+ if (a)
107
+ anomalies.push(a);
108
+ }
109
+ const td = detectTrafficDrop(metrics.traffic.currentDay, metrics.traffic.avgDaily);
110
+ if (td)
111
+ anomalies.push(td);
112
+ const cc = detectConversionChange(metrics.conversion.currentRate, metrics.conversion.avgRate);
113
+ if (cc)
114
+ anomalies.push(cc);
115
+ for (const r of metrics.roasByPlatform) {
116
+ const a = detectRoasDrop(r.current, r.avg, r.platform);
117
+ if (a)
118
+ anomalies.push(a);
119
+ }
120
+ return anomalies;
121
+ }
122
+ export { THRESHOLDS };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Anthropic API utilities — model resolution and helpers.
3
+ *
4
+ * Fetches available models from the API and picks the best one
5
+ * for PRD generation. No hardcoded model IDs.
6
+ */
7
+ export interface ResolvedModel {
8
+ id: string;
9
+ maxTokens: number;
10
+ }
11
+ /**
12
+ * Resolve the best available model for PRD generation.
13
+ *
14
+ * Strategy: pick the newest Opus (most capable — PRD generation is a one-time
15
+ * operation where quality matters most). Falls back to Sonnet, then Haiku.
16
+ */
17
+ export declare function resolveBestModel(apiKey: string): Promise<string>;
18
+ /** Resolve model ID + max output tokens for the selected model */
19
+ export declare function resolveModelWithLimits(apiKey: string): Promise<ResolvedModel>;
20
+ /** Clear the cached model (e.g., if the API key changes) */
21
+ export declare function clearModelCache(): void;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Anthropic API utilities — model resolution and helpers.
3
+ *
4
+ * Fetches available models from the API and picks the best one
5
+ * for PRD generation. No hardcoded model IDs.
6
+ */
7
+ import { request as httpsRequest } from 'node:https';
8
+ /** Preference order: most capable first, then newest within family */
9
+ const MODEL_PREFERENCE = [
10
+ 'claude-opus',
11
+ 'claude-sonnet',
12
+ 'claude-haiku',
13
+ ];
14
+ /** Max output tokens by model family — use each model's full capacity */
15
+ const MAX_OUTPUT_TOKENS = {
16
+ 'claude-opus': 32768,
17
+ 'claude-sonnet': 16384,
18
+ 'claude-haiku': 8192,
19
+ };
20
+ const DEFAULT_MAX_TOKENS = 16384;
21
+ let cachedModel = null;
22
+ /** Fetch available models from the Anthropic API */
23
+ function fetchModels(apiKey) {
24
+ return new Promise((resolve, reject) => {
25
+ const req = httpsRequest({
26
+ hostname: 'api.anthropic.com',
27
+ path: '/v1/models',
28
+ method: 'GET',
29
+ headers: {
30
+ 'x-api-key': apiKey,
31
+ 'anthropic-version': '2023-06-01',
32
+ },
33
+ timeout: 10000,
34
+ }, (res) => {
35
+ let body = '';
36
+ res.on('data', (chunk) => { body += chunk.toString(); });
37
+ res.on('end', () => {
38
+ if (res.statusCode !== 200) {
39
+ reject(new Error(`Models API returned ${res.statusCode}: ${body}`));
40
+ return;
41
+ }
42
+ try {
43
+ const parsed = JSON.parse(body);
44
+ resolve(parsed.data ?? []);
45
+ }
46
+ catch {
47
+ reject(new Error('Failed to parse models response'));
48
+ }
49
+ });
50
+ });
51
+ req.on('error', reject);
52
+ req.on('timeout', () => {
53
+ req.destroy();
54
+ reject(new Error('Models request timed out'));
55
+ });
56
+ req.end();
57
+ });
58
+ }
59
+ /**
60
+ * Resolve the best available model for PRD generation.
61
+ *
62
+ * Strategy: pick the newest Opus (most capable — PRD generation is a one-time
63
+ * operation where quality matters most). Falls back to Sonnet, then Haiku.
64
+ */
65
+ export async function resolveBestModel(apiKey) {
66
+ if (cachedModel)
67
+ return cachedModel;
68
+ let models;
69
+ try {
70
+ models = await fetchModels(apiKey);
71
+ }
72
+ catch {
73
+ // If we can't reach the models endpoint, fall back to a known-good model.
74
+ // This is the one hardcoded fallback — everything else is dynamic.
75
+ return 'claude-sonnet-4-6';
76
+ }
77
+ if (models.length === 0) {
78
+ return 'claude-sonnet-4-6';
79
+ }
80
+ // Sort each model into preference buckets, newest first within each bucket
81
+ for (const prefix of MODEL_PREFERENCE) {
82
+ const matches = models
83
+ .filter((m) => m.id.startsWith(prefix))
84
+ .sort((a, b) => b.created_at.localeCompare(a.created_at));
85
+ if (matches.length > 0) {
86
+ cachedModel = matches[0].id;
87
+ return cachedModel;
88
+ }
89
+ }
90
+ // Nothing matched our preferences — pick the newest model overall
91
+ const sorted = [...models].sort((a, b) => b.created_at.localeCompare(a.created_at));
92
+ cachedModel = sorted[0].id;
93
+ return cachedModel;
94
+ }
95
+ /** Resolve model ID + max output tokens for the selected model */
96
+ export async function resolveModelWithLimits(apiKey) {
97
+ const id = await resolveBestModel(apiKey);
98
+ const family = MODEL_PREFERENCE.find((prefix) => id.startsWith(prefix));
99
+ const maxTokens = family ? (MAX_OUTPUT_TOKENS[family] ?? DEFAULT_MAX_TOKENS) : DEFAULT_MAX_TOKENS;
100
+ return { id, maxTokens };
101
+ }
102
+ /** Clear the cached model (e.g., if the API key changes) */
103
+ export function clearModelCache() {
104
+ cachedModel = null;
105
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * PRD asset scanner — identifies image/visual requirements from PRD prose.
3
+ * Used by Celebrimbor's /imagine command to find what needs generating.
4
+ * Pure text analysis — no API calls, no side effects.
5
+ */
6
+ export interface AssetRequirement {
7
+ description: string;
8
+ category: string;
9
+ context: string;
10
+ width: number;
11
+ height: number;
12
+ section: string;
13
+ }
14
+ /**
15
+ * Scan a PRD document for visual asset requirements.
16
+ * Returns a list of assets that need generating.
17
+ */
18
+ export declare function scanPrdForAssets(prdContent: string): AssetRequirement[];
19
+ /**
20
+ * Extract brand/style keywords from the PRD for style prefix generation.
21
+ * Looks for Section 14 (Brand) or any section mentioning "brand", "style", "aesthetic".
22
+ */
23
+ export declare function extractBrandStyle(prdContent: string): string[];
@@ -0,0 +1,107 @@
1
+ /**
2
+ * PRD asset scanner — identifies image/visual requirements from PRD prose.
3
+ * Used by Celebrimbor's /imagine command to find what needs generating.
4
+ * Pure text analysis — no API calls, no side effects.
5
+ */
6
+ /** Patterns that indicate a visual asset requirement in PRD prose. */
7
+ const ASSET_PATTERNS = [
8
+ { pattern: /illustrat(?:ion|ed|e)/i, category: 'illustration' },
9
+ { pattern: /portrait/i, category: 'portrait' },
10
+ { pattern: /silhouette/i, category: 'portrait' },
11
+ { pattern: /avatar/i, category: 'portrait' },
12
+ { pattern: /(?:custom\s+)?\bicon\b/i, category: 'icon' },
13
+ { pattern: /og[:\s-]image/i, category: 'og-image' },
14
+ { pattern: /social\s+(?:sharing\s+)?image/i, category: 'og-image' },
15
+ { pattern: /hero\s+(?:image|banner|art)/i, category: 'hero' },
16
+ { pattern: /splash\s+(?:page|screen)/i, category: 'hero' },
17
+ { pattern: /background\s+image/i, category: 'background' },
18
+ { pattern: /cover\s+image/i, category: 'background' },
19
+ { pattern: /\blogo\b/i, category: 'logo' },
20
+ { pattern: /\bfavicon\b/i, category: 'icon' },
21
+ { pattern: /comic\s+strip/i, category: 'illustration' },
22
+ { pattern: /comic\s+panel/i, category: 'illustration' },
23
+ { pattern: /screenshot/i, category: 'screenshot' },
24
+ { pattern: /mockup/i, category: 'screenshot' },
25
+ ];
26
+ /** Default dimensions per asset category. */
27
+ const CATEGORY_DIMENSIONS = {
28
+ 'portrait': { width: 1024, height: 1024 },
29
+ 'illustration': { width: 1024, height: 1024 },
30
+ 'og-image': { width: 1200, height: 630 },
31
+ 'hero': { width: 1792, height: 1024 },
32
+ 'background': { width: 1792, height: 1024 },
33
+ 'logo': { width: 512, height: 512 },
34
+ 'icon': { width: 512, height: 512 },
35
+ 'screenshot': { width: 1280, height: 720 },
36
+ };
37
+ /**
38
+ * Scan a PRD document for visual asset requirements.
39
+ * Returns a list of assets that need generating.
40
+ */
41
+ export function scanPrdForAssets(prdContent) {
42
+ const assets = [];
43
+ const lines = prdContent.split('\n');
44
+ let currentSection = '';
45
+ for (let i = 0; i < lines.length; i++) {
46
+ const line = lines[i];
47
+ // Track section headers
48
+ const headerMatch = line.match(/^#{1,4}\s+(.+)/);
49
+ if (headerMatch) {
50
+ currentSection = headerMatch[1].trim();
51
+ continue;
52
+ }
53
+ // Check each line against asset patterns
54
+ for (const { pattern, category } of ASSET_PATTERNS) {
55
+ if (pattern.test(line)) {
56
+ // Extract surrounding context (current line + next line for description)
57
+ const contextLines = lines.slice(Math.max(0, i - 1), Math.min(lines.length, i + 3));
58
+ const context = contextLines.join(' ').trim();
59
+ const dims = CATEGORY_DIMENSIONS[category] || { width: 1024, height: 1024 };
60
+ assets.push({
61
+ description: line.trim(),
62
+ category,
63
+ context,
64
+ width: dims.width,
65
+ height: dims.height,
66
+ section: currentSection,
67
+ });
68
+ break; // One match per line is enough
69
+ }
70
+ }
71
+ }
72
+ // Deduplicate by description similarity
73
+ const seen = new Set();
74
+ return assets.filter(a => {
75
+ const key = a.description.toLowerCase().slice(0, 60);
76
+ if (seen.has(key))
77
+ return false;
78
+ seen.add(key);
79
+ return true;
80
+ });
81
+ }
82
+ /**
83
+ * Extract brand/style keywords from the PRD for style prefix generation.
84
+ * Looks for Section 14 (Brand) or any section mentioning "brand", "style", "aesthetic".
85
+ */
86
+ export function extractBrandStyle(prdContent) {
87
+ const keywords = [];
88
+ const lines = prdContent.split('\n');
89
+ let inBrandSection = false;
90
+ for (const line of lines) {
91
+ const headerMatch = line.match(/^#{1,4}\s+(.+)/);
92
+ if (headerMatch) {
93
+ const title = headerMatch[1].toLowerCase();
94
+ inBrandSection = title.includes('brand') || title.includes('style') || title.includes('aesthetic') || title.includes('design') || title.includes('personality');
95
+ continue;
96
+ }
97
+ if (inBrandSection && line.trim()) {
98
+ // Extract adjectives and style keywords
99
+ const styleWords = line.match(/\b(minimal|bold|playful|professional|elegant|modern|retro|vintage|comic|pulp|neon|dark|light|cinematic|warm|cool|vibrant|muted|halftone|watercolor|photorealistic|illustration|flat|gradient|geometric|organic)\b/gi);
100
+ if (styleWords) {
101
+ keywords.push(...styleWords.map(w => w.toLowerCase()));
102
+ }
103
+ }
104
+ }
105
+ // Deduplicate
106
+ return [...new Set(keywords)];
107
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Audit Log — Append-only JSON lines logger for Avengers Tower Remote.
3
+ *
4
+ * Layer 5 of the 5-layer security architecture.
5
+ * Every security-relevant action is recorded.
6
+ * File permissions: 0600 (owner read/write only).
7
+ * Rotation: at 10MB, rename to .1 and start fresh.
8
+ */
9
+ export type AuditEventType = 'login_attempt' | 'login_success' | 'login_failure' | 'logout' | 'session_create' | 'session_expire' | 'vault_unlock' | 'vault_lock' | 'terminal_start' | 'terminal_end' | 'ssh_connect' | 'deploy' | 'credential_access' | 'project_create' | 'project_delete' | 'health_failure' | 'user_create' | 'user_remove' | 'role_change' | 'invite_create' | 'invite_complete' | 'access_denied' | 'access_grant' | 'access_revoke';
10
+ export interface AuditEntry {
11
+ timestamp: string;
12
+ event: AuditEventType;
13
+ ip: string;
14
+ user: string;
15
+ details: Record<string, string | number | boolean>;
16
+ }
17
+ /** Ensure the log directory exists. Called once on startup. */
18
+ export declare function initAuditLog(): Promise<void>;
19
+ /**
20
+ * Append an audit entry. Never throws — logging must not crash the server.
21
+ * If the write fails, the entry is lost (acceptable tradeoff vs. crashing).
22
+ */
23
+ export declare function audit(event: AuditEventType, ip: string, user: string, details?: Record<string, string | number | boolean>): Promise<void>;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Audit Log — Append-only JSON lines logger for Avengers Tower Remote.
3
+ *
4
+ * Layer 5 of the 5-layer security architecture.
5
+ * Every security-relevant action is recorded.
6
+ * File permissions: 0600 (owner read/write only).
7
+ * Rotation: at 10MB, rename to .1 and start fresh.
8
+ */
9
+ import { appendFile, stat, rename, mkdir } from 'node:fs/promises';
10
+ import { join } from 'node:path';
11
+ import { homedir } from 'node:os';
12
+ const VOIDFORGE_DIR = join(homedir(), '.voidforge');
13
+ const LOG_PATH = join(VOIDFORGE_DIR, 'audit.log');
14
+ const MAX_SIZE_BYTES = 10 * 1024 * 1024; // 10MB rotation threshold
15
+ let initialized = false;
16
+ /** Ensure the log directory exists. Called once on startup. */
17
+ export async function initAuditLog() {
18
+ if (initialized)
19
+ return;
20
+ await mkdir(VOIDFORGE_DIR, { recursive: true });
21
+ initialized = true;
22
+ }
23
+ const MAX_ROTATIONS = 7; // Keep 7 rotated files (.1 through .7) for financial audit trail
24
+ /** Check if log needs rotation and rotate if so. */
25
+ async function rotateIfNeeded() {
26
+ try {
27
+ const stats = await stat(LOG_PATH);
28
+ if (stats.size >= MAX_SIZE_BYTES) {
29
+ // v17.0: 7-rotation scheme instead of single .1 (preserves financial audit trail).
30
+ // Shift .6 → .7, .5 → .6, ... .1 → .2, then current → .1
31
+ for (let i = MAX_ROTATIONS - 1; i >= 1; i--) {
32
+ try {
33
+ await rename(LOG_PATH + '.' + i, LOG_PATH + '.' + (i + 1));
34
+ }
35
+ catch { /* file doesn't exist at this slot — skip */ }
36
+ }
37
+ await rename(LOG_PATH, LOG_PATH + '.1');
38
+ }
39
+ }
40
+ catch {
41
+ // File doesn't exist yet — that's fine
42
+ }
43
+ }
44
+ /**
45
+ * Append an audit entry. Never throws — logging must not crash the server.
46
+ * If the write fails, the entry is lost (acceptable tradeoff vs. crashing).
47
+ */
48
+ export async function audit(event, ip, user, details = {}) {
49
+ try {
50
+ if (!initialized)
51
+ await initAuditLog();
52
+ await rotateIfNeeded();
53
+ const entry = {
54
+ timestamp: new Date().toISOString(),
55
+ event,
56
+ ip,
57
+ user,
58
+ details,
59
+ };
60
+ // JSON lines format: one JSON object per line, newline-terminated
61
+ const line = JSON.stringify(entry) + '\n';
62
+ // Append with 0600 permissions (creates file if needed)
63
+ await appendFile(LOG_PATH, line, { mode: 0o600 });
64
+ }
65
+ catch {
66
+ // Audit logging must never crash the server.
67
+ // If we can't write, the entry is lost — but the server stays up.
68
+ console.error('Audit log write failed');
69
+ }
70
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Autonomy Controller — Tier 2 supervised + Tier 3 full autonomy (v12.3-v12.4).
3
+ *
4
+ * Manages the autonomous execution loop: proposal → delay → execute/veto.
5
+ * Implements circuit breakers, kill switch, deploy freeze, strategic sync.
6
+ *
7
+ * PRD Reference: ROADMAP v12.3-v12.4, DEEP_CURRENT.md Autonomy Tiers + Security
8
+ */
9
+ import type { CampaignProposal } from './campaign-proposer.js';
10
+ interface AutonomyState {
11
+ tier: 1 | 2 | 3;
12
+ active: boolean;
13
+ stopped: boolean;
14
+ pendingProposal?: {
15
+ proposal: CampaignProposal;
16
+ proposedAt: string;
17
+ executeAt: string;
18
+ vetoed: boolean;
19
+ };
20
+ campaignsRun: number;
21
+ consecutiveCampaigns: number;
22
+ lastHumanReview: string;
23
+ lastStrategicSync: string;
24
+ circuitBreakers: {
25
+ driftScore: number;
26
+ consecutiveCriticals: number;
27
+ spendIncreaseStreak: number;
28
+ roasBelow1: number;
29
+ };
30
+ deployFreezeWindows: Array<{
31
+ dayOfWeek: number;
32
+ startHour: number;
33
+ endHour: number;
34
+ }>;
35
+ }
36
+ declare const AUTONOMY_STATE_PATH: string;
37
+ declare const DEFAULT_STATE: AutonomyState;
38
+ export declare function loadAutonomyState(): Promise<AutonomyState>;
39
+ export declare function saveAutonomyState(state: AutonomyState): Promise<void>;
40
+ interface CircuitBreakerResult {
41
+ safe: boolean;
42
+ reason?: string;
43
+ action?: 'pause' | 'downgrade_to_tier1' | 'stop';
44
+ }
45
+ /**
46
+ * Check all circuit breakers. Returns whether autonomous operation should continue.
47
+ */
48
+ export declare function checkCircuitBreakers(state: AutonomyState): CircuitBreakerResult;
49
+ /**
50
+ * Queue a proposal for Tier 2 execution (24h delay).
51
+ */
52
+ export declare function queueProposal(state: AutonomyState, proposal: CampaignProposal): AutonomyState;
53
+ /**
54
+ * Check if a pending Tier 2 proposal is ready to execute.
55
+ */
56
+ export declare function isProposalReady(state: AutonomyState): boolean;
57
+ /**
58
+ * Veto a pending Tier 2 proposal.
59
+ */
60
+ export declare function vetoProposal(state: AutonomyState): AutonomyState;
61
+ export declare function engageKillSwitch(state: AutonomyState): AutonomyState;
62
+ export declare function disengageKillSwitch(state: AutonomyState): AutonomyState;
63
+ export declare function recordStrategicSync(state: AutonomyState): AutonomyState;
64
+ export declare function recordCampaignComplete(state: AutonomyState): AutonomyState;
65
+ interface SoftLimits {
66
+ maxConsecutiveMissions: number;
67
+ maxDeploysPerDay: number;
68
+ aggregateDailySpendCeiling: number;
69
+ strategicDriftThreshold: number;
70
+ explorationBudgetPercent: number;
71
+ lessonDecayHalfLifeDays: number;
72
+ minRoasBeforeFreeze: number;
73
+ }
74
+ declare const DEFAULT_SOFT_LIMITS: SoftLimits;
75
+ export type { AutonomyState, CircuitBreakerResult, SoftLimits };
76
+ export { DEFAULT_STATE, DEFAULT_SOFT_LIMITS, AUTONOMY_STATE_PATH };