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
package/dist/Logger.js ADDED
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Logger - Structured logger with env-var-based configuration.
3
+ *
4
+ * SIGNALWIRE_LOG_LEVEL: debug | info | warn | error (default: info)
5
+ * SIGNALWIRE_LOG_MODE: off to suppress all logging
6
+ * SIGNALWIRE_LOG_FORMAT: text | json (default: text)
7
+ * SIGNALWIRE_LOG_COLOR: true | false (default: true when TTY)
8
+ */
9
+ const LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
10
+ let globalLevel = process.env['SIGNALWIRE_LOG_LEVEL'] ?? 'info';
11
+ let globalSuppressed = process.env['SIGNALWIRE_LOG_MODE'] === 'off';
12
+ let globalFormat = process.env['SIGNALWIRE_LOG_FORMAT'] ?? 'text';
13
+ let globalColor = process.env['SIGNALWIRE_LOG_COLOR'] !== undefined
14
+ ? process.env['SIGNALWIRE_LOG_COLOR'] === 'true'
15
+ : (process.stdout?.isTTY ?? false);
16
+ // ANSI color codes
17
+ const COLORS = {
18
+ debug: '\x1b[36m', // cyan
19
+ info: '\x1b[32m', // green
20
+ warn: '\x1b[33m', // yellow
21
+ error: '\x1b[31m', // red
22
+ };
23
+ const RESET = '\x1b[0m';
24
+ const DIM = '\x1b[2m';
25
+ /**
26
+ * Set the minimum log level for all loggers.
27
+ * @param level - The minimum severity level to emit.
28
+ */
29
+ export function setGlobalLogLevel(level) {
30
+ globalLevel = level;
31
+ }
32
+ /**
33
+ * Suppress or unsuppress all log output globally.
34
+ * @param suppress - True to suppress, false to restore (default true).
35
+ */
36
+ export function suppressAllLogs(suppress = true) {
37
+ globalSuppressed = suppress;
38
+ }
39
+ /**
40
+ * Set the output format for all loggers.
41
+ * @param format - Either 'text' (human-readable) or 'json' (structured).
42
+ */
43
+ export function setGlobalLogFormat(format) {
44
+ globalFormat = format;
45
+ }
46
+ /**
47
+ * Enable or disable ANSI color codes in text-format output.
48
+ * @param enabled - True to enable colors, false to disable.
49
+ */
50
+ export function setGlobalLogColor(enabled) {
51
+ globalColor = enabled;
52
+ }
53
+ /** Reset all logging settings to their environment-variable-based defaults. */
54
+ export function resetLoggingConfiguration() {
55
+ globalLevel = process.env['SIGNALWIRE_LOG_LEVEL'] ?? 'info';
56
+ globalSuppressed = process.env['SIGNALWIRE_LOG_MODE'] === 'off';
57
+ globalFormat = process.env['SIGNALWIRE_LOG_FORMAT'] ?? 'text';
58
+ globalColor = process.env['SIGNALWIRE_LOG_COLOR'] !== undefined
59
+ ? process.env['SIGNALWIRE_LOG_COLOR'] === 'true'
60
+ : (process.stdout?.isTTY ?? false);
61
+ }
62
+ /** Structured logger that respects global level, format, and color settings. */
63
+ export class Logger {
64
+ name;
65
+ context;
66
+ /**
67
+ * Create a new Logger instance.
68
+ * @param name - Logger name shown in log output.
69
+ * @param context - Optional key-value pairs included in every log entry.
70
+ */
71
+ constructor(name, context) {
72
+ this.name = name;
73
+ this.context = context ?? {};
74
+ }
75
+ /**
76
+ * Create a child logger with additional bound context fields merged into the parent's context.
77
+ * @param context - Key-value pairs to merge into the child logger's context.
78
+ * @returns A new Logger instance with the merged context.
79
+ */
80
+ bind(context) {
81
+ return new Logger(this.name, { ...this.context, ...context });
82
+ }
83
+ /**
84
+ * Log a message at the debug level.
85
+ * @param msg - The log message.
86
+ * @param data - Optional structured data to include.
87
+ */
88
+ debug(msg, data) {
89
+ this.log('debug', msg, data);
90
+ }
91
+ /**
92
+ * Log a message at the info level.
93
+ * @param msg - The log message.
94
+ * @param data - Optional structured data to include.
95
+ */
96
+ info(msg, data) {
97
+ this.log('info', msg, data);
98
+ }
99
+ /**
100
+ * Log a message at the warn level.
101
+ * @param msg - The log message.
102
+ * @param data - Optional structured data to include.
103
+ */
104
+ warn(msg, data) {
105
+ this.log('warn', msg, data);
106
+ }
107
+ /**
108
+ * Log a message at the error level.
109
+ * @param msg - The log message.
110
+ * @param data - Optional structured data to include.
111
+ */
112
+ error(msg, data) {
113
+ this.log('error', msg, data);
114
+ }
115
+ log(level, msg, data) {
116
+ if (globalSuppressed)
117
+ return;
118
+ if (LEVELS[level] < LEVELS[globalLevel])
119
+ return;
120
+ const merged = (data && Object.keys(data).length) || Object.keys(this.context).length
121
+ ? { ...this.context, ...data }
122
+ : undefined;
123
+ if (globalFormat === 'json') {
124
+ this.logJson(level, msg, merged);
125
+ }
126
+ else {
127
+ this.logText(level, msg, merged);
128
+ }
129
+ }
130
+ logText(level, msg, data) {
131
+ const levelStr = level.toUpperCase();
132
+ let prefix;
133
+ if (globalColor) {
134
+ prefix = `${COLORS[level]}[${levelStr}]${RESET} ${DIM}[${this.name}]${RESET}`;
135
+ }
136
+ else {
137
+ prefix = `[${levelStr}] [${this.name}]`;
138
+ }
139
+ const suffix = data && Object.keys(data).length ? ' ' + JSON.stringify(data) : '';
140
+ const line = `${prefix} ${msg}${suffix}`;
141
+ switch (level) {
142
+ case 'debug':
143
+ console.debug(line);
144
+ break;
145
+ case 'info':
146
+ console.info(line);
147
+ break;
148
+ case 'warn':
149
+ console.warn(line);
150
+ break;
151
+ case 'error':
152
+ console.error(line);
153
+ break;
154
+ }
155
+ }
156
+ logJson(level, msg, data) {
157
+ const entry = {
158
+ timestamp: new Date().toISOString(),
159
+ level,
160
+ logger: this.name,
161
+ message: msg,
162
+ };
163
+ if (data && Object.keys(data).length) {
164
+ Object.assign(entry, data);
165
+ }
166
+ const line = JSON.stringify(entry);
167
+ switch (level) {
168
+ case 'debug':
169
+ console.debug(line);
170
+ break;
171
+ case 'info':
172
+ console.info(line);
173
+ break;
174
+ case 'warn':
175
+ console.warn(line);
176
+ break;
177
+ case 'error':
178
+ console.error(line);
179
+ break;
180
+ }
181
+ }
182
+ }
183
+ /**
184
+ * Create a new Logger instance with the given name.
185
+ * @param name - Logger name shown in log output.
186
+ * @returns A new Logger instance.
187
+ */
188
+ export function getLogger(name) {
189
+ return new Logger(name);
190
+ }
191
+ //# sourceMappingURL=Logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Logger.js","sourceRoot":"","sources":["../src/Logger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAW,CAAC;AAMjE,IAAI,WAAW,GAAc,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAc,IAAI,MAAM,CAAC;AACxF,IAAI,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,KAAK,KAAK,CAAC;AACpE,IAAI,YAAY,GAAe,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAe,IAAI,MAAM,CAAC;AAC5F,IAAI,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,KAAK,SAAS;IACjE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,KAAK,MAAM;IAChD,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,IAAI,KAAK,CAAC,CAAC;AAErC,mBAAmB;AACnB,MAAM,MAAM,GAA6B;IACvC,KAAK,EAAE,UAAU,EAAG,OAAO;IAC3B,IAAI,EAAE,UAAU,EAAI,QAAQ;IAC5B,IAAI,EAAE,UAAU,EAAI,SAAS;IAC7B,KAAK,EAAE,UAAU,EAAG,MAAM;CAC3B,CAAC;AACF,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,GAAG,GAAG,SAAS,CAAC;AAEtB;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAe;IAC/C,WAAW,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MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;YACrC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAEnC,QAAQ,KAAK,EAAE,CAAC;YACd,KAAK,OAAO;gBAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAAC,MAAM;YACzC,KAAK,MAAM;gBAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAAC,MAAM;YACvC,KAAK,MAAM;gBAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAAC,MAAM;YACvC,KAAK,OAAO;gBAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAAC,MAAM;QAC3C,CAAC;IACH,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * PomBuilder - Prompt Object Model for structured prompt sections.
3
+ *
4
+ * Built-in replacement for the external signalwire-pom package.
5
+ * Sections have a title, body, bullets (optionally numbered),
6
+ * and nested subsections.
7
+ */
8
+ /** Serializable representation of a POM section, used for JSON export. */
9
+ export interface PomSectionData {
10
+ /** Section heading text. */
11
+ title?: string;
12
+ /** Section body paragraph text. */
13
+ body?: string;
14
+ /** List of bullet point strings. */
15
+ bullets?: string[];
16
+ /** Whether subsections are numbered. */
17
+ numbered?: boolean;
18
+ /** Whether bullet points are rendered as a numbered list. */
19
+ numberedBullets?: boolean;
20
+ /** Nested child sections. */
21
+ subsections?: PomSectionData[];
22
+ }
23
+ /** A single section in a Prompt Object Model, with optional title, body, bullets, and nested subsections. */
24
+ export declare class PomSection {
25
+ /** Section heading text, or null if untitled. */
26
+ title: string | null;
27
+ /** Section body paragraph text. */
28
+ body: string;
29
+ /** List of bullet point strings. */
30
+ bullets: string[];
31
+ /** Nested child sections. */
32
+ subsections: PomSection[];
33
+ /** Whether this section is numbered when rendered; null means inherit from parent context. */
34
+ numbered: boolean | null;
35
+ /** Whether bullet points are rendered as a numbered list. */
36
+ numberedBullets: boolean;
37
+ /**
38
+ * Creates a new PomSection.
39
+ * @param opts - Optional section configuration.
40
+ */
41
+ constructor(opts?: {
42
+ title?: string | null;
43
+ body?: string;
44
+ bullets?: string[];
45
+ numbered?: boolean | null;
46
+ numberedBullets?: boolean;
47
+ });
48
+ /**
49
+ * Adds a nested subsection to this section.
50
+ * @param opts - Subsection configuration including title and optional body/bullets.
51
+ * @returns The newly created child PomSection.
52
+ */
53
+ addSubsection(opts: {
54
+ title: string;
55
+ body?: string;
56
+ bullets?: string[];
57
+ numbered?: boolean;
58
+ numberedBullets?: boolean;
59
+ }): PomSection;
60
+ /**
61
+ * Serializes this section to a plain data object.
62
+ * @returns A PomSectionData representation of this section and its subsections.
63
+ */
64
+ toDict(): PomSectionData;
65
+ /**
66
+ * Renders this section and its subsections as a Markdown string.
67
+ * @param level - The heading level to start at (default 2 for ##).
68
+ * @param sectionNumber - Hierarchical numbering prefix for numbered sections.
69
+ * @returns The rendered Markdown string.
70
+ */
71
+ renderMarkdown(level?: number, sectionNumber?: number[]): string;
72
+ }
73
+ /** Builds a structured prompt by composing named POM sections, with Markdown and dict export. */
74
+ export declare class PomBuilder {
75
+ private sections;
76
+ private sectionMap;
77
+ /**
78
+ * Adds a new top-level section to the prompt.
79
+ * @param title - The section heading.
80
+ * @param opts - Optional body, bullets, numbering, and subsection configuration.
81
+ * @returns This builder for chaining.
82
+ */
83
+ addSection(title: string, opts?: {
84
+ body?: string;
85
+ bullets?: string[];
86
+ numbered?: boolean;
87
+ numberedBullets?: boolean;
88
+ subsections?: {
89
+ title: string;
90
+ body?: string;
91
+ bullets?: string[];
92
+ }[];
93
+ }): this;
94
+ /**
95
+ * Appends body text or bullets to an existing section, creating it if absent.
96
+ * @param title - The section heading to append to.
97
+ * @param opts - Body text and/or bullets to add.
98
+ * @returns This builder for chaining.
99
+ */
100
+ addToSection(title: string, opts?: {
101
+ body?: string;
102
+ bullet?: string;
103
+ bullets?: string[];
104
+ }): this;
105
+ /**
106
+ * Adds a subsection under an existing parent section, creating the parent if absent.
107
+ * @param parentTitle - The heading of the parent section.
108
+ * @param title - The subsection heading.
109
+ * @param opts - Optional body text and bullets for the subsection.
110
+ * @returns This builder for chaining.
111
+ */
112
+ addSubsection(parentTitle: string, title: string, opts?: {
113
+ body?: string;
114
+ bullets?: string[];
115
+ }): this;
116
+ /**
117
+ * Checks whether a top-level section with the given title exists.
118
+ * @param title - The section heading to look for.
119
+ * @returns True if the section exists.
120
+ */
121
+ hasSection(title: string): boolean;
122
+ /**
123
+ * Returns a top-level section by title.
124
+ * @param title - The section heading to retrieve.
125
+ * @returns The matching PomSection, or undefined if not found.
126
+ */
127
+ getSection(title: string): PomSection | undefined;
128
+ /**
129
+ * Recursively searches all sections and subsections for one matching the given title.
130
+ * @param title - The section heading to search for.
131
+ * @returns The matching PomSection, or undefined if not found.
132
+ */
133
+ findSection(title: string): PomSection | undefined;
134
+ /**
135
+ * Serializes all sections to an array of plain data objects.
136
+ * @returns An array of PomSectionData representing all top-level sections.
137
+ */
138
+ toDict(): PomSectionData[];
139
+ /**
140
+ * Renders all sections as a combined Markdown string.
141
+ * @returns The complete rendered Markdown prompt text.
142
+ */
143
+ renderMarkdown(): string;
144
+ }
@@ -0,0 +1,249 @@
1
+ /**
2
+ * PomBuilder - Prompt Object Model for structured prompt sections.
3
+ *
4
+ * Built-in replacement for the external signalwire-pom package.
5
+ * Sections have a title, body, bullets (optionally numbered),
6
+ * and nested subsections.
7
+ */
8
+ /** A single section in a Prompt Object Model, with optional title, body, bullets, and nested subsections. */
9
+ export class PomSection {
10
+ /** Section heading text, or null if untitled. */
11
+ title;
12
+ /** Section body paragraph text. */
13
+ body;
14
+ /** List of bullet point strings. */
15
+ bullets;
16
+ /** Nested child sections. */
17
+ subsections;
18
+ /** Whether this section is numbered when rendered; null means inherit from parent context. */
19
+ numbered;
20
+ /** Whether bullet points are rendered as a numbered list. */
21
+ numberedBullets;
22
+ /**
23
+ * Creates a new PomSection.
24
+ * @param opts - Optional section configuration.
25
+ */
26
+ constructor(opts) {
27
+ this.title = opts?.title ?? null;
28
+ this.body = opts?.body ?? '';
29
+ this.bullets = opts?.bullets ?? [];
30
+ this.subsections = [];
31
+ this.numbered = opts?.numbered ?? null;
32
+ this.numberedBullets = opts?.numberedBullets ?? false;
33
+ }
34
+ /**
35
+ * Adds a nested subsection to this section.
36
+ * @param opts - Subsection configuration including title and optional body/bullets.
37
+ * @returns The newly created child PomSection.
38
+ */
39
+ addSubsection(opts) {
40
+ const sub = new PomSection({
41
+ title: opts.title,
42
+ body: opts.body,
43
+ bullets: opts.bullets,
44
+ numbered: opts.numbered ?? false,
45
+ numberedBullets: opts.numberedBullets ?? false,
46
+ });
47
+ this.subsections.push(sub);
48
+ return sub;
49
+ }
50
+ /**
51
+ * Serializes this section to a plain data object.
52
+ * @returns A PomSectionData representation of this section and its subsections.
53
+ */
54
+ toDict() {
55
+ const data = {};
56
+ if (this.body)
57
+ data.body = this.body;
58
+ if (this.bullets.length)
59
+ data.bullets = this.bullets;
60
+ if (this.subsections.length)
61
+ data.subsections = this.subsections.map((s) => s.toDict());
62
+ if (this.title !== null)
63
+ data.title = this.title;
64
+ if (this.numbered)
65
+ data.numbered = this.numbered;
66
+ if (this.numberedBullets)
67
+ data.numberedBullets = this.numberedBullets;
68
+ return data;
69
+ }
70
+ /**
71
+ * Renders this section and its subsections as a Markdown string.
72
+ * @param level - The heading level to start at (default 2 for ##).
73
+ * @param sectionNumber - Hierarchical numbering prefix for numbered sections.
74
+ * @returns The rendered Markdown string.
75
+ */
76
+ renderMarkdown(level = 2, sectionNumber = []) {
77
+ const lines = [];
78
+ if (this.title !== null) {
79
+ const prefix = sectionNumber.length ? `${sectionNumber.join('.')}. ` : '';
80
+ lines.push(`${'#'.repeat(level)} ${prefix}${this.title}\n`);
81
+ }
82
+ if (this.body) {
83
+ lines.push(`${this.body}\n`);
84
+ }
85
+ for (let i = 0; i < this.bullets.length; i++) {
86
+ if (this.numberedBullets) {
87
+ lines.push(`${i + 1}. ${this.bullets[i]}`);
88
+ }
89
+ else {
90
+ lines.push(`- ${this.bullets[i]}`);
91
+ }
92
+ }
93
+ if (this.bullets.length)
94
+ lines.push('');
95
+ const anyNumbered = this.subsections.some((s) => s.numbered);
96
+ for (let i = 0; i < this.subsections.length; i++) {
97
+ const sub = this.subsections[i];
98
+ let newNumber;
99
+ let nextLevel;
100
+ if (this.title !== null || sectionNumber.length) {
101
+ if (anyNumbered && sub.numbered !== false) {
102
+ newNumber = [...sectionNumber, i + 1];
103
+ }
104
+ else {
105
+ newNumber = sectionNumber;
106
+ }
107
+ nextLevel = level + 1;
108
+ }
109
+ else {
110
+ newNumber = sectionNumber;
111
+ nextLevel = level;
112
+ }
113
+ lines.push(sub.renderMarkdown(nextLevel, newNumber));
114
+ }
115
+ return lines.join('\n');
116
+ }
117
+ }
118
+ /** Builds a structured prompt by composing named POM sections, with Markdown and dict export. */
119
+ export class PomBuilder {
120
+ sections = [];
121
+ sectionMap = new Map();
122
+ /**
123
+ * Adds a new top-level section to the prompt.
124
+ * @param title - The section heading.
125
+ * @param opts - Optional body, bullets, numbering, and subsection configuration.
126
+ * @returns This builder for chaining.
127
+ */
128
+ addSection(title, opts) {
129
+ const section = new PomSection({
130
+ title,
131
+ body: opts?.body,
132
+ bullets: opts?.bullets,
133
+ numbered: opts?.numbered,
134
+ numberedBullets: opts?.numberedBullets,
135
+ });
136
+ this.sections.push(section);
137
+ this.sectionMap.set(title, section);
138
+ if (opts?.subsections) {
139
+ for (const sub of opts.subsections) {
140
+ section.addSubsection({
141
+ title: sub.title,
142
+ body: sub.body,
143
+ bullets: sub.bullets,
144
+ });
145
+ }
146
+ }
147
+ return this;
148
+ }
149
+ /**
150
+ * Appends body text or bullets to an existing section, creating it if absent.
151
+ * @param title - The section heading to append to.
152
+ * @param opts - Body text and/or bullets to add.
153
+ * @returns This builder for chaining.
154
+ */
155
+ addToSection(title, opts) {
156
+ if (!this.sectionMap.has(title)) {
157
+ this.addSection(title);
158
+ }
159
+ const section = this.sectionMap.get(title);
160
+ if (opts?.body) {
161
+ section.body = section.body ? `${section.body}\n\n${opts.body}` : opts.body;
162
+ }
163
+ if (opts?.bullet)
164
+ section.bullets.push(opts.bullet);
165
+ if (opts?.bullets)
166
+ section.bullets.push(...opts.bullets);
167
+ return this;
168
+ }
169
+ /**
170
+ * Adds a subsection under an existing parent section, creating the parent if absent.
171
+ * @param parentTitle - The heading of the parent section.
172
+ * @param title - The subsection heading.
173
+ * @param opts - Optional body text and bullets for the subsection.
174
+ * @returns This builder for chaining.
175
+ */
176
+ addSubsection(parentTitle, title, opts) {
177
+ if (!this.sectionMap.has(parentTitle)) {
178
+ this.addSection(parentTitle);
179
+ }
180
+ this.sectionMap.get(parentTitle).addSubsection({
181
+ title,
182
+ body: opts?.body,
183
+ bullets: opts?.bullets,
184
+ });
185
+ return this;
186
+ }
187
+ /**
188
+ * Checks whether a top-level section with the given title exists.
189
+ * @param title - The section heading to look for.
190
+ * @returns True if the section exists.
191
+ */
192
+ hasSection(title) {
193
+ return this.sectionMap.has(title);
194
+ }
195
+ /**
196
+ * Returns a top-level section by title.
197
+ * @param title - The section heading to retrieve.
198
+ * @returns The matching PomSection, or undefined if not found.
199
+ */
200
+ getSection(title) {
201
+ return this.sectionMap.get(title);
202
+ }
203
+ /**
204
+ * Recursively searches all sections and subsections for one matching the given title.
205
+ * @param title - The section heading to search for.
206
+ * @returns The matching PomSection, or undefined if not found.
207
+ */
208
+ findSection(title) {
209
+ const recurse = (sections) => {
210
+ for (const s of sections) {
211
+ if (s.title === title)
212
+ return s;
213
+ const found = recurse(s.subsections);
214
+ if (found)
215
+ return found;
216
+ }
217
+ return undefined;
218
+ };
219
+ return recurse(this.sections);
220
+ }
221
+ /**
222
+ * Serializes all sections to an array of plain data objects.
223
+ * @returns An array of PomSectionData representing all top-level sections.
224
+ */
225
+ toDict() {
226
+ return this.sections.map((s) => s.toDict());
227
+ }
228
+ /**
229
+ * Renders all sections as a combined Markdown string.
230
+ * @returns The complete rendered Markdown prompt text.
231
+ */
232
+ renderMarkdown() {
233
+ const anyNumbered = this.sections.some((s) => s.numbered);
234
+ const parts = [];
235
+ let counter = 0;
236
+ for (const section of this.sections) {
237
+ let sectionNumber = [];
238
+ if (section.title !== null) {
239
+ counter++;
240
+ if (anyNumbered && section.numbered !== false) {
241
+ sectionNumber = [counter];
242
+ }
243
+ }
244
+ parts.push(section.renderMarkdown(2, sectionNumber));
245
+ }
246
+ return parts.join('\n');
247
+ }
248
+ }
249
+ //# sourceMappingURL=PomBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PomBuilder.js","sourceRoot":"","sources":["../src/PomBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkBH,6GAA6G;AAC7G,MAAM,OAAO,UAAU;IACrB,iDAAiD;IACjD,KAAK,CAAgB;IACrB,mCAAmC;IACnC,IAAI,CAAS;IACb,oCAAoC;IACpC,OAAO,CAAW;IAClB,6BAA6B;IAC7B,WAAW,CAAe;IAC1B,8FAA8F;IAC9F,QAAQ,CAAiB;IACzB,6DAA6D;IAC7D,eAAe,CAAU;IAEzB;;;OAGG;IACH,YAAY,IAMX;QACC,IAAI,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,IAAI,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,IAAI,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AAC,CAAC;QAC1D,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpC,IAAI,aAAa,GAAa,EAAE,CAAC;YACjC,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC3B,OAAO,EAAE,CAAC;gBACV,IAAI,WAAW,IAAI,OAAO,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;oBAC9C,aAAa,GAAG,CAAC,OAAO,CAAC,CAAC;gBAC5B,CAAC;YACH,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * PromptManager - Manages agent prompts with POM support.
3
+ *
4
+ * Holds either raw prompt text or a PomBuilder for structured prompts.
5
+ */
6
+ import { PomBuilder } from './PomBuilder.js';
7
+ /** Manages agent prompt text, supporting both raw text and structured POM-based prompts. */
8
+ export declare class PromptManager {
9
+ private rawText;
10
+ private postPrompt;
11
+ private pom;
12
+ private usePom;
13
+ /**
14
+ * Creates a new PromptManager.
15
+ * @param usePom - Whether to use structured POM sections (default true).
16
+ */
17
+ constructor(usePom?: boolean);
18
+ /**
19
+ * Sets the raw prompt text, bypassing POM rendering.
20
+ * @param text - The raw prompt string.
21
+ */
22
+ setPromptText(text: string): void;
23
+ /**
24
+ * Sets the post-prompt text appended after the main prompt.
25
+ * @param text - The post-prompt string.
26
+ */
27
+ setPostPrompt(text: string): void;
28
+ /**
29
+ * Adds a POM section to the prompt, initializing the PomBuilder if needed.
30
+ * @param title - The section heading.
31
+ * @param opts - Optional body, bullets, numbering, and subsection configuration.
32
+ */
33
+ addSection(title: string, opts?: {
34
+ body?: string;
35
+ bullets?: string[];
36
+ numbered?: boolean;
37
+ numberedBullets?: boolean;
38
+ subsections?: {
39
+ title: string;
40
+ body?: string;
41
+ bullets?: string[];
42
+ }[];
43
+ }): void;
44
+ /**
45
+ * Appends body text or bullets to an existing POM section, creating it if absent.
46
+ * @param title - The section heading to append to.
47
+ * @param opts - Body text and/or bullets to add.
48
+ */
49
+ addToSection(title: string, opts?: {
50
+ body?: string;
51
+ bullet?: string;
52
+ bullets?: string[];
53
+ }): void;
54
+ /**
55
+ * Adds a subsection under a parent POM section, creating the parent if absent.
56
+ * @param parentTitle - The heading of the parent section.
57
+ * @param title - The subsection heading.
58
+ * @param opts - Optional body text and bullets for the subsection.
59
+ */
60
+ addSubsection(parentTitle: string, title: string, opts?: {
61
+ body?: string;
62
+ bullets?: string[];
63
+ }): void;
64
+ /**
65
+ * Checks whether a POM section with the given title exists.
66
+ * @param title - The section heading to look for.
67
+ * @returns True if the section exists.
68
+ */
69
+ hasSection(title: string): boolean;
70
+ /**
71
+ * Returns the fully rendered prompt text, either raw text or POM-rendered Markdown.
72
+ * @returns The prompt string, or empty string if nothing is set.
73
+ */
74
+ getPrompt(): string;
75
+ /**
76
+ * Returns the post-prompt text.
77
+ * @returns The post-prompt string, or null if not set.
78
+ */
79
+ getPostPrompt(): string | null;
80
+ /**
81
+ * Returns the underlying PomBuilder instance, if POM mode is active.
82
+ * @returns The PomBuilder, or null if POM is not in use.
83
+ */
84
+ getPomBuilder(): PomBuilder | null;
85
+ }