toolroll 0.9.54 → 0.9.56

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 (350) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +29 -12
  3. package/dist/action-ledger.d.ts +2 -4
  4. package/dist/action-ledger.js +2 -10
  5. package/dist/agent-onboard.js +4 -1
  6. package/dist/approval-policy.d.ts +5 -5
  7. package/dist/approval-policy.js +4 -4
  8. package/dist/approval-rules-ui.d.ts +3 -2
  9. package/dist/approval-rules-ui.js +17 -22
  10. package/dist/assignment-ui.d.ts +3 -2
  11. package/dist/assignment-ui.js +4 -11
  12. package/dist/backup-ui.d.ts +2 -1
  13. package/dist/backup-ui.js +16 -27
  14. package/dist/brand-mark.d.ts +3 -2
  15. package/dist/brand-mark.js +4 -4
  16. package/dist/browser/workspace.css +1 -1
  17. package/dist/browser/workspace.js +25 -25
  18. package/dist/browser-shell.d.ts +2 -1
  19. package/dist/browser-shell.js +9 -9
  20. package/dist/browser-workspace.d.ts +14 -15
  21. package/dist/browser-workspace.js +0 -3
  22. package/dist/budget-alerts.js +3 -3
  23. package/dist/chat-actions.d.ts +23 -18
  24. package/dist/chat-actions.js +110 -88
  25. package/dist/chat-ask.d.ts +2 -2
  26. package/dist/chat-ask.js +5 -5
  27. package/dist/chat-channel.d.ts +15 -15
  28. package/dist/chat-channel.js +20 -20
  29. package/dist/chat-controls.d.ts +0 -4
  30. package/dist/chat-controls.js +0 -1
  31. package/dist/chat-core.js +1 -1
  32. package/dist/chat-delivery-state.js +2 -2
  33. package/dist/chat-delivery.d.ts +2 -2
  34. package/dist/chat-delivery.js +27 -34
  35. package/dist/chat-flow.js +3 -3
  36. package/dist/chat-messages.d.ts +1 -1
  37. package/dist/chat-messages.js +4 -4
  38. package/dist/chat-migration.d.ts +1 -1
  39. package/dist/chat-migration.js +11 -11
  40. package/dist/chat-polish.d.ts +5 -4
  41. package/dist/chat-polish.js +9 -10
  42. package/dist/chat-rooms.js +3 -3
  43. package/dist/chat-warmth.d.ts +2 -2
  44. package/dist/check-levels-ui.d.ts +2 -1
  45. package/dist/check-levels-ui.js +26 -53
  46. package/dist/cli.d.ts +3 -1
  47. package/dist/cli.js +15 -10
  48. package/dist/coding-shipping-ui.d.ts +2 -1
  49. package/dist/coding-shipping-ui.js +6 -6
  50. package/dist/coding-ui.d.ts +3 -1
  51. package/dist/coding-ui.js +30 -29
  52. package/dist/contracts/chat-actions.d.ts +32 -27
  53. package/dist/contracts/chat-actions.js +29 -11
  54. package/dist/contracts/chat-content.d.ts +1 -1
  55. package/dist/contracts/chat-content.js +1 -1
  56. package/dist/contracts/chat-tables.js +4 -4
  57. package/dist/contracts/cli.d.ts +1 -3
  58. package/dist/contracts/console-api.d.ts +7 -7
  59. package/dist/contracts/console-api.js +13 -12
  60. package/dist/contracts/flow-propose.d.ts +3 -3
  61. package/dist/contracts/flow.d.ts +132 -125
  62. package/dist/contracts/flow.js +27 -12
  63. package/dist/contracts/health.d.ts +1 -3
  64. package/dist/contracts/lead-context.d.ts +1 -1
  65. package/dist/contracts/lead-context.js +2 -2
  66. package/dist/contracts/lead-tools.d.ts +20 -18
  67. package/dist/contracts/lead-tools.js +15 -15
  68. package/dist/contracts/stage-output.d.ts +1 -1
  69. package/dist/contracts/stage-output.js +1 -1
  70. package/dist/contracts/store-json.d.ts +23 -22
  71. package/dist/contracts/store-json.js +17 -17
  72. package/dist/contracts/{teammate-turn.d.ts → subagent-turn.d.ts} +5 -5
  73. package/dist/contracts/{teammate-turn.js → subagent-turn.js} +7 -7
  74. package/dist/control-ui.d.ts +5 -4
  75. package/dist/control-ui.js +9 -34
  76. package/dist/converse.d.ts +23 -23
  77. package/dist/converse.js +28 -28
  78. package/dist/coordinator-proposals.d.ts +2 -2
  79. package/dist/coordinator-proposals.js +1 -1
  80. package/dist/coordinator.js +1 -1
  81. package/dist/credentials-ui.d.ts +5 -4
  82. package/dist/credentials-ui.js +23 -24
  83. package/dist/demo-chat.d.ts +3 -3
  84. package/dist/demo-chat.js +29 -76
  85. package/dist/deprecations.d.ts +12 -0
  86. package/dist/deprecations.js +20 -0
  87. package/dist/desktop-update-gate.js +8 -4
  88. package/dist/desktop-update.js +6 -1
  89. package/dist/discord-chat.js +6 -6
  90. package/dist/discord-settings.d.ts +3 -2
  91. package/dist/discord-settings.js +17 -42
  92. package/dist/dispatch.d.ts +1 -1
  93. package/dist/dispatch.js +1 -1
  94. package/dist/envelope.js +10 -1
  95. package/dist/evidence-pack.d.ts +2 -1
  96. package/dist/evidence-pack.js +45 -49
  97. package/dist/export-ui.d.ts +7 -2
  98. package/dist/export-ui.js +4 -10
  99. package/dist/export.js +7 -7
  100. package/dist/flow-engine.d.ts +2 -2
  101. package/dist/flow-engine.js +21 -21
  102. package/dist/flow-gallery-ui.d.ts +4 -3
  103. package/dist/flow-gallery-ui.js +28 -43
  104. package/dist/flow-insights.d.ts +1 -1
  105. package/dist/flow-share.js +13 -8
  106. package/dist/flow-starters-ui.d.ts +2 -1
  107. package/dist/flow-starters-ui.js +12 -15
  108. package/dist/flow-steps.d.ts +5 -5
  109. package/dist/flow-steps.js +19 -19
  110. package/dist/flow-triggers.d.ts +2 -1
  111. package/dist/flow-triggers.js +17 -15
  112. package/dist/flows-cli.js +1 -1
  113. package/dist/flows-ui.d.ts +4 -3
  114. package/dist/flows-ui.js +38 -49
  115. package/dist/flows.js +21 -20
  116. package/dist/guides.js +112 -6
  117. package/dist/html.d.ts +76 -0
  118. package/dist/html.js +173 -0
  119. package/dist/integrations-ui.d.ts +2 -1
  120. package/dist/integrations-ui.js +19 -23
  121. package/dist/invoke.js +1 -1
  122. package/dist/kits-ui.d.ts +5 -4
  123. package/dist/kits-ui.js +22 -24
  124. package/dist/kits.d.ts +12 -12
  125. package/dist/kits.js +31 -31
  126. package/dist/knowledge-ui.d.ts +6 -5
  127. package/dist/knowledge-ui.js +26 -25
  128. package/dist/{mate-cli.d.ts → lead-cli.d.ts} +11 -11
  129. package/dist/{mate-cli.js → lead-cli.js} +38 -38
  130. package/dist/lead-commitments.js +4 -4
  131. package/dist/lead-context.d.ts +12 -2
  132. package/dist/lead-context.js +15 -17
  133. package/dist/{mate-contract.d.ts → lead-contract.d.ts} +3 -3
  134. package/dist/{mate-contract.js → lead-contract.js} +7 -6
  135. package/dist/{mate-doors.d.ts → lead-doors.d.ts} +6 -6
  136. package/dist/{mate-doors.js → lead-doors.js} +24 -24
  137. package/dist/lead-follow.d.ts +5 -5
  138. package/dist/lead-follow.js +9 -9
  139. package/dist/lead-people.d.ts +5 -5
  140. package/dist/lead-people.js +14 -14
  141. package/dist/{mate-progress.d.ts → lead-progress.d.ts} +9 -9
  142. package/dist/{mate-progress.js → lead-progress.js} +3 -3
  143. package/dist/{mate-tools.d.ts → lead-tools.d.ts} +19 -19
  144. package/dist/{mate-tools.js → lead-tools.js} +109 -101
  145. package/dist/{mate.d.ts → lead.d.ts} +27 -27
  146. package/dist/{mate.js → lead.js} +102 -102
  147. package/dist/ledger-view.d.ts +2 -1
  148. package/dist/ledger-view.js +27 -29
  149. package/dist/limits-ui.d.ts +3 -2
  150. package/dist/limits-ui.js +8 -8
  151. package/dist/live-bus.d.ts +50 -8
  152. package/dist/live-bus.js +133 -50
  153. package/dist/mcp-connect.d.ts +1 -1
  154. package/dist/mcp-connect.js +3 -3
  155. package/dist/mcp-core.js +1 -1
  156. package/dist/mcp-oauth.js +35 -36
  157. package/dist/memory-pass.d.ts +2 -2
  158. package/dist/memory-pass.js +7 -7
  159. package/dist/models-ui.d.ts +2 -1
  160. package/dist/models-ui.js +25 -35
  161. package/dist/monitoring-ui.d.ts +4 -3
  162. package/dist/monitoring-ui.js +13 -26
  163. package/dist/notification-rows.d.ts +2 -2
  164. package/dist/openrouter-models.d.ts +2 -1
  165. package/dist/openrouter-models.js +5 -9
  166. package/dist/operate.d.ts +3 -3
  167. package/dist/operate.js +46 -41
  168. package/dist/people-audit-ui.d.ts +2 -1
  169. package/dist/people-audit-ui.js +13 -13
  170. package/dist/policy-ui.d.ts +3 -2
  171. package/dist/policy-ui.js +17 -23
  172. package/dist/policy.d.ts +1 -1
  173. package/dist/principal.d.ts +1 -1
  174. package/dist/principal.js +2 -2
  175. package/dist/project-delete-ui.d.ts +4 -3
  176. package/dist/project-delete-ui.js +16 -28
  177. package/dist/project-delete.d.ts +1 -1
  178. package/dist/project-delete.js +26 -26
  179. package/dist/project-memory.js +1 -1
  180. package/dist/project-tools.d.ts +1 -1
  181. package/dist/project-tools.js +1 -1
  182. package/dist/pull-request-ui.d.ts +2 -1
  183. package/dist/pull-request-ui.js +17 -32
  184. package/dist/recipe-ui.d.ts +8 -7
  185. package/dist/recipe-ui.js +39 -32
  186. package/dist/release-adapters.d.ts +60 -0
  187. package/dist/release-adapters.js +435 -0
  188. package/dist/release-cli.d.ts +24 -0
  189. package/dist/release-cli.js +181 -0
  190. package/dist/release-gate.d.ts +80 -0
  191. package/dist/release-gate.js +150 -0
  192. package/dist/release-links.d.ts +29 -0
  193. package/dist/release-links.js +102 -0
  194. package/dist/release.d.ts +331 -0
  195. package/dist/release.js +550 -0
  196. package/dist/reply-shape.d.ts +2 -1
  197. package/dist/reply-shape.js +5 -5
  198. package/dist/repository-context-ui.d.ts +2 -1
  199. package/dist/repository-context-ui.js +2 -7
  200. package/dist/request-budget-ui.d.ts +2 -1
  201. package/dist/request-budget-ui.js +16 -16
  202. package/dist/result-review.d.ts +2 -3
  203. package/dist/result-review.js +3 -9
  204. package/dist/retention-ui.d.ts +7 -1
  205. package/dist/retention-ui.js +7 -11
  206. package/dist/retention.js +4 -4
  207. package/dist/scope.d.ts +2 -2
  208. package/dist/scout-report.d.ts +1 -1
  209. package/dist/scout-report.js +1 -1
  210. package/dist/serve.d.ts +11 -2
  211. package/dist/serve.js +105 -99
  212. package/dist/server/chat.d.ts +7 -10
  213. package/dist/server/chat.js +984 -1021
  214. package/dist/server/chrome.d.ts +291 -0
  215. package/dist/server/chrome.js +747 -0
  216. package/dist/server/console.css +2819 -0
  217. package/dist/server/flows.d.ts +2 -6
  218. package/dist/server/flows.js +854 -773
  219. package/dist/server/guards.d.ts +1 -1
  220. package/dist/server/guards.js +8 -5
  221. package/dist/server/handler-context.d.ts +1 -1
  222. package/dist/server/handler-context.js +1 -1
  223. package/dist/server/handler-registry.d.ts +8 -6
  224. package/dist/server/handler-registry.js +14 -2
  225. package/dist/server/http.d.ts +274 -0
  226. package/dist/server/http.js +239 -0
  227. package/dist/server/live.d.ts +34 -0
  228. package/dist/server/live.js +309 -0
  229. package/dist/server/pages.d.ts +2 -6
  230. package/dist/server/pages.js +808 -789
  231. package/dist/server/people-tokens.d.ts +1 -6
  232. package/dist/server/people-tokens.js +581 -573
  233. package/dist/server/remote.d.ts +4 -7
  234. package/dist/server/remote.js +39 -70
  235. package/dist/server/render-chat.d.ts +402 -0
  236. package/dist/server/render-chat.js +927 -0
  237. package/dist/server/render-pages.d.ts +535 -0
  238. package/dist/server/render-pages.js +1277 -0
  239. package/dist/server/render-people.d.ts +32 -0
  240. package/dist/server/render-people.js +121 -0
  241. package/dist/server/render-results.d.ts +744 -0
  242. package/dist/server/render-results.js +2237 -0
  243. package/dist/server/render-settings.d.ts +154 -0
  244. package/dist/server/render-settings.js +580 -0
  245. package/dist/server/render-tasks.d.ts +632 -0
  246. package/dist/server/render-tasks.js +2345 -0
  247. package/dist/server/request-context.d.ts +46 -0
  248. package/dist/server/request-context.js +17 -0
  249. package/dist/server/route-table.d.ts +25 -3
  250. package/dist/server/route-table.js +167 -77
  251. package/dist/server/runtime.d.ts +28 -20
  252. package/dist/server/runtime.js +7 -1
  253. package/dist/server/session.d.ts +138 -0
  254. package/dist/server/session.js +94 -0
  255. package/dist/server/settings.d.ts +1 -5
  256. package/dist/server/settings.js +2186 -2121
  257. package/dist/server/task-views.d.ts +11 -4
  258. package/dist/server/task-views.js +26 -22
  259. package/dist/server/tasks.d.ts +9 -9
  260. package/dist/server/tasks.js +1489 -1420
  261. package/dist/server-telemetry.d.ts +4 -3
  262. package/dist/server-telemetry.js +4 -8
  263. package/dist/setup-guide.d.ts +2 -2
  264. package/dist/skills-ui.d.ts +4 -3
  265. package/dist/skills-ui.js +14 -17
  266. package/dist/skills.d.ts +1 -1
  267. package/dist/skills.js +2 -1
  268. package/dist/slack-chat.d.ts +2 -2
  269. package/dist/slack-chat.js +6 -6
  270. package/dist/slack-settings.d.ts +3 -2
  271. package/dist/slack-settings.js +17 -42
  272. package/dist/spend-ui.d.ts +5 -4
  273. package/dist/spend-ui.js +17 -40
  274. package/dist/spend.d.ts +14 -14
  275. package/dist/spend.js +31 -31
  276. package/dist/sso-ui.d.ts +3 -2
  277. package/dist/sso-ui.js +26 -27
  278. package/dist/storage-ui.d.ts +2 -1
  279. package/dist/storage-ui.js +14 -33
  280. package/dist/store-baseline.d.ts +19 -0
  281. package/dist/store-baseline.js +2873 -0
  282. package/dist/store.d.ts +197 -249
  283. package/dist/store.js +747 -3084
  284. package/dist/subagent-admin.d.ts +53 -0
  285. package/dist/{teammate-admin.js → subagent-admin.js} +37 -37
  286. package/dist/{teammate-desk.d.ts → subagent-desk.d.ts} +22 -23
  287. package/dist/{teammate-desk.js → subagent-desk.js} +26 -35
  288. package/dist/{teammate-memory.d.ts → subagent-memory.d.ts} +17 -17
  289. package/dist/{teammate-memory.js → subagent-memory.js} +41 -41
  290. package/dist/{teammate-question.d.ts → subagent-question.d.ts} +6 -6
  291. package/dist/{teammate-question.js → subagent-question.js} +17 -17
  292. package/dist/{teammate-tools.d.ts → subagent-tools.d.ts} +18 -18
  293. package/dist/{teammate-tools.js → subagent-tools.js} +36 -36
  294. package/dist/{teammate-week.d.ts → subagent-week.d.ts} +10 -10
  295. package/dist/{teammate-week.js → subagent-week.js} +23 -23
  296. package/dist/{teammate-work.d.ts → subagent-work.d.ts} +21 -21
  297. package/dist/{teammate-work.js → subagent-work.js} +50 -50
  298. package/dist/subagents-ui.d.ts +22 -0
  299. package/dist/subagents-ui.js +137 -0
  300. package/dist/{teammates.d.ts → subagents.d.ts} +11 -11
  301. package/dist/{teammates.js → subagents.js} +21 -21
  302. package/dist/subscription-chat.d.ts +13 -13
  303. package/dist/subscription-chat.js +19 -19
  304. package/dist/surface.d.ts +19 -2
  305. package/dist/surface.js +20 -33
  306. package/dist/task-composer.d.ts +2 -1
  307. package/dist/task-composer.js +7 -7
  308. package/dist/task-status.d.ts +4 -3
  309. package/dist/task-status.js +15 -16
  310. package/dist/team-cli.d.ts +1 -0
  311. package/dist/team-cli.js +14 -2
  312. package/dist/team-http.d.ts +5 -9
  313. package/dist/team-http.js +5 -63
  314. package/dist/team-leads.js +13 -13
  315. package/dist/team-runtime.d.ts +2 -2
  316. package/dist/team-runtime.js +8 -8
  317. package/dist/team-ui.d.ts +2 -1
  318. package/dist/team-ui.js +2 -5
  319. package/dist/teams-chat.js +6 -6
  320. package/dist/teams-settings.d.ts +3 -2
  321. package/dist/teams-settings.js +20 -31
  322. package/dist/telegram-flow.d.ts +3 -3
  323. package/dist/telegram-flow.js +3 -3
  324. package/dist/{telegram-mate.d.ts → telegram-lead.d.ts} +5 -5
  325. package/dist/{telegram-mate.js → telegram-lead.js} +27 -27
  326. package/dist/telegram-settings.d.ts +3 -2
  327. package/dist/telegram-settings.js +14 -25
  328. package/dist/telegram-status.js +1 -1
  329. package/dist/telegram-team.d.ts +1 -1
  330. package/dist/telegram-team.js +5 -5
  331. package/dist/telegram.d.ts +1 -1
  332. package/dist/telegram.js +9 -30
  333. package/dist/text-limits.d.ts +18 -18
  334. package/dist/text-limits.js +18 -18
  335. package/dist/toolroll-update-ui.d.ts +3 -2
  336. package/dist/toolroll-update-ui.js +35 -39
  337. package/dist/toolroll-update.d.ts +8 -0
  338. package/dist/toolroll-update.js +45 -8
  339. package/dist/tools-ui.d.ts +5 -2
  340. package/dist/tools-ui.js +31 -31
  341. package/dist/when-html.d.ts +11 -3
  342. package/dist/when-html.js +5 -6
  343. package/dist/workspace-ui.d.ts +4 -2
  344. package/dist/workspace-ui.js +10 -10
  345. package/package.json +1 -2
  346. package/dist/server/shared.d.ts +0 -3151
  347. package/dist/server/shared.js +0 -12001
  348. package/dist/teammate-admin.d.ts +0 -53
  349. package/dist/teammates-ui.d.ts +0 -20
  350. package/dist/teammates-ui.js +0 -166
@@ -5,7 +5,7 @@ import { TEXT_LIMITS } from "./text-limits.js";
5
5
  import { publicChatText } from "./chat-display.js";
6
6
  import { gateWords } from "./approval-policy.js";
7
7
  import { createHash, randomBytes } from "node:crypto";
8
- import { mateTurnKeepsProposals, verifiedAuthor } from "./store.js";
8
+ import { leadTurnKeepsProposals, verifiedAuthor } from "./store.js";
9
9
  import { isVerifiedApprover, reproveApprover, } from "./principal.js";
10
10
  import { changeSkills, importSkill, skillsView, skillsVersion, testSkill, validateSkill, } from "./project-skills.js";
11
11
  import { changeKnowledge, knowledgeVersion, knowledgeView, } from "./project-knowledge.js";
@@ -25,15 +25,15 @@ import { assignFlowCard, commentOnFlowCard, flowPeople, mentionsIn, watchFlowCar
25
25
  import { addFlowTriggerTo, describeTrigger, readLinearKey, removeFlowTrigger, scheduleFromWords, takesDeliveries, triggerConfigOf, validateTriggerConfig } from "./flow-triggers.js";
26
26
  import { describeSchedule, parseSchedule } from "./flow-schedule.js";
27
27
  import { dirname } from "node:path";
28
- import { handleOf, parseSoul, SOUL_CHARS, TEAMMATE_TEMPLATES, teammateLabel } from "./teammates.js";
29
- import { createTeammateFrom, labelOf, nameOf, renamedSoul, saveSoul, setTeammateState } from "./teammate-admin.js";
30
- import { cleanMemory, editMemory, forgetMemory, tellTeammate } from "./teammate-memory.js";
31
- import { addRoutine, removeRoutine, routineSchedule, routinesOf } from "./teammate-desk.js";
32
- import { requestUndo, undoFor } from "./teammate-week.js";
28
+ import { handleOf, parseSoul, SOUL_CHARS, SUBAGENT_TEMPLATES, subagentLabel } from "./subagents.js";
29
+ import { createSubagentFrom, labelOf, nameOf, renamedSoul, saveSoul, setSubagentState } from "./subagent-admin.js";
30
+ import { cleanMemory, editMemory, forgetMemory, tellSubagent } from "./subagent-memory.js";
31
+ import { addRoutine, askSubagent, removeRoutine, routineSchedule, routinesOf } from "./subagent-desk.js";
32
+ import { requestUndo, undoFor } from "./subagent-week.js";
33
33
  import { kitInstalled, kitOf, KITS, setUpKitNow } from "./kits.js";
34
34
  import { starterFlowOf, starterOf, startersFor, starterTerms, STARTER_FLOWS, switchOnStarter } from "./flow-starters.js";
35
- import { answerTeammateQuestion } from "./teammate-work.js";
36
- import { callWords, checkRule, defaultRule, grantListed, revokeTool, ruleWords, setToolRules } from "./teammate-tools.js";
35
+ import { answerSubagentQuestion } from "./subagent-work.js";
36
+ import { callWords, checkRule, defaultRule, grantListed, revokeTool, ruleWords, setToolRules } from "./subagent-tools.js";
37
37
  import { aboutYouOf, checkAboutYouLine, saveAboutYou, withAboutYouLine } from "./lead-about.js";
38
38
  import { CHAT_ACTION_FIELDS, readChatActionRequest, readSharedAction, SHARED_ACTION_VERSION } from "./contracts/chat-actions.js";
39
39
  export { CHAT_ACTION_FIELDS };
@@ -101,15 +101,16 @@ export const CHAT_ACTIONS = {
101
101
  flow_trigger_pause: { label: "Pause trigger", protected: false, password: false },
102
102
  flow_trigger_resume: { label: "Turn trigger on", protected: false, password: false },
103
103
  flow_trigger_remove: { label: "Remove trigger", protected: false, password: false },
104
- teammate_create: { label: "Add teammate", protected: false, password: false },
105
- teammate_soul: { label: "Update soul file", protected: false, password: false },
106
- teammate_state: { label: "Change teammate", protected: false, password: false },
107
- teammate_note: { label: "Tell teammate", protected: false, password: false },
108
- teammate_answer: { label: "Answer teammate", protected: false, password: false },
109
- teammate_tools: { label: "Change teammate's tools", protected: false, password: false },
110
- teammate_memory: { label: "Change teammate's memory", protected: false, password: false },
111
- teammate_routine: { label: "Change teammate's routines", protected: false, password: false },
112
- teammate_undo: { label: "Undo teammate's call", protected: false, password: false },
104
+ subagent_create: { label: "Add subagent", protected: false, password: false },
105
+ subagent_soul: { label: "Update soul file", protected: false, password: false },
106
+ subagent_state: { label: "Change subagent", protected: false, password: false },
107
+ subagent_note: { label: "Tell subagent", protected: false, password: false },
108
+ subagent_ask: { label: "Ask subagent", protected: false, password: false },
109
+ subagent_answer: { label: "Answer subagent", protected: false, password: false },
110
+ subagent_tools: { label: "Change subagent's tools", protected: false, password: false },
111
+ subagent_memory: { label: "Change subagent's memory", protected: false, password: false },
112
+ subagent_routine: { label: "Change subagent's routines", protected: false, password: false },
113
+ subagent_undo: { label: "Undo subagent's call", protected: false, password: false },
113
114
  kit_setup: { label: "Set up kit", protected: false, password: false },
114
115
  decision_record: { label: "Record decision", protected: false, password: false },
115
116
  decision_retire: { label: "Retire decision", protected: false, password: false },
@@ -262,19 +263,19 @@ export function prepareSharedAction(store, who, operation, input, root, now = ne
262
263
  const stamp = hash({ operation, request, repo: "", state, terms, actor: who.name, generation: who.generation, ceiling: who.ceilingDigest });
263
264
  return { version: SHARED_ACTION_VERSION, operation, request, repo: "", title, terms, stamp, state };
264
265
  }
265
- const task = operation.startsWith("skill_") || operation.startsWith("knowledge_") || operation.startsWith("decision_") || operation.startsWith("tool_") || operation.startsWith("flow_") || operation.startsWith("teammate_") || operation.startsWith("kit_")
266
+ const task = operation.startsWith("skill_") || operation.startsWith("knowledge_") || operation.startsWith("decision_") || operation.startsWith("tool_") || operation.startsWith("flow_") || operation.startsWith("subagent_") || operation.startsWith("kit_")
266
267
  ? null
267
268
  : text(input, "task", 64);
268
269
  const flowTarget = operation.startsWith("flow_") && operation !== "flow_create" && operation !== "flow_script_save" && operation !== "flow_starter" ? flowTargetOf(store, input) : null;
269
- // v92: a teammate names its project; a question names it through its card's flow.
270
- const mateTarget = operation.startsWith("teammate_") && operation !== "teammate_create" && operation !== "teammate_answer" ? store.getTeammate(integer(input, "teammate")) : null;
271
- if (mateTarget !== null && mateTarget.state === "removed")
272
- throw Error("That teammate is off the team.");
273
- const questionTarget = operation === "teammate_answer" ? store.teammateQuestion(integer(input, "question")) : null;
270
+ // v92: a subagent names its project; a question names it through its card's flow.
271
+ const subagentTarget = operation.startsWith("subagent_") && operation !== "subagent_create" && operation !== "subagent_answer" ? store.getSubagent(integer(input, "subagent")) : null;
272
+ if (subagentTarget !== null && subagentTarget.state === "removed")
273
+ throw Error("That subagent is off the team.");
274
+ const questionTarget = operation === "subagent_answer" ? store.subagentQuestion(integer(input, "question")) : null;
274
275
  const questionFlow = questionTarget === null ? null : store.getFlow(store.getFlowCard(questionTarget.card)?.flow ?? -1);
275
- if (operation === "teammate_answer" && (questionTarget === null || questionFlow === null))
276
+ if (operation === "subagent_answer" && (questionTarget === null || questionFlow === null))
276
277
  throw Error("That question isn't open any more.");
277
- const repo = flowTarget !== null ? flowTarget.flow.repo : mateTarget !== null ? mateTarget.repo : questionFlow !== null ? questionFlow.repo : task === null ? text(input, "repo", 4096) : store.lookupRef(task)?.repo;
278
+ const repo = flowTarget !== null ? flowTarget.flow.repo : subagentTarget !== null ? subagentTarget.repo : questionFlow !== null ? questionFlow.repo : task === null ? text(input, "repo", 4096) : store.lookupRef(task)?.repo;
278
279
  if (!repo)
279
280
  throw Error("Choose an available project.");
280
281
  requireActor(store, who, repo);
@@ -358,23 +359,23 @@ export function prepareSharedAction(store, who, operation, input, root, now = ne
358
359
  }
359
360
  }
360
361
  else if (operation === "kit_setup") {
361
- // a starter kit — its teammate, its flow and its buttons.
362
+ // a starter kit — its subagent, its flow and its buttons.
362
363
  const project = repo.split(/[\\/]/).filter(Boolean).at(-1) ?? repo;
363
364
  const kit = kitOf(String(input["kit"] ?? ""));
364
365
  if (kit === null)
365
366
  throw Error(`Choose a kit: ${KITS.map(one => one.id).join(", ")}.`);
366
367
  if (kitInstalled(store, kit, repo) !== null)
367
368
  throw Error(`${kit.name} is already set up in ${project}.`);
368
- const template = TEAMMATE_TEMPLATES.find(one => one.id === kit.teammate.template);
369
+ const template = SUBAGENT_TEMPLATES.find(one => one.id === kit.subagent.template);
369
370
  title = `Set up ${kit.name} in ${project}`;
370
- terms.push(kit.promise, `Adds ${kit.teammate.handle.charAt(0).toUpperCase()}${kit.teammate.handle.slice(1)} (${template?.label.toLowerCase() ?? "a teammate"}) and the ${kit.flowName} flow${kit.buttons.length === 0 ? "" : ` with its ${kit.buttons.map(one => `“${one.label}”`).join(" and ")} button`}. Nothing goes out without your approval.`);
371
+ terms.push(kit.promise, `Adds ${kit.subagent.handle.charAt(0).toUpperCase()}${kit.subagent.handle.slice(1)} (${template?.label.toLowerCase() ?? "a subagent"}) and the ${kit.flowName} flow${kit.buttons.length === 0 ? "" : ` with its ${kit.buttons.map(one => `“${one.label}”`).join(" and ")} button`}. Nothing goes out without your approval.`);
371
372
  state = {};
372
373
  }
373
- else if (operation.startsWith("teammate_")) {
374
+ else if (operation.startsWith("subagent_")) {
374
375
  const project = repo.split(/[\\/]/).filter(Boolean).at(-1) ?? repo;
375
- const mate = mateTarget;
376
- if (operation === "teammate_create") {
377
- const template = TEAMMATE_TEMPLATES.find(one => one.id === input["template"]);
376
+ const mate = subagentTarget;
377
+ if (operation === "subagent_create") {
378
+ const template = SUBAGENT_TEMPLATES.find(one => one.id === input["template"]);
378
379
  const given = typeof input["soul"] === "string" && input["soul"].trim() !== "" ? text(input, "soul", SOUL_CHARS) : null;
379
380
  if ((template === undefined) === (given === null))
380
381
  throw Error("Start from a template, or write the whole soul file, not both.");
@@ -384,29 +385,29 @@ export function prepareSharedAction(store, who, operation, input, root, now = ne
384
385
  const read = parseSoul(soul);
385
386
  if (!read.ok)
386
387
  throw Error(read.problem);
387
- if (store.teammateByHandle(repo, handleOf(read.soul.name)) !== null)
388
- throw Error(`There's already a teammate called ${read.soul.name} in ${project}.`);
388
+ if (store.subagentByHandle(repo, handleOf(read.soul.name)) !== null)
389
+ throw Error(`There's already a subagent called ${read.soul.name} in ${project}.`);
389
390
  Object.assign(request, { soul });
390
391
  delete request["template"];
391
392
  delete request["name"];
392
393
  state = { handle: handleOf(read.soul.name) };
393
- title = `Add ${teammateLabel(read.soul)} to the team in ${project}`;
394
- terms.push(soul.trim(), `${read.soul.name} decides only within these rules and asks you when they say to. Teammates never approve code tasks or merges.`);
394
+ title = `Add ${subagentLabel(read.soul)} to the team in ${project}`;
395
+ terms.push(soul.trim(), `${read.soul.name} decides only within these rules and asks you when they say to. Subagents never approve code tasks or merges.`);
395
396
  }
396
- else if (operation === "teammate_soul") {
397
+ else if (operation === "subagent_soul") {
397
398
  const soul = text(input, "soul", SOUL_CHARS);
398
399
  const read = parseSoul(soul);
399
400
  if (!read.ok)
400
401
  throw Error(read.problem);
401
402
  if (handleOf(read.soul.name) !== mate.handle)
402
- throw Error("Keep the teammate's name; make a new teammate for another name.");
403
+ throw Error("Keep the subagent's name; make a new subagent for another name.");
403
404
  if (soul.trim() === mate.soul.trim())
404
405
  throw Error("That's already its soul file.");
405
406
  state = { version: mate.version };
406
- title = `Update ${teammateLabel(read.soul)}'s soul file`;
407
+ title = `Update ${subagentLabel(read.soul)}'s soul file`;
407
408
  terms.push(soul.trim(), `Replaces version ${mate.version}. Its next turn reads this.`);
408
409
  }
409
- else if (operation === "teammate_state") {
410
+ else if (operation === "subagent_state") {
410
411
  const wanted = input["state"];
411
412
  if (wanted !== "active" && wanted !== "paused" && wanted !== "removed")
412
413
  throw Error("Choose pause, resume or remove.");
@@ -414,13 +415,13 @@ export function prepareSharedAction(store, who, operation, input, root, now = ne
414
415
  title = `${wanted === "paused" ? "Pause" : wanted === "active" ? "Resume" : "Remove"} ${labelOf(mate)}`;
415
416
  terms.push(wanted === "paused" ? "Its decisions go to people and the zones it handles wait until you resume it." : wanted === "active" ? "It picks up its zones' cards again." : "It leaves the team: zones that name it go to people.");
416
417
  }
417
- else if (operation === "teammate_tools") {
418
+ else if (operation === "subagent_tools") {
418
419
  // v94: which project tools it may use, and its rule for one action.
419
420
  const tool = text(input, "tool", 40);
420
421
  const change = input["change"];
421
- const grant = store.teammateGrant(mate.id, tool);
422
+ const grant = store.subagentGrant(mate.id, tool);
422
423
  const name = nameOf(mate);
423
- const grants = store.teammateGrants(mate.id);
424
+ const grants = store.subagentGrants(mate.id);
424
425
  const uses = grants.length === 0 ? ` ${name} doesn't use any tools yet.` : ` ${name} uses ${grants.map(one => `${one.tool} (actions: ${one.actions.map(each => each.name).join(", ")})`).join("; ")}.`;
425
426
  if (change === "grant") {
426
427
  const found = projectToolsOf(store, repo).find(one => one.name === tool);
@@ -458,17 +459,17 @@ export function prepareSharedAction(store, who, operation, input, root, now = ne
458
459
  else
459
460
  throw Error("Choose grant, revoke or rule.");
460
461
  }
461
- else if (operation === "teammate_undo") {
462
+ else if (operation === "subagent_undo") {
462
463
  // v97: undo one of its tool calls with the action its manager named for that.
463
- const call = store.teammateCall(integer(input, "call"));
464
- const undo = call === null || call.teammate !== mate.id ? null : undoFor(store, call);
464
+ const call = store.subagentCall(integer(input, "call"));
465
+ const undo = call === null || call.subagent !== mate.id ? null : undoFor(store, call);
465
466
  if (call === null || undo === null)
466
- throw Error(call?.undoneBy ? `${call.undoneBy} already undid it.` : "That call can't be undone: its action has no undo set on the teammate's Tools.");
467
+ throw Error(call?.undoneBy ? `${call.undoneBy} already undid it.` : "That call can't be undone: its action has no undo set on the subagent's Tools.");
467
468
  title = `Undo ${nameOf(mate)}'s ${call.action}`;
468
469
  terms.push(`Undoes: ${callWords(call.tool, call.action, call.input, 300)}`, `By calling: ${callWords(call.tool, undo, call.input, 300)}`, "It's made as you, with the same input, and both calls keep their receipts.");
469
470
  state = { call: call.id };
470
471
  }
471
- else if (operation === "teammate_routine") {
472
+ else if (operation === "subagent_routine") {
472
473
  // v96: a routine: on a schedule, a card on its desk saying what to do; its answer goes to its manager.
473
474
  const name = nameOf(mate);
474
475
  if (input["change"] === "add") {
@@ -494,10 +495,10 @@ export function prepareSharedAction(store, who, operation, input, root, now = ne
494
495
  else
495
496
  throw Error("Choose add or remove.");
496
497
  }
497
- else if (operation === "teammate_memory") {
498
+ else if (operation === "subagent_memory") {
498
499
  // v95: edit or forget one thing it remembers.
499
- const memory = store.teammateMemory(integer(input, "memory"));
500
- if (memory === null || memory.teammate !== mate.id)
500
+ const memory = store.subagentMemory(integer(input, "memory"));
501
+ if (memory === null || memory.subagent !== mate.id)
501
502
  throw Error(`${nameOf(mate)} doesn't remember that any more.`);
502
503
  if (input["change"] === "forget") {
503
504
  title = `${nameOf(mate)} forgets: ${memory.text.slice(0, 60)}`;
@@ -515,12 +516,24 @@ export function prepareSharedAction(store, who, operation, input, root, now = ne
515
516
  throw Error("Choose edit or forget.");
516
517
  state = { text: memory.text };
517
518
  }
518
- else if (operation === "teammate_note") {
519
+ else if (operation === "subagent_ask") {
520
+ // D5: the lead delegates. The card says exactly what goes to the subagent, which works it within its own rules.
521
+ const asked = text(input, "text", 4000).replace(/\r\n?/g, "\n").trim();
522
+ if (asked === "")
523
+ throw Error(`Say what to ask ${nameOf(mate)}.`);
524
+ if (mate.state !== "active")
525
+ throw Error(`${nameOf(mate)} is paused. Resume it first.`);
526
+ request["text"] = asked;
527
+ state = { subagent: mate.id, version: mate.version };
528
+ title = `Ask ${nameOf(mate)}`;
529
+ terms.push(asked, `${nameOf(mate)} works on it within its own rules and tools, asks you first where they say to, and its answer comes back to you. It never approves code tasks or merges.`);
530
+ }
531
+ else if (operation === "subagent_note") {
519
532
  const note = cleanMemory(text(input, "note", 1000));
520
533
  if (!note.ok)
521
534
  throw Error(note.said);
522
535
  request["note"] = note.text;
523
- state = { teammate: mate.id };
536
+ state = { subagent: mate.id };
524
537
  title = `Tell ${nameOf(mate)}`;
525
538
  terms.push(note.text, "It keeps this in its memory: every turn reads the latest ten things people told it.");
526
539
  }
@@ -536,8 +549,8 @@ export function prepareSharedAction(store, who, operation, input, root, now = ne
536
549
  throw Error("Pick one of its options or say the answer.");
537
550
  Object.assign(request, { choice: choice?.id ?? null, text: said || null });
538
551
  state = { question: question.id };
539
- const mateOf = store.getTeammate(question.teammate);
540
- title = `Answer ${mateOf === null ? "the teammate" : nameOf(mateOf)}`;
552
+ const subagentOf = store.getSubagent(question.subagent);
553
+ title = `Answer ${subagentOf === null ? "the subagent" : nameOf(subagentOf)}`;
541
554
  terms.push(question.question, `Your answer: ${[choice?.label, said].filter(Boolean).join(" — ")}`);
542
555
  }
543
556
  }
@@ -766,7 +779,7 @@ export function prepareSharedAction(store, who, operation, input, root, now = ne
766
779
  }
767
780
  else if (operation.startsWith("decision_")) {
768
781
  // The staleness fence: the newest decision id and the active count, so a
769
- // card drafted before a teammate recorded or retired one is refused.
782
+ // card drafted before a subagent recorded or retired one is refused.
770
783
  const stamp = store.handle.prepare("SELECT COALESCE(MAX(id),0) AS newest, COUNT(*) AS active FROM project_decision WHERE repo=? AND status='active'").get(repo);
771
784
  state = { newest: Number(stamp?.["newest"] ?? 0), active: Number(stamp?.["active"] ?? 0) };
772
785
  if (operation === "decision_record") {
@@ -952,22 +965,22 @@ export function sharedActionReviewPath(id) {
952
965
  function savedActionContext(store, who, id, state) {
953
966
  if (!isVerifiedApprover(who) || !reproveApprover(store, who).ok)
954
967
  throw Error("Your access changed. Sign in again.");
955
- const proposal = store.getMateProposal(id), payload = proposal?.kind === "action"
968
+ const proposal = store.getLeadProposal(id), payload = proposal?.kind === "action"
956
969
  ? sharedActionPayload(proposal.payload)
957
970
  : null;
958
971
  const shared = proposal && store.handle.prepare('SELECT id FROM team_conversation WHERE thread=?').get(proposal.thread);
959
- const session = shared && proposal ? store.teamMateSession(who.name, proposal.thread) : store.activeMateSession(who.name), turn = proposal ? store.getMateTurn(proposal.turn) : null;
972
+ const session = shared && proposal ? store.teamMateSession(who.name, proposal.thread) : store.activeLeadSession(who.name), turn = proposal ? store.getLeadTurn(proposal.turn) : null;
960
973
  if (!proposal ||
961
974
  !payload ||
962
975
  proposal.state !== state ||
963
- (shared ? !store.canUseTeamMateThread(who.name, who.generation, proposal.thread) : store.getMateThread(proposal.thread)?.approver !== who.name))
976
+ (shared ? !store.canUseTeamMateThread(who.name, who.generation, proposal.thread) : store.getLeadThread(proposal.thread)?.approver !== who.name))
964
977
  throw Error("This action is no longer waiting for your review.");
965
978
  if (!session ||
966
979
  session.approverGeneration !== who.generation ||
967
980
  session.ceilingDigest !== who.ceilingDigest ||
968
981
  proposal.ceilingDigest !== who.ceilingDigest ||
969
982
  (!shared && turn?.session !== session.id) ||
970
- !mateTurnKeepsProposals(turn))
983
+ !leadTurnKeepsProposals(turn))
971
984
  throw Error("This conversation ended or its project access changed. Ask for a fresh proposal.");
972
985
  requireActor(store, who, payload.repo, payload.operation);
973
986
  return payload;
@@ -1070,8 +1083,8 @@ export function executeSharedAction(store, who, id, payload, now, options) {
1070
1083
  throw Error(made.said);
1071
1084
  return { ok: true, taskId: null, said: `${made.said} Try it with a sample card from its page.`, href: `/kits/${kit.id}?repo=${encodeURIComponent(repo)}` };
1072
1085
  }
1073
- else if (payload.operation.startsWith("teammate_")) {
1074
- const done = runTeammateAction(store, payload, actor, now);
1086
+ else if (payload.operation.startsWith("subagent_")) {
1087
+ const done = runSubagentAction(store, payload, actor, now);
1075
1088
  return { ok: true, taskId: null, said: done.said, href: done.href };
1076
1089
  }
1077
1090
  else if (payload.operation === "tool_add") {
@@ -1181,50 +1194,59 @@ export function executeSharedAction(store, who, id, payload, now, options) {
1181
1194
  : "The action could not be completed.");
1182
1195
  }
1183
1196
  }
1184
- /** A confirmed teammate action (v92), through the same helpers the Teammates pages use. */
1185
- function runTeammateAction(store, payload, actor, now) {
1197
+ /** A confirmed subagent action (v92), through the same helpers the Subagents pages use. */
1198
+ function runSubagentAction(store, payload, actor, now) {
1186
1199
  const req = payload.request;
1187
- if (payload.operation === "teammate_create") {
1188
- const made = createTeammateFrom(store, { repo: payload.repo, soul: String(req["soul"]), by: actor }, now);
1200
+ if (payload.operation === "subagent_create") {
1201
+ const made = createSubagentFrom(store, { repo: payload.repo, soul: String(req["soul"]), by: actor }, now);
1189
1202
  if (!made.ok)
1190
1203
  throw Error(made.said);
1191
- return { said: made.said, href: `/teammates/${made.id}` };
1204
+ return { said: made.said, href: `/settings/lead/subagents/${made.id}` };
1192
1205
  }
1193
- if (payload.operation === "teammate_answer") {
1194
- const question = store.teammateQuestion(Number(req["question"]));
1195
- const answered = answerTeammateQuestion(store, Number(req["question"]), { choice: req["choice"] === null ? null : String(req["choice"]), text: req["text"] === null ? null : String(req["text"]), by: actor, via: "chat" }, now);
1206
+ if (payload.operation === "subagent_answer") {
1207
+ const question = store.subagentQuestion(Number(req["question"]));
1208
+ const answered = answerSubagentQuestion(store, Number(req["question"]), { choice: req["choice"] === null ? null : String(req["choice"]), text: req["text"] === null ? null : String(req["text"]), by: actor, via: "chat" }, now);
1196
1209
  if (!answered.ok)
1197
1210
  throw Error(answered.said);
1198
- return { said: answered.said, href: question === null ? "/teammates" : `/teammates/${question.teammate}` };
1211
+ return { said: answered.said, href: question === null ? "/settings/lead/subagents" : `/settings/lead/subagents/${question.subagent}` };
1199
1212
  }
1200
- const mate = store.getTeammate(Number(req["teammate"]));
1213
+ const mate = store.getSubagent(Number(req["subagent"]));
1201
1214
  if (mate === null || mate.state === "removed")
1202
- throw Error("That teammate is off the team.");
1203
- if (payload.operation === "teammate_undo") {
1215
+ throw Error("That subagent is off the team.");
1216
+ if (payload.operation === "subagent_ask") {
1217
+ // One card per confirmed proposal: the confirmation runs once, so a retried tap never asks twice.
1218
+ if (mate.version !== payload.state["version"])
1219
+ throw Error("Someone changed its soul file since. Ask for a fresh proposal.");
1220
+ const asked = askSubagent(store, mate, { who: actor, via: "the lead" }, String(req["text"]), now);
1221
+ if (!asked.ok)
1222
+ throw Error(asked.said);
1223
+ return { said: asked.said, href: asked.link.path };
1224
+ }
1225
+ if (payload.operation === "subagent_undo") {
1204
1226
  const asked = requestUndo(store, mate, Number(req["call"]), actor, now);
1205
1227
  if (!asked.ok)
1206
1228
  throw Error(asked.said);
1207
- return { said: `${asked.said} The receipt on the card shows how it went.`, href: `/teammates/${mate.id}#week` };
1229
+ return { said: `${asked.said} The receipt on the card shows how it went.`, href: `/settings/lead/subagents/${mate.id}#week` };
1208
1230
  }
1209
- if (payload.operation === "teammate_routine") {
1231
+ if (payload.operation === "subagent_routine") {
1210
1232
  const done = req["change"] === "add" ? addRoutine(store, mate, String(req["schedule"]), String(req["text"]), actor, now, null)
1211
1233
  : removeRoutine(store, mate, Number(req["routine"]), now, null);
1212
1234
  if (!done.ok)
1213
1235
  throw Error(done.said);
1214
- return { said: done.said, href: `/teammates/${mate.id}#desk` };
1236
+ return { said: done.said, href: `/settings/lead/subagents/${mate.id}#desk` };
1215
1237
  }
1216
- if (payload.operation === "teammate_memory") {
1217
- const memory = store.teammateMemory(Number(req["memory"]));
1238
+ if (payload.operation === "subagent_memory") {
1239
+ const memory = store.subagentMemory(Number(req["memory"]));
1218
1240
  if (memory === null || memory.text !== payload.state["text"])
1219
1241
  throw Error("That memory changed since. Ask for a fresh proposal.");
1220
1242
  const done = req["change"] === "forget" ? forgetMemory(store, mate, memory.id, actor, now) : editMemory(store, mate, memory.id, String(req["text"]), actor, now);
1221
1243
  if (!done.ok)
1222
1244
  throw Error(done.said);
1223
- return { said: done.said, href: `/teammates/${mate.id}#memory` };
1245
+ return { said: done.said, href: `/settings/lead/subagents/${mate.id}#memory` };
1224
1246
  }
1225
- if (payload.operation === "teammate_tools") {
1247
+ if (payload.operation === "subagent_tools") {
1226
1248
  const tool = String(req["tool"]);
1227
- const grant = store.teammateGrant(mate.id, tool);
1249
+ const grant = store.subagentGrant(mate.id, tool);
1228
1250
  if ((grant === null ? "" : JSON.stringify(grant.rules)) !== payload.state["rules"])
1229
1251
  throw Error("Someone changed its tools since. Ask for a fresh proposal.");
1230
1252
  const found = projectToolsOf(store, mate.repo).find(one => one.name === tool);
@@ -1234,16 +1256,16 @@ function runTeammateAction(store, payload, actor, now) {
1234
1256
  undo: req["undoWith"] ?? grant?.rules[String(req["action"])]?.undo ?? "" } }, actor, now);
1235
1257
  if (!done.ok)
1236
1258
  throw Error(done.said);
1237
- return { said: done.said, href: `/teammates/${mate.id}#tools` };
1259
+ return { said: done.said, href: `/settings/lead/subagents/${mate.id}#tools` };
1238
1260
  }
1239
- if (payload.operation === "teammate_soul" && mate.version !== payload.state["version"])
1261
+ if (payload.operation === "subagent_soul" && mate.version !== payload.state["version"])
1240
1262
  throw Error("Someone changed its soul file since. Ask for a fresh proposal.");
1241
- const done = payload.operation === "teammate_soul" ? saveSoul(store, mate, String(req["soul"]), actor, now)
1242
- : payload.operation === "teammate_state" ? setTeammateState(store, mate, req["state"], actor, now)
1243
- : tellTeammate(store, mate, String(req["note"]), actor, now);
1263
+ const done = payload.operation === "subagent_soul" ? saveSoul(store, mate, String(req["soul"]), actor, now)
1264
+ : payload.operation === "subagent_state" ? setSubagentState(store, mate, req["state"], actor, now)
1265
+ : tellSubagent(store, mate, String(req["note"]), actor, now);
1244
1266
  if (!done.ok)
1245
1267
  throw Error(done.said);
1246
- return { said: done.said, href: payload.operation === "teammate_state" && req["state"] === "removed" ? "/teammates" : `/teammates/${mate.id}` };
1268
+ return { said: done.said, href: payload.operation === "subagent_state" && req["state"] === "removed" ? "/settings/lead/subagents" : `/settings/lead/subagents/${mate.id}` };
1247
1269
  }
1248
1270
  /** A confirmed flow action, through the same helpers the canvas uses; then
1249
1271
  * the flow moves what it can right away, as it does after a canvas change. */
@@ -11,9 +11,9 @@
11
11
  * asked, and only while nobody has written in that thread since.
12
12
  */
13
13
  import type { ChatBinding, ChatEvent, ChatState } from "./chat-delivery-state.js";
14
- import { type MateAsk, type Store } from "./store.js";
14
+ import { type LeadAsk, type Store } from "./store.js";
15
15
  /** The question as text with its options, where no buttons are drawn. */
16
- export declare function chatAskText(ask: Pick<MateAsk, "question" | "options">): string;
16
+ export declare function chatAskText(ask: Pick<LeadAsk, "question" | "options">): string;
17
17
  /** The live buttons on one part, in the order they were minted: the options, then "Something else". None when the part
18
18
  * is not in its owner's own chat with Toolroll (a room), where a tap could not be their message. */
19
19
  export declare function chatAskButtons(state: ChatState, part: number, now: Date): Array<{
package/dist/chat-ask.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { chatHash, partContent, savedChatPart } from "./chat-delivery-state.js";
2
- import { MATE_ASK_OTHER } from "./store.js";
2
+ import { LEAD_ASK_OTHER } from "./store.js";
3
3
  /** The question as text with its options, where no buttons are drawn. */
4
4
  export function chatAskText(ask) {
5
- return [ask.question, ...ask.options.map(one => `• ${one}`), `• ${MATE_ASK_OTHER}: say it in your own words`].join("\n");
5
+ return [ask.question, ...ask.options.map(one => `• ${one}`), `• ${LEAD_ASK_OTHER}: say it in your own words`].join("\n");
6
6
  }
7
7
  /** The live buttons on one part, in the order they were minted: the options, then "Something else". None when the part
8
8
  * is not in its owner's own chat with Toolroll (a room), where a tap could not be their message. */
@@ -16,7 +16,7 @@ export function chatAskButtons(state, part, now) {
16
16
  const options = content.ask?.options ?? [];
17
17
  return state.prepare("SELECT token,choice FROM chat_ask_action WHERE provider=:provider AND part=? AND consumed IS NULL AND expires>? ORDER BY rowid").all(part, now.toISOString())
18
18
  .map(one => {
19
- const label = one.choice === null ? MATE_ASK_OTHER : options[Number(one.choice)] ?? null;
19
+ const label = one.choice === null ? LEAD_ASK_OTHER : options[Number(one.choice)] ?? null;
20
20
  return label === null ? null : { token: String(one.token), label: label.slice(0, 75), words: one.choice === null };
21
21
  })
22
22
  .filter((one) => one !== null);
@@ -51,12 +51,12 @@ export function applyChatAskTap(options, event, binding, token, now) {
51
51
  }
52
52
  const turn = Number(action["turn"]), part = Number(action["part"]);
53
53
  // Only the person the lead asked answers it: anyone else's tap changes nothing and says nothing.
54
- const asker = store.getMateTurn(turn)?.approver;
54
+ const asker = store.getLeadTurn(turn)?.approver;
55
55
  if (asker !== undefined && asker !== binding.approver) {
56
56
  state.finish(event.id);
57
57
  return true;
58
58
  }
59
- const found = asker === undefined ? { state: "expired" } : store.mateAskState(turn, now);
59
+ const found = asker === undefined ? { state: "expired" } : store.leadAskState(turn, now);
60
60
  const expired = found.state === "expired" || String(action["expires"]) <= now.toISOString();
61
61
  // A question already settled was shown so once (or is being): a later tap says nothing more.
62
62
  if (action["consumed"] !== null) {
@@ -1,12 +1,12 @@
1
- import type { DoorOutcome } from "./mate-doors.js";
1
+ import type { DoorOutcome } from "./lead-doors.js";
2
2
  import { type VerifiedApprover } from "./principal.js";
3
- import type { ChatConfig, MateProposal, MateSession, MateThread, Store, SubscriptionChatProviderId } from "./store.js";
3
+ import type { ChatConfig, LeadProposal, LeadSession, LeadThread, Store, SubscriptionChatProviderId } from "./store.js";
4
4
  export declare function channelRepos(store: Store, approver: string, registry: readonly string[]): string[];
5
- export type ResolvedMate = {
5
+ export type ResolvedLead = {
6
6
  ok: true;
7
7
  who: VerifiedApprover;
8
- session: MateSession;
9
- thread: MateThread;
8
+ session: LeadSession;
9
+ thread: LeadThread;
10
10
  config: ChatConfig & {
11
11
  provider: SubscriptionChatProviderId;
12
12
  };
@@ -25,10 +25,10 @@ export type ResolvedMate = {
25
25
  * always gets an answer — except while a turn is still running there,
26
26
  * which is "busy": the message waits its turn instead of ending it.
27
27
  */
28
- export declare function resolveChannelMate(store: Store, binding: {
28
+ export declare function resolveChannelLead(store: Store, binding: {
29
29
  approver: string;
30
30
  approverGeneration: number;
31
- }, repos: readonly string[], now: Date): ResolvedMate;
31
+ }, repos: readonly string[], now: Date): ResolvedLead;
32
32
  /** A phone exchange about one task (a reply to that task's or result's
33
33
  * message) stays in the lead conversation, and is kept in the task's own
34
34
  * chat as well, so the task shows everything asked of it wherever it was
@@ -65,10 +65,10 @@ export declare function taskInCeiling(store: Store, taskId: string, repos: reado
65
65
  export type ChatChannelName = "telegram" | "slack" | "discord" | "teams";
66
66
  /** The card text once its challenge is armed: an irreversible answer or a
67
67
  * challenge action, in the same words on every channel. */
68
- export declare function armedCardText(proposal: MateProposal, previewText: string): string;
68
+ export declare function armedCardText(proposal: LeadProposal, previewText: string): string;
69
69
  /** The "yes" button's label for an armed card. */
70
- export declare function armedYesLabel(proposal: MateProposal): string;
71
- export declare function proposalLink(store: Store, proposal: MateProposal, repos: readonly string[], channel?: ChatChannelName | null): PhoneLink | null;
70
+ export declare function armedYesLabel(proposal: LeadProposal): string;
71
+ export declare function proposalLink(store: Store, proposal: LeadProposal, repos: readonly string[], channel?: ChatChannelName | null): PhoneLink | null;
72
72
  /**
73
73
  * The link a CONFIRMED card carries: the exact recorded task the outcome
74
74
  * names, where its remaining step lives — the approval control while the
@@ -76,17 +76,17 @@ export declare function proposalLink(store: Store, proposal: MateProposal, repos
76
76
  * automatic approval, a staged resume). Kinds whose outcome is complete
77
77
  * carry none.
78
78
  */
79
- export declare function confirmedLink(store: Store, outcome: DoorOutcome, proposal: MateProposal, repos: readonly string[]): PhoneLink | null;
79
+ export declare function confirmedLink(store: Store, outcome: DoorOutcome, proposal: LeadProposal, repos: readonly string[]): PhoneLink | null;
80
80
  /** The card: plain words for what confirming does, the exact terms it binds to, and whether a button belongs on it. */
81
- export declare function proposalPreview(store: Store, proposal: MateProposal, repos: readonly string[], channel?: ChatChannelName | null): {
81
+ export declare function proposalPreview(store: Store, proposal: LeadProposal, repos: readonly string[], channel?: ChatChannelName | null): {
82
82
  text: string;
83
83
  buttons: boolean;
84
84
  };
85
85
  /** The card after it resolves, from the recorded outcome — the same words every surface shows. */
86
- export declare function proposalOutcomeText(proposal: MateProposal): string;
86
+ export declare function proposalOutcomeText(proposal: LeadProposal): string;
87
87
  export type ParitySupport = "direct" | "handoff" | "missing";
88
88
  /**
89
- * One row per mate tool: how the paired phone reaches it. `direct` means
89
+ * One row per lead tool: how the paired phone reaches it. `direct` means
90
90
  * the same engine tool or the same confirm door runs from Telegram;
91
91
  * `handoff` means the phone shows where the existing authenticated
92
92
  * control lives and does nothing itself; `missing` means no phone path
@@ -108,4 +108,4 @@ export declare function handoffCardText(text: string, note: string | null): stri
108
108
  * the console on the computer when no link exists). A scope approved under
109
109
  * a signed mode asks for nothing more. A staged resume says what remains.
110
110
  */
111
- export declare function confirmedCardText(store: Store, outcome: DoorOutcome, proposal: MateProposal, note: string | null): string;
111
+ export declare function confirmedCardText(store: Store, outcome: DoorOutcome, proposal: LeadProposal, note: string | null): string;