@esso0428/pi-subagents 0.17.5 → 0.17.7

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 (263) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CONTRIBUTING.md +4 -0
  3. package/README.md +1 -1
  4. package/dist/abortable.d.ts +13 -0
  5. package/dist/abortable.d.ts.map +1 -0
  6. package/dist/abortable.js +43 -0
  7. package/dist/abortable.js.map +1 -0
  8. package/dist/agent-color.d.ts +36 -0
  9. package/dist/agent-color.d.ts.map +1 -0
  10. package/dist/agent-color.js +124 -0
  11. package/dist/agent-color.js.map +1 -0
  12. package/dist/agent-file-toggle.d.ts +126 -0
  13. package/dist/agent-file-toggle.d.ts.map +1 -0
  14. package/dist/agent-file-toggle.js +259 -0
  15. package/dist/agent-file-toggle.js.map +1 -0
  16. package/dist/agent-history.d.ts +4 -0
  17. package/dist/agent-history.d.ts.map +1 -1
  18. package/dist/agent-history.js +47 -1
  19. package/dist/agent-history.js.map +1 -1
  20. package/dist/agent-manager.d.ts +370 -56
  21. package/dist/agent-manager.d.ts.map +1 -1
  22. package/dist/agent-manager.js +1123 -409
  23. package/dist/agent-manager.js.map +1 -1
  24. package/dist/agent-runner.d.ts +100 -10
  25. package/dist/agent-runner.d.ts.map +1 -1
  26. package/dist/agent-runner.js +166 -21
  27. package/dist/agent-runner.js.map +1 -1
  28. package/dist/agent-types.d.ts +57 -5
  29. package/dist/agent-types.d.ts.map +1 -1
  30. package/dist/agent-types.js +164 -32
  31. package/dist/agent-types.js.map +1 -1
  32. package/dist/child-context.d.ts +3 -0
  33. package/dist/child-context.d.ts.map +1 -0
  34. package/dist/child-context.js +13 -0
  35. package/dist/child-context.js.map +1 -0
  36. package/dist/cross-extension-rpc.d.ts +23 -3
  37. package/dist/cross-extension-rpc.d.ts.map +1 -1
  38. package/dist/cross-extension-rpc.js +79 -17
  39. package/dist/cross-extension-rpc.js.map +1 -1
  40. package/dist/custom-agents.d.ts +38 -1
  41. package/dist/custom-agents.d.ts.map +1 -1
  42. package/dist/custom-agents.js +164 -12
  43. package/dist/custom-agents.js.map +1 -1
  44. package/dist/index.d.ts +34 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +1908 -495
  47. package/dist/index.js.map +1 -1
  48. package/dist/invocation-config.d.ts +87 -2
  49. package/dist/invocation-config.d.ts.map +1 -1
  50. package/dist/invocation-config.js +71 -3
  51. package/dist/invocation-config.js.map +1 -1
  52. package/dist/mention-clone.d.ts +88 -0
  53. package/dist/mention-clone.d.ts.map +1 -0
  54. package/dist/mention-clone.js +154 -0
  55. package/dist/mention-clone.js.map +1 -0
  56. package/dist/mention.d.ts +82 -0
  57. package/dist/mention.d.ts.map +1 -0
  58. package/dist/mention.js +132 -0
  59. package/dist/mention.js.map +1 -0
  60. package/dist/model-resolver.d.ts +17 -0
  61. package/dist/model-resolver.d.ts.map +1 -1
  62. package/dist/model-resolver.js +15 -0
  63. package/dist/model-resolver.js.map +1 -1
  64. package/dist/model-scope.d.ts +50 -0
  65. package/dist/model-scope.d.ts.map +1 -0
  66. package/dist/model-scope.js +49 -0
  67. package/dist/model-scope.js.map +1 -0
  68. package/dist/nested-tools.d.ts +57 -0
  69. package/dist/nested-tools.d.ts.map +1 -0
  70. package/dist/nested-tools.js +301 -0
  71. package/dist/nested-tools.js.map +1 -0
  72. package/dist/output-file.d.ts +22 -3
  73. package/dist/output-file.d.ts.map +1 -1
  74. package/dist/output-file.js +58 -7
  75. package/dist/output-file.js.map +1 -1
  76. package/dist/prompts.d.ts +23 -0
  77. package/dist/prompts.d.ts.map +1 -1
  78. package/dist/prompts.js +20 -2
  79. package/dist/prompts.js.map +1 -1
  80. package/dist/schedule.d.ts.map +1 -1
  81. package/dist/schedule.js +36 -15
  82. package/dist/schedule.js.map +1 -1
  83. package/dist/settings.d.ts +228 -2
  84. package/dist/settings.d.ts.map +1 -1
  85. package/dist/settings.js +94 -0
  86. package/dist/settings.js.map +1 -1
  87. package/dist/status-note.d.ts +49 -1
  88. package/dist/status-note.d.ts.map +1 -1
  89. package/dist/status-note.js +62 -1
  90. package/dist/status-note.js.map +1 -1
  91. package/dist/structured-output.d.ts +62 -0
  92. package/dist/structured-output.d.ts.map +1 -0
  93. package/dist/structured-output.js +113 -0
  94. package/dist/structured-output.js.map +1 -0
  95. package/dist/types.d.ts +176 -10
  96. package/dist/types.d.ts.map +1 -1
  97. package/dist/ui/agent-mention.d.ts +83 -0
  98. package/dist/ui/agent-mention.d.ts.map +1 -0
  99. package/dist/ui/agent-mention.js +188 -0
  100. package/dist/ui/agent-mention.js.map +1 -0
  101. package/dist/ui/agent-widget.d.ts +96 -75
  102. package/dist/ui/agent-widget.d.ts.map +1 -1
  103. package/dist/ui/agent-widget.js +397 -420
  104. package/dist/ui/agent-widget.js.map +1 -1
  105. package/dist/ui/conversation-blocks.d.ts.map +1 -1
  106. package/dist/ui/conversation-blocks.js +6 -0
  107. package/dist/ui/conversation-blocks.js.map +1 -1
  108. package/dist/ui/conversation-timeline.d.ts +10 -2
  109. package/dist/ui/conversation-timeline.d.ts.map +1 -1
  110. package/dist/ui/conversation-timeline.js +130 -23
  111. package/dist/ui/conversation-timeline.js.map +1 -1
  112. package/dist/ui/conversation-viewer.d.ts +20 -5
  113. package/dist/ui/conversation-viewer.d.ts.map +1 -1
  114. package/dist/ui/conversation-viewer.js +274 -73
  115. package/dist/ui/conversation-viewer.js.map +1 -1
  116. package/dist/ui/fleet-list.d.ts +198 -0
  117. package/dist/ui/fleet-list.d.ts.map +1 -0
  118. package/dist/ui/fleet-list.js +487 -0
  119. package/dist/ui/fleet-list.js.map +1 -0
  120. package/dist/ui/schedule-menu.d.ts.map +1 -1
  121. package/dist/ui/schedule-menu.js +6 -7
  122. package/dist/ui/schedule-menu.js.map +1 -1
  123. package/dist/ui/select-item.d.ts +28 -0
  124. package/dist/ui/select-item.d.ts.map +1 -0
  125. package/dist/ui/select-item.js +35 -0
  126. package/dist/ui/select-item.js.map +1 -0
  127. package/dist/ui/workflow-card.d.ts +176 -0
  128. package/dist/ui/workflow-card.d.ts.map +1 -0
  129. package/dist/ui/workflow-card.js +333 -0
  130. package/dist/ui/workflow-card.js.map +1 -0
  131. package/dist/ui/workflow-dialog.d.ts +306 -0
  132. package/dist/ui/workflow-dialog.d.ts.map +1 -0
  133. package/dist/ui/workflow-dialog.js +844 -0
  134. package/dist/ui/workflow-dialog.js.map +1 -0
  135. package/dist/ui/workflow-menu.d.ts +61 -0
  136. package/dist/ui/workflow-menu.d.ts.map +1 -0
  137. package/dist/ui/workflow-menu.js +148 -0
  138. package/dist/ui/workflow-menu.js.map +1 -0
  139. package/dist/usage.d.ts +86 -1
  140. package/dist/usage.d.ts.map +1 -1
  141. package/dist/usage.js +72 -1
  142. package/dist/usage.js.map +1 -1
  143. package/dist/workflow/collisions.d.ts +96 -0
  144. package/dist/workflow/collisions.d.ts.map +1 -0
  145. package/dist/workflow/collisions.js +89 -0
  146. package/dist/workflow/collisions.js.map +1 -0
  147. package/dist/workflow/entry.d.ts +33 -0
  148. package/dist/workflow/entry.d.ts.map +1 -0
  149. package/dist/workflow/entry.js +30 -0
  150. package/dist/workflow/entry.js.map +1 -0
  151. package/dist/workflow/host.d.ts +63 -0
  152. package/dist/workflow/host.d.ts.map +1 -0
  153. package/dist/workflow/host.js +363 -0
  154. package/dist/workflow/host.js.map +1 -0
  155. package/dist/workflow/journal.d.ts +98 -0
  156. package/dist/workflow/journal.d.ts.map +1 -0
  157. package/dist/workflow/journal.js +121 -0
  158. package/dist/workflow/journal.js.map +1 -0
  159. package/dist/workflow/json-schema.d.ts +52 -0
  160. package/dist/workflow/json-schema.d.ts.map +1 -0
  161. package/dist/workflow/json-schema.js +112 -0
  162. package/dist/workflow/json-schema.js.map +1 -0
  163. package/dist/workflow/meta.d.ts +68 -0
  164. package/dist/workflow/meta.d.ts.map +1 -0
  165. package/dist/workflow/meta.js +318 -0
  166. package/dist/workflow/meta.js.map +1 -0
  167. package/dist/workflow/progress.d.ts +225 -0
  168. package/dist/workflow/progress.d.ts.map +1 -0
  169. package/dist/workflow/progress.js +362 -0
  170. package/dist/workflow/progress.js.map +1 -0
  171. package/dist/workflow/runtime.d.ts +335 -0
  172. package/dist/workflow/runtime.d.ts.map +1 -0
  173. package/dist/workflow/runtime.js +831 -0
  174. package/dist/workflow/runtime.js.map +1 -0
  175. package/dist/workflow/saved.d.ts +91 -0
  176. package/dist/workflow/saved.d.ts.map +1 -0
  177. package/dist/workflow/saved.js +204 -0
  178. package/dist/workflow/saved.js.map +1 -0
  179. package/dist/workflow/task.d.ts +137 -0
  180. package/dist/workflow/task.d.ts.map +1 -0
  181. package/dist/workflow/task.js +208 -0
  182. package/dist/workflow/task.js.map +1 -0
  183. package/dist/workflow/tool-description.d.ts +39 -0
  184. package/dist/workflow/tool-description.d.ts.map +1 -0
  185. package/dist/workflow/tool-description.js +200 -0
  186. package/dist/workflow/tool-description.js.map +1 -0
  187. package/dist/workflow/worker-source.d.ts +48 -0
  188. package/dist/workflow/worker-source.d.ts.map +1 -0
  189. package/dist/workflow/worker-source.js +779 -0
  190. package/dist/workflow/worker-source.js.map +1 -0
  191. package/dist/worktree.d.ts +10 -3
  192. package/dist/worktree.d.ts.map +1 -1
  193. package/dist/worktree.js +58 -54
  194. package/dist/worktree.js.map +1 -1
  195. package/dist/xml.d.ts +11 -0
  196. package/dist/xml.d.ts.map +1 -0
  197. package/dist/xml.js +13 -0
  198. package/dist/xml.js.map +1 -0
  199. package/docs/rpc.md +183 -0
  200. package/docs/superpowers/plans/2026-09-30-conversation-viewer-scrollbar.md +216 -0
  201. package/docs/superpowers/plans/2026-09-30-upstream-event-workflow-partial-history.md +195 -0
  202. package/docs/superpowers/specs/2026-09-30-conversation-viewer-scrollbar-design.md +82 -0
  203. package/docs/superpowers/specs/2026-09-30-upstream-event-workflow-partial-history-design.md +49 -0
  204. package/docs/workflows.md +437 -0
  205. package/examples/agent-tool-description.md +7 -7
  206. package/examples/workflows/compose.js +51 -0
  207. package/examples/workflows/fan-out-audit.js +47 -0
  208. package/examples/workflows/gated-fix.js +60 -0
  209. package/examples/workflows/lib/count-child.js +27 -0
  210. package/examples/workflows/review-panel.js +63 -0
  211. package/examples/workflows/structured-findings.js +78 -0
  212. package/package.json +1 -1
  213. package/src/abortable.ts +43 -0
  214. package/src/agent-color.ts +161 -0
  215. package/src/agent-file-toggle.ts +269 -0
  216. package/src/agent-history.ts +54 -2
  217. package/src/agent-manager.ts +1263 -402
  218. package/src/agent-runner.ts +251 -27
  219. package/src/agent-types.ts +188 -32
  220. package/src/child-context.ts +15 -0
  221. package/src/cross-extension-rpc.ts +96 -20
  222. package/src/custom-agents.ts +170 -13
  223. package/src/index.ts +2024 -537
  224. package/src/invocation-config.ts +118 -3
  225. package/src/mention-clone.ts +196 -0
  226. package/src/mention.ts +141 -0
  227. package/src/model-resolver.ts +18 -0
  228. package/src/model-scope.ts +70 -0
  229. package/src/nested-tools.ts +424 -0
  230. package/src/output-file.ts +61 -6
  231. package/src/prompts.ts +45 -2
  232. package/src/schedule.ts +35 -14
  233. package/src/settings.ts +312 -2
  234. package/src/status-note.ts +66 -1
  235. package/src/structured-output.ts +130 -0
  236. package/src/types.ts +177 -10
  237. package/src/ui/agent-mention.ts +216 -0
  238. package/src/ui/agent-widget.ts +389 -441
  239. package/src/ui/conversation-blocks.ts +6 -0
  240. package/src/ui/conversation-timeline.ts +139 -25
  241. package/src/ui/conversation-viewer.ts +284 -69
  242. package/src/ui/fleet-list.ts +558 -0
  243. package/src/ui/schedule-menu.ts +9 -8
  244. package/src/ui/select-item.ts +45 -0
  245. package/src/ui/workflow-card.ts +470 -0
  246. package/src/ui/workflow-dialog.ts +1115 -0
  247. package/src/ui/workflow-menu.ts +193 -0
  248. package/src/usage.ts +109 -2
  249. package/src/workflow/collisions.ts +123 -0
  250. package/src/workflow/entry.ts +47 -0
  251. package/src/workflow/host.ts +403 -0
  252. package/src/workflow/journal.ts +164 -0
  253. package/src/workflow/json-schema.ts +128 -0
  254. package/src/workflow/meta.ts +325 -0
  255. package/src/workflow/progress.ts +550 -0
  256. package/src/workflow/runtime.ts +1219 -0
  257. package/src/workflow/saved.ts +217 -0
  258. package/src/workflow/task.ts +302 -0
  259. package/src/workflow/tool-description.ts +200 -0
  260. package/src/workflow/worker-source.ts +781 -0
  261. package/src/worktree.ts +69 -55
  262. package/src/xml.ts +13 -0
  263. package/vitest.config.ts +0 -18
@@ -1,13 +1,81 @@
1
- export function resolveAgentInvocationConfig(agentConfig, params) {
1
+ import { Type } from "@sinclair/typebox";
2
+ /**
3
+ * The model-facing `isolation` parameter, shared by the `Agent` tool and the
4
+ * nested delegation tool so the two cannot drift.
5
+ *
6
+ * Shape matters more than wording here. As a single-value optional literal,
7
+ * models that fill every optional parameter — the transcript on #231 shows one
8
+ * emitting `resume: ""`, `schedule: ""` and `model: "default"` alongside it —
9
+ * had only `"worktree"` available to fill it with, and kept spawning worktrees
10
+ * across three turns while their own reasoning said to omit the field. Every
11
+ * other optional parameter has an inert filler; this one did not. `"off"` is
12
+ * listed first and described as the default so the harmless value is the
13
+ * obvious one to reach for.
14
+ *
15
+ * The wording tracks Claude Code's own `isolation` parameter, whose phrasing
16
+ * models have the most exposure to: one description on the union rather than
17
+ * per-value ones, opening "Isolation mode.", then a sentence per value in
18
+ * schema order, each with its caveats in a trailing parenthetical. Two clauses
19
+ * are ours, because our shape is not theirs — `"off"` has no counterpart there
20
+ * (their enum is `worktree | remote`, so both of their values do something),
21
+ * and neither does the uncommitted-work warning, which is the specific trap
22
+ * #231 fell into. Deliberately absent is any "only use a worktree when…"
23
+ * restriction: Claude Code's `Agent` tool states the capability and stops, and
24
+ * a second legal value is what lets a model decline one, not being told to.
25
+ */
26
+ const isolationParamShape = {
27
+ isolation: Type.Optional(Type.Union([Type.Literal("off"), Type.Literal("worktree")], {
28
+ description: 'Isolation mode. Default "off". "off" runs the agent in the current checkout, the same as omitting the field. "worktree" creates a temporary git worktree so the agent works on an isolated copy of the repo (a copy cannot see uncommitted or staged changes in the main checkout).',
29
+ })),
30
+ };
31
+ /**
32
+ * Build the `isolation` parameter for a tool schema, or nothing when the
33
+ * project disabled worktrees (`worktreeIsolation: false`).
34
+ *
35
+ * Dropping the field beats accepting it and quietly downgrading. The setting is
36
+ * for a project whose model passes `"worktree"` on *every* call, so a
37
+ * per-result "isolation was disabled" note would be noise on every result and
38
+ * would keep raising the salience of a capability that isn't there. With no
39
+ * field there is nothing to pass, nothing to drop, and nothing to explain — the
40
+ * same trade `scheduleParam` makes for disabled scheduling, at zero LLM-context
41
+ * cost. The resolver gate and the `agent-manager` check still cover the paths a
42
+ * schema can't reach: agent files, the scheduler, and cross-extension RPC.
43
+ *
44
+ * Like `scheduleParam`, this is read once at tool registration — flipping the
45
+ * setting needs a new pi session for the schema to change.
46
+ */
47
+ export function isolationParam(enabled) {
48
+ return enabled ? isolationParamShape : {};
49
+ }
50
+ export function resolveAgentInvocationConfig(agentConfig, params, opts) {
51
+ // Precedence first, collapse second — reversing these loses the veto, since
52
+ // an agent file's "off" only outranks a caller's "worktree" while it is still
53
+ // a value. Everything downstream then sees "worktree" or nothing at all.
54
+ const requested = agentConfig?.isolation ?? params.isolation;
55
+ const isolation = requested === "worktree" && opts?.worktreeAllowed !== false ? "worktree" : undefined;
56
+ const overriddenThinking = agentConfig?.thinking != null && params.thinking != null
57
+ && agentConfig.thinking !== params.thinking
58
+ ? params.thinking
59
+ : undefined;
60
+ const overriddenModel = agentConfig?.model != null && params.model != null
61
+ && agentConfig.model !== params.model
62
+ ? params.model
63
+ : undefined;
2
64
  return {
3
65
  modelInput: agentConfig?.model ?? params.model,
4
66
  modelFromParams: agentConfig?.model == null && params.model != null,
5
67
  thinking: (agentConfig?.thinking ?? params.thinking),
6
68
  maxTurns: agentConfig?.maxTurns ?? params.max_turns,
7
69
  inheritContext: agentConfig?.inheritContext ?? params.inherit_context ?? false,
8
- runInBackground: agentConfig?.runInBackground ?? params.run_in_background ?? false,
70
+ runInBackground: agentConfig?.runInBackground ?? params.run_in_background ?? opts?.defaultRunInBackground ?? false,
9
71
  isolated: agentConfig?.isolated ?? params.isolated ?? false,
10
- isolation: agentConfig?.isolation ?? params.isolation,
72
+ isolation,
73
+ // Undefined rather than an empty object when nothing was overridden: callers
74
+ // spread this into the invocation snapshot, and an always-present key would
75
+ // put `requestedThinking: undefined` on every record.
76
+ overridden: overriddenThinking || overriddenModel
77
+ ? { thinking: overriddenThinking, model: overriddenModel }
78
+ : undefined,
11
79
  };
12
80
  }
13
81
  export function resolveJoinMode(defaultJoinMode, runInBackground) {
@@ -1 +1 @@
1
- {"version":3,"file":"invocation-config.js","sourceRoot":"","sources":["../src/invocation-config.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,4BAA4B,CAC1C,WAAoC,EACpC,MAA6B;IAW7B,OAAO;QACL,UAAU,EAAE,WAAW,EAAE,KAAK,IAAI,MAAM,CAAC,KAAK;QAC9C,eAAe,EAAE,WAAW,EAAE,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,KAAK,IAAI,IAAI;QACnE,QAAQ,EAAE,CAAC,WAAW,EAAE,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAA8B;QACjF,QAAQ,EAAE,WAAW,EAAE,QAAQ,IAAI,MAAM,CAAC,SAAS;QACnD,cAAc,EAAE,WAAW,EAAE,cAAc,IAAI,MAAM,CAAC,eAAe,IAAI,KAAK;QAC9E,eAAe,EAAE,WAAW,EAAE,eAAe,IAAI,MAAM,CAAC,iBAAiB,IAAI,KAAK;QAClF,QAAQ,EAAE,WAAW,EAAE,QAAQ,IAAI,MAAM,CAAC,QAAQ,IAAI,KAAK;QAC3D,SAAS,EAAE,WAAW,EAAE,SAAS,IAAI,MAAM,CAAC,SAAS;KACtD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,eAAyB,EAAE,eAAwB;IACjF,OAAO,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC"}
1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AAK;QACrC,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO;QACL,UAAU,EAAE,WAAW,EAAE,KAAK,IAAI,MAAM,CAAC,KAAK;QAC9C,eAAe,EAAE,WAAW,EAAE,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,KAAK,IAAI,IAAI;QACnE,QAAQ,EAAE,CAAC,WAAW,EAAE,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAA8B;QACjF,QAAQ,EAAE,WAAW,EAAE,QAAQ,IAAI,MAAM,CAAC,SAAS;QACnD,cAAc,EAAE,WAAW,EAAE,cAAc,IAAI,MAAM,CAAC,eAAe,IAAI,KAAK;QAC9E,eAAe,EAAE,WAAW,EAAE,eAAe,IAAI,MAAM,CAAC,iBAAiB,IAAI,IAAI,EAAE,sBAAsB,IAAI,KAAK;QAClH,QAAQ,EAAE,WAAW,EAAE,QAAQ,IAAI,MAAM,CAAC,QAAQ,IAAI,KAAK;QAC3D,SAAS;QACT,6EAA6E;QAC7E,4EAA4E;QAC5E,sDAAsD;QACtD,UAAU,EAAE,kBAAkB,IAAI,eAAe;YAC/C,CAAC,CAAC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,KAAK,EAAE,eAAe,EAAE;YAC1D,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,eAAyB,EAAE,eAAwB;IACjF,OAAO,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * mention-clone.ts — start a mentioned agent through a clone of this
3
+ * conversation, without putting anything in the chat.
4
+ *
5
+ * Claude Code routes `@agent-<type>` through the main model: the mention
6
+ * becomes a `<system-reminder>` appended to the prompt and the model makes the
7
+ * tool call (see `agentMentionReminder`). That buys the spawned agent a prompt
8
+ * written with conversation context, and costs a visible turn — the model's
9
+ * reasoning and its tool block land in the transcript, for a decision the user
10
+ * already made when they typed the handle.
11
+ *
12
+ * So the turn happens somewhere else. The conversation is cloned into a
13
+ * throwaway in-memory session — same messages, same system prompt, same model —
14
+ * and that copy takes the turn off-screen. A literal clone: the session's own
15
+ * entries, projected by pi's own `sessionEntryToContextMessages`, not
16
+ * `inherit_context`'s text rendering of them.
17
+ *
18
+ * Cloned from memory rather than from the session file, which cannot be relied
19
+ * on: `SessionManager._persist` withholds every write until the first assistant
20
+ * message lands, so a fork taken before then reads an empty file and throws.
21
+ * `buildSessionContext()` has no such timing, and is compaction-aware — it walks
22
+ * the leaf path and substitutes the summary for entries folded into it, so a
23
+ * long conversation clones as what the main model is actually working from. A
24
+ * conversation with nothing in it yet clones to nothing in it yet, which is the
25
+ * correct answer rather than a failure.
26
+ *
27
+ * It is also the oldest of the equivalent Pi APIs — `buildContextEntries` on
28
+ * ReadonlySessionManager and the `sessionEntryToContextMessages` export both
29
+ * arrived in 0.80.5 — where this one has been exported unchanged from before
30
+ * the declared peer floor, and is the same code path (`byId` is only an index
31
+ * cache, so passing it or not cannot change the result). Keeping the floor
32
+ * honest costs nothing here: see the `compat-floor-pi` job.
33
+ *
34
+ * Its `thinkingLevel` is NOT used, and is the one place the newer API would be
35
+ * better. `getSessionContextSettings` starts at "off" and moves only on an
36
+ * explicit `thinking_level_change` entry, so a session where nobody ran
37
+ * `/think` reports "off" rather than the level it is really using. Omitting the
38
+ * field instead lets `createAgentSession` resolve it from settings, which is
39
+ * that real level.
40
+ *
41
+ * Three details make the spawn belong to the real session rather than the
42
+ * clone:
43
+ *
44
+ * - the clone is handed the *registered* `Agent` tool, whose handler closes
45
+ * over the main activation, so it spawns top-level: widget, fleet row,
46
+ * handle, completion notification, all as if the main model had called it;
47
+ * - that tool is re-bound to the main `ExtensionContext`, because the handler
48
+ * reads `cwd`, `model` and `sessionManager.getSessionId()` off it to place
49
+ * the transcript and the `rootSessionId`. The clone's own context would
50
+ * file both under the throwaway fork;
51
+ * - it is called with no tool-call id. The clone's turn produces one, but the
52
+ * real session never issued it, and a `<tool-use-id>` pointing at nothing
53
+ * is exactly the bug the mention-resume path had to fix;
54
+ * - and it is forced into the background. A foreground agent returns its
55
+ * answer as the tool result and is marked `resultConsumed` so no completion
56
+ * notification is sent — correct when the caller is the real conversation,
57
+ * silent loss when the caller is a fork about to be discarded. Background
58
+ * delivery is the only route from a mention back to the main model.
59
+ *
60
+ * The clone gets one tool and one job. It cannot read, write or run anything —
61
+ * an invisible turn with the full toolset could do invisible work.
62
+ */
63
+ import { type ExtensionContext, type ToolDefinition } from "@earendil-works/pi-coding-agent";
64
+ import type { SubagentType } from "./types.js";
65
+ export interface MentionCloneOptions {
66
+ /** The MAIN session's context — what the spawn is attributed to, and the
67
+ * source of both the conversation and the live system prompt. */
68
+ ctx: ExtensionContext;
69
+ /** Agent type the handle resolved to. */
70
+ type: SubagentType;
71
+ /** What the user typed after the handle. */
72
+ message: string;
73
+ /** The registered `Agent` tool, reused so the spawn is an ordinary one. */
74
+ agentTool: ToolDefinition;
75
+ }
76
+ export interface MentionCloneResult {
77
+ /** True once the clone actually called `Agent`. */
78
+ spawned: boolean;
79
+ /** Why not, when it didn't. Absent on success. */
80
+ error?: string;
81
+ }
82
+ /**
83
+ * Fork the conversation, let the copy make the tool call, throw the copy away.
84
+ * Never rejects: a clone that cannot run is reported so the caller can fall
85
+ * back to starting the agent directly.
86
+ */
87
+ export declare function runMentionClone(opts: MentionCloneOptions): Promise<MentionCloneResult>;
88
+ //# sourceMappingURL=mention-clone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mention-clone.d.ts","sourceRoot":"","sources":["../src/mention-clone.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAGH,OAAO,EAGL,KAAK,gBAAgB,EAErB,KAAK,cAAc,EACpB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,YAAY,CAAC;AAE9D,MAAM,WAAW,mBAAmB;IAClC;qEACiE;IACjE,GAAG,EAAE,gBAAgB,CAAC;IACtB,yCAAyC;IACzC,IAAI,EAAE,YAAY,CAAC;IACnB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,SAAS,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,mDAAmD;IACnD,OAAO,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAgG5F"}
@@ -0,0 +1,154 @@
1
+ /**
2
+ * mention-clone.ts — start a mentioned agent through a clone of this
3
+ * conversation, without putting anything in the chat.
4
+ *
5
+ * Claude Code routes `@agent-<type>` through the main model: the mention
6
+ * becomes a `<system-reminder>` appended to the prompt and the model makes the
7
+ * tool call (see `agentMentionReminder`). That buys the spawned agent a prompt
8
+ * written with conversation context, and costs a visible turn — the model's
9
+ * reasoning and its tool block land in the transcript, for a decision the user
10
+ * already made when they typed the handle.
11
+ *
12
+ * So the turn happens somewhere else. The conversation is cloned into a
13
+ * throwaway in-memory session — same messages, same system prompt, same model —
14
+ * and that copy takes the turn off-screen. A literal clone: the session's own
15
+ * entries, projected by pi's own `sessionEntryToContextMessages`, not
16
+ * `inherit_context`'s text rendering of them.
17
+ *
18
+ * Cloned from memory rather than from the session file, which cannot be relied
19
+ * on: `SessionManager._persist` withholds every write until the first assistant
20
+ * message lands, so a fork taken before then reads an empty file and throws.
21
+ * `buildSessionContext()` has no such timing, and is compaction-aware — it walks
22
+ * the leaf path and substitutes the summary for entries folded into it, so a
23
+ * long conversation clones as what the main model is actually working from. A
24
+ * conversation with nothing in it yet clones to nothing in it yet, which is the
25
+ * correct answer rather than a failure.
26
+ *
27
+ * It is also the oldest of the equivalent Pi APIs — `buildContextEntries` on
28
+ * ReadonlySessionManager and the `sessionEntryToContextMessages` export both
29
+ * arrived in 0.80.5 — where this one has been exported unchanged from before
30
+ * the declared peer floor, and is the same code path (`byId` is only an index
31
+ * cache, so passing it or not cannot change the result). Keeping the floor
32
+ * honest costs nothing here: see the `compat-floor-pi` job.
33
+ *
34
+ * Its `thinkingLevel` is NOT used, and is the one place the newer API would be
35
+ * better. `getSessionContextSettings` starts at "off" and moves only on an
36
+ * explicit `thinking_level_change` entry, so a session where nobody ran
37
+ * `/think` reports "off" rather than the level it is really using. Omitting the
38
+ * field instead lets `createAgentSession` resolve it from settings, which is
39
+ * that real level.
40
+ *
41
+ * Three details make the spawn belong to the real session rather than the
42
+ * clone:
43
+ *
44
+ * - the clone is handed the *registered* `Agent` tool, whose handler closes
45
+ * over the main activation, so it spawns top-level: widget, fleet row,
46
+ * handle, completion notification, all as if the main model had called it;
47
+ * - that tool is re-bound to the main `ExtensionContext`, because the handler
48
+ * reads `cwd`, `model` and `sessionManager.getSessionId()` off it to place
49
+ * the transcript and the `rootSessionId`. The clone's own context would
50
+ * file both under the throwaway fork;
51
+ * - it is called with no tool-call id. The clone's turn produces one, but the
52
+ * real session never issued it, and a `<tool-use-id>` pointing at nothing
53
+ * is exactly the bug the mention-resume path had to fix;
54
+ * - and it is forced into the background. A foreground agent returns its
55
+ * answer as the tool result and is marked `resultConsumed` so no completion
56
+ * notification is sent — correct when the caller is the real conversation,
57
+ * silent loss when the caller is a fork about to be discarded. Background
58
+ * delivery is the only route from a mention back to the main model.
59
+ *
60
+ * The clone gets one tool and one job. It cannot read, write or run anything —
61
+ * an invisible turn with the full toolset could do invisible work.
62
+ */
63
+ import { buildSessionContext, createAgentSession, SessionManager, } from "@earendil-works/pi-coding-agent";
64
+ import { runInChildSessionContext } from "./child-context.js";
65
+ import { agentMentionReminder } from "./mention.js";
66
+ /**
67
+ * Fork the conversation, let the copy make the tool call, throw the copy away.
68
+ * Never rejects: a clone that cannot run is reported so the caller can fall
69
+ * back to starting the agent directly.
70
+ */
71
+ export async function runMentionClone(opts) {
72
+ const { ctx, type, message, agentTool } = opts;
73
+ let spawned = false;
74
+ const cloneAgentTool = {
75
+ ...agentTool,
76
+ execute: (_cloneToolCallId, params, signal, onUpdate, _cloneCtx) => {
77
+ // One spawn per mention. The clone has a single tool and every reason to
78
+ // stop after using it, but a model that decides to "also" launch a second
79
+ // agent would do it where nobody can see and nobody asked.
80
+ if (spawned) {
81
+ return Promise.resolve({
82
+ content: [{ type: "text", text: "Already started an agent for this mention. Stop here." }],
83
+ details: undefined,
84
+ isError: true,
85
+ });
86
+ }
87
+ spawned = true;
88
+ // undefined tool-call id + the main ctx: see the header. Background is
89
+ // forced rather than left to the clone: `run_in_background` defaults to
90
+ // false, and a foreground agent answers through its TOOL RESULT — which
91
+ // here is delivered into a session that is disposed moments later, so the
92
+ // agent would run, appear in the widget and the fleet, and reach nobody.
93
+ return agentTool.execute(undefined, { ...params, run_in_background: true }, signal, onUpdate, ctx);
94
+ },
95
+ };
96
+ let session;
97
+ try {
98
+ // Pi 0.80.8 moved createAgentSession from modelRegistry to modelRuntime;
99
+ // agent-runner.ts carries the same shim for the same reason — pass both so
100
+ // the clone keeps the parent's providers across the supported range.
101
+ const parentModelRuntime = ctx.modelRegistry.runtime;
102
+ // The conversation as the main session resolves it: compaction applied,
103
+ // branch summaries substituted.
104
+ const conversation = buildSessionContext(ctx.sessionManager.getEntries(), ctx.sessionManager.getLeafId());
105
+ // Pi 0.82.0 added this; below it the field is absent and the clone takes
106
+ // the settings level instead, which is what a session that never ran
107
+ // `/think` is on anyway. Same shim shape as `modelRuntime` below.
108
+ const thinkingLevel = ctx.thinkingLevel;
109
+ const created = await runInChildSessionContext(() => createAgentSession({
110
+ cwd: ctx.cwd,
111
+ // Nothing about the copy is worth persisting, and an in-memory manager
112
+ // is also what keeps the real session untouched.
113
+ sessionManager: SessionManager.inMemory(ctx.cwd),
114
+ model: ctx.model,
115
+ ...(thinkingLevel && { thinkingLevel }),
116
+ modelRegistry: ctx.modelRegistry,
117
+ ...(parentModelRuntime !== undefined && { modelRuntime: parentModelRuntime }),
118
+ // An allowlist naming exactly the clone's own tool. NOT `noTools:
119
+ // "all"`, whose doc comment ("start with no tools enabled") reads like
120
+ // it spares custom tools and does not: it resolves to an EMPTY
121
+ // allowlist, and `isAllowedTool` then drops every tool from the
122
+ // registry — the custom one included. The clone would be prompted with
123
+ // nothing to call, answer in prose, and every mention would fall
124
+ // through to the direct start with a warning. Same idiom as
125
+ // agent-runner's `tools: sessionTools` beside its nested `customTools`.
126
+ tools: [cloneAgentTool.name],
127
+ customTools: [cloneAgentTool],
128
+ }));
129
+ session = created.session;
130
+ // The clone rebuilds a system prompt from cwd and agentDir, which is close
131
+ // but not the live one — extensions contribute to it per turn. Copy the
132
+ // real thing, so the copy reasons under the instructions the user's model
133
+ // is actually working under.
134
+ const systemPrompt = ctx.getSystemPrompt?.();
135
+ if (systemPrompt)
136
+ session.agent.state.systemPrompt = systemPrompt;
137
+ // The conversation itself. Pushed rather than assigned so the array the
138
+ // session was built around stays the one it goes on using.
139
+ session.agent.state.messages.push(...conversation.messages);
140
+ // User text first, reminder after — the order Claude Code's attachment
141
+ // renderer produces, where the reminder trails the message it is about.
142
+ await session.prompt(`${message}\n\n${agentMentionReminder(type)}`);
143
+ }
144
+ catch (err) {
145
+ return { spawned, error: err instanceof Error ? err.message : String(err) };
146
+ }
147
+ finally {
148
+ session?.dispose?.();
149
+ }
150
+ return spawned
151
+ ? { spawned: true }
152
+ : { spawned: false, error: "the conversation clone did not start it" };
153
+ }
154
+ //# sourceMappingURL=mention-clone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mention-clone.js","sourceRoot":"","sources":["../src/mention-clone.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAGH,OAAO,EACL,mBAAmB,EACnB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AAC;QAE5D,uEAAuE;QACvE,wEAAwE;QACxE,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,OAAO,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IAC9E,CAAC;YAAS,CAAC;QACT,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC;IACvB,CAAC;IAED,OAAO,OAAO;QACZ,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;QACnB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,yCAAyC,EAAE,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * mention.ts — the `@handle` grammar for messaging a subagent from the prompt.
3
+ *
4
+ * Claude Code lets you type `@code-review take another look` at the prompt and
5
+ * routes the message to that agent instead of the main model. Its grammar is
6
+ * reproduced here so the two behave identically:
7
+ *
8
+ * - suggestions fire on `@` at the start of the input or after whitespace,
9
+ * followed by `[\w-]*` (so `@src/foo.ts` is a file, never an agent);
10
+ * - a send is recognized only at the START of the input, and only with a
11
+ * non-empty message after the handle. That is why a bare `@code-review`
12
+ * goes to the main model rather than anywhere near the agent.
13
+ *
14
+ * A record's own identity is a UUID plus a deliberately non-unique description,
15
+ * neither of which is typeable, so the handle is derived from the agent type.
16
+ * Colliding handles are numbered (`explore`, `explore-2`), which is also what
17
+ * Claude Code's `allocateName` does — it recycles a name only once the task
18
+ * behind it is gone. Its SendMessage prompt describes the *registry* as
19
+ * latest-wins, which is a different thing and not how names are allocated.
20
+ */
21
+ /**
22
+ * Suggestion trigger: `@` at a token boundary plus the partial handle typed so
23
+ * far. Ported from Claude Code, including the CJK sentence-ending punctuation
24
+ * it accepts as a boundary.
25
+ */
26
+ export declare const MENTION_TRIGGER: RegExp;
27
+ /** Whether `@handle` names the main conversation rather than any subagent. */
28
+ export declare function isReservedHandle(handle: string): boolean;
29
+ /** Slug of an agent type or name, restricted to the `[\w-]` the grammar allows. */
30
+ export declare function handleBase(type: string): string;
31
+ /**
32
+ * `base`, else `base-2`, `base-3`, … — the first form that is neither `taken`
33
+ * nor reserved. Callers pass one shared `taken` set covering type-derived
34
+ * handles and model-supplied aliases alike, so the two can never collide.
35
+ */
36
+ export declare function assignHandle(base: string, taken: ReadonlySet<string>): string;
37
+ /**
38
+ * Map a typed handle back to a registered agent type, so `@explore fix it`
39
+ * reaches the Explore agent even when no instance has ever run. `handleBase` is
40
+ * the single source of truth in both directions, so a type is addressable by
41
+ * exactly the handle its instances would be given.
42
+ */
43
+ export declare function resolveHandleToType(handle: string, types: readonly string[]): string | undefined;
44
+ /**
45
+ * Claude Code documents `@agent-<name>` as the form you type by hand when the
46
+ * picker isn't involved. Accepted here as an exact synonym: the caller tries the
47
+ * handle as written first, so an agent genuinely called `agent-foo` still wins
48
+ * over `@agent-` + `foo`, and only falls back to this when that finds nothing.
49
+ * Returns undefined when the prefix is absent or is the whole handle.
50
+ */
51
+ export declare function stripAgentPrefix(handle: string): string | undefined;
52
+ /**
53
+ * A spawn needs the short description every agent surface renders. A mention
54
+ * carries no separate label, so the message itself becomes one: first line,
55
+ * whitespace collapsed, clipped to roughly the 3-5 words the Agent tool asks of
56
+ * the model.
57
+ */
58
+ export declare function describeMention(message: string): string;
59
+ /**
60
+ * What Claude Code sends the main model when a mention names an agent it could
61
+ * start. Its `@agent-<type>` mention is not a spawn at all: it becomes an
62
+ * `agent_mention` attachment, which renders to a synthetic `isMeta` user
63
+ * message placed after the user's own untouched text — no tool forcing, no
64
+ * allowed-tools narrowing, and the Task tool is not even named. The model reads
65
+ * this and calls the tool itself.
66
+ *
67
+ * Ported verbatim from the 2.1.233 bundle's attachment renderer, trailing space
68
+ * before the closing newline included, so the wording the model was trained
69
+ * against is the wording it gets. The one substitution is ours: pi's equivalent
70
+ * of Task is the `Agent` tool, and the agent listing that teaches valid
71
+ * `subagent_type` values is the tool spec rather than a separate attachment.
72
+ */
73
+ export declare function agentMentionReminder(type: string): string;
74
+ /**
75
+ * Split `@handle message` into its parts, or null when the text isn't a send —
76
+ * a bare handle, a leading file path, or a mention that isn't at the start.
77
+ */
78
+ export declare function parseMention(text: string): {
79
+ handle: string;
80
+ message: string;
81
+ } | null;
82
+ //# sourceMappingURL=mention.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mention.d.ts","sourceRoot":"","sources":["../src/mention.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAA2B,CAAC;AAmBxD,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ/C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAQ7E;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAMhG;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGnE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAKrF"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * mention.ts — the `@handle` grammar for messaging a subagent from the prompt.
3
+ *
4
+ * Claude Code lets you type `@code-review take another look` at the prompt and
5
+ * routes the message to that agent instead of the main model. Its grammar is
6
+ * reproduced here so the two behave identically:
7
+ *
8
+ * - suggestions fire on `@` at the start of the input or after whitespace,
9
+ * followed by `[\w-]*` (so `@src/foo.ts` is a file, never an agent);
10
+ * - a send is recognized only at the START of the input, and only with a
11
+ * non-empty message after the handle. That is why a bare `@code-review`
12
+ * goes to the main model rather than anywhere near the agent.
13
+ *
14
+ * A record's own identity is a UUID plus a deliberately non-unique description,
15
+ * neither of which is typeable, so the handle is derived from the agent type.
16
+ * Colliding handles are numbered (`explore`, `explore-2`), which is also what
17
+ * Claude Code's `allocateName` does — it recycles a name only once the task
18
+ * behind it is gone. Its SendMessage prompt describes the *registry* as
19
+ * latest-wins, which is a different thing and not how names are allocated.
20
+ */
21
+ /**
22
+ * Suggestion trigger: `@` at a token boundary plus the partial handle typed so
23
+ * far. Ported from Claude Code, including the CJK sentence-ending punctuation
24
+ * it accepts as a boundary.
25
+ */
26
+ export const MENTION_TRIGGER = /(^|[\s。、?!])@([\w-]*)$/;
27
+ /** Send grammar: leading `@handle`, then a non-empty message. */
28
+ const MENTION_SEND = /^@([\w-]+)\s+([\s\S]+)$/;
29
+ /**
30
+ * Upper bound on a handle, matching Claude Code's `dSS`. Nothing here generates
31
+ * a name this long, but an agent type or a model-supplied name can be arbitrary
32
+ * text, and an unbounded handle would wrap the suggestion popup.
33
+ */
34
+ const MAX_HANDLE_LENGTH = 64;
35
+ /**
36
+ * Handles that address something other than a subagent, and so can never be
37
+ * allocated to one. Claude Code reserves exactly this name (`Vq = "main"`),
38
+ * refusing it at spawn and routing it to the main conversation instead.
39
+ */
40
+ const RESERVED_HANDLES = new Set(["main"]);
41
+ /** Whether `@handle` names the main conversation rather than any subagent. */
42
+ export function isReservedHandle(handle) {
43
+ return RESERVED_HANDLES.has(handle.toLowerCase());
44
+ }
45
+ /** Slug of an agent type or name, restricted to the `[\w-]` the grammar allows. */
46
+ export function handleBase(type) {
47
+ const slug = type.toLowerCase()
48
+ .replace(/[^a-z0-9_-]+/g, "-")
49
+ .replace(/^-+|-+$/g, "")
50
+ .slice(0, MAX_HANDLE_LENGTH)
51
+ // The slice can land mid-run and leave the trailing hyphen back.
52
+ .replace(/-+$/, "");
53
+ return slug || "agent";
54
+ }
55
+ /**
56
+ * `base`, else `base-2`, `base-3`, … — the first form that is neither `taken`
57
+ * nor reserved. Callers pass one shared `taken` set covering type-derived
58
+ * handles and model-supplied aliases alike, so the two can never collide.
59
+ */
60
+ export function assignHandle(base, taken) {
61
+ let candidate = base;
62
+ let n = 1;
63
+ while (taken.has(candidate) || RESERVED_HANDLES.has(candidate)) {
64
+ n++;
65
+ candidate = `${base}-${n}`;
66
+ }
67
+ return candidate;
68
+ }
69
+ /**
70
+ * Map a typed handle back to a registered agent type, so `@explore fix it`
71
+ * reaches the Explore agent even when no instance has ever run. `handleBase` is
72
+ * the single source of truth in both directions, so a type is addressable by
73
+ * exactly the handle its instances would be given.
74
+ */
75
+ export function resolveHandleToType(handle, types) {
76
+ const wanted = handle.toLowerCase();
77
+ // A type slugging to a reserved name is unaddressable rather than shadowing
78
+ // it — `assignHandle` refuses that name too, so its instances never hold one.
79
+ if (RESERVED_HANDLES.has(wanted))
80
+ return undefined;
81
+ return types.find(type => handleBase(type) === wanted);
82
+ }
83
+ /**
84
+ * Claude Code documents `@agent-<name>` as the form you type by hand when the
85
+ * picker isn't involved. Accepted here as an exact synonym: the caller tries the
86
+ * handle as written first, so an agent genuinely called `agent-foo` still wins
87
+ * over `@agent-` + `foo`, and only falls back to this when that finds nothing.
88
+ * Returns undefined when the prefix is absent or is the whole handle.
89
+ */
90
+ export function stripAgentPrefix(handle) {
91
+ const rest = /^agent-(.+)$/i.exec(handle)?.[1];
92
+ return rest || undefined;
93
+ }
94
+ /**
95
+ * A spawn needs the short description every agent surface renders. A mention
96
+ * carries no separate label, so the message itself becomes one: first line,
97
+ * whitespace collapsed, clipped to roughly the 3-5 words the Agent tool asks of
98
+ * the model.
99
+ */
100
+ export function describeMention(message) {
101
+ const oneLine = message.split("\n", 1)[0].replace(/\s+/g, " ").trim();
102
+ return oneLine.length > 40 ? `${oneLine.slice(0, 39).trimEnd()}…` : oneLine;
103
+ }
104
+ /**
105
+ * What Claude Code sends the main model when a mention names an agent it could
106
+ * start. Its `@agent-<type>` mention is not a spawn at all: it becomes an
107
+ * `agent_mention` attachment, which renders to a synthetic `isMeta` user
108
+ * message placed after the user's own untouched text — no tool forcing, no
109
+ * allowed-tools narrowing, and the Task tool is not even named. The model reads
110
+ * this and calls the tool itself.
111
+ *
112
+ * Ported verbatim from the 2.1.233 bundle's attachment renderer, trailing space
113
+ * before the closing newline included, so the wording the model was trained
114
+ * against is the wording it gets. The one substitution is ours: pi's equivalent
115
+ * of Task is the `Agent` tool, and the agent listing that teaches valid
116
+ * `subagent_type` values is the tool spec rather than a separate attachment.
117
+ */
118
+ export function agentMentionReminder(type) {
119
+ return `<system-reminder>\nThe user has expressed a desire to invoke the agent "${type}". Please invoke the agent appropriately, passing in the required context to it. \n</system-reminder>`;
120
+ }
121
+ /**
122
+ * Split `@handle message` into its parts, or null when the text isn't a send —
123
+ * a bare handle, a leading file path, or a mention that isn't at the start.
124
+ */
125
+ export function parseMention(text) {
126
+ const match = MENTION_SEND.exec(text);
127
+ if (!match)
128
+ return null;
129
+ const message = match[2].trim();
130
+ return message ? { handle: match[1], message } : null;
131
+ }
132
+ //# sourceMappingURL=mention.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mention.js","sourceRoot":"","sources":["../src/mention.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;GAIG;AACH,MAAM,CAA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CAAC,CAAC,CAAC,IAAI,CAAC;AACxD,CAAC"}
@@ -11,6 +11,23 @@ export interface ModelRegistry {
11
11
  getAll(): any[];
12
12
  getAvailable?(): any[];
13
13
  }
14
+ /**
15
+ * Both display forms of a model. The short one goes on tight rows (the widget,
16
+ * the Agent tool result), the canonical one where there is room to disambiguate
17
+ * two providers serving a similarly-named model (the conversation viewer).
18
+ *
19
+ * One function, because `index.ts` labels the model it resolved before the run
20
+ * and `agent-manager.ts` relabels it from the live session afterwards — the two
21
+ * must agree or the label would visibly change the moment the session starts.
22
+ */
23
+ export declare function describeModel(model: {
24
+ provider: string;
25
+ id: string;
26
+ name?: string;
27
+ }): {
28
+ modelName: string;
29
+ modelId: string;
30
+ };
14
31
  /**
15
32
  * Resolve a model string to a Model instance.
16
33
  * Tries exact match first ("provider/modelId"), then fuzzy match against all available models.
@@ -1 +1 @@
1
- {"version":3,"file":"model-resolver.d.ts","sourceRoot":"","sources":["../src/model-resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC;IAC7C,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,YAAY,CAAC,IAAI,GAAG,EAAE,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,aAAa,GACtB,GAAG,GAAG,MAAM,CA2Ed"}
1
+ {"version":3,"file":"model-resolver.d.ts","sourceRoot":"","sources":["../src/model-resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC;IAC7C,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,YAAY,CAAC,IAAI,GAAG,EAAE,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAKxC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,aAAa,GACtB,GAAG,GAAG,MAAM,CA2Ed"}
@@ -1,6 +1,21 @@
1
1
  /**
2
2
  * Model resolution: exact match ("provider/modelId") with fuzzy fallback.
3
3
  */
4
+ /**
5
+ * Both display forms of a model. The short one goes on tight rows (the widget,
6
+ * the Agent tool result), the canonical one where there is room to disambiguate
7
+ * two providers serving a similarly-named model (the conversation viewer).
8
+ *
9
+ * One function, because `index.ts` labels the model it resolved before the run
10
+ * and `agent-manager.ts` relabels it from the live session afterwards — the two
11
+ * must agree or the label would visibly change the moment the session starts.
12
+ */
13
+ export function describeModel(model) {
14
+ return {
15
+ modelName: (model.name ?? model.id).replace(/^Claude\s+/i, "").toLowerCase(),
16
+ modelId: `${model.provider}/${model.id}`,
17
+ };
18
+ }
4
19
  /**
5
20
  * Resolve a model string to a Model instance.
6
21
  * Tries exact match first ("provider/modelId"), then fuzzy match against all available models.
@@ -1 +1 @@
1
- {"version":3,"file":"model-resolver.js","sourceRoot":"","sources":["../src/model-resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAC1B,KAA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