funolio-agent 1.0.53 → 1.1.65

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 (276) hide show
  1. package/dist/approval.d.ts +1 -6
  2. package/dist/approval.d.ts.map +1 -1
  3. package/dist/approval.js +2 -7
  4. package/dist/approval.js.map +1 -1
  5. package/dist/auth/credential-reader.d.ts.map +1 -1
  6. package/dist/auth/credential-reader.js +4 -3
  7. package/dist/auth/credential-reader.js.map +1 -1
  8. package/dist/auth/token-refresh.d.ts +8 -0
  9. package/dist/auth/token-refresh.d.ts.map +1 -1
  10. package/dist/auth/token-refresh.js +82 -52
  11. package/dist/auth/token-refresh.js.map +1 -1
  12. package/dist/auto-organizer.d.ts.map +1 -1
  13. package/dist/auto-organizer.js +6 -7
  14. package/dist/auto-organizer.js.map +1 -1
  15. package/dist/bench-prefix.d.ts +16 -0
  16. package/dist/bench-prefix.d.ts.map +1 -0
  17. package/dist/bench-prefix.js +25 -0
  18. package/dist/bench-prefix.js.map +1 -0
  19. package/dist/bot-manager.d.ts +5 -1
  20. package/dist/bot-manager.d.ts.map +1 -1
  21. package/dist/bot-manager.js +46 -27
  22. package/dist/bot-manager.js.map +1 -1
  23. package/dist/chat-sync.d.ts +42 -0
  24. package/dist/chat-sync.d.ts.map +1 -0
  25. package/dist/chat-sync.js +95 -0
  26. package/dist/chat-sync.js.map +1 -0
  27. package/dist/clerk-model.d.ts +7 -0
  28. package/dist/clerk-model.d.ts.map +1 -1
  29. package/dist/clerk-model.js +42 -8
  30. package/dist/clerk-model.js.map +1 -1
  31. package/dist/cli-bootstrap-history.d.ts +10 -0
  32. package/dist/cli-bootstrap-history.d.ts.map +1 -0
  33. package/dist/cli-bootstrap-history.js +112 -0
  34. package/dist/cli-bootstrap-history.js.map +1 -0
  35. package/dist/cli-models.d.ts +8 -0
  36. package/dist/cli-models.d.ts.map +1 -0
  37. package/dist/cli-models.js +91 -0
  38. package/dist/cli-models.js.map +1 -0
  39. package/dist/cli-session-epoch.d.ts +13 -3
  40. package/dist/cli-session-epoch.d.ts.map +1 -1
  41. package/dist/cli-session-epoch.js +53 -4
  42. package/dist/cli-session-epoch.js.map +1 -1
  43. package/dist/cli-session-registry.d.ts +35 -0
  44. package/dist/cli-session-registry.d.ts.map +1 -0
  45. package/dist/cli-session-registry.js +177 -0
  46. package/dist/cli-session-registry.js.map +1 -0
  47. package/dist/cli.js +62 -0
  48. package/dist/cli.js.map +1 -1
  49. package/dist/codex-app-server-manager.d.ts +189 -0
  50. package/dist/codex-app-server-manager.d.ts.map +1 -0
  51. package/dist/codex-app-server-manager.js +1468 -0
  52. package/dist/codex-app-server-manager.js.map +1 -0
  53. package/dist/commands/init.d.ts.map +1 -1
  54. package/dist/commands/init.js +8 -30
  55. package/dist/commands/init.js.map +1 -1
  56. package/dist/commands/pool.d.ts +32 -0
  57. package/dist/commands/pool.d.ts.map +1 -1
  58. package/dist/commands/pool.js +145 -66
  59. package/dist/commands/pool.js.map +1 -1
  60. package/dist/commands/setup.d.ts +4 -1
  61. package/dist/commands/setup.d.ts.map +1 -1
  62. package/dist/commands/setup.js +9 -25
  63. package/dist/commands/setup.js.map +1 -1
  64. package/dist/commands/start.d.ts +21 -0
  65. package/dist/commands/start.d.ts.map +1 -1
  66. package/dist/commands/start.js +559 -63
  67. package/dist/commands/start.js.map +1 -1
  68. package/dist/commands/status.d.ts.map +1 -1
  69. package/dist/commands/status.js +5 -2
  70. package/dist/commands/status.js.map +1 -1
  71. package/dist/completion-marker.d.ts +7 -0
  72. package/dist/completion-marker.d.ts.map +1 -0
  73. package/dist/completion-marker.js +28 -0
  74. package/dist/completion-marker.js.map +1 -0
  75. package/dist/config.d.ts +7 -2
  76. package/dist/config.d.ts.map +1 -1
  77. package/dist/config.js +184 -60
  78. package/dist/config.js.map +1 -1
  79. package/dist/context-window.d.ts +37 -1
  80. package/dist/context-window.d.ts.map +1 -1
  81. package/dist/context-window.js +210 -17
  82. package/dist/context-window.js.map +1 -1
  83. package/dist/live-activity.d.ts +31 -0
  84. package/dist/live-activity.d.ts.map +1 -0
  85. package/dist/live-activity.js +36 -0
  86. package/dist/live-activity.js.map +1 -0
  87. package/dist/local-chat-execution.d.ts +114 -0
  88. package/dist/local-chat-execution.d.ts.map +1 -0
  89. package/dist/local-chat-execution.js +349 -0
  90. package/dist/local-chat-execution.js.map +1 -0
  91. package/dist/local-cli-pty-manager.d.ts +186 -0
  92. package/dist/local-cli-pty-manager.d.ts.map +1 -1
  93. package/dist/local-cli-pty-manager.js +2581 -164
  94. package/dist/local-cli-pty-manager.js.map +1 -1
  95. package/dist/local-conversation-gateway.d.ts +110 -0
  96. package/dist/local-conversation-gateway.d.ts.map +1 -0
  97. package/dist/local-conversation-gateway.js +175 -0
  98. package/dist/local-conversation-gateway.js.map +1 -0
  99. package/dist/local-data.d.ts +276 -5
  100. package/dist/local-data.d.ts.map +1 -1
  101. package/dist/local-data.js +1201 -86
  102. package/dist/local-data.js.map +1 -1
  103. package/dist/local-db.d.ts +6 -0
  104. package/dist/local-db.d.ts.map +1 -1
  105. package/dist/local-db.js +428 -2
  106. package/dist/local-db.js.map +1 -1
  107. package/dist/local-funnel.d.ts.map +1 -1
  108. package/dist/local-funnel.js +6 -5
  109. package/dist/local-funnel.js.map +1 -1
  110. package/dist/local-server.d.ts +55 -0
  111. package/dist/local-server.d.ts.map +1 -1
  112. package/dist/local-server.js +3281 -441
  113. package/dist/local-server.js.map +1 -1
  114. package/dist/managed-process-registry.d.ts +59 -0
  115. package/dist/managed-process-registry.d.ts.map +1 -0
  116. package/dist/managed-process-registry.js +390 -0
  117. package/dist/managed-process-registry.js.map +1 -0
  118. package/dist/mcp/claude-config-writer.d.ts +5 -5
  119. package/dist/mcp/claude-config-writer.d.ts.map +1 -1
  120. package/dist/mcp/claude-config-writer.js +19 -11
  121. package/dist/mcp/claude-config-writer.js.map +1 -1
  122. package/dist/mcp/index.d.ts +4 -2
  123. package/dist/mcp/index.d.ts.map +1 -1
  124. package/dist/mcp/index.js.map +1 -1
  125. package/dist/mcp/sync-cli-config.d.ts +42 -4
  126. package/dist/mcp/sync-cli-config.d.ts.map +1 -1
  127. package/dist/mcp/sync-cli-config.js +497 -17
  128. package/dist/mcp/sync-cli-config.js.map +1 -1
  129. package/dist/message-loop.d.ts +6 -0
  130. package/dist/message-loop.d.ts.map +1 -1
  131. package/dist/message-loop.js +281 -89
  132. package/dist/message-loop.js.map +1 -1
  133. package/dist/mqtt-client.d.ts +44 -1
  134. package/dist/mqtt-client.d.ts.map +1 -1
  135. package/dist/mqtt-client.js +284 -46
  136. package/dist/mqtt-client.js.map +1 -1
  137. package/dist/mqtt-data-relay.d.ts +44 -0
  138. package/dist/mqtt-data-relay.d.ts.map +1 -0
  139. package/dist/mqtt-data-relay.js +106 -0
  140. package/dist/mqtt-data-relay.js.map +1 -0
  141. package/dist/oauth.d.ts.map +1 -1
  142. package/dist/oauth.js +69 -29
  143. package/dist/oauth.js.map +1 -1
  144. package/dist/orchestration/capabilities.d.ts +13 -0
  145. package/dist/orchestration/capabilities.d.ts.map +1 -0
  146. package/dist/orchestration/capabilities.js +152 -0
  147. package/dist/orchestration/capabilities.js.map +1 -0
  148. package/dist/orchestration/dispatch-executor.d.ts +83 -0
  149. package/dist/orchestration/dispatch-executor.d.ts.map +1 -0
  150. package/dist/orchestration/dispatch-executor.js +266 -0
  151. package/dist/orchestration/dispatch-executor.js.map +1 -0
  152. package/dist/orchestration/dispatch-hint.d.ts +134 -0
  153. package/dist/orchestration/dispatch-hint.d.ts.map +1 -0
  154. package/dist/orchestration/dispatch-hint.js +247 -0
  155. package/dist/orchestration/dispatch-hint.js.map +1 -0
  156. package/dist/orchestration/dispatch-runner.d.ts +106 -0
  157. package/dist/orchestration/dispatch-runner.d.ts.map +1 -0
  158. package/dist/orchestration/dispatch-runner.js +604 -0
  159. package/dist/orchestration/dispatch-runner.js.map +1 -0
  160. package/dist/orchestration/dispatch-tools.d.ts +167 -0
  161. package/dist/orchestration/dispatch-tools.d.ts.map +1 -0
  162. package/dist/orchestration/dispatch-tools.js +328 -0
  163. package/dist/orchestration/dispatch-tools.js.map +1 -0
  164. package/dist/orchestration/front-door-policy.d.ts +35 -10
  165. package/dist/orchestration/front-door-policy.d.ts.map +1 -1
  166. package/dist/orchestration/front-door-policy.js +30 -267
  167. package/dist/orchestration/front-door-policy.js.map +1 -1
  168. package/dist/orchestration/orchestrator-dispatch-prompt.d.ts +43 -0
  169. package/dist/orchestration/orchestrator-dispatch-prompt.d.ts.map +1 -0
  170. package/dist/orchestration/orchestrator-dispatch-prompt.js +267 -0
  171. package/dist/orchestration/orchestrator-dispatch-prompt.js.map +1 -0
  172. package/dist/orchestration/orchestrator-operating-prompt.d.ts +15 -0
  173. package/dist/orchestration/orchestrator-operating-prompt.d.ts.map +1 -1
  174. package/dist/orchestration/orchestrator-operating-prompt.js +206 -20
  175. package/dist/orchestration/orchestrator-operating-prompt.js.map +1 -1
  176. package/dist/orchestration/plan-import.d.ts +39 -0
  177. package/dist/orchestration/plan-import.d.ts.map +1 -0
  178. package/dist/orchestration/plan-import.js +547 -0
  179. package/dist/orchestration/plan-import.js.map +1 -0
  180. package/dist/orchestration/validation.d.ts +40 -0
  181. package/dist/orchestration/validation.d.ts.map +1 -0
  182. package/dist/orchestration/validation.js +203 -0
  183. package/dist/orchestration/validation.js.map +1 -0
  184. package/dist/orchestration/worker-operating-prompt.d.ts +2 -0
  185. package/dist/orchestration/worker-operating-prompt.d.ts.map +1 -1
  186. package/dist/orchestration/worker-operating-prompt.js +36 -46
  187. package/dist/orchestration/worker-operating-prompt.js.map +1 -1
  188. package/dist/orchestrator.d.ts +214 -33
  189. package/dist/orchestrator.d.ts.map +1 -1
  190. package/dist/orchestrator.js +2200 -1100
  191. package/dist/orchestrator.js.map +1 -1
  192. package/dist/providers/anthropic.d.ts.map +1 -1
  193. package/dist/providers/anthropic.js +8 -4
  194. package/dist/providers/anthropic.js.map +1 -1
  195. package/dist/providers/claude-cli-prompt.d.ts.map +1 -1
  196. package/dist/providers/claude-cli-prompt.js +49 -5
  197. package/dist/providers/claude-cli-prompt.js.map +1 -1
  198. package/dist/providers/claude-cli.d.ts.map +1 -1
  199. package/dist/providers/claude-cli.js +81 -5
  200. package/dist/providers/claude-cli.js.map +1 -1
  201. package/dist/providers/codex-cli.d.ts +10 -6
  202. package/dist/providers/codex-cli.d.ts.map +1 -1
  203. package/dist/providers/codex-cli.js +204 -26
  204. package/dist/providers/codex-cli.js.map +1 -1
  205. package/dist/providers/google.d.ts.map +1 -1
  206. package/dist/providers/google.js +15 -5
  207. package/dist/providers/google.js.map +1 -1
  208. package/dist/providers/index.d.ts +15 -1
  209. package/dist/providers/index.d.ts.map +1 -1
  210. package/dist/providers/index.js.map +1 -1
  211. package/dist/providers/openai.d.ts +1 -1
  212. package/dist/providers/openai.d.ts.map +1 -1
  213. package/dist/providers/openai.js +13 -5
  214. package/dist/providers/openai.js.map +1 -1
  215. package/dist/response-guard.js +1 -1
  216. package/dist/response-guard.js.map +1 -1
  217. package/dist/server-adapter.d.ts +8 -0
  218. package/dist/server-adapter.d.ts.map +1 -1
  219. package/dist/server-adapter.js +7 -0
  220. package/dist/server-adapter.js.map +1 -1
  221. package/dist/service-mode.d.ts +1 -1
  222. package/dist/service-mode.d.ts.map +1 -1
  223. package/dist/service-mode.js +64 -1
  224. package/dist/service-mode.js.map +1 -1
  225. package/dist/service-setup-only.d.ts +8 -0
  226. package/dist/service-setup-only.d.ts.map +1 -0
  227. package/dist/service-setup-only.js +37 -0
  228. package/dist/service-setup-only.js.map +1 -0
  229. package/dist/slash-commands.d.ts +21 -0
  230. package/dist/slash-commands.d.ts.map +1 -0
  231. package/dist/slash-commands.js +99 -0
  232. package/dist/slash-commands.js.map +1 -0
  233. package/dist/subagent/index.d.ts +4 -2
  234. package/dist/subagent/index.d.ts.map +1 -1
  235. package/dist/subagent/index.js.map +1 -1
  236. package/dist/summarization-pipeline.d.ts.map +1 -1
  237. package/dist/summarization-pipeline.js +1 -9
  238. package/dist/summarization-pipeline.js.map +1 -1
  239. package/dist/token-counter.d.ts.map +1 -1
  240. package/dist/token-counter.js +11 -4
  241. package/dist/token-counter.js.map +1 -1
  242. package/dist/tool-filter.d.ts.map +1 -1
  243. package/dist/tool-filter.js +10 -6
  244. package/dist/tool-filter.js.map +1 -1
  245. package/dist/tools/admin-tools.d.ts.map +1 -1
  246. package/dist/tools/admin-tools.js +20 -5
  247. package/dist/tools/admin-tools.js.map +1 -1
  248. package/dist/tools/index.d.ts.map +1 -1
  249. package/dist/tools/index.js +2 -1
  250. package/dist/tools/index.js.map +1 -1
  251. package/dist/tools/run-command.d.ts.map +1 -1
  252. package/dist/tools/run-command.js +5 -1
  253. package/dist/tools/run-command.js.map +1 -1
  254. package/dist/tools/search-conversation-history.d.ts +16 -0
  255. package/dist/tools/search-conversation-history.d.ts.map +1 -0
  256. package/dist/tools/search-conversation-history.js +334 -0
  257. package/dist/tools/search-conversation-history.js.map +1 -0
  258. package/dist/tools/todo-tasks.d.ts.map +1 -1
  259. package/dist/tools/todo-tasks.js +77 -5
  260. package/dist/tools/todo-tasks.js.map +1 -1
  261. package/dist/usage-log.d.ts +62 -0
  262. package/dist/usage-log.d.ts.map +1 -0
  263. package/dist/usage-log.js +98 -0
  264. package/dist/usage-log.js.map +1 -0
  265. package/dist/wizard-state.d.ts +20 -0
  266. package/dist/wizard-state.d.ts.map +1 -1
  267. package/dist/wizard-state.js +90 -3
  268. package/dist/wizard-state.js.map +1 -1
  269. package/dist/wizard-support.d.ts.map +1 -1
  270. package/dist/wizard-support.js +27 -1
  271. package/dist/wizard-support.js.map +1 -1
  272. package/dist/workflow-engine.d.ts +44 -2
  273. package/dist/workflow-engine.d.ts.map +1 -1
  274. package/dist/workflow-engine.js +932 -111
  275. package/dist/workflow-engine.js.map +1 -1
  276. package/package.json +2 -2
@@ -1,286 +1,49 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.inferFrontDoorTaskType = inferFrontDoorTaskType;
4
- exports.isContextualWorkerReferencePrompt = isContextualWorkerReferencePrompt;
5
4
  exports.extractFrontDoorSignals = extractFrontDoorSignals;
5
+ exports.isContextualWorkerReferencePrompt = isContextualWorkerReferencePrompt;
6
6
  exports.applyFrontDoorPolicy = applyFrontDoorPolicy;
7
- function normalize(value) {
8
- return String(value || '').trim().toLowerCase();
9
- }
10
- function escapeRegex(text) {
11
- return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
12
- }
13
- function uniqueStrings(values) {
14
- return Array.from(new Set(values.map((value) => value.trim()).filter(Boolean)));
15
- }
16
- function matchWholeTerm(prompt, term) {
17
- const normalizedTerm = normalize(term);
18
- if (!normalizedTerm)
19
- return false;
20
- const escaped = escapeRegex(normalizedTerm);
21
- return new RegExp(`(^|[^a-z0-9])${escaped}([^a-z0-9]|$)`, 'i').test(prompt);
22
- }
23
- function promptNamesWorkflow(prompt, workflowNames) {
24
- return uniqueStrings((workflowNames || []).filter((name) => matchWholeTerm(prompt, name)));
25
- }
26
- function matchSpecialistNames(prompt, specialists) {
27
- return uniqueStrings((specialists || [])
28
- .filter((specialist) => [specialist.name, ...(specialist.references || [])].some((name) => matchWholeTerm(prompt, name)))
29
- .map((specialist) => specialist.name));
30
- }
31
- function roleTermsForSpecialists(specialists) {
32
- const termsByRole = {
33
- coding: new Set(['coder', 'coding']),
34
- qa: new Set(['qa']),
35
- research: new Set(['brainstorm', 'brainstorming', 'research', 'planning']),
7
+ function emptySignals() {
8
+ return {
9
+ matchedBots: [],
10
+ matchedRoles: [],
11
+ matchedWorkflowNames: [],
12
+ explicitTodoKeyword: false,
13
+ explicitWorkflowKeyword: false,
14
+ explicitDelegationKeyword: false,
15
+ explicitOrchestrationRequested: false,
16
+ preferredMode: null,
17
+ preferredTarget: null,
36
18
  };
37
- for (const specialist of specialists || []) {
38
- const roleLabel = normalize(specialist.roleLabel);
39
- if (roleLabel === 'qa') {
40
- termsByRole.qa.add('quality assurance');
41
- }
42
- else if (roleLabel === 'research' || roleLabel === 'planning' || roleLabel === 'brainstorm') {
43
- termsByRole.research.add(roleLabel);
44
- }
45
- else if (roleLabel === 'code' || roleLabel === 'coding') {
46
- termsByRole.coding.add(roleLabel);
47
- }
48
- }
49
- return [
50
- { role: 'coding', terms: Array.from(termsByRole.coding) },
51
- { role: 'qa', terms: Array.from(termsByRole.qa) },
52
- { role: 'research', terms: Array.from(termsByRole.research) },
53
- ];
54
- }
55
- function matchRoles(prompt, specialists) {
56
- const matched = [];
57
- for (const entry of roleTermsForSpecialists(specialists)) {
58
- if (entry.terms.some((term) => matchWholeTerm(prompt, term))) {
59
- matched.push(entry.role);
60
- }
61
- }
62
- return matched;
63
19
  }
64
- function inferFrontDoorTaskType(prompt) {
65
- if (/\b(from now on|by default|set (?:the )?default workflow|save (?:this|it) as (?:the )?default workflow|default qa|default research|default coder)\b/i.test(prompt))
66
- return 'policy';
67
- if (/\b(status|progress|what(?:'s| is) happening|where are we|is it done|how far along)\b/i.test(prompt))
68
- return 'status';
69
- const hasQa = /\b(qa(?:'d|ed|ing)?|review|test|verify|verification|audit)\b/i.test(prompt);
70
- const hasCoding = /\b(build|code|implement|create|fix|update|edit|change|refactor|ship|deploy|make|add|remove|rename|wire up|hook up)\b/i.test(prompt);
71
- const hasResearch = /\b(brainstorm(?:ing)?|research(?:es|ed|ing)?|investigate|analy[sz]e|evaluate|compare|feasibility|plan|planning)\b/i.test(prompt);
72
- if (hasQa && !hasCoding && !hasResearch)
73
- return 'qa';
74
- if (hasResearch && !hasCoding)
75
- return 'research';
76
- if (hasCoding && (hasQa || hasResearch))
77
- return 'mixed';
78
- if (hasCoding)
79
- return 'coding';
20
+ /** DEPRECATED — returns 'conversation'. Codex #5: no regex task typing. */
21
+ function inferFrontDoorTaskType(_prompt) {
80
22
  return 'conversation';
81
23
  }
82
- function countAssignedRoles(assignments) {
83
- if (!assignments)
84
- return 0;
85
- let count = 0;
86
- if (assignments.coding)
87
- count += 1;
88
- if (assignments.qa)
89
- count += 1;
90
- if (assignments.research)
91
- count += 1;
92
- return count;
93
- }
94
- function isAdvisoryPrompt(prompt) {
95
- return /\bwhat do you think|can we|should we|do you agree|need to discuss|discuss more|is this a good idea|is this sound|thoughts\??|recommend(?:ation)?\b/i.test(prompt);
96
- }
97
- function isContextualWorkerReferencePrompt(prompt) {
98
- return /\b(i want you to|please|can you|could you)\b[\s\S]{0,80}\b(look at|review|check|inspect|verify)\b/i.test(prompt)
99
- && /\b(made|did|wrote|created|changed|updated|fixed|committed|worked on)\b/i.test(prompt);
24
+ /** DEPRECATED — returns empty signals. Codex #5: no regex signal extraction. */
25
+ function extractFrontDoorSignals(_input) {
26
+ return emptySignals();
100
27
  }
101
- function resolvePreferredTarget(matchedBots, matchedRoles, roleAssignments) {
102
- if (matchedBots.length === 1)
103
- return matchedBots[0];
104
- if (matchedRoles.length === 1) {
105
- const role = matchedRoles[0];
106
- return roleAssignments?.[role] || null;
107
- }
108
- return null;
109
- }
110
- function extractFrontDoorSignals(input) {
111
- const prompt = String(input.prompt || '');
112
- const matchedBots = matchSpecialistNames(prompt, input.specialists);
113
- const matchedRoles = matchRoles(prompt, input.specialists);
114
- const matchedWorkflowNames = promptNamesWorkflow(prompt, input.workflowNames);
115
- const explicitTodoKeyword = /\b(todo|to-?do|task list)\b/i.test(prompt);
116
- const explicitWorkflowKeyword = /\bworkflow\b/i.test(prompt);
117
- const explicitDelegationKeyword = /\b(delegate|delegation|assign(?:ed|ment)?|handoff|hand off)\b/i.test(prompt);
118
- const explicitOrchestrationRequested = explicitTodoKeyword || explicitWorkflowKeyword || explicitDelegationKeyword || matchedWorkflowNames.length > 0;
119
- const multiWorkerSignal = matchedBots.length >= 2 || matchedRoles.length >= 2;
120
- const preferredMode = matchedWorkflowNames.length > 0
121
- ? 'workflow'
122
- : explicitOrchestrationRequested
123
- ? (multiWorkerSignal ? 'workflow' : ((matchedBots.length === 1 || matchedRoles.length === 1) ? 'delegate' : null))
124
- : null;
125
- const preferredTarget = preferredMode === 'delegate'
126
- ? resolvePreferredTarget(matchedBots, matchedRoles, input.roleAssignments)
127
- : null;
128
- return {
129
- matchedBots,
130
- matchedRoles,
131
- matchedWorkflowNames,
132
- explicitTodoKeyword,
133
- explicitWorkflowKeyword,
134
- explicitDelegationKeyword,
135
- explicitOrchestrationRequested,
136
- preferredMode,
137
- preferredTarget,
138
- };
28
+ /** DEPRECATED returns false. Codex #5: no regex review-prompt detection. */
29
+ function isContextualWorkerReferencePrompt(_prompt) {
30
+ return false;
139
31
  }
140
32
  /**
141
- * Front-door policy:
142
- * - default to direct orchestrator ownership unless there is strong positive
143
- * evidence for delegate/workflow routing
144
- * - explicit orchestration requests should not silently fall through to execute_self
145
- * - a single named worker/role can justify delegate when the task is clearly
146
- * actionable and worker-owned
147
- * - multi-worker or named workflow requests prefer workflow
33
+ * DEPRECATED — returns the LLM's initial decision unchanged. Codex #5:
34
+ * runtime must not override LLM mode via regex on the user prompt.
35
+ * The orchestrator LLM's front-door decision is the source of truth.
148
36
  */
149
37
  function applyFrontDoorPolicy(input) {
150
- const prompt = String(input.prompt || '');
151
- const taskType = inferFrontDoorTaskType(prompt);
152
- const signals = extractFrontDoorSignals({
153
- prompt,
154
- specialists: input.specialists,
155
- workflowNames: input.workflowNames,
156
- roleAssignments: input.roleAssignments,
157
- });
158
- const initial = { ...input.initialDecision };
159
- let decision = { ...input.initialDecision };
160
- let correctionReason;
161
- const promptAssignedRoleCount = countAssignedRoles(input.promptAssignments);
162
- const mapsToWorkerRole = taskType === 'coding' || taskType === 'qa' || taskType === 'research';
163
- const nonDelegableTask = taskType === 'conversation'
164
- || taskType === 'status'
165
- || taskType === 'policy';
166
- const multiWorkerRequested = signals.matchedBots.length >= 2
167
- || signals.matchedRoles.length >= 2
168
- || taskType === 'mixed'
169
- || promptAssignedRoleCount >= 2;
170
- const singleWorkerSignal = signals.matchedBots.length === 1
171
- || signals.matchedRoles.length === 1
172
- || promptAssignedRoleCount === 1;
173
- const strongSingleWorkerRequested = !nonDelegableTask
174
- && !isAdvisoryPrompt(prompt)
175
- && !isContextualWorkerReferencePrompt(prompt)
176
- && singleWorkerSignal;
177
- const fallbackTarget = resolvePreferredTarget(signals.matchedBots, signals.matchedRoles, input.roleAssignments);
178
- const advisoryOnly = initial.mode === 'respond'
179
- && isAdvisoryPrompt(prompt)
180
- && !signals.explicitTodoKeyword
181
- && !signals.explicitWorkflowKeyword
182
- && !signals.explicitDelegationKeyword
183
- && signals.matchedWorkflowNames.length === 0;
184
- if (advisoryOnly) {
185
- // Preserve conversational advisory responses even if the text contains
186
- // planning words like "plan" or "first".
187
- }
188
- else if (initial.mode === 'clarify' && (signals.explicitOrchestrationRequested || multiWorkerRequested)) {
189
- // Preserve clarify when the request clearly needs worker/workflow execution
190
- // but the model determined required details are still missing.
191
- }
192
- else if (signals.matchedWorkflowNames.length > 0 || multiWorkerRequested) {
193
- if (initial.mode !== 'workflow') {
194
- decision = {
195
- mode: 'workflow',
196
- reason: signals.matchedWorkflowNames.length > 0
197
- ? 'Code-based front door matched a named workflow in the user prompt.'
198
- : 'Code-based front door found a multi-worker or staged task that should run as a workflow.',
199
- workflow_request: initial.workflow_request || prompt,
200
- };
201
- correctionReason = decision.reason;
202
- }
203
- }
204
- else if (initial.mode !== 'clarify'
205
- && strongSingleWorkerRequested
206
- && Boolean(signals.preferredTarget || fallbackTarget)) {
207
- const delegateTarget = signals.preferredTarget || fallbackTarget;
208
- if (delegateTarget && (initial.mode !== 'delegate' || normalize(initial.delegate_target) !== normalize(delegateTarget))) {
209
- const delegateRole = signals.matchedRoles[0]
210
- || (normalize(delegateTarget) === normalize(input.roleAssignments?.qa) ? 'qa'
211
- : normalize(delegateTarget) === normalize(input.roleAssignments?.research) ? 'research'
212
- : taskType === 'qa'
213
- ? 'qa'
214
- : taskType === 'research'
215
- ? 'research'
216
- : 'coding');
217
- decision = {
218
- mode: 'delegate',
219
- reason: signals.explicitOrchestrationRequested
220
- ? 'Code-based front door found an explicit single-worker TODO/workflow request.'
221
- : 'Code-based front door found a clear single-worker assignment in the user prompt.',
222
- delegate_target: delegateTarget,
223
- delegate_role: delegateRole,
224
- delegate_request: initial.delegate_request || prompt,
225
- };
226
- correctionReason = decision.reason;
227
- }
228
- }
229
- else if (!signals.explicitOrchestrationRequested) {
230
- if (initial.mode === 'workflow' || initial.mode === 'delegate') {
231
- decision = {
232
- mode: 'execute_self',
233
- reason: 'No strong delegation or workflow evidence was found. Handle it directly.',
234
- };
235
- correctionReason = decision.reason;
236
- }
237
- else if (initial.mode === 'clarify' && !mapsToWorkerRole) {
238
- decision = {
239
- mode: 'execute_self',
240
- reason: 'Converted clarify to execute_self. This is not a worker workflow request.',
241
- };
242
- correctionReason = decision.reason;
243
- }
244
- else if (initial.mode === 'respond') {
245
- const resp = String(initial.response || '').toLowerCase();
246
- const hasOrchestrationLanguage = /which (worker|bot|agent|specialist)|ready to coordinate|get the right bots|need a few details|before i start|i need to know|which .* should handle/i.test(resp);
247
- if (hasOrchestrationLanguage) {
248
- if (multiWorkerRequested) {
249
- decision = {
250
- mode: 'workflow',
251
- reason: 'Respond contained orchestration language. Route this staged worker task as a workflow.',
252
- workflow_request: prompt,
253
- };
254
- }
255
- else if (fallbackTarget) {
256
- decision = {
257
- mode: 'delegate',
258
- reason: 'Respond contained orchestration language. Route the worker task instead of asking who should own it.',
259
- delegate_target: fallbackTarget,
260
- delegate_role: taskType === 'qa' ? 'qa' : taskType === 'research' ? 'research' : 'coding',
261
- delegate_request: prompt,
262
- };
263
- }
264
- else {
265
- decision = {
266
- mode: 'execute_self',
267
- reason: 'Respond contained orchestration language. Handle it directly instead.',
268
- };
269
- }
270
- correctionReason = decision.reason;
271
- }
272
- }
273
- }
274
- const corrected = JSON.stringify(decision) !== JSON.stringify(initial);
275
38
  return {
276
- decision,
277
- corrected,
278
- correctionReason,
279
- taskType,
39
+ decision: { ...input.initialDecision },
40
+ corrected: false,
41
+ correctionReason: undefined,
42
+ taskType: 'conversation',
280
43
  qaMode: 'none',
281
- preferredWorkflowRequested: signals.matchedWorkflowNames.length > 0,
282
- explicitWorkflowRequested: signals.explicitOrchestrationRequested,
283
- signals,
44
+ preferredWorkflowRequested: false,
45
+ explicitWorkflowRequested: false,
46
+ signals: emptySignals(),
284
47
  };
285
48
  }
286
49
  //# sourceMappingURL=front-door-policy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"front-door-policy.js","sourceRoot":"","sources":["../../src/orchestration/front-door-policy.ts"],"names":[],"mappings":";;AA4GA,wDAWC;AAeD,8EAGC;AAeD,0DA+BC;AAWD,oDA8IC;AAlSD,SAAS,SAAS,CAAC,KAAgC;IACjD,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAClD,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,aAAa,CAAC,MAAgB;IACrC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,cAAc,CAAC,MAAc,EAAE,IAAY;IAClD,MAAM,cAAc,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,CAAC,cAAc;QAAE,OAAO,KAAK,CAAC;IAClC,MAAM,OAAO,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC;IAC5C,OAAO,IAAI,MAAM,CAAC,gBAAgB,OAAO,eAAe,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAc,EAAE,aAAmC;IAC9E,OAAO,aAAa,CAAC,CAAC,aAAa,IAAI,EAAE,CAAC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ACzF,gBAAgB,EAAE,MAAM;qBACzB,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,QAAQ,GAAG;wBACT,IAAI,EAAE,cAAc;wBACpB,MAAM,EAAE,uEAAuE;qBAChF,CAAC;gBACJ,CAAC;gBACD,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAC;YACrC,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACvE,OAAO;QACL,QAAQ;QACR,SAAS;QACT,gBAAgB;QAChB,QAAQ;QACR,MAAM,EAAE,MAAM;QACd,0BAA0B,EAAE,OAAO,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC;QACnE,yBAAyB,EAAE,OAAO,CAAC,8BAA8B;QACjE,OAAO;KACR,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"front-door-policy.js","sourceRoot":"","sources":["../../src/orchestration/front-door-policy.ts"],"names":[],"mappings":";;AAwFA,wDAEC;AAGD,0DAEC;AAGD,8EAEC;AAOD,oDAWC;AA7CD,SAAS,YAAY;IACnB,OAAO;QACL,WAAW,EAAE,EAAE;QACf,YAAY,EAAE,EAAE;QAChB,oBAAoB,EAAE,EAAE;QACxB,mBAAmB,EAAE,KAAK;QAC1B,uBAAuB,EAAE,KAAK;QAC9B,yBAAyB,EAAE,KAAK;QAChC,8BAA8B,EAAE,KAAK;QACrC,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,IAAI;KACtB,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,SAAgB,sBAAsB,CAAC,OAAe;IACpD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,gFAAgF;AAChF,SAAgB,uBAAuB,CAAC,MAA4B;IAClE,OAAO,YAAY,EAAE,CAAC;AACxB,CAAC;AAED,8EAA8E;AAC9E,SAAgB,iCAAiC,CAAC,OAAe;IAC/D,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,KAA2B;IAC9D,OAAO;QACL,QAAQ,EAAE,EAAE,GAAG,KAAK,CAAC,eAAe,EAAE;QACtC,SAAS,EAAE,KAAK;QAChB,gBAAgB,EAAE,SAAS;QAC3B,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,MAAM;QACd,0BAA0B,EAAE,KAAK;QACjC,yBAAyB,EAAE,KAAK;QAChC,OAAO,EAAE,YAAY,EAAE;KACxB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Orchestrator system prompt for the tool-dispatch path.
3
+ *
4
+ * Post-2026-04-19 rewrite: replaces the old contradictory prompt that
5
+ * promised a worker-toolkit the dispatch runner didn't actually expose,
6
+ * with Steven's explicit rule:
7
+ *
8
+ * "If you have something that needs doing, do it yourself unless you
9
+ * have a bot that is designed for this role. So we tell the LLM 'do
10
+ * it yourself' and give the exceptions from settings."
11
+ *
12
+ * The role-based exceptions list is built dynamically from the hint's
13
+ * active bots + their orchestration_roles_json. If a role has no
14
+ * configured bot in the current conversation, the orchestrator handles
15
+ * that role itself.
16
+ */
17
+ import type { DispatchHint } from './dispatch-hint';
18
+ export interface BuildOrchestratorDispatchPromptInput {
19
+ hint: DispatchHint;
20
+ /** Optional extra guidance appended after the core prompt body. */
21
+ additionalGuidance?: string | null;
22
+ }
23
+ /**
24
+ * Build the full system prompt for an orchestrator turn.
25
+ *
26
+ * Output shape:
27
+ * [Orchestrator Operating Prompt]
28
+ * <static body>
29
+ *
30
+ * <dynamic roles-with-a-dedicated-bot section>
31
+ *
32
+ * [Additional Guidance] — if provided
33
+ * <soul_md or bot-specific text>
34
+ *
35
+ * [Hint Block]
36
+ * <JSON-stringified hint>
37
+ *
38
+ * [End of Hint]
39
+ */
40
+ export declare function buildOrchestratorDispatchPrompt(input: BuildOrchestratorDispatchPromptInput): string;
41
+ /** Export the static body for tests. */
42
+ export declare const ORCHESTRATOR_DISPATCH_PROMPT_BODY = "You are the orchestrator for a Funolio multi-bot conversation.\n\nYour job: understand the user's request, decide whether to handle it yourself or\ndelegate to a worker bot, and return a structured tool call. The user's prompt\nis authoritative \u2014 treat it as such.\n\nOPERATING RULE\n\nYou handle every request yourself UNLESS it falls under one of the capabilities\nlisted below in CAPABILITIES WITH A DEDICATED BOT. For those capabilities,\ndelegate to the bot that owns that priority.\n\nAnything outside the listed capabilities \u2014 reading a file, summarizing, answering a\nquestion, giving status, writing a short reply, clarifying something \u2014 you do\ndirectly. You have read-side tools for this:\n\n - read_file, list_directory, search_codebase \u2014 inspect the project.\n - search_local_memory \u2014 look up stored project memory.\n - list_tasks \u2014 see the current TODO queue.\n - web_search, web_fetch \u2014 external info.\n\nUse these tools freely when you need context to answer. When you're done\ngathering context, end the turn with reply_directly.\n\nWRITE-SIDE WORK (creating or changing files, running commands) IS NOT\navailable to you directly \u2014 those are role-specific jobs. Delegate them to\nthe appropriate bot from the list below via delegate_single or\ncreate_workflow.\n\nMULTI-TURN FLOW\n\nIf you need multiple pieces of context, call the read-side tools across\nmultiple turns. Funolio feeds each tool's result back to you automatically.\nOnly when you have what you need, end the conversation with exactly one\nof the three dispatch tools.\n\nDo NOT mix a read-side tool call with a dispatch tool call in the same\nturn \u2014 that's ambiguous and will be rejected. Gather first, then\ndispatch on a subsequent turn.\n\nTHREE DISPATCH TOOLS\n\nEvery turn ends by calling exactly ONE of these three tools:\n\n reply_directly(text)\n Your answer to the user. Use for questions, clarifications, status,\n summaries, greetings, and anything that does not require a role-specific\n bot. The text you provide becomes the user's reply.\n\n delegate_single(task_instructions, bot_name?, role?, success_criteria?)\n Delegate a single task to one worker bot. Creates one TODO.\n Provide at least one of bot_name or role.\n - bot_name routes to that specific bot.\n - role picks the highest-priority bot for that role.\n - When both are provided, bot_name wins.\n Optional title may be supplied for the TODO label.\n task_instructions must include every concrete reference the worker\n needs \u2014 file paths, URLs, artifact names, the relevant user spec \u2014\n so the worker can act without prospecting for context.\n\n create_workflow(steps[])\n Create an ordered multi-step workflow. Use when the user needs multiple\n roles in sequence (e.g. research \u2192 coding \u2192 QA \u2192 verify).\n Each step requires task_instructions plus bot_name or role.\n Each step may include a short title for the TODO label.\n Optional handoff_to_next passes context from one step's worker to the\n next worker's task prompt. Each step's task_instructions must carry\n concrete references for that worker.\n\nIf the hint includes selected_workflow_template or candidate_workflow_plan,\nFunolio detected an obvious user-requested workflow candidate. Treat it as a\nsuggestion, not a command. Approve it by calling create_workflow with the\nlisted steps, modify it by calling create_workflow with corrected steps, or\nreject it with reply_directly if the candidate is wrong or unclear.\n\nIf the hint also shows existing_todos that match the candidate, Funolio has\nalready created visible proposed TODOs but has NOT started any workers. In\nthat case you do not need to call a dispatch tool just to approve the proposal.\nIf it is correct, reply with exactly: APPROVE_PROPOSED_WORKFLOW. If it is\nwrong or unclear, reply with exactly: REJECT_PROPOSED_WORKFLOW followed by one\nshort reason. If you need edits, call create_workflow with the corrected plan.\n\nFor selected_workflow_template, the user explicitly selected or named that\nsaved workflow. If you agree, keep exactly the listed step order and bot_name\nvalues. You author each step's title and task_instructions from the user's\nrequest and the intended role of that bot. Do not emit generic labels like\n\"Complete Ben's workflow step\", \"Coding\", \"QA\", or \"Verify\". The saved\ntemplate provides bot order; it is not a substitute for your per-run task\nwriting.\n\nTODO COMPLETION RULE\n\nDo NOT call complete_worker_task or block_worker_task. Those are the worker's\ntools for reporting status on their own TODO. The orchestrator calling them\nwould mark a worker's task done without the worker actually doing it.\n\nRare exception \u2014 deliberate override: if a worker is permanently stuck and\nthe user has explicitly asked you to clean up the stuck TODO, call\ncomplete_worker_task or block_worker_task with a clear reason. The system\nlogs these to the orchestration audit trail.\n\nQA PASS/FAIL\n\nWorkers declare QA pass/fail via the qa_result argument on\ncomplete_worker_task \u2014 not via prose. As the orchestrator you do not\nclassify worker output; you trust the structured signal. If QA passes,\nthe workflow continues. If QA fails, the runtime auto-creates a fix\ntask + re-QA cycle based on the worker's findings.\n\nHINT BLOCK\n\nEvery turn includes a structured context block containing the user prompt,\nconversation metadata, available bots with their role priority lists,\nexisting TODOs, and effective policy. The `advisory` sub-block contains\nheuristic keyword suggestions \u2014 treat it as advisory only; trust the user\nprompt and the available bots list.\n\nWhen the hint includes `conversation.recent_turns`, read those turns before\ndeciding. They are especially important for stateless/API orchestrators when the\nuser refers to \"the page\", \"that file\", \"the last fix\", or similar shorthand.\n\nWhen the hint includes `conversation.bootstrap_history_file`, read that file\nfor context. This is used for fresh CLI orchestrator sessions. Use it for\ncontext only and do not mention the file path unless the user asks.\n\nPLAN FILE EXECUTION\n\nWhen the hint includes `plan_execution_intent.mode`:\n\n - `per_step_todos`\n The user explicitly wants a file/plan expanded into sequential worker TODOs.\n First read the referenced file. Only do this if the file actually contains\n structured steps (numbered items, lettered items, bullet items, or clearly\n separated actionable sections). Then create ONE ordered workflow where each\n parsed file step is expanded through the user-requested worker sequence.\n Example: if the user asked for Ben coding then John QA, file step 1 becomes\n Ben step 1 -> John QA step 1, file step 2 becomes Ben step 2 -> John QA step 2.\n Do not collapse the entire file into one coarse TODO.\n\n - `per_step_workflow`\n The user explicitly wants each file step to run through the selected or\n named workflow template. First read the referenced file. Only proceed if\n the file actually contains structured steps. Then expand EACH parsed file\n step through the saved workflow order. Example: if the selected workflow is\n Brain -> Ben -> John, file step 1 becomes Brain step 1 -> Ben step 1 ->\n John step 1; then file step 2 repeats the same workflow order.\n If no selected/named workflow is actually available, ask the user to pick\n one instead of guessing.\n\nIf the file is not structured enough to identify separate steps, reply_directly\nand ask the user to clarify or reformat the plan instead of guessing.\n\nWhen this orchestrator runs through an API provider (OpenAI, Anthropic API,\nGoogle Gemini, etc.), the hint block that reaches the provider includes\nlocal project path metadata (project_folder). That's deliberate \u2014 the path\nlets you write accurate task_instructions for workers.\n\nROLE-BASED DISPATCH DETAILS\n\nWhen you use `role` without naming a bot, the dispatcher picks the\nhighest-priority bot for that role from the available_bots list in the\nhint. Ties break toward bots that don't already have active TODOs in this\nconversation.\n\nRole strings are matched case-insensitively after whitespace normalization.\n\"QA\" == \"qa\" == \" QA \". There is no alias table \u2014 use the exact role labels\nfrom the `role_priorities` of the bots in the hint.\n\nNATIVE TOOL CALLS VS TEXT FALLBACK\n\nIf your provider supports native tool calls (Anthropic API, OpenAI API,\nGoogle Gemini API, etc.), invoke one of the three dispatch tools directly.\n\nIf your provider does NOT support native tool calls (Claude CLI, Codex CLI,\nor any other text-only interface), emit exactly ONE fenced JSON block as\nyour ENTIRE response, with no prose before or after:\n\n ```json\n {\"tool\": \"delegate_single\", \"arguments\": {\"bot_name\": \"Ben\", \"task_instructions\": \"Fix the login bug in C:\\\\Projects\\\\app\\\\login.ts\"}}\n ```\n\nThe shape must be:\n - `tool`: one of \"reply_directly\", \"delegate_single\", \"create_workflow\"\n - `arguments`: the same fields documented above for that tool\n\nFunolio parses this block identically to a native tool call \u2014 same\nvalidators, same executor, same audit trail. Emit exactly one block per\nturn.";
43
+ //# sourceMappingURL=orchestrator-dispatch-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator-dispatch-prompt.d.ts","sourceRoot":"","sources":["../../src/orchestration/orchestrator-dispatch-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,iBAAiB,CAAC;AA+LlE,MAAM,WAAW,oCAAoC;IACnD,IAAI,EAAE,YAAY,CAAC;IACnB,mEAAmE;IACnE,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAwCD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,GAAG,MAAM,CAcnG;AAED,wCAAwC;AACxC,eAAO,MAAM,iCAAiC,mqSAAqB,CAAC"}