signalwire-agents 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/CLAUDE.md +112 -0
  2. package/README.md +417 -0
  3. package/dist/AgentBase.d.ts +481 -0
  4. package/dist/AgentBase.js +1155 -0
  5. package/dist/AgentBase.js.map +1 -0
  6. package/dist/AgentServer.d.ts +60 -0
  7. package/dist/AgentServer.js +128 -0
  8. package/dist/AgentServer.js.map +1 -0
  9. package/dist/AuthHandler.d.ts +56 -0
  10. package/dist/AuthHandler.js +119 -0
  11. package/dist/AuthHandler.js.map +1 -0
  12. package/dist/ConfigLoader.d.ts +68 -0
  13. package/dist/ConfigLoader.js +150 -0
  14. package/dist/ConfigLoader.js.map +1 -0
  15. package/dist/ContextBuilder.d.ts +431 -0
  16. package/dist/ContextBuilder.js +751 -0
  17. package/dist/ContextBuilder.js.map +1 -0
  18. package/dist/DataMap.d.ts +179 -0
  19. package/dist/DataMap.js +321 -0
  20. package/dist/DataMap.js.map +1 -0
  21. package/dist/Logger.d.ts +91 -0
  22. package/dist/Logger.js +191 -0
  23. package/dist/Logger.js.map +1 -0
  24. package/dist/PomBuilder.d.ts +144 -0
  25. package/dist/PomBuilder.js +249 -0
  26. package/dist/PomBuilder.js.map +1 -0
  27. package/dist/PromptManager.d.ts +85 -0
  28. package/dist/PromptManager.js +108 -0
  29. package/dist/PromptManager.js.map +1 -0
  30. package/dist/SchemaUtils.d.ts +42 -0
  31. package/dist/SchemaUtils.js +148 -0
  32. package/dist/SchemaUtils.js.map +1 -0
  33. package/dist/ServerlessAdapter.d.ts +100 -0
  34. package/dist/ServerlessAdapter.js +166 -0
  35. package/dist/ServerlessAdapter.js.map +1 -0
  36. package/dist/SessionManager.d.ts +86 -0
  37. package/dist/SessionManager.js +155 -0
  38. package/dist/SessionManager.js.map +1 -0
  39. package/dist/SslConfig.d.ts +77 -0
  40. package/dist/SslConfig.js +100 -0
  41. package/dist/SslConfig.js.map +1 -0
  42. package/dist/SwaigFunction.d.ts +88 -0
  43. package/dist/SwaigFunction.js +125 -0
  44. package/dist/SwaigFunction.js.map +1 -0
  45. package/dist/SwaigFunctionResult.d.ts +442 -0
  46. package/dist/SwaigFunctionResult.js +735 -0
  47. package/dist/SwaigFunctionResult.js.map +1 -0
  48. package/dist/SwmlBuilder.d.ts +37 -0
  49. package/dist/SwmlBuilder.js +55 -0
  50. package/dist/SwmlBuilder.js.map +1 -0
  51. package/dist/cli/agent-loader.d.ts +22 -0
  52. package/dist/cli/agent-loader.js +106 -0
  53. package/dist/cli/agent-loader.js.map +1 -0
  54. package/dist/cli/mock-data.d.ts +37 -0
  55. package/dist/cli/mock-data.js +79 -0
  56. package/dist/cli/mock-data.js.map +1 -0
  57. package/dist/cli/swaig-test.d.ts +32 -0
  58. package/dist/cli/swaig-test.js +405 -0
  59. package/dist/cli/swaig-test.js.map +1 -0
  60. package/dist/index.d.ts +36 -0
  61. package/dist/index.js +44 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/prefabs/ConciergeAgent.d.ts +64 -0
  64. package/dist/prefabs/ConciergeAgent.js +188 -0
  65. package/dist/prefabs/ConciergeAgent.js.map +1 -0
  66. package/dist/prefabs/FAQBotAgent.d.ts +68 -0
  67. package/dist/prefabs/FAQBotAgent.js +206 -0
  68. package/dist/prefabs/FAQBotAgent.js.map +1 -0
  69. package/dist/prefabs/InfoGathererAgent.d.ts +73 -0
  70. package/dist/prefabs/InfoGathererAgent.js +202 -0
  71. package/dist/prefabs/InfoGathererAgent.js.map +1 -0
  72. package/dist/prefabs/ReceptionistAgent.d.ts +65 -0
  73. package/dist/prefabs/ReceptionistAgent.js +205 -0
  74. package/dist/prefabs/ReceptionistAgent.js.map +1 -0
  75. package/dist/prefabs/SurveyAgent.d.ts +84 -0
  76. package/dist/prefabs/SurveyAgent.js +324 -0
  77. package/dist/prefabs/SurveyAgent.js.map +1 -0
  78. package/dist/prefabs/index.d.ts +13 -0
  79. package/dist/prefabs/index.js +14 -0
  80. package/dist/prefabs/index.js.map +1 -0
  81. package/dist/skills/SkillBase.d.ts +134 -0
  82. package/dist/skills/SkillBase.js +105 -0
  83. package/dist/skills/SkillBase.js.map +1 -0
  84. package/dist/skills/SkillManager.d.ts +83 -0
  85. package/dist/skills/SkillManager.js +159 -0
  86. package/dist/skills/SkillManager.js.map +1 -0
  87. package/dist/skills/SkillRegistry.d.ts +105 -0
  88. package/dist/skills/SkillRegistry.js +195 -0
  89. package/dist/skills/SkillRegistry.js.map +1 -0
  90. package/dist/skills/builtin/api_ninjas_trivia.d.ts +35 -0
  91. package/dist/skills/builtin/api_ninjas_trivia.js +161 -0
  92. package/dist/skills/builtin/api_ninjas_trivia.js.map +1 -0
  93. package/dist/skills/builtin/claude_skills.d.ts +34 -0
  94. package/dist/skills/builtin/claude_skills.js +156 -0
  95. package/dist/skills/builtin/claude_skills.js.map +1 -0
  96. package/dist/skills/builtin/custom_skills.d.ts +59 -0
  97. package/dist/skills/builtin/custom_skills.js +231 -0
  98. package/dist/skills/builtin/custom_skills.js.map +1 -0
  99. package/dist/skills/builtin/datasphere.d.ts +34 -0
  100. package/dist/skills/builtin/datasphere.js +163 -0
  101. package/dist/skills/builtin/datasphere.js.map +1 -0
  102. package/dist/skills/builtin/datasphere_serverless.d.ts +54 -0
  103. package/dist/skills/builtin/datasphere_serverless.js +155 -0
  104. package/dist/skills/builtin/datasphere_serverless.js.map +1 -0
  105. package/dist/skills/builtin/datetime.d.ts +31 -0
  106. package/dist/skills/builtin/datetime.js +95 -0
  107. package/dist/skills/builtin/datetime.js.map +1 -0
  108. package/dist/skills/builtin/google_maps.d.ts +33 -0
  109. package/dist/skills/builtin/google_maps.js +233 -0
  110. package/dist/skills/builtin/google_maps.js.map +1 -0
  111. package/dist/skills/builtin/index.d.ts +28 -0
  112. package/dist/skills/builtin/index.js +75 -0
  113. package/dist/skills/builtin/index.js.map +1 -0
  114. package/dist/skills/builtin/info_gatherer.d.ts +52 -0
  115. package/dist/skills/builtin/info_gatherer.js +237 -0
  116. package/dist/skills/builtin/info_gatherer.js.map +1 -0
  117. package/dist/skills/builtin/joke.d.ts +32 -0
  118. package/dist/skills/builtin/joke.js +142 -0
  119. package/dist/skills/builtin/joke.js.map +1 -0
  120. package/dist/skills/builtin/math.d.ts +33 -0
  121. package/dist/skills/builtin/math.js +120 -0
  122. package/dist/skills/builtin/math.js.map +1 -0
  123. package/dist/skills/builtin/mcp_gateway.d.ts +35 -0
  124. package/dist/skills/builtin/mcp_gateway.js +85 -0
  125. package/dist/skills/builtin/mcp_gateway.js.map +1 -0
  126. package/dist/skills/builtin/native_vector_search.d.ts +44 -0
  127. package/dist/skills/builtin/native_vector_search.js +248 -0
  128. package/dist/skills/builtin/native_vector_search.js.map +1 -0
  129. package/dist/skills/builtin/play_background_file.d.ts +34 -0
  130. package/dist/skills/builtin/play_background_file.js +135 -0
  131. package/dist/skills/builtin/play_background_file.js.map +1 -0
  132. package/dist/skills/builtin/spider.d.ts +34 -0
  133. package/dist/skills/builtin/spider.js +164 -0
  134. package/dist/skills/builtin/spider.js.map +1 -0
  135. package/dist/skills/builtin/swml_transfer.d.ts +44 -0
  136. package/dist/skills/builtin/swml_transfer.js +204 -0
  137. package/dist/skills/builtin/swml_transfer.js.map +1 -0
  138. package/dist/skills/builtin/weather_api.d.ts +34 -0
  139. package/dist/skills/builtin/weather_api.js +136 -0
  140. package/dist/skills/builtin/weather_api.js.map +1 -0
  141. package/dist/skills/builtin/web_search.d.ts +34 -0
  142. package/dist/skills/builtin/web_search.js +141 -0
  143. package/dist/skills/builtin/web_search.js.map +1 -0
  144. package/dist/skills/builtin/wikipedia_search.d.ts +34 -0
  145. package/dist/skills/builtin/wikipedia_search.js +166 -0
  146. package/dist/skills/builtin/wikipedia_search.js.map +1 -0
  147. package/dist/skills/index.d.ts +11 -0
  148. package/dist/skills/index.js +10 -0
  149. package/dist/skills/index.js.map +1 -0
  150. package/dist/types.d.ts +85 -0
  151. package/dist/types.js +5 -0
  152. package/dist/types.js.map +1 -0
  153. package/docs/agent-guide.md +869 -0
  154. package/docs/api-reference.md +2419 -0
  155. package/docs/architecture.md +843 -0
  156. package/docs/cli-guide.md +579 -0
  157. package/docs/configuration.md +422 -0
  158. package/docs/contexts-guide.md +787 -0
  159. package/docs/datamap-guide.md +1141 -0
  160. package/docs/prefabs-guide.md +830 -0
  161. package/docs/security.md +436 -0
  162. package/docs/serverless-guide.md +513 -0
  163. package/docs/skills-guide.md +845 -0
  164. package/docs/swaig-reference.md +1627 -0
  165. package/examples/call-flow.ts +60 -0
  166. package/examples/contexts-steps.ts +62 -0
  167. package/examples/datamap-tools.ts +52 -0
  168. package/examples/dynamic-config.ts +51 -0
  169. package/examples/multi-agent.ts +67 -0
  170. package/examples/pom-prompt.ts +68 -0
  171. package/examples/simple-agent.ts +33 -0
  172. package/package.json +35 -0
  173. package/src/AgentBase.ts +1279 -0
  174. package/src/AgentServer.ts +149 -0
  175. package/src/AuthHandler.ts +141 -0
  176. package/src/ConfigLoader.ts +165 -0
  177. package/src/ContextBuilder.ts +796 -0
  178. package/src/DataMap.ts +365 -0
  179. package/src/Logger.ts +197 -0
  180. package/src/PomBuilder.ts +298 -0
  181. package/src/PromptManager.ts +133 -0
  182. package/src/SchemaUtils.ts +170 -0
  183. package/src/ServerlessAdapter.ts +218 -0
  184. package/src/SessionManager.ts +161 -0
  185. package/src/SslConfig.ts +118 -0
  186. package/src/SwaigFunction.ts +168 -0
  187. package/src/SwaigFunctionResult.ts +864 -0
  188. package/src/SwmlBuilder.ts +62 -0
  189. package/src/cli/agent-loader.ts +122 -0
  190. package/src/cli/mock-data.ts +110 -0
  191. package/src/cli/swaig-test.ts +440 -0
  192. package/src/index.ts +99 -0
  193. package/src/prefabs/ConciergeAgent.ts +251 -0
  194. package/src/prefabs/FAQBotAgent.ts +263 -0
  195. package/src/prefabs/InfoGathererAgent.ts +276 -0
  196. package/src/prefabs/ReceptionistAgent.ts +277 -0
  197. package/src/prefabs/SurveyAgent.ts +413 -0
  198. package/src/prefabs/index.ts +23 -0
  199. package/src/skills/SkillBase.ts +184 -0
  200. package/src/skills/SkillManager.ts +177 -0
  201. package/src/skills/SkillRegistry.ts +231 -0
  202. package/src/skills/builtin/api_ninjas_trivia.ts +230 -0
  203. package/src/skills/builtin/claude_skills.ts +239 -0
  204. package/src/skills/builtin/custom_skills.ts +326 -0
  205. package/src/skills/builtin/datasphere.ts +225 -0
  206. package/src/skills/builtin/datasphere_serverless.ts +194 -0
  207. package/src/skills/builtin/datetime.ts +115 -0
  208. package/src/skills/builtin/google_maps.ts +347 -0
  209. package/src/skills/builtin/index.ts +79 -0
  210. package/src/skills/builtin/info_gatherer.ts +331 -0
  211. package/src/skills/builtin/joke.ts +180 -0
  212. package/src/skills/builtin/math.ts +150 -0
  213. package/src/skills/builtin/mcp_gateway.ts +99 -0
  214. package/src/skills/builtin/native_vector_search.ts +327 -0
  215. package/src/skills/builtin/play_background_file.ts +189 -0
  216. package/src/skills/builtin/spider.ts +232 -0
  217. package/src/skills/builtin/swml_transfer.ts +285 -0
  218. package/src/skills/builtin/weather_api.ts +193 -0
  219. package/src/skills/builtin/web_search.ts +212 -0
  220. package/src/skills/builtin/wikipedia_search.ts +248 -0
  221. package/src/skills/index.ts +12 -0
  222. package/src/types.ts +99 -0
  223. package/tests/AgentBase.test.ts +693 -0
  224. package/tests/AgentServer.test.ts +102 -0
  225. package/tests/AuthHandler.test.ts +121 -0
  226. package/tests/ConfigLoader.test.ts +121 -0
  227. package/tests/DataMap.test.ts +286 -0
  228. package/tests/Logger.test.ts +218 -0
  229. package/tests/PomBuilder.test.ts +164 -0
  230. package/tests/ProxyDetection.test.ts +185 -0
  231. package/tests/SchemaUtils.test.ts +106 -0
  232. package/tests/ServerlessAdapter.test.ts +200 -0
  233. package/tests/SessionManager.test.ts +139 -0
  234. package/tests/SslConfig.test.ts +97 -0
  235. package/tests/SwaigFunctionResult.test.ts +298 -0
  236. package/tests/cli/mock-data.test.ts +94 -0
  237. package/tests/cli/swaig-test.test.ts +96 -0
  238. package/tests/prefabs/prefabs.test.ts +854 -0
  239. package/tests/setup.ts +6 -0
  240. package/tests/skills/SkillBase.test.ts +118 -0
  241. package/tests/skills/SkillManager.test.ts +164 -0
  242. package/tests/skills/SkillRegistry.test.ts +124 -0
  243. package/tests/skills/builtin.test.ts +924 -0
  244. package/tsconfig.json +18 -0
  245. package/vitest.config.ts +9 -0
@@ -0,0 +1,481 @@
1
+ /**
2
+ * AgentBase - Core agent class with Hono HTTP server and 5-phase SWML rendering.
3
+ *
4
+ * Composes PromptManager, SessionManager, SwmlBuilder, and a tool registry
5
+ * into a single HTTP-servable agent.
6
+ */
7
+ import { Hono } from 'hono';
8
+ import { SwaigFunction, type SwaigHandler } from './SwaigFunction.js';
9
+ import { ContextBuilder } from './ContextBuilder.js';
10
+ import type { SkillBase } from './skills/SkillBase.js';
11
+ import type { AgentOptions, LanguageConfig, PronunciationRule, DynamicConfigCallback } from './types.js';
12
+ /**
13
+ * Core agent class that composes an HTTP server, prompt management, session handling,
14
+ * SWAIG tool registry, and 5-phase SWML rendering into a single deployable unit.
15
+ */
16
+ export declare class AgentBase {
17
+ /** Display name of this agent. */
18
+ name: string;
19
+ /** HTTP route path this agent listens on. */
20
+ route: string;
21
+ /** Hostname the HTTP server binds to. */
22
+ host: string;
23
+ /** Port number the HTTP server listens on. */
24
+ port: number;
25
+ /** Unique identifier for this agent instance. */
26
+ agentId: string;
27
+ private promptManager;
28
+ private sessionManager;
29
+ private swmlBuilder;
30
+ private toolRegistry;
31
+ private basicAuthCreds;
32
+ private basicAuthSource;
33
+ private autoAnswer;
34
+ private _recordCall;
35
+ private recordFormat;
36
+ private recordStereo;
37
+ private defaultWebhookUrl;
38
+ private nativeFunctions;
39
+ private hints;
40
+ private languages;
41
+ private pronounce;
42
+ private params;
43
+ private globalData;
44
+ private functionIncludes;
45
+ private promptLlmParams;
46
+ private postPromptLlmParams;
47
+ private internalFillers;
48
+ private preAnswerVerbs;
49
+ private answerConfig;
50
+ private postAnswerVerbs;
51
+ private postAiVerbs;
52
+ private dynamicConfigCallback;
53
+ private swaigQueryParams;
54
+ private webHookUrlOverride;
55
+ private postPromptUrlOverride;
56
+ private contextsBuilder;
57
+ private debugEventsEnabled;
58
+ private debugEventsLevel;
59
+ private _proxyUrlBase;
60
+ private _proxyUrlBaseFromEnv;
61
+ private _proxyDebug;
62
+ /** Structured logger instance for this agent, configurable via SIGNALWIRE_LOG_LEVEL. */
63
+ protected log: import("./Logger.js").Logger;
64
+ private skillManager;
65
+ private _app;
66
+ /**
67
+ * Create a new AgentBase instance.
68
+ * @param opts - Agent configuration options including name, route, auth, and call settings.
69
+ */
70
+ constructor(opts: AgentOptions);
71
+ /**
72
+ * Static prompt sections: subclasses can define these declaratively.
73
+ * Each entry is applied via promptAddSection() in the constructor.
74
+ */
75
+ static PROMPT_SECTIONS?: {
76
+ title: string;
77
+ body?: string;
78
+ bullets?: string[];
79
+ numbered?: boolean;
80
+ }[];
81
+ /**
82
+ * Lifecycle method to register tools. Subclasses should call this at the
83
+ * end of their own constructor (after all fields are initialized).
84
+ * Not called automatically — call `this.defineTools()` explicitly.
85
+ */
86
+ protected defineTools(): void;
87
+ /**
88
+ * Set the main system prompt text for the AI.
89
+ * @param text - The prompt text to use.
90
+ * @returns This agent instance for chaining.
91
+ */
92
+ setPromptText(text: string): this;
93
+ /**
94
+ * Set the post-prompt text evaluated after the call ends.
95
+ * @param text - The post-prompt text to use.
96
+ * @returns This agent instance for chaining.
97
+ */
98
+ setPostPrompt(text: string): this;
99
+ /**
100
+ * Add a new section to the prompt with optional body, bullets, and subsections.
101
+ * @param title - Section heading.
102
+ * @param opts - Optional section content including body text, bullet points, and subsections.
103
+ * @returns This agent instance for chaining.
104
+ */
105
+ promptAddSection(title: string, opts?: {
106
+ body?: string;
107
+ bullets?: string[];
108
+ numbered?: boolean;
109
+ numberedBullets?: boolean;
110
+ subsections?: {
111
+ title: string;
112
+ body?: string;
113
+ bullets?: string[];
114
+ }[];
115
+ }): this;
116
+ /**
117
+ * Append content to an existing prompt section.
118
+ * @param title - Title of the section to append to.
119
+ * @param opts - Content to add: body text, a single bullet, or multiple bullets.
120
+ * @returns This agent instance for chaining.
121
+ */
122
+ promptAddToSection(title: string, opts?: {
123
+ body?: string;
124
+ bullet?: string;
125
+ bullets?: string[];
126
+ }): this;
127
+ /**
128
+ * Add a subsection under an existing prompt section.
129
+ * @param parentTitle - Title of the parent section.
130
+ * @param title - Title of the new subsection.
131
+ * @param opts - Optional body text and bullet points for the subsection.
132
+ * @returns This agent instance for chaining.
133
+ */
134
+ promptAddSubsection(parentTitle: string, title: string, opts?: {
135
+ body?: string;
136
+ bullets?: string[];
137
+ }): this;
138
+ /**
139
+ * Check whether a prompt section with the given title exists.
140
+ * @param title - Section title to look for.
141
+ * @returns True if the section exists.
142
+ */
143
+ promptHasSection(title: string): boolean;
144
+ /**
145
+ * Get the fully rendered main prompt text.
146
+ * @returns The assembled prompt string.
147
+ */
148
+ getPrompt(): string;
149
+ /**
150
+ * Get the post-prompt text, if one has been set.
151
+ * @returns The post-prompt string, or null if not configured.
152
+ */
153
+ getPostPrompt(): string | null;
154
+ /**
155
+ * Define or replace the contexts configuration for the AI verb.
156
+ * @param contexts - An existing ContextBuilder instance or a plain object; a new ContextBuilder is created if omitted.
157
+ * @returns The active ContextBuilder for further configuration.
158
+ */
159
+ defineContexts(contexts?: ContextBuilder | Record<string, unknown>): ContextBuilder;
160
+ /**
161
+ * Add a single speech-recognition hint.
162
+ * @param hint - Word or phrase to boost in speech recognition.
163
+ * @returns This agent instance for chaining.
164
+ */
165
+ addHint(hint: string): this;
166
+ /**
167
+ * Add multiple speech-recognition hints at once.
168
+ * @param hints - Array of words or phrases to boost.
169
+ * @returns This agent instance for chaining.
170
+ */
171
+ addHints(hints: string[]): this;
172
+ /**
173
+ * Add a pattern-based speech-recognition hint with find-and-replace behavior.
174
+ * @param opts - Pattern hint configuration with regex pattern, replacement, and optional case flag.
175
+ * @returns This agent instance for chaining.
176
+ */
177
+ addPatternHint(opts: {
178
+ pattern: string;
179
+ replace: string;
180
+ ignoreCase?: boolean;
181
+ }): this;
182
+ /**
183
+ * Add a supported language to the AI configuration.
184
+ * @param config - Language configuration including name, code, voice, and optional fillers.
185
+ * @returns This agent instance for chaining.
186
+ */
187
+ addLanguage(config: LanguageConfig): this;
188
+ /**
189
+ * Replace all configured languages with a new list.
190
+ * @param languages - Array of language configurations.
191
+ * @returns This agent instance for chaining.
192
+ */
193
+ setLanguages(languages: LanguageConfig[]): this;
194
+ /**
195
+ * Add a pronunciation override rule for the TTS engine.
196
+ * @param rule - Pronunciation rule specifying the text to replace and its substitute.
197
+ * @returns This agent instance for chaining.
198
+ */
199
+ addPronunciation(rule: PronunciationRule): this;
200
+ /**
201
+ * Set a single AI parameter (e.g. "temperature", "top_p").
202
+ * @param key - Parameter name.
203
+ * @param value - Parameter value.
204
+ * @returns This agent instance for chaining.
205
+ */
206
+ setParam(key: string, value: unknown): this;
207
+ /**
208
+ * Merge multiple AI parameters into the existing params object.
209
+ * @param params - Key-value pairs to merge.
210
+ * @returns This agent instance for chaining.
211
+ */
212
+ setParams(params: Record<string, unknown>): this;
213
+ /**
214
+ * Replace the entire global_data object passed into the AI configuration.
215
+ * @param data - New global data object.
216
+ * @returns This agent instance for chaining.
217
+ */
218
+ setGlobalData(data: Record<string, unknown>): this;
219
+ /**
220
+ * Merge additional entries into the existing global_data object.
221
+ * @param data - Key-value pairs to merge into global data.
222
+ * @returns This agent instance for chaining.
223
+ */
224
+ updateGlobalData(data: Record<string, unknown>): this;
225
+ /**
226
+ * Set the list of native SWAIG function names (built-in platform functions).
227
+ * @param funcs - Array of native function names.
228
+ * @returns This agent instance for chaining.
229
+ */
230
+ setNativeFunctions(funcs: string[]): this;
231
+ /**
232
+ * Add internal filler phrases spoken while a specific function is executing.
233
+ * @param functionName - Name of the SWAIG function these fillers apply to.
234
+ * @param languageCode - BCP-47 language code for the fillers.
235
+ * @param fillers - Array of filler phrases.
236
+ * @returns This agent instance for chaining.
237
+ */
238
+ addInternalFiller(functionName: string, languageCode: string, fillers: string[]): this;
239
+ /**
240
+ * Add a remote SWAIG function include reference.
241
+ * @param url - URL of the remote SWAIG endpoint.
242
+ * @param functions - Function names available at that endpoint.
243
+ * @param metaData - Optional metadata to attach to the include.
244
+ * @returns This agent instance for chaining.
245
+ */
246
+ addFunctionInclude(url: string, functions: string[], metaData?: Record<string, unknown>): this;
247
+ /**
248
+ * Merge LLM-specific parameters into the main prompt configuration (e.g. model, temperature).
249
+ * @param params - Key-value LLM parameters to merge.
250
+ * @returns This agent instance for chaining.
251
+ */
252
+ setPromptLlmParams(params: Record<string, unknown>): this;
253
+ /**
254
+ * Merge LLM-specific parameters into the post-prompt configuration.
255
+ * @param params - Key-value LLM parameters to merge.
256
+ * @returns This agent instance for chaining.
257
+ */
258
+ setPostPromptLlmParams(params: Record<string, unknown>): this;
259
+ /**
260
+ * Enable debug event webhooks for this agent.
261
+ * @param level - Debug verbosity level (defaults to 1).
262
+ * @returns This agent instance for chaining.
263
+ */
264
+ enableDebugEvents(level?: number): this;
265
+ /**
266
+ * Register a SWAIG tool (function) that the AI can invoke during a call.
267
+ * @param opts - Tool definition including name, description, parameter schema, and handler callback.
268
+ * @returns This agent instance for chaining.
269
+ */
270
+ defineTool(opts: {
271
+ name: string;
272
+ description: string;
273
+ parameters?: Record<string, unknown>;
274
+ handler: SwaigHandler;
275
+ secure?: boolean;
276
+ fillers?: Record<string, string[]>;
277
+ waitFile?: string;
278
+ waitFileLoops?: number;
279
+ required?: string[];
280
+ }): this;
281
+ /**
282
+ * Get a summary of all registered tools with their names, descriptions, and parameter schemas.
283
+ * @returns Array of tool descriptors.
284
+ */
285
+ getRegisteredTools(): {
286
+ name: string;
287
+ description: string;
288
+ parameters: Record<string, unknown>;
289
+ }[];
290
+ /**
291
+ * Look up a registered SwaigFunction by name.
292
+ * @param name - The tool name to search for.
293
+ * @returns The SwaigFunction instance, or undefined if not found or not a SwaigFunction.
294
+ */
295
+ getTool(name: string): SwaigFunction | undefined;
296
+ /**
297
+ * Register a pre-built SwaigFunction instance or a raw function descriptor (e.g. DataMap).
298
+ * @param fn - A SwaigFunction instance or a plain object with a "function" key.
299
+ * @returns This agent instance for chaining.
300
+ */
301
+ registerSwaigFunction(fn: SwaigFunction | Record<string, unknown>): this;
302
+ /**
303
+ * Add a SWML verb to execute before the answer phase (phase 1).
304
+ * @param verbName - Name of the SWML verb (e.g. "play", "record").
305
+ * @param config - Verb configuration object.
306
+ * @returns This agent instance for chaining.
307
+ */
308
+ addPreAnswerVerb(verbName: string, config: Record<string, unknown>): this;
309
+ /**
310
+ * Configure the answer verb (phase 2) with optional settings.
311
+ * @param config - Optional answer verb configuration.
312
+ * @returns This agent instance for chaining.
313
+ */
314
+ addAnswerVerb(config?: Record<string, unknown>): this;
315
+ /**
316
+ * Add a SWML verb to execute after the answer phase but before the AI verb (phase 3).
317
+ * @param verbName - Name of the SWML verb.
318
+ * @param config - Verb configuration object.
319
+ * @returns This agent instance for chaining.
320
+ */
321
+ addPostAnswerVerb(verbName: string, config: Record<string, unknown>): this;
322
+ /**
323
+ * Add a SWML verb to execute after the AI verb (phase 5).
324
+ * @param verbName - Name of the SWML verb.
325
+ * @param config - Verb configuration object.
326
+ * @returns This agent instance for chaining.
327
+ */
328
+ addPostAiVerb(verbName: string, config: Record<string, unknown>): this;
329
+ /**
330
+ * Remove all pre-answer verbs.
331
+ * @returns This agent instance for chaining.
332
+ */
333
+ clearPreAnswerVerbs(): this;
334
+ /**
335
+ * Remove all post-answer verbs.
336
+ * @returns This agent instance for chaining.
337
+ */
338
+ clearPostAnswerVerbs(): this;
339
+ /**
340
+ * Remove all post-AI verbs.
341
+ * @returns This agent instance for chaining.
342
+ */
343
+ clearPostAiVerbs(): this;
344
+ /**
345
+ * Get the agent's display name.
346
+ * @returns The agent name string.
347
+ */
348
+ getName(): string;
349
+ /**
350
+ * Add a skill to this agent, registering its tools, prompt sections, hints, and global data.
351
+ * @param skill - The skill instance to add.
352
+ * @returns This agent instance for chaining.
353
+ */
354
+ addSkill(skill: SkillBase): Promise<this>;
355
+ /**
356
+ * Remove a previously added skill by its instance ID.
357
+ * @param instanceId - The unique instance ID of the skill to remove.
358
+ * @returns True if the skill was found and removed.
359
+ */
360
+ removeSkill(instanceId: string): Promise<boolean>;
361
+ /**
362
+ * List all registered skills with their names, instance IDs, and initialization status.
363
+ * @returns Array of skill descriptors.
364
+ */
365
+ listSkills(): {
366
+ name: string;
367
+ instanceId: string;
368
+ initialized: boolean;
369
+ }[];
370
+ /**
371
+ * Check whether a skill with the given name is registered.
372
+ * @param skillName - The skill name to check.
373
+ * @returns True if a skill with that name exists.
374
+ */
375
+ hasSkill(skillName: string): boolean;
376
+ /**
377
+ * Set a callback invoked on each SWML request to dynamically modify an ephemeral agent copy.
378
+ * @param cb - The dynamic configuration callback.
379
+ * @returns This agent instance for chaining.
380
+ */
381
+ setDynamicConfigCallback(cb: DynamicConfigCallback): this;
382
+ /**
383
+ * Add extra query parameters appended to all SWAIG webhook URLs.
384
+ * @param params - Key-value pairs to append as query parameters.
385
+ * @returns This agent instance for chaining.
386
+ */
387
+ addSwaigQueryParams(params: Record<string, string>): this;
388
+ /**
389
+ * Manually set the proxy base URL used for webhook URL generation.
390
+ * @param url - The external-facing base URL (trailing slashes are stripped).
391
+ * @returns This agent instance for chaining.
392
+ */
393
+ manualSetProxyUrl(url: string): this;
394
+ private detectProxyFromRequest;
395
+ /**
396
+ * Override the default SWAIG webhook URL with a custom one.
397
+ * @param url - The custom webhook URL.
398
+ * @returns This agent instance for chaining.
399
+ */
400
+ setWebHookUrl(url: string): this;
401
+ /**
402
+ * Override the default post-prompt webhook URL with a custom one.
403
+ * @param url - The custom post-prompt URL.
404
+ * @returns This agent instance for chaining.
405
+ */
406
+ setPostPromptUrl(url: string): this;
407
+ /**
408
+ * Get the full external URL of this agent, using the proxy base URL if available.
409
+ * @param includeAuth - Whether to embed basic-auth credentials in the URL (defaults to false).
410
+ * @returns The fully-qualified URL string.
411
+ */
412
+ getFullUrl(includeAuth?: boolean): string;
413
+ private insertAuth;
414
+ private buildWebhookUrl;
415
+ /**
416
+ * Lifecycle hook called when a post-prompt summary is received. Override in subclasses.
417
+ * @param _summary - Parsed summary object, or null if extraction failed.
418
+ * @param _rawData - The full raw post-prompt payload.
419
+ */
420
+ onSummary(_summary: Record<string, unknown> | null, _rawData: Record<string, unknown>): void | Promise<void>;
421
+ /**
422
+ * Lifecycle hook called on every SWML request before rendering. Override in subclasses.
423
+ * @param _rawData - The parsed request body.
424
+ */
425
+ onSwmlRequest(_rawData: Record<string, unknown>): void | Promise<void>;
426
+ /**
427
+ * Lifecycle hook called when a debug event webhook is received. Override in subclasses.
428
+ * @param _event - The debug event payload.
429
+ */
430
+ onDebugEvent(_event: Record<string, unknown>): void | Promise<void>;
431
+ /**
432
+ * Override to add custom basic-auth validation logic beyond credential matching.
433
+ * @param _username - The username from the request.
434
+ * @param _password - The password from the request.
435
+ * @returns True if the credentials are valid; false to reject the request.
436
+ */
437
+ validateBasicAuth(_username: string, _password: string): boolean | Promise<boolean>;
438
+ /**
439
+ * Pre-execution hook called before each SWAIG function. Override in subclasses.
440
+ * @param _name - Name of the function about to execute.
441
+ * @param _args - Parsed arguments for the function.
442
+ * @param _rawData - The full raw SWAIG request payload.
443
+ */
444
+ onFunctionCall(_name: string, _args: Record<string, unknown>, _rawData: Record<string, unknown>): void | Promise<void>;
445
+ /**
446
+ * Render the complete SWML document by assembling all 5 phases: pre-answer, answer,
447
+ * post-answer, AI, and post-AI verbs.
448
+ * @param callId - Optional call ID to use for session tokens; auto-generated if omitted.
449
+ * @returns The rendered SWML document as a JSON string.
450
+ */
451
+ renderSwml(callId?: string): string;
452
+ private createEphemeralCopy;
453
+ /**
454
+ * Get or lazily create the Hono HTTP application with all routes, middleware, auth, and CORS.
455
+ * @returns The configured Hono application instance.
456
+ */
457
+ getApp(): Hono;
458
+ /**
459
+ * Return this agent's Hono app for mounting as a sub-router in an AgentServer.
460
+ * @returns The Hono application instance.
461
+ */
462
+ asRouter(): Hono;
463
+ /**
464
+ * Start the HTTP server and begin listening for requests.
465
+ * @returns A promise that resolves once the server is running.
466
+ */
467
+ serve(): Promise<void>;
468
+ /**
469
+ * Alias for {@link serve}. Starts the HTTP server.
470
+ * @returns A promise that resolves once the server is running.
471
+ */
472
+ run(): Promise<void>;
473
+ private findSummary;
474
+ /**
475
+ * Get the basic-auth credentials used by this agent.
476
+ * @param includeSource - When true, a third element indicating the credential source is appended.
477
+ * @returns A tuple of [username, password] or [username, password, source].
478
+ */
479
+ getBasicAuthCredentials(includeSource?: false): [string, string];
480
+ getBasicAuthCredentials(includeSource: true): [string, string, 'provided' | 'environment' | 'generated'];
481
+ }