@ariaflowagents/core 0.7.0 → 0.8.1

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 (228) hide show
  1. package/README.md +90 -1
  2. package/dist/agents/Agent.d.ts +188 -9
  3. package/dist/agents/Agent.d.ts.map +1 -1
  4. package/dist/agents/Agent.js +246 -24
  5. package/dist/agents/Agent.js.map +1 -1
  6. package/dist/agents/CompositeAgent.d.ts +4 -3
  7. package/dist/agents/CompositeAgent.d.ts.map +1 -1
  8. package/dist/agents/CompositeAgent.js +19 -9
  9. package/dist/agents/CompositeAgent.js.map +1 -1
  10. package/dist/agents/FlowAgent.d.ts +3 -2
  11. package/dist/agents/FlowAgent.d.ts.map +1 -1
  12. package/dist/agents/FlowAgent.js +16 -6
  13. package/dist/agents/FlowAgent.js.map +1 -1
  14. package/dist/agents/TriageAgent.d.ts +8 -2
  15. package/dist/agents/TriageAgent.d.ts.map +1 -1
  16. package/dist/agents/TriageAgent.js +39 -6
  17. package/dist/agents/TriageAgent.js.map +1 -1
  18. package/dist/agents/index.d.ts +1 -1
  19. package/dist/agents/index.d.ts.map +1 -1
  20. package/dist/agents/index.js +0 -1
  21. package/dist/agents/index.js.map +1 -1
  22. package/dist/flows/FlowManager.d.ts +8 -0
  23. package/dist/flows/FlowManager.d.ts.map +1 -1
  24. package/dist/flows/FlowManager.js +38 -4
  25. package/dist/flows/FlowManager.js.map +1 -1
  26. package/dist/flows/template.d.ts +2 -2
  27. package/dist/flows/template.d.ts.map +1 -1
  28. package/dist/flows/template.js +13 -0
  29. package/dist/flows/template.js.map +1 -1
  30. package/dist/foundation/AgentDefinition.d.ts +18 -0
  31. package/dist/foundation/AgentDefinition.d.ts.map +1 -0
  32. package/dist/foundation/AgentDefinition.js +2 -0
  33. package/dist/foundation/AgentDefinition.js.map +1 -0
  34. package/dist/foundation/AgentStateController.d.ts +26 -0
  35. package/dist/foundation/AgentStateController.d.ts.map +1 -0
  36. package/dist/foundation/AgentStateController.js +2 -0
  37. package/dist/foundation/AgentStateController.js.map +1 -0
  38. package/dist/foundation/ConversationEventLog.d.ts +72 -0
  39. package/dist/foundation/ConversationEventLog.d.ts.map +1 -0
  40. package/dist/foundation/ConversationEventLog.js +2 -0
  41. package/dist/foundation/ConversationEventLog.js.map +1 -0
  42. package/dist/foundation/ConversationState.d.ts +31 -0
  43. package/dist/foundation/ConversationState.d.ts.map +1 -0
  44. package/dist/foundation/ConversationState.js +2 -0
  45. package/dist/foundation/ConversationState.js.map +1 -0
  46. package/dist/foundation/DefaultAgentStateController.d.ts +24 -0
  47. package/dist/foundation/DefaultAgentStateController.d.ts.map +1 -0
  48. package/dist/foundation/DefaultAgentStateController.js +49 -0
  49. package/dist/foundation/DefaultAgentStateController.js.map +1 -0
  50. package/dist/foundation/DefaultConversationEventLog.d.ts +28 -0
  51. package/dist/foundation/DefaultConversationEventLog.d.ts.map +1 -0
  52. package/dist/foundation/DefaultConversationEventLog.js +195 -0
  53. package/dist/foundation/DefaultConversationEventLog.js.map +1 -0
  54. package/dist/foundation/DefaultConversationState.d.ts +34 -0
  55. package/dist/foundation/DefaultConversationState.d.ts.map +1 -0
  56. package/dist/foundation/DefaultConversationState.js +100 -0
  57. package/dist/foundation/DefaultConversationState.js.map +1 -0
  58. package/dist/foundation/DefaultToolExecutor.d.ts +58 -0
  59. package/dist/foundation/DefaultToolExecutor.d.ts.map +1 -0
  60. package/dist/foundation/DefaultToolExecutor.js +128 -0
  61. package/dist/foundation/DefaultToolExecutor.js.map +1 -0
  62. package/dist/foundation/ToolExecutor.d.ts +44 -0
  63. package/dist/foundation/ToolExecutor.d.ts.map +1 -0
  64. package/dist/foundation/ToolExecutor.js +2 -0
  65. package/dist/foundation/ToolExecutor.js.map +1 -0
  66. package/dist/foundation/createFoundation.d.ts +33 -0
  67. package/dist/foundation/createFoundation.d.ts.map +1 -0
  68. package/dist/foundation/createFoundation.js +34 -0
  69. package/dist/foundation/createFoundation.js.map +1 -0
  70. package/dist/foundation/index.d.ts +15 -0
  71. package/dist/foundation/index.d.ts.map +1 -0
  72. package/dist/foundation/index.js +8 -0
  73. package/dist/foundation/index.js.map +1 -0
  74. package/dist/hooks/HookRunner.d.ts +2 -0
  75. package/dist/hooks/HookRunner.d.ts.map +1 -1
  76. package/dist/hooks/HookRunner.js +4 -0
  77. package/dist/hooks/HookRunner.js.map +1 -1
  78. package/dist/index.d.ts +13 -2
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +9 -1
  81. package/dist/index.js.map +1 -1
  82. package/dist/memory/MemoryService.d.ts +40 -0
  83. package/dist/memory/MemoryService.d.ts.map +1 -0
  84. package/dist/memory/MemoryService.js +2 -0
  85. package/dist/memory/MemoryService.js.map +1 -0
  86. package/dist/memory/index.d.ts +5 -0
  87. package/dist/memory/index.d.ts.map +1 -0
  88. package/dist/memory/index.js +3 -0
  89. package/dist/memory/index.js.map +1 -0
  90. package/dist/memory/preloadMemory.d.ts +17 -0
  91. package/dist/memory/preloadMemory.d.ts.map +1 -0
  92. package/dist/memory/preloadMemory.js +62 -0
  93. package/dist/memory/preloadMemory.js.map +1 -0
  94. package/dist/memory/stores/InMemoryMemoryService.d.ts +20 -0
  95. package/dist/memory/stores/InMemoryMemoryService.d.ts.map +1 -0
  96. package/dist/memory/stores/InMemoryMemoryService.js +92 -0
  97. package/dist/memory/stores/InMemoryMemoryService.js.map +1 -0
  98. package/dist/memory/types.d.ts +49 -0
  99. package/dist/memory/types.d.ts.map +1 -0
  100. package/dist/memory/types.js +8 -0
  101. package/dist/memory/types.js.map +1 -0
  102. package/dist/prompts/AgentPrompt.d.ts +110 -0
  103. package/dist/prompts/AgentPrompt.d.ts.map +1 -0
  104. package/dist/prompts/AgentPrompt.js +373 -0
  105. package/dist/prompts/AgentPrompt.js.map +1 -0
  106. package/dist/prompts/PromptAssembly.d.ts +119 -0
  107. package/dist/prompts/PromptAssembly.d.ts.map +1 -0
  108. package/dist/prompts/PromptAssembly.js +150 -0
  109. package/dist/prompts/PromptAssembly.js.map +1 -0
  110. package/dist/prompts/PromptBuilder.d.ts +22 -3
  111. package/dist/prompts/PromptBuilder.d.ts.map +1 -1
  112. package/dist/prompts/PromptBuilder.js +242 -13
  113. package/dist/prompts/PromptBuilder.js.map +1 -1
  114. package/dist/prompts/PromptRenderer.d.ts +43 -0
  115. package/dist/prompts/PromptRenderer.d.ts.map +1 -0
  116. package/dist/prompts/PromptRenderer.js +114 -0
  117. package/dist/prompts/PromptRenderer.js.map +1 -0
  118. package/dist/prompts/brandVoice.d.ts +10 -0
  119. package/dist/prompts/brandVoice.d.ts.map +1 -0
  120. package/dist/prompts/brandVoice.js +87 -0
  121. package/dist/prompts/brandVoice.js.map +1 -0
  122. package/dist/prompts/index.d.ts +11 -4
  123. package/dist/prompts/index.d.ts.map +1 -1
  124. package/dist/prompts/index.js +7 -2
  125. package/dist/prompts/index.js.map +1 -1
  126. package/dist/prompts/security.d.ts +5 -0
  127. package/dist/prompts/security.d.ts.map +1 -0
  128. package/dist/prompts/security.js +52 -0
  129. package/dist/prompts/security.js.map +1 -0
  130. package/dist/prompts/types.d.ts +65 -1
  131. package/dist/prompts/types.d.ts.map +1 -1
  132. package/dist/prompts/types.js +26 -0
  133. package/dist/prompts/types.js.map +1 -1
  134. package/dist/runtime/ContextBudget.d.ts +57 -0
  135. package/dist/runtime/ContextBudget.d.ts.map +1 -0
  136. package/dist/runtime/ContextBudget.js +103 -0
  137. package/dist/runtime/ContextBudget.js.map +1 -0
  138. package/dist/runtime/ContextManager.d.ts +8 -5
  139. package/dist/runtime/ContextManager.d.ts.map +1 -1
  140. package/dist/runtime/ContextManager.js +47 -14
  141. package/dist/runtime/ContextManager.js.map +1 -1
  142. package/dist/runtime/FlowExecutor.d.ts +16 -11
  143. package/dist/runtime/FlowExecutor.d.ts.map +1 -1
  144. package/dist/runtime/FlowExecutor.js +32 -138
  145. package/dist/runtime/FlowExecutor.js.map +1 -1
  146. package/dist/runtime/Runtime.d.ts +31 -78
  147. package/dist/runtime/Runtime.d.ts.map +1 -1
  148. package/dist/runtime/Runtime.js +225 -1406
  149. package/dist/runtime/Runtime.js.map +1 -1
  150. package/dist/runtime/SessionCache.d.ts +16 -0
  151. package/dist/runtime/SessionCache.d.ts.map +1 -0
  152. package/dist/runtime/SessionCache.js +49 -0
  153. package/dist/runtime/SessionCache.js.map +1 -0
  154. package/dist/runtime/SessionMutex.d.ts +37 -0
  155. package/dist/runtime/SessionMutex.d.ts.map +1 -0
  156. package/dist/runtime/SessionMutex.js +59 -0
  157. package/dist/runtime/SessionMutex.js.map +1 -0
  158. package/dist/runtime/StreamEmitter.d.ts +34 -0
  159. package/dist/runtime/StreamEmitter.d.ts.map +1 -0
  160. package/dist/runtime/StreamEmitter.js +91 -0
  161. package/dist/runtime/StreamEmitter.js.map +1 -0
  162. package/dist/runtime/handoffFilters.d.ts +60 -0
  163. package/dist/runtime/handoffFilters.d.ts.map +1 -0
  164. package/dist/runtime/handoffFilters.js +95 -0
  165. package/dist/runtime/handoffFilters.js.map +1 -0
  166. package/dist/runtime/pipeline/AgentExecuteStage.d.ts +22 -0
  167. package/dist/runtime/pipeline/AgentExecuteStage.d.ts.map +1 -0
  168. package/dist/runtime/pipeline/AgentExecuteStage.js +889 -0
  169. package/dist/runtime/pipeline/AgentExecuteStage.js.map +1 -0
  170. package/dist/runtime/pipeline/ContextAssembleStage.d.ts +26 -0
  171. package/dist/runtime/pipeline/ContextAssembleStage.d.ts.map +1 -0
  172. package/dist/runtime/pipeline/ContextAssembleStage.js +253 -0
  173. package/dist/runtime/pipeline/ContextAssembleStage.js.map +1 -0
  174. package/dist/runtime/pipeline/ContextGatherStage.d.ts +21 -0
  175. package/dist/runtime/pipeline/ContextGatherStage.d.ts.map +1 -0
  176. package/dist/runtime/pipeline/ContextGatherStage.js +161 -0
  177. package/dist/runtime/pipeline/ContextGatherStage.js.map +1 -0
  178. package/dist/runtime/pipeline/IntakeStage.d.ts +25 -0
  179. package/dist/runtime/pipeline/IntakeStage.d.ts.map +1 -0
  180. package/dist/runtime/pipeline/IntakeStage.js +126 -0
  181. package/dist/runtime/pipeline/IntakeStage.js.map +1 -0
  182. package/dist/runtime/pipeline/PostStreamStage.d.ts +26 -0
  183. package/dist/runtime/pipeline/PostStreamStage.d.ts.map +1 -0
  184. package/dist/runtime/pipeline/PostStreamStage.js +129 -0
  185. package/dist/runtime/pipeline/PostStreamStage.js.map +1 -0
  186. package/dist/runtime/pipeline/TurnPipeline.d.ts +54 -0
  187. package/dist/runtime/pipeline/TurnPipeline.d.ts.map +1 -0
  188. package/dist/runtime/pipeline/TurnPipeline.js +15 -0
  189. package/dist/runtime/pipeline/TurnPipeline.js.map +1 -0
  190. package/dist/runtime/pipeline/TurnServices.d.ts +48 -0
  191. package/dist/runtime/pipeline/TurnServices.d.ts.map +1 -0
  192. package/dist/runtime/pipeline/TurnServices.js +2 -0
  193. package/dist/runtime/pipeline/TurnServices.js.map +1 -0
  194. package/dist/runtime/pipeline/agentTypeGuards.d.ts +4 -0
  195. package/dist/runtime/pipeline/agentTypeGuards.d.ts.map +1 -0
  196. package/dist/runtime/pipeline/agentTypeGuards.js +7 -0
  197. package/dist/runtime/pipeline/agentTypeGuards.js.map +1 -0
  198. package/dist/runtime/pipeline/index.d.ts +11 -0
  199. package/dist/runtime/pipeline/index.d.ts.map +1 -0
  200. package/dist/runtime/pipeline/index.js +13 -0
  201. package/dist/runtime/pipeline/index.js.map +1 -0
  202. package/dist/runtime/pipeline/outputProcessing.d.ts +23 -0
  203. package/dist/runtime/pipeline/outputProcessing.d.ts.map +1 -0
  204. package/dist/runtime/pipeline/outputProcessing.js +63 -0
  205. package/dist/runtime/pipeline/outputProcessing.js.map +1 -0
  206. package/dist/runtime/pipeline/sessionUtils.d.ts +12 -0
  207. package/dist/runtime/pipeline/sessionUtils.d.ts.map +1 -0
  208. package/dist/runtime/pipeline/sessionUtils.js +73 -0
  209. package/dist/runtime/pipeline/sessionUtils.js.map +1 -0
  210. package/dist/tools/Tool.d.ts +7 -0
  211. package/dist/tools/Tool.d.ts.map +1 -1
  212. package/dist/tools/Tool.js +12 -3
  213. package/dist/tools/Tool.js.map +1 -1
  214. package/dist/tools/memory.d.ts +26 -0
  215. package/dist/tools/memory.d.ts.map +1 -0
  216. package/dist/tools/memory.js +51 -0
  217. package/dist/tools/memory.js.map +1 -0
  218. package/dist/types/index.d.ts +177 -6
  219. package/dist/types/index.d.ts.map +1 -1
  220. package/dist/types/index.js.map +1 -1
  221. package/guides/AGENTS.md +173 -0
  222. package/guides/README.md +12 -0
  223. package/guides/TOOLS.md +93 -27
  224. package/package.json +12 -4
  225. package/dist/agents/LLMAgent.d.ts +0 -11
  226. package/dist/agents/LLMAgent.d.ts.map +0 -1
  227. package/dist/agents/LLMAgent.js +0 -31
  228. package/dist/agents/LLMAgent.js.map +0 -1
@@ -1,9 +1,28 @@
1
- import type { PromptTemplate } from './types.js';
1
+ import type { ToolSet } from '../tools/Tool.js';
2
+ import type { PromptTemplate, PromptBuilderConfig, BrandVoiceConfig, KnowledgeContext, SessionMemory, AgentDefinition, PolicyProfile } from './types.js';
2
3
  export declare class PromptBuilder {
3
- private template;
4
- constructor(template: PromptTemplate);
4
+ private config;
5
+ /**
6
+ * Accepts either:
7
+ * - PromptBuilderConfig (new fluent API)
8
+ * - PromptTemplate (backward compatible - treated as user template sections)
9
+ */
10
+ constructor(config?: PromptBuilderConfig | PromptTemplate);
11
+ withTemplate(template: PromptTemplate): this;
12
+ withAgentDefinition(definition: AgentDefinition): this;
13
+ withBrandVoice(brandVoice: BrandVoiceConfig): this;
14
+ withTools(tools: ToolSet): this;
15
+ withSessionMemory(memory: SessionMemory): this;
16
+ withKnowledgeContext(context: KnowledgeContext): this;
17
+ withPolicyProfile(profile: PolicyProfile): this;
5
18
  build(): string;
19
+ private buildAgentDefinitionSections;
20
+ private buildBrandVoiceSections;
21
+ private buildKnowledgeSections;
22
+ private buildToolsSections;
23
+ private buildSessionMemorySections;
6
24
  private formatSection;
7
25
  private getHeader;
8
26
  }
27
+ export declare function createPrompt(): PromptBuilder;
9
28
  //# sourceMappingURL=PromptBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PromptBuilder.d.ts","sourceRoot":"","sources":["../../src/prompts/PromptBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,YAAY,CAAC;AAEhE,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAiB;gBAErB,QAAQ,EAAE,cAAc;IAIpC,KAAK,IAAI,MAAM;IASf,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,SAAS;CAkBlB"}
1
+ {"version":3,"file":"PromptBuilder.d.ts","sourceRoot":"","sources":["../../src/prompts/PromptBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAEV,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,aAAa,EACd,MAAM,YAAY,CAAC;AAKpB,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAsB;IAEpC;;;;OAIG;gBACS,MAAM,GAAE,mBAAmB,GAAG,cAAmB;IAS7D,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAK5C,mBAAmB,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI;IAKtD,cAAc,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI;IAKlD,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAK/B,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAK9C,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAKrD,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAO/C,KAAK,IAAI,MAAM;IAyDf,OAAO,CAAC,4BAA4B;IA2BpC,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,sBAAsB;IA+C9B,OAAO,CAAC,kBAAkB;IA6B1B,OAAO,CAAC,0BAA0B;IAwClC,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,SAAS;CAmClB;AAGD,wBAAgB,YAAY,IAAI,aAAa,CAE5C"}
@@ -1,15 +1,223 @@
1
+ import { LAYER_PRIORITIES } from './types.js';
2
+ import { getSecurityCore, SECURITY_REMINDER } from './security.js';
3
+ import { buildBrandVoiceSection } from './brandVoice.js';
1
4
  export class PromptBuilder {
2
- template;
3
- constructor(template) {
4
- this.template = template;
5
+ config;
6
+ /**
7
+ * Accepts either:
8
+ * - PromptBuilderConfig (new fluent API)
9
+ * - PromptTemplate (backward compatible - treated as user template sections)
10
+ */
11
+ constructor(config = {}) {
12
+ // Handle backward compatibility: if it's a PromptTemplate, wrap it
13
+ if ('sections' in config && 'id' in config) {
14
+ this.config = { template: config };
15
+ }
16
+ else {
17
+ this.config = config;
18
+ }
19
+ }
20
+ withTemplate(template) {
21
+ this.config.template = template;
22
+ return this;
23
+ }
24
+ withAgentDefinition(definition) {
25
+ this.config.agentDefinition = definition;
26
+ return this;
27
+ }
28
+ withBrandVoice(brandVoice) {
29
+ this.config.brandVoice = brandVoice;
30
+ return this;
31
+ }
32
+ withTools(tools) {
33
+ this.config.tools = tools;
34
+ return this;
35
+ }
36
+ withSessionMemory(memory) {
37
+ this.config.sessionMemory = memory;
38
+ return this;
39
+ }
40
+ withKnowledgeContext(context) {
41
+ this.config.knowledgeContext = context;
42
+ return this;
43
+ }
44
+ withPolicyProfile(profile) {
45
+ this.config.policyProfile = profile;
46
+ return this;
5
47
  }
6
48
  build() {
7
- const sortedSections = [...this.template.sections].sort((a, b) => {
8
- const pA = a.priority ?? 100;
9
- const pB = b.priority ?? 100;
10
- return pA - pB;
49
+ const sections = [];
50
+ // Layer 0: Security Core (IMMUTABLE - always first)
51
+ sections.push({
52
+ type: 'security_core',
53
+ content: getSecurityCore(this.config.policyProfile ?? 'minimal'),
54
+ priority: LAYER_PRIORITIES.SECURITY_CORE.min,
55
+ immutable: true,
56
+ });
57
+ // Layer 1: Agent Definition
58
+ if (this.config.agentDefinition) {
59
+ sections.push(...this.buildAgentDefinitionSections());
60
+ }
61
+ // Layer 2: Brand Voice
62
+ if (this.config.brandVoice) {
63
+ sections.push(...this.buildBrandVoiceSections());
64
+ }
65
+ // User Template Sections (priority 10-99)
66
+ if (this.config.template) {
67
+ sections.push(...this.config.template.sections);
68
+ }
69
+ // Layer 3: Knowledge & Grounding
70
+ if (this.config.knowledgeContext) {
71
+ sections.push(...this.buildKnowledgeSections());
72
+ }
73
+ // Layer 4: Tools & Actions (auto)
74
+ if (this.config.tools && Object.keys(this.config.tools).length > 0) {
75
+ sections.push(...this.buildToolsSections());
76
+ }
77
+ // Layer 5: Session Memory (auto)
78
+ if (this.config.sessionMemory) {
79
+ sections.push(...this.buildSessionMemorySections());
80
+ }
81
+ // Layer 6: Security Reminder (IMMUTABLE - always last)
82
+ sections.push({
83
+ type: 'security_reminder',
84
+ content: SECURITY_REMINDER,
85
+ priority: LAYER_PRIORITIES.SECURITY_REMINDER,
86
+ immutable: true,
87
+ });
88
+ // Sort by priority
89
+ const sorted = sections.sort((a, b) => (a.priority ?? 100) - (b.priority ?? 100));
90
+ return sorted.map(s => this.formatSection(s)).join('\n\n');
91
+ }
92
+ buildAgentDefinitionSections() {
93
+ const def = this.config.agentDefinition;
94
+ const sections = [];
95
+ sections.push({
96
+ type: 'identity',
97
+ content: def.identity,
98
+ priority: LAYER_PRIORITIES.IDENTITY,
11
99
  });
12
- return sortedSections.map(section => this.formatSection(section)).join('\n\n');
100
+ sections.push({
101
+ type: 'role',
102
+ content: def.role,
103
+ priority: LAYER_PRIORITIES.ROLE,
104
+ });
105
+ if (def.capabilities?.length) {
106
+ sections.push({
107
+ type: 'capabilities',
108
+ content: `## Capabilities\n${def.capabilities.map(c => `- ${c}`).join('\n')}`,
109
+ priority: 18,
110
+ });
111
+ }
112
+ return sections;
113
+ }
114
+ buildBrandVoiceSections() {
115
+ const voice = this.config.brandVoice;
116
+ return [{
117
+ type: 'brand_voice',
118
+ content: buildBrandVoiceSection(voice),
119
+ priority: LAYER_PRIORITIES.BRAND_VOICE,
120
+ }];
121
+ }
122
+ buildKnowledgeSections() {
123
+ const knowledge = this.config.knowledgeContext;
124
+ const sections = [];
125
+ // Retrieved context (RAG/CAG)
126
+ if (knowledge.retrieved) {
127
+ sections.push({
128
+ type: 'knowledge',
129
+ content: `## Knowledge Context\n\n${knowledge.retrieved}`,
130
+ priority: LAYER_PRIORITIES.KNOWLEDGE,
131
+ });
132
+ }
133
+ // Business rules
134
+ if (knowledge.businessRules?.length) {
135
+ sections.push({
136
+ type: 'business_rules',
137
+ content: `## Business Rules\n\n${knowledge.businessRules.map(r => `- ${r}`).join('\n')}`,
138
+ priority: LAYER_PRIORITIES.BUSINESS_RULES,
139
+ });
140
+ }
141
+ // Grounding rules (always included)
142
+ sections.push({
143
+ type: 'grounding_rules',
144
+ content: `## Grounding Rules
145
+ - Only state facts that are supported by the knowledge context or tool results.
146
+ - If information is not available, say so clearly rather than guessing.
147
+ - When citing information, reference the source naturally.`,
148
+ priority: LAYER_PRIORITIES.GROUNDING_RULES,
149
+ });
150
+ // Glossary
151
+ if (knowledge.glossary?.length) {
152
+ const glossaryContent = knowledge.glossary
153
+ .map(t => `- **${t.name}**: ${t.description}${t.synonyms ? ` (also: ${t.synonyms.join(', ')})` : ''}`)
154
+ .join('\n');
155
+ sections.push({
156
+ type: 'glossary',
157
+ content: `## Glossary\n\n${glossaryContent}`,
158
+ priority: LAYER_PRIORITIES.GLOSSARY,
159
+ });
160
+ }
161
+ return sections;
162
+ }
163
+ buildToolsSections() {
164
+ const tools = this.config.tools;
165
+ const sections = [];
166
+ const toolDescriptions = Object.entries(tools)
167
+ .map(([name, tool]) => {
168
+ const desc = 'description' in tool ? String(tool.description) : '';
169
+ return `### ${name}\n${desc}`;
170
+ })
171
+ .join('\n\n');
172
+ sections.push({
173
+ type: 'tools',
174
+ content: `## Available Tools\n\n${toolDescriptions}`,
175
+ priority: LAYER_PRIORITIES.TOOLS,
176
+ });
177
+ sections.push({
178
+ type: 'tool_contract',
179
+ content: `## Tool Usage Rules
180
+ - Only use tools that are available.
181
+ - Report tool failures honestly.
182
+ - For critical operations, verify success before confirming to the user.`,
183
+ priority: LAYER_PRIORITIES.TOOL_CONTRACT,
184
+ });
185
+ return sections;
186
+ }
187
+ buildSessionMemorySections() {
188
+ const memory = this.config.sessionMemory;
189
+ const sections = [];
190
+ // Flow progress
191
+ if (memory.flowProgress) {
192
+ const collectedData = Object.keys(memory.flowProgress.collectedData).length > 0
193
+ ? `\n**Collected Data:**\n${JSON.stringify(memory.flowProgress.collectedData, null, 2)}`
194
+ : '';
195
+ sections.push({
196
+ type: 'flow_context',
197
+ content: `## Current Flow State\n**Current Step:** ${memory.flowProgress.currentNode}${collectedData}`,
198
+ priority: LAYER_PRIORITIES.FLOW_CONTEXT,
199
+ });
200
+ }
201
+ // Conversation state
202
+ if (memory.conversationState && Object.keys(memory.conversationState).length > 0) {
203
+ sections.push({
204
+ type: 'session_state',
205
+ content: `## Session State\n\`\`\`json\n${JSON.stringify(memory.conversationState, null, 2)}\n\`\`\``,
206
+ priority: LAYER_PRIORITIES.SESSION_STATE,
207
+ });
208
+ }
209
+ // Working memory (injection queue)
210
+ if (memory.workingMemory?.length) {
211
+ const workingContent = memory.workingMemory
212
+ .map(w => `### ${w.label}\n${w.content}`)
213
+ .join('\n\n');
214
+ sections.push({
215
+ type: 'conversation_summary',
216
+ content: `## Context\n\n${workingContent}`,
217
+ priority: LAYER_PRIORITIES.CONVERSATION_SUMMARY,
218
+ });
219
+ }
220
+ return sections;
13
221
  }
14
222
  formatSection(section) {
15
223
  const header = this.getHeader(section.type);
@@ -21,21 +229,42 @@ export class PromptBuilder {
21
229
  }
22
230
  getHeader(type) {
23
231
  const headers = {
232
+ // Security layers
233
+ security_core: '# Security Core',
234
+ security_reminder: '# Final Check',
235
+ // Agent definition
236
+ identity: '# Identity',
237
+ role: '# Role',
238
+ capabilities: '# Capabilities',
239
+ // Brand voice
240
+ brand_voice: '# Brand Voice',
241
+ tone: '# Tone',
24
242
  personality: '# Personality',
25
- goal: '# Goal',
26
- guardrails: '# Guardrails',
243
+ // Knowledge & grounding
244
+ knowledge: '# Knowledge Context',
245
+ grounding_rules: '# Grounding Rules',
246
+ business_rules: '# Business Rules',
247
+ // Tools
27
248
  tools: '# Tools',
28
- tone: '# Tone',
249
+ tool_contract: '# Tool Usage',
250
+ // Session memory
251
+ session_state: '# Session State',
252
+ flow_context: '# Flow Context',
253
+ conversation_summary: '# Context',
254
+ // Legacy
29
255
  character_normalization: '# Character Normalization',
30
256
  voice_rules: '# Voice Output Rules',
31
- glossary: '# Glossary',
32
257
  system_reminder: '# System Reminder',
33
258
  error_handling: '# Error Handling',
34
259
  brief_speech: '# Response Style',
35
260
  handoff: '',
36
- custom: '', // Custom sections include their own header in content
261
+ custom: '',
37
262
  };
38
263
  return headers[type] || '# Custom';
39
264
  }
40
265
  }
266
+ // Fluent builder factory
267
+ export function createPrompt() {
268
+ return new PromptBuilder();
269
+ }
41
270
  //# sourceMappingURL=PromptBuilder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PromptBuilder.js","sourceRoot":"","sources":["../../src/prompts/PromptBuilder.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAa;IAChB,QAAQ,CAAiB;IAEjC,YAAY,QAAwB;QAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,KAAK;QACH,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAC/D,MAAM,EAAE,GAAG,CAAC,CAAC,QAAQ,IAAI,GAAG,CAAC;YAC7B,MAAM,EAAE,GAAG,CAAC,CAAC,QAAQ,IAAI,GAAG,CAAC;YAC7B,OAAO,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oB,EAAE,WAAW;YACjC,SAAS;YACT,uBAAuB,EAAE,2BAA2B;YACpD,WAAW,EAAE,sBAAsB;YACnC,eAAe,EAAE,mBAAmB;YACpC,cAAc,EAAE,kBAAkB;YAClC,YAAY,EAAE,kBAAkB;YAChC,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,EAAE;SACX,CAAC;QACF,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC;IACrC,CAAC;CACF;AAED,yBAAyB;AACzB,MAAM,UAAU,YAAY;IAC1B,OAAO,IAAI,aAAa,EAAE,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * PromptRenderer — Pure functions that render resolved prompt sections to a string.
3
+ *
4
+ * Handles XML tag wrapping, token budgeting (trimming shrinkable sections in
5
+ * reverse priority order), and security validation.
6
+ *
7
+ * @module
8
+ */
9
+ import type { ResolvedSection } from './PromptAssembly.js';
10
+ /**
11
+ * Options controlling how resolved sections are rendered to a final string.
12
+ */
13
+ export interface RenderOptions {
14
+ /** Maximum token budget for the rendered prompt. If exceeded, shrinkable sections are trimmed. */
15
+ maxTokens?: number;
16
+ /** Whether to wrap each section in XML tags. Defaults to true. */
17
+ useXmlTags?: boolean;
18
+ /** Whether to validate that security sections (security_core, security_reminder) exist. Defaults to true. */
19
+ validateSecurity?: boolean;
20
+ }
21
+ /**
22
+ * Thrown when prompt validation fails (e.g. missing security sections).
23
+ */
24
+ export declare class PromptValidationError extends Error {
25
+ constructor(message: string);
26
+ }
27
+ /**
28
+ * Renders an array of resolved sections into a single prompt string.
29
+ *
30
+ * Behavior:
31
+ * 1. Filters out sections with empty content.
32
+ * 2. Validates that security sections exist (if `validateSecurity` is true).
33
+ * 3. If total tokens exceed `maxTokens`, trims shrinkable sections in
34
+ * **reverse** priority order (lowest priority trimmed first — so knowledge,
35
+ * memory, and tools are trimmed before role/instructions).
36
+ * 4. Wraps each section in `<tag>\ncontent\n</tag>` when `useXmlTags` is true.
37
+ *
38
+ * @param sections - Pre-sorted resolved sections (ascending priority).
39
+ * @param options - Render options.
40
+ * @returns The assembled prompt string.
41
+ */
42
+ export declare function renderSections(sections: ResolvedSection[], options?: RenderOptions): string;
43
+ //# sourceMappingURL=PromptRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PromptRenderer.d.ts","sourceRoot":"","sources":["../../src/prompts/PromptRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAM3D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,kGAAkG;IAClG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,6GAA6G;IAC7G,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAMD;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,eAAe,EAAE,EAC3B,OAAO,GAAE,aAAkB,GAC1B,MAAM,CA2CR"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * PromptRenderer — Pure functions that render resolved prompt sections to a string.
3
+ *
4
+ * Handles XML tag wrapping, token budgeting (trimming shrinkable sections in
5
+ * reverse priority order), and security validation.
6
+ *
7
+ * @module
8
+ */
9
+ import { estimateTokenCount, truncateToTokenBudget } from '../runtime/ContextBudget.js';
10
+ // ============================================
11
+ // Error
12
+ // ============================================
13
+ /**
14
+ * Thrown when prompt validation fails (e.g. missing security sections).
15
+ */
16
+ export class PromptValidationError extends Error {
17
+ constructor(message) {
18
+ super(message);
19
+ this.name = 'PromptValidationError';
20
+ }
21
+ }
22
+ // ============================================
23
+ // Render
24
+ // ============================================
25
+ /**
26
+ * Renders an array of resolved sections into a single prompt string.
27
+ *
28
+ * Behavior:
29
+ * 1. Filters out sections with empty content.
30
+ * 2. Validates that security sections exist (if `validateSecurity` is true).
31
+ * 3. If total tokens exceed `maxTokens`, trims shrinkable sections in
32
+ * **reverse** priority order (lowest priority trimmed first — so knowledge,
33
+ * memory, and tools are trimmed before role/instructions).
34
+ * 4. Wraps each section in `<tag>\ncontent\n</tag>` when `useXmlTags` is true.
35
+ *
36
+ * @param sections - Pre-sorted resolved sections (ascending priority).
37
+ * @param options - Render options.
38
+ * @returns The assembled prompt string.
39
+ */
40
+ export function renderSections(sections, options = {}) {
41
+ const { maxTokens, useXmlTags = true, validateSecurity = true, } = options;
42
+ // Filter empty sections
43
+ let active = sections.filter((s) => s.content.trim().length > 0);
44
+ // Validate security
45
+ if (validateSecurity) {
46
+ const hasSecurityCore = active.some((s) => s.type === 'security_core');
47
+ const hasSecurityReminder = active.some((s) => s.type === 'security_reminder');
48
+ if (!hasSecurityCore) {
49
+ throw new PromptValidationError('Missing required security_core section. ' +
50
+ 'Disable security validation with { validateSecurity: false } if intentional.');
51
+ }
52
+ if (!hasSecurityReminder) {
53
+ throw new PromptValidationError('Missing required security_reminder section. ' +
54
+ 'Disable security validation with { validateSecurity: false } if intentional.');
55
+ }
56
+ }
57
+ // Token budgeting — trim shrinkable sections in reverse priority order
58
+ if (maxTokens && maxTokens > 0) {
59
+ active = applyTokenBudget(active, maxTokens);
60
+ }
61
+ // Render each section
62
+ const rendered = active.map((section) => {
63
+ if (useXmlTags) {
64
+ return `<${section.tag}>\n${section.content}\n</${section.tag}>`;
65
+ }
66
+ return section.content;
67
+ });
68
+ return rendered.join('\n\n');
69
+ }
70
+ // ============================================
71
+ // Internal
72
+ // ============================================
73
+ /**
74
+ * Applies token budgeting by trimming shrinkable sections.
75
+ *
76
+ * Strategy: iterate sections from lowest priority (highest priority number)
77
+ * to highest priority (lowest priority number). For each shrinkable section
78
+ * whose removal or truncation would bring the total under budget, truncate it.
79
+ */
80
+ function applyTokenBudget(sections, maxTokens) {
81
+ let totalTokens = sections.reduce((sum, s) => sum + s.estimatedTokens, 0);
82
+ if (totalTokens <= maxTokens)
83
+ return sections;
84
+ // Work on a mutable copy, iterate from lowest priority (end) to highest (start).
85
+ const result = [...sections];
86
+ // Build indices sorted by priority descending (lowest priority = highest number first)
87
+ const indices = result
88
+ .map((_, i) => i)
89
+ .sort((a, b) => result[b].priority - result[a].priority);
90
+ for (const idx of indices) {
91
+ if (totalTokens <= maxTokens)
92
+ break;
93
+ const section = result[idx];
94
+ if (!section.shrinkable)
95
+ continue;
96
+ const excess = totalTokens - maxTokens;
97
+ const newBudget = Math.max(0, section.estimatedTokens - excess);
98
+ if (newBudget <= 0) {
99
+ // Remove the section entirely
100
+ totalTokens -= section.estimatedTokens;
101
+ result[idx] = { ...section, content: '', estimatedTokens: 0 };
102
+ }
103
+ else {
104
+ // Truncate to remaining budget
105
+ const truncated = truncateToTokenBudget(section.content, newBudget);
106
+ const newTokens = estimateTokenCount(truncated);
107
+ totalTokens -= section.estimatedTokens - newTokens;
108
+ result[idx] = { ...section, content: truncated, estimatedTokens: newTokens };
109
+ }
110
+ }
111
+ // Filter out emptied sections
112
+ return result.filter((s) => s.content.trim().length > 0);
113
+ }
114
+ //# sourceMappingURL=PromptRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PromptRenderer.js","sourceRoot":"","sources":["../../src/prompts/PromptRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAmBxF,+CAA+C;AAC/C,QAAQ;AACR,+CAA+C;AAE/C;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED,+CAA+C;AAC/C,SAAS;AACT,+CAA+C;AAE/C;;;;;;;;;;;;;;GAcG;AACH,MAAM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,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,+BAA+B;YAC/B,MAAM,SAAS,GAAG,qBAAqB,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YACpE,MAAM,SAAS,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;YAChD,WAAW,IAAI,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;YACnD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC;QAC/E,CAAC;IACH,CAAC;IAED,8BAA8B;IAC9B,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { BrandVoiceConfig } from './types.js';
2
+ export interface BrandVoiceTemplate {
3
+ tone: string;
4
+ styleRules: string[];
5
+ avoidPhrases: string[];
6
+ emojiPolicy: 'never' | 'minimal' | 'moderate' | 'encouraged';
7
+ }
8
+ export declare const BRAND_VOICE_TEMPLATES: Record<Exclude<BrandVoiceConfig['tone'], 'custom' | undefined>, BrandVoiceTemplate>;
9
+ export declare function buildBrandVoiceSection(config: BrandVoiceConfig): string;
10
+ //# sourceMappingURL=brandVoice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brandVoice.d.ts","sourceRoot":"","sources":["../../src/prompts/brandVoice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,CAAC;CAC9D;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC,EAAE,kBAAkB,CAyCrH,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAoDvE"}
@@ -0,0 +1,87 @@
1
+ export const BRAND_VOICE_TEMPLATES = {
2
+ formal: {
3
+ tone: 'Professional and respectful. Use complete sentences and proper grammar.',
4
+ styleRules: [
5
+ 'Address customers formally (use "you" respectfully)',
6
+ 'Avoid contractions in serious contexts',
7
+ 'Be precise and factual',
8
+ ],
9
+ avoidPhrases: ['No problem', 'Cool', 'Awesome', 'Yeah', 'Hey'],
10
+ emojiPolicy: 'never',
11
+ },
12
+ casual: {
13
+ tone: 'Friendly and conversational. Natural, human-like communication.',
14
+ styleRules: [
15
+ 'Use contractions freely',
16
+ 'Keep it light and approachable',
17
+ 'Match customer energy level',
18
+ ],
19
+ avoidPhrases: ['Pursuant to', 'Please be advised', 'Kindly', 'At your earliest convenience'],
20
+ emojiPolicy: 'moderate',
21
+ },
22
+ friendly: {
23
+ tone: 'Warm and helpful. Balance professionalism with approachability.',
24
+ styleRules: [
25
+ 'Be personable but not overly casual',
26
+ 'Show empathy in responses',
27
+ 'Use natural conversational language',
28
+ ],
29
+ avoidPhrases: ['As per our policy', 'Unfortunately', 'We regret to inform'],
30
+ emojiPolicy: 'minimal',
31
+ },
32
+ professional: {
33
+ tone: 'Competent and reliable. Clear, efficient communication.',
34
+ styleRules: [
35
+ 'Be direct and solution-focused',
36
+ 'Avoid unnecessary flourishes',
37
+ 'Maintain professional boundaries',
38
+ ],
39
+ avoidPhrases: ['LOL', 'OMG', 'TBH', 'fr', 'omg'],
40
+ emojiPolicy: 'never',
41
+ },
42
+ };
43
+ export function buildBrandVoiceSection(config) {
44
+ const template = config.tone && config.tone !== 'custom' ? BRAND_VOICE_TEMPLATES[config.tone] : null;
45
+ const parts = [];
46
+ // Tone
47
+ const tone = config.toneCustom ?? template?.tone ?? config.tone ?? 'Professional and helpful';
48
+ parts.push(`**Tone:** ${tone}`);
49
+ // Personality
50
+ if (config.personality) {
51
+ parts.push(`**Personality:** ${config.personality}`);
52
+ }
53
+ // Style rules
54
+ const styleRules = config.styleRules ?? template?.styleRules ?? [];
55
+ if (styleRules.length > 0) {
56
+ parts.push(`**Style Guidelines:**\n${styleRules.map(r => `- ${r}`).join('\n')}`);
57
+ }
58
+ // Avoid phrases
59
+ const avoidPhrases = config.avoidPhrases ?? template?.avoidPhrases ?? [];
60
+ if (avoidPhrases.length > 0) {
61
+ parts.push(`**Avoid saying:** ${avoidPhrases.join(', ')}`);
62
+ }
63
+ // Preferred phrases
64
+ if (config.preferredPhrases?.length) {
65
+ parts.push(`**Preferred phrases:** ${config.preferredPhrases.join(', ')}`);
66
+ }
67
+ // Emoji policy
68
+ const emojiPolicy = config.emojiPolicy ?? template?.emojiPolicy ?? 'never';
69
+ const emojiGuidance = {
70
+ never: 'Do not use emojis.',
71
+ minimal: 'Use emojis sparingly, only when appropriate (e.g., simple smiley).',
72
+ moderate: 'Emojis are acceptable to convey tone and warmth.',
73
+ encouraged: 'Use emojis freely to enhance friendly communication.',
74
+ };
75
+ parts.push(`**Emoji usage:** ${emojiGuidance[emojiPolicy]}`);
76
+ // Response length
77
+ if (config.responseLength) {
78
+ const lengthGuidance = {
79
+ brief: 'Keep responses short and to the point. One to two sentences when possible.',
80
+ moderate: 'Balance brevity with completeness. Include necessary details but avoid verbosity.',
81
+ detailed: 'Provide thorough, comprehensive responses. Cover all relevant aspects.',
82
+ };
83
+ parts.push(`**Response length:** ${lengthGuidance[config.responseLength]}`);
84
+ }
85
+ return parts.join('\n\n');
86
+ }
87
+ //# sourceMappingURL=brandVoice.js.map
@@ -0,0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GAAuC;QACxD,KAAK,EAAE,oBAAoB;QAC3B,OAAO,EAAE,oEAAoE;QAC7E,QAAQ,EAAE,kDAAkD;QAC5D,UAAU,EAAE,sDAAsD;KACnE,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,oBAAoB,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAE7D,kBAAkB;IAClB,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;QAC1B,MAAM,cAAc,GAAiD;YACnE,KAAK,EAAE,4EAA4E;YACnF,QAAQ,EAAE,mFAAmF;YAC7F,QAAQ,EAAE,wEAAwE;SACnF,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,wBAAwB,cAAc,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC"}
@@ -1,7 +1,14 @@
1
- export type { PromptSection, PromptTemplate, ToolGuideline, PromptTemplateBuilderOptions } from './types.js';
2
- export { PromptTemplateBuilder, createPromptTemplate } from './types.js';
3
- export type { PromptSectionType, VoiceRulesConfig, VoiceRules, GlossaryTerm, GlossaryConfig } from './types.js';
4
- export { PromptBuilder } from './PromptBuilder.js';
1
+ export type { PromptSection, PromptTemplate, ToolGuideline, PromptTemplateBuilderOptions, PromptSectionType, VoiceRulesConfig, VoiceRules, GlossaryTerm, GlossaryConfig, BrandVoiceConfig, KnowledgeContext, SessionMemory, AgentDefinition, PolicyProfile, PromptBuilderConfig, } from './types.js';
2
+ export { PromptTemplateBuilder, createPromptTemplate, LAYER_PRIORITIES } from './types.js';
3
+ export { PromptBuilder, createPrompt } from './PromptBuilder.js';
5
4
  export { SUPPORT_AGENT_TEMPLATE, SALES_AGENT_TEMPLATE, TRIAGE_AGENT_TEMPLATE, createSupportAgentTemplate, BUILTIN_TEMPLATES, DEFAULT_HANDOFF_INSTRUCTION, } from './templates.js';
6
5
  export { getTemplate, registerTemplate, listTemplates, getAllTemplates } from './registry.js';
6
+ export { getSecurityCore, SECURITY_REMINDER } from './security.js';
7
+ export { buildBrandVoiceSection, BRAND_VOICE_TEMPLATES } from './brandVoice.js';
8
+ export { PromptAssembly, PromptSecurityViolationError } from './PromptAssembly.js';
9
+ export type { PromptSectionConfig, ResolvedSection, AssemblyDebugInfo } from './PromptAssembly.js';
10
+ export { renderSections, PromptValidationError } from './PromptRenderer.js';
11
+ export type { RenderOptions } from './PromptRenderer.js';
12
+ export { AgentPrompt } from './AgentPrompt.js';
13
+ export type { AgentPromptConfig } from './AgentPrompt.js';
7
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAC7G,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACzE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAChH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,EACjB,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,cAAc,EACd,aAAa,EACb,4BAA4B,EAC5B,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,aAA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