@vorionsys/atsf-core 0.2.3 → 0.3.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 (437) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/LICENSE +1 -1
  3. package/README.md +82 -29
  4. package/dist/adapters/base-adapter.d.ts +94 -0
  5. package/dist/adapters/base-adapter.d.ts.map +1 -0
  6. package/dist/adapters/base-adapter.js +233 -0
  7. package/dist/adapters/base-adapter.js.map +1 -0
  8. package/dist/adapters/index.d.ts +9 -0
  9. package/dist/adapters/index.d.ts.map +1 -0
  10. package/dist/adapters/index.js +5 -0
  11. package/dist/adapters/index.js.map +1 -0
  12. package/dist/adapters/types.d.ts +83 -0
  13. package/dist/adapters/types.d.ts.map +1 -0
  14. package/dist/adapters/types.js +4 -0
  15. package/dist/adapters/types.js.map +1 -0
  16. package/dist/adapters/webhook-handler.d.ts +64 -0
  17. package/dist/adapters/webhook-handler.d.ts.map +1 -0
  18. package/dist/adapters/webhook-handler.js +170 -0
  19. package/dist/adapters/webhook-handler.js.map +1 -0
  20. package/dist/api/index.d.ts +1 -1
  21. package/dist/api/index.d.ts.map +1 -1
  22. package/dist/api/index.js +3 -1
  23. package/dist/api/index.js.map +1 -1
  24. package/dist/api/server.d.ts +2 -2
  25. package/dist/api/server.d.ts.map +1 -1
  26. package/dist/api/server.js +149 -184
  27. package/dist/api/server.js.map +1 -1
  28. package/dist/arbitration/index.d.ts +4 -12
  29. package/dist/arbitration/index.d.ts.map +1 -1
  30. package/dist/arbitration/index.js +43 -46
  31. package/dist/arbitration/index.js.map +1 -1
  32. package/dist/arbitration/types.d.ts +10 -10
  33. package/dist/arbitration/types.d.ts.map +1 -1
  34. package/dist/arbitration/types.js +2 -8
  35. package/dist/arbitration/types.js.map +1 -1
  36. package/dist/basis/evaluator.d.ts +1 -6
  37. package/dist/basis/evaluator.d.ts.map +1 -1
  38. package/dist/basis/evaluator.js +56 -56
  39. package/dist/basis/evaluator.js.map +1 -1
  40. package/dist/basis/index.d.ts +3 -3
  41. package/dist/basis/index.d.ts.map +1 -1
  42. package/dist/basis/index.js +5 -3
  43. package/dist/basis/index.js.map +1 -1
  44. package/dist/basis/parser.d.ts +30 -30
  45. package/dist/basis/parser.d.ts.map +1 -1
  46. package/dist/basis/parser.js +27 -32
  47. package/dist/basis/parser.js.map +1 -1
  48. package/dist/basis/types.d.ts +2 -2
  49. package/dist/basis/types.d.ts.map +1 -1
  50. package/dist/basis/types.js +2 -3
  51. package/dist/basis/types.js.map +1 -1
  52. package/dist/chain/index.d.ts +0 -8
  53. package/dist/chain/index.d.ts.map +1 -1
  54. package/dist/chain/index.js +18 -16
  55. package/dist/chain/index.js.map +1 -1
  56. package/dist/cognigate/index.d.ts +1 -9
  57. package/dist/cognigate/index.d.ts.map +1 -1
  58. package/dist/cognigate/index.js +35 -44
  59. package/dist/cognigate/index.js.map +1 -1
  60. package/dist/common/adapters.d.ts +4 -4
  61. package/dist/common/adapters.d.ts.map +1 -1
  62. package/dist/common/adapters.js +54 -70
  63. package/dist/common/adapters.js.map +1 -1
  64. package/dist/common/config.d.ts +69 -68
  65. package/dist/common/config.d.ts.map +1 -1
  66. package/dist/common/config.js +52 -50
  67. package/dist/common/config.js.map +1 -1
  68. package/dist/common/index.d.ts +4 -4
  69. package/dist/common/index.d.ts.map +1 -1
  70. package/dist/common/index.js +6 -4
  71. package/dist/common/index.js.map +1 -1
  72. package/dist/common/logger.d.ts +1 -1
  73. package/dist/common/logger.d.ts.map +1 -1
  74. package/dist/common/logger.js +10 -8
  75. package/dist/common/logger.js.map +1 -1
  76. package/dist/common/types.d.ts +12 -12
  77. package/dist/common/types.d.ts.map +1 -1
  78. package/dist/common/types.js +7 -14
  79. package/dist/common/types.js.map +1 -1
  80. package/dist/containment/index.d.ts +3 -11
  81. package/dist/containment/index.d.ts.map +1 -1
  82. package/dist/containment/index.js +107 -119
  83. package/dist/containment/index.js.map +1 -1
  84. package/dist/containment/types.d.ts +11 -11
  85. package/dist/containment/types.d.ts.map +1 -1
  86. package/dist/containment/types.js +2 -8
  87. package/dist/containment/types.js.map +1 -1
  88. package/dist/contracts/index.d.ts +9 -17
  89. package/dist/contracts/index.d.ts.map +1 -1
  90. package/dist/contracts/index.js +56 -59
  91. package/dist/contracts/index.js.map +1 -1
  92. package/dist/contracts/types.d.ts +12 -12
  93. package/dist/contracts/types.d.ts.map +1 -1
  94. package/dist/contracts/types.js +2 -8
  95. package/dist/contracts/types.js.map +1 -1
  96. package/dist/crewai/callback.d.ts +2 -9
  97. package/dist/crewai/callback.d.ts.map +1 -1
  98. package/dist/crewai/callback.js +29 -27
  99. package/dist/crewai/callback.js.map +1 -1
  100. package/dist/crewai/executor.d.ts +95 -11
  101. package/dist/crewai/executor.d.ts.map +1 -1
  102. package/dist/crewai/executor.js +459 -16
  103. package/dist/crewai/executor.js.map +1 -1
  104. package/dist/crewai/index.d.ts +4 -4
  105. package/dist/crewai/index.d.ts.map +1 -1
  106. package/dist/crewai/index.js +6 -4
  107. package/dist/crewai/index.js.map +1 -1
  108. package/dist/crewai/tools.d.ts +1 -1
  109. package/dist/crewai/tools.d.ts.map +1 -1
  110. package/dist/crewai/tools.js +40 -46
  111. package/dist/crewai/tools.js.map +1 -1
  112. package/dist/crewai/types.d.ts +66 -3
  113. package/dist/crewai/types.d.ts.map +1 -1
  114. package/dist/crewai/types.js +2 -7
  115. package/dist/crewai/types.js.map +1 -1
  116. package/dist/enforce/index.d.ts +226 -19
  117. package/dist/enforce/index.d.ts.map +1 -1
  118. package/dist/enforce/index.js +55 -81
  119. package/dist/enforce/index.js.map +1 -1
  120. package/dist/enforce/trust-aware-enforcement-service.d.ts +8 -23
  121. package/dist/enforce/trust-aware-enforcement-service.d.ts.map +1 -1
  122. package/dist/enforce/trust-aware-enforcement-service.js +109 -125
  123. package/dist/enforce/trust-aware-enforcement-service.js.map +1 -1
  124. package/dist/governance/fluid-workflow.d.ts +8 -16
  125. package/dist/governance/fluid-workflow.d.ts.map +1 -1
  126. package/dist/governance/fluid-workflow.js +88 -114
  127. package/dist/governance/fluid-workflow.js.map +1 -1
  128. package/dist/governance/index.d.ts +7 -15
  129. package/dist/governance/index.d.ts.map +1 -1
  130. package/dist/governance/index.js +76 -81
  131. package/dist/governance/index.js.map +1 -1
  132. package/dist/governance/proof-bridge.d.ts +6 -6
  133. package/dist/governance/proof-bridge.d.ts.map +1 -1
  134. package/dist/governance/proof-bridge.js +6 -16
  135. package/dist/governance/proof-bridge.js.map +1 -1
  136. package/dist/governance/types.d.ts +9 -16
  137. package/dist/governance/types.d.ts.map +1 -1
  138. package/dist/governance/types.js +2 -8
  139. package/dist/governance/types.js.map +1 -1
  140. package/dist/index.d.ts +30 -29
  141. package/dist/index.d.ts.map +1 -1
  142. package/dist/index.js +33 -31
  143. package/dist/index.js.map +1 -1
  144. package/dist/intent/index.d.ts +55 -18
  145. package/dist/intent/index.d.ts.map +1 -1
  146. package/dist/intent/index.js +25 -26
  147. package/dist/intent/index.js.map +1 -1
  148. package/dist/intent/persistent-intent-service.d.ts +2 -17
  149. package/dist/intent/persistent-intent-service.d.ts.map +1 -1
  150. package/dist/intent/persistent-intent-service.js +33 -43
  151. package/dist/intent/persistent-intent-service.js.map +1 -1
  152. package/dist/intent/supabase-intent-repository.d.ts +107 -0
  153. package/dist/intent/supabase-intent-repository.d.ts.map +1 -0
  154. package/dist/intent/supabase-intent-repository.js +406 -0
  155. package/dist/intent/supabase-intent-repository.js.map +1 -0
  156. package/dist/intent-gateway/index.d.ts +5 -28
  157. package/dist/intent-gateway/index.d.ts.map +1 -1
  158. package/dist/intent-gateway/index.js +341 -508
  159. package/dist/intent-gateway/index.js.map +1 -1
  160. package/dist/langchain/callback.d.ts +2 -9
  161. package/dist/langchain/callback.d.ts.map +1 -1
  162. package/dist/langchain/callback.js +32 -30
  163. package/dist/langchain/callback.js.map +1 -1
  164. package/dist/langchain/executor.d.ts +4 -11
  165. package/dist/langchain/executor.d.ts.map +1 -1
  166. package/dist/langchain/executor.js +82 -82
  167. package/dist/langchain/executor.js.map +1 -1
  168. package/dist/langchain/index.d.ts +5 -5
  169. package/dist/langchain/index.d.ts.map +1 -1
  170. package/dist/langchain/index.js +7 -5
  171. package/dist/langchain/index.js.map +1 -1
  172. package/dist/langchain/tools.d.ts +1 -1
  173. package/dist/langchain/tools.d.ts.map +1 -1
  174. package/dist/langchain/tools.js +36 -43
  175. package/dist/langchain/tools.js.map +1 -1
  176. package/dist/langchain/types.d.ts +3 -3
  177. package/dist/langchain/types.d.ts.map +1 -1
  178. package/dist/langchain/types.js +2 -7
  179. package/dist/langchain/types.js.map +1 -1
  180. package/dist/layers/implementations/L0-request-format.d.ts +2 -2
  181. package/dist/layers/implementations/L0-request-format.d.ts.map +1 -1
  182. package/dist/layers/implementations/L0-request-format.js +54 -54
  183. package/dist/layers/implementations/L0-request-format.js.map +1 -1
  184. package/dist/layers/implementations/L1-input-size.d.ts +2 -2
  185. package/dist/layers/implementations/L1-input-size.d.ts.map +1 -1
  186. package/dist/layers/implementations/L1-input-size.js +41 -49
  187. package/dist/layers/implementations/L1-input-size.js.map +1 -1
  188. package/dist/layers/implementations/L2-charset-sanitizer.d.ts +2 -2
  189. package/dist/layers/implementations/L2-charset-sanitizer.d.ts.map +1 -1
  190. package/dist/layers/implementations/L2-charset-sanitizer.js +73 -81
  191. package/dist/layers/implementations/L2-charset-sanitizer.js.map +1 -1
  192. package/dist/layers/implementations/L3-schema-conformance.d.ts +3 -3
  193. package/dist/layers/implementations/L3-schema-conformance.d.ts.map +1 -1
  194. package/dist/layers/implementations/L3-schema-conformance.js +75 -82
  195. package/dist/layers/implementations/L3-schema-conformance.js.map +1 -1
  196. package/dist/layers/implementations/L4-injection-detector.d.ts +4 -4
  197. package/dist/layers/implementations/L4-injection-detector.d.ts.map +1 -1
  198. package/dist/layers/implementations/L4-injection-detector.js +83 -85
  199. package/dist/layers/implementations/L4-injection-detector.js.map +1 -1
  200. package/dist/layers/implementations/L5-rate-limiter.d.ts +2 -2
  201. package/dist/layers/implementations/L5-rate-limiter.d.ts.map +1 -1
  202. package/dist/layers/implementations/L5-rate-limiter.js +22 -20
  203. package/dist/layers/implementations/L5-rate-limiter.js.map +1 -1
  204. package/dist/layers/implementations/index.d.ts +6 -6
  205. package/dist/layers/implementations/index.d.ts.map +1 -1
  206. package/dist/layers/implementations/index.js +8 -6
  207. package/dist/layers/implementations/index.js.map +1 -1
  208. package/dist/layers/index.d.ts +3 -11
  209. package/dist/layers/index.d.ts.map +1 -1
  210. package/dist/layers/index.js +73 -99
  211. package/dist/layers/index.js.map +1 -1
  212. package/dist/layers/types.d.ts +16 -16
  213. package/dist/layers/types.d.ts.map +1 -1
  214. package/dist/layers/types.js +2 -8
  215. package/dist/layers/types.js.map +1 -1
  216. package/dist/paramesphere/activation-collector.d.ts +128 -0
  217. package/dist/paramesphere/activation-collector.d.ts.map +1 -0
  218. package/dist/paramesphere/activation-collector.js +260 -0
  219. package/dist/paramesphere/activation-collector.js.map +1 -0
  220. package/dist/paramesphere/cognitive-envelope.d.ts +73 -0
  221. package/dist/paramesphere/cognitive-envelope.d.ts.map +1 -0
  222. package/dist/paramesphere/cognitive-envelope.js +209 -0
  223. package/dist/paramesphere/cognitive-envelope.js.map +1 -0
  224. package/dist/paramesphere/envelope-integration.d.ts +60 -0
  225. package/dist/paramesphere/envelope-integration.d.ts.map +1 -0
  226. package/dist/paramesphere/envelope-integration.js +93 -0
  227. package/dist/paramesphere/envelope-integration.js.map +1 -0
  228. package/dist/paramesphere/fingerprint-monitor.d.ts +136 -0
  229. package/dist/paramesphere/fingerprint-monitor.d.ts.map +1 -0
  230. package/dist/paramesphere/fingerprint-monitor.js +212 -0
  231. package/dist/paramesphere/fingerprint-monitor.js.map +1 -0
  232. package/dist/paramesphere/fingerprint-store.d.ts +85 -0
  233. package/dist/paramesphere/fingerprint-store.d.ts.map +1 -0
  234. package/dist/paramesphere/fingerprint-store.js +68 -0
  235. package/dist/paramesphere/fingerprint-store.js.map +1 -0
  236. package/dist/paramesphere/index.d.ts +21 -0
  237. package/dist/paramesphere/index.d.ts.map +1 -0
  238. package/dist/paramesphere/index.js +18 -0
  239. package/dist/paramesphere/index.js.map +1 -0
  240. package/dist/paramesphere/monitor-integration.d.ts +37 -0
  241. package/dist/paramesphere/monitor-integration.d.ts.map +1 -0
  242. package/dist/paramesphere/monitor-integration.js +81 -0
  243. package/dist/paramesphere/monitor-integration.js.map +1 -0
  244. package/dist/paramesphere/paramesphere-engine.d.ts +111 -0
  245. package/dist/paramesphere/paramesphere-engine.d.ts.map +1 -0
  246. package/dist/paramesphere/paramesphere-engine.js +542 -0
  247. package/dist/paramesphere/paramesphere-engine.js.map +1 -0
  248. package/dist/paramesphere/types.d.ts +142 -0
  249. package/dist/paramesphere/types.d.ts.map +1 -0
  250. package/dist/paramesphere/types.js +4 -0
  251. package/dist/paramesphere/types.js.map +1 -0
  252. package/dist/persistence/file.d.ts +3 -10
  253. package/dist/persistence/file.d.ts.map +1 -1
  254. package/dist/persistence/file.js +30 -32
  255. package/dist/persistence/file.js.map +1 -1
  256. package/dist/persistence/index.d.ts +7 -7
  257. package/dist/persistence/index.d.ts.map +1 -1
  258. package/dist/persistence/index.js +20 -18
  259. package/dist/persistence/index.js.map +1 -1
  260. package/dist/persistence/memory.d.ts +3 -3
  261. package/dist/persistence/memory.d.ts.map +1 -1
  262. package/dist/persistence/memory.js +10 -17
  263. package/dist/persistence/memory.js.map +1 -1
  264. package/dist/persistence/sqlite.d.ts +3 -11
  265. package/dist/persistence/sqlite.d.ts.map +1 -1
  266. package/dist/persistence/sqlite.js +42 -39
  267. package/dist/persistence/sqlite.js.map +1 -1
  268. package/dist/persistence/supabase.d.ts +3 -3
  269. package/dist/persistence/supabase.d.ts.map +1 -1
  270. package/dist/persistence/supabase.js +46 -49
  271. package/dist/persistence/supabase.js.map +1 -1
  272. package/dist/persistence/types.d.ts +5 -5
  273. package/dist/persistence/types.d.ts.map +1 -1
  274. package/dist/persistence/types.js +2 -7
  275. package/dist/persistence/types.js.map +1 -1
  276. package/dist/phase6/ceiling.d.ts +5 -21
  277. package/dist/phase6/ceiling.d.ts.map +1 -1
  278. package/dist/phase6/ceiling.js +38 -69
  279. package/dist/phase6/ceiling.js.map +1 -1
  280. package/dist/phase6/context.d.ts +3 -20
  281. package/dist/phase6/context.d.ts.map +1 -1
  282. package/dist/phase6/context.js +49 -93
  283. package/dist/phase6/context.js.map +1 -1
  284. package/dist/phase6/index.d.ts +12 -12
  285. package/dist/phase6/index.d.ts.map +1 -1
  286. package/dist/phase6/index.js +17 -15
  287. package/dist/phase6/index.js.map +1 -1
  288. package/dist/phase6/presets.d.ts +2 -18
  289. package/dist/phase6/presets.d.ts.map +1 -1
  290. package/dist/phase6/presets.js +35 -39
  291. package/dist/phase6/presets.js.map +1 -1
  292. package/dist/phase6/provenance.d.ts +4 -19
  293. package/dist/phase6/provenance.d.ts.map +1 -1
  294. package/dist/phase6/provenance.js +37 -42
  295. package/dist/phase6/provenance.js.map +1 -1
  296. package/dist/phase6/role-gates/index.d.ts +2 -2
  297. package/dist/phase6/role-gates/index.d.ts.map +1 -1
  298. package/dist/phase6/role-gates/index.js +4 -2
  299. package/dist/phase6/role-gates/index.js.map +1 -1
  300. package/dist/phase6/role-gates/kernel.d.ts.map +1 -1
  301. package/dist/phase6/role-gates/kernel.js +18 -16
  302. package/dist/phase6/role-gates/kernel.js.map +1 -1
  303. package/dist/phase6/role-gates/policy.d.ts +2 -2
  304. package/dist/phase6/role-gates/policy.d.ts.map +1 -1
  305. package/dist/phase6/role-gates/policy.js +8 -17
  306. package/dist/phase6/role-gates/policy.js.map +1 -1
  307. package/dist/phase6/role-gates.d.ts +4 -20
  308. package/dist/phase6/role-gates.d.ts.map +1 -1
  309. package/dist/phase6/role-gates.js +60 -80
  310. package/dist/phase6/role-gates.js.map +1 -1
  311. package/dist/phase6/types.d.ts +53 -23
  312. package/dist/phase6/types.d.ts.map +1 -1
  313. package/dist/phase6/types.js +131 -177
  314. package/dist/phase6/types.js.map +1 -1
  315. package/dist/phase6/weight-presets/canonical.d.ts.map +1 -1
  316. package/dist/phase6/weight-presets/canonical.js +12 -10
  317. package/dist/phase6/weight-presets/canonical.js.map +1 -1
  318. package/dist/phase6/weight-presets/deltas.d.ts +2 -2
  319. package/dist/phase6/weight-presets/deltas.d.ts.map +1 -1
  320. package/dist/phase6/weight-presets/deltas.js +29 -37
  321. package/dist/phase6/weight-presets/deltas.js.map +1 -1
  322. package/dist/phase6/weight-presets/index.d.ts +3 -3
  323. package/dist/phase6/weight-presets/index.d.ts.map +1 -1
  324. package/dist/phase6/weight-presets/index.js +5 -3
  325. package/dist/phase6/weight-presets/index.js.map +1 -1
  326. package/dist/phase6/weight-presets/merger.d.ts +2 -12
  327. package/dist/phase6/weight-presets/merger.d.ts.map +1 -1
  328. package/dist/phase6/weight-presets/merger.js +45 -39
  329. package/dist/phase6/weight-presets/merger.js.map +1 -1
  330. package/dist/proof/index.d.ts +6 -13
  331. package/dist/proof/index.d.ts.map +1 -1
  332. package/dist/proof/index.js +63 -51
  333. package/dist/proof/index.js.map +1 -1
  334. package/dist/proof/merkle.d.ts +24 -19
  335. package/dist/proof/merkle.d.ts.map +1 -1
  336. package/dist/proof/merkle.js +118 -32
  337. package/dist/proof/merkle.js.map +1 -1
  338. package/dist/proof/zk-proofs.d.ts +6 -24
  339. package/dist/proof/zk-proofs.d.ts.map +1 -1
  340. package/dist/proof/zk-proofs.js +45 -42
  341. package/dist/proof/zk-proofs.js.map +1 -1
  342. package/dist/provenance/index.d.ts +3 -11
  343. package/dist/provenance/index.d.ts.map +1 -1
  344. package/dist/provenance/index.js +19 -19
  345. package/dist/provenance/index.js.map +1 -1
  346. package/dist/provenance/types.d.ts +4 -4
  347. package/dist/provenance/types.d.ts.map +1 -1
  348. package/dist/provenance/types.js +2 -8
  349. package/dist/provenance/types.js.map +1 -1
  350. package/dist/sandbox-training/challenges.d.ts +1 -1
  351. package/dist/sandbox-training/challenges.d.ts.map +1 -1
  352. package/dist/sandbox-training/challenges.js +230 -236
  353. package/dist/sandbox-training/challenges.js.map +1 -1
  354. package/dist/sandbox-training/graduation.d.ts +1 -1
  355. package/dist/sandbox-training/graduation.d.ts.map +1 -1
  356. package/dist/sandbox-training/graduation.js +17 -22
  357. package/dist/sandbox-training/graduation.js.map +1 -1
  358. package/dist/sandbox-training/index.d.ts +9 -9
  359. package/dist/sandbox-training/index.d.ts.map +1 -1
  360. package/dist/sandbox-training/index.js +8 -6
  361. package/dist/sandbox-training/index.js.map +1 -1
  362. package/dist/sandbox-training/promotion-service.d.ts +4 -4
  363. package/dist/sandbox-training/promotion-service.d.ts.map +1 -1
  364. package/dist/sandbox-training/promotion-service.js +7 -16
  365. package/dist/sandbox-training/promotion-service.js.map +1 -1
  366. package/dist/sandbox-training/runner.d.ts +1 -1
  367. package/dist/sandbox-training/runner.d.ts.map +1 -1
  368. package/dist/sandbox-training/runner.js +75 -82
  369. package/dist/sandbox-training/runner.js.map +1 -1
  370. package/dist/sandbox-training/scorer.d.ts +4 -4
  371. package/dist/sandbox-training/scorer.d.ts.map +1 -1
  372. package/dist/sandbox-training/scorer.js +7 -13
  373. package/dist/sandbox-training/scorer.js.map +1 -1
  374. package/dist/sandbox-training/types.d.ts +4 -4
  375. package/dist/sandbox-training/types.d.ts.map +1 -1
  376. package/dist/sandbox-training/types.js +9 -19
  377. package/dist/sandbox-training/types.js.map +1 -1
  378. package/dist/trust-engine/ceiling-enforcement/audit.d.ts +1 -9
  379. package/dist/trust-engine/ceiling-enforcement/audit.d.ts.map +1 -1
  380. package/dist/trust-engine/ceiling-enforcement/audit.js +6 -11
  381. package/dist/trust-engine/ceiling-enforcement/audit.js.map +1 -1
  382. package/dist/trust-engine/ceiling-enforcement/index.d.ts +2 -2
  383. package/dist/trust-engine/ceiling-enforcement/index.d.ts.map +1 -1
  384. package/dist/trust-engine/ceiling-enforcement/index.js +4 -2
  385. package/dist/trust-engine/ceiling-enforcement/index.js.map +1 -1
  386. package/dist/trust-engine/ceiling-enforcement/kernel.d.ts +12 -10
  387. package/dist/trust-engine/ceiling-enforcement/kernel.d.ts.map +1 -1
  388. package/dist/trust-engine/ceiling-enforcement/kernel.js +28 -20
  389. package/dist/trust-engine/ceiling-enforcement/kernel.js.map +1 -1
  390. package/dist/trust-engine/context-policy/enforcement.d.ts +0 -9
  391. package/dist/trust-engine/context-policy/enforcement.d.ts.map +1 -1
  392. package/dist/trust-engine/context-policy/enforcement.js +2 -9
  393. package/dist/trust-engine/context-policy/enforcement.js.map +1 -1
  394. package/dist/trust-engine/context-policy/factory.d.ts +1 -1
  395. package/dist/trust-engine/context-policy/factory.d.ts.map +1 -1
  396. package/dist/trust-engine/context-policy/factory.js +3 -1
  397. package/dist/trust-engine/context-policy/factory.js.map +1 -1
  398. package/dist/trust-engine/context-policy/index.d.ts +2 -2
  399. package/dist/trust-engine/context-policy/index.d.ts.map +1 -1
  400. package/dist/trust-engine/context-policy/index.js +4 -2
  401. package/dist/trust-engine/context-policy/index.js.map +1 -1
  402. package/dist/trust-engine/creation-modifiers/index.d.ts +1 -1
  403. package/dist/trust-engine/creation-modifiers/index.d.ts.map +1 -1
  404. package/dist/trust-engine/creation-modifiers/index.js +3 -1
  405. package/dist/trust-engine/creation-modifiers/index.js.map +1 -1
  406. package/dist/trust-engine/creation-modifiers/types.d.ts.map +1 -1
  407. package/dist/trust-engine/creation-modifiers/types.js +5 -2
  408. package/dist/trust-engine/creation-modifiers/types.js.map +1 -1
  409. package/dist/trust-engine/decay-profiles.d.ts +37 -136
  410. package/dist/trust-engine/decay-profiles.d.ts.map +1 -1
  411. package/dist/trust-engine/decay-profiles.js +61 -183
  412. package/dist/trust-engine/decay-profiles.js.map +1 -1
  413. package/dist/trust-engine/index.d.ts +327 -22
  414. package/dist/trust-engine/index.d.ts.map +1 -1
  415. package/dist/trust-engine/index.js +706 -130
  416. package/dist/trust-engine/index.js.map +1 -1
  417. package/dist/trust-engine/phase6-types.d.ts +15 -18
  418. package/dist/trust-engine/phase6-types.d.ts.map +1 -1
  419. package/dist/trust-engine/phase6-types.js +32 -36
  420. package/dist/trust-engine/phase6-types.js.map +1 -1
  421. package/dist/trust-engine/trust-verifier.d.ts +121 -0
  422. package/dist/trust-engine/trust-verifier.d.ts.map +1 -0
  423. package/dist/trust-engine/trust-verifier.js +226 -0
  424. package/dist/trust-engine/trust-verifier.js.map +1 -0
  425. package/package.json +140 -135
  426. package/dist/enforce/types.d.ts +0 -234
  427. package/dist/enforce/types.d.ts.map +0 -1
  428. package/dist/enforce/types.js +0 -10
  429. package/dist/enforce/types.js.map +0 -1
  430. package/dist/intent/types.d.ts +0 -69
  431. package/dist/intent/types.d.ts.map +0 -1
  432. package/dist/intent/types.js +0 -10
  433. package/dist/intent/types.js.map +0 -1
  434. package/dist/trust-engine/types.d.ts +0 -77
  435. package/dist/trust-engine/types.d.ts.map +0 -1
  436. package/dist/trust-engine/types.js +0 -20
  437. package/dist/trust-engine/types.js.map +0 -1
@@ -1,3 +1,5 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright 2024-2026 Vorion LLC
1
3
  /**
2
4
  * API Server
3
5
  *
@@ -5,19 +7,19 @@
5
7
  *
6
8
  * @packageDocumentation
7
9
  */
8
- import Fastify from "fastify";
9
- import cors from "@fastify/cors";
10
- import helmet from "@fastify/helmet";
11
- import rateLimit from "@fastify/rate-limit";
12
- import { createLogger } from "../common/logger.js";
13
- import { getConfig } from "../common/config.js";
14
- import { PersistentIntentService } from "../intent/persistent-intent-service.js";
15
- import { createProofService } from "../proof/index.js";
16
- import { createTrustEngine } from "../trust-engine/index.js";
17
- import { createEvaluator } from "../basis/evaluator.js";
18
- import { createGovernanceEngine } from "../governance/index.js";
19
- import { GovernanceProofBridge } from "../governance/proof-bridge.js";
20
- const apiLogger = createLogger({ component: "api" });
10
+ import Fastify from 'fastify';
11
+ import cors from '@fastify/cors';
12
+ import helmet from '@fastify/helmet';
13
+ import rateLimit from '@fastify/rate-limit';
14
+ import { createLogger } from '../common/logger.js';
15
+ import { getConfig } from '../common/config.js';
16
+ import { PersistentIntentService } from '../intent/persistent-intent-service.js';
17
+ import { createProofService } from '../proof/index.js';
18
+ import { createTrustEngine } from '../trust-engine/index.js';
19
+ import { createEvaluator } from '../basis/evaluator.js';
20
+ import { createGovernanceEngine } from '../governance/index.js';
21
+ import { GovernanceProofBridge } from '../governance/proof-bridge.js';
22
+ const apiLogger = createLogger({ component: 'api' });
21
23
  // ============================================================
22
24
  // Health Check Implementation
23
25
  // ============================================================
@@ -43,15 +45,15 @@ function checkSystemHealth(startTime) {
43
45
  const metrics = getSystemMetrics(startTime);
44
46
  // Warning threshold: 80% memory usage
45
47
  // Error threshold: 95% memory usage
46
- let status = "ok";
47
- let message = "System healthy";
48
+ let status = 'ok';
49
+ let message = 'System healthy';
48
50
  if (metrics.memoryUsagePercent > 95) {
49
- status = "error";
50
- message = "Critical memory pressure";
51
+ status = 'error';
52
+ message = 'Critical memory pressure';
51
53
  }
52
54
  else if (metrics.memoryUsagePercent > 80) {
53
- status = "degraded";
54
- message = "High memory usage";
55
+ status = 'degraded';
56
+ message = 'High memory usage';
55
57
  }
56
58
  return {
57
59
  status,
@@ -71,16 +73,16 @@ async function checkService(name, checkFn) {
71
73
  try {
72
74
  await checkFn();
73
75
  return {
74
- status: "ok",
76
+ status: 'ok',
75
77
  latencyMs: Date.now() - start,
76
78
  message: `${name} operational`,
77
79
  };
78
80
  }
79
81
  catch (error) {
80
82
  return {
81
- status: "error",
83
+ status: 'error',
82
84
  latencyMs: Date.now() - start,
83
- message: `${name} error: ${error instanceof Error ? error.message : "Unknown error"}`,
85
+ message: `${name} error: ${error instanceof Error ? error.message : 'Unknown error'}`,
84
86
  };
85
87
  }
86
88
  }
@@ -101,45 +103,41 @@ export async function createServer(deps) {
101
103
  const proof = await proofService.create(req);
102
104
  return { id: proof.id };
103
105
  },
104
- tenantId: "__system__",
106
+ tenantId: '__system__',
105
107
  });
106
108
  // Use pino logger config for Fastify 5
107
- const isTest = process.env["NODE_ENV"] === "test" || process.env["VITEST"];
109
+ const isTest = process.env['NODE_ENV'] === 'test' || process.env['VITEST'];
108
110
  const server = Fastify({
109
- logger: isTest
110
- ? false
111
- : {
112
- level: config.env === "production" ? "info" : "debug",
113
- transport: config.env !== "production"
114
- ? {
115
- target: "pino-pretty",
116
- options: { colorize: true },
117
- }
118
- : undefined,
119
- },
120
- requestIdHeader: "x-request-id",
121
- requestIdLogLabel: "requestId",
111
+ logger: isTest ? false : {
112
+ level: config.env === 'production' ? 'info' : 'debug',
113
+ transport: config.env !== 'production' ? {
114
+ target: 'pino-pretty',
115
+ options: { colorize: true },
116
+ } : undefined,
117
+ },
118
+ requestIdHeader: 'x-request-id',
119
+ requestIdLogLabel: 'requestId',
122
120
  });
123
121
  // Register plugins
124
122
  await server.register(cors, {
125
- origin: config.env === "production" ? false : true,
123
+ origin: config.env === 'production' ? false : true,
126
124
  credentials: true,
127
125
  });
128
126
  await server.register(helmet, {
129
- contentSecurityPolicy: config.env === "production",
127
+ contentSecurityPolicy: config.env === 'production',
130
128
  });
131
129
  await server.register(rateLimit, {
132
130
  max: config.api.rateLimit,
133
- timeWindow: "1 minute",
131
+ timeWindow: '1 minute',
134
132
  });
135
133
  // API Key authentication for protected routes
136
- const API_KEY = process.env["VORION_API_KEY"] || config.api.apiKey;
134
+ const API_KEY = process.env['VORION_API_KEY'] || config.api.apiKey;
137
135
  const requiresAuth = (url) => {
138
136
  // Public endpoints that don't require auth
139
- const publicPaths = ["/health", "/ready", "/live", "/api/v1/health"];
140
- return !publicPaths.some((path) => url === path || url.startsWith(path + "?"));
137
+ const publicPaths = ['/health', '/ready', '/live', '/api/v1/health'];
138
+ return !publicPaths.some(path => url === path || url.startsWith(path + '?'));
141
139
  };
142
- server.addHook("onRequest", async (request, reply) => {
140
+ server.addHook('onRequest', async (request, reply) => {
143
141
  // Skip auth in test mode or for public endpoints
144
142
  if (isTest || !requiresAuth(request.url)) {
145
143
  return;
@@ -148,113 +146,107 @@ export async function createServer(deps) {
148
146
  if (!API_KEY) {
149
147
  return;
150
148
  }
151
- const authHeader = request.headers["authorization"];
149
+ const authHeader = request.headers['authorization'];
152
150
  if (!authHeader) {
153
151
  return reply.status(401).send({
154
- error: {
155
- code: "UNAUTHORIZED",
156
- message: "Missing Authorization header",
157
- },
152
+ error: { code: 'UNAUTHORIZED', message: 'Missing Authorization header' },
158
153
  });
159
154
  }
160
- const [scheme, token] = authHeader.split(" ");
161
- if (scheme?.toLowerCase() !== "bearer" || token !== API_KEY) {
155
+ const [scheme, token] = authHeader.split(' ');
156
+ if (scheme?.toLowerCase() !== 'bearer' || token !== API_KEY) {
162
157
  return reply.status(401).send({
163
- error: { code: "UNAUTHORIZED", message: "Invalid API key" },
158
+ error: { code: 'UNAUTHORIZED', message: 'Invalid API key' },
164
159
  });
165
160
  }
166
161
  });
167
162
  // Health check endpoint - performs actual checks on all services
168
- server.get("/health", async () => {
163
+ server.get('/health', async () => {
169
164
  const checks = {};
170
165
  // Check trust engine
171
- checks.trustEngine = await checkService("Trust engine", async () => {
172
- await trustEngine.getScore("__health_check__");
166
+ checks.trustEngine = await checkService('Trust engine', async () => {
167
+ await trustEngine.getScore('__health_check__');
173
168
  });
174
169
  // Check proof service
175
- checks.proofService = await checkService("Proof service", async () => {
176
- await proofService.get("__health_check_proof__");
170
+ checks.proofService = await checkService('Proof service', async () => {
171
+ await proofService.get('__health_check_proof__');
177
172
  });
178
173
  // Check intent service
179
- checks.intentService = await checkService("Intent service", async () => {
180
- await intentService.get("__health_check_intent__", "__system__");
174
+ checks.intentService = await checkService('Intent service', async () => {
175
+ await intentService.get('__health_check_intent__', '__system__');
181
176
  });
182
177
  // Check system health
183
178
  checks.system = checkSystemHealth(startTime);
184
179
  // Determine overall status
185
180
  const statuses = Object.values(checks).map((c) => c.status);
186
181
  let status;
187
- if (statuses.every((s) => s === "ok")) {
188
- status = "healthy";
182
+ if (statuses.every((s) => s === 'ok')) {
183
+ status = 'healthy';
189
184
  }
190
- else if (statuses.some((s) => s === "error")) {
191
- status = "unhealthy";
185
+ else if (statuses.some((s) => s === 'error')) {
186
+ status = 'unhealthy';
192
187
  }
193
188
  else {
194
- status = "degraded";
189
+ status = 'degraded';
195
190
  }
196
191
  return {
197
192
  status,
198
193
  timestamp: new Date().toISOString(),
199
- version: process.env["npm_package_version"],
194
+ version: process.env['npm_package_version'],
200
195
  environment: config.env,
201
196
  checks,
202
197
  metrics: getSystemMetrics(startTime),
203
198
  };
204
199
  });
205
200
  // Ready check endpoint - verifies all critical services are ready
206
- server.get("/ready", async (_request, reply) => {
201
+ server.get('/ready', async (_request, reply) => {
207
202
  const checks = {};
208
203
  // Check trust engine (critical)
209
- checks.trustEngine = await checkService("Trust engine", async () => {
210
- await trustEngine.getScore("__health_check__");
204
+ checks.trustEngine = await checkService('Trust engine', async () => {
205
+ await trustEngine.getScore('__health_check__');
211
206
  });
212
207
  // Check proof service (critical)
213
- checks.proofService = await checkService("Proof service", async () => {
214
- await proofService.get("__health_check_proof__");
208
+ checks.proofService = await checkService('Proof service', async () => {
209
+ await proofService.get('__health_check_proof__');
215
210
  });
216
211
  // Check intent service (critical)
217
- checks.intentService = await checkService("Intent service", async () => {
218
- await intentService.get("__health_check_intent__", "__system__");
212
+ checks.intentService = await checkService('Intent service', async () => {
213
+ await intentService.get('__health_check_intent__', '__system__');
219
214
  });
220
- const allPassed = Object.values(checks).every((c) => c.status === "ok" || c.status === "degraded");
215
+ const allPassed = Object.values(checks).every((c) => c.status === 'ok' || c.status === 'degraded');
221
216
  // Return 503 if not ready (for Kubernetes probes)
222
217
  if (!allPassed) {
223
218
  reply.status(503);
224
219
  }
225
220
  return {
226
- status: allPassed ? "ready" : "not_ready",
221
+ status: allPassed ? 'ready' : 'not_ready',
227
222
  timestamp: new Date().toISOString(),
228
223
  checks,
229
224
  allPassed,
230
225
  };
231
226
  });
232
227
  // Liveness probe endpoint - simple alive check (no deep checks)
233
- server.get("/live", async () => ({
234
- status: "alive",
228
+ server.get('/live', async () => ({
229
+ status: 'alive',
235
230
  timestamp: new Date().toISOString(),
236
231
  }));
237
232
  // API routes
238
233
  server.register(async (api) => {
239
234
  // SDK: Health check endpoint
240
- api.get("/health", async () => ({
241
- status: "healthy",
242
- version: process.env["npm_package_version"] ?? "0.1.0",
235
+ api.get('/health', async () => ({
236
+ status: 'healthy',
237
+ version: process.env['npm_package_version'] ?? '0.1.0',
243
238
  }));
244
239
  // Intent routes - unified handler for both legacy and SDK formats
245
- api.post("/intents", async (request, reply) => {
240
+ api.post('/intents', async (request, reply) => {
246
241
  const body = request.body;
247
242
  // Detect format: SDK format has 'agentId' and 'action', legacy has 'entityId' and 'goal'
248
- if ("agentId" in body && "action" in body) {
243
+ if ('agentId' in body && 'action' in body) {
249
244
  // SDK format
250
245
  const startTime = Date.now();
251
- const { agentId, capabilities = [], action, } = body;
246
+ const { agentId, capabilities = [], action } = body;
252
247
  if (!agentId || !action?.type || !action?.resource) {
253
248
  return reply.status(400).send({
254
- error: {
255
- code: "INVALID_REQUEST",
256
- message: "Missing required fields: agentId, action.type, action.resource",
257
- },
249
+ error: { code: 'INVALID_REQUEST', message: 'Missing required fields: agentId, action.type, action.resource' },
258
250
  });
259
251
  }
260
252
  // Get or create agent trust record
@@ -264,10 +256,10 @@ export async function createServer(deps) {
264
256
  trustRecord = await trustEngine.getScore(agentId);
265
257
  }
266
258
  // Check capability
267
- const hasCapability = capabilities.some((cap) => cap === "*" ||
259
+ const hasCapability = capabilities.some(cap => cap === '*' ||
268
260
  cap === action.type ||
269
261
  cap === `${action.type}:*` ||
270
- cap === `${action.type}:${action.resource.split("/")[0]}`);
262
+ cap === `${action.type}:${action.resource.split('/')[0]}`);
271
263
  // Determine decision
272
264
  const trustLevel = trustRecord?.level ?? 3;
273
265
  const trustScore = trustRecord?.score ?? 500;
@@ -275,13 +267,13 @@ export async function createServer(deps) {
275
267
  // Decision tier based on trust level
276
268
  let tier;
277
269
  if (!allowed) {
278
- tier = "RED";
270
+ tier = 'RED';
279
271
  }
280
272
  else if (trustLevel >= 5) {
281
- tier = "GREEN";
273
+ tier = 'GREEN';
282
274
  }
283
275
  else {
284
- tier = "YELLOW";
276
+ tier = 'YELLOW';
285
277
  }
286
278
  // Create proof record
287
279
  const proofId = `proof-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
@@ -289,20 +281,20 @@ export async function createServer(deps) {
289
281
  // Determine constraints based on tier
290
282
  const constraints = [];
291
283
  if (trustLevel <= 1) {
292
- constraints.push("rate_limit:10/min", "audit:full", "sandbox:true");
284
+ constraints.push('rate_limit:10/min', 'audit:full', 'sandbox:true');
293
285
  }
294
286
  else if (trustLevel <= 3) {
295
- constraints.push("rate_limit:100/min", "audit:standard");
287
+ constraints.push('rate_limit:100/min', 'audit:standard');
296
288
  }
297
289
  else if (trustLevel <= 5) {
298
- constraints.push("rate_limit:1000/min", "audit:light");
290
+ constraints.push('rate_limit:1000/min', 'audit:light');
299
291
  }
300
292
  const reason = allowed
301
- ? "Action permitted based on capabilities and trust level"
293
+ ? 'Action permitted based on capabilities and trust level'
302
294
  : hasCapability
303
295
  ? `Trust score ${trustScore} below minimum threshold (200)`
304
- : `Missing capability for ${action.type}:${action.resource.split("/")[0]}`;
305
- apiLogger.info({ intentId, agentId, action: action.type, allowed, tier }, "Intent processed");
296
+ : `Missing capability for ${action.type}:${action.resource.split('/')[0]}`;
297
+ apiLogger.info({ intentId, agentId, action: action.type, allowed, tier }, 'Intent processed');
306
298
  return {
307
299
  intentId,
308
300
  allowed,
@@ -318,10 +310,7 @@ export async function createServer(deps) {
318
310
  const { entityId, goal, context, metadata } = body;
319
311
  if (!entityId || !goal) {
320
312
  return reply.status(400).send({
321
- error: {
322
- code: "INVALID_REQUEST",
323
- message: "Missing required fields: entityId, goal",
324
- },
313
+ error: { code: 'INVALID_REQUEST', message: 'Missing required fields: entityId, goal' },
325
314
  });
326
315
  }
327
316
  const intent = await intentService.submit({
@@ -329,29 +318,26 @@ export async function createServer(deps) {
329
318
  goal,
330
319
  context: context ?? {},
331
320
  metadata,
332
- }, { tenantId: "__system__" });
333
- apiLogger.info({ intentId: intent.id, entityId }, "Intent submitted");
321
+ }, { tenantId: '__system__' });
322
+ apiLogger.info({ intentId: intent.id, entityId }, 'Intent submitted');
334
323
  return reply.status(201).send({ intent });
335
324
  }
336
325
  });
337
- api.get("/intents/:id", async (request, reply) => {
338
- const intent = await intentService.get(request.params.id, "__system__");
326
+ api.get('/intents/:id', async (request, reply) => {
327
+ const intent = await intentService.get(request.params.id, '__system__');
339
328
  if (!intent) {
340
329
  return reply.status(404).send({
341
- error: { code: "NOT_FOUND", message: "Intent not found" },
330
+ error: { code: 'NOT_FOUND', message: 'Intent not found' },
342
331
  });
343
332
  }
344
333
  return { intent };
345
334
  });
346
335
  // SDK: Check intent (pre-flight, no side effects)
347
- api.post("/intents/check", async (request, reply) => {
336
+ api.post('/intents/check', async (request, reply) => {
348
337
  const { agentId, capabilities = [], action } = request.body;
349
338
  if (!agentId || !action?.type || !action?.resource) {
350
339
  return reply.status(400).send({
351
- error: {
352
- code: "INVALID_REQUEST",
353
- message: "Missing required fields",
354
- },
340
+ error: { code: 'INVALID_REQUEST', message: 'Missing required fields' },
355
341
  });
356
342
  }
357
343
  // Get agent trust record
@@ -359,49 +345,49 @@ export async function createServer(deps) {
359
345
  const trustScore = trustRecord?.score ?? 0;
360
346
  const trustLevel = trustRecord?.level ?? 0;
361
347
  // Check capability
362
- const hasCapability = capabilities.some((cap) => cap === "*" ||
348
+ const hasCapability = capabilities.some(cap => cap === '*' ||
363
349
  cap === action.type ||
364
350
  cap === `${action.type}:*` ||
365
- cap === `${action.type}:${action.resource.split("/")[0]}`);
351
+ cap === `${action.type}:${action.resource.split('/')[0]}`);
366
352
  const wouldAllow = hasCapability && trustScore >= 200;
367
353
  let tier;
368
354
  if (!wouldAllow) {
369
- tier = "RED";
355
+ tier = 'RED';
370
356
  }
371
357
  else if (trustLevel >= 5) {
372
- tier = "GREEN";
358
+ tier = 'GREEN';
373
359
  }
374
360
  else {
375
- tier = "YELLOW";
361
+ tier = 'YELLOW';
376
362
  }
377
363
  const reason = wouldAllow
378
- ? "Action would be permitted"
364
+ ? 'Action would be permitted'
379
365
  : hasCapability
380
366
  ? `Trust score ${trustScore} below minimum threshold`
381
367
  : `Missing capability for ${action.type}`;
382
368
  return { wouldAllow, tier, reason };
383
369
  });
384
370
  // Proof routes
385
- api.get("/proofs/:id", async (request, reply) => {
371
+ api.get('/proofs/:id', async (request, reply) => {
386
372
  const proof = await proofService.get(request.params.id);
387
373
  if (!proof) {
388
374
  return reply.status(404).send({
389
- error: { code: "NOT_FOUND", message: "Proof not found" },
375
+ error: { code: 'NOT_FOUND', message: 'Proof not found' },
390
376
  });
391
377
  }
392
378
  return { proof };
393
379
  });
394
- api.post("/proofs/:id/verify", async (request, reply) => {
380
+ api.post('/proofs/:id/verify', async (request, reply) => {
395
381
  const result = await proofService.verify(request.params.id);
396
382
  if (result.chainPosition === -1) {
397
383
  return reply.status(404).send({
398
- error: { code: "NOT_FOUND", message: "Proof not found" },
384
+ error: { code: 'NOT_FOUND', message: 'Proof not found' },
399
385
  });
400
386
  }
401
387
  return { verification: result };
402
388
  });
403
389
  // Trust routes
404
- api.get("/trust/:entityId", async (request) => {
390
+ api.get('/trust/:entityId', async (request) => {
405
391
  const record = await trustEngine.getScore(request.params.entityId);
406
392
  if (!record) {
407
393
  // Return null values for non-existent agents (SDK compatible)
@@ -410,7 +396,7 @@ export async function createServer(deps) {
410
396
  score: null,
411
397
  tier: null,
412
398
  tierName: null,
413
- message: "Agent not found",
399
+ message: 'Agent not found',
414
400
  };
415
401
  }
416
402
  return {
@@ -422,14 +408,11 @@ export async function createServer(deps) {
422
408
  };
423
409
  });
424
410
  // SDK: Admit agent endpoint
425
- api.post("/trust/admit", async (request, reply) => {
411
+ api.post('/trust/admit', async (request, reply) => {
426
412
  const { agentId, name, capabilities, observationTier } = request.body;
427
413
  if (!agentId || !name) {
428
414
  return reply.status(400).send({
429
- error: {
430
- code: "INVALID_REQUEST",
431
- message: "Missing required fields: agentId, name",
432
- },
415
+ error: { code: 'INVALID_REQUEST', message: 'Missing required fields: agentId, name' },
433
416
  });
434
417
  }
435
418
  // Initialize agent in trust engine at T3 (Monitored)
@@ -437,35 +420,31 @@ export async function createServer(deps) {
437
420
  await trustEngine.initializeEntity(agentId, initialLevel);
438
421
  const record = await trustEngine.getScore(agentId);
439
422
  const expiresAt = new Date(Date.now() + 365 * 24 * 60 * 60 * 1000).toISOString(); // 1 year
440
- apiLogger.info({ agentId, name, initialLevel }, "Agent admitted");
423
+ apiLogger.info({ agentId, name, initialLevel }, 'Agent admitted');
441
424
  return reply.status(201).send({
442
425
  admitted: true,
443
426
  initialTier: record?.level ?? initialLevel,
444
427
  initialScore: record?.score ?? 500,
445
- observationCeiling: observationTier === "WHITE_BOX"
446
- ? 7
447
- : observationTier === "GRAY_BOX"
448
- ? 5
449
- : 3,
428
+ observationCeiling: observationTier === 'WHITE_BOX' ? 7 : observationTier === 'GRAY_BOX' ? 5 : 3,
450
429
  capabilities: capabilities ?? [],
451
430
  expiresAt,
452
431
  });
453
432
  });
454
433
  // SDK: Record trust signal
455
- api.post("/trust/:agentId/signal", async (request, reply) => {
434
+ api.post('/trust/:agentId/signal', async (request, reply) => {
456
435
  const { agentId } = request.params;
457
436
  const { type, source, weight = 0.1, context } = request.body;
458
437
  const recordBefore = await trustEngine.getScore(agentId);
459
438
  if (!recordBefore) {
460
439
  return reply.status(404).send({
461
- error: { code: "NOT_FOUND", message: "Agent not found" },
440
+ error: { code: 'NOT_FOUND', message: 'Agent not found' },
462
441
  });
463
442
  }
464
443
  const scoreBefore = recordBefore.score;
465
444
  // Map signal type to trust value
466
445
  const valueMap = {
467
- success: 0.8 + weight * 0.2,
468
- failure: 0.2 - weight * 0.1,
446
+ success: 0.8 + (weight * 0.2),
447
+ failure: 0.2 - (weight * 0.1),
469
448
  violation: 0.0,
470
449
  neutral: 0.5,
471
450
  };
@@ -487,23 +466,18 @@ export async function createServer(deps) {
487
466
  scoreAfter,
488
467
  change: scoreAfter - scoreBefore,
489
468
  newTier: recordAfter?.level ?? null,
490
- newTierName: recordAfter
491
- ? trustEngine.getLevelName(recordAfter.level)
492
- : null,
469
+ newTierName: recordAfter ? trustEngine.getLevelName(recordAfter.level) : null,
493
470
  };
494
471
  });
495
472
  // ================================================================
496
473
  // Governance routes
497
474
  // ================================================================
498
475
  // Evaluate governance request (with proof chain)
499
- api.post("/governance/evaluate", async (request, reply) => {
476
+ api.post('/governance/evaluate', async (request, reply) => {
500
477
  const body = request.body;
501
478
  if (!body.requestId || !body.entityId || !body.action) {
502
479
  return reply.status(400).send({
503
- error: {
504
- code: "INVALID_REQUEST",
505
- message: "Missing required fields: requestId, entityId, action",
506
- },
480
+ error: { code: 'INVALID_REQUEST', message: 'Missing required fields: requestId, entityId, action' },
507
481
  });
508
482
  }
509
483
  const startTime = Date.now();
@@ -513,7 +487,7 @@ export async function createServer(deps) {
513
487
  entityId: body.entityId,
514
488
  decision: result.decision,
515
489
  proofId,
516
- }, "Governance evaluation completed");
490
+ }, 'Governance evaluation completed');
517
491
  return {
518
492
  result,
519
493
  proofId,
@@ -521,96 +495,85 @@ export async function createServer(deps) {
521
495
  };
522
496
  });
523
497
  // Query governance rules
524
- api.get("/governance/rules", async (request) => {
498
+ api.get('/governance/rules', async (request) => {
525
499
  const rules = await governanceEngine.queryRules(request.query);
526
500
  return { rules, count: rules.length };
527
501
  });
528
502
  // Register governance rule
529
- api.post("/governance/rules", async (request, reply) => {
503
+ api.post('/governance/rules', async (request, reply) => {
530
504
  const rule = request.body;
531
505
  if (!rule.ruleId || !rule.name || !rule.condition || !rule.effect) {
532
506
  return reply.status(400).send({
533
- error: {
534
- code: "INVALID_REQUEST",
535
- message: "Missing required rule fields",
536
- },
507
+ error: { code: 'INVALID_REQUEST', message: 'Missing required rule fields' },
537
508
  });
538
509
  }
539
510
  governanceEngine.registerRule(rule);
540
- apiLogger.info({ ruleId: rule.ruleId, name: rule.name }, "Governance rule registered");
541
- return reply
542
- .status(201)
543
- .send({ registered: true, ruleId: rule.ruleId });
511
+ apiLogger.info({ ruleId: rule.ruleId, name: rule.name }, 'Governance rule registered');
512
+ return reply.status(201).send({ registered: true, ruleId: rule.ruleId });
544
513
  });
545
514
  // ================================================================
546
515
  // Boot Camp routes
547
516
  // ================================================================
548
517
  // Run boot camp for an agent
549
- api.post("/agents/:agentId/bootcamp", async (request, reply) => {
518
+ api.post('/agents/:agentId/bootcamp', async (request, reply) => {
550
519
  const { agentId } = request.params;
551
520
  const { tenantId } = request.body;
552
521
  if (!tenantId) {
553
522
  return reply.status(400).send({
554
- error: {
555
- code: "INVALID_REQUEST",
556
- message: "Missing required field: tenantId",
557
- },
523
+ error: { code: 'INVALID_REQUEST', message: 'Missing required field: tenantId' },
558
524
  });
559
525
  }
560
526
  // The agent must implement handleChallenge — for API usage,
561
527
  // this is a placeholder that indicates the boot camp needs
562
528
  // to be driven by the calling service with a real agent adapter.
563
529
  // For now, return the service configuration info.
564
- apiLogger.info({ agentId, tenantId }, "Boot camp requested");
530
+ apiLogger.info({ agentId, tenantId }, 'Boot camp requested');
565
531
  return reply.status(501).send({
566
532
  error: {
567
- code: "NOT_IMPLEMENTED",
568
- message: "Boot camp must be run programmatically via PromotionService. " +
569
- "Use the @vorionsys/atsf-core SDK to run boot camp with a BootCampAgent implementation.",
533
+ code: 'NOT_IMPLEMENTED',
534
+ message: 'Boot camp must be run programmatically via PromotionService. ' +
535
+ 'Use the @vorionsys/atsf-core SDK to run boot camp with a BootCampAgent implementation.',
570
536
  },
571
537
  hint: {
572
- sdk: "@vorionsys/atsf-core",
573
- import: "PromotionService",
574
- usage: "new PromotionService(trustEngine).runAndEvaluate(agent)",
538
+ sdk: '@vorionsys/atsf-core',
539
+ import: 'PromotionService',
540
+ usage: 'new PromotionService(trustEngine).runAndEvaluate(agent)',
575
541
  },
576
542
  });
577
543
  });
578
544
  // Constraint routes
579
- api.post("/constraints/validate", async (request, reply) => {
545
+ api.post('/constraints/validate', async (request, reply) => {
580
546
  const { entityId, intentType, context } = request.body;
581
547
  if (!entityId || !intentType) {
582
548
  return reply.status(400).send({
583
- error: {
584
- code: "INVALID_REQUEST",
585
- message: "Missing required fields",
586
- },
549
+ error: { code: 'INVALID_REQUEST', message: 'Missing required fields' },
587
550
  });
588
551
  }
589
552
  // Get entity trust record
590
553
  const trustRecord = await trustEngine.getScore(entityId);
591
554
  if (!trustRecord) {
592
555
  return reply.status(404).send({
593
- error: { code: "NOT_FOUND", message: "Entity not found" },
556
+ error: { code: 'NOT_FOUND', message: 'Entity not found' },
594
557
  });
595
558
  }
596
559
  // Create evaluation context
597
560
  const evalContext = {
598
561
  intent: {
599
- id: "validation-check",
562
+ id: 'validation-check',
600
563
  type: intentType,
601
- goal: "constraint-validation",
564
+ goal: 'constraint-validation',
602
565
  context: context ?? {},
603
566
  },
604
567
  entity: {
605
568
  id: entityId,
606
- type: "agent",
569
+ type: 'agent',
607
570
  trustScore: trustRecord.score,
608
571
  trustLevel: trustRecord.level,
609
572
  attributes: {},
610
573
  },
611
574
  environment: {
612
575
  timestamp: new Date().toISOString(),
613
- timezone: "UTC",
576
+ timezone: 'UTC',
614
577
  requestId: request.id,
615
578
  },
616
579
  custom: {},
@@ -636,11 +599,13 @@ export async function createServer(deps) {
636
599
  error: error.message,
637
600
  stack: error.stack,
638
601
  requestId: request.id,
639
- }, "Request error");
602
+ }, 'Request error');
640
603
  reply.status(error.statusCode ?? 500).send({
641
604
  error: {
642
- code: error.code ?? "INTERNAL_ERROR",
643
- message: config.env === "production" ? "An error occurred" : error.message,
605
+ code: error.code ?? 'INTERNAL_ERROR',
606
+ message: config.env === 'production'
607
+ ? 'An error occurred'
608
+ : error.message,
644
609
  },
645
610
  });
646
611
  });
@@ -661,10 +626,10 @@ export async function startServer() {
661
626
  port: config.api.port,
662
627
  host: config.api.host,
663
628
  environment: config.env,
664
- }, "Server started");
629
+ }, 'Server started');
665
630
  }
666
631
  catch (error) {
667
- apiLogger.error({ error }, "Failed to start server");
632
+ apiLogger.error({ error }, 'Failed to start server');
668
633
  process.exit(1);
669
634
  }
670
635
  }