tuplet 2.7.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 (319) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +136 -0
  3. package/dist/agent.d.ts +46 -0
  4. package/dist/agent.d.ts.map +1 -0
  5. package/dist/agent.js +393 -0
  6. package/dist/agent.js.map +1 -0
  7. package/dist/built-in-agents/explore.d.ts +9 -0
  8. package/dist/built-in-agents/explore.d.ts.map +1 -0
  9. package/dist/built-in-agents/explore.js +40 -0
  10. package/dist/built-in-agents/explore.js.map +1 -0
  11. package/dist/built-in-agents/index.d.ts +15 -0
  12. package/dist/built-in-agents/index.d.ts.map +1 -0
  13. package/dist/built-in-agents/index.js +19 -0
  14. package/dist/built-in-agents/index.js.map +1 -0
  15. package/dist/built-in-agents/plan.d.ts +10 -0
  16. package/dist/built-in-agents/plan.d.ts.map +1 -0
  17. package/dist/built-in-agents/plan.js +62 -0
  18. package/dist/built-in-agents/plan.js.map +1 -0
  19. package/dist/built-in-agents/worker.d.ts +9 -0
  20. package/dist/built-in-agents/worker.d.ts.map +1 -0
  21. package/dist/built-in-agents/worker.js +53 -0
  22. package/dist/built-in-agents/worker.js.map +1 -0
  23. package/dist/constants.d.ts +7 -0
  24. package/dist/constants.d.ts.map +1 -0
  25. package/dist/constants.js +18 -0
  26. package/dist/constants.js.map +1 -0
  27. package/dist/context-manager.d.ts +65 -0
  28. package/dist/context-manager.d.ts.map +1 -0
  29. package/dist/context-manager.js +272 -0
  30. package/dist/context-manager.js.map +1 -0
  31. package/dist/context-manager.test.d.ts +2 -0
  32. package/dist/context-manager.test.d.ts.map +1 -0
  33. package/dist/context-manager.test.js +394 -0
  34. package/dist/context-manager.test.js.map +1 -0
  35. package/dist/executor.d.ts +29 -0
  36. package/dist/executor.d.ts.map +1 -0
  37. package/dist/executor.js +399 -0
  38. package/dist/executor.js.map +1 -0
  39. package/dist/index.d.ts +24 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +40 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/prompt/index.d.ts +9 -0
  44. package/dist/prompt/index.d.ts.map +1 -0
  45. package/dist/prompt/index.js +10 -0
  46. package/dist/prompt/index.js.map +1 -0
  47. package/dist/prompt/main-agent-builder.d.ts +81 -0
  48. package/dist/prompt/main-agent-builder.d.ts.map +1 -0
  49. package/dist/prompt/main-agent-builder.js +287 -0
  50. package/dist/prompt/main-agent-builder.js.map +1 -0
  51. package/dist/prompt/sub-agent-builder.d.ts +133 -0
  52. package/dist/prompt/sub-agent-builder.d.ts.map +1 -0
  53. package/dist/prompt/sub-agent-builder.js +337 -0
  54. package/dist/prompt/sub-agent-builder.js.map +1 -0
  55. package/dist/prompt/templates.d.ts +87 -0
  56. package/dist/prompt/templates.d.ts.map +1 -0
  57. package/dist/prompt/templates.js +343 -0
  58. package/dist/prompt/templates.js.map +1 -0
  59. package/dist/prompt/types.d.ts +159 -0
  60. package/dist/prompt/types.d.ts.map +1 -0
  61. package/dist/prompt/types.js +5 -0
  62. package/dist/prompt/types.js.map +1 -0
  63. package/dist/prompt.d.ts +32 -0
  64. package/dist/prompt.d.ts.map +1 -0
  65. package/dist/prompt.js +86 -0
  66. package/dist/prompt.js.map +1 -0
  67. package/dist/providers/dataset/base.d.ts +74 -0
  68. package/dist/providers/dataset/base.d.ts.map +1 -0
  69. package/dist/providers/dataset/base.js +7 -0
  70. package/dist/providers/dataset/base.js.map +1 -0
  71. package/dist/providers/dataset/index.d.ts +8 -0
  72. package/dist/providers/dataset/index.d.ts.map +1 -0
  73. package/dist/providers/dataset/index.js +8 -0
  74. package/dist/providers/dataset/index.js.map +1 -0
  75. package/dist/providers/dataset/recorder.d.ts +46 -0
  76. package/dist/providers/dataset/recorder.d.ts.map +1 -0
  77. package/dist/providers/dataset/recorder.js +105 -0
  78. package/dist/providers/dataset/recorder.js.map +1 -0
  79. package/dist/providers/dataset/replayer.d.ts +46 -0
  80. package/dist/providers/dataset/replayer.d.ts.map +1 -0
  81. package/dist/providers/dataset/replayer.js +163 -0
  82. package/dist/providers/dataset/replayer.js.map +1 -0
  83. package/dist/providers/dataset/tester.d.ts +89 -0
  84. package/dist/providers/dataset/tester.d.ts.map +1 -0
  85. package/dist/providers/dataset/tester.js +143 -0
  86. package/dist/providers/dataset/tester.js.map +1 -0
  87. package/dist/providers/env/memory.d.ts +14 -0
  88. package/dist/providers/env/memory.d.ts.map +1 -0
  89. package/dist/providers/env/memory.js +19 -0
  90. package/dist/providers/env/memory.js.map +1 -0
  91. package/dist/providers/index.d.ts +12 -0
  92. package/dist/providers/index.d.ts.map +1 -0
  93. package/dist/providers/index.js +10 -0
  94. package/dist/providers/index.js.map +1 -0
  95. package/dist/providers/llm/base.d.ts +7 -0
  96. package/dist/providers/llm/base.d.ts.map +1 -0
  97. package/dist/providers/llm/base.js +7 -0
  98. package/dist/providers/llm/base.js.map +1 -0
  99. package/dist/providers/llm/claude.d.ts +32 -0
  100. package/dist/providers/llm/claude.d.ts.map +1 -0
  101. package/dist/providers/llm/claude.js +171 -0
  102. package/dist/providers/llm/claude.js.map +1 -0
  103. package/dist/providers/llm/openai.d.ts +26 -0
  104. package/dist/providers/llm/openai.d.ts.map +1 -0
  105. package/dist/providers/llm/openai.js +174 -0
  106. package/dist/providers/llm/openai.js.map +1 -0
  107. package/dist/providers/llm/openrouter.d.ts +43 -0
  108. package/dist/providers/llm/openrouter.d.ts.map +1 -0
  109. package/dist/providers/llm/openrouter.js +288 -0
  110. package/dist/providers/llm/openrouter.js.map +1 -0
  111. package/dist/providers/logger/base.d.ts +7 -0
  112. package/dist/providers/logger/base.d.ts.map +1 -0
  113. package/dist/providers/logger/base.js +7 -0
  114. package/dist/providers/logger/base.js.map +1 -0
  115. package/dist/providers/logger/console.d.ts +29 -0
  116. package/dist/providers/logger/console.d.ts.map +1 -0
  117. package/dist/providers/logger/console.js +70 -0
  118. package/dist/providers/logger/console.js.map +1 -0
  119. package/dist/providers/repository/base.d.ts +7 -0
  120. package/dist/providers/repository/base.d.ts.map +1 -0
  121. package/dist/providers/repository/base.js +7 -0
  122. package/dist/providers/repository/base.js.map +1 -0
  123. package/dist/providers/repository/memory.d.ts +21 -0
  124. package/dist/providers/repository/memory.d.ts.map +1 -0
  125. package/dist/providers/repository/memory.js +50 -0
  126. package/dist/providers/repository/memory.js.map +1 -0
  127. package/dist/providers/workspace/file.d.ts +26 -0
  128. package/dist/providers/workspace/file.d.ts.map +1 -0
  129. package/dist/providers/workspace/file.js +151 -0
  130. package/dist/providers/workspace/file.js.map +1 -0
  131. package/dist/providers/workspace/index.d.ts +7 -0
  132. package/dist/providers/workspace/index.d.ts.map +1 -0
  133. package/dist/providers/workspace/index.js +6 -0
  134. package/dist/providers/workspace/index.js.map +1 -0
  135. package/dist/providers/workspace/memory.d.ts +26 -0
  136. package/dist/providers/workspace/memory.d.ts.map +1 -0
  137. package/dist/providers/workspace/memory.js +136 -0
  138. package/dist/providers/workspace/memory.js.map +1 -0
  139. package/dist/providers/workspace/types.d.ts +27 -0
  140. package/dist/providers/workspace/types.d.ts.map +1 -0
  141. package/dist/providers/workspace/types.js +8 -0
  142. package/dist/providers/workspace/types.js.map +1 -0
  143. package/dist/providers/workspace/workspace-provider.test.d.ts +2 -0
  144. package/dist/providers/workspace/workspace-provider.test.d.ts.map +1 -0
  145. package/dist/providers/workspace/workspace-provider.test.js +250 -0
  146. package/dist/providers/workspace/workspace-provider.test.js.map +1 -0
  147. package/dist/shell/commands/browse.d.ts +6 -0
  148. package/dist/shell/commands/browse.d.ts.map +1 -0
  149. package/dist/shell/commands/browse.js +158 -0
  150. package/dist/shell/commands/browse.js.map +1 -0
  151. package/dist/shell/commands/cat.d.ts +6 -0
  152. package/dist/shell/commands/cat.d.ts.map +1 -0
  153. package/dist/shell/commands/cat.js +104 -0
  154. package/dist/shell/commands/cat.js.map +1 -0
  155. package/dist/shell/commands/curl.d.ts +6 -0
  156. package/dist/shell/commands/curl.d.ts.map +1 -0
  157. package/dist/shell/commands/curl.js +190 -0
  158. package/dist/shell/commands/curl.js.map +1 -0
  159. package/dist/shell/commands/date.d.ts +6 -0
  160. package/dist/shell/commands/date.d.ts.map +1 -0
  161. package/dist/shell/commands/date.js +151 -0
  162. package/dist/shell/commands/date.js.map +1 -0
  163. package/dist/shell/commands/echo.d.ts +6 -0
  164. package/dist/shell/commands/echo.d.ts.map +1 -0
  165. package/dist/shell/commands/echo.js +48 -0
  166. package/dist/shell/commands/echo.js.map +1 -0
  167. package/dist/shell/commands/env.d.ts +8 -0
  168. package/dist/shell/commands/env.d.ts.map +1 -0
  169. package/dist/shell/commands/env.js +41 -0
  170. package/dist/shell/commands/env.js.map +1 -0
  171. package/dist/shell/commands/file.d.ts +6 -0
  172. package/dist/shell/commands/file.d.ts.map +1 -0
  173. package/dist/shell/commands/file.js +213 -0
  174. package/dist/shell/commands/file.js.map +1 -0
  175. package/dist/shell/commands/find.d.ts +6 -0
  176. package/dist/shell/commands/find.d.ts.map +1 -0
  177. package/dist/shell/commands/find.js +100 -0
  178. package/dist/shell/commands/find.js.map +1 -0
  179. package/dist/shell/commands/grep.d.ts +6 -0
  180. package/dist/shell/commands/grep.d.ts.map +1 -0
  181. package/dist/shell/commands/grep.js +229 -0
  182. package/dist/shell/commands/grep.js.map +1 -0
  183. package/dist/shell/commands/head.d.ts +6 -0
  184. package/dist/shell/commands/head.d.ts.map +1 -0
  185. package/dist/shell/commands/head.js +88 -0
  186. package/dist/shell/commands/head.js.map +1 -0
  187. package/dist/shell/commands/index.d.ts +25 -0
  188. package/dist/shell/commands/index.d.ts.map +1 -0
  189. package/dist/shell/commands/index.js +43 -0
  190. package/dist/shell/commands/index.js.map +1 -0
  191. package/dist/shell/commands/jq.d.ts +8 -0
  192. package/dist/shell/commands/jq.d.ts.map +1 -0
  193. package/dist/shell/commands/jq.js +233 -0
  194. package/dist/shell/commands/jq.js.map +1 -0
  195. package/dist/shell/commands/ls.d.ts +6 -0
  196. package/dist/shell/commands/ls.d.ts.map +1 -0
  197. package/dist/shell/commands/ls.js +88 -0
  198. package/dist/shell/commands/ls.js.map +1 -0
  199. package/dist/shell/commands/mkdir.d.ts +6 -0
  200. package/dist/shell/commands/mkdir.d.ts.map +1 -0
  201. package/dist/shell/commands/mkdir.js +43 -0
  202. package/dist/shell/commands/mkdir.js.map +1 -0
  203. package/dist/shell/commands/rm.d.ts +6 -0
  204. package/dist/shell/commands/rm.d.ts.map +1 -0
  205. package/dist/shell/commands/rm.js +64 -0
  206. package/dist/shell/commands/rm.js.map +1 -0
  207. package/dist/shell/commands/sed.d.ts +6 -0
  208. package/dist/shell/commands/sed.d.ts.map +1 -0
  209. package/dist/shell/commands/sed.js +414 -0
  210. package/dist/shell/commands/sed.js.map +1 -0
  211. package/dist/shell/commands/sort.d.ts +6 -0
  212. package/dist/shell/commands/sort.d.ts.map +1 -0
  213. package/dist/shell/commands/sort.js +109 -0
  214. package/dist/shell/commands/sort.js.map +1 -0
  215. package/dist/shell/commands/tail.d.ts +6 -0
  216. package/dist/shell/commands/tail.d.ts.map +1 -0
  217. package/dist/shell/commands/tail.js +68 -0
  218. package/dist/shell/commands/tail.js.map +1 -0
  219. package/dist/shell/commands/wc.d.ts +6 -0
  220. package/dist/shell/commands/wc.d.ts.map +1 -0
  221. package/dist/shell/commands/wc.js +86 -0
  222. package/dist/shell/commands/wc.js.map +1 -0
  223. package/dist/shell/index.d.ts +10 -0
  224. package/dist/shell/index.d.ts.map +1 -0
  225. package/dist/shell/index.js +10 -0
  226. package/dist/shell/index.js.map +1 -0
  227. package/dist/shell/limits.d.ts +5 -0
  228. package/dist/shell/limits.d.ts.map +1 -0
  229. package/dist/shell/limits.js +5 -0
  230. package/dist/shell/limits.js.map +1 -0
  231. package/dist/shell/parser.d.ts +8 -0
  232. package/dist/shell/parser.d.ts.map +1 -0
  233. package/dist/shell/parser.js +307 -0
  234. package/dist/shell/parser.js.map +1 -0
  235. package/dist/shell/path-validation.d.ts +35 -0
  236. package/dist/shell/path-validation.d.ts.map +1 -0
  237. package/dist/shell/path-validation.js +81 -0
  238. package/dist/shell/path-validation.js.map +1 -0
  239. package/dist/shell/shell.d.ts +66 -0
  240. package/dist/shell/shell.d.ts.map +1 -0
  241. package/dist/shell/shell.js +301 -0
  242. package/dist/shell/shell.js.map +1 -0
  243. package/dist/shell/shell.test.d.ts +2 -0
  244. package/dist/shell/shell.test.d.ts.map +1 -0
  245. package/dist/shell/shell.test.js +1088 -0
  246. package/dist/shell/shell.test.js.map +1 -0
  247. package/dist/shell/types.d.ts +82 -0
  248. package/dist/shell/types.d.ts.map +1 -0
  249. package/dist/shell/types.js +5 -0
  250. package/dist/shell/types.js.map +1 -0
  251. package/dist/summarizer.d.ts +28 -0
  252. package/dist/summarizer.d.ts.map +1 -0
  253. package/dist/summarizer.js +136 -0
  254. package/dist/summarizer.js.map +1 -0
  255. package/dist/summarizer.test.d.ts +2 -0
  256. package/dist/summarizer.test.d.ts.map +1 -0
  257. package/dist/summarizer.test.js +192 -0
  258. package/dist/summarizer.test.js.map +1 -0
  259. package/dist/tools/ask-user.d.ts +11 -0
  260. package/dist/tools/ask-user.d.ts.map +1 -0
  261. package/dist/tools/ask-user.js +35 -0
  262. package/dist/tools/ask-user.js.map +1 -0
  263. package/dist/tools/index.d.ts +11 -0
  264. package/dist/tools/index.d.ts.map +1 -0
  265. package/dist/tools/index.js +18 -0
  266. package/dist/tools/index.js.map +1 -0
  267. package/dist/tools/output.d.ts +15 -0
  268. package/dist/tools/output.d.ts.map +1 -0
  269. package/dist/tools/output.js +40 -0
  270. package/dist/tools/output.js.map +1 -0
  271. package/dist/tools/shell.d.ts +13 -0
  272. package/dist/tools/shell.d.ts.map +1 -0
  273. package/dist/tools/shell.js +166 -0
  274. package/dist/tools/shell.js.map +1 -0
  275. package/dist/tools/sub-agent.d.ts +25 -0
  276. package/dist/tools/sub-agent.d.ts.map +1 -0
  277. package/dist/tools/sub-agent.js +312 -0
  278. package/dist/tools/sub-agent.js.map +1 -0
  279. package/dist/tools/tasks.d.ts +170 -0
  280. package/dist/tools/tasks.d.ts.map +1 -0
  281. package/dist/tools/tasks.js +947 -0
  282. package/dist/tools/tasks.js.map +1 -0
  283. package/dist/trace/builder.d.ts +54 -0
  284. package/dist/trace/builder.d.ts.map +1 -0
  285. package/dist/trace/builder.js +229 -0
  286. package/dist/trace/builder.js.map +1 -0
  287. package/dist/trace/console.d.ts +45 -0
  288. package/dist/trace/console.d.ts.map +1 -0
  289. package/dist/trace/console.js +143 -0
  290. package/dist/trace/console.js.map +1 -0
  291. package/dist/trace/index.d.ts +11 -0
  292. package/dist/trace/index.d.ts.map +1 -0
  293. package/dist/trace/index.js +11 -0
  294. package/dist/trace/index.js.map +1 -0
  295. package/dist/trace/openrouter-pricing.d.ts +9 -0
  296. package/dist/trace/openrouter-pricing.d.ts.map +1 -0
  297. package/dist/trace/openrouter-pricing.js +321 -0
  298. package/dist/trace/openrouter-pricing.js.map +1 -0
  299. package/dist/trace/pricing.d.ts +13 -0
  300. package/dist/trace/pricing.d.ts.map +1 -0
  301. package/dist/trace/pricing.js +41 -0
  302. package/dist/trace/pricing.js.map +1 -0
  303. package/dist/trace/types.d.ts +142 -0
  304. package/dist/trace/types.d.ts.map +1 -0
  305. package/dist/trace/types.js +16 -0
  306. package/dist/trace/types.js.map +1 -0
  307. package/dist/trace.d.ts +5 -0
  308. package/dist/trace.d.ts.map +1 -0
  309. package/dist/trace.js +5 -0
  310. package/dist/trace.js.map +1 -0
  311. package/dist/types.d.ts +382 -0
  312. package/dist/types.d.ts.map +1 -0
  313. package/dist/types.js +5 -0
  314. package/dist/types.js.map +1 -0
  315. package/dist/workspace.d.ts +287 -0
  316. package/dist/workspace.d.ts.map +1 -0
  317. package/dist/workspace.js +560 -0
  318. package/dist/workspace.js.map +1 -0
  319. package/package.json +47 -0
@@ -0,0 +1,287 @@
1
+ /**
2
+ * Main Agent Prompt Builder
3
+ *
4
+ * Fluent API for building main agent system prompts.
5
+ */
6
+ import { getBuiltInAgents } from '../built-in-agents/index.js';
7
+ import { roleSection, subAgentsTable, subAgentParametersSection, questionHandlingSection, directToolsSection, workspaceStorageSection, rulesSection, taskExamplesSection } from './templates.js';
8
+ export class MainAgentBuilder {
9
+ config = {
10
+ subAgents: [],
11
+ directTools: [],
12
+ workspacePaths: [],
13
+ rules: [],
14
+ examples: [],
15
+ customSections: []
16
+ };
17
+ _skipBuiltInAgents = false;
18
+ /**
19
+ * Skip auto-injecting built-in agents (used when Tuplet already merges them)
20
+ */
21
+ skipBuiltInAgents() {
22
+ this._skipBuiltInAgents = true;
23
+ return this;
24
+ }
25
+ /**
26
+ * Set the agent's role identity
27
+ */
28
+ role(role) {
29
+ this.config.role = role;
30
+ return this;
31
+ }
32
+ /**
33
+ * Set the agent's description
34
+ */
35
+ description(description) {
36
+ this.config.description = description;
37
+ return this;
38
+ }
39
+ /**
40
+ * Set sub-agents from actual SubAgentConfig objects
41
+ * Extracts name, description, and input parameters automatically
42
+ */
43
+ agents(configs) {
44
+ for (const config of configs) {
45
+ // Extract input parameters from inputSchema
46
+ const inputParams = [];
47
+ if (config.inputSchema?.properties) {
48
+ const required = config.inputSchema.required || [];
49
+ for (const [name, prop] of Object.entries(config.inputSchema.properties)) {
50
+ inputParams.push({
51
+ name,
52
+ description: prop.description || '',
53
+ required: required.includes(name)
54
+ });
55
+ }
56
+ }
57
+ this.config.subAgents.push({
58
+ name: config.name,
59
+ purpose: config.description,
60
+ whenToUse: config.description,
61
+ inputParams: inputParams.length > 0 ? inputParams : undefined
62
+ });
63
+ }
64
+ return this;
65
+ }
66
+ /**
67
+ * Configure question handling behavior
68
+ */
69
+ questionHandling(options) {
70
+ this.config.questionHandling = options;
71
+ return this;
72
+ }
73
+ /**
74
+ * Set tools from actual Tool objects
75
+ * Extracts name and description automatically
76
+ */
77
+ tools(toolObjects) {
78
+ for (const tool of toolObjects) {
79
+ // Extract first line of description for brevity
80
+ const desc = tool.description.split('\n')[0].trim();
81
+ this.config.directTools.push({
82
+ name: tool.name,
83
+ description: desc
84
+ });
85
+ }
86
+ return this;
87
+ }
88
+ /**
89
+ * Add a workspace path definition
90
+ */
91
+ addWorkspacePath(path, description) {
92
+ this.config.workspacePaths.push({ path, description });
93
+ return this;
94
+ }
95
+ /**
96
+ * Add multiple workspace paths at once
97
+ */
98
+ addWorkspacePaths(paths) {
99
+ this.config.workspacePaths.push(...paths);
100
+ return this;
101
+ }
102
+ /**
103
+ * Add a behavioral rule
104
+ */
105
+ addRule(rule) {
106
+ this.config.rules.push(rule);
107
+ return this;
108
+ }
109
+ /**
110
+ * Add multiple rules at once
111
+ */
112
+ addRules(rules) {
113
+ this.config.rules.push(...rules);
114
+ return this;
115
+ }
116
+ /**
117
+ * Add a task example showing the flow
118
+ */
119
+ addExample(example) {
120
+ this.config.examples.push(example);
121
+ return this;
122
+ }
123
+ /**
124
+ * Add multiple examples at once
125
+ */
126
+ addExamples(examples) {
127
+ this.config.examples.push(...examples);
128
+ return this;
129
+ }
130
+ /**
131
+ * Add a custom section with title and content
132
+ */
133
+ addSection(title, content) {
134
+ this.config.customSections.push({ title, content });
135
+ return this;
136
+ }
137
+ /**
138
+ * Get the current configuration
139
+ */
140
+ getConfig() {
141
+ return { ...this.config };
142
+ }
143
+ /**
144
+ * Build the final system prompt string
145
+ */
146
+ build() {
147
+ const sections = [];
148
+ // Auto-inject built-in agent defs (unless skipBuiltInAgents or user already added same name)
149
+ let builtInDefs = [];
150
+ if (!this._skipBuiltInAgents) {
151
+ const userAgentNames = new Set((this.config.subAgents || []).map(a => a.name));
152
+ const builtInAgents = getBuiltInAgents();
153
+ const newBuiltIns = builtInAgents.filter(a => !userAgentNames.has(a.name));
154
+ builtInDefs = newBuiltIns.map(a => ({
155
+ name: a.name,
156
+ purpose: a.description,
157
+ whenToUse: a.description,
158
+ }));
159
+ }
160
+ else {
161
+ // When called from Tuplet, built-ins are already merged into subAgents.
162
+ // Detect which ones are built-in by checking against getBuiltInAgents().
163
+ const builtInNames = new Set(getBuiltInAgents().map(a => a.name));
164
+ builtInDefs = (this.config.subAgents || [])
165
+ .filter(a => builtInNames.has(a.name))
166
+ .map(a => ({ name: a.name, purpose: a.purpose, whenToUse: a.whenToUse }));
167
+ }
168
+ const allSubAgents = [...(this.config.subAgents || []), ...(this._skipBuiltInAgents ? [] : builtInDefs)];
169
+ // Role section (required, with default)
170
+ const role = this.config.role || 'an AI assistant';
171
+ sections.push(roleSection(role, this.config.description));
172
+ // Current date
173
+ const today = new Date().toISOString().split('T')[0];
174
+ sections.push('');
175
+ sections.push(`Today's date is ${today}.`);
176
+ // Your Role header if we have sub-agents (orchestrator pattern)
177
+ if (allSubAgents.length > 0) {
178
+ sections.push('');
179
+ sections.push('## Your Role');
180
+ sections.push('');
181
+ if (builtInDefs.length > 0) {
182
+ sections.push('1. **Explore first** - Use the `explore` sub-agent to check workspace state. You are a lead — give it a SPECIFIC brief: what paths to check, what data to look for, what keywords to search. Example: "List top-level paths with `ls`, then check if `data/` has any funding-related JSON files." Do NOT send vague instructions like "explore everything"');
183
+ sections.push('2. **Clarify if needed** - If the request is vague or ambiguous, ask the user using __ask_user__ BEFORE doing work. Examples of things to clarify: what "small" means, where to save results, what format, what criteria to use, what sources to prefer');
184
+ sections.push('3. **Formulate requirements** - Before planning or delegating, synthesize your findings into a structured brief:');
185
+ sections.push(' - Context: current state and exploration findings');
186
+ sections.push(' - Goal: what the user wants to achieve');
187
+ sections.push(' - Affected areas: workspace paths and components involved');
188
+ sections.push(' - Constraints: limitations and dependencies');
189
+ sections.push(' - Success criteria: how to verify completion');
190
+ sections.push('4. **Plan** - For any task that involves multiple steps (searching, processing, saving), pass the structured brief to the `plan` sub-agent. Do NOT skip planning and jump straight into execution');
191
+ sections.push('5. **Create tasks from the plan** - After receiving the plan, create one task per plan step using TaskCreate. Each task should match a plan step: clear goal, relevant context, and expected outcome. This is MANDATORY for multi-step plans — do not skip task creation and jump straight to execution');
192
+ sections.push('6. **Execute** — Work through tasks in order. For each task: mark it in_progress, delegate to the `worker` sub-agent, then mark it completed. Delegate like a team lead assigns work to a developer — give the goal, relevant context, requirements, and constraints. Do NOT micromanage — the worker decides HOW to accomplish the goal');
193
+ sections.push('7. **Verify** — Use the `explore` sub-agent to verify results (read saved files, check data quality)');
194
+ sections.push('8. **Present results** - After ALL tasks are completed, output a clear summary to the user');
195
+ }
196
+ else {
197
+ sections.push('1. **Delegate** - Call __sub_agent__ tool to spawn sub-agents');
198
+ sections.push('2. **Present results** - After sub-agent completes, you MUST output a text message to the user');
199
+ }
200
+ sections.push('');
201
+ sections.push('⚠️ CRITICAL:');
202
+ sections.push('- Make actual tool calls, never write tool names as text');
203
+ sections.push('- After receiving tool results, ALWAYS respond with a text message to the user');
204
+ sections.push('- Never return an empty response');
205
+ }
206
+ // Sub-agents table
207
+ if (allSubAgents.length > 0) {
208
+ sections.push('');
209
+ sections.push(subAgentsTable(allSubAgents));
210
+ // Add sub-agent parameters documentation
211
+ const paramsSection = subAgentParametersSection(allSubAgents);
212
+ if (paramsSection) {
213
+ sections.push('');
214
+ sections.push(paramsSection);
215
+ }
216
+ }
217
+ // Built-in agents usage instructions (always present)
218
+ if (builtInDefs.length > 0) {
219
+ sections.push('');
220
+ sections.push('## Built-in Agents — Mandatory Usage');
221
+ sections.push('');
222
+ sections.push('These agents are always available. You MUST use them:');
223
+ sections.push('');
224
+ sections.push('- **explore**: ALWAYS call this BEFORE handling any user request. Give it a focused brief — tell it exactly what to look for and where. It should only read files that are relevant to the task, not explore the entire workspace.');
225
+ sections.push('- **plan**: Pure planner — does NOT explore or execute. Call this AFTER exploring, BEFORE executing. Feed it your exploration findings as a structured brief (context, goal, constraints, success criteria) and it returns a step-by-step execution plan where each step is a worker mission.');
226
+ sections.push('- **worker**: The ONLY way to execute actions. Delegate like a team lead to a developer — describe WHAT needs to be done and WHY, provide relevant context (paths, URLs, data formats), state requirements and constraints, but let the worker figure out the implementation details. Include hints only when you have specific domain knowledge that would save time. Examples: "We need to extract company data from this page (URL). Save each company with name, url, and description to the workspace at data/companies.json" or "Push these companies to the CRM API (endpoint: X, auth token is in env). Map our name field to their company_name field."');
227
+ sections.push('');
228
+ sections.push('The `explore` and `plan` agents are read-only. The `worker` agent has full read-write access.');
229
+ }
230
+ // Question handling (only when explicitly configured)
231
+ if (this.config.questionHandling) {
232
+ sections.push('');
233
+ sections.push(questionHandlingSection(this.config.questionHandling?.description, this.config.questionHandling?.exampleFlow));
234
+ }
235
+ // Direct tools
236
+ if (this.config.directTools && this.config.directTools.length > 0) {
237
+ sections.push('');
238
+ sections.push(directToolsSection(this.config.directTools));
239
+ }
240
+ // Workspace storage
241
+ if (this.config.workspacePaths && this.config.workspacePaths.length > 0) {
242
+ sections.push('');
243
+ sections.push(workspaceStorageSection(this.config.workspacePaths));
244
+ }
245
+ // Task examples
246
+ if (this.config.examples && this.config.examples.length > 0) {
247
+ sections.push('');
248
+ sections.push(taskExamplesSection(this.config.examples));
249
+ }
250
+ // Custom sections
251
+ for (const section of this.config.customSections || []) {
252
+ sections.push('');
253
+ sections.push(`## ${section.title}`);
254
+ sections.push('');
255
+ sections.push(section.content);
256
+ }
257
+ // Rules (always at the end): combine default rules with user rules
258
+ const defaultRules = [
259
+ 'ALWAYS call the `explore` sub-agent at the start of each user request to check workspace state before doing anything else',
260
+ 'ALWAYS use the `plan` sub-agent before executing any multi-step task. After receiving the plan, create one task per plan step using TaskCreate BEFORE starting execution. Never jump straight from planning to execution without creating tasks first',
261
+ 'For vague or ambiguous requests, ask the user to clarify BEFORE starting work. Use __ask_user__ to confirm key details: criteria, format, where to save, what sources to use. Do not guess — ask',
262
+ 'NEVER assume credentials, API keys, or secrets exist. Before any authenticated API call, first check what variables and credentials are actually available in the workspace. If they are not there, ask the user using __ask_user__ — do not guess or fabricate values',
263
+ 'Prefer free public APIs and resources that require no authentication. If auth is needed and credentials are not in workspace, ask the user',
264
+ 'If a tool call fails, read the response carefully and decide how to proceed. Do not blindly retry the same approach',
265
+ 'After completing work, verify results by reading back saved data. Present a summary to the user',
266
+ ];
267
+ const allRules = [...defaultRules, ...(this.config.rules || [])];
268
+ sections.push('');
269
+ sections.push(rulesSection(allRules));
270
+ return sections.join('\n');
271
+ }
272
+ /**
273
+ * Reset the builder to initial state
274
+ */
275
+ reset() {
276
+ this.config = {
277
+ subAgents: [],
278
+ directTools: [],
279
+ workspacePaths: [],
280
+ rules: [],
281
+ examples: [],
282
+ customSections: []
283
+ };
284
+ return this;
285
+ }
286
+ }
287
+ //# sourceMappingURL=main-agent-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main-agent-builder.js","sourceRoot":"","sources":["../../src/prompt/main-agent-builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EACL,WAAW,EACX,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,YAAY,EACZ,mBAAmB,EACpB,MAAM,gBAAgB,CAAA;AAEvB,MAAM,OAAO,gBAAgB;IACnB,MAAM,GAA0B;QACtC,SAAS,EAAE,EAAE;QACb,WAAW,EAAE,EAAE;QACf,cAAc,EAAE,EAAE;QAClB,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,cAAc,EAAE,EAAE;KACnB,CAAA;IAEO,kBAAkB,GAAG,KAAK,CAAA;IAElC;;OAEG;IACH,iBAAiB;QACf,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAA;QAC9B,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,IAAY;QACf,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;QACvB,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,WAAmB;QAC7B,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA;QACrC,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,OAAyB;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AK,IAAI,EAAE,CAAC,CAAC,CAAA;QAChE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACjB,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAA;QAErC,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,GAAG;YACZ,SAAS,EAAE,EAAE;YACb,WAAW,EAAE,EAAE;YACf,cAAc,EAAE,EAAE;YAClB,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,cAAc,EAAE,EAAE;SACnB,CAAA;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Sub-Agent Prompt Builder
3
+ *
4
+ * Fluent API for building sub-agent system prompts.
5
+ */
6
+ import type { WorkflowStep, OutputFormat, SubAgentPromptConfig, WorkspacePathDef, ToolStepRef, ChecklistItem, SubAgentExample } from './types.js';
7
+ import type { Tool, JSONSchema } from '../types.js';
8
+ export declare class SubAgentBuilder {
9
+ private config;
10
+ /**
11
+ * Set the sub-agent's role (e.g., "a Nutrition Counter assistant")
12
+ */
13
+ role(role: string): this;
14
+ /**
15
+ * Set the task description
16
+ */
17
+ task(task: string): this;
18
+ /**
19
+ * Add step-by-step instructions
20
+ */
21
+ instructions(instructions: string[]): this;
22
+ /**
23
+ * Add a single instruction
24
+ */
25
+ addInstruction(instruction: string): this;
26
+ /**
27
+ * Enable todo tracking - AI will plan and track its own work
28
+ * @param options.exampleSteps - Example todos to guide the AI (optional)
29
+ */
30
+ useTodoTracking(options?: {
31
+ exampleSteps?: string[];
32
+ }): this;
33
+ /**
34
+ * Add guidance items (without todo tracking)
35
+ * @deprecated Use useTodoTracking() for progress tracking, or addGuidelines() for static guidance
36
+ */
37
+ checklist(items: (string | ChecklistItem)[], options?: {
38
+ sequential?: boolean;
39
+ trackProgress?: boolean;
40
+ }): this;
41
+ /**
42
+ * Add an input/output example
43
+ */
44
+ addExample(input: string, output: string, explanation?: string): this;
45
+ /**
46
+ * Add multiple examples at once
47
+ */
48
+ examples(examples: SubAgentExample[]): this;
49
+ /**
50
+ * Add a constraint (thing to avoid)
51
+ */
52
+ addConstraint(constraint: string): this;
53
+ /**
54
+ * Add multiple constraints at once
55
+ */
56
+ constraints(constraints: string[]): this;
57
+ /**
58
+ * Add a workflow step
59
+ */
60
+ addStep(step: WorkflowStep): this;
61
+ /**
62
+ * Add a step that may ask a question
63
+ */
64
+ addQuestionStep(description: string, askQuestion: {
65
+ condition?: string;
66
+ question: string;
67
+ options?: string[];
68
+ }): this;
69
+ /**
70
+ * Add a guideline
71
+ */
72
+ addGuideline(guideline: string): this;
73
+ /**
74
+ * Add multiple guidelines at once
75
+ */
76
+ addGuidelines(guidelines: string[]): this;
77
+ /**
78
+ * Enable workspace discovery - agent will check workspace before starting work
79
+ */
80
+ useWorkspace(): this;
81
+ /**
82
+ * Add a workspace path the agent should check
83
+ */
84
+ addWorkspacePath(path: string, description: string): this;
85
+ /**
86
+ * Add multiple workspace paths at once
87
+ */
88
+ addWorkspacePaths(paths: WorkspacePathDef[]): this;
89
+ /**
90
+ * Set the output format
91
+ */
92
+ output(format: OutputFormat): this;
93
+ /**
94
+ * Shorthand for common output format
95
+ * @deprecated Use outputSchema() instead for type-safe output definition
96
+ */
97
+ outputWithSummary(summaryTemplate: string, dataFields: Record<string, string>, errorCase?: {
98
+ condition: string;
99
+ data: Record<string, unknown>;
100
+ }): this;
101
+ /**
102
+ * Set output schema - generates output instructions from the schema
103
+ * This is the preferred way to define output format (type-safe)
104
+ */
105
+ outputSchema(schema: JSONSchema): this;
106
+ /**
107
+ * Set available tools from actual Tool objects
108
+ * Extracts name and description automatically for documentation
109
+ */
110
+ tools(toolObjects: Tool[]): this;
111
+ /**
112
+ * Add a workflow step that uses specific tools
113
+ * Type-safe alternative to addToolStep with string arrays
114
+ */
115
+ addToolsStep(description: string, toolRefs: ToolStepRef[]): this;
116
+ /**
117
+ * Add a custom section
118
+ */
119
+ addSection(title: string, content: string): this;
120
+ /**
121
+ * Get the current configuration
122
+ */
123
+ getConfig(): SubAgentPromptConfig;
124
+ /**
125
+ * Build the final system prompt string
126
+ */
127
+ build(): string;
128
+ /**
129
+ * Reset the builder to initial state
130
+ */
131
+ reset(): this;
132
+ }
133
+ //# sourceMappingURL=sub-agent-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sub-agent-builder.d.ts","sourceRoot":"","sources":["../../src/prompt/sub-agent-builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EAEZ,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,eAAe,EAChB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAgBnD,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAUb;IAED;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKxB;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKxB;;OAEG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI;IAK1C;;OAEG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAKzC;;;OAGG;IACH,eAAe,CAAC,OAAO,CAAC,EAAE;QACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;KACxB,GAAG,IAAI;IAQR;;;OAGG;IACH,SAAS,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE;QACrD,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB,aAAa,CAAC,EAAE,OAAO,CAAA;KACxB,GAAG,IAAI;IAWR;;OAEG;IACH,UAAU,CAA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