bazilion 0.56.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/cli.js +2 -1
  2. package/dist/cli.js.map +1 -1
  3. package/dist/daemon.js +599 -318
  4. package/dist/daemon.js.map +1 -1
  5. package/dist/web/client/assets/AddProviderDialog-DwUu2FGE.js +1 -0
  6. package/dist/web/client/assets/AgentTemplateParts-C3BasVck.js +1 -0
  7. package/dist/web/client/assets/{ConfigPage-Ch-DSJUO.js → ConfigPage-DFmHgEaL.js} +1 -1
  8. package/dist/web/client/assets/ConfirmDialog-BCOfW63x.js +1 -0
  9. package/dist/web/client/assets/ConnectionsView-BbpY5YbI.js +1 -0
  10. package/dist/web/client/assets/{ManagePage-kd7iWYEL.js → ManagePage-BzyMHGqs.js} +1 -1
  11. package/dist/web/client/assets/SectionTabs-C8H_LunZ.js +1 -0
  12. package/dist/web/client/assets/SkillsParts-DoygBgF2.js +1 -0
  13. package/dist/web/client/assets/SpawnTeamModal-BVf4yN9X.js +1 -0
  14. package/dist/web/client/assets/TeamForm-Bfb5hVUX.js +1 -0
  15. package/dist/web/client/assets/TeamThread-BFmaBj82.js +1 -0
  16. package/dist/web/client/assets/{UnsavedChangesGuard-vQBdMl8h.js → UnsavedChangesGuard-BUsIHSxO.js} +1 -1
  17. package/dist/web/client/assets/{_id-C6SADaiD.js → _id-BRD3kxrX.js} +1 -1
  18. package/dist/web/client/assets/{_id-CC9r0qsr.js → _id-BapVoTMJ.js} +1 -1
  19. package/dist/web/client/assets/{access-BbQFbTPh.js → access-CqcKius1.js} +1 -1
  20. package/dist/web/client/assets/agents-BC_ITk28.js +1 -0
  21. package/dist/web/client/assets/{agents-BXwzmHu8.js → agents-DQ8nQnD6.js} +1 -1
  22. package/dist/web/client/assets/{attention-BMrZJ9ui.js → attention-BnCihfi0.js} +1 -1
  23. package/dist/web/client/assets/config-DYS8bkQl.js +1 -0
  24. package/dist/web/client/assets/{es2015-D1pnOGPG.js → es2015-DZDOQ3kj.js} +11 -11
  25. package/dist/web/client/assets/{index-B-N6NIX4.js → index-CxXsZzDC.js} +3 -3
  26. package/dist/web/client/assets/{login-DM3q-V4R.js → login-DFVsVP0s.js} +1 -1
  27. package/dist/web/client/assets/{manage-R57MUzsY.js → manage-CpXaObuS.js} +1 -1
  28. package/dist/web/client/assets/{mcp-CSHrVH1t.js → mcp-DslGDHmN.js} +1 -1
  29. package/dist/web/client/assets/{parts-68zf8Fgw.js → parts-C104qEuC.js} +1 -1
  30. package/dist/web/client/assets/routes-D1wFPm0n.js +85 -0
  31. package/dist/web/client/assets/{skills-CPZftp9O.js → skills-DmIo3vN3.js} +1 -1
  32. package/dist/web/client/assets/style-CqkCFvvz.js +7 -0
  33. package/dist/web/client/assets/styles-C7NsCHeU.css +2 -0
  34. package/dist/web/client/assets/{system-Dd2P9eqE.js → system-CUW9JZ9c.js} +1 -1
  35. package/dist/web/client/assets/teams-DJzYsuh9.js +1 -0
  36. package/dist/web/client/assets/teams-DrhG8KiS.js +1 -0
  37. package/dist/web/client/assets/telegram-Bk_kg8hb.js +1 -0
  38. package/dist/web/client/assets/{tools-DqNXLMpc.js → tools-z9Ixmuu2.js} +1 -1
  39. package/dist/web/client/assets/{usage-BC_TStVj.js → usage-DGe3x1m7.js} +1 -1
  40. package/dist/web/client/assets/use-resource-qjIkNQDY.js +1 -0
  41. package/dist/web/client/assets/{welcome-g8wtn_or.js → welcome-DDKqxHkF.js} +1 -1
  42. package/dist/web/server/assets/{AddProviderDialog-DtkjBMv4.js → AddProviderDialog-CpLDHOcA.js} +4 -4
  43. package/dist/web/server/assets/{AgentTemplateParts-CxWyovvM.js → AgentTemplateParts-Dh9F_-T_.js} +5 -5
  44. package/dist/web/server/assets/{ConfigPage-usZi48Zr.js → ConfigPage-CrxctbtN.js} +2 -2
  45. package/dist/web/server/assets/{ConfirmDialog-DAcSBHkT.js → ConfirmDialog-C89B8qKM.js} +1 -1
  46. package/dist/web/server/assets/{ConnectionsView-Dy6uYSRI.js → ConnectionsView-DslcKQmA.js} +5 -5
  47. package/dist/web/server/assets/{Dialog-DTeF-nOZ.js → Dialog-_Gt_Nt86.js} +2 -2
  48. package/dist/web/server/assets/{ManagePage-Dy1EdovO.js → ManagePage-DGYNJ6XG.js} +2 -2
  49. package/dist/web/server/assets/{ModelMenu-D-hTgYOO.js → ModelMenu-DEJoYASj.js} +13 -1
  50. package/dist/web/server/assets/{SectionTabs-BVrMn76H.js → SectionTabs--vMBvaUz.js} +7 -1
  51. package/dist/web/server/assets/{SkillsParts-Cw05b3al.js → SkillsParts-CqS2B45v.js} +5 -5
  52. package/dist/web/server/assets/{SpawnDialog-BAE8W91z.js → SpawnDialog-BNKj2Lup.js} +10 -8
  53. package/dist/web/server/assets/{SpawnTeamModal-CgBY0HuN.js → SpawnTeamModal-zcLxtFOO.js} +4 -4
  54. package/dist/web/server/assets/{TeamForm-JyO5xJXX.js → TeamForm-XFP0l2TB.js} +9 -7
  55. package/dist/web/server/assets/{TeamThread-5o48EbXL.js → TeamThread-gYV_ToRM.js} +8 -9
  56. package/dist/web/server/assets/{UnsavedChangesGuard-CJQGu45L.js → UnsavedChangesGuard-CB_TugFF.js} +1 -1
  57. package/dist/web/server/assets/{_id-BNvm89oJ.js → _id-517adSuB.js} +1 -1
  58. package/dist/web/server/assets/{_id-BpumuCYL.js → _id-BTyd2i5U.js} +1 -1
  59. package/dist/web/server/assets/{_id-BE_RSvuN.js → _id-BsQnL9LV.js} +9 -9
  60. package/dist/web/server/assets/{_id-BfjTS4JO.js → _id-CyinHJam.js} +11 -11
  61. package/dist/web/server/assets/{_id-BW6sVrvw.js → _id-D4RFNqaJ.js} +2 -2
  62. package/dist/web/server/assets/{_id-C54t_nX6.js → _id-josYXBx3.js} +1 -1
  63. package/dist/web/server/assets/{_tanstack-start-manifest_v-BPwQX_5b.js → _tanstack-start-manifest_v-w2xn07aY.js} +78 -78
  64. package/dist/web/server/assets/{access-BhAMfi7U.js → access-B97-94Wt.js} +1 -1
  65. package/dist/web/server/assets/{access-DEyq3uP_.js → access-BdQmjMJV.js} +1 -1
  66. package/dist/web/server/assets/{access-6FWih7nC.js → access-Cc7fMMod.js} +5 -5
  67. package/dist/web/server/assets/{agents-ncyhVx-T.js → agents-BL918wVc.js} +1 -1
  68. package/dist/web/server/assets/{agents-BXuglv4G.js → agents-BlUZqqJn.js} +10 -10
  69. package/dist/web/server/assets/{agents-3hBjrd8B.js → agents-BzJFjA2i.js} +2 -2
  70. package/dist/web/server/assets/{agents-KJcDMj0Y.js → agents-CjrkaEz8.js} +9 -9
  71. package/dist/web/server/assets/{agents-rTDlRZa5.js → agents-Tg3zkmQv.js} +2 -2
  72. package/dist/web/server/assets/{agents-DhenbitX.js → agents-uw32jPWx.js} +1 -1
  73. package/dist/web/server/assets/{attention-X0U6ZmiA.js → attention-2unmuO-q.js} +1 -1
  74. package/dist/web/server/assets/{attention-CDdOCOio.js → attention-C94WWwQe.js} +1 -1
  75. package/dist/web/server/assets/{attention-DM__BzWY.js → attention-a_OmC6L3.js} +6 -6
  76. package/dist/web/server/assets/{auth-BexhV8Yq.js → auth-DuIqEAed.js} +1 -1
  77. package/dist/web/server/assets/{config-Cld8Q8N7.js → config-BG1KOtwA.js} +1 -1
  78. package/dist/web/server/assets/{config-DpgYAXQ3.js → config-Bhem9XER.js} +8 -8
  79. package/dist/web/server/assets/{config-Cx5ri2DL2.js → config-D1Li_7Yt2.js} +1 -1
  80. package/dist/web/server/assets/{daemon-client-RxAllljf.js → daemon-client-D-NWKQto.js} +1 -1
  81. package/dist/web/server/assets/{form-BEjeiSy3.js → form-Bwsyt9OY.js} +2 -2
  82. package/dist/web/server/assets/{manage-C6ucNYZW.js → manage-C7ReF2ZZ.js} +1 -1
  83. package/dist/web/server/assets/{mcp-DwCzj7eO.js → mcp-BFixpBQk.js} +1 -1
  84. package/dist/web/server/assets/{mcp-BXnWQOwM.js → mcp-BTZkDvdc.js} +5 -5
  85. package/dist/web/server/assets/{mcp-C8VLspco.js → mcp-Ceg9gzKE.js} +1 -1
  86. package/dist/web/server/assets/{open-groups-BMGYUTtY.js → open-groups-C89TEK85.js} +1 -1
  87. package/dist/web/server/assets/{parts-k9M-atPa.js → parts-B0wbj_yK.js} +1 -1
  88. package/dist/web/server/assets/{router-BttfLktO.js → router-Ci_9VxDk.js} +83 -51
  89. package/dist/web/server/assets/{routes-A7UcreVX.js → routes-CVrH9qgo.js} +1 -1
  90. package/dist/web/server/assets/{routes-B9jw-MJ8.js → routes-D9Mw1_VV.js} +297 -101
  91. package/dist/web/server/assets/{routes-BX2FV8rS.js → routes-DsuaDPTO.js} +2 -2
  92. package/dist/web/server/assets/{skills-Cd5Cfdaz.js → skills-BNbZ75am.js} +1 -1
  93. package/dist/web/server/assets/{skills-y3GsyKce.js → skills-BWwEFc4a.js} +1 -1
  94. package/dist/web/server/assets/{skills-BVAH93cd.js → skills-D5rnOmKJ.js} +7 -7
  95. package/dist/web/server/assets/{src-vrZVrV9u.js → src-BeMh8Fze.js} +11 -1
  96. package/dist/web/server/assets/{start-Dl8gQ-95.js → start-2MvkBRdC.js} +1 -1
  97. package/dist/web/server/assets/{style-BQ3H9I7Y.js → style-B3l0Wtlf.js} +1 -1
  98. package/dist/web/server/assets/{system-BJPKqM6b.js → system-Cr4C-YRw.js} +1 -1
  99. package/dist/web/server/assets/{system-C7mejQSc.js → system-DT7AU0e6.js} +3 -3
  100. package/dist/web/server/assets/{system-LsLcuVzY.js → system-DsmXkgqn.js} +1 -1
  101. package/dist/web/server/assets/{teams-CiX8LUQo.js → teams-BeStcDvQ.js} +1 -1
  102. package/dist/web/server/assets/{teams-B6gbflsZ.js → teams-CsEBLW8-.js} +11 -9
  103. package/dist/web/server/assets/{teams-D-XdIkCr.js → teams-Dix5XVIx.js} +1 -1
  104. package/dist/web/server/assets/{teams-C7kXMNgc.js → teams-DjE0swAZ.js} +8 -8
  105. package/dist/web/server/assets/{teams-CeLLd2Mf.js → teams-Rk_RED7X.js} +1 -1
  106. package/dist/web/server/assets/{teams-CPXoTggb.js → teams-u6m6JzuU.js} +1 -1
  107. package/dist/web/server/assets/{telegram-D8_V7_sW.js → telegram-BjqABrl-.js} +7 -7
  108. package/dist/web/server/assets/{telegram-D7TW3LNZ.js → telegram-CQpF3EHA.js} +1 -1
  109. package/dist/web/server/assets/{telegram-DA2dwLID.js → telegram-DhzHgDfg.js} +1 -1
  110. package/dist/web/server/assets/{tools-D1BBVkRh.js → tools-DC69leH7.js} +1 -1
  111. package/dist/web/server/assets/{tools-CluiJywK.js → tools-Dn6RnOFu.js} +1 -1
  112. package/dist/web/server/assets/{tools-CckcG9Jl.js → tools-x_DQTQtE.js} +5 -5
  113. package/dist/web/server/assets/{usage-PNNb3pPj.js → usage-4zMG0sab.js} +4 -4
  114. package/dist/web/server/assets/{usage-CrYyvPgf.js → usage-mvQegG4l.js} +1 -1
  115. package/dist/web/server/assets/{use-resource-BUA9qGGY.js → use-resource-BjN1uJoL.js} +9 -1
  116. package/dist/web/server/assets/{welcome-CwzLt6Rp.js → welcome-BuE9FRf4.js} +1 -1
  117. package/dist/web/server/assets/{welcome-CUTYf8UG.js → welcome-DYw35wl5.js} +1 -1
  118. package/dist/web/server/assets/{welcome-CYhh3iUU.js → welcome-DrYbWGd_.js} +5 -5
  119. package/dist/web/server/server.js +20 -20
  120. package/dist/worker.js +116 -12
  121. package/dist/worker.js.map +1 -1
  122. package/package.json +1 -1
  123. package/dist/web/client/assets/AddProviderDialog-DZ9mXFdq.js +0 -1
  124. package/dist/web/client/assets/AgentTemplateParts-BfG3a-ri.js +0 -1
  125. package/dist/web/client/assets/ConfirmDialog-B_jXAPmh.js +0 -1
  126. package/dist/web/client/assets/ConnectionsView-D1Liebtf.js +0 -1
  127. package/dist/web/client/assets/SectionTabs-Dc0bNn-J.js +0 -1
  128. package/dist/web/client/assets/SkillsParts-C5T7sYDA.js +0 -1
  129. package/dist/web/client/assets/SpawnTeamModal-DatFF4f_.js +0 -1
  130. package/dist/web/client/assets/TeamForm-l-N_PYeE.js +0 -1
  131. package/dist/web/client/assets/TeamThread-BWmIQiAh.js +0 -1
  132. package/dist/web/client/assets/agents-BtETzVIY.js +0 -1
  133. package/dist/web/client/assets/config-B2ZDYo52.js +0 -1
  134. package/dist/web/client/assets/routes-DOoeKVwr.js +0 -85
  135. package/dist/web/client/assets/style-Bm9QsFpy.js +0 -7
  136. package/dist/web/client/assets/styles-B-kTTvCo.css +0 -2
  137. package/dist/web/client/assets/teams-7FEpSZg1.js +0 -1
  138. package/dist/web/client/assets/teams-ClirFbDV.js +0 -1
  139. package/dist/web/client/assets/telegram-BJnT5THs.js +0 -1
  140. package/dist/web/client/assets/use-resource-Bn0Sx7r6.js +0 -1
package/dist/worker.js CHANGED
@@ -1024,11 +1024,11 @@ function assertRootUnchanged(root, canonicalRoot) {
1024
1024
  function safeKey(root, key) {
1025
1025
  const segments = key.split(/[\\/]/);
1026
1026
  if (key.length === 0 || key.includes("\0") || isAbsolute(key) || /^[A-Za-z]:[\\/]/.test(key) || key.startsWith("\\\\") || segments.includes("..")) {
1027
- throw new Error(`unsafe memory key: ${key}`);
1027
+ throw new DomainError(400, `unsafe memory key: ${key}`);
1028
1028
  }
1029
- if (!key.endsWith(".md")) throw new Error(`memory keys end in .md: ${key}`);
1029
+ if (!key.endsWith(".md")) throw new DomainError(400, `memory keys end in .md: ${key}`);
1030
1030
  const candidate = resolve2(root, key);
1031
- if (candidate === root) throw new Error(`unsafe memory key: ${key}`);
1031
+ if (candidate === root) throw new DomainError(400, `unsafe memory key: ${key}`);
1032
1032
  assertContained(root, candidate);
1033
1033
  return candidate;
1034
1034
  }
@@ -1485,6 +1485,8 @@ function piMessagesToProviderView(messages, secrets = []) {
1485
1485
  const toolCalls = extractAssistantToolCalls(am);
1486
1486
  const msg = { role: "assistant", content: text };
1487
1487
  if (toolCalls.length > 0) msg.toolCalls = toolCalls;
1488
+ if (am.stopReason === "aborted") msg.stopped = "cancelled";
1489
+ else if (am.stopReason === "error") msg.stopped = "failed";
1488
1490
  out.push(msg);
1489
1491
  break;
1490
1492
  }
@@ -1745,6 +1747,8 @@ function browserGuideSection(attached = false) {
1745
1747
 
1746
1748
  // ../daemon/src/runtime/session/prompt.ts
1747
1749
  var SANDBOX_SKILLS_DIR = "/skills";
1750
+ var MAX_LISTED_TEAMMATES = 40;
1751
+ var MAX_LISTED_OUTSIDE = 20;
1748
1752
  function loadPromptSkills(skillsDir, attachedNames) {
1749
1753
  if (!existsSync(skillsDir) || attachedNames.length === 0) return [];
1750
1754
  const attached = new Set(attachedNames);
@@ -1809,7 +1813,16 @@ ${contextBlocks.join("\n\n")}`
1809
1813
  });
1810
1814
  }
1811
1815
  const bootstrap = homeDocuments["BOOTSTRAP.md"]?.trimEnd();
1812
- if (bootstrap) {
1816
+ if (bootstrap && options.withOperator === false) {
1817
+ parts.push({
1818
+ id: "first-run",
1819
+ text: [
1820
+ "# First-Run Ritual",
1821
+ "",
1822
+ "You have not had your first conversation with the human yet; it waits until they talk to you. This turn was not started by them (a teammate wrote to you, or a schedule fired), so nobody is here to answer its questions: do not greet the human or ask who you are. Do the work this turn asks for, with what you know."
1823
+ ].join("\n")
1824
+ });
1825
+ } else if (bootstrap) {
1813
1826
  parts.push({
1814
1827
  id: "first-run",
1815
1828
  text: [
@@ -1821,6 +1834,9 @@ ${contextBlocks.join("\n\n")}`
1821
1834
  "- Your first reply is ONLY a greeting + ONE question. No tool calls. Wait for the human to answer.",
1822
1835
  "- Each subsequent turn: at most one new question. Wait between turns.",
1823
1836
  "- Only after the ritual is complete (you have enough to write IDENTITY.md): call `home_write` once, then `bootstrap_done`.",
1837
+ ...agent.team.userMd.trim() ? [
1838
+ "- The Team's USER.md (under About the User) already says some things about the human: do not ask what it answers."
1839
+ ] : [],
1824
1840
  "",
1825
1841
  "## BOOTSTRAP.md",
1826
1842
  "",
@@ -1891,6 +1907,7 @@ ${contextBlocks.join("\n\n")}`
1891
1907
  "",
1892
1908
  "An `AGENTS.md` file in the workspace holds repository instructions that govern its own directory and everything below it. The ones from the workspace root down to your working directory are already in your project instructions; read any other `AGENTS.md` on the path to files you edit."
1893
1909
  ];
1910
+ teamLines.push("", ...teammateLines(agent, options));
1894
1911
  parts.push({ id: "team", text: teamLines.join("\n") });
1895
1912
  if (agent.team.userMd.trim()) {
1896
1913
  parts.push({
@@ -1926,6 +1943,44 @@ ${reviewedLessons.map((lesson) => `- ${lesson}`).join("\n")}`
1926
1943
  });
1927
1944
  return parts;
1928
1945
  }
1946
+ function teammateLines(agent, options) {
1947
+ const contacts = options.contacts ?? [];
1948
+ const line = (text) => text.replace(/[\p{Cc}\p{Cf}\u2028\u2029\s]+/gu, " ").trim();
1949
+ const entry = (contact, team) => `- ${line(contact.name)}: id ${contact.id}${team ? "" : `, Team ${line(contact.teamName)}`} (template ${line(contact.template)})`;
1950
+ const listed = (list4, max, team) => [
1951
+ ...list4.slice(0, max).map((contact) => entry(contact, team)),
1952
+ ...list4.length > max ? [`- and ${list4.length - max} more`] : []
1953
+ ];
1954
+ const teammates = contacts.filter((contact) => contact.teamId === agent.team.id);
1955
+ const reachable = teammates.filter((contact) => contact.canMessage);
1956
+ const unreachable = teammates.filter((contact) => !contact.canMessage);
1957
+ const outside = contacts.filter((contact) => contact.teamId !== agent.team.id);
1958
+ const create2 = options.canCreateAgents ? " When the human asks you to add teammates, create them with `agent_create`." : "";
1959
+ const lines = ["## Your teammates", ""];
1960
+ if (teammates.length === 0) {
1961
+ lines.push(`You are the only Agent in this Team so far.${create2}`);
1962
+ } else {
1963
+ lines.push(
1964
+ `Message an Agent with \`send_message\`: put its id (or its exact name) in \`to\`. These are current; do not ask the human for ids.${create2}`
1965
+ );
1966
+ if (reachable.length > 0) lines.push("", ...listed(reachable, MAX_LISTED_TEAMMATES, true));
1967
+ if (unreachable.length > 0) {
1968
+ lines.push(
1969
+ "",
1970
+ "In this restricted Team you have no connection to these teammates, so you cannot message them; the human can connect you in the Team's Connections view:",
1971
+ ...listed(unreachable, MAX_LISTED_TEAMMATES, true)
1972
+ );
1973
+ }
1974
+ }
1975
+ if (outside.length > 0) {
1976
+ lines.push(
1977
+ "",
1978
+ "Team Policy also lets you message these Agents of other Teams:",
1979
+ ...listed(outside, MAX_LISTED_OUTSIDE, false)
1980
+ );
1981
+ }
1982
+ return lines;
1983
+ }
1929
1984
  function boundReviewedLessons(lessons, maxCharacters = 8e3) {
1930
1985
  const selected = [];
1931
1986
  let used = 0;
@@ -3011,11 +3066,11 @@ function messagingTools(host, fromAgentId) {
3011
3066
  {
3012
3067
  def: {
3013
3068
  name: "send_message",
3014
- description: `Send a message to another agent. Use the recipient's agent id (UUID). Use this ONLY for things the recipient needs to ACT on: delegating a task, asking a peer for information you cannot get yourself, escalating a decision. Do NOT use it for status updates or to announce changes to team-shared resources \u2014 USER.md and the team memory backend both propagate to every agent in the team automatically on their next turn, so messages like "I updated USER.md" or "I wrote a new memory note" are pure noise and will trigger an inbox-wake loop on the recipient.`,
3069
+ description: 'Send a message to another agent: `to` is its id, or its exact name (your teammates are listed in your instructions). Use this ONLY for things the recipient needs to ACT on: delegating a task, asking a peer for information you cannot get yourself, escalating a decision. Do NOT use it for status updates or to announce changes to team-shared resources \u2014 USER.md and the team memory backend both propagate to every agent in the team automatically on their next turn, so messages like "I updated USER.md" or "I wrote a new memory note" are pure noise and will trigger an inbox-wake loop on the recipient.',
3015
3070
  parameters: {
3016
3071
  type: "object",
3017
3072
  properties: {
3018
- to: { type: "string", description: "Recipient agent id" },
3073
+ to: { type: "string", description: "Recipient Agent id, or its exact name" },
3019
3074
  text: { type: "string", description: "Message text" },
3020
3075
  reply_to: {
3021
3076
  type: "string",
@@ -3030,9 +3085,6 @@ function messagingTools(host, fromAgentId) {
3030
3085
  const text = String(args.text ?? "");
3031
3086
  if (!to) throw new Error('send_message: "to" is required');
3032
3087
  if (!text) throw new Error('send_message: "text" is required');
3033
- if (!await host.agentExists(to)) {
3034
- throw new Error(`send_message: agent not found: ${to}`);
3035
- }
3036
3088
  const replyTo = typeof args.reply_to === "string" ? args.reply_to : null;
3037
3089
  const { messageId } = await host.sendMessage({
3038
3090
  from: fromAgentId,
@@ -3115,6 +3167,51 @@ function messagingTools(host, fromAgentId) {
3115
3167
  ];
3116
3168
  }
3117
3169
 
3170
+ // ../daemon/src/runtime/tools/team.ts
3171
+ function agentCreateTool(host) {
3172
+ return {
3173
+ def: {
3174
+ name: "agent_create",
3175
+ description: "Add a new Agent to your Team, when the operator asks you to (to build a team, or to hand part of the work to a specialist). It joins your Team, shares its workspace and memory, and starts knowing its role and that you made it: give it a clear name and say what it is for. It uses your model and Agent template unless you name others. In a restricted Team it is connected with you both ways. Message it afterwards with send_message, by the id this returns. Do not create Agents the operator did not ask for, or several for one job.",
3176
+ parameters: {
3177
+ type: "object",
3178
+ properties: {
3179
+ name: {
3180
+ type: "string",
3181
+ description: 'Its name, unique in your Team, e.g. "Lead Researcher"'
3182
+ },
3183
+ role: {
3184
+ type: "string",
3185
+ description: "What it is for and how it should work, in a few sentences: its job, what it delivers and to whom, and its limits"
3186
+ },
3187
+ template: {
3188
+ type: "string",
3189
+ description: "Optional: an Agent template id (default: your own)"
3190
+ },
3191
+ model: {
3192
+ type: "string",
3193
+ description: 'Optional: a model as "provider:model" (default: your own model)'
3194
+ }
3195
+ },
3196
+ required: ["name", "role"]
3197
+ }
3198
+ },
3199
+ async invoke(args) {
3200
+ const created = await host.createAgent({
3201
+ name: String(args.name ?? ""),
3202
+ role: String(args.role ?? ""),
3203
+ ...typeof args.template === "string" && args.template ? { template: args.template } : {},
3204
+ ...typeof args.model === "string" && args.model ? { model: args.model } : {}
3205
+ });
3206
+ return [
3207
+ `Created ${created.name} (id ${created.id}) in ${created.teamName}, from the template ${created.template}, on ${created.model}.`,
3208
+ created.connected ? "It is connected with you both ways." : "",
3209
+ "Brief it with send_message to that id."
3210
+ ].filter(Boolean).join(" ");
3211
+ }
3212
+ };
3213
+ }
3214
+
3118
3215
  // ../daemon/src/runtime/tools/user-md.ts
3119
3216
  function userMdTools(host, teamId) {
3120
3217
  return [
@@ -3821,6 +3918,7 @@ function createBazilionCustomTools(opts) {
3821
3918
  if (opts.fileSink) handlers.push(deliverFileTool(opts.agent.team.path, opts.fileSink));
3822
3919
  if (opts.imageGenerationHost) handlers.push(imageGenerateTool(opts.imageGenerationHost));
3823
3920
  if (opts.askUser) handlers.push(askUserTool(opts.askUser));
3921
+ if (opts.teamHost) handlers.push(agentCreateTool(opts.teamHost));
3824
3922
  return handlers.map(ourToolToPiTool);
3825
3923
  }
3826
3924
 
@@ -3905,6 +4003,7 @@ function turnSurface(opts) {
3905
4003
  imageGenerationHost: opts.imageGenerationHost,
3906
4004
  webSearchHost: opts.webSearchHost,
3907
4005
  askUser: opts.askUser,
4006
+ teamHost: opts.teamHost,
3908
4007
  env
3909
4008
  });
3910
4009
  const promptOptions = {
@@ -3912,7 +4011,10 @@ function turnSurface(opts) {
3912
4011
  sandboxMode: shellTools.config.sandboxMode,
3913
4012
  // The guides ride along exactly when their tools are admitted.
3914
4013
  ...opts.browserHost ? { browserGuide: resolveBrowserConfig(env).attach ? "attached" : true } : {},
3915
- ...opts.webSearchHost ? { searchGuide: true } : {}
4014
+ ...opts.webSearchHost ? { searchGuide: true } : {},
4015
+ contacts: opts.contacts ?? [],
4016
+ canCreateAgents: opts.teamHost !== void 0,
4017
+ withOperator: opts.withOperator ?? true
3916
4018
  };
3917
4019
  return {
3918
4020
  cwd,
@@ -4271,7 +4373,6 @@ async function openAgentTurn(input, call) {
4271
4373
  refreshApiKey: ipcRefresher(input, call),
4272
4374
  mcpTools: input.mcpTools,
4273
4375
  messagingHost: served.has("messagingHost") ? {
4274
- agentExists: (agentId) => call("agentExists", { agentId }),
4275
4376
  sendMessage: (args) => call("sendMessage", args),
4276
4377
  listInbox: (agentId, { unreadOnly }) => call("listInbox", { agentId, unreadOnly }),
4277
4378
  markRead: async (messageId) => {
@@ -4304,7 +4405,10 @@ async function openAgentTurn(input, call) {
4304
4405
  });
4305
4406
  return result;
4306
4407
  } : void 0,
4307
- bashApprovalHost: served.has("bashApprovalHost") ? ipcBashApproval(call, input) : void 0
4408
+ bashApprovalHost: served.has("bashApprovalHost") ? ipcBashApproval(call, input) : void 0,
4409
+ teamHost: served.has("teamHost") ? { createAgent: (args) => call("createAgent", args) } : void 0,
4410
+ contacts: input.contacts,
4411
+ withOperator: input.withOperator
4308
4412
  });
4309
4413
  }
4310
4414
  async function openReview(input, call) {