@dcyfr/ai 1.0.4 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (411) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/README.md +381 -9
  3. package/dist/ai/agents/agent-loader.d.ts +12 -0
  4. package/dist/ai/agents/agent-loader.d.ts.map +1 -1
  5. package/dist/ai/agents/agent-loader.js +74 -65
  6. package/dist/ai/agents/agent-loader.js.map +1 -1
  7. package/dist/ai/agents/agent-registry.d.ts +2 -0
  8. package/dist/ai/agents/agent-registry.d.ts.map +1 -1
  9. package/dist/ai/agents/agent-registry.js +15 -14
  10. package/dist/ai/agents/agent-registry.js.map +1 -1
  11. package/dist/ai/agents/agent-router.d.ts +20 -5
  12. package/dist/ai/agents/agent-router.d.ts.map +1 -1
  13. package/dist/ai/agents/agent-router.js +89 -43
  14. package/dist/ai/agents/agent-router.js.map +1 -1
  15. package/dist/ai/agents/index.d.ts +6 -1
  16. package/dist/ai/agents/index.d.ts.map +1 -1
  17. package/dist/ai/agents/index.js +9 -3
  18. package/dist/ai/agents/index.js.map +1 -1
  19. package/dist/ai/agents/instruction-template.d.ts +45 -0
  20. package/dist/ai/agents/instruction-template.d.ts.map +1 -0
  21. package/dist/ai/agents/instruction-template.js +197 -0
  22. package/dist/ai/agents/instruction-template.js.map +1 -0
  23. package/dist/ai/agents/persona-resolver.d.ts +90 -0
  24. package/dist/ai/agents/persona-resolver.d.ts.map +1 -0
  25. package/dist/ai/agents/persona-resolver.js +121 -0
  26. package/dist/ai/agents/persona-resolver.js.map +1 -0
  27. package/dist/ai/agents/schema.d.ts +166 -0
  28. package/dist/ai/agents/schema.d.ts.map +1 -0
  29. package/dist/ai/agents/schema.js +94 -0
  30. package/dist/ai/agents/schema.js.map +1 -0
  31. package/dist/ai/agents/types.d.ts +102 -0
  32. package/dist/ai/agents/types.d.ts.map +1 -1
  33. package/dist/ai/agents-builtin/architecture/index.js +3 -3
  34. package/dist/ai/agents-builtin/content/index.js +1 -1
  35. package/dist/ai/agents-builtin/data/index.js +1 -1
  36. package/dist/ai/agents-builtin/development/index.js +4 -4
  37. package/dist/ai/agents-builtin/devops/index.js +1 -1
  38. package/dist/ai/agents-builtin/index.js +33 -33
  39. package/dist/ai/agents-builtin/performance/index.js +1 -1
  40. package/dist/ai/agents-builtin/research/index.js +1 -1
  41. package/dist/ai/agents-builtin/security/index.js +1 -1
  42. package/dist/ai/agents-builtin/testing/index.js +2 -2
  43. package/dist/ai/config/loader.d.ts.map +1 -1
  44. package/dist/ai/config/loader.js +6 -3
  45. package/dist/ai/config/loader.js.map +1 -1
  46. package/dist/ai/config/schema.d.ts +242 -1156
  47. package/dist/ai/config/schema.d.ts.map +1 -1
  48. package/dist/ai/config/schema.js +69 -20
  49. package/dist/ai/config/schema.js.map +1 -1
  50. package/dist/ai/core/provider-registry.d.ts +32 -0
  51. package/dist/ai/core/provider-registry.d.ts.map +1 -1
  52. package/dist/ai/core/provider-registry.js +189 -14
  53. package/dist/ai/core/provider-registry.js.map +1 -1
  54. package/dist/ai/core/telemetry-engine.d.ts +26 -0
  55. package/dist/ai/core/telemetry-engine.d.ts.map +1 -1
  56. package/dist/ai/core/telemetry-engine.js +81 -1
  57. package/dist/ai/core/telemetry-engine.js.map +1 -1
  58. package/dist/ai/delegation/agent-registry.d.ts +143 -0
  59. package/dist/ai/delegation/agent-registry.d.ts.map +1 -0
  60. package/dist/ai/delegation/agent-registry.js +231 -0
  61. package/dist/ai/delegation/agent-registry.js.map +1 -0
  62. package/dist/ai/delegation/blast-radius-tracker.d.ts +65 -0
  63. package/dist/ai/delegation/blast-radius-tracker.d.ts.map +1 -0
  64. package/dist/ai/delegation/blast-radius-tracker.js +81 -0
  65. package/dist/ai/delegation/blast-radius-tracker.js.map +1 -0
  66. package/dist/ai/delegation/capability-bootstrap.d.ts +40 -0
  67. package/dist/ai/delegation/capability-bootstrap.d.ts.map +1 -0
  68. package/dist/ai/delegation/capability-bootstrap.js +431 -0
  69. package/dist/ai/delegation/capability-bootstrap.js.map +1 -0
  70. package/dist/ai/delegation/capability-registry.d.ts +81 -0
  71. package/dist/ai/delegation/capability-registry.d.ts.map +1 -0
  72. package/dist/ai/delegation/capability-registry.js +339 -0
  73. package/dist/ai/delegation/capability-registry.js.map +1 -0
  74. package/dist/ai/delegation/chain-tracker.d.ts +152 -0
  75. package/dist/ai/delegation/chain-tracker.d.ts.map +1 -0
  76. package/dist/ai/delegation/chain-tracker.js +336 -0
  77. package/dist/ai/delegation/chain-tracker.js.map +1 -0
  78. package/dist/ai/delegation/circuit-breaker.d.ts +59 -0
  79. package/dist/ai/delegation/circuit-breaker.d.ts.map +1 -0
  80. package/dist/ai/delegation/circuit-breaker.js +153 -0
  81. package/dist/ai/delegation/circuit-breaker.js.map +1 -0
  82. package/dist/ai/delegation/contract-manager.d.ts +415 -0
  83. package/dist/ai/delegation/contract-manager.d.ts.map +1 -0
  84. package/dist/ai/delegation/contract-manager.js +1258 -0
  85. package/dist/ai/delegation/contract-manager.js.map +1 -0
  86. package/dist/ai/delegation/delegation-manager.d.ts +505 -0
  87. package/dist/ai/delegation/delegation-manager.d.ts.map +1 -0
  88. package/dist/ai/delegation/delegation-manager.js +773 -0
  89. package/dist/ai/delegation/delegation-manager.js.map +1 -0
  90. package/dist/ai/delegation/event-schemas.d.ts +101 -0
  91. package/dist/ai/delegation/event-schemas.d.ts.map +1 -0
  92. package/dist/ai/delegation/event-schemas.js +59 -0
  93. package/dist/ai/delegation/event-schemas.js.map +1 -0
  94. package/dist/ai/delegation/execution-mode-dashboard.d.ts +109 -0
  95. package/dist/ai/delegation/execution-mode-dashboard.d.ts.map +1 -0
  96. package/dist/ai/delegation/execution-mode-dashboard.js +167 -0
  97. package/dist/ai/delegation/execution-mode-dashboard.js.map +1 -0
  98. package/dist/ai/delegation/feature-flags.d.ts +191 -0
  99. package/dist/ai/delegation/feature-flags.d.ts.map +1 -0
  100. package/dist/ai/delegation/feature-flags.js +332 -0
  101. package/dist/ai/delegation/feature-flags.js.map +1 -0
  102. package/dist/ai/delegation/index.d.ts +51 -0
  103. package/dist/ai/delegation/index.d.ts.map +1 -0
  104. package/dist/ai/delegation/index.js +39 -0
  105. package/dist/ai/delegation/index.js.map +1 -0
  106. package/dist/ai/delegation/middleware/chain-depth-middleware.d.ts +39 -0
  107. package/dist/ai/delegation/middleware/chain-depth-middleware.d.ts.map +1 -0
  108. package/dist/ai/delegation/middleware/chain-depth-middleware.js +77 -0
  109. package/dist/ai/delegation/middleware/chain-depth-middleware.js.map +1 -0
  110. package/dist/ai/delegation/middleware/chain-tracker-middleware.d.ts +46 -0
  111. package/dist/ai/delegation/middleware/chain-tracker-middleware.d.ts.map +1 -0
  112. package/dist/ai/delegation/middleware/chain-tracker-middleware.js +89 -0
  113. package/dist/ai/delegation/middleware/chain-tracker-middleware.js.map +1 -0
  114. package/dist/ai/delegation/middleware/content-policy-middleware.d.ts +31 -0
  115. package/dist/ai/delegation/middleware/content-policy-middleware.d.ts.map +1 -0
  116. package/dist/ai/delegation/middleware/content-policy-middleware.js +82 -0
  117. package/dist/ai/delegation/middleware/content-policy-middleware.js.map +1 -0
  118. package/dist/ai/delegation/middleware/feature-flag-middleware.d.ts +46 -0
  119. package/dist/ai/delegation/middleware/feature-flag-middleware.d.ts.map +1 -0
  120. package/dist/ai/delegation/middleware/feature-flag-middleware.js +59 -0
  121. package/dist/ai/delegation/middleware/feature-flag-middleware.js.map +1 -0
  122. package/dist/ai/delegation/middleware/identity-middleware.d.ts +23 -0
  123. package/dist/ai/delegation/middleware/identity-middleware.d.ts.map +1 -0
  124. package/dist/ai/delegation/middleware/identity-middleware.js +64 -0
  125. package/dist/ai/delegation/middleware/identity-middleware.js.map +1 -0
  126. package/dist/ai/delegation/middleware/permissions-middleware.d.ts +48 -0
  127. package/dist/ai/delegation/middleware/permissions-middleware.d.ts.map +1 -0
  128. package/dist/ai/delegation/middleware/permissions-middleware.js +107 -0
  129. package/dist/ai/delegation/middleware/permissions-middleware.js.map +1 -0
  130. package/dist/ai/delegation/middleware/rate-limiter-middleware.d.ts +38 -0
  131. package/dist/ai/delegation/middleware/rate-limiter-middleware.d.ts.map +1 -0
  132. package/dist/ai/delegation/middleware/rate-limiter-middleware.js +65 -0
  133. package/dist/ai/delegation/middleware/rate-limiter-middleware.js.map +1 -0
  134. package/dist/ai/delegation/middleware/reputation-middleware.d.ts +39 -0
  135. package/dist/ai/delegation/middleware/reputation-middleware.d.ts.map +1 -0
  136. package/dist/ai/delegation/middleware/reputation-middleware.js +75 -0
  137. package/dist/ai/delegation/middleware/reputation-middleware.js.map +1 -0
  138. package/dist/ai/delegation/middleware/resource-limiter-middleware.d.ts +52 -0
  139. package/dist/ai/delegation/middleware/resource-limiter-middleware.d.ts.map +1 -0
  140. package/dist/ai/delegation/middleware/resource-limiter-middleware.js +112 -0
  141. package/dist/ai/delegation/middleware/resource-limiter-middleware.js.map +1 -0
  142. package/dist/ai/delegation/middleware/threat-validator-middleware.d.ts +23 -0
  143. package/dist/ai/delegation/middleware/threat-validator-middleware.d.ts.map +1 -0
  144. package/dist/ai/delegation/middleware/threat-validator-middleware.js +83 -0
  145. package/dist/ai/delegation/middleware/threat-validator-middleware.js.map +1 -0
  146. package/dist/ai/delegation/middleware/tlp-middleware.d.ts +23 -0
  147. package/dist/ai/delegation/middleware/tlp-middleware.d.ts.map +1 -0
  148. package/dist/ai/delegation/middleware/tlp-middleware.js +59 -0
  149. package/dist/ai/delegation/middleware/tlp-middleware.js.map +1 -0
  150. package/dist/ai/delegation/monitoring.d.ts +298 -0
  151. package/dist/ai/delegation/monitoring.d.ts.map +1 -0
  152. package/dist/ai/delegation/monitoring.js +584 -0
  153. package/dist/ai/delegation/monitoring.js.map +1 -0
  154. package/dist/ai/delegation/security-middleware-chain.d.ts +71 -0
  155. package/dist/ai/delegation/security-middleware-chain.d.ts.map +1 -0
  156. package/dist/ai/delegation/security-middleware-chain.js +163 -0
  157. package/dist/ai/delegation/security-middleware-chain.js.map +1 -0
  158. package/dist/ai/delegation/session-checkpoint.d.ts +77 -0
  159. package/dist/ai/delegation/session-checkpoint.d.ts.map +1 -0
  160. package/dist/ai/delegation/session-checkpoint.js +131 -0
  161. package/dist/ai/delegation/session-checkpoint.js.map +1 -0
  162. package/dist/ai/delegation/session-manager.d.ts +131 -0
  163. package/dist/ai/delegation/session-manager.d.ts.map +1 -0
  164. package/dist/ai/delegation/session-manager.js +243 -0
  165. package/dist/ai/delegation/session-manager.js.map +1 -0
  166. package/dist/ai/delegation/session-queue.d.ts +95 -0
  167. package/dist/ai/delegation/session-queue.d.ts.map +1 -0
  168. package/dist/ai/delegation/session-queue.js +136 -0
  169. package/dist/ai/delegation/session-queue.js.map +1 -0
  170. package/dist/ai/delegation/timeout-watchdog.d.ts +60 -0
  171. package/dist/ai/delegation/timeout-watchdog.d.ts.map +1 -0
  172. package/dist/ai/delegation/timeout-watchdog.js +100 -0
  173. package/dist/ai/delegation/timeout-watchdog.js.map +1 -0
  174. package/dist/ai/examples/integration-demo.d.ts +27 -0
  175. package/dist/ai/examples/integration-demo.d.ts.map +1 -0
  176. package/dist/ai/examples/integration-demo.js +536 -0
  177. package/dist/ai/examples/integration-demo.js.map +1 -0
  178. package/dist/ai/index.d.ts +25 -0
  179. package/dist/ai/index.d.ts.map +1 -1
  180. package/dist/ai/index.js +31 -11
  181. package/dist/ai/index.js.map +1 -1
  182. package/dist/ai/mcp/servers/analytics/index.js +67 -11
  183. package/dist/ai/mcp/servers/analytics/index.js.map +1 -1
  184. package/dist/ai/mcp/servers/content-manager/index.d.ts.map +1 -1
  185. package/dist/ai/mcp/servers/content-manager/index.js +50 -4
  186. package/dist/ai/mcp/servers/content-manager/index.js.map +1 -1
  187. package/dist/ai/mcp/servers/delegation-monitor/index.d.ts +36 -0
  188. package/dist/ai/mcp/servers/delegation-monitor/index.d.ts.map +1 -0
  189. package/dist/ai/mcp/servers/delegation-monitor/index.js +757 -0
  190. package/dist/ai/mcp/servers/delegation-monitor/index.js.map +1 -0
  191. package/dist/ai/mcp/servers/design-tokens/index.d.ts.map +1 -1
  192. package/dist/ai/mcp/servers/design-tokens/index.js +62 -39
  193. package/dist/ai/mcp/servers/design-tokens/index.js.map +1 -1
  194. package/dist/ai/mcp/servers/promptintel/index.js +15 -3
  195. package/dist/ai/mcp/servers/promptintel/index.js.map +1 -1
  196. package/dist/ai/mcp/servers/shared/rate-limiter.d.ts.map +1 -1
  197. package/dist/ai/mcp/servers/shared/rate-limiter.js +3 -1
  198. package/dist/ai/mcp/servers/shared/rate-limiter.js.map +1 -1
  199. package/dist/ai/mcp/servers/shared/redis-client.d.ts.map +1 -1
  200. package/dist/ai/mcp/servers/shared/redis-client.js +54 -47
  201. package/dist/ai/mcp/servers/shared/redis-client.js.map +1 -1
  202. package/dist/ai/mcp/servers/shared/types.d.ts +9 -0
  203. package/dist/ai/mcp/servers/shared/types.d.ts.map +1 -1
  204. package/dist/ai/mcp/servers/shared/utils.d.ts +9 -1
  205. package/dist/ai/mcp/servers/shared/utils.d.ts.map +1 -1
  206. package/dist/ai/mcp/servers/shared/utils.js +52 -2
  207. package/dist/ai/mcp/servers/shared/utils.js.map +1 -1
  208. package/dist/ai/memory/config.d.ts +18 -3
  209. package/dist/ai/memory/config.d.ts.map +1 -1
  210. package/dist/ai/memory/config.js +61 -15
  211. package/dist/ai/memory/config.js.map +1 -1
  212. package/dist/ai/memory/dcyfr-memory.d.ts +4 -0
  213. package/dist/ai/memory/dcyfr-memory.d.ts.map +1 -1
  214. package/dist/ai/memory/dcyfr-memory.js +44 -6
  215. package/dist/ai/memory/dcyfr-memory.js.map +1 -1
  216. package/dist/ai/memory/mem0-client.d.ts.map +1 -1
  217. package/dist/ai/memory/mem0-client.js +53 -14
  218. package/dist/ai/memory/mem0-client.js.map +1 -1
  219. package/dist/ai/permissions/attenuation-engine.d.ts +159 -0
  220. package/dist/ai/permissions/attenuation-engine.d.ts.map +1 -0
  221. package/dist/ai/permissions/attenuation-engine.js +511 -0
  222. package/dist/ai/permissions/attenuation-engine.js.map +1 -0
  223. package/dist/ai/plugins/plugin-loader.d.ts +4 -0
  224. package/dist/ai/plugins/plugin-loader.d.ts.map +1 -1
  225. package/dist/ai/plugins/plugin-loader.js +28 -28
  226. package/dist/ai/plugins/plugin-loader.js.map +1 -1
  227. package/dist/ai/reputation/execution-mode-reputation.d.ts +104 -0
  228. package/dist/ai/reputation/execution-mode-reputation.d.ts.map +1 -0
  229. package/dist/ai/reputation/execution-mode-reputation.js +142 -0
  230. package/dist/ai/reputation/execution-mode-reputation.js.map +1 -0
  231. package/dist/ai/reputation/reputation-engine.d.ts +204 -0
  232. package/dist/ai/reputation/reputation-engine.d.ts.map +1 -0
  233. package/dist/ai/reputation/reputation-engine.js +426 -0
  234. package/dist/ai/reputation/reputation-engine.js.map +1 -0
  235. package/dist/ai/runtime/agent-runtime.d.ts +193 -0
  236. package/dist/ai/runtime/agent-runtime.d.ts.map +1 -0
  237. package/dist/ai/runtime/agent-runtime.js +1009 -0
  238. package/dist/ai/runtime/agent-runtime.js.map +1 -0
  239. package/dist/ai/runtime/index.d.ts +11 -0
  240. package/dist/ai/runtime/index.d.ts.map +1 -0
  241. package/dist/ai/runtime/index.js +9 -0
  242. package/dist/ai/runtime/index.js.map +1 -0
  243. package/dist/ai/runtime/telemetry-schema.d.ts +192 -0
  244. package/dist/ai/runtime/telemetry-schema.d.ts.map +1 -0
  245. package/dist/ai/runtime/telemetry-schema.js +200 -0
  246. package/dist/ai/runtime/telemetry-schema.js.map +1 -0
  247. package/dist/ai/runtime/types.d.ts +236 -0
  248. package/dist/ai/runtime/types.d.ts.map +1 -0
  249. package/dist/ai/runtime/types.js +10 -0
  250. package/dist/ai/runtime/types.js.map +1 -0
  251. package/dist/ai/src/batch-processor.d.ts +298 -0
  252. package/dist/ai/src/batch-processor.d.ts.map +1 -0
  253. package/dist/ai/src/batch-processor.js +520 -0
  254. package/dist/ai/src/batch-processor.js.map +1 -0
  255. package/dist/ai/src/capability-bootstrap.d.ts +222 -0
  256. package/dist/ai/src/capability-bootstrap.d.ts.map +1 -0
  257. package/dist/ai/src/capability-bootstrap.js +421 -0
  258. package/dist/ai/src/capability-bootstrap.js.map +1 -0
  259. package/dist/ai/src/capability-manifest-generator.d.ts +52 -0
  260. package/dist/ai/src/capability-manifest-generator.d.ts.map +1 -0
  261. package/dist/ai/src/capability-manifest-generator.js +691 -0
  262. package/dist/ai/src/capability-manifest-generator.js.map +1 -0
  263. package/dist/ai/src/capability-registry.d.ts +157 -0
  264. package/dist/ai/src/capability-registry.d.ts.map +1 -0
  265. package/dist/ai/src/capability-registry.js +577 -0
  266. package/dist/ai/src/capability-registry.js.map +1 -0
  267. package/dist/ai/src/cli/telemetry-dashboard.d.ts +132 -0
  268. package/dist/ai/src/cli/telemetry-dashboard.d.ts.map +1 -0
  269. package/dist/ai/src/cli/telemetry-dashboard.js +565 -0
  270. package/dist/ai/src/cli/telemetry-dashboard.js.map +1 -0
  271. package/dist/ai/src/delegation/feature-flags.d.ts +213 -0
  272. package/dist/ai/src/delegation/feature-flags.d.ts.map +1 -0
  273. package/dist/ai/src/delegation/feature-flags.js +395 -0
  274. package/dist/ai/src/delegation/feature-flags.js.map +1 -0
  275. package/dist/ai/src/delegation/liability-firebreak.d.ts +303 -0
  276. package/dist/ai/src/delegation/liability-firebreak.d.ts.map +1 -0
  277. package/dist/ai/src/delegation/liability-firebreak.js +643 -0
  278. package/dist/ai/src/delegation/liability-firebreak.js.map +1 -0
  279. package/dist/ai/src/delegation/security-threat-model.d.ts +171 -0
  280. package/dist/ai/src/delegation/security-threat-model.d.ts.map +1 -0
  281. package/dist/ai/src/delegation/security-threat-model.js +723 -0
  282. package/dist/ai/src/delegation/security-threat-model.js.map +1 -0
  283. package/dist/ai/src/delegation/tlp-enforcement.d.ts +146 -0
  284. package/dist/ai/src/delegation/tlp-enforcement.d.ts.map +1 -0
  285. package/dist/ai/src/delegation/tlp-enforcement.js +382 -0
  286. package/dist/ai/src/delegation/tlp-enforcement.js.map +1 -0
  287. package/dist/ai/src/delegation-capability-integration.d.ts +154 -0
  288. package/dist/ai/src/delegation-capability-integration.d.ts.map +1 -0
  289. package/dist/ai/src/delegation-capability-integration.js +351 -0
  290. package/dist/ai/src/delegation-capability-integration.js.map +1 -0
  291. package/dist/ai/src/end-to-end-workflow-orchestrator.d.ts +325 -0
  292. package/dist/ai/src/end-to-end-workflow-orchestrator.d.ts.map +1 -0
  293. package/dist/ai/src/end-to-end-workflow-orchestrator.js +801 -0
  294. package/dist/ai/src/end-to-end-workflow-orchestrator.js.map +1 -0
  295. package/dist/ai/src/enhanced-capability-detection.d.ts +237 -0
  296. package/dist/ai/src/enhanced-capability-detection.d.ts.map +1 -0
  297. package/dist/ai/src/enhanced-capability-detection.js +448 -0
  298. package/dist/ai/src/enhanced-capability-detection.js.map +1 -0
  299. package/dist/ai/src/intelligent-cache-manager.d.ts +327 -0
  300. package/dist/ai/src/intelligent-cache-manager.d.ts.map +1 -0
  301. package/dist/ai/src/intelligent-cache-manager.js +634 -0
  302. package/dist/ai/src/intelligent-cache-manager.js.map +1 -0
  303. package/dist/ai/src/mcp-auto-configuration.d.ts +232 -0
  304. package/dist/ai/src/mcp-auto-configuration.d.ts.map +1 -0
  305. package/dist/ai/src/mcp-auto-configuration.js +445 -0
  306. package/dist/ai/src/mcp-auto-configuration.js.map +1 -0
  307. package/dist/ai/src/performance-profiler.d.ts +351 -0
  308. package/dist/ai/src/performance-profiler.d.ts.map +1 -0
  309. package/dist/ai/src/performance-profiler.js +475 -0
  310. package/dist/ai/src/performance-profiler.js.map +1 -0
  311. package/dist/ai/src/personas/hooks/before-llm-call.d.ts +96 -0
  312. package/dist/ai/src/personas/hooks/before-llm-call.d.ts.map +1 -0
  313. package/dist/ai/src/personas/hooks/before-llm-call.js +83 -0
  314. package/dist/ai/src/personas/hooks/before-llm-call.js.map +1 -0
  315. package/dist/ai/src/personas/index.d.ts +10 -0
  316. package/dist/ai/src/personas/index.d.ts.map +1 -0
  317. package/dist/ai/src/personas/index.js +10 -0
  318. package/dist/ai/src/personas/index.js.map +1 -0
  319. package/dist/ai/src/personas/persona-loader.d.ts +42 -0
  320. package/dist/ai/src/personas/persona-loader.d.ts.map +1 -0
  321. package/dist/ai/src/personas/persona-loader.js +162 -0
  322. package/dist/ai/src/personas/persona-loader.js.map +1 -0
  323. package/dist/ai/src/personas/types.d.ts +199 -0
  324. package/dist/ai/src/personas/types.d.ts.map +1 -0
  325. package/dist/ai/src/personas/types.js +7 -0
  326. package/dist/ai/src/personas/types.js.map +1 -0
  327. package/dist/ai/src/personas/voice-resolver.d.ts +40 -0
  328. package/dist/ai/src/personas/voice-resolver.d.ts.map +1 -0
  329. package/dist/ai/src/personas/voice-resolver.js +201 -0
  330. package/dist/ai/src/personas/voice-resolver.js.map +1 -0
  331. package/dist/ai/src/resource-monitor.d.ts +311 -0
  332. package/dist/ai/src/resource-monitor.d.ts.map +1 -0
  333. package/dist/ai/src/resource-monitor.js +475 -0
  334. package/dist/ai/src/resource-monitor.js.map +1 -0
  335. package/dist/ai/src/runtime/agent-runtime.d.ts +340 -0
  336. package/dist/ai/src/runtime/agent-runtime.d.ts.map +1 -0
  337. package/dist/ai/src/runtime/agent-runtime.js +1084 -0
  338. package/dist/ai/src/runtime/agent-runtime.js.map +1 -0
  339. package/dist/ai/src/telemetry/delegation-telemetry.d.ts +287 -0
  340. package/dist/ai/src/telemetry/delegation-telemetry.d.ts.map +1 -0
  341. package/dist/ai/src/telemetry/delegation-telemetry.js +389 -0
  342. package/dist/ai/src/telemetry/delegation-telemetry.js.map +1 -0
  343. package/dist/ai/src/telemetry/index.d.ts +48 -0
  344. package/dist/ai/src/telemetry/index.d.ts.map +1 -0
  345. package/dist/ai/src/telemetry/index.js +48 -0
  346. package/dist/ai/src/telemetry/index.js.map +1 -0
  347. package/dist/ai/src/telemetry/runtime-telemetry-integration.d.ts +67 -0
  348. package/dist/ai/src/telemetry/runtime-telemetry-integration.d.ts.map +1 -0
  349. package/dist/ai/src/telemetry/runtime-telemetry-integration.js +415 -0
  350. package/dist/ai/src/telemetry/runtime-telemetry-integration.js.map +1 -0
  351. package/dist/ai/src/telemetry/telemetry-utils.d.ts +119 -0
  352. package/dist/ai/src/telemetry/telemetry-utils.d.ts.map +1 -0
  353. package/dist/ai/src/telemetry/telemetry-utils.js +250 -0
  354. package/dist/ai/src/telemetry/telemetry-utils.js.map +1 -0
  355. package/dist/ai/src/types/agent-capabilities.d.ts +227 -0
  356. package/dist/ai/src/types/agent-capabilities.d.ts.map +1 -0
  357. package/dist/ai/src/types/agent-capabilities.js +11 -0
  358. package/dist/ai/src/types/agent-capabilities.js.map +1 -0
  359. package/dist/ai/src/types/context-verification.d.ts +158 -0
  360. package/dist/ai/src/types/context-verification.d.ts.map +1 -0
  361. package/dist/ai/src/types/context-verification.js +73 -0
  362. package/dist/ai/src/types/context-verification.js.map +1 -0
  363. package/dist/ai/src/types/delegation-contracts.d.ts +296 -0
  364. package/dist/ai/src/types/delegation-contracts.d.ts.map +1 -0
  365. package/dist/ai/src/types/delegation-contracts.js +17 -0
  366. package/dist/ai/src/types/delegation-contracts.js.map +1 -0
  367. package/dist/ai/src/validation-pipeline-integration.d.ts +266 -0
  368. package/dist/ai/src/validation-pipeline-integration.d.ts.map +1 -0
  369. package/dist/ai/src/validation-pipeline-integration.js +695 -0
  370. package/dist/ai/src/validation-pipeline-integration.js.map +1 -0
  371. package/dist/ai/src/verification/multi-modal-formatters.d.ts +57 -0
  372. package/dist/ai/src/verification/multi-modal-formatters.d.ts.map +1 -0
  373. package/dist/ai/src/verification/multi-modal-formatters.js +655 -0
  374. package/dist/ai/src/verification/multi-modal-formatters.js.map +1 -0
  375. package/dist/ai/src/verification/output-formatter.d.ts +186 -0
  376. package/dist/ai/src/verification/output-formatter.d.ts.map +1 -0
  377. package/dist/ai/src/verification/output-formatter.js +296 -0
  378. package/dist/ai/src/verification/output-formatter.js.map +1 -0
  379. package/dist/ai/src/verification/parser-integration.d.ts +137 -0
  380. package/dist/ai/src/verification/parser-integration.d.ts.map +1 -0
  381. package/dist/ai/src/verification/parser-integration.js +273 -0
  382. package/dist/ai/src/verification/parser-integration.js.map +1 -0
  383. package/dist/ai/types/agent-capabilities.d.ts +387 -0
  384. package/dist/ai/types/agent-capabilities.d.ts.map +1 -0
  385. package/dist/ai/types/agent-capabilities.js +32 -0
  386. package/dist/ai/types/agent-capabilities.js.map +1 -0
  387. package/dist/ai/types/delegation-contracts.d.ts +291 -0
  388. package/dist/ai/types/delegation-contracts.d.ts.map +1 -0
  389. package/dist/ai/types/delegation-contracts.js +14 -0
  390. package/dist/ai/types/delegation-contracts.js.map +1 -0
  391. package/dist/ai/types/index.d.ts +4 -1
  392. package/dist/ai/types/index.d.ts.map +1 -1
  393. package/dist/ai/types/index.js +4 -1
  394. package/dist/ai/types/index.js.map +1 -1
  395. package/dist/ai/types/permission-tokens.d.ts +365 -0
  396. package/dist/ai/types/permission-tokens.d.ts.map +1 -0
  397. package/dist/ai/types/permission-tokens.js +13 -0
  398. package/dist/ai/types/permission-tokens.js.map +1 -0
  399. package/dist/ai/types/security-middleware.d.ts +130 -0
  400. package/dist/ai/types/security-middleware.d.ts.map +1 -0
  401. package/dist/ai/types/security-middleware.js +13 -0
  402. package/dist/ai/types/security-middleware.js.map +1 -0
  403. package/dist/ai/utils/storage.d.ts.map +1 -1
  404. package/dist/ai/utils/storage.js +6 -3
  405. package/dist/ai/utils/storage.js.map +1 -1
  406. package/dist/ai/validation/validation-framework.js +1 -1
  407. package/dist/ai/verification/policy-framework.d.ts +161 -0
  408. package/dist/ai/verification/policy-framework.d.ts.map +1 -0
  409. package/dist/ai/verification/policy-framework.js +436 -0
  410. package/dist/ai/verification/policy-framework.js.map +1 -0
  411. package/package.json +35 -7
@@ -3,7 +3,12 @@
3
3
  *
4
4
  * @module @dcyfr/ai/agents
5
5
  */
6
- export type { AgentCategory, AgentTier, AgentModel, AgentPermissionMode, AgentQualityGate, AgentProactiveTrigger, AgentSkill, AgentManifest, AgentHooks, Agent, LoadedAgent, AgentExecutionContext, AgentExecutionResult, AgentViolation, AgentRoutingRule, AgentRoutingResult, AgentRegistryConfig, AgentLoaderConfig, AgentRouterConfig, } from './types';
6
+ export type { AgentCategory, AgentTier, AgentModel, AgentPermissionMode, AgentQualityGate, AgentProactiveTrigger, AgentSkill, AgentManifest, AgentHooks, Agent, LoadedAgent, AgentExecutionContext, AgentExecutionResult, AgentViolation, AgentRoutingRule, AgentRoutingResult, AgentRegistryConfig, AgentLoaderConfig, AgentRouterConfig, PersonalityTrait, PersonalityTraits, SituationalTone, IntentSignal, ProactiveGuidance, AgentPersona, } from './types';
7
+ export { personalityTraitSchema, personalityTraitsSchema, situationalToneSchema, intentSignalSchema, proactiveGuidanceSchema, agentPersonaIdentitySchema, agentPersonaVoiceSchema, agentPersonaSchema, validatePersona, safeValidatePersona, } from './schema';
8
+ export { resolvePersona } from './persona-resolver';
9
+ export type { BrandVoice, BrandVoiceTraits, ResolvedPersona } from './persona-resolver';
10
+ export { generatePersonaInstructions } from './instruction-template';
11
+ export type { PersonaInstructionSegments } from './instruction-template';
7
12
  export { AgentLoader, AgentLoadError, AgentValidationError, getGlobalAgentLoader, resetGlobalAgentLoader, } from './agent-loader';
8
13
  export { AgentRegistry, getGlobalAgentRegistry, resetGlobalAgentRegistry, } from './agent-registry';
9
14
  export { AgentRouter, getGlobalAgentRouter, resetGlobalAgentRouter, } from './agent-router';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/ai/agents/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,aAAa,EACb,UAAU,EACV,KAAK,EACL,WAAW,EACX,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/ai/agents/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,aAAa,EACb,UAAU,EACV,KAAK,EACL,WAAW,EACX,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EAEjB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,YAAY,GACb,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,EAC1B,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGxF,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,YAAY,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAGzE,OAAO,EACL,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC"}
@@ -3,10 +3,16 @@
3
3
  *
4
4
  * @module @dcyfr/ai/agents
5
5
  */
6
+ // Agent Persona validation exports
7
+ export { personalityTraitSchema, personalityTraitsSchema, situationalToneSchema, intentSignalSchema, proactiveGuidanceSchema, agentPersonaIdentitySchema, agentPersonaVoiceSchema, agentPersonaSchema, validatePersona, safeValidatePersona, } from './schema.js';
8
+ // Agent Persona resolution exports
9
+ export { resolvePersona } from './persona-resolver.js';
10
+ // Instruction template exports
11
+ export { generatePersonaInstructions } from './instruction-template.js';
6
12
  // Agent Loader exports
7
- export { AgentLoader, AgentLoadError, AgentValidationError, getGlobalAgentLoader, resetGlobalAgentLoader, } from './agent-loader';
13
+ export { AgentLoader, AgentLoadError, AgentValidationError, getGlobalAgentLoader, resetGlobalAgentLoader, } from './agent-loader.js';
8
14
  // Agent Registry exports
9
- export { AgentRegistry, getGlobalAgentRegistry, resetGlobalAgentRegistry, } from './agent-registry';
15
+ export { AgentRegistry, getGlobalAgentRegistry, resetGlobalAgentRegistry, } from './agent-registry.js';
10
16
  // Agent Router exports
11
- export { AgentRouter, getGlobalAgentRouter, resetGlobalAgentRouter, } from './agent-router';
17
+ export { AgentRouter, getGlobalAgentRouter, resetGlobalAgentRouter, } from './agent-router.js';
12
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/ai/agents/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAyBH,uBAAuB;AACvB,OAAO,EACL,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB,yBAAyB;AACzB,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,uBAAuB;AACvB,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/ai/agents/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgCH,mCAAmC;AACnC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,EAC1B,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAElB,mCAAmC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,+BAA+B;AAC/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAGrE,uBAAuB;AACvB,OAAO,EACL,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB,yBAAyB;AACzB,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,uBAAuB;AACvB,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Instruction Template Generator
3
+ *
4
+ * Produces natural language instruction segments from a resolved persona,
5
+ * suitable for injection into agent markdown instruction bodies.
6
+ *
7
+ * The generated sections describe:
8
+ * - Agent identity and archetype
9
+ * - Communication style (voice attributes + personality trait descriptions)
10
+ * - Situational tone adaptations
11
+ * - Anti-patterns to avoid
12
+ *
13
+ * @module @dcyfr/ai/agents/instruction-template
14
+ * @version 1.0.0
15
+ */
16
+ import type { ResolvedPersona } from './persona-resolver';
17
+ /**
18
+ * Generated instruction segments.
19
+ * Each section is optional — only rendered when the resolved persona
20
+ * has relevant data.
21
+ */
22
+ export interface PersonaInstructionSegments {
23
+ /** "## Agent Identity" section markdown */
24
+ identity?: string;
25
+ /** "## How You Communicate" section markdown */
26
+ communicationStyle?: string;
27
+ /** "## Situational Adaptation" section markdown */
28
+ situationalAdaptation?: string;
29
+ /** "## You Never" section markdown */
30
+ antiPatterns?: string;
31
+ /** All sections combined as a single markdown block */
32
+ combined: string;
33
+ }
34
+ /**
35
+ * Generate persona instruction segments from a resolved persona.
36
+ *
37
+ * All sections are optional — if the resolved persona lacks data for a section
38
+ * (e.g., no situational tones), that section is omitted from the output.
39
+ * The `combined` field always contains whatever sections were rendered.
40
+ *
41
+ * @param persona - Resolved persona from `resolvePersona()`
42
+ * @returns Object containing individual sections + combined markdown
43
+ */
44
+ export declare function generatePersonaInstructions(persona: ResolvedPersona): PersonaInstructionSegments;
45
+ //# sourceMappingURL=instruction-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instruction-template.d.ts","sourceRoot":"","sources":["../../../packages/ai/agents/instruction-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mDAAmD;IACnD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,sCAAsC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;CAClB;AA8ID;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,eAAe,GACvB,0BAA0B,CAsB5B"}
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Instruction Template Generator
3
+ *
4
+ * Produces natural language instruction segments from a resolved persona,
5
+ * suitable for injection into agent markdown instruction bodies.
6
+ *
7
+ * The generated sections describe:
8
+ * - Agent identity and archetype
9
+ * - Communication style (voice attributes + personality trait descriptions)
10
+ * - Situational tone adaptations
11
+ * - Anti-patterns to avoid
12
+ *
13
+ * @module @dcyfr/ai/agents/instruction-template
14
+ * @version 1.0.0
15
+ */
16
+ /**
17
+ * Map of trait name → human-readable low/high descriptions used when
18
+ * generating natural language descriptions from numeric trait values.
19
+ */
20
+ const TRAIT_DESCRIPTIONS = {
21
+ warmth: {
22
+ low: 'professional and measured in warmth',
23
+ mid: 'warm and collaborative',
24
+ high: 'exceptionally warm and supportive',
25
+ },
26
+ formality: {
27
+ low: 'approachable and conversational (low formality)',
28
+ mid: 'professionally approachable',
29
+ high: 'formal and structured',
30
+ },
31
+ humor: {
32
+ low: 'focused and earnest — minimal humor',
33
+ mid: 'occasionally uses well-timed humor',
34
+ high: 'often light-hearted with frequent humor',
35
+ },
36
+ directness: {
37
+ low: 'exploratory and open-ended',
38
+ mid: 'clear and direct',
39
+ high: 'extremely direct and concise — front-loads key information',
40
+ },
41
+ technicality: {
42
+ low: 'accessible, uses plain language',
43
+ mid: 'technically proficient',
44
+ high: 'highly technical and precise — assumes expert knowledge',
45
+ },
46
+ empathy: {
47
+ low: 'task-focused with minimal emotional acknowledgment',
48
+ mid: 'empathetic and understanding',
49
+ high: 'highly empathetic — always acknowledges emotional context first',
50
+ },
51
+ };
52
+ /**
53
+ * Classify a 0-1 trait value into a low/mid/high band
54
+ */
55
+ function traitBand(value) {
56
+ if (value < 0.4)
57
+ return 'low';
58
+ if (value < 0.7)
59
+ return 'mid';
60
+ return 'high';
61
+ }
62
+ /**
63
+ * Generate natural language description for a set of personality traits
64
+ */
65
+ function describeTraits(traits) {
66
+ const lines = [];
67
+ for (const [trait, value] of Object.entries(traits)) {
68
+ if (typeof value !== 'number')
69
+ continue;
70
+ const desc = TRAIT_DESCRIPTIONS[trait];
71
+ if (desc) {
72
+ lines.push(`- **${capitalize(trait)}**: ${desc[traitBand(value)]} (${value.toFixed(1)})`);
73
+ }
74
+ else {
75
+ lines.push(`- **${capitalize(trait)}**: ${value.toFixed(1)}`);
76
+ }
77
+ }
78
+ return lines.join('\n');
79
+ }
80
+ function capitalize(s) {
81
+ return s.charAt(0).toUpperCase() + s.slice(1);
82
+ }
83
+ /**
84
+ * Generate identity section from persona
85
+ */
86
+ function generateIdentitySection(persona) {
87
+ if (!persona.displayName && !persona.identity)
88
+ return undefined;
89
+ const lines = ['## Agent Identity', ''];
90
+ if (persona.displayName) {
91
+ lines.push(`**Name:** ${persona.displayName}`);
92
+ }
93
+ if (persona.identity) {
94
+ lines.push('');
95
+ lines.push(persona.identity);
96
+ }
97
+ return lines.join('\n');
98
+ }
99
+ /**
100
+ * Generate communication style section from persona
101
+ */
102
+ function generateCommunicationSection(persona) {
103
+ const hasAttributes = persona.voiceAttributes.length > 0;
104
+ const hasTraits = Object.keys(persona.personalityTraits).length > 0;
105
+ if (!hasAttributes && !hasTraits)
106
+ return undefined;
107
+ const lines = ['## How You Communicate', ''];
108
+ if (hasAttributes) {
109
+ lines.push('Your voice is:');
110
+ for (const attr of persona.voiceAttributes) {
111
+ lines.push(`- ${attr}`);
112
+ }
113
+ }
114
+ if (hasTraits) {
115
+ if (hasAttributes)
116
+ lines.push('');
117
+ lines.push('Your personality calibration:');
118
+ lines.push(describeTraits(persona.personalityTraits));
119
+ }
120
+ if (persona.perspective) {
121
+ lines.push('');
122
+ lines.push(`**Perspective:** ${perspectiveLabel(persona.perspective)}`);
123
+ }
124
+ return lines.join('\n');
125
+ }
126
+ /**
127
+ * Generate situational adaptation section from persona
128
+ */
129
+ function generateSituationalSection(persona) {
130
+ if (persona.situationalTones.length === 0)
131
+ return undefined;
132
+ const lines = ['## Situational Adaptation', ''];
133
+ lines.push('Adjust your approach based on context:');
134
+ lines.push('');
135
+ for (const tone of persona.situationalTones) {
136
+ const label = tone.situation.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
137
+ lines.push(`**${label}:** ${tone.guidance}`);
138
+ }
139
+ return lines.join('\n');
140
+ }
141
+ /**
142
+ * Generate anti-patterns section from persona
143
+ */
144
+ function generateAntiPatternsSection(persona) {
145
+ if (persona.antiPatterns.length === 0)
146
+ return undefined;
147
+ const lines = ['## You Never', ''];
148
+ for (const pattern of persona.antiPatterns) {
149
+ lines.push(`- ${pattern}`);
150
+ }
151
+ return lines.join('\n');
152
+ }
153
+ /**
154
+ * Generate persona instruction segments from a resolved persona.
155
+ *
156
+ * All sections are optional — if the resolved persona lacks data for a section
157
+ * (e.g., no situational tones), that section is omitted from the output.
158
+ * The `combined` field always contains whatever sections were rendered.
159
+ *
160
+ * @param persona - Resolved persona from `resolvePersona()`
161
+ * @returns Object containing individual sections + combined markdown
162
+ */
163
+ export function generatePersonaInstructions(persona) {
164
+ const sections = [];
165
+ const identitySection = generateIdentitySection(persona);
166
+ if (identitySection)
167
+ sections.push(identitySection);
168
+ const communicationSection = generateCommunicationSection(persona);
169
+ if (communicationSection)
170
+ sections.push(communicationSection);
171
+ const situationalSection = generateSituationalSection(persona);
172
+ if (situationalSection)
173
+ sections.push(situationalSection);
174
+ const antiPatternsSection = generateAntiPatternsSection(persona);
175
+ if (antiPatternsSection)
176
+ sections.push(antiPatternsSection);
177
+ return {
178
+ identity: identitySection,
179
+ communicationStyle: communicationSection,
180
+ situationalAdaptation: situationalSection,
181
+ antiPatterns: antiPatternsSection,
182
+ combined: sections.join('\n\n'),
183
+ };
184
+ }
185
+ /**
186
+ * Convert perspective enum value to a human-readable description
187
+ */
188
+ function perspectiveLabel(perspective) {
189
+ const labels = {
190
+ 'first-person-singular': 'First-person singular ("I/my")',
191
+ 'first-person-plural': 'First-person plural ("we/our")',
192
+ 'second-person': 'Second-person ("you/your")',
193
+ 'third-person': 'Third-person ("they/their")',
194
+ };
195
+ return labels[perspective] ?? perspective;
196
+ }
197
+ //# sourceMappingURL=instruction-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instruction-template.js","sourceRoot":"","sources":["../../../packages/ai/agents/instruction-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAsBH;;;GAGG;AACH,MAAM,kBAAkB,GAA+D;IACrF,MAAM,EAAE;QACN,GAAG,EAAE,qCAAqC;QAC1C,GAAG,EAAE,wBAAwB;QAC7B,IAAI,EAAE,mCAAmC;KAC1C;IACD,SAAS,EAAE;QACT,GAAG,EAAE,iDAAiD;QACtD,GAAG,EAAE,6BAA6B;QAClC,IAAI,EAAE,uBAAuB;KAC9B;IACD,KAAK,EAAE;QACL,GAAG,EAAE,qCAAqC;QAC1C,GAAG,EAAE,oCAAoC;QACzC,IAAI,EAAE,yCAAyC;KAChD;IACD,UAAU,EAAE;QACV,GAAG,EAAE,4BAA4B;QACjC,GAAG,EAAE,kBAAkB;QACvB,IAAI,EAAE,4DAA4D;KACnE;IACD,YAAY,EAAE;QACZ,GAAG,EAAE,iCAAiC;QACtC,GAAG,EAAE,wBAAwB;QAC7B,IAAI,EAAE,yDAAyD;KAChE;IACD,OAAO,EAAE;QACP,GAAG,EAAE,oDAAoD;QACzD,GAAG,EAAE,8BAA8B;QACnC,IAAI,EAAE,iEAAiE;KACxE;CACF,CAAC;AAEF;;GAEG;AACH,SAAS,SAAS,CAAC,KAAa;IAC9B,IAAI,KAAK,GAAG,GAAG;QAAE,OAAO,KAAK,CAAC;IAC9B,IAAI,KAAK,GAAG,GAAG;QAAE,OAAO,KAAK,CAAC;IAC9B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CAAC,MAA0C;IAChE,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACpD,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,SAAS;QACxC,MAAM,IAAI,GAAG,kBAAkB,CAAC,K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G,0BAA0B,CAAC,OAAO,CAAC,CAAC;IAC/D,IAAI,kBAAkB;QAAE,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAE1D,MAAM,mBAAmB,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAC;IACjE,IAAI,mBAAmB;QAAE,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAE5D,OAAO;QACL,QAAQ,EAAE,eAAe;QACzB,kBAAkB,EAAE,oBAAoB;QACxC,qBAAqB,EAAE,kBAAkB;QACzC,YAAY,EAAE,mBAAmB;QACjC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;KAChC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CAAC,WAAmB;IAC3C,MAAM,MAAM,GAA2B;QACrC,uBAAuB,EAAE,gCAAgC;QACzD,qBAAqB,EAAE,gCAAgC;QACvD,eAAe,EAAE,4BAA4B;QAC7C,cAAc,EAAE,6BAA6B;KAC9C,CAAC;IACF,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Persona Resolver
3
+ *
4
+ * Merges canonical brand voice defaults with per-agent persona overrides to
5
+ * produce a fully resolved persona for any agent. Agents that declare
6
+ * `inheritsBrandVoice: false` receive only their own declared fields.
7
+ *
8
+ * @module @dcyfr/ai/agents/persona-resolver
9
+ * @version 1.0.0
10
+ */
11
+ import type { AgentPersona, SituationalTone } from './types';
12
+ /**
13
+ * Brand voice personality traits (from DCYFR_CONTEXT.json brand_voice block)
14
+ */
15
+ export interface BrandVoiceTraits {
16
+ warmth?: number;
17
+ formality?: number;
18
+ humor?: number;
19
+ directness?: number;
20
+ technicality?: number;
21
+ empathy?: number;
22
+ [key: string]: number | undefined;
23
+ }
24
+ /**
25
+ * Minimal brand voice shape needed for persona resolution.
26
+ * Maps to the structure of DCYFR_CONTEXT.json `brand_voice`.
27
+ */
28
+ export interface BrandVoice {
29
+ identity?: {
30
+ name?: string;
31
+ tagline?: string;
32
+ archetype?: string;
33
+ description?: string;
34
+ };
35
+ core_voice?: {
36
+ attributes?: string[];
37
+ personality_traits?: BrandVoiceTraits;
38
+ perspective?: string;
39
+ };
40
+ anti_patterns?: string[];
41
+ tone_spectrum?: {
42
+ default?: string;
43
+ situational?: Record<string, {
44
+ tone: string;
45
+ }>;
46
+ };
47
+ }
48
+ /**
49
+ * Resolved persona — the merge product of brand voice + agent overrides.
50
+ * All fields are fully concrete (no nullables from inheritance uncertainty).
51
+ */
52
+ export interface ResolvedPersona {
53
+ /** Display name for the agent (from agent persona or brand name) */
54
+ displayName?: string;
55
+ /** Identity statement */
56
+ identity?: string;
57
+ /** Voice attributes (merged or agent-only) */
58
+ voiceAttributes: string[];
59
+ /** Resolved personality traits (agent overrides win) */
60
+ personalityTraits: BrandVoiceTraits;
61
+ /** Perspective string */
62
+ perspective?: string;
63
+ /** Situational tones (brand + agent combined) */
64
+ situationalTones: SituationalTone[];
65
+ /** Anti-patterns (brand + agent combined, deduplicated) */
66
+ antiPatterns: string[];
67
+ /** Whether brand voice was inherited */
68
+ inheritsBrandVoice: boolean;
69
+ }
70
+ /**
71
+ * Resolve an agent's effective persona by merging brand voice defaults with
72
+ * the agent's declared persona overrides.
73
+ *
74
+ * Merge rules:
75
+ * - `personalityTraits`: agent overrides individual trait values; unset traits
76
+ * fall back to brand defaults.
77
+ * - `voiceAttributes`: brand attributes + agent-specific attributes concatenated.
78
+ * - `antiPatterns`: brand anti-patterns + agent anti-patterns, deduplicated.
79
+ * - `situationalTones`: brand tones + agent-specific tones. Agent tones for the
80
+ * same `situation` key do NOT replace brand tones — both are surfaced since
81
+ * they may carry different `traitAdjustments` / `guidance`.
82
+ * - `inheritsBrandVoice: false`: brand merging is skipped entirely; only agent
83
+ * declared fields are included.
84
+ *
85
+ * @param brandVoice - Brand voice block from DCYFR_CONTEXT.json (may be partial)
86
+ * @param agentPersona - Per-agent persona from manifest (optional)
87
+ * @returns Fully resolved persona ready for instruction template generation
88
+ */
89
+ export declare function resolvePersona(brandVoice: BrandVoice | undefined, agentPersona?: AgentPersona): ResolvedPersona;
90
+ //# sourceMappingURL=persona-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persona-resolver.d.ts","sourceRoot":"","sources":["../../../packages/ai/agents/persona-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAqB,eAAe,EAAE,MAAM,SAAS,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE;QACT,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,UAAU,CAAC,EAAE;QACX,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;QACtC,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAChD,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,wDAAwD;IACxD,iBAAiB,EAAE,gBAAgB,CAAC;IACpC,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,2DAA2D;IAC3D,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,wCAAwC;IACxC,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,YAAY,CAAC,EAAE,YAAY,GAC1B,eAAe,CA6CjB"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Persona Resolver
3
+ *
4
+ * Merges canonical brand voice defaults with per-agent persona overrides to
5
+ * produce a fully resolved persona for any agent. Agents that declare
6
+ * `inheritsBrandVoice: false` receive only their own declared fields.
7
+ *
8
+ * @module @dcyfr/ai/agents/persona-resolver
9
+ * @version 1.0.0
10
+ */
11
+ /**
12
+ * Resolve an agent's effective persona by merging brand voice defaults with
13
+ * the agent's declared persona overrides.
14
+ *
15
+ * Merge rules:
16
+ * - `personalityTraits`: agent overrides individual trait values; unset traits
17
+ * fall back to brand defaults.
18
+ * - `voiceAttributes`: brand attributes + agent-specific attributes concatenated.
19
+ * - `antiPatterns`: brand anti-patterns + agent anti-patterns, deduplicated.
20
+ * - `situationalTones`: brand tones + agent-specific tones. Agent tones for the
21
+ * same `situation` key do NOT replace brand tones — both are surfaced since
22
+ * they may carry different `traitAdjustments` / `guidance`.
23
+ * - `inheritsBrandVoice: false`: brand merging is skipped entirely; only agent
24
+ * declared fields are included.
25
+ *
26
+ * @param brandVoice - Brand voice block from DCYFR_CONTEXT.json (may be partial)
27
+ * @param agentPersona - Per-agent persona from manifest (optional)
28
+ * @returns Fully resolved persona ready for instruction template generation
29
+ */
30
+ export function resolvePersona(brandVoice, agentPersona) {
31
+ const inherit = agentPersona?.inheritsBrandVoice !== false;
32
+ if (!inherit) {
33
+ // Agent opted out of brand inheritance — use agent-only fields
34
+ return {
35
+ displayName: agentPersona?.identity?.name,
36
+ identity: agentPersona?.identity?.description,
37
+ voiceAttributes: agentPersona?.voice?.attributes ?? [],
38
+ personalityTraits: flattenTraits(agentPersona?.voice?.personalityTraits),
39
+ perspective: agentPersona?.voice?.perspective,
40
+ situationalTones: agentPersona?.situationalTones ?? [],
41
+ antiPatterns: agentPersona?.antiPatterns ?? [],
42
+ inheritsBrandVoice: false,
43
+ };
44
+ }
45
+ // Brand defaults
46
+ const brandTraits = brandVoice?.core_voice?.personality_traits ?? {};
47
+ const brandAttributes = brandVoice?.core_voice?.attributes ?? [];
48
+ const brandAntiPatterns = brandVoice?.anti_patterns ?? [];
49
+ const brandTones = buildBrandTones(brandVoice?.tone_spectrum?.situational);
50
+ // Agent overrides
51
+ const agentTraits = flattenTraits(agentPersona?.voice?.personalityTraits);
52
+ const agentAttributes = agentPersona?.voice?.attributes ?? [];
53
+ const agentAntiPatterns = agentPersona?.antiPatterns ?? [];
54
+ const agentTones = agentPersona?.situationalTones ?? [];
55
+ // Merge
56
+ const mergedTraits = { ...brandTraits, ...agentTraits };
57
+ const mergedAttributes = deduplicate([...brandAttributes, ...agentAttributes]);
58
+ const mergedAntiPatterns = deduplicate([...brandAntiPatterns, ...agentAntiPatterns]);
59
+ const mergedTones = mergeTones(brandTones, agentTones);
60
+ return {
61
+ displayName: agentPersona?.identity?.name ?? brandVoice?.identity?.name,
62
+ identity: agentPersona?.identity?.description ?? brandVoice?.identity?.description,
63
+ voiceAttributes: mergedAttributes,
64
+ personalityTraits: mergedTraits,
65
+ perspective: agentPersona?.voice?.perspective ?? brandVoice?.core_voice?.perspective,
66
+ situationalTones: mergedTones,
67
+ antiPatterns: mergedAntiPatterns,
68
+ inheritsBrandVoice: true,
69
+ };
70
+ }
71
+ // ---------------------------------------------------------------------------
72
+ // Helpers
73
+ // ---------------------------------------------------------------------------
74
+ /**
75
+ * Extract a flat Record<string, number> from the typed PersonalityTraits object
76
+ */
77
+ function flattenTraits(traits) {
78
+ if (!traits)
79
+ return {};
80
+ const result = {};
81
+ for (const [key, value] of Object.entries(traits)) {
82
+ if (typeof value === 'number') {
83
+ result[key] = value;
84
+ }
85
+ }
86
+ return result;
87
+ }
88
+ /**
89
+ * Convert brand voice situational tone map into SituationalTone[] for merging
90
+ */
91
+ function buildBrandTones(situational) {
92
+ if (!situational)
93
+ return [];
94
+ return Object.entries(situational).map(([situation, data]) => ({
95
+ situation,
96
+ traitAdjustments: {},
97
+ guidance: data.tone,
98
+ }));
99
+ }
100
+ /**
101
+ * Merge brand tones with agent tones. Agent tones for the same situation key
102
+ * override the brand tone entry (agent is more specific).
103
+ */
104
+ function mergeTones(brandTones, agentTones) {
105
+ const toneMap = new Map();
106
+ for (const tone of brandTones) {
107
+ toneMap.set(tone.situation, tone);
108
+ }
109
+ // Agent tones override brand tones for the same situation
110
+ for (const tone of agentTones) {
111
+ toneMap.set(tone.situation, tone);
112
+ }
113
+ return Array.from(toneMap.values());
114
+ }
115
+ /**
116
+ * Deduplicate an array of strings preserving order
117
+ */
118
+ function deduplicate(arr) {
119
+ return [...new Set(arr)];
120
+ }
121
+ //# sourceMappingURL=persona-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persona-resolver.js","sourceRoot":"","sources":["../../../packages/ai/agents/persona-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA+DH;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,cAAc,CAC5B,UAAkC,EAClC,YAA2B;IAE3B,MAAM,OAAO,GAAG,YAAY,EAAE,kBAA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