lsd-pi 1.2.0 → 1.2.2

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 (520) hide show
  1. package/dist/cli.js +7 -1
  2. package/dist/onboarding.js +3 -3
  3. package/dist/resources/agents/scout.md +6 -0
  4. package/dist/resources/extensions/slash-commands/plan.js +7 -1
  5. package/dist/resources/extensions/subagent/index.js +10 -2
  6. package/dist/resources/extensions/usage/index.js +87 -36
  7. package/package.json +1 -1
  8. package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
  9. package/packages/pi-agent-core/dist/agent.js +8 -2
  10. package/packages/pi-agent-core/dist/agent.js.map +1 -1
  11. package/packages/pi-agent-core/src/agent.ts +8 -2
  12. package/packages/pi-ai/dist/models.generated.d.ts +222 -1
  13. package/packages/pi-ai/dist/models.generated.d.ts.map +1 -1
  14. package/packages/pi-ai/dist/models.generated.js +227 -6
  15. package/packages/pi-ai/dist/models.generated.js.map +1 -1
  16. package/packages/pi-ai/dist/models.test.js +28 -0
  17. package/packages/pi-ai/dist/models.test.js.map +1 -1
  18. package/packages/pi-ai/scripts/generate-models.ts +10 -100
  19. package/packages/pi-ai/src/models.generated.ts +227 -6
  20. package/packages/pi-ai/src/models.test.ts +30 -0
  21. package/packages/pi-coding-agent/dist/core/agent-session.d.ts +2 -0
  22. package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  23. package/packages/pi-coding-agent/dist/core/agent-session.js +28 -0
  24. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  25. package/packages/pi-coding-agent/dist/core/settings-manager.js +1 -1
  26. package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
  27. package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
  28. package/packages/pi-coding-agent/dist/core/system-prompt.js +10 -0
  29. package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
  30. package/packages/pi-coding-agent/dist/index.d.ts +1 -1
  31. package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
  32. package/packages/pi-coding-agent/dist/index.js +1 -1
  33. package/packages/pi-coding-agent/dist/index.js.map +1 -1
  34. package/packages/pi-coding-agent/dist/tests/path-display.test.js +13 -0
  35. package/packages/pi-coding-agent/dist/tests/path-display.test.js.map +1 -1
  36. package/packages/pi-coding-agent/dist/tests/settings-manager-scout-policy.test.d.ts +2 -0
  37. package/packages/pi-coding-agent/dist/tests/settings-manager-scout-policy.test.d.ts.map +1 -0
  38. package/packages/pi-coding-agent/dist/tests/settings-manager-scout-policy.test.js +15 -0
  39. package/packages/pi-coding-agent/dist/tests/settings-manager-scout-policy.test.js.map +1 -0
  40. package/packages/pi-coding-agent/package.json +1 -1
  41. package/packages/pi-coding-agent/src/core/agent-session.ts +35 -0
  42. package/packages/pi-coding-agent/src/core/settings-manager.ts +1 -1
  43. package/packages/pi-coding-agent/src/core/system-prompt.ts +26 -0
  44. package/packages/pi-coding-agent/src/index.ts +1 -0
  45. package/packages/pi-coding-agent/src/tests/path-display.test.ts +14 -0
  46. package/pkg/package.json +1 -1
  47. package/src/resources/agents/scout.md +6 -0
  48. package/src/resources/extensions/slash-commands/plan.ts +11 -1
  49. package/src/resources/extensions/subagent/index.ts +10 -2
  50. package/src/resources/extensions/usage/index.ts +92 -38
  51. package/dist/resources/agents/javascript-pro.md +0 -280
  52. package/dist/resources/agents/researcher.md +0 -29
  53. package/dist/resources/agents/teams-builder.md +0 -74
  54. package/dist/resources/agents/teams-reviewer.md +0 -113
  55. package/dist/resources/agents/typescript-pro.md +0 -255
  56. package/dist/resources/skills/accessibility/SKILL.md +0 -522
  57. package/dist/resources/skills/accessibility/references/WCAG.md +0 -162
  58. package/dist/resources/skills/core-web-vitals/SKILL.md +0 -441
  59. package/dist/resources/skills/core-web-vitals/references/LCP.md +0 -208
  60. package/dist/resources/skills/frontend-design/SKILL.md +0 -45
  61. package/dist/resources/skills/make-interfaces-feel-better/SKILL.md +0 -122
  62. package/dist/resources/skills/make-interfaces-feel-better/animations.md +0 -379
  63. package/dist/resources/skills/make-interfaces-feel-better/performance.md +0 -88
  64. package/dist/resources/skills/make-interfaces-feel-better/surfaces.md +0 -247
  65. package/dist/resources/skills/make-interfaces-feel-better/typography.md +0 -123
  66. package/dist/resources/skills/react-best-practices/README.md +0 -123
  67. package/dist/resources/skills/react-best-practices/SKILL.md +0 -136
  68. package/dist/resources/skills/react-best-practices/metadata.json +0 -15
  69. package/dist/resources/skills/react-best-practices/rules/_sections.md +0 -46
  70. package/dist/resources/skills/react-best-practices/rules/_template.md +0 -28
  71. package/dist/resources/skills/react-best-practices/rules/advanced-event-handler-refs.md +0 -55
  72. package/dist/resources/skills/react-best-practices/rules/advanced-init-once.md +0 -42
  73. package/dist/resources/skills/react-best-practices/rules/advanced-use-latest.md +0 -39
  74. package/dist/resources/skills/react-best-practices/rules/async-api-routes.md +0 -38
  75. package/dist/resources/skills/react-best-practices/rules/async-defer-await.md +0 -80
  76. package/dist/resources/skills/react-best-practices/rules/async-dependencies.md +0 -51
  77. package/dist/resources/skills/react-best-practices/rules/async-parallel.md +0 -28
  78. package/dist/resources/skills/react-best-practices/rules/async-suspense-boundaries.md +0 -99
  79. package/dist/resources/skills/react-best-practices/rules/bundle-barrel-imports.md +0 -59
  80. package/dist/resources/skills/react-best-practices/rules/bundle-conditional.md +0 -31
  81. package/dist/resources/skills/react-best-practices/rules/bundle-defer-third-party.md +0 -49
  82. package/dist/resources/skills/react-best-practices/rules/bundle-dynamic-imports.md +0 -35
  83. package/dist/resources/skills/react-best-practices/rules/bundle-preload.md +0 -50
  84. package/dist/resources/skills/react-best-practices/rules/client-event-listeners.md +0 -74
  85. package/dist/resources/skills/react-best-practices/rules/client-localstorage-schema.md +0 -71
  86. package/dist/resources/skills/react-best-practices/rules/client-passive-event-listeners.md +0 -48
  87. package/dist/resources/skills/react-best-practices/rules/client-swr-dedup.md +0 -56
  88. package/dist/resources/skills/react-best-practices/rules/js-batch-dom-css.md +0 -107
  89. package/dist/resources/skills/react-best-practices/rules/js-cache-function-results.md +0 -80
  90. package/dist/resources/skills/react-best-practices/rules/js-cache-property-access.md +0 -28
  91. package/dist/resources/skills/react-best-practices/rules/js-cache-storage.md +0 -70
  92. package/dist/resources/skills/react-best-practices/rules/js-combine-iterations.md +0 -32
  93. package/dist/resources/skills/react-best-practices/rules/js-early-exit.md +0 -50
  94. package/dist/resources/skills/react-best-practices/rules/js-hoist-regexp.md +0 -45
  95. package/dist/resources/skills/react-best-practices/rules/js-index-maps.md +0 -37
  96. package/dist/resources/skills/react-best-practices/rules/js-length-check-first.md +0 -49
  97. package/dist/resources/skills/react-best-practices/rules/js-min-max-loop.md +0 -82
  98. package/dist/resources/skills/react-best-practices/rules/js-set-map-lookups.md +0 -24
  99. package/dist/resources/skills/react-best-practices/rules/js-tosorted-immutable.md +0 -57
  100. package/dist/resources/skills/react-best-practices/rules/rendering-activity.md +0 -26
  101. package/dist/resources/skills/react-best-practices/rules/rendering-animate-svg-wrapper.md +0 -47
  102. package/dist/resources/skills/react-best-practices/rules/rendering-conditional-render.md +0 -40
  103. package/dist/resources/skills/react-best-practices/rules/rendering-content-visibility.md +0 -38
  104. package/dist/resources/skills/react-best-practices/rules/rendering-hoist-jsx.md +0 -46
  105. package/dist/resources/skills/react-best-practices/rules/rendering-hydration-no-flicker.md +0 -82
  106. package/dist/resources/skills/react-best-practices/rules/rendering-hydration-suppress-warning.md +0 -30
  107. package/dist/resources/skills/react-best-practices/rules/rendering-svg-precision.md +0 -28
  108. package/dist/resources/skills/react-best-practices/rules/rendering-usetransition-loading.md +0 -75
  109. package/dist/resources/skills/react-best-practices/rules/rerender-defer-reads.md +0 -39
  110. package/dist/resources/skills/react-best-practices/rules/rerender-dependencies.md +0 -45
  111. package/dist/resources/skills/react-best-practices/rules/rerender-derived-state-no-effect.md +0 -40
  112. package/dist/resources/skills/react-best-practices/rules/rerender-derived-state.md +0 -29
  113. package/dist/resources/skills/react-best-practices/rules/rerender-functional-setstate.md +0 -74
  114. package/dist/resources/skills/react-best-practices/rules/rerender-lazy-state-init.md +0 -58
  115. package/dist/resources/skills/react-best-practices/rules/rerender-memo-with-default-value.md +0 -38
  116. package/dist/resources/skills/react-best-practices/rules/rerender-memo.md +0 -44
  117. package/dist/resources/skills/react-best-practices/rules/rerender-move-effect-to-event.md +0 -45
  118. package/dist/resources/skills/react-best-practices/rules/rerender-simple-expression-in-memo.md +0 -35
  119. package/dist/resources/skills/react-best-practices/rules/rerender-transitions.md +0 -40
  120. package/dist/resources/skills/react-best-practices/rules/rerender-use-ref-transient-values.md +0 -73
  121. package/dist/resources/skills/react-best-practices/rules/server-after-nonblocking.md +0 -73
  122. package/dist/resources/skills/react-best-practices/rules/server-auth-actions.md +0 -96
  123. package/dist/resources/skills/react-best-practices/rules/server-cache-lru.md +0 -41
  124. package/dist/resources/skills/react-best-practices/rules/server-cache-react.md +0 -76
  125. package/dist/resources/skills/react-best-practices/rules/server-dedup-props.md +0 -65
  126. package/dist/resources/skills/react-best-practices/rules/server-parallel-fetching.md +0 -83
  127. package/dist/resources/skills/react-best-practices/rules/server-serialization.md +0 -38
  128. package/dist/resources/skills/userinterface-wiki/SKILL.md +0 -253
  129. package/dist/resources/skills/userinterface-wiki/rules/_sections.md +0 -66
  130. package/dist/resources/skills/userinterface-wiki/rules/_template.md +0 -24
  131. package/dist/resources/skills/userinterface-wiki/rules/a11y-reduced-motion-check.md +0 -30
  132. package/dist/resources/skills/userinterface-wiki/rules/a11y-toggle-setting.md +0 -30
  133. package/dist/resources/skills/userinterface-wiki/rules/a11y-visual-equivalent.md +0 -36
  134. package/dist/resources/skills/userinterface-wiki/rules/a11y-volume-control.md +0 -28
  135. package/dist/resources/skills/userinterface-wiki/rules/appropriate-confirmations-only.md +0 -19
  136. package/dist/resources/skills/userinterface-wiki/rules/appropriate-errors-warnings.md +0 -18
  137. package/dist/resources/skills/userinterface-wiki/rules/appropriate-no-decorative.md +0 -21
  138. package/dist/resources/skills/userinterface-wiki/rules/appropriate-no-high-frequency.md +0 -28
  139. package/dist/resources/skills/userinterface-wiki/rules/appropriate-no-punishing.md +0 -27
  140. package/dist/resources/skills/userinterface-wiki/rules/container-callback-ref.md +0 -31
  141. package/dist/resources/skills/userinterface-wiki/rules/container-guard-initial-zero.md +0 -25
  142. package/dist/resources/skills/userinterface-wiki/rules/container-no-excessive-use.md +0 -13
  143. package/dist/resources/skills/userinterface-wiki/rules/container-overflow-hidden.md +0 -25
  144. package/dist/resources/skills/userinterface-wiki/rules/container-transition-delay.md +0 -21
  145. package/dist/resources/skills/userinterface-wiki/rules/container-two-div-pattern.md +0 -35
  146. package/dist/resources/skills/userinterface-wiki/rules/container-use-resize-observer.md +0 -48
  147. package/dist/resources/skills/userinterface-wiki/rules/context-cleanup-nodes.md +0 -25
  148. package/dist/resources/skills/userinterface-wiki/rules/context-resume-suspended.md +0 -28
  149. package/dist/resources/skills/userinterface-wiki/rules/context-reuse-single.md +0 -30
  150. package/dist/resources/skills/userinterface-wiki/rules/design-filter-for-character.md +0 -25
  151. package/dist/resources/skills/userinterface-wiki/rules/design-noise-for-percussion.md +0 -26
  152. package/dist/resources/skills/userinterface-wiki/rules/design-oscillator-for-tonal.md +0 -22
  153. package/dist/resources/skills/userinterface-wiki/rules/duration-max-300ms.md +0 -21
  154. package/dist/resources/skills/userinterface-wiki/rules/duration-press-hover.md +0 -21
  155. package/dist/resources/skills/userinterface-wiki/rules/duration-shorten-before-curve.md +0 -21
  156. package/dist/resources/skills/userinterface-wiki/rules/duration-small-state.md +0 -15
  157. package/dist/resources/skills/userinterface-wiki/rules/easing-entrance-ease-out.md +0 -21
  158. package/dist/resources/skills/userinterface-wiki/rules/easing-exit-ease-in.md +0 -21
  159. package/dist/resources/skills/userinterface-wiki/rules/easing-for-state-change.md +0 -27
  160. package/dist/resources/skills/userinterface-wiki/rules/easing-linear-only-progress.md +0 -21
  161. package/dist/resources/skills/userinterface-wiki/rules/easing-natural-decay.md +0 -22
  162. package/dist/resources/skills/userinterface-wiki/rules/easing-no-linear-motion.md +0 -22
  163. package/dist/resources/skills/userinterface-wiki/rules/easing-transition-ease-in-out.md +0 -15
  164. package/dist/resources/skills/userinterface-wiki/rules/envelope-exponential-decay.md +0 -21
  165. package/dist/resources/skills/userinterface-wiki/rules/envelope-no-zero-target.md +0 -21
  166. package/dist/resources/skills/userinterface-wiki/rules/envelope-set-initial-value.md +0 -22
  167. package/dist/resources/skills/userinterface-wiki/rules/exit-key-required.md +0 -29
  168. package/dist/resources/skills/userinterface-wiki/rules/exit-matches-initial.md +0 -29
  169. package/dist/resources/skills/userinterface-wiki/rules/exit-prop-required.md +0 -33
  170. package/dist/resources/skills/userinterface-wiki/rules/exit-requires-wrapper.md +0 -27
  171. package/dist/resources/skills/userinterface-wiki/rules/impl-default-subtle.md +0 -21
  172. package/dist/resources/skills/userinterface-wiki/rules/impl-preload-audio.md +0 -34
  173. package/dist/resources/skills/userinterface-wiki/rules/impl-reset-current-time.md +0 -26
  174. package/dist/resources/skills/userinterface-wiki/rules/mode-pop-layout-for-lists.md +0 -25
  175. package/dist/resources/skills/userinterface-wiki/rules/mode-sync-layout-conflict.md +0 -29
  176. package/dist/resources/skills/userinterface-wiki/rules/mode-wait-doubles-duration.md +0 -25
  177. package/dist/resources/skills/userinterface-wiki/rules/morphing-aria-hidden.md +0 -21
  178. package/dist/resources/skills/userinterface-wiki/rules/morphing-consistent-viewbox.md +0 -23
  179. package/dist/resources/skills/userinterface-wiki/rules/morphing-group-variants.md +0 -33
  180. package/dist/resources/skills/userinterface-wiki/rules/morphing-jump-non-grouped.md +0 -29
  181. package/dist/resources/skills/userinterface-wiki/rules/morphing-reduced-motion.md +0 -28
  182. package/dist/resources/skills/userinterface-wiki/rules/morphing-spring-rotation.md +0 -23
  183. package/dist/resources/skills/userinterface-wiki/rules/morphing-strokelinecap-round.md +0 -21
  184. package/dist/resources/skills/userinterface-wiki/rules/morphing-three-lines.md +0 -32
  185. package/dist/resources/skills/userinterface-wiki/rules/morphing-use-collapsed.md +0 -33
  186. package/dist/resources/skills/userinterface-wiki/rules/native-backdrop-styling.md +0 -27
  187. package/dist/resources/skills/userinterface-wiki/rules/native-placeholder-styling.md +0 -27
  188. package/dist/resources/skills/userinterface-wiki/rules/native-selection-styling.md +0 -18
  189. package/dist/resources/skills/userinterface-wiki/rules/nested-consistent-timing.md +0 -25
  190. package/dist/resources/skills/userinterface-wiki/rules/nested-propagate-required.md +0 -41
  191. package/dist/resources/skills/userinterface-wiki/rules/none-context-menu-entrance.md +0 -25
  192. package/dist/resources/skills/userinterface-wiki/rules/none-high-frequency.md +0 -29
  193. package/dist/resources/skills/userinterface-wiki/rules/none-keyboard-navigation.md +0 -32
  194. package/dist/resources/skills/userinterface-wiki/rules/param-click-duration.md +0 -21
  195. package/dist/resources/skills/userinterface-wiki/rules/param-filter-frequency-range.md +0 -21
  196. package/dist/resources/skills/userinterface-wiki/rules/param-q-value-range.md +0 -21
  197. package/dist/resources/skills/userinterface-wiki/rules/param-reasonable-gain.md +0 -21
  198. package/dist/resources/skills/userinterface-wiki/rules/physics-active-state.md +0 -23
  199. package/dist/resources/skills/userinterface-wiki/rules/physics-no-excessive-stagger.md +0 -22
  200. package/dist/resources/skills/userinterface-wiki/rules/physics-spring-for-overshoot.md +0 -23
  201. package/dist/resources/skills/userinterface-wiki/rules/physics-subtle-deformation.md +0 -22
  202. package/dist/resources/skills/userinterface-wiki/rules/prefetch-hit-slop.md +0 -27
  203. package/dist/resources/skills/userinterface-wiki/rules/prefetch-keyboard-tab.md +0 -19
  204. package/dist/resources/skills/userinterface-wiki/rules/prefetch-not-everything.md +0 -22
  205. package/dist/resources/skills/userinterface-wiki/rules/prefetch-touch-fallback.md +0 -34
  206. package/dist/resources/skills/userinterface-wiki/rules/prefetch-trajectory-over-hover.md +0 -32
  207. package/dist/resources/skills/userinterface-wiki/rules/prefetch-use-selectively.md +0 -13
  208. package/dist/resources/skills/userinterface-wiki/rules/presence-disable-interactions.md +0 -31
  209. package/dist/resources/skills/userinterface-wiki/rules/presence-hook-in-child.md +0 -31
  210. package/dist/resources/skills/userinterface-wiki/rules/presence-safe-to-remove.md +0 -37
  211. package/dist/resources/skills/userinterface-wiki/rules/pseudo-content-required.md +0 -28
  212. package/dist/resources/skills/userinterface-wiki/rules/pseudo-first-line-styling.md +0 -27
  213. package/dist/resources/skills/userinterface-wiki/rules/pseudo-hit-target-expansion.md +0 -31
  214. package/dist/resources/skills/userinterface-wiki/rules/pseudo-marker-styling.md +0 -28
  215. package/dist/resources/skills/userinterface-wiki/rules/pseudo-over-dom-node.md +0 -32
  216. package/dist/resources/skills/userinterface-wiki/rules/pseudo-position-relative-parent.md +0 -33
  217. package/dist/resources/skills/userinterface-wiki/rules/pseudo-z-index-layering.md +0 -37
  218. package/dist/resources/skills/userinterface-wiki/rules/spring-for-gestures.md +0 -27
  219. package/dist/resources/skills/userinterface-wiki/rules/spring-for-interruptible.md +0 -27
  220. package/dist/resources/skills/userinterface-wiki/rules/spring-params-balanced.md +0 -29
  221. package/dist/resources/skills/userinterface-wiki/rules/spring-preserves-velocity.md +0 -28
  222. package/dist/resources/skills/userinterface-wiki/rules/staging-dim-background.md +0 -22
  223. package/dist/resources/skills/userinterface-wiki/rules/staging-one-focal-point.md +0 -24
  224. package/dist/resources/skills/userinterface-wiki/rules/staging-z-index-hierarchy.md +0 -22
  225. package/dist/resources/skills/userinterface-wiki/rules/timing-consistent.md +0 -24
  226. package/dist/resources/skills/userinterface-wiki/rules/timing-no-entrance-context-menu.md +0 -22
  227. package/dist/resources/skills/userinterface-wiki/rules/timing-under-300ms.md +0 -22
  228. package/dist/resources/skills/userinterface-wiki/rules/transition-name-cleanup.md +0 -28
  229. package/dist/resources/skills/userinterface-wiki/rules/transition-name-required.md +0 -27
  230. package/dist/resources/skills/userinterface-wiki/rules/transition-name-unique.md +0 -24
  231. package/dist/resources/skills/userinterface-wiki/rules/transition-over-js-library.md +0 -32
  232. package/dist/resources/skills/userinterface-wiki/rules/transition-style-pseudo-elements.md +0 -24
  233. package/dist/resources/skills/userinterface-wiki/rules/type-antialiased-on-retina.md +0 -18
  234. package/dist/resources/skills/userinterface-wiki/rules/type-disambiguation-stylistic-set.md +0 -15
  235. package/dist/resources/skills/userinterface-wiki/rules/type-font-display-swap.md +0 -28
  236. package/dist/resources/skills/userinterface-wiki/rules/type-justify-with-hyphens.md +0 -24
  237. package/dist/resources/skills/userinterface-wiki/rules/type-letter-spacing-uppercase.md +0 -28
  238. package/dist/resources/skills/userinterface-wiki/rules/type-no-font-synthesis.md +0 -18
  239. package/dist/resources/skills/userinterface-wiki/rules/type-oldstyle-nums-for-prose.md +0 -21
  240. package/dist/resources/skills/userinterface-wiki/rules/type-opentype-contextual-alternates.md +0 -15
  241. package/dist/resources/skills/userinterface-wiki/rules/type-optical-sizing-auto.md +0 -25
  242. package/dist/resources/skills/userinterface-wiki/rules/type-proper-fractions.md +0 -15
  243. package/dist/resources/skills/userinterface-wiki/rules/type-slashed-zero.md +0 -17
  244. package/dist/resources/skills/userinterface-wiki/rules/type-tabular-nums-for-data.md +0 -21
  245. package/dist/resources/skills/userinterface-wiki/rules/type-text-wrap-balance-headings.md +0 -21
  246. package/dist/resources/skills/userinterface-wiki/rules/type-text-wrap-pretty.md +0 -16
  247. package/dist/resources/skills/userinterface-wiki/rules/type-underline-offset.md +0 -25
  248. package/dist/resources/skills/userinterface-wiki/rules/type-variable-weight-continuous.md +0 -23
  249. package/dist/resources/skills/userinterface-wiki/rules/ux-aesthetic-usability.md +0 -32
  250. package/dist/resources/skills/userinterface-wiki/rules/ux-cognitive-load-reduce.md +0 -49
  251. package/dist/resources/skills/userinterface-wiki/rules/ux-common-region-boundaries.md +0 -50
  252. package/dist/resources/skills/userinterface-wiki/rules/ux-doherty-perceived-speed.md +0 -29
  253. package/dist/resources/skills/userinterface-wiki/rules/ux-doherty-under-400ms.md +0 -30
  254. package/dist/resources/skills/userinterface-wiki/rules/ux-fitts-hit-area.md +0 -32
  255. package/dist/resources/skills/userinterface-wiki/rules/ux-fitts-target-size.md +0 -31
  256. package/dist/resources/skills/userinterface-wiki/rules/ux-goal-gradient-progress.md +0 -33
  257. package/dist/resources/skills/userinterface-wiki/rules/ux-hicks-minimize-choices.md +0 -45
  258. package/dist/resources/skills/userinterface-wiki/rules/ux-jakobs-familiar-patterns.md +0 -37
  259. package/dist/resources/skills/userinterface-wiki/rules/ux-millers-chunking.md +0 -23
  260. package/dist/resources/skills/userinterface-wiki/rules/ux-pareto-prioritize-features.md +0 -36
  261. package/dist/resources/skills/userinterface-wiki/rules/ux-peak-end-finish-strong.md +0 -35
  262. package/dist/resources/skills/userinterface-wiki/rules/ux-postels-accept-messy-input.md +0 -45
  263. package/dist/resources/skills/userinterface-wiki/rules/ux-pragnanz-simplify.md +0 -33
  264. package/dist/resources/skills/userinterface-wiki/rules/ux-progressive-disclosure.md +0 -41
  265. package/dist/resources/skills/userinterface-wiki/rules/ux-proximity-grouping.md +0 -38
  266. package/dist/resources/skills/userinterface-wiki/rules/ux-serial-position.md +0 -31
  267. package/dist/resources/skills/userinterface-wiki/rules/ux-similarity-consistency.md +0 -35
  268. package/dist/resources/skills/userinterface-wiki/rules/ux-teslers-complexity.md +0 -28
  269. package/dist/resources/skills/userinterface-wiki/rules/ux-uniform-connectedness.md +0 -43
  270. package/dist/resources/skills/userinterface-wiki/rules/ux-von-restorff-emphasis.md +0 -29
  271. package/dist/resources/skills/userinterface-wiki/rules/ux-zeigarnik-show-incomplete.md +0 -36
  272. package/dist/resources/skills/userinterface-wiki/rules/visual-animate-shadow-pseudo.md +0 -49
  273. package/dist/resources/skills/userinterface-wiki/rules/visual-border-alpha-colors.md +0 -25
  274. package/dist/resources/skills/userinterface-wiki/rules/visual-button-shadow-anatomy.md +0 -49
  275. package/dist/resources/skills/userinterface-wiki/rules/visual-concentric-radius.md +0 -40
  276. package/dist/resources/skills/userinterface-wiki/rules/visual-consistent-spacing-scale.md +0 -35
  277. package/dist/resources/skills/userinterface-wiki/rules/visual-layered-shadows.md +0 -30
  278. package/dist/resources/skills/userinterface-wiki/rules/visual-no-pure-black-shadow.md +0 -25
  279. package/dist/resources/skills/userinterface-wiki/rules/visual-shadow-direction.md +0 -25
  280. package/dist/resources/skills/userinterface-wiki/rules/visual-shadow-matches-elevation.md +0 -23
  281. package/dist/resources/skills/userinterface-wiki/rules/weight-duration-matches-action.md +0 -29
  282. package/dist/resources/skills/userinterface-wiki/rules/weight-match-action.md +0 -32
  283. package/dist/resources/skills/web-design-guidelines/SKILL.md +0 -39
  284. package/dist/resources/skills/web-quality-audit/SKILL.md +0 -168
  285. package/dist/resources/skills/web-quality-audit/scripts/analyze.sh +0 -91
  286. package/src/resources/agents/javascript-pro.md +0 -280
  287. package/src/resources/agents/researcher.md +0 -29
  288. package/src/resources/agents/teams-builder.md +0 -74
  289. package/src/resources/agents/teams-reviewer.md +0 -113
  290. package/src/resources/agents/typescript-pro.md +0 -255
  291. package/src/resources/skills/accessibility/SKILL.md +0 -522
  292. package/src/resources/skills/accessibility/references/WCAG.md +0 -162
  293. package/src/resources/skills/core-web-vitals/SKILL.md +0 -441
  294. package/src/resources/skills/core-web-vitals/references/LCP.md +0 -208
  295. package/src/resources/skills/frontend-design/SKILL.md +0 -45
  296. package/src/resources/skills/make-interfaces-feel-better/SKILL.md +0 -122
  297. package/src/resources/skills/make-interfaces-feel-better/animations.md +0 -379
  298. package/src/resources/skills/make-interfaces-feel-better/performance.md +0 -88
  299. package/src/resources/skills/make-interfaces-feel-better/surfaces.md +0 -247
  300. package/src/resources/skills/make-interfaces-feel-better/typography.md +0 -123
  301. package/src/resources/skills/react-best-practices/README.md +0 -123
  302. package/src/resources/skills/react-best-practices/SKILL.md +0 -136
  303. package/src/resources/skills/react-best-practices/metadata.json +0 -15
  304. package/src/resources/skills/react-best-practices/rules/_sections.md +0 -46
  305. package/src/resources/skills/react-best-practices/rules/_template.md +0 -28
  306. package/src/resources/skills/react-best-practices/rules/advanced-event-handler-refs.md +0 -55
  307. package/src/resources/skills/react-best-practices/rules/advanced-init-once.md +0 -42
  308. package/src/resources/skills/react-best-practices/rules/advanced-use-latest.md +0 -39
  309. package/src/resources/skills/react-best-practices/rules/async-api-routes.md +0 -38
  310. package/src/resources/skills/react-best-practices/rules/async-defer-await.md +0 -80
  311. package/src/resources/skills/react-best-practices/rules/async-dependencies.md +0 -51
  312. package/src/resources/skills/react-best-practices/rules/async-parallel.md +0 -28
  313. package/src/resources/skills/react-best-practices/rules/async-suspense-boundaries.md +0 -99
  314. package/src/resources/skills/react-best-practices/rules/bundle-barrel-imports.md +0 -59
  315. package/src/resources/skills/react-best-practices/rules/bundle-conditional.md +0 -31
  316. package/src/resources/skills/react-best-practices/rules/bundle-defer-third-party.md +0 -49
  317. package/src/resources/skills/react-best-practices/rules/bundle-dynamic-imports.md +0 -35
  318. package/src/resources/skills/react-best-practices/rules/bundle-preload.md +0 -50
  319. package/src/resources/skills/react-best-practices/rules/client-event-listeners.md +0 -74
  320. package/src/resources/skills/react-best-practices/rules/client-localstorage-schema.md +0 -71
  321. package/src/resources/skills/react-best-practices/rules/client-passive-event-listeners.md +0 -48
  322. package/src/resources/skills/react-best-practices/rules/client-swr-dedup.md +0 -56
  323. package/src/resources/skills/react-best-practices/rules/js-batch-dom-css.md +0 -107
  324. package/src/resources/skills/react-best-practices/rules/js-cache-function-results.md +0 -80
  325. package/src/resources/skills/react-best-practices/rules/js-cache-property-access.md +0 -28
  326. package/src/resources/skills/react-best-practices/rules/js-cache-storage.md +0 -70
  327. package/src/resources/skills/react-best-practices/rules/js-combine-iterations.md +0 -32
  328. package/src/resources/skills/react-best-practices/rules/js-early-exit.md +0 -50
  329. package/src/resources/skills/react-best-practices/rules/js-hoist-regexp.md +0 -45
  330. package/src/resources/skills/react-best-practices/rules/js-index-maps.md +0 -37
  331. package/src/resources/skills/react-best-practices/rules/js-length-check-first.md +0 -49
  332. package/src/resources/skills/react-best-practices/rules/js-min-max-loop.md +0 -82
  333. package/src/resources/skills/react-best-practices/rules/js-set-map-lookups.md +0 -24
  334. package/src/resources/skills/react-best-practices/rules/js-tosorted-immutable.md +0 -57
  335. package/src/resources/skills/react-best-practices/rules/rendering-activity.md +0 -26
  336. package/src/resources/skills/react-best-practices/rules/rendering-animate-svg-wrapper.md +0 -47
  337. package/src/resources/skills/react-best-practices/rules/rendering-conditional-render.md +0 -40
  338. package/src/resources/skills/react-best-practices/rules/rendering-content-visibility.md +0 -38
  339. package/src/resources/skills/react-best-practices/rules/rendering-hoist-jsx.md +0 -46
  340. package/src/resources/skills/react-best-practices/rules/rendering-hydration-no-flicker.md +0 -82
  341. package/src/resources/skills/react-best-practices/rules/rendering-hydration-suppress-warning.md +0 -30
  342. package/src/resources/skills/react-best-practices/rules/rendering-svg-precision.md +0 -28
  343. package/src/resources/skills/react-best-practices/rules/rendering-usetransition-loading.md +0 -75
  344. package/src/resources/skills/react-best-practices/rules/rerender-defer-reads.md +0 -39
  345. package/src/resources/skills/react-best-practices/rules/rerender-dependencies.md +0 -45
  346. package/src/resources/skills/react-best-practices/rules/rerender-derived-state-no-effect.md +0 -40
  347. package/src/resources/skills/react-best-practices/rules/rerender-derived-state.md +0 -29
  348. package/src/resources/skills/react-best-practices/rules/rerender-functional-setstate.md +0 -74
  349. package/src/resources/skills/react-best-practices/rules/rerender-lazy-state-init.md +0 -58
  350. package/src/resources/skills/react-best-practices/rules/rerender-memo-with-default-value.md +0 -38
  351. package/src/resources/skills/react-best-practices/rules/rerender-memo.md +0 -44
  352. package/src/resources/skills/react-best-practices/rules/rerender-move-effect-to-event.md +0 -45
  353. package/src/resources/skills/react-best-practices/rules/rerender-simple-expression-in-memo.md +0 -35
  354. package/src/resources/skills/react-best-practices/rules/rerender-transitions.md +0 -40
  355. package/src/resources/skills/react-best-practices/rules/rerender-use-ref-transient-values.md +0 -73
  356. package/src/resources/skills/react-best-practices/rules/server-after-nonblocking.md +0 -73
  357. package/src/resources/skills/react-best-practices/rules/server-auth-actions.md +0 -96
  358. package/src/resources/skills/react-best-practices/rules/server-cache-lru.md +0 -41
  359. package/src/resources/skills/react-best-practices/rules/server-cache-react.md +0 -76
  360. package/src/resources/skills/react-best-practices/rules/server-dedup-props.md +0 -65
  361. package/src/resources/skills/react-best-practices/rules/server-parallel-fetching.md +0 -83
  362. package/src/resources/skills/react-best-practices/rules/server-serialization.md +0 -38
  363. package/src/resources/skills/userinterface-wiki/SKILL.md +0 -253
  364. package/src/resources/skills/userinterface-wiki/rules/_sections.md +0 -66
  365. package/src/resources/skills/userinterface-wiki/rules/_template.md +0 -24
  366. package/src/resources/skills/userinterface-wiki/rules/a11y-reduced-motion-check.md +0 -30
  367. package/src/resources/skills/userinterface-wiki/rules/a11y-toggle-setting.md +0 -30
  368. package/src/resources/skills/userinterface-wiki/rules/a11y-visual-equivalent.md +0 -36
  369. package/src/resources/skills/userinterface-wiki/rules/a11y-volume-control.md +0 -28
  370. package/src/resources/skills/userinterface-wiki/rules/appropriate-confirmations-only.md +0 -19
  371. package/src/resources/skills/userinterface-wiki/rules/appropriate-errors-warnings.md +0 -18
  372. package/src/resources/skills/userinterface-wiki/rules/appropriate-no-decorative.md +0 -21
  373. package/src/resources/skills/userinterface-wiki/rules/appropriate-no-high-frequency.md +0 -28
  374. package/src/resources/skills/userinterface-wiki/rules/appropriate-no-punishing.md +0 -27
  375. package/src/resources/skills/userinterface-wiki/rules/container-callback-ref.md +0 -31
  376. package/src/resources/skills/userinterface-wiki/rules/container-guard-initial-zero.md +0 -25
  377. package/src/resources/skills/userinterface-wiki/rules/container-no-excessive-use.md +0 -13
  378. package/src/resources/skills/userinterface-wiki/rules/container-overflow-hidden.md +0 -25
  379. package/src/resources/skills/userinterface-wiki/rules/container-transition-delay.md +0 -21
  380. package/src/resources/skills/userinterface-wiki/rules/container-two-div-pattern.md +0 -35
  381. package/src/resources/skills/userinterface-wiki/rules/container-use-resize-observer.md +0 -48
  382. package/src/resources/skills/userinterface-wiki/rules/context-cleanup-nodes.md +0 -25
  383. package/src/resources/skills/userinterface-wiki/rules/context-resume-suspended.md +0 -28
  384. package/src/resources/skills/userinterface-wiki/rules/context-reuse-single.md +0 -30
  385. package/src/resources/skills/userinterface-wiki/rules/design-filter-for-character.md +0 -25
  386. package/src/resources/skills/userinterface-wiki/rules/design-noise-for-percussion.md +0 -26
  387. package/src/resources/skills/userinterface-wiki/rules/design-oscillator-for-tonal.md +0 -22
  388. package/src/resources/skills/userinterface-wiki/rules/duration-max-300ms.md +0 -21
  389. package/src/resources/skills/userinterface-wiki/rules/duration-press-hover.md +0 -21
  390. package/src/resources/skills/userinterface-wiki/rules/duration-shorten-before-curve.md +0 -21
  391. package/src/resources/skills/userinterface-wiki/rules/duration-small-state.md +0 -15
  392. package/src/resources/skills/userinterface-wiki/rules/easing-entrance-ease-out.md +0 -21
  393. package/src/resources/skills/userinterface-wiki/rules/easing-exit-ease-in.md +0 -21
  394. package/src/resources/skills/userinterface-wiki/rules/easing-for-state-change.md +0 -27
  395. package/src/resources/skills/userinterface-wiki/rules/easing-linear-only-progress.md +0 -21
  396. package/src/resources/skills/userinterface-wiki/rules/easing-natural-decay.md +0 -22
  397. package/src/resources/skills/userinterface-wiki/rules/easing-no-linear-motion.md +0 -22
  398. package/src/resources/skills/userinterface-wiki/rules/easing-transition-ease-in-out.md +0 -15
  399. package/src/resources/skills/userinterface-wiki/rules/envelope-exponential-decay.md +0 -21
  400. package/src/resources/skills/userinterface-wiki/rules/envelope-no-zero-target.md +0 -21
  401. package/src/resources/skills/userinterface-wiki/rules/envelope-set-initial-value.md +0 -22
  402. package/src/resources/skills/userinterface-wiki/rules/exit-key-required.md +0 -29
  403. package/src/resources/skills/userinterface-wiki/rules/exit-matches-initial.md +0 -29
  404. package/src/resources/skills/userinterface-wiki/rules/exit-prop-required.md +0 -33
  405. package/src/resources/skills/userinterface-wiki/rules/exit-requires-wrapper.md +0 -27
  406. package/src/resources/skills/userinterface-wiki/rules/impl-default-subtle.md +0 -21
  407. package/src/resources/skills/userinterface-wiki/rules/impl-preload-audio.md +0 -34
  408. package/src/resources/skills/userinterface-wiki/rules/impl-reset-current-time.md +0 -26
  409. package/src/resources/skills/userinterface-wiki/rules/mode-pop-layout-for-lists.md +0 -25
  410. package/src/resources/skills/userinterface-wiki/rules/mode-sync-layout-conflict.md +0 -29
  411. package/src/resources/skills/userinterface-wiki/rules/mode-wait-doubles-duration.md +0 -25
  412. package/src/resources/skills/userinterface-wiki/rules/morphing-aria-hidden.md +0 -21
  413. package/src/resources/skills/userinterface-wiki/rules/morphing-consistent-viewbox.md +0 -23
  414. package/src/resources/skills/userinterface-wiki/rules/morphing-group-variants.md +0 -33
  415. package/src/resources/skills/userinterface-wiki/rules/morphing-jump-non-grouped.md +0 -29
  416. package/src/resources/skills/userinterface-wiki/rules/morphing-reduced-motion.md +0 -28
  417. package/src/resources/skills/userinterface-wiki/rules/morphing-spring-rotation.md +0 -23
  418. package/src/resources/skills/userinterface-wiki/rules/morphing-strokelinecap-round.md +0 -21
  419. package/src/resources/skills/userinterface-wiki/rules/morphing-three-lines.md +0 -32
  420. package/src/resources/skills/userinterface-wiki/rules/morphing-use-collapsed.md +0 -33
  421. package/src/resources/skills/userinterface-wiki/rules/native-backdrop-styling.md +0 -27
  422. package/src/resources/skills/userinterface-wiki/rules/native-placeholder-styling.md +0 -27
  423. package/src/resources/skills/userinterface-wiki/rules/native-selection-styling.md +0 -18
  424. package/src/resources/skills/userinterface-wiki/rules/nested-consistent-timing.md +0 -25
  425. package/src/resources/skills/userinterface-wiki/rules/nested-propagate-required.md +0 -41
  426. package/src/resources/skills/userinterface-wiki/rules/none-context-menu-entrance.md +0 -25
  427. package/src/resources/skills/userinterface-wiki/rules/none-high-frequency.md +0 -29
  428. package/src/resources/skills/userinterface-wiki/rules/none-keyboard-navigation.md +0 -32
  429. package/src/resources/skills/userinterface-wiki/rules/param-click-duration.md +0 -21
  430. package/src/resources/skills/userinterface-wiki/rules/param-filter-frequency-range.md +0 -21
  431. package/src/resources/skills/userinterface-wiki/rules/param-q-value-range.md +0 -21
  432. package/src/resources/skills/userinterface-wiki/rules/param-reasonable-gain.md +0 -21
  433. package/src/resources/skills/userinterface-wiki/rules/physics-active-state.md +0 -23
  434. package/src/resources/skills/userinterface-wiki/rules/physics-no-excessive-stagger.md +0 -22
  435. package/src/resources/skills/userinterface-wiki/rules/physics-spring-for-overshoot.md +0 -23
  436. package/src/resources/skills/userinterface-wiki/rules/physics-subtle-deformation.md +0 -22
  437. package/src/resources/skills/userinterface-wiki/rules/prefetch-hit-slop.md +0 -27
  438. package/src/resources/skills/userinterface-wiki/rules/prefetch-keyboard-tab.md +0 -19
  439. package/src/resources/skills/userinterface-wiki/rules/prefetch-not-everything.md +0 -22
  440. package/src/resources/skills/userinterface-wiki/rules/prefetch-touch-fallback.md +0 -34
  441. package/src/resources/skills/userinterface-wiki/rules/prefetch-trajectory-over-hover.md +0 -32
  442. package/src/resources/skills/userinterface-wiki/rules/prefetch-use-selectively.md +0 -13
  443. package/src/resources/skills/userinterface-wiki/rules/presence-disable-interactions.md +0 -31
  444. package/src/resources/skills/userinterface-wiki/rules/presence-hook-in-child.md +0 -31
  445. package/src/resources/skills/userinterface-wiki/rules/presence-safe-to-remove.md +0 -37
  446. package/src/resources/skills/userinterface-wiki/rules/pseudo-content-required.md +0 -28
  447. package/src/resources/skills/userinterface-wiki/rules/pseudo-first-line-styling.md +0 -27
  448. package/src/resources/skills/userinterface-wiki/rules/pseudo-hit-target-expansion.md +0 -31
  449. package/src/resources/skills/userinterface-wiki/rules/pseudo-marker-styling.md +0 -28
  450. package/src/resources/skills/userinterface-wiki/rules/pseudo-over-dom-node.md +0 -32
  451. package/src/resources/skills/userinterface-wiki/rules/pseudo-position-relative-parent.md +0 -33
  452. package/src/resources/skills/userinterface-wiki/rules/pseudo-z-index-layering.md +0 -37
  453. package/src/resources/skills/userinterface-wiki/rules/spring-for-gestures.md +0 -27
  454. package/src/resources/skills/userinterface-wiki/rules/spring-for-interruptible.md +0 -27
  455. package/src/resources/skills/userinterface-wiki/rules/spring-params-balanced.md +0 -29
  456. package/src/resources/skills/userinterface-wiki/rules/spring-preserves-velocity.md +0 -28
  457. package/src/resources/skills/userinterface-wiki/rules/staging-dim-background.md +0 -22
  458. package/src/resources/skills/userinterface-wiki/rules/staging-one-focal-point.md +0 -24
  459. package/src/resources/skills/userinterface-wiki/rules/staging-z-index-hierarchy.md +0 -22
  460. package/src/resources/skills/userinterface-wiki/rules/timing-consistent.md +0 -24
  461. package/src/resources/skills/userinterface-wiki/rules/timing-no-entrance-context-menu.md +0 -22
  462. package/src/resources/skills/userinterface-wiki/rules/timing-under-300ms.md +0 -22
  463. package/src/resources/skills/userinterface-wiki/rules/transition-name-cleanup.md +0 -28
  464. package/src/resources/skills/userinterface-wiki/rules/transition-name-required.md +0 -27
  465. package/src/resources/skills/userinterface-wiki/rules/transition-name-unique.md +0 -24
  466. package/src/resources/skills/userinterface-wiki/rules/transition-over-js-library.md +0 -32
  467. package/src/resources/skills/userinterface-wiki/rules/transition-style-pseudo-elements.md +0 -24
  468. package/src/resources/skills/userinterface-wiki/rules/type-antialiased-on-retina.md +0 -18
  469. package/src/resources/skills/userinterface-wiki/rules/type-disambiguation-stylistic-set.md +0 -15
  470. package/src/resources/skills/userinterface-wiki/rules/type-font-display-swap.md +0 -28
  471. package/src/resources/skills/userinterface-wiki/rules/type-justify-with-hyphens.md +0 -24
  472. package/src/resources/skills/userinterface-wiki/rules/type-letter-spacing-uppercase.md +0 -28
  473. package/src/resources/skills/userinterface-wiki/rules/type-no-font-synthesis.md +0 -18
  474. package/src/resources/skills/userinterface-wiki/rules/type-oldstyle-nums-for-prose.md +0 -21
  475. package/src/resources/skills/userinterface-wiki/rules/type-opentype-contextual-alternates.md +0 -15
  476. package/src/resources/skills/userinterface-wiki/rules/type-optical-sizing-auto.md +0 -25
  477. package/src/resources/skills/userinterface-wiki/rules/type-proper-fractions.md +0 -15
  478. package/src/resources/skills/userinterface-wiki/rules/type-slashed-zero.md +0 -17
  479. package/src/resources/skills/userinterface-wiki/rules/type-tabular-nums-for-data.md +0 -21
  480. package/src/resources/skills/userinterface-wiki/rules/type-text-wrap-balance-headings.md +0 -21
  481. package/src/resources/skills/userinterface-wiki/rules/type-text-wrap-pretty.md +0 -16
  482. package/src/resources/skills/userinterface-wiki/rules/type-underline-offset.md +0 -25
  483. package/src/resources/skills/userinterface-wiki/rules/type-variable-weight-continuous.md +0 -23
  484. package/src/resources/skills/userinterface-wiki/rules/ux-aesthetic-usability.md +0 -32
  485. package/src/resources/skills/userinterface-wiki/rules/ux-cognitive-load-reduce.md +0 -49
  486. package/src/resources/skills/userinterface-wiki/rules/ux-common-region-boundaries.md +0 -50
  487. package/src/resources/skills/userinterface-wiki/rules/ux-doherty-perceived-speed.md +0 -29
  488. package/src/resources/skills/userinterface-wiki/rules/ux-doherty-under-400ms.md +0 -30
  489. package/src/resources/skills/userinterface-wiki/rules/ux-fitts-hit-area.md +0 -32
  490. package/src/resources/skills/userinterface-wiki/rules/ux-fitts-target-size.md +0 -31
  491. package/src/resources/skills/userinterface-wiki/rules/ux-goal-gradient-progress.md +0 -33
  492. package/src/resources/skills/userinterface-wiki/rules/ux-hicks-minimize-choices.md +0 -45
  493. package/src/resources/skills/userinterface-wiki/rules/ux-jakobs-familiar-patterns.md +0 -37
  494. package/src/resources/skills/userinterface-wiki/rules/ux-millers-chunking.md +0 -23
  495. package/src/resources/skills/userinterface-wiki/rules/ux-pareto-prioritize-features.md +0 -36
  496. package/src/resources/skills/userinterface-wiki/rules/ux-peak-end-finish-strong.md +0 -35
  497. package/src/resources/skills/userinterface-wiki/rules/ux-postels-accept-messy-input.md +0 -45
  498. package/src/resources/skills/userinterface-wiki/rules/ux-pragnanz-simplify.md +0 -33
  499. package/src/resources/skills/userinterface-wiki/rules/ux-progressive-disclosure.md +0 -41
  500. package/src/resources/skills/userinterface-wiki/rules/ux-proximity-grouping.md +0 -38
  501. package/src/resources/skills/userinterface-wiki/rules/ux-serial-position.md +0 -31
  502. package/src/resources/skills/userinterface-wiki/rules/ux-similarity-consistency.md +0 -35
  503. package/src/resources/skills/userinterface-wiki/rules/ux-teslers-complexity.md +0 -28
  504. package/src/resources/skills/userinterface-wiki/rules/ux-uniform-connectedness.md +0 -43
  505. package/src/resources/skills/userinterface-wiki/rules/ux-von-restorff-emphasis.md +0 -29
  506. package/src/resources/skills/userinterface-wiki/rules/ux-zeigarnik-show-incomplete.md +0 -36
  507. package/src/resources/skills/userinterface-wiki/rules/visual-animate-shadow-pseudo.md +0 -49
  508. package/src/resources/skills/userinterface-wiki/rules/visual-border-alpha-colors.md +0 -25
  509. package/src/resources/skills/userinterface-wiki/rules/visual-button-shadow-anatomy.md +0 -49
  510. package/src/resources/skills/userinterface-wiki/rules/visual-concentric-radius.md +0 -40
  511. package/src/resources/skills/userinterface-wiki/rules/visual-consistent-spacing-scale.md +0 -35
  512. package/src/resources/skills/userinterface-wiki/rules/visual-layered-shadows.md +0 -30
  513. package/src/resources/skills/userinterface-wiki/rules/visual-no-pure-black-shadow.md +0 -25
  514. package/src/resources/skills/userinterface-wiki/rules/visual-shadow-direction.md +0 -25
  515. package/src/resources/skills/userinterface-wiki/rules/visual-shadow-matches-elevation.md +0 -23
  516. package/src/resources/skills/userinterface-wiki/rules/weight-duration-matches-action.md +0 -29
  517. package/src/resources/skills/userinterface-wiki/rules/weight-match-action.md +0 -32
  518. package/src/resources/skills/web-design-guidelines/SKILL.md +0 -39
  519. package/src/resources/skills/web-quality-audit/SKILL.md +0 -168
  520. package/src/resources/skills/web-quality-audit/scripts/analyze.sh +0 -91
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AuthStorage, DefaultResourceLoader, ModelRegistry, runPackageCommand, SettingsManager, SessionManager, createAgentSession, InteractiveMode, resetStdinForTui, runPrintMode, runRpcMode, } from '@gsd/pi-coding-agent';
1
+ import { AuthStorage, DefaultResourceLoader, ModelRegistry, runPackageCommand, SettingsManager, SessionManager, createAgentSession, allBuiltInTools, InteractiveMode, resetStdinForTui, runPrintMode, runRpcMode, } from '@gsd/pi-coding-agent';
2
2
  import { spawnSync } from 'node:child_process';
3
3
  import { readFileSync } from 'node:fs';
4
4
  import { join } from 'node:path';
@@ -373,12 +373,18 @@ if (isPrintMode) {
373
373
  });
374
374
  await resourceLoader.reload();
375
375
  markStartup('resourceLoader.reload');
376
+ const toolsOverride = cliFlags.tools
377
+ ? cliFlags.tools
378
+ .filter((toolName) => toolName in allBuiltInTools)
379
+ .map((toolName) => allBuiltInTools[toolName])
380
+ : undefined;
376
381
  const { session, extensionsResult } = await createAgentSession({
377
382
  authStorage,
378
383
  modelRegistry,
379
384
  settingsManager,
380
385
  sessionManager,
381
386
  resourceLoader,
387
+ ...(toolsOverride ? { tools: toolsOverride } : {}),
382
388
  });
383
389
  markStartup('createAgentSession');
384
390
  // Validate configured model AFTER extensions have registered their models (#2626).
@@ -296,7 +296,7 @@ export async function runOnboarding(authStorage, settingsManager) {
296
296
  summaryLines.push(`${pc.green('✓')} Budget subagent model: ${budgetModel}`);
297
297
  }
298
298
  else {
299
- summaryLines.push(`${pc.dim('↷')} Budget subagent model: app default/current model`);
299
+ summaryLines.push(`${pc.dim('↷')} Budget subagent model: app default/current model — set one to keep scout reconnaissance cheap`);
300
300
  }
301
301
  if (lspInstalled === null) {
302
302
  summaryLines.push(`${pc.dim('↷')} Language servers: skipped — run /setup to install later`);
@@ -345,9 +345,9 @@ async function runBudgetModelStep(p, pc, settingsManager) {
345
345
  if (existing) {
346
346
  options.push({ value: 'keep', label: `Keep current (${existing})`, hint: 'already configured' });
347
347
  }
348
- options.push({ value: 'default', label: 'Use current/default model', hint: 'scout falls back when no budget model is set' }, ...BUDGET_MODEL_OPTIONS, { value: 'skip', label: 'Skip for now', hint: 'change later in /settings' });
348
+ options.push({ value: 'default', label: 'Use current/default model', hint: 'works, but setting a cheap scout model keeps reconnaissance predictable' }, ...BUDGET_MODEL_OPTIONS, { value: 'skip', label: 'Skip for now', hint: 'change later in /settings' });
349
349
  const choice = await p.select({
350
- message: 'Choose a budget model for cheap subagents like scout',
350
+ message: 'Choose a budget model for cheap scout / recon subagents',
351
351
  options,
352
352
  });
353
353
  if (p.isCancel(choice) || choice === 'skip') {
@@ -9,6 +9,12 @@ You are a scout. Quickly investigate a codebase and return structured findings t
9
9
 
10
10
  Your output will be passed to an agent who has NOT seen the files you explored.
11
11
 
12
+ Scope boundary:
13
+ - Scout is for reconnaissance and mapping only.
14
+ - Do **not** perform full code review, security audit, bug triage, ranking of issues, or final recommendations as if you were the reviewer.
15
+ - If the task asks for review/audit findings, narrow your work to reconnaissance support: identify likely hotspots, relevant files, and questions/risks for a later reviewer.
16
+ - Do not present "top issues" as final judgments; present them as areas worth deeper review.
17
+
12
18
  Thoroughness (infer from task, default medium):
13
19
 
14
20
  - Quick: Targeted lookups, key files only
@@ -303,7 +303,13 @@ function buildExecutionKickoffMessage(options) {
303
303
  details.push(`Original task: ${task}`);
304
304
  if (state.latestPlanPath)
305
305
  details.push(`Primary plan artifact: ${state.latestPlanPath}`);
306
- details.push("After subagent completion, summarize the result and any remaining follow-ups.");
306
+ details.push("Important: if the plan is large and you estimate it would exceed a single subagent's context window (~200k tokens), " +
307
+ "split execution across multiple sequential subagents instead of one. " +
308
+ "Use the subagent tool's chain mode: pass a \"chain\" array where each entry covers one self-contained phase or group of steps from the plan. " +
309
+ "Each chain entry should include the agent name, a focused task description for that phase, and may reference {previous} to receive the prior phase's output as handoff context. " +
310
+ "Only split when genuinely needed — prefer a single subagent for plans that fit comfortably.");
311
+ details.push("After all subagents complete: (1) do a quick review of the implementation — check that the plan steps were actually carried out, spot obvious issues or missed pieces, and verify the code compiles/passes lint if applicable. " +
312
+ "(2) Then summarize what was done, what (if anything) needs follow-up, and flag any concerns found during review.");
307
313
  return details.join(" ");
308
314
  }
309
315
  let pendingNewSession = null;
@@ -790,9 +790,17 @@ export default function (pi) {
790
790
  ].join(" "),
791
791
  promptGuidelines: [
792
792
  "Use subagent to delegate self-contained tasks that benefit from an isolated context window.",
793
- "Use scout when a task requires reading and understanding many files to build architectural context — not for targeted lookups where LSP or a single file read is enough.",
793
+ "When scout is the right fit, call the subagent tool directly do not type '/subagent' as a shell-like command.",
794
+ "Valid call shapes: single mode uses { agent, task }, parallel mode uses { tasks: [{ agent, task }, ...] }, and chain mode uses { chain: [{ agent, task }, ...] }.",
795
+ "Recon planning rule: use no scout for narrow known-file work, one scout for one broad unfamiliar subsystem, and parallel scouts only when the work spans multiple loosely-coupled subsystems.",
796
+ "Use scout only for broad or unfamiliar codebase reconnaissance before you read many files yourself; save direct reads for targeted lookups once the relevant files are known.",
797
+ "Do not use scout as the reviewer, auditor, or final judge. Scout should map architecture, files, ownership, and likely hotspots for another agent or the parent model to evaluate.",
798
+ "If understanding the task would require scanning multiple files or folders to figure out architecture, routes, data flow, or ownership, launch scout first with single mode: { agent: 'scout', task: '...' }.",
799
+ "If reconnaissance spans multiple loosely-coupled subsystems, prefer parallel scout subagents with { tasks: [{ agent: 'scout', task: 'map frontend...' }, { agent: 'scout', task: 'map backend...' }] }.",
800
+ "When using scout for a review-like request, phrase the task as mapping: ask for architecture, key files, hotspots, and likely risk areas to inspect next — not for a final ranked review.",
801
+ "For broad review or audit requests, use scout only as a prep step; the parent model or a reviewer should make the final judgments.",
802
+ "Skip scout when the user already named the exact file/function to inspect or the task is obviously narrow.",
794
803
  "Use parallel mode when tasks are independent and don't need each other's output.",
795
- "Always check available agents with /subagent before choosing one.",
796
804
  "Use background: true when the user wants to keep chatting while a long-running agent works in parallel.",
797
805
  "If the user wants to wait for a background subagent result, use await_subagent.",
798
806
  ],
@@ -222,12 +222,15 @@ function makeGroupKey(groupBy, project, model) {
222
222
  }
223
223
  function collectUsage(sessionFiles, startMs, endMs, scope, groupBy) {
224
224
  const rows = new Map();
225
+ const userPromptRows = new Map();
225
226
  let filesScanned = 0;
226
227
  let matchedMessages = 0;
228
+ let matchedUserPrompts = 0;
227
229
  for (const file of sessionFiles) {
228
230
  filesScanned++;
229
231
  let projectLabel = basename(file);
230
232
  let headerResolved = false;
233
+ let currentModel = "";
231
234
  const raw = readFileSync(file, "utf-8");
232
235
  for (const line of raw.split("\n")) {
233
236
  if (!line.trim())
@@ -246,42 +249,83 @@ function collectUsage(sessionFiles, startMs, endMs, scope, groupBy) {
246
249
  headerResolved = true;
247
250
  }
248
251
  }
252
+ // Track model changes
253
+ if (parsed?.type === "model_change" && parsed.provider && parsed.modelId) {
254
+ currentModel = `${parsed.provider}/${parsed.modelId}`;
255
+ }
249
256
  const message = parsed?.type === "message" ? parsed.message : undefined;
250
- if (!message || message.role !== "assistant")
251
- continue;
252
- const timestamp = Number(message.timestamp ?? 0);
253
- if (!timestamp || timestamp < startMs || timestamp >= endMs)
257
+ if (!message)
254
258
  continue;
255
- matchedMessages++;
256
- const model = makeModelLabel(message);
257
- const key = makeGroupKey(groupBy, projectLabel, model);
258
- const usage = message.usage ?? {};
259
- const input = Number(usage.input ?? 0);
260
- const output = Number(usage.output ?? 0);
261
- const cacheRead = Number(usage.cacheRead ?? 0);
262
- const cacheWrite = Number(usage.cacheWrite ?? 0);
263
- const cost = Number(usage.cost?.total ?? 0);
264
- const total = input + output + cacheRead + cacheWrite;
265
- const existing = rows.get(key) ?? {
266
- key,
267
- project: groupBy === "model" ? "—" : projectLabel,
268
- model: groupBy === "project" ? "—" : model,
269
- messages: 0,
270
- input: 0,
271
- output: 0,
272
- cacheRead: 0,
273
- cacheWrite: 0,
274
- total: 0,
275
- cost: 0,
276
- };
277
- existing.messages += 1;
278
- existing.input += input;
279
- existing.output += output;
280
- existing.cacheRead += cacheRead;
281
- existing.cacheWrite += cacheWrite;
282
- existing.total += total;
283
- existing.cost += cost;
284
- rows.set(key, existing);
259
+ if (message.role === "assistant") {
260
+ const timestamp = Number(message.timestamp ?? 0);
261
+ if (!timestamp || timestamp < startMs || timestamp >= endMs)
262
+ continue;
263
+ matchedMessages++;
264
+ const model = message.provider && message.model ? `${message.provider}/${message.model}` : currentModel;
265
+ const key = makeGroupKey(groupBy, projectLabel, model);
266
+ const usage = message.usage ?? {};
267
+ const input = Number(usage.input ?? 0);
268
+ const output = Number(usage.output ?? 0);
269
+ const cacheRead = Number(usage.cacheRead ?? 0);
270
+ const cacheWrite = Number(usage.cacheWrite ?? 0);
271
+ const cost = Number(usage.cost?.total ?? 0);
272
+ const total = input + output + cacheRead + cacheWrite;
273
+ const existing = rows.get(key) ?? {
274
+ key,
275
+ project: groupBy === "model" ? "—" : projectLabel,
276
+ model: groupBy === "project" ? "—" : model,
277
+ messages: 0,
278
+ userPrompts: 0,
279
+ input: 0,
280
+ output: 0,
281
+ cacheRead: 0,
282
+ cacheWrite: 0,
283
+ total: 0,
284
+ cost: 0,
285
+ };
286
+ existing.messages += 1;
287
+ existing.input += input;
288
+ existing.output += output;
289
+ existing.cacheRead += cacheRead;
290
+ existing.cacheWrite += cacheWrite;
291
+ existing.total += total;
292
+ existing.cost += cost;
293
+ rows.set(key, existing);
294
+ }
295
+ else if (message.role === "user") {
296
+ const timestamp = Number(message.timestamp ?? 0);
297
+ if (!timestamp || timestamp < startMs || timestamp >= endMs)
298
+ continue;
299
+ matchedUserPrompts++;
300
+ const model = currentModel;
301
+ const key = makeGroupKey(groupBy, projectLabel, model);
302
+ const existing = userPromptRows.get(key) ?? {
303
+ key,
304
+ project: groupBy === "model" ? "—" : projectLabel,
305
+ model: groupBy === "project" ? "—" : model,
306
+ messages: 0,
307
+ userPrompts: 0,
308
+ input: 0,
309
+ output: 0,
310
+ cacheRead: 0,
311
+ cacheWrite: 0,
312
+ total: 0,
313
+ cost: 0,
314
+ };
315
+ existing.userPrompts += 1;
316
+ userPromptRows.set(key, existing);
317
+ }
318
+ }
319
+ }
320
+ // Merge user prompt counts into the main rows
321
+ for (const [key, userRow] of userPromptRows.entries()) {
322
+ const existing = rows.get(key);
323
+ if (existing) {
324
+ existing.userPrompts = userRow.userPrompts;
325
+ }
326
+ else {
327
+ // User prompts without assistant responses (edge case)
328
+ rows.set(key, userRow);
285
329
  }
286
330
  }
287
331
  const orderedRows = [...rows.values()].sort((left, right) => {
@@ -291,6 +335,7 @@ function collectUsage(sessionFiles, startMs, endMs, scope, groupBy) {
291
335
  });
292
336
  const totals = orderedRows.reduce((acc, row) => {
293
337
  acc.messages += row.messages;
338
+ acc.userPrompts += row.userPrompts;
294
339
  acc.input += row.input;
295
340
  acc.output += row.output;
296
341
  acc.cacheRead += row.cacheRead;
@@ -298,7 +343,7 @@ function collectUsage(sessionFiles, startMs, endMs, scope, groupBy) {
298
343
  acc.total += row.total;
299
344
  acc.cost += row.cost;
300
345
  return acc;
301
- }, { messages: 0, input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0, cost: 0 });
346
+ }, { messages: 0, userPrompts: 0, input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0, cost: 0 });
302
347
  return {
303
348
  label: "",
304
349
  scope,
@@ -318,6 +363,7 @@ function renderTable(report) {
318
363
  : "model";
319
364
  const displayRows = report.rows.map((row) => ({
320
365
  label: row.key,
366
+ userPrompts: String(row.userPrompts),
321
367
  msgs: String(row.messages),
322
368
  input: formatInt(row.input),
323
369
  output: formatInt(row.output),
@@ -328,6 +374,7 @@ function renderTable(report) {
328
374
  }));
329
375
  const widths = {
330
376
  label: Math.max(firstColumnHeader.length, ...displayRows.map((row) => row.label.length), 5),
377
+ userPrompts: Math.max(11, ...displayRows.map((row) => row.userPrompts.length), String(report.totals.userPrompts).length),
331
378
  msgs: Math.max(4, ...displayRows.map((row) => row.msgs.length), String(report.totals.messages).length),
332
379
  input: Math.max(5, ...displayRows.map((row) => row.input.length), formatInt(report.totals.input).length),
333
380
  output: Math.max(6, ...displayRows.map((row) => row.output.length), formatInt(report.totals.output).length),
@@ -338,6 +385,7 @@ function renderTable(report) {
338
385
  };
339
386
  const header = [
340
387
  firstColumnHeader.padEnd(widths.label),
388
+ "user prompts".padStart(widths.userPrompts),
341
389
  "msgs".padStart(widths.msgs),
342
390
  "input".padStart(widths.input),
343
391
  "output".padStart(widths.output),
@@ -349,6 +397,7 @@ function renderTable(report) {
349
397
  const divider = "-".repeat(header.length);
350
398
  const body = displayRows.map((row) => [
351
399
  row.label.padEnd(widths.label),
400
+ row.userPrompts.padStart(widths.userPrompts),
352
401
  row.msgs.padStart(widths.msgs),
353
402
  row.input.padStart(widths.input),
354
403
  row.output.padStart(widths.output),
@@ -359,6 +408,7 @@ function renderTable(report) {
359
408
  ].join(" "));
360
409
  const totalsLine = [
361
410
  "TOTAL".padEnd(widths.label),
411
+ String(report.totals.userPrompts).padStart(widths.userPrompts),
362
412
  String(report.totals.messages).padStart(widths.msgs),
363
413
  formatInt(report.totals.input).padStart(widths.input),
364
414
  formatInt(report.totals.output).padStart(widths.output),
@@ -377,7 +427,8 @@ function renderReport(report) {
377
427
  `Grouped by: ${report.groupBy}`,
378
428
  `Sessions root: ${report.sessionsRoot}`,
379
429
  `Session files scanned: ${report.filesScanned}`,
380
- `Assistant messages matched: ${report.matchedMessages}`,
430
+ `User prompts: ${report.totals.userPrompts}`,
431
+ `Assistant messages: ${report.matchedMessages}`,
381
432
  ].join("\n");
382
433
  if (report.rows.length === 0) {
383
434
  return `${summary}\n\nNo assistant usage found for that range.`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lsd-pi",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "LSD — Looks Sort of Done coding agent",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,mBAAmB,EAGxB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAEX,UAAU,EACV,eAAe,EACf,YAAY,EACZ,UAAU,EACV,SAAS,EAKT,QAAQ,EACR,aAAa,EACb,MAAM,YAAY,CAAC;AASpB,MAAM,WAAW,YAAY;IAC5B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C,EAAE,EAAE,YAAY,EAAE;IAIlC,aAAa,CAAC,CAAC,EAAE,YAAY;IAI7B;;;OAGG;IACH,KAAK,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,GAAE,MAAM,GAAG,QAAmB;IAI3D;;;OAGG;IACH,QAAQ,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,GAAE,MAAM,GAAG,QAAmB;IAI9D,kBAAkB;IAIlB,kBAAkB;IAIlB,cAAc;IAKd;;;OAGG;IACH,iBAAiB,IAAI;QAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;QAAC,QAAQ,EAAE,YAAY,EAAE,CAAA;KAAE;IAQ3E,iBAAiB,IAAI,OAAO;IAI5B,OAAO,CAAC,uBAAuB;IAe/B,OAAO,CAAC,uBAAuB;IAe/B,aAAa;IAIb,KAAK;IAIL,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,KAAK;IAUL,yCAAyC;IACnC,MAAM,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAC7D,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkCnE;;OAEG;IACG,QAAQ;IA4Bd;;;;OAIG;YACW,QAAQ;IA8ItB,OAAO,CAAC,uBAAuB;IAM/B,OAAO,CAAC,IAAI;CAKZ"}
@@ -134,7 +134,10 @@ export class Agent {
134
134
  return this.followUpMode;
135
135
  }
136
136
  setTools(t) {
137
- this._state.tools = t;
137
+ // Mutate in-place so any AgentContext.tools reference captured by the
138
+ // running agent loop stays live and immediately sees the new tool set.
139
+ // This allows tool_enable to take effect within the same turn.
140
+ this._state.tools.splice(0, this._state.tools.length, ...t);
138
141
  }
139
142
  replaceMessages(ms) {
140
143
  this._state.messages = ms.slice();
@@ -297,10 +300,13 @@ export class Agent {
297
300
  this._state.streamMessage = null;
298
301
  this._state.error = undefined;
299
302
  const reasoning = this._state.thinkingLevel === "off" ? undefined : this._state.thinkingLevel;
303
+ const self = this;
300
304
  const context = {
301
305
  systemPrompt: this._state.systemPrompt,
302
306
  messages: this._state.messages.slice(),
303
- tools: this._state.tools,
307
+ get tools() {
308
+ return self._state.tools;
309
+ },
304
310
  };
305
311
  let skipInitialSteeringPoll = options?.skipInitialSteeringPoll === true;
306
312
  const config = {
@@ -1 +1 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,QAAQ,EAKR,YAAY,GAIZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAgB3E;;GAEG;AACH,SAAS,mBAAmB,CAAC,QAAwB;IACpD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;AACvG,CAAC;AAoFD,MAAM,OAAO,KAAK;IAkCjB,YAAY,OAAqB,EAAE;QAjC3B,WAAM,GAAe;YAC5B,YAAY,EAAE,EAAE;YAChB,KAAK,EAAE,QAAQ,CAAC,QAAQ,EAAE,qCAAqC,CAAC;YAChE,aAAa,EAAE,KAAK;YACpB,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,WAAW,EAAE,KAAK;YAClB,aAAa,EAAE,IAAI;YACnB,gBAAgB,EAAE,IAAI,GAAG,EAAU;YACnC,KAAK,EAAE,SAAS;SAChB,CAAC;QAEM,cAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;QAI/C,kBAAa,GAAiB,EAAE,CAAC;QACjC,kBAAa,GAAiB,EAAE,CAAC;QAiBxC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,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AEO,uBAAuB,CAAC,MAAwB,EAAE,EAAU;QACnE,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAChD,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAClC,CAAC;IAEO,IAAI,CAAC,CAAa;QACzB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACvC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACb,CAAC;IACF,CAAC;CACD","sourcesContent":["/**\n * Agent class that uses the agent-loop directly.\n * No transport abstraction - calls streamSimple via the loop.\n */\n\nimport {\n\tgetModel,\n\ttype ImageContent,\n\ttype Message,\n\ttype Model,\n\ttype SimpleStreamOptions,\n\tstreamSimple,\n\ttype TextContent,\n\ttype ThinkingBudgets,\n\ttype Transport,\n} from \"@gsd/pi-ai\";\nimport { agentLoop, agentLoopContinue, ZERO_USAGE } from \"./agent-loop.js\";\nimport type {\n\tAgentContext,\n\tAgentEvent,\n\tAgentLoopConfig,\n\tAgentMessage,\n\tAgentState,\n\tAgentTool,\n\tBeforeToolCallContext,\n\tBeforeToolCallResult,\n\tAfterToolCallContext,\n\tAfterToolCallResult,\n\tStreamFn,\n\tThinkingLevel,\n} from \"./types.js\";\n\n/**\n * Default convertToLlm: Keep only LLM-compatible messages, convert attachments.\n */\nfunction defaultConvertToLlm(messages: AgentMessage[]): Message[] {\n\treturn messages.filter((m) => m.role === \"user\" || m.role === \"assistant\" || m.role === \"toolResult\");\n}\n\nexport interface AgentOptions {\n\tinitialState?: Partial<AgentState>;\n\n\t/**\n\t * Converts AgentMessage[] to LLM-compatible Message[] before each LLM call.\n\t * Default filters to user/assistant/toolResult and converts attachments.\n\t */\n\tconvertToLlm?: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\n\t/**\n\t * Optional transform applied to context before convertToLlm.\n\t * Use for context pruning, injecting external context, etc.\n\t */\n\ttransformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\n\t/**\n\t * Steering mode: \"all\" = send all steering messages at once, \"one-at-a-time\" = one per turn\n\t */\n\tsteeringMode?: \"all\" | \"one-at-a-time\";\n\n\t/**\n\t * Follow-up mode: \"all\" = send all follow-up messages at once, \"one-at-a-time\" = one per turn\n\t */\n\tfollowUpMode?: \"all\" | \"one-at-a-time\";\n\n\t/**\n\t * Custom stream function (for proxy backends, etc.). Default uses streamSimple.\n\t */\n\tstreamFn?: StreamFn;\n\n\t/**\n\t * Optional session identifier forwarded to LLM providers.\n\t * Used by providers that support session-based caching (e.g., OpenAI Codex).\n\t */\n\tsessionId?: string;\n\n\t/**\n\t * Resolves an API key dynamically for each LLM call.\n\t * Useful for expiring tokens (e.g., GitHub Copilot OAuth).\n\t */\n\tgetApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\n\t/**\n\t * Inspect or replace provider payloads before they are sent.\n\t */\n\tonPayload?: SimpleStreamOptions[\"onPayload\"];\n\n\t/**\n\t * Custom token budgets for thinking levels (token-based providers only).\n\t */\n\tthinkingBudgets?: ThinkingBudgets;\n\n\t/**\n\t * Preferred transport for providers that support multiple transports.\n\t */\n\ttransport?: Transport;\n\n\t/**\n\t * Maximum delay in milliseconds to wait for a retry when the server requests a long wait.\n\t * If the server's requested delay exceeds this value, the request fails immediately,\n\t * allowing higher-level retry logic to handle it with user visibility.\n\t * Default: 60000 (60 seconds). Set to 0 to disable the cap.\n\t */\n\tmaxRetryDelayMs?: number;\n\n\t/**\n\t * Determines whether a model uses external tool execution (tools handled\n\t * by the provider, not dispatched locally). Evaluated per-loop so model\n\t * switches mid-session are handled correctly.\n\t */\n\texternalToolExecution?: (model: Model<any>) => boolean;\n}\n\n/**\n * Internal wrapper that tracks message origin for origin-aware queue clearing.\n * \"user\" = typed by human in TUI; \"system\" = generated by extensions/background jobs.\n */\ninterface QueueEntry {\n\tmessage: AgentMessage;\n\torigin: \"user\" | \"system\";\n}\n\nexport class Agent {\n\tprivate _state: AgentState = {\n\t\tsystemPrompt: \"\",\n\t\tmodel: getModel(\"google\", \"gemini-2.5-flash-lite-preview-06-17\"),\n\t\tthinkingLevel: \"off\",\n\t\ttools: [],\n\t\tmessages: [],\n\t\tisStreaming: false,\n\t\tstreamMessage: null,\n\t\tpendingToolCalls: new Set<string>(),\n\t\terror: undefined,\n\t};\n\n\tprivate listeners = new Set<(e: AgentEvent) => void>();\n\tprivate abortController?: AbortController;\n\tprivate convertToLlm: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\tprivate transformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\tprivate steeringQueue: QueueEntry[] = [];\n\tprivate followUpQueue: QueueEntry[] = [];\n\tprivate steeringMode: \"all\" | \"one-at-a-time\";\n\tprivate followUpMode: \"all\" | \"one-at-a-time\";\n\tpublic streamFn: StreamFn;\n\tprivate _sessionId?: string;\n\tpublic getApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\tprivate _onPayload?: SimpleStreamOptions[\"onPayload\"];\n\tprivate runningPrompt?: Promise<void>;\n\tprivate resolveRunningPrompt?: () => void;\n\tprivate _thinkingBudgets?: ThinkingBudgets;\n\tprivate _transport: Transport;\n\tprivate _maxRetryDelayMs?: number;\n\tprivate _beforeToolCall?: AgentLoopConfig[\"beforeToolCall\"];\n\tprivate _afterToolCall?: AgentLoopConfig[\"afterToolCall\"];\n\tprivate _externalToolExecution?: (model: Model<any>) => boolean;\n\n\tconstructor(opts: AgentOptions = {}) {\n\t\tthis._state = { ...this._state, ...opts.initialState };\n\t\tthis.convertToLlm = opts.convertToLlm || defaultConvertToLlm;\n\t\tthis.transformContext = opts.transformContext;\n\t\tthis.steeringMode = opts.steeringMode || \"one-at-a-time\";\n\t\tthis.followUpMode = opts.followUpMode || \"one-at-a-time\";\n\t\tthis.streamFn = opts.streamFn || streamSimple;\n\t\tthis._sessionId = opts.sessionId;\n\t\tthis.getApiKey = opts.getApiKey;\n\t\tthis._onPayload = opts.onPayload;\n\t\tthis._thinkingBudgets = opts.thinkingBudgets;\n\t\tthis._transport = opts.transport ?? \"sse\";\n\t\tthis._maxRetryDelayMs = opts.maxRetryDelayMs;\n\t\tthis._externalToolExecution = opts.externalToolExecution;\n\t}\n\n\t/**\n\t * Get the current session ID used for provider caching.\n\t */\n\tget sessionId(): string | undefined {\n\t\treturn this._sessionId;\n\t}\n\n\t/**\n\t * Set the session ID for provider caching.\n\t * Call this when switching sessions (new session, branch, resume).\n\t */\n\tset sessionId(value: string | undefined) {\n\t\tthis._sessionId = value;\n\t}\n\n\t/**\n\t * Get the current thinking budgets.\n\t */\n\tget thinkingBudgets(): ThinkingBudgets | undefined {\n\t\treturn this._thinkingBudgets;\n\t}\n\n\t/**\n\t * Set custom thinking budgets for token-based providers.\n\t */\n\tset thinkingBudgets(value: ThinkingBudgets | undefined) {\n\t\tthis._thinkingBudgets = value;\n\t}\n\n\t/**\n\t * Get the current preferred transport.\n\t */\n\tget transport(): Transport {\n\t\treturn this._transport;\n\t}\n\n\t/**\n\t * Set the preferred transport.\n\t */\n\tsetTransport(value: Transport) {\n\t\tthis._transport = value;\n\t}\n\n\t/**\n\t * Get the current max retry delay in milliseconds.\n\t */\n\tget maxRetryDelayMs(): number | undefined {\n\t\treturn this._maxRetryDelayMs;\n\t}\n\n\t/**\n\t * Set the maximum delay to wait for server-requested retries.\n\t * Set to 0 to disable the cap.\n\t */\n\tset maxRetryDelayMs(value: number | undefined) {\n\t\tthis._maxRetryDelayMs = value;\n\t}\n\n\t/**\n\t * Install a hook called before each tool executes, after argument validation.\n\t * Return `{ block: true }` to prevent execution.\n\t */\n\tsetBeforeToolCall(fn: AgentLoopConfig[\"beforeToolCall\"]): void {\n\t\tthis._beforeToolCall = fn;\n\t}\n\n\t/**\n\t * Install a hook called after each tool executes, before results are emitted.\n\t * Return field overrides for content/details/isError.\n\t */\n\tsetAfterToolCall(fn: AgentLoopConfig[\"afterToolCall\"]): void {\n\t\tthis._afterToolCall = fn;\n\t}\n\n\tget state(): AgentState {\n\t\treturn this._state;\n\t}\n\n\tsubscribe(fn: (e: AgentEvent) => void): () => void {\n\t\tthis.listeners.add(fn);\n\t\treturn () => this.listeners.delete(fn);\n\t}\n\n\t// State mutators\n\tsetSystemPrompt(v: string) {\n\t\tthis._state.systemPrompt = v;\n\t}\n\n\tsetModel(m: Model<any>) {\n\t\tthis._state.model = m;\n\t}\n\n\tsetThinkingLevel(l: ThinkingLevel) {\n\t\tthis._state.thinkingLevel = l;\n\t}\n\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\") {\n\t\tthis.steeringMode = mode;\n\t}\n\n\tgetSteeringMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.steeringMode;\n\t}\n\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\") {\n\t\tthis.followUpMode = mode;\n\t}\n\n\tgetFollowUpMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.followUpMode;\n\t}\n\n\tsetTools(t: AgentTool<any>[]) {\n\t\tthis._state.tools = t;\n\t}\n\n\treplaceMessages(ms: AgentMessage[]) {\n\t\tthis._state.messages = ms.slice();\n\t}\n\n\tappendMessage(m: AgentMessage) {\n\t\tthis._state.messages = [...this._state.messages, m];\n\t}\n\n\t/**\n\t * Queue a steering message to interrupt the agent mid-run.\n\t * Delivered after current tool execution, skips remaining tools.\n\t */\n\tsteer(m: AgentMessage, origin: \"user\" | \"system\" = \"system\") {\n\t\tthis.steeringQueue.push({ message: m, origin });\n\t}\n\n\t/**\n\t * Queue a follow-up message to be processed after the agent finishes.\n\t * Delivered only when agent has no more tool calls or steering messages.\n\t */\n\tfollowUp(m: AgentMessage, origin: \"user\" | \"system\" = \"system\") {\n\t\tthis.followUpQueue.push({ message: m, origin });\n\t}\n\n\tclearSteeringQueue() {\n\t\tthis.steeringQueue = [];\n\t}\n\n\tclearFollowUpQueue() {\n\t\tthis.followUpQueue = [];\n\t}\n\n\tclearAllQueues() {\n\t\tthis.steeringQueue = [];\n\t\tthis.followUpQueue = [];\n\t}\n\n\t/**\n\t * Drain user-origin messages from queues, leaving system messages in place.\n\t * Used during abort to preserve messages the user explicitly typed.\n\t */\n\tdrainUserMessages(): { steering: AgentMessage[]; followUp: AgentMessage[] } {\n\t\tconst userSteering = this.steeringQueue.filter((e) => e.origin === \"user\").map((e) => e.message);\n\t\tconst userFollowUp = this.followUpQueue.filter((e) => e.origin === \"user\").map((e) => e.message);\n\t\tthis.steeringQueue = this.steeringQueue.filter((e) => e.origin !== \"user\");\n\t\tthis.followUpQueue = this.followUpQueue.filter((e) => e.origin !== \"user\");\n\t\treturn { steering: userSteering, followUp: userFollowUp };\n\t}\n\n\thasQueuedMessages(): boolean {\n\t\treturn this.steeringQueue.length > 0 || this.followUpQueue.length > 0;\n\t}\n\n\tprivate dequeueSteeringMessages(): AgentMessage[] {\n\t\tif (this.steeringMode === \"one-at-a-time\") {\n\t\t\tif (this.steeringQueue.length > 0) {\n\t\t\t\tconst first = this.steeringQueue[0];\n\t\t\t\tthis.steeringQueue = this.steeringQueue.slice(1);\n\t\t\t\treturn [first.message];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\n\t\tconst steering = this.steeringQueue.map((e) => e.message);\n\t\tthis.steeringQueue = [];\n\t\treturn steering;\n\t}\n\n\tprivate dequeueFollowUpMessages(): AgentMessage[] {\n\t\tif (this.followUpMode === \"one-at-a-time\") {\n\t\t\tif (this.followUpQueue.length > 0) {\n\t\t\t\tconst first = this.followUpQueue[0];\n\t\t\t\tthis.followUpQueue = this.followUpQueue.slice(1);\n\t\t\t\treturn [first.message];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\n\t\tconst followUp = this.followUpQueue.map((e) => e.message);\n\t\tthis.followUpQueue = [];\n\t\treturn followUp;\n\t}\n\n\tclearMessages() {\n\t\tthis._state.messages = [];\n\t}\n\n\tabort() {\n\t\tthis.abortController?.abort();\n\t}\n\n\twaitForIdle(): Promise<void> {\n\t\treturn this.runningPrompt ?? Promise.resolve();\n\t}\n\n\treset() {\n\t\tthis._state.messages = [];\n\t\tthis._state.isStreaming = false;\n\t\tthis._state.streamMessage = null;\n\t\tthis._state.pendingToolCalls = new Set<string>();\n\t\tthis._state.error = undefined;\n\t\tthis.steeringQueue = [];\n\t\tthis.followUpQueue = [];\n\t}\n\n\t/** Send a prompt with an AgentMessage */\n\tasync prompt(message: AgentMessage | AgentMessage[]): Promise<void>;\n\tasync prompt(input: string, images?: ImageContent[]): Promise<void>;\n\tasync prompt(input: string | AgentMessage | AgentMessage[], images?: ImageContent[]) {\n\t\tif (this._state.isStreaming) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Agent is already processing a prompt. Use steer() or followUp() to queue messages, or wait for completion.\",\n\t\t\t);\n\t\t}\n\n\t\tconst model = this._state.model;\n\t\tif (!model) throw new Error(\"No model configured\");\n\n\t\tlet msgs: AgentMessage[];\n\n\t\tif (Array.isArray(input)) {\n\t\t\tmsgs = input;\n\t\t} else if (typeof input === \"string\") {\n\t\t\tconst content: Array<TextContent | ImageContent> = [{ type: \"text\", text: input }];\n\t\t\tif (images && images.length > 0) {\n\t\t\t\tcontent.push(...images);\n\t\t\t}\n\t\t\tmsgs = [\n\t\t\t\t{\n\t\t\t\t\trole: \"user\",\n\t\t\t\t\tcontent,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t},\n\t\t\t];\n\t\t} else {\n\t\t\tmsgs = [input];\n\t\t}\n\n\t\tawait this._runLoop(msgs);\n\t}\n\n\t/**\n\t * Continue from current context (used for retries and resuming queued messages).\n\t */\n\tasync continue() {\n\t\tif (this._state.isStreaming) {\n\t\t\tthrow new Error(\"Agent is already processing. Wait for completion before continuing.\");\n\t\t}\n\n\t\tconst messages = this._state.messages;\n\t\tif (messages.length === 0) {\n\t\t\tthrow new Error(\"No messages to continue from\");\n\t\t}\n\t\tif (messages[messages.length - 1].role === \"assistant\") {\n\t\t\tconst queuedSteering = this.dequeueSteeringMessages();\n\t\t\tif (queuedSteering.length > 0) {\n\t\t\t\tawait this._runLoop(queuedSteering, { skipInitialSteeringPoll: true });\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst queuedFollowUp = this.dequeueFollowUpMessages();\n\t\t\tif (queuedFollowUp.length > 0) {\n\t\t\t\tawait this._runLoop(queuedFollowUp);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrow new Error(\"Cannot continue from message role: assistant\");\n\t\t}\n\n\t\tawait this._runLoop(undefined);\n\t}\n\n\t/**\n\t * Run the agent loop.\n\t * If messages are provided, starts a new conversation turn with those messages.\n\t * Otherwise, continues from existing context.\n\t */\n\tprivate async _runLoop(messages?: AgentMessage[], options?: { skipInitialSteeringPoll?: boolean }) {\n\t\tconst model = this._state.model;\n\t\tif (!model) throw new Error(\"No model configured\");\n\n\t\tthis._state.activeInferenceModel = model;\n\n\t\tthis.runningPrompt = new Promise<void>((resolve) => {\n\t\t\tthis.resolveRunningPrompt = resolve;\n\t\t});\n\n\t\tthis.abortController = new AbortController();\n\t\tthis._state.isStreaming = true;\n\t\tthis._state.streamMessage = null;\n\t\tthis._state.error = undefined;\n\n\t\tconst reasoning = this._state.thinkingLevel === \"off\" ? undefined : this._state.thinkingLevel;\n\n\t\tconst context: AgentContext = {\n\t\t\tsystemPrompt: this._state.systemPrompt,\n\t\t\tmessages: this._state.messages.slice(),\n\t\t\ttools: this._state.tools,\n\t\t};\n\n\t\tlet skipInitialSteeringPoll = options?.skipInitialSteeringPoll === true;\n\n\t\tconst config: AgentLoopConfig = {\n\t\t\tmodel,\n\t\t\treasoning,\n\t\t\tsessionId: this._sessionId,\n\t\t\tonPayload: this._onPayload,\n\t\t\ttransport: this._transport,\n\t\t\tthinkingBudgets: this._thinkingBudgets,\n\t\t\tmaxRetryDelayMs: this._maxRetryDelayMs,\n\t\t\tconvertToLlm: this.convertToLlm,\n\t\t\ttransformContext: this.transformContext,\n\t\t\tgetApiKey: this.getApiKey,\n\t\t\tgetSteeringMessages: async () => {\n\t\t\t\tif (skipInitialSteeringPoll) {\n\t\t\t\t\tskipInitialSteeringPoll = false;\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn this.dequeueSteeringMessages();\n\t\t\t},\n\t\t\tgetFollowUpMessages: async () => this.dequeueFollowUpMessages(),\n\t\t\tbeforeToolCall: this._beforeToolCall,\n\t\t\tafterToolCall: this._afterToolCall,\n\t\t\texternalToolExecution: this._externalToolExecution?.(model) ?? false,\n\t\t};\n\n\t\tlet partial: AgentMessage | null = null;\n\n\t\ttry {\n\t\t\tconst stream = messages\n\t\t\t\t? agentLoop(messages, context, config, this.abortController.signal, this.streamFn)\n\t\t\t\t: agentLoopContinue(context, config, this.abortController.signal, this.streamFn);\n\n\t\t\tfor await (const event of stream) {\n\t\t\t\t// Update internal state based on events\n\t\t\t\tswitch (event.type) {\n\t\t\t\t\tcase \"message_start\":\n\t\t\t\t\tcase \"message_update\":\n\t\t\t\t\t\tpartial = event.message;\n\t\t\t\t\t\tthis._state.streamMessage = event.message;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"message_end\":\n\t\t\t\t\t\tpartial = null;\n\t\t\t\t\t\tthis._state.streamMessage = null;\n\t\t\t\t\t\tthis.appendMessage(event.message);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"tool_execution_start\":\n\t\t\t\t\t\tthis._updatePendingToolCalls(\"add\", event.toolCallId);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"tool_execution_end\":\n\t\t\t\t\t\tthis._updatePendingToolCalls(\"delete\", event.toolCallId);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"turn_end\":\n\t\t\t\t\t\tif (event.message.role === \"assistant\" && (event.message as any).errorMessage) {\n\t\t\t\t\t\t\tthis._state.error = (event.message as any).errorMessage;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"agent_end\":\n\t\t\t\t\t\tthis._state.isStreaming = false;\n\t\t\t\t\t\tthis._state.streamMessage = null;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Emit to listeners\n\t\t\t\tthis.emit(event);\n\t\t\t}\n\n\t\t\t// Handle any remaining partial message\n\t\t\tif (partial && partial.role === \"assistant\" && partial.content.length > 0) {\n\t\t\t\tconst onlyEmpty = !partial.content.some(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\t(c.type === \"thinking\" && c.thinking.trim().length > 0) ||\n\t\t\t\t\t\t(c.type === \"text\" && c.text.trim().length > 0) ||\n\t\t\t\t\t\t(c.type === \"toolCall\" && c.name.trim().length > 0),\n\t\t\t\t);\n\t\t\t\tif (!onlyEmpty) {\n\t\t\t\t\tthis.appendMessage(partial);\n\t\t\t\t} else {\n\t\t\t\t\tif (this.abortController?.signal.aborted) {\n\t\t\t\t\t\tthrow new Error(\"Request was aborted\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\tconst errorMsg: AgentMessage = {\n\t\t\t\trole: \"assistant\",\n\t\t\t\tcontent: [{ type: \"text\", text: \"\" }],\n\t\t\t\tapi: model.api,\n\t\t\t\tprovider: model.provider,\n\t\t\t\tmodel: model.id,\n\t\t\t\tusage: ZERO_USAGE,\n\t\t\t\tstopReason: this.abortController?.signal.aborted ? \"aborted\" : \"error\",\n\t\t\t\terrorMessage: err?.message || String(err),\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t} as AgentMessage;\n\n\t\t\tthis.appendMessage(errorMsg);\n\t\t\tthis._state.error = err?.message || String(err);\n\t\t\tthis.emit({ type: \"agent_end\", messages: [errorMsg] });\n\t\t} finally {\n\t\t\tthis._state.isStreaming = false;\n\t\t\tthis._state.streamMessage = null;\n\t\t\tthis._state.pendingToolCalls = new Set<string>();\n\t\t\tthis._state.activeInferenceModel = undefined;\n\t\t\tthis.abortController = undefined;\n\t\t\tthis.resolveRunningPrompt?.();\n\t\t\tthis.runningPrompt = undefined;\n\t\t\tthis.resolveRunningPrompt = undefined;\n\t\t}\n\t}\n\n\tprivate _updatePendingToolCalls(action: \"add\" | \"delete\", id: string): void {\n\t\tconst s = new Set(this._state.pendingToolCalls);\n\t\ts[action](id);\n\t\tthis._state.pendingToolCalls = s;\n\t}\n\n\tprivate emit(e: AgentEvent) {\n\t\tfor (const listener of this.listeners) {\n\t\t\tlistener(e);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,QAAQ,EAKR,YAAY,GAIZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAgB3E;;GAEG;AACH,SAAS,mBAAmB,CAAC,QAAwB;IACpD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;AACvG,CAAC;AAoFD,MAAM,OAAO,KAAK;IAkCjB,YAAY,OAAqB,EAAE;QAjC3B,WAAM,GAAe;YAC5B,YAAY,EAAE,EAAE;YAChB,KAAK,EAAE,QAAQ,CAAC,QAAQ,EAAE,qCAAqC,CAAC;YAChE,aAAa,EAAE,KAAK;YACpB,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,WAAW,EAAE,KAAK;YAClB,aAAa,EAAE,IAAI;YACnB,gBAAgB,EAAE,IAAI,GAAG,EAAU;YACnC,KAAK,EAAE,SAAS;SAChB,CAAC;QAEM,cAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;QAI/C,kBAAa,GAAiB,EAAE,CAAC;QACjC,kBAAa,GAAiB,EAAE,CA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ACjD,IAAI,CAAC,MAAM,CAAC,oBAAoB,GAAG,SAAS,CAAC;YAC7C,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;YACjC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;YAC9B,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;YAC/B,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;QACvC,CAAC;IACF,CAAC;IAEO,uBAAuB,CAAC,MAAwB,EAAE,EAAU;QACnE,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAChD,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAClC,CAAC;IAEO,IAAI,CAAC,CAAa;QACzB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACvC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACb,CAAC;IACF,CAAC;CACD","sourcesContent":["/**\n * Agent class that uses the agent-loop directly.\n * No transport abstraction - calls streamSimple via the loop.\n */\n\nimport {\n\tgetModel,\n\ttype ImageContent,\n\ttype Message,\n\ttype Model,\n\ttype SimpleStreamOptions,\n\tstreamSimple,\n\ttype TextContent,\n\ttype ThinkingBudgets,\n\ttype Transport,\n} from \"@gsd/pi-ai\";\nimport { agentLoop, agentLoopContinue, ZERO_USAGE } from \"./agent-loop.js\";\nimport type {\n\tAgentContext,\n\tAgentEvent,\n\tAgentLoopConfig,\n\tAgentMessage,\n\tAgentState,\n\tAgentTool,\n\tBeforeToolCallContext,\n\tBeforeToolCallResult,\n\tAfterToolCallContext,\n\tAfterToolCallResult,\n\tStreamFn,\n\tThinkingLevel,\n} from \"./types.js\";\n\n/**\n * Default convertToLlm: Keep only LLM-compatible messages, convert attachments.\n */\nfunction defaultConvertToLlm(messages: AgentMessage[]): Message[] {\n\treturn messages.filter((m) => m.role === \"user\" || m.role === \"assistant\" || m.role === \"toolResult\");\n}\n\nexport interface AgentOptions {\n\tinitialState?: Partial<AgentState>;\n\n\t/**\n\t * Converts AgentMessage[] to LLM-compatible Message[] before each LLM call.\n\t * Default filters to user/assistant/toolResult and converts attachments.\n\t */\n\tconvertToLlm?: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\n\t/**\n\t * Optional transform applied to context before convertToLlm.\n\t * Use for context pruning, injecting external context, etc.\n\t */\n\ttransformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\n\t/**\n\t * Steering mode: \"all\" = send all steering messages at once, \"one-at-a-time\" = one per turn\n\t */\n\tsteeringMode?: \"all\" | \"one-at-a-time\";\n\n\t/**\n\t * Follow-up mode: \"all\" = send all follow-up messages at once, \"one-at-a-time\" = one per turn\n\t */\n\tfollowUpMode?: \"all\" | \"one-at-a-time\";\n\n\t/**\n\t * Custom stream function (for proxy backends, etc.). Default uses streamSimple.\n\t */\n\tstreamFn?: StreamFn;\n\n\t/**\n\t * Optional session identifier forwarded to LLM providers.\n\t * Used by providers that support session-based caching (e.g., OpenAI Codex).\n\t */\n\tsessionId?: string;\n\n\t/**\n\t * Resolves an API key dynamically for each LLM call.\n\t * Useful for expiring tokens (e.g., GitHub Copilot OAuth).\n\t */\n\tgetApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\n\t/**\n\t * Inspect or replace provider payloads before they are sent.\n\t */\n\tonPayload?: SimpleStreamOptions[\"onPayload\"];\n\n\t/**\n\t * Custom token budgets for thinking levels (token-based providers only).\n\t */\n\tthinkingBudgets?: ThinkingBudgets;\n\n\t/**\n\t * Preferred transport for providers that support multiple transports.\n\t */\n\ttransport?: Transport;\n\n\t/**\n\t * Maximum delay in milliseconds to wait for a retry when the server requests a long wait.\n\t * If the server's requested delay exceeds this value, the request fails immediately,\n\t * allowing higher-level retry logic to handle it with user visibility.\n\t * Default: 60000 (60 seconds). Set to 0 to disable the cap.\n\t */\n\tmaxRetryDelayMs?: number;\n\n\t/**\n\t * Determines whether a model uses external tool execution (tools handled\n\t * by the provider, not dispatched locally). Evaluated per-loop so model\n\t * switches mid-session are handled correctly.\n\t */\n\texternalToolExecution?: (model: Model<any>) => boolean;\n}\n\n/**\n * Internal wrapper that tracks message origin for origin-aware queue clearing.\n * \"user\" = typed by human in TUI; \"system\" = generated by extensions/background jobs.\n */\ninterface QueueEntry {\n\tmessage: AgentMessage;\n\torigin: \"user\" | \"system\";\n}\n\nexport class Agent {\n\tprivate _state: AgentState = {\n\t\tsystemPrompt: \"\",\n\t\tmodel: getModel(\"google\", \"gemini-2.5-flash-lite-preview-06-17\"),\n\t\tthinkingLevel: \"off\",\n\t\ttools: [],\n\t\tmessages: [],\n\t\tisStreaming: false,\n\t\tstreamMessage: null,\n\t\tpendingToolCalls: new Set<string>(),\n\t\terror: undefined,\n\t};\n\n\tprivate listeners = new Set<(e: AgentEvent) => void>();\n\tprivate abortController?: AbortController;\n\tprivate convertToLlm: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\tprivate transformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\tprivate steeringQueue: QueueEntry[] = [];\n\tprivate followUpQueue: QueueEntry[] = [];\n\tprivate steeringMode: \"all\" | \"one-at-a-time\";\n\tprivate followUpMode: \"all\" | \"one-at-a-time\";\n\tpublic streamFn: StreamFn;\n\tprivate _sessionId?: string;\n\tpublic getApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\tprivate _onPayload?: SimpleStreamOptions[\"onPayload\"];\n\tprivate runningPrompt?: Promise<void>;\n\tprivate resolveRunningPrompt?: () => void;\n\tprivate _thinkingBudgets?: ThinkingBudgets;\n\tprivate _transport: Transport;\n\tprivate _maxRetryDelayMs?: number;\n\tprivate _beforeToolCall?: AgentLoopConfig[\"beforeToolCall\"];\n\tprivate _afterToolCall?: AgentLoopConfig[\"afterToolCall\"];\n\tprivate _externalToolExecution?: (model: Model<any>) => boolean;\n\n\tconstructor(opts: AgentOptions = {}) {\n\t\tthis._state = { ...this._state, ...opts.initialState };\n\t\tthis.convertToLlm = opts.convertToLlm || defaultConvertToLlm;\n\t\tthis.transformContext = opts.transformContext;\n\t\tthis.steeringMode = opts.steeringMode || \"one-at-a-time\";\n\t\tthis.followUpMode = opts.followUpMode || \"one-at-a-time\";\n\t\tthis.streamFn = opts.streamFn || streamSimple;\n\t\tthis._sessionId = opts.sessionId;\n\t\tthis.getApiKey = opts.getApiKey;\n\t\tthis._onPayload = opts.onPayload;\n\t\tthis._thinkingBudgets = opts.thinkingBudgets;\n\t\tthis._transport = opts.transport ?? \"sse\";\n\t\tthis._maxRetryDelayMs = opts.maxRetryDelayMs;\n\t\tthis._externalToolExecution = opts.externalToolExecution;\n\t}\n\n\t/**\n\t * Get the current session ID used for provider caching.\n\t */\n\tget sessionId(): string | undefined {\n\t\treturn this._sessionId;\n\t}\n\n\t/**\n\t * Set the session ID for provider caching.\n\t * Call this when switching sessions (new session, branch, resume).\n\t */\n\tset sessionId(value: string | undefined) {\n\t\tthis._sessionId = value;\n\t}\n\n\t/**\n\t * Get the current thinking budgets.\n\t */\n\tget thinkingBudgets(): ThinkingBudgets | undefined {\n\t\treturn this._thinkingBudgets;\n\t}\n\n\t/**\n\t * Set custom thinking budgets for token-based providers.\n\t */\n\tset thinkingBudgets(value: ThinkingBudgets | undefined) {\n\t\tthis._thinkingBudgets = value;\n\t}\n\n\t/**\n\t * Get the current preferred transport.\n\t */\n\tget transport(): Transport {\n\t\treturn this._transport;\n\t}\n\n\t/**\n\t * Set the preferred transport.\n\t */\n\tsetTransport(value: Transport) {\n\t\tthis._transport = value;\n\t}\n\n\t/**\n\t * Get the current max retry delay in milliseconds.\n\t */\n\tget maxRetryDelayMs(): number | undefined {\n\t\treturn this._maxRetryDelayMs;\n\t}\n\n\t/**\n\t * Set the maximum delay to wait for server-requested retries.\n\t * Set to 0 to disable the cap.\n\t */\n\tset maxRetryDelayMs(value: number | undefined) {\n\t\tthis._maxRetryDelayMs = value;\n\t}\n\n\t/**\n\t * Install a hook called before each tool executes, after argument validation.\n\t * Return `{ block: true }` to prevent execution.\n\t */\n\tsetBeforeToolCall(fn: AgentLoopConfig[\"beforeToolCall\"]): void {\n\t\tthis._beforeToolCall = fn;\n\t}\n\n\t/**\n\t * Install a hook called after each tool executes, before results are emitted.\n\t * Return field overrides for content/details/isError.\n\t */\n\tsetAfterToolCall(fn: AgentLoopConfig[\"afterToolCall\"]): void {\n\t\tthis._afterToolCall = fn;\n\t}\n\n\tget state(): AgentState {\n\t\treturn this._state;\n\t}\n\n\tsubscribe(fn: (e: AgentEvent) => void): () => void {\n\t\tthis.listeners.add(fn);\n\t\treturn () => this.listeners.delete(fn);\n\t}\n\n\t// State mutators\n\tsetSystemPrompt(v: string) {\n\t\tthis._state.systemPrompt = v;\n\t}\n\n\tsetModel(m: Model<any>) {\n\t\tthis._state.model = m;\n\t}\n\n\tsetThinkingLevel(l: ThinkingLevel) {\n\t\tthis._state.thinkingLevel = l;\n\t}\n\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\") {\n\t\tthis.steeringMode = mode;\n\t}\n\n\tgetSteeringMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.steeringMode;\n\t}\n\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\") {\n\t\tthis.followUpMode = mode;\n\t}\n\n\tgetFollowUpMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.followUpMode;\n\t}\n\n\tsetTools(t: AgentTool<any>[]) {\n\t\t// Mutate in-place so any AgentContext.tools reference captured by the\n\t\t// running agent loop stays live and immediately sees the new tool set.\n\t\t// This allows tool_enable to take effect within the same turn.\n\t\tthis._state.tools.splice(0, this._state.tools.length, ...t);\n\t}\n\n\treplaceMessages(ms: AgentMessage[]) {\n\t\tthis._state.messages = ms.slice();\n\t}\n\n\tappendMessage(m: AgentMessage) {\n\t\tthis._state.messages = [...this._state.messages, m];\n\t}\n\n\t/**\n\t * Queue a steering message to interrupt the agent mid-run.\n\t * Delivered after current tool execution, skips remaining tools.\n\t */\n\tsteer(m: AgentMessage, origin: \"user\" | \"system\" = \"system\") {\n\t\tthis.steeringQueue.push({ message: m, origin });\n\t}\n\n\t/**\n\t * Queue a follow-up message to be processed after the agent finishes.\n\t * Delivered only when agent has no more tool calls or steering messages.\n\t */\n\tfollowUp(m: AgentMessage, origin: \"user\" | \"system\" = \"system\") {\n\t\tthis.followUpQueue.push({ message: m, origin });\n\t}\n\n\tclearSteeringQueue() {\n\t\tthis.steeringQueue = [];\n\t}\n\n\tclearFollowUpQueue() {\n\t\tthis.followUpQueue = [];\n\t}\n\n\tclearAllQueues() {\n\t\tthis.steeringQueue = [];\n\t\tthis.followUpQueue = [];\n\t}\n\n\t/**\n\t * Drain user-origin messages from queues, leaving system messages in place.\n\t * Used during abort to preserve messages the user explicitly typed.\n\t */\n\tdrainUserMessages(): { steering: AgentMessage[]; followUp: AgentMessage[] } {\n\t\tconst userSteering = this.steeringQueue.filter((e) => e.origin === \"user\").map((e) => e.message);\n\t\tconst userFollowUp = this.followUpQueue.filter((e) => e.origin === \"user\").map((e) => e.message);\n\t\tthis.steeringQueue = this.steeringQueue.filter((e) => e.origin !== \"user\");\n\t\tthis.followUpQueue = this.followUpQueue.filter((e) => e.origin !== \"user\");\n\t\treturn { steering: userSteering, followUp: userFollowUp };\n\t}\n\n\thasQueuedMessages(): boolean {\n\t\treturn this.steeringQueue.length > 0 || this.followUpQueue.length > 0;\n\t}\n\n\tprivate dequeueSteeringMessages(): AgentMessage[] {\n\t\tif (this.steeringMode === \"one-at-a-time\") {\n\t\t\tif (this.steeringQueue.length > 0) {\n\t\t\t\tconst first = this.steeringQueue[0];\n\t\t\t\tthis.steeringQueue = this.steeringQueue.slice(1);\n\t\t\t\treturn [first.message];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\n\t\tconst steering = this.steeringQueue.map((e) => e.message);\n\t\tthis.steeringQueue = [];\n\t\treturn steering;\n\t}\n\n\tprivate dequeueFollowUpMessages(): AgentMessage[] {\n\t\tif (this.followUpMode === \"one-at-a-time\") {\n\t\t\tif (this.followUpQueue.length > 0) {\n\t\t\t\tconst first = this.followUpQueue[0];\n\t\t\t\tthis.followUpQueue = this.followUpQueue.slice(1);\n\t\t\t\treturn [first.message];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\n\t\tconst followUp = this.followUpQueue.map((e) => e.message);\n\t\tthis.followUpQueue = [];\n\t\treturn followUp;\n\t}\n\n\tclearMessages() {\n\t\tthis._state.messages = [];\n\t}\n\n\tabort() {\n\t\tthis.abortController?.abort();\n\t}\n\n\twaitForIdle(): Promise<void> {\n\t\treturn this.runningPrompt ?? Promise.resolve();\n\t}\n\n\treset() {\n\t\tthis._state.messages = [];\n\t\tthis._state.isStreaming = false;\n\t\tthis._state.streamMessage = null;\n\t\tthis._state.pendingToolCalls = new Set<string>();\n\t\tthis._state.error = undefined;\n\t\tthis.steeringQueue = [];\n\t\tthis.followUpQueue = [];\n\t}\n\n\t/** Send a prompt with an AgentMessage */\n\tasync prompt(message: AgentMessage | AgentMessage[]): Promise<void>;\n\tasync prompt(input: string, images?: ImageContent[]): Promise<void>;\n\tasync prompt(input: string | AgentMessage | AgentMessage[], images?: ImageContent[]) {\n\t\tif (this._state.isStreaming) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Agent is already processing a prompt. Use steer() or followUp() to queue messages, or wait for completion.\",\n\t\t\t);\n\t\t}\n\n\t\tconst model = this._state.model;\n\t\tif (!model) throw new Error(\"No model configured\");\n\n\t\tlet msgs: AgentMessage[];\n\n\t\tif (Array.isArray(input)) {\n\t\t\tmsgs = input;\n\t\t} else if (typeof input === \"string\") {\n\t\t\tconst content: Array<TextContent | ImageContent> = [{ type: \"text\", text: input }];\n\t\t\tif (images && images.length > 0) {\n\t\t\t\tcontent.push(...images);\n\t\t\t}\n\t\t\tmsgs = [\n\t\t\t\t{\n\t\t\t\t\trole: \"user\",\n\t\t\t\t\tcontent,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t},\n\t\t\t];\n\t\t} else {\n\t\t\tmsgs = [input];\n\t\t}\n\n\t\tawait this._runLoop(msgs);\n\t}\n\n\t/**\n\t * Continue from current context (used for retries and resuming queued messages).\n\t */\n\tasync continue() {\n\t\tif (this._state.isStreaming) {\n\t\t\tthrow new Error(\"Agent is already processing. Wait for completion before continuing.\");\n\t\t}\n\n\t\tconst messages = this._state.messages;\n\t\tif (messages.length === 0) {\n\t\t\tthrow new Error(\"No messages to continue from\");\n\t\t}\n\t\tif (messages[messages.length - 1].role === \"assistant\") {\n\t\t\tconst queuedSteering = this.dequeueSteeringMessages();\n\t\t\tif (queuedSteering.length > 0) {\n\t\t\t\tawait this._runLoop(queuedSteering, { skipInitialSteeringPoll: true });\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst queuedFollowUp = this.dequeueFollowUpMessages();\n\t\t\tif (queuedFollowUp.length > 0) {\n\t\t\t\tawait this._runLoop(queuedFollowUp);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrow new Error(\"Cannot continue from message role: assistant\");\n\t\t}\n\n\t\tawait this._runLoop(undefined);\n\t}\n\n\t/**\n\t * Run the agent loop.\n\t * If messages are provided, starts a new conversation turn with those messages.\n\t * Otherwise, continues from existing context.\n\t */\n\tprivate async _runLoop(messages?: AgentMessage[], options?: { skipInitialSteeringPoll?: boolean }) {\n\t\tconst model = this._state.model;\n\t\tif (!model) throw new Error(\"No model configured\");\n\n\t\tthis._state.activeInferenceModel = model;\n\n\t\tthis.runningPrompt = new Promise<void>((resolve) => {\n\t\t\tthis.resolveRunningPrompt = resolve;\n\t\t});\n\n\t\tthis.abortController = new AbortController();\n\t\tthis._state.isStreaming = true;\n\t\tthis._state.streamMessage = null;\n\t\tthis._state.error = undefined;\n\n\t\tconst reasoning = this._state.thinkingLevel === \"off\" ? undefined : this._state.thinkingLevel;\n\n\t\tconst self = this;\n\t\tconst context: AgentContext = {\n\t\t\tsystemPrompt: this._state.systemPrompt,\n\t\t\tmessages: this._state.messages.slice(),\n\t\t\tget tools() {\n\t\t\t\treturn self._state.tools;\n\t\t\t},\n\t\t};\n\n\t\tlet skipInitialSteeringPoll = options?.skipInitialSteeringPoll === true;\n\n\t\tconst config: AgentLoopConfig = {\n\t\t\tmodel,\n\t\t\treasoning,\n\t\t\tsessionId: this._sessionId,\n\t\t\tonPayload: this._onPayload,\n\t\t\ttransport: this._transport,\n\t\t\tthinkingBudgets: this._thinkingBudgets,\n\t\t\tmaxRetryDelayMs: this._maxRetryDelayMs,\n\t\t\tconvertToLlm: this.convertToLlm,\n\t\t\ttransformContext: this.transformContext,\n\t\t\tgetApiKey: this.getApiKey,\n\t\t\tgetSteeringMessages: async () => {\n\t\t\t\tif (skipInitialSteeringPoll) {\n\t\t\t\t\tskipInitialSteeringPoll = false;\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn this.dequeueSteeringMessages();\n\t\t\t},\n\t\t\tgetFollowUpMessages: async () => this.dequeueFollowUpMessages(),\n\t\t\tbeforeToolCall: this._beforeToolCall,\n\t\t\tafterToolCall: this._afterToolCall,\n\t\t\texternalToolExecution: this._externalToolExecution?.(model) ?? false,\n\t\t};\n\n\t\tlet partial: AgentMessage | null = null;\n\n\t\ttry {\n\t\t\tconst stream = messages\n\t\t\t\t? agentLoop(messages, context, config, this.abortController.signal, this.streamFn)\n\t\t\t\t: agentLoopContinue(context, config, this.abortController.signal, this.streamFn);\n\n\t\t\tfor await (const event of stream) {\n\t\t\t\t// Update internal state based on events\n\t\t\t\tswitch (event.type) {\n\t\t\t\t\tcase \"message_start\":\n\t\t\t\t\tcase \"message_update\":\n\t\t\t\t\t\tpartial = event.message;\n\t\t\t\t\t\tthis._state.streamMessage = event.message;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"message_end\":\n\t\t\t\t\t\tpartial = null;\n\t\t\t\t\t\tthis._state.streamMessage = null;\n\t\t\t\t\t\tthis.appendMessage(event.message);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"tool_execution_start\":\n\t\t\t\t\t\tthis._updatePendingToolCalls(\"add\", event.toolCallId);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"tool_execution_end\":\n\t\t\t\t\t\tthis._updatePendingToolCalls(\"delete\", event.toolCallId);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"turn_end\":\n\t\t\t\t\t\tif (event.message.role === \"assistant\" && (event.message as any).errorMessage) {\n\t\t\t\t\t\t\tthis._state.error = (event.message as any).errorMessage;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"agent_end\":\n\t\t\t\t\t\tthis._state.isStreaming = false;\n\t\t\t\t\t\tthis._state.streamMessage = null;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Emit to listeners\n\t\t\t\tthis.emit(event);\n\t\t\t}\n\n\t\t\t// Handle any remaining partial message\n\t\t\tif (partial && partial.role === \"assistant\" && partial.content.length > 0) {\n\t\t\t\tconst onlyEmpty = !partial.content.some(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\t(c.type === \"thinking\" && c.thinking.trim().length > 0) ||\n\t\t\t\t\t\t(c.type === \"text\" && c.text.trim().length > 0) ||\n\t\t\t\t\t\t(c.type === \"toolCall\" && c.name.trim().length > 0),\n\t\t\t\t);\n\t\t\t\tif (!onlyEmpty) {\n\t\t\t\t\tthis.appendMessage(partial);\n\t\t\t\t} else {\n\t\t\t\t\tif (this.abortController?.signal.aborted) {\n\t\t\t\t\t\tthrow new Error(\"Request was aborted\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\tconst errorMsg: AgentMessage = {\n\t\t\t\trole: \"assistant\",\n\t\t\t\tcontent: [{ type: \"text\", text: \"\" }],\n\t\t\t\tapi: model.api,\n\t\t\t\tprovider: model.provider,\n\t\t\t\tmodel: model.id,\n\t\t\t\tusage: ZERO_USAGE,\n\t\t\t\tstopReason: this.abortController?.signal.aborted ? \"aborted\" : \"error\",\n\t\t\t\terrorMessage: err?.message || String(err),\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t} as AgentMessage;\n\n\t\t\tthis.appendMessage(errorMsg);\n\t\t\tthis._state.error = err?.message || String(err);\n\t\t\tthis.emit({ type: \"agent_end\", messages: [errorMsg] });\n\t\t} finally {\n\t\t\tthis._state.isStreaming = false;\n\t\t\tthis._state.streamMessage = null;\n\t\t\tthis._state.pendingToolCalls = new Set<string>();\n\t\t\tthis._state.activeInferenceModel = undefined;\n\t\t\tthis.abortController = undefined;\n\t\t\tthis.resolveRunningPrompt?.();\n\t\t\tthis.runningPrompt = undefined;\n\t\t\tthis.resolveRunningPrompt = undefined;\n\t\t}\n\t}\n\n\tprivate _updatePendingToolCalls(action: \"add\" | \"delete\", id: string): void {\n\t\tconst s = new Set(this._state.pendingToolCalls);\n\t\ts[action](id);\n\t\tthis._state.pendingToolCalls = s;\n\t}\n\n\tprivate emit(e: AgentEvent) {\n\t\tfor (const listener of this.listeners) {\n\t\t\tlistener(e);\n\t\t}\n\t}\n}\n"]}
@@ -282,7 +282,10 @@ export class Agent {
282
282
  }
283
283
 
284
284
  setTools(t: AgentTool<any>[]) {
285
- this._state.tools = t;
285
+ // Mutate in-place so any AgentContext.tools reference captured by the
286
+ // running agent loop stays live and immediately sees the new tool set.
287
+ // This allows tool_enable to take effect within the same turn.
288
+ this._state.tools.splice(0, this._state.tools.length, ...t);
286
289
  }
287
290
 
288
291
  replaceMessages(ms: AgentMessage[]) {
@@ -479,10 +482,13 @@ export class Agent {
479
482
 
480
483
  const reasoning = this._state.thinkingLevel === "off" ? undefined : this._state.thinkingLevel;
481
484
 
485
+ const self = this;
482
486
  const context: AgentContext = {
483
487
  systemPrompt: this._state.systemPrompt,
484
488
  messages: this._state.messages.slice(),
485
- tools: this._state.tools,
489
+ get tools() {
490
+ return self._state.tools;
491
+ },
486
492
  };
487
493
 
488
494
  let skipInitialSteeringPoll = options?.skipInitialSteeringPoll === true;