@code-yeongyu/senpi 2026.8.14 → 2026.8.17

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 (1060) hide show
  1. package/CHANGELOG.md +128 -0
  2. package/README.md +1 -0
  3. package/dist/bun/cli.js +1 -0
  4. package/dist/bun/cli.js.map +1 -1
  5. package/dist/bun/register-cursor-agent.d.ts +2 -0
  6. package/dist/bun/register-cursor-agent.d.ts.map +1 -0
  7. package/dist/bun/register-cursor-agent.js +4 -0
  8. package/dist/bun/register-cursor-agent.js.map +1 -0
  9. package/dist/cli/args.d.ts +1 -0
  10. package/dist/cli/args.d.ts.map +1 -1
  11. package/dist/cli/args.js +14 -0
  12. package/dist/cli/args.js.map +1 -1
  13. package/dist/cli/auth-command.d.ts.map +1 -1
  14. package/dist/cli/auth-command.js +5 -4
  15. package/dist/cli/auth-command.js.map +1 -1
  16. package/dist/core/agent-session-services.js +2 -2
  17. package/dist/core/agent-session-services.js.map +1 -1
  18. package/dist/core/agent-session.d.ts +127 -13
  19. package/dist/core/agent-session.d.ts.map +1 -1
  20. package/dist/core/agent-session.js +420 -82
  21. package/dist/core/agent-session.js.map +1 -1
  22. package/dist/core/auth-storage.d.ts.map +1 -1
  23. package/dist/core/auth-storage.js +19 -8
  24. package/dist/core/auth-storage.js.map +1 -1
  25. package/dist/core/cursor-exec-bridge-session.d.ts +11 -0
  26. package/dist/core/cursor-exec-bridge-session.d.ts.map +1 -0
  27. package/dist/core/cursor-exec-bridge-session.js +17 -0
  28. package/dist/core/cursor-exec-bridge-session.js.map +1 -0
  29. package/dist/core/cursor-exec-bridge.d.ts +52 -0
  30. package/dist/core/cursor-exec-bridge.d.ts.map +1 -0
  31. package/dist/core/cursor-exec-bridge.js +196 -0
  32. package/dist/core/cursor-exec-bridge.js.map +1 -0
  33. package/dist/core/experimental.d.ts +4 -0
  34. package/dist/core/experimental.d.ts.map +1 -1
  35. package/dist/core/experimental.js +4 -0
  36. package/dist/core/experimental.js.map +1 -1
  37. package/dist/core/export-html/template.js +31 -9
  38. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-environment.d.ts +4 -0
  39. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-environment.d.ts.map +1 -0
  40. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-environment.js +30 -0
  41. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-environment.js.map +1 -0
  42. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-lane.d.ts +2 -0
  43. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-lane.d.ts.map +1 -1
  44. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-lane.js +13 -47
  45. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-lane.js.map +1 -1
  46. package/dist/core/extensions/builtin/claude-sdk-oauth/availability.d.ts +18 -1
  47. package/dist/core/extensions/builtin/claude-sdk-oauth/availability.d.ts.map +1 -1
  48. package/dist/core/extensions/builtin/claude-sdk-oauth/availability.js +64 -2
  49. package/dist/core/extensions/builtin/claude-sdk-oauth/availability.js.map +1 -1
  50. package/dist/core/extensions/builtin/claude-sdk-oauth/config-dir-credentials.d.ts +3 -0
  51. package/dist/core/extensions/builtin/claude-sdk-oauth/config-dir-credentials.d.ts.map +1 -0
  52. package/dist/core/extensions/builtin/claude-sdk-oauth/config-dir-credentials.js +27 -0
  53. package/dist/core/extensions/builtin/claude-sdk-oauth/config-dir-credentials.js.map +1 -0
  54. package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.d.ts +15 -2
  55. package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.d.ts.map +1 -1
  56. package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.js +45 -11
  57. package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.js.map +1 -1
  58. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js +1 -0
  59. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js.map +1 -1
  60. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts.map +1 -1
  61. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js +17 -1
  62. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js.map +1 -1
  63. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.d.ts.map +1 -1
  64. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js +1 -0
  65. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js.map +1 -1
  66. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  67. package/dist/core/extensions/builtin/compaction/index.js +48 -6
  68. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  69. package/dist/core/extensions/builtin/compaction/log.d.ts +1 -1
  70. package/dist/core/extensions/builtin/compaction/log.d.ts.map +1 -1
  71. package/dist/core/extensions/builtin/compaction/log.js +2 -0
  72. package/dist/core/extensions/builtin/compaction/log.js.map +1 -1
  73. package/dist/core/extensions/builtin/compaction/overflow-retry.d.ts.map +1 -1
  74. package/dist/core/extensions/builtin/compaction/overflow-retry.js +38 -4
  75. package/dist/core/extensions/builtin/compaction/overflow-retry.js.map +1 -1
  76. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  77. package/dist/core/extensions/builtin/compaction/speculative.js +2 -1
  78. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  79. package/dist/core/extensions/builtin/compaction/summarization-turn-order.d.ts +33 -0
  80. package/dist/core/extensions/builtin/compaction/summarization-turn-order.d.ts.map +1 -0
  81. package/dist/core/extensions/builtin/compaction/summarization-turn-order.js +67 -0
  82. package/dist/core/extensions/builtin/compaction/summarization-turn-order.js.map +1 -0
  83. package/dist/core/extensions/builtin/config-reload/index.d.ts.map +1 -1
  84. package/dist/core/extensions/builtin/config-reload/index.js +31 -8
  85. package/dist/core/extensions/builtin/config-reload/index.js.map +1 -1
  86. package/dist/core/extensions/builtin/config-reload/routine-settings.d.ts.map +1 -1
  87. package/dist/core/extensions/builtin/config-reload/routine-settings.js +11 -12
  88. package/dist/core/extensions/builtin/config-reload/routine-settings.js.map +1 -1
  89. package/dist/core/extensions/builtin/cursor-cli-oauth/account-command.d.ts +28 -0
  90. package/dist/core/extensions/builtin/cursor-cli-oauth/account-command.d.ts.map +1 -0
  91. package/dist/core/extensions/builtin/cursor-cli-oauth/account-command.js +278 -0
  92. package/dist/core/extensions/builtin/cursor-cli-oauth/account-command.js.map +1 -0
  93. package/dist/core/extensions/builtin/cursor-cli-oauth/accounts.d.ts +38 -0
  94. package/dist/core/extensions/builtin/cursor-cli-oauth/accounts.d.ts.map +1 -0
  95. package/dist/core/extensions/builtin/cursor-cli-oauth/accounts.js +75 -0
  96. package/dist/core/extensions/builtin/cursor-cli-oauth/accounts.js.map +1 -0
  97. package/dist/core/extensions/builtin/cursor-cli-oauth/affinity.d.ts +24 -0
  98. package/dist/core/extensions/builtin/cursor-cli-oauth/affinity.d.ts.map +1 -0
  99. package/dist/core/extensions/builtin/cursor-cli-oauth/affinity.js +64 -0
  100. package/dist/core/extensions/builtin/cursor-cli-oauth/affinity.js.map +1 -0
  101. package/dist/core/extensions/builtin/cursor-cli-oauth/diagnostics.d.ts +139 -0
  102. package/dist/core/extensions/builtin/cursor-cli-oauth/diagnostics.d.ts.map +1 -0
  103. package/dist/core/extensions/builtin/cursor-cli-oauth/diagnostics.js +362 -0
  104. package/dist/core/extensions/builtin/cursor-cli-oauth/diagnostics.js.map +1 -0
  105. package/dist/core/extensions/builtin/cursor-cli-oauth/errors.d.ts +19 -0
  106. package/dist/core/extensions/builtin/cursor-cli-oauth/errors.d.ts.map +1 -0
  107. package/dist/core/extensions/builtin/cursor-cli-oauth/errors.js +122 -0
  108. package/dist/core/extensions/builtin/cursor-cli-oauth/errors.js.map +1 -0
  109. package/dist/core/extensions/builtin/cursor-cli-oauth/executable.d.ts +30 -0
  110. package/dist/core/extensions/builtin/cursor-cli-oauth/executable.d.ts.map +1 -0
  111. package/dist/core/extensions/builtin/cursor-cli-oauth/executable.js +117 -0
  112. package/dist/core/extensions/builtin/cursor-cli-oauth/executable.js.map +1 -0
  113. package/dist/core/extensions/builtin/cursor-cli-oauth/failover.d.ts +39 -0
  114. package/dist/core/extensions/builtin/cursor-cli-oauth/failover.d.ts.map +1 -0
  115. package/dist/core/extensions/builtin/cursor-cli-oauth/failover.js +155 -0
  116. package/dist/core/extensions/builtin/cursor-cli-oauth/failover.js.map +1 -0
  117. package/dist/core/extensions/builtin/cursor-cli-oauth/guardrails.d.ts +89 -0
  118. package/dist/core/extensions/builtin/cursor-cli-oauth/guardrails.d.ts.map +1 -0
  119. package/dist/core/extensions/builtin/cursor-cli-oauth/guardrails.js +147 -0
  120. package/dist/core/extensions/builtin/cursor-cli-oauth/guardrails.js.map +1 -0
  121. package/dist/core/extensions/builtin/cursor-cli-oauth/home-store.d.ts +20 -0
  122. package/dist/core/extensions/builtin/cursor-cli-oauth/home-store.d.ts.map +1 -0
  123. package/dist/core/extensions/builtin/cursor-cli-oauth/home-store.js +99 -0
  124. package/dist/core/extensions/builtin/cursor-cli-oauth/home-store.js.map +1 -0
  125. package/dist/core/extensions/builtin/cursor-cli-oauth/index.d.ts +25 -0
  126. package/dist/core/extensions/builtin/cursor-cli-oauth/index.d.ts.map +1 -0
  127. package/dist/core/extensions/builtin/cursor-cli-oauth/index.js +67 -0
  128. package/dist/core/extensions/builtin/cursor-cli-oauth/index.js.map +1 -0
  129. package/dist/core/extensions/builtin/cursor-cli-oauth/models.d.ts +27 -0
  130. package/dist/core/extensions/builtin/cursor-cli-oauth/models.d.ts.map +1 -0
  131. package/dist/core/extensions/builtin/cursor-cli-oauth/models.js +242 -0
  132. package/dist/core/extensions/builtin/cursor-cli-oauth/models.js.map +1 -0
  133. package/dist/core/extensions/builtin/cursor-cli-oauth/oauth-login.d.ts +73 -0
  134. package/dist/core/extensions/builtin/cursor-cli-oauth/oauth-login.d.ts.map +1 -0
  135. package/dist/core/extensions/builtin/cursor-cli-oauth/oauth-login.js +330 -0
  136. package/dist/core/extensions/builtin/cursor-cli-oauth/oauth-login.js.map +1 -0
  137. package/dist/core/extensions/builtin/cursor-cli-oauth/session-router.d.ts +94 -0
  138. package/dist/core/extensions/builtin/cursor-cli-oauth/session-router.d.ts.map +1 -0
  139. package/dist/core/extensions/builtin/cursor-cli-oauth/session-router.js +248 -0
  140. package/dist/core/extensions/builtin/cursor-cli-oauth/session-router.js.map +1 -0
  141. package/dist/core/extensions/builtin/cursor-cli-oauth/settings.d.ts +35 -0
  142. package/dist/core/extensions/builtin/cursor-cli-oauth/settings.d.ts.map +1 -0
  143. package/dist/core/extensions/builtin/cursor-cli-oauth/settings.js +186 -0
  144. package/dist/core/extensions/builtin/cursor-cli-oauth/settings.js.map +1 -0
  145. package/dist/core/extensions/builtin/cursor-cli-oauth/spawn-args.d.ts +11 -0
  146. package/dist/core/extensions/builtin/cursor-cli-oauth/spawn-args.d.ts.map +1 -0
  147. package/dist/core/extensions/builtin/cursor-cli-oauth/spawn-args.js +17 -0
  148. package/dist/core/extensions/builtin/cursor-cli-oauth/spawn-args.js.map +1 -0
  149. package/dist/core/extensions/builtin/cursor-cli-oauth/stream-parser.d.ts +104 -0
  150. package/dist/core/extensions/builtin/cursor-cli-oauth/stream-parser.d.ts.map +1 -0
  151. package/dist/core/extensions/builtin/cursor-cli-oauth/stream-parser.js +301 -0
  152. package/dist/core/extensions/builtin/cursor-cli-oauth/stream-parser.js.map +1 -0
  153. package/dist/core/extensions/builtin/cursor-cli-oauth/stream.d.ts +26 -0
  154. package/dist/core/extensions/builtin/cursor-cli-oauth/stream.d.ts.map +1 -0
  155. package/dist/core/extensions/builtin/cursor-cli-oauth/stream.js +587 -0
  156. package/dist/core/extensions/builtin/cursor-cli-oauth/stream.js.map +1 -0
  157. package/dist/core/extensions/builtin/cursor-cli-oauth/transport.d.ts +43 -0
  158. package/dist/core/extensions/builtin/cursor-cli-oauth/transport.d.ts.map +1 -0
  159. package/dist/core/extensions/builtin/cursor-cli-oauth/transport.js +196 -0
  160. package/dist/core/extensions/builtin/cursor-cli-oauth/transport.js.map +1 -0
  161. package/dist/core/extensions/builtin/goal/channel-state-subscriptions.d.ts +9 -0
  162. package/dist/core/extensions/builtin/goal/channel-state-subscriptions.d.ts.map +1 -0
  163. package/dist/core/extensions/builtin/goal/channel-state-subscriptions.js +18 -0
  164. package/dist/core/extensions/builtin/goal/channel-state-subscriptions.js.map +1 -0
  165. package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts.map +1 -1
  166. package/dist/core/extensions/builtin/goal/monitor-continuation.js +10 -9
  167. package/dist/core/extensions/builtin/goal/monitor-continuation.js.map +1 -1
  168. package/dist/core/extensions/builtin/goal/terminal-provider-error.d.ts.map +1 -1
  169. package/dist/core/extensions/builtin/goal/terminal-provider-error.js +16 -0
  170. package/dist/core/extensions/builtin/goal/terminal-provider-error.js.map +1 -1
  171. package/dist/core/extensions/builtin/index.d.ts.map +1 -1
  172. package/dist/core/extensions/builtin/index.js +9 -2
  173. package/dist/core/extensions/builtin/index.js.map +1 -1
  174. package/dist/core/extensions/builtin/loop-guard/detectors.d.ts.map +1 -1
  175. package/dist/core/extensions/builtin/loop-guard/detectors.js +21 -3
  176. package/dist/core/extensions/builtin/loop-guard/detectors.js.map +1 -1
  177. package/dist/core/extensions/builtin/loop-guard/escalation.d.ts +24 -0
  178. package/dist/core/extensions/builtin/loop-guard/escalation.d.ts.map +1 -0
  179. package/dist/core/extensions/builtin/loop-guard/escalation.js +77 -0
  180. package/dist/core/extensions/builtin/loop-guard/escalation.js.map +1 -0
  181. package/dist/core/extensions/builtin/loop-guard/index.d.ts.map +1 -1
  182. package/dist/core/extensions/builtin/loop-guard/index.js +98 -3
  183. package/dist/core/extensions/builtin/loop-guard/index.js.map +1 -1
  184. package/dist/core/extensions/builtin/loop-guard/notice.d.ts +9 -0
  185. package/dist/core/extensions/builtin/loop-guard/notice.d.ts.map +1 -1
  186. package/dist/core/extensions/builtin/loop-guard/notice.js +17 -0
  187. package/dist/core/extensions/builtin/loop-guard/notice.js.map +1 -1
  188. package/dist/core/extensions/builtin/loop-guard/policy.d.ts +4 -0
  189. package/dist/core/extensions/builtin/loop-guard/policy.d.ts.map +1 -1
  190. package/dist/core/extensions/builtin/loop-guard/policy.js +4 -0
  191. package/dist/core/extensions/builtin/loop-guard/policy.js.map +1 -1
  192. package/dist/core/extensions/builtin/loop-guard/renderer.d.ts +2 -0
  193. package/dist/core/extensions/builtin/loop-guard/renderer.d.ts.map +1 -1
  194. package/dist/core/extensions/builtin/loop-guard/renderer.js +11 -0
  195. package/dist/core/extensions/builtin/loop-guard/renderer.js.map +1 -1
  196. package/dist/core/extensions/builtin/loop-guard/tracker.d.ts +1 -1
  197. package/dist/core/extensions/builtin/loop-guard/tracker.d.ts.map +1 -1
  198. package/dist/core/extensions/builtin/loop-guard/tracker.js +3 -1
  199. package/dist/core/extensions/builtin/loop-guard/tracker.js.map +1 -1
  200. package/dist/core/extensions/builtin/mcp/process-tree.js +6 -1
  201. package/dist/core/extensions/builtin/mcp/process-tree.js.map +1 -1
  202. package/dist/core/extensions/builtin/monitor-state-event.d.ts +6 -0
  203. package/dist/core/extensions/builtin/monitor-state-event.d.ts.map +1 -1
  204. package/dist/core/extensions/builtin/monitor-state-event.js +10 -0
  205. package/dist/core/extensions/builtin/monitor-state-event.js.map +1 -1
  206. package/dist/core/extensions/builtin/prompt-preset/glm-5-3.d.ts +3 -0
  207. package/dist/core/extensions/builtin/prompt-preset/glm-5-3.d.ts.map +1 -0
  208. package/dist/core/extensions/builtin/prompt-preset/glm-5-3.js +14 -0
  209. package/dist/core/extensions/builtin/prompt-preset/glm-5-3.js.map +1 -0
  210. package/dist/core/extensions/builtin/prompt-preset/grok-4.6.d.ts +3 -0
  211. package/dist/core/extensions/builtin/prompt-preset/grok-4.6.d.ts.map +1 -0
  212. package/dist/core/extensions/builtin/prompt-preset/grok-4.6.js +91 -0
  213. package/dist/core/extensions/builtin/prompt-preset/grok-4.6.js.map +1 -0
  214. package/dist/core/extensions/builtin/prompt-preset/index.d.ts.map +1 -1
  215. package/dist/core/extensions/builtin/prompt-preset/index.js +22 -2
  216. package/dist/core/extensions/builtin/prompt-preset/index.js.map +1 -1
  217. package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
  218. package/dist/core/extensions/builtin/prompt-preset/presets.js +25 -0
  219. package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
  220. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
  221. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
  222. package/dist/core/extensions/builtin/prompt-preset/settings.js +2 -0
  223. package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
  224. package/dist/core/extensions/builtin/reasoning/index.d.ts +3 -0
  225. package/dist/core/extensions/builtin/reasoning/index.d.ts.map +1 -0
  226. package/dist/core/extensions/builtin/reasoning/index.js +211 -0
  227. package/dist/core/extensions/builtin/reasoning/index.js.map +1 -0
  228. package/dist/core/extensions/builtin/service-tier.d.ts +44 -1
  229. package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
  230. package/dist/core/extensions/builtin/service-tier.js +176 -24
  231. package/dist/core/extensions/builtin/service-tier.js.map +1 -1
  232. package/dist/core/extensions/runner.d.ts.map +1 -1
  233. package/dist/core/extensions/runner.js +4 -4
  234. package/dist/core/extensions/runner.js.map +1 -1
  235. package/dist/core/extensions/types.d.ts +12 -0
  236. package/dist/core/extensions/types.d.ts.map +1 -1
  237. package/dist/core/extensions/types.js.map +1 -1
  238. package/dist/core/keybindings.d.ts +24 -0
  239. package/dist/core/keybindings.d.ts.map +1 -1
  240. package/dist/core/lockfile-policy.d.ts +15 -0
  241. package/dist/core/lockfile-policy.d.ts.map +1 -0
  242. package/dist/core/lockfile-policy.js +15 -0
  243. package/dist/core/lockfile-policy.js.map +1 -0
  244. package/dist/core/model-config.d.ts.map +1 -1
  245. package/dist/core/model-config.js +1 -0
  246. package/dist/core/model-config.js.map +1 -1
  247. package/dist/core/model-resolver.d.ts +34 -7
  248. package/dist/core/model-resolver.d.ts.map +1 -1
  249. package/dist/core/model-resolver.js +116 -28
  250. package/dist/core/model-resolver.js.map +1 -1
  251. package/dist/core/model-runtime.d.ts +7 -2
  252. package/dist/core/model-runtime.d.ts.map +1 -1
  253. package/dist/core/model-runtime.js +19 -5
  254. package/dist/core/model-runtime.js.map +1 -1
  255. package/dist/core/prompt-templates.d.ts +5 -0
  256. package/dist/core/prompt-templates.d.ts.map +1 -1
  257. package/dist/core/prompt-templates.js +8 -9
  258. package/dist/core/prompt-templates.js.map +1 -1
  259. package/dist/core/provider-api-key-auth.d.ts.map +1 -1
  260. package/dist/core/provider-api-key-auth.js +45 -2
  261. package/dist/core/provider-api-key-auth.js.map +1 -1
  262. package/dist/core/provider-composer.d.ts +12 -1
  263. package/dist/core/provider-composer.d.ts.map +1 -1
  264. package/dist/core/provider-composer.js.map +1 -1
  265. package/dist/core/provider-display-names.d.ts.map +1 -1
  266. package/dist/core/provider-display-names.js +2 -0
  267. package/dist/core/provider-display-names.js.map +1 -1
  268. package/dist/core/remote-catalog-provider.d.ts +13 -0
  269. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  270. package/dist/core/remote-catalog-provider.js +15 -0
  271. package/dist/core/remote-catalog-provider.js.map +1 -1
  272. package/dist/core/retry-fallback/controller.d.ts +1 -1
  273. package/dist/core/retry-fallback/controller.d.ts.map +1 -1
  274. package/dist/core/retry-fallback/controller.js +5 -3
  275. package/dist/core/retry-fallback/controller.js.map +1 -1
  276. package/dist/core/sdk.d.ts +5 -3
  277. package/dist/core/sdk.d.ts.map +1 -1
  278. package/dist/core/sdk.js +20 -8
  279. package/dist/core/sdk.js.map +1 -1
  280. package/dist/core/session-manager.d.ts.map +1 -1
  281. package/dist/core/session-manager.js +20 -4
  282. package/dist/core/session-manager.js.map +1 -1
  283. package/dist/core/settings-manager.d.ts +50 -1
  284. package/dist/core/settings-manager.d.ts.map +1 -1
  285. package/dist/core/settings-manager.js +258 -15
  286. package/dist/core/settings-manager.js.map +1 -1
  287. package/dist/core/system-prompt.js +1 -1
  288. package/dist/core/system-prompt.js.map +1 -1
  289. package/dist/core/thinking-levels.d.ts +22 -0
  290. package/dist/core/thinking-levels.d.ts.map +1 -1
  291. package/dist/core/thinking-levels.js +29 -0
  292. package/dist/core/thinking-levels.js.map +1 -1
  293. package/dist/core/tools/bash.d.ts.map +1 -1
  294. package/dist/core/tools/bash.js +2 -0
  295. package/dist/core/tools/bash.js.map +1 -1
  296. package/dist/core/tools/edit.d.ts.map +1 -1
  297. package/dist/core/tools/edit.js +2 -0
  298. package/dist/core/tools/edit.js.map +1 -1
  299. package/dist/core/tools/find.js +1 -1
  300. package/dist/core/tools/find.js.map +1 -1
  301. package/dist/core/tools/grep.js +1 -1
  302. package/dist/core/tools/grep.js.map +1 -1
  303. package/dist/core/tools/read.d.ts.map +1 -1
  304. package/dist/core/tools/read.js +2 -0
  305. package/dist/core/tools/read.js.map +1 -1
  306. package/dist/core/tools/write.d.ts.map +1 -1
  307. package/dist/core/tools/write.js +2 -0
  308. package/dist/core/tools/write.js.map +1 -1
  309. package/dist/index.d.ts +1 -1
  310. package/dist/index.d.ts.map +1 -1
  311. package/dist/index.js.map +1 -1
  312. package/dist/main.d.ts.map +1 -1
  313. package/dist/main.js +18 -1
  314. package/dist/main.js.map +1 -1
  315. package/dist/modes/interactive/components/model-favorites.d.ts +2 -1
  316. package/dist/modes/interactive/components/model-favorites.d.ts.map +1 -1
  317. package/dist/modes/interactive/components/model-favorites.js +72 -6
  318. package/dist/modes/interactive/components/model-favorites.js.map +1 -1
  319. package/dist/modes/interactive/components/model-selector.d.ts +5 -1
  320. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  321. package/dist/modes/interactive/components/model-selector.js +10 -6
  322. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  323. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  324. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  325. package/dist/modes/interactive/components/settings-selector.js +10 -0
  326. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  327. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  328. package/dist/modes/interactive/components/tool-execution.js +22 -1
  329. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  330. package/dist/modes/interactive/editor-paste-transfer.d.ts +10 -0
  331. package/dist/modes/interactive/editor-paste-transfer.d.ts.map +1 -1
  332. package/dist/modes/interactive/editor-paste-transfer.js +16 -0
  333. package/dist/modes/interactive/editor-paste-transfer.js.map +1 -1
  334. package/dist/modes/interactive/interactive-mode.d.ts +14 -4
  335. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  336. package/dist/modes/interactive/interactive-mode.js +111 -52
  337. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  338. package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
  339. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
  340. package/dist/modes/interactive/model-catalog-refresh.js +36 -0
  341. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
  342. package/dist/modes/interactive/theme/dark.json +2 -0
  343. package/dist/modes/interactive/theme/grok-day.json +2 -0
  344. package/dist/modes/interactive/theme/grok-night.json +2 -0
  345. package/dist/modes/interactive/theme/light.json +2 -0
  346. package/dist/modes/interactive/theme/theme-controller.d.ts +10 -2
  347. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  348. package/dist/modes/interactive/theme/theme-controller.js +23 -10
  349. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  350. package/dist/modes/interactive/theme/theme-schema.json +9 -1
  351. package/dist/modes/interactive/theme/theme.d.ts +5 -3
  352. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  353. package/dist/modes/interactive/theme/theme.js +12 -2
  354. package/dist/modes/interactive/theme/theme.js.map +1 -1
  355. package/dist/modes/json-event.d.ts +4 -1
  356. package/dist/modes/json-event.d.ts.map +1 -1
  357. package/dist/modes/json-event.js +5 -2
  358. package/dist/modes/json-event.js.map +1 -1
  359. package/dist/modes/rpc/connection-handler.d.ts +10 -0
  360. package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
  361. package/dist/modes/rpc/connection-handler.js +119 -46
  362. package/dist/modes/rpc/connection-handler.js.map +1 -1
  363. package/dist/modes/rpc/jsonl.d.ts +6 -1
  364. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  365. package/dist/modes/rpc/jsonl.js +47 -14
  366. package/dist/modes/rpc/jsonl.js.map +1 -1
  367. package/dist/modes/rpc/multi-session-host.d.ts.map +1 -1
  368. package/dist/modes/rpc/multi-session-host.js +29 -7
  369. package/dist/modes/rpc/multi-session-host.js.map +1 -1
  370. package/dist/modes/rpc/rpc-client.d.ts +26 -1
  371. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  372. package/dist/modes/rpc/rpc-client.js +25 -2
  373. package/dist/modes/rpc/rpc-client.js.map +1 -1
  374. package/dist/modes/rpc/rpc-command-invocation.d.ts +5 -0
  375. package/dist/modes/rpc/rpc-command-invocation.d.ts.map +1 -0
  376. package/dist/modes/rpc/rpc-command-invocation.js +2 -0
  377. package/dist/modes/rpc/rpc-command-invocation.js.map +1 -0
  378. package/dist/modes/rpc/rpc-command-surface.d.ts +49 -0
  379. package/dist/modes/rpc/rpc-command-surface.d.ts.map +1 -0
  380. package/dist/modes/rpc/rpc-command-surface.js +40 -0
  381. package/dist/modes/rpc/rpc-command-surface.js.map +1 -0
  382. package/dist/modes/rpc/rpc-input-validation.d.ts +4 -0
  383. package/dist/modes/rpc/rpc-input-validation.d.ts.map +1 -0
  384. package/dist/modes/rpc/rpc-input-validation.js +20 -0
  385. package/dist/modes/rpc/rpc-input-validation.js.map +1 -0
  386. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  387. package/dist/modes/rpc/rpc-mode.js +12 -1
  388. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  389. package/dist/modes/rpc/rpc-types.d.ts +72 -12
  390. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  391. package/dist/modes/rpc/rpc-types.js.map +1 -1
  392. package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
  393. package/dist/modes/rpc/session-command-router.js +2 -14
  394. package/dist/modes/rpc/session-command-router.js.map +1 -1
  395. package/dist/modes/rpc/session-event-writer.d.ts +29 -10
  396. package/dist/modes/rpc/session-event-writer.d.ts.map +1 -1
  397. package/dist/modes/rpc/session-event-writer.js +229 -50
  398. package/dist/modes/rpc/session-event-writer.js.map +1 -1
  399. package/dist/server/create-harness.d.ts.map +1 -1
  400. package/dist/server/create-harness.js +2 -0
  401. package/dist/server/create-harness.js.map +1 -1
  402. package/dist/utils/shell.d.ts +27 -0
  403. package/dist/utils/shell.d.ts.map +1 -1
  404. package/dist/utils/shell.js +79 -13
  405. package/dist/utils/shell.js.map +1 -1
  406. package/dist/utils/tools-manager.d.ts +10 -1
  407. package/dist/utils/tools-manager.d.ts.map +1 -1
  408. package/dist/utils/tools-manager.js +14 -19
  409. package/dist/utils/tools-manager.js.map +1 -1
  410. package/docs/compaction.md +3 -3
  411. package/docs/custom-provider.md +1 -1
  412. package/docs/environment-variables.md +8 -2
  413. package/docs/extensions.md +4 -0
  414. package/docs/json.md +6 -4
  415. package/docs/keybindings.md +8 -2
  416. package/docs/providers.md +56 -0
  417. package/docs/rpc.md +206 -12
  418. package/docs/sdk.md +9 -0
  419. package/docs/settings.md +93 -1
  420. package/docs/skills.md +14 -3
  421. package/docs/terminal-setup.md +23 -2
  422. package/docs/themes.md +24 -3
  423. package/docs/tui.md +2 -2
  424. package/docs/usage.md +24 -4
  425. package/examples/extensions/subagent/agents.ts +40 -9
  426. package/examples/extensions/subagent/index.ts +26 -3
  427. package/node_modules/@bufbuild/protobuf/README.md +44 -0
  428. package/node_modules/@bufbuild/protobuf/dist/commonjs/clone.d.ts +6 -0
  429. package/node_modules/@bufbuild/protobuf/dist/commonjs/clone.js +66 -0
  430. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/boot.d.ts +1 -0
  431. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/boot.js +18 -0
  432. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/enum.d.ts +10 -0
  433. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/enum.js +31 -0
  434. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/extension.d.ts +9 -0
  435. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/extension.js +28 -0
  436. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/file.d.ts +1 -0
  437. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/file.js +18 -0
  438. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/index.d.ts +10 -0
  439. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/index.js +39 -0
  440. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/message.d.ts +10 -0
  441. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/message.js +24 -0
  442. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/service.d.ts +8 -0
  443. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/service.js +27 -0
  444. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/symbols.d.ts +140 -0
  445. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/symbols.js +43 -0
  446. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/types.d.ts +79 -0
  447. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/types.js +15 -0
  448. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/boot.d.ts +63 -0
  449. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/boot.js +105 -0
  450. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/embed.d.ts +43 -0
  451. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/embed.js +244 -0
  452. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/enum.d.ts +29 -0
  453. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/enum.js +58 -0
  454. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/extension.d.ts +9 -0
  455. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/extension.js +28 -0
  456. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/file.d.ts +7 -0
  457. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/file.js +35 -0
  458. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/index.d.ts +10 -0
  459. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/index.js +39 -0
  460. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/message.d.ts +15 -0
  461. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/message.js +24 -0
  462. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/restore-json-names.d.ts +5 -0
  463. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/restore-json-names.js +29 -0
  464. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/scalar.d.ts +9 -0
  465. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/scalar.js +67 -0
  466. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/service.d.ts +8 -0
  467. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/service.js +27 -0
  468. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/symbols.d.ts +145 -0
  469. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/symbols.js +74 -0
  470. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/types.d.ts +85 -0
  471. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/types.js +15 -0
  472. package/node_modules/@bufbuild/protobuf/dist/commonjs/create.d.ts +9 -0
  473. package/node_modules/@bufbuild/protobuf/dist/commonjs/create.js +259 -0
  474. package/node_modules/@bufbuild/protobuf/dist/commonjs/descriptors.d.ts +634 -0
  475. package/node_modules/@bufbuild/protobuf/dist/commonjs/descriptors.js +53 -0
  476. package/node_modules/@bufbuild/protobuf/dist/commonjs/equals.d.ts +46 -0
  477. package/node_modules/@bufbuild/protobuf/dist/commonjs/equals.js +209 -0
  478. package/node_modules/@bufbuild/protobuf/dist/commonjs/extensions.d.ts +60 -0
  479. package/node_modules/@bufbuild/protobuf/dist/commonjs/extensions.js +168 -0
  480. package/node_modules/@bufbuild/protobuf/dist/commonjs/fields.d.ts +23 -0
  481. package/node_modules/@bufbuild/protobuf/dist/commonjs/fields.js +45 -0
  482. package/node_modules/@bufbuild/protobuf/dist/commonjs/from-binary.d.ts +48 -0
  483. package/node_modules/@bufbuild/protobuf/dist/commonjs/from-binary.js +247 -0
  484. package/node_modules/@bufbuild/protobuf/dist/commonjs/from-json.d.ts +73 -0
  485. package/node_modules/@bufbuild/protobuf/dist/commonjs/from-json.js +739 -0
  486. package/node_modules/@bufbuild/protobuf/dist/commonjs/index.d.ts +19 -0
  487. package/node_modules/@bufbuild/protobuf/dist/commonjs/index.js +55 -0
  488. package/node_modules/@bufbuild/protobuf/dist/commonjs/is-message.d.ts +7 -0
  489. package/node_modules/@bufbuild/protobuf/dist/commonjs/is-message.js +33 -0
  490. package/node_modules/@bufbuild/protobuf/dist/commonjs/json-value.d.ts +16 -0
  491. package/node_modules/@bufbuild/protobuf/dist/commonjs/json-value.js +15 -0
  492. package/node_modules/@bufbuild/protobuf/dist/commonjs/merge.d.ts +13 -0
  493. package/node_modules/@bufbuild/protobuf/dist/commonjs/merge.js +70 -0
  494. package/node_modules/@bufbuild/protobuf/dist/commonjs/package.json +4 -0
  495. package/node_modules/@bufbuild/protobuf/dist/commonjs/proto-int64.d.ts +98 -0
  496. package/node_modules/@bufbuild/protobuf/dist/commonjs/proto-int64.js +131 -0
  497. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/error.d.ts +9 -0
  498. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/error.js +36 -0
  499. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/guard.d.ts +20 -0
  500. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/guard.js +78 -0
  501. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/index.d.ts +8 -0
  502. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/index.js +41 -0
  503. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/names.d.ts +30 -0
  504. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/names.js +115 -0
  505. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/nested-types.d.ts +35 -0
  506. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/nested-types.js +110 -0
  507. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/path.d.ts +107 -0
  508. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/path.js +376 -0
  509. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect-check.d.ts +19 -0
  510. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect-check.js +268 -0
  511. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect-types.d.ts +217 -0
  512. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect-types.js +16 -0
  513. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect.d.ts +43 -0
  514. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect.js +546 -0
  515. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/scalar.d.ts +43 -0
  516. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/scalar.js +129 -0
  517. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/unsafe.d.ts +39 -0
  518. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/unsafe.js +149 -0
  519. package/node_modules/@bufbuild/protobuf/dist/commonjs/registry.d.ts +98 -0
  520. package/node_modules/@bufbuild/protobuf/dist/commonjs/registry.js +945 -0
  521. package/node_modules/@bufbuild/protobuf/dist/commonjs/to-binary.d.ts +24 -0
  522. package/node_modules/@bufbuild/protobuf/dist/commonjs/to-binary.js +199 -0
  523. package/node_modules/@bufbuild/protobuf/dist/commonjs/to-json.d.ts +67 -0
  524. package/node_modules/@bufbuild/protobuf/dist/commonjs/to-json.js +391 -0
  525. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/from-text.d.ts +35 -0
  526. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/from-text.js +684 -0
  527. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/index.d.ts +4 -0
  528. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/index.js +21 -0
  529. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/is-group-like.d.ts +19 -0
  530. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/is-group-like.js +47 -0
  531. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/reader.d.ts +91 -0
  532. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/reader.js +481 -0
  533. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/to-text.d.ts +34 -0
  534. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/to-text.js +358 -0
  535. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/writer.d.ts +76 -0
  536. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/writer.js +220 -0
  537. package/node_modules/@bufbuild/protobuf/dist/commonjs/types.d.ts +135 -0
  538. package/node_modules/@bufbuild/protobuf/dist/commonjs/types.js +15 -0
  539. package/node_modules/@bufbuild/protobuf/dist/commonjs/unknown-enum.d.ts +10 -0
  540. package/node_modules/@bufbuild/protobuf/dist/commonjs/unknown-enum.js +26 -0
  541. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/base64-encoding.d.ts +23 -0
  542. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/base64-encoding.js +156 -0
  543. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/binary-encoding.d.ts +268 -0
  544. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/binary-encoding.js +530 -0
  545. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/index.d.ts +5 -0
  546. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/index.js +34 -0
  547. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/size-delimited.d.ts +69 -0
  548. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/size-delimited.js +191 -0
  549. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/text-encoding.d.ts +28 -0
  550. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/text-encoding.js +61 -0
  551. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/text-format.d.ts +13 -0
  552. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/text-format.js +199 -0
  553. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/varint.d.ts +70 -0
  554. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/varint.js +322 -0
  555. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/any.d.ts +38 -0
  556. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/any.js +75 -0
  557. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/duration.d.ts +9 -0
  558. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/duration.js +39 -0
  559. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/any_pb.d.ts +238 -0
  560. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/any_pb.js +27 -0
  561. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/api_pb.d.ts +537 -0
  562. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/api_pb.js +39 -0
  563. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/compiler/plugin_pb.d.ts +490 -0
  564. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/compiler/plugin_pb.js +68 -0
  565. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/cpp_features_pb.d.ts +91 -0
  566. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/cpp_features_pb.js +60 -0
  567. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/descriptor_pb.d.ts +4143 -0
  568. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/descriptor_pb.js +892 -0
  569. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/duration_pb.d.ts +161 -0
  570. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/duration_pb.js +27 -0
  571. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/empty_pb.d.ts +39 -0
  572. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/empty_pb.js +27 -0
  573. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/field_mask_pb.d.ts +424 -0
  574. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/field_mask_pb.js +27 -0
  575. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/go_features_pb.d.ts +189 -0
  576. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/go_features_pb.js +126 -0
  577. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/java_features_pb.d.ts +194 -0
  578. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/java_features_pb.js +106 -0
  579. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/source_context_pb.d.ts +43 -0
  580. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/source_context_pb.js +27 -0
  581. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/struct_pb.d.ts +195 -0
  582. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/struct_pb.js +59 -0
  583. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/timestamp_pb.d.ts +222 -0
  584. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/timestamp_pb.js +27 -0
  585. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/type_pb.d.ts +722 -0
  586. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/type_pb.js +242 -0
  587. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/wrappers_pb.d.ts +330 -0
  588. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/wrappers_pb.js +67 -0
  589. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/index.d.ts +19 -0
  590. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/index.js +48 -0
  591. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/timestamp.d.ts +21 -0
  592. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/timestamp.js +57 -0
  593. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/wrappers.d.ts +25 -0
  594. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/wrappers.js +66 -0
  595. package/node_modules/@bufbuild/protobuf/dist/esm/clone.d.ts +6 -0
  596. package/node_modules/@bufbuild/protobuf/dist/esm/clone.js +63 -0
  597. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/boot.d.ts +1 -0
  598. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/boot.js +14 -0
  599. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/enum.d.ts +10 -0
  600. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/enum.js +26 -0
  601. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/extension.d.ts +9 -0
  602. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/extension.js +25 -0
  603. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/file.d.ts +1 -0
  604. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/file.js +14 -0
  605. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/index.d.ts +10 -0
  606. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/index.js +23 -0
  607. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/message.d.ts +10 -0
  608. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/message.js +21 -0
  609. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/service.d.ts +8 -0
  610. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/service.js +24 -0
  611. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/symbols.d.ts +140 -0
  612. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/symbols.js +40 -0
  613. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/types.d.ts +79 -0
  614. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/types.js +14 -0
  615. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/boot.d.ts +63 -0
  616. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/boot.js +101 -0
  617. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/embed.d.ts +43 -0
  618. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/embed.js +239 -0
  619. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/enum.d.ts +29 -0
  620. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/enum.js +53 -0
  621. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/extension.d.ts +9 -0
  622. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/extension.js +25 -0
  623. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/file.d.ts +7 -0
  624. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/file.js +32 -0
  625. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/index.d.ts +10 -0
  626. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/index.js +23 -0
  627. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/message.d.ts +15 -0
  628. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/message.js +21 -0
  629. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/restore-json-names.d.ts +5 -0
  630. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/restore-json-names.js +26 -0
  631. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/scalar.d.ts +9 -0
  632. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/scalar.js +63 -0
  633. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/service.d.ts +8 -0
  634. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/service.js +24 -0
  635. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/symbols.d.ts +145 -0
  636. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/symbols.js +71 -0
  637. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/types.d.ts +85 -0
  638. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/types.js +14 -0
  639. package/node_modules/@bufbuild/protobuf/dist/esm/create.d.ts +9 -0
  640. package/node_modules/@bufbuild/protobuf/dist/esm/create.js +256 -0
  641. package/node_modules/@bufbuild/protobuf/dist/esm/descriptors.d.ts +634 -0
  642. package/node_modules/@bufbuild/protobuf/dist/esm/descriptors.js +50 -0
  643. package/node_modules/@bufbuild/protobuf/dist/esm/equals.d.ts +46 -0
  644. package/node_modules/@bufbuild/protobuf/dist/esm/equals.js +206 -0
  645. package/node_modules/@bufbuild/protobuf/dist/esm/extensions.d.ts +60 -0
  646. package/node_modules/@bufbuild/protobuf/dist/esm/extensions.js +159 -0
  647. package/node_modules/@bufbuild/protobuf/dist/esm/fields.d.ts +23 -0
  648. package/node_modules/@bufbuild/protobuf/dist/esm/fields.js +41 -0
  649. package/node_modules/@bufbuild/protobuf/dist/esm/from-binary.d.ts +48 -0
  650. package/node_modules/@bufbuild/protobuf/dist/esm/from-binary.js +241 -0
  651. package/node_modules/@bufbuild/protobuf/dist/esm/from-json.d.ts +73 -0
  652. package/node_modules/@bufbuild/protobuf/dist/esm/from-json.js +731 -0
  653. package/node_modules/@bufbuild/protobuf/dist/esm/index.d.ts +19 -0
  654. package/node_modules/@bufbuild/protobuf/dist/esm/index.js +29 -0
  655. package/node_modules/@bufbuild/protobuf/dist/esm/is-message.d.ts +7 -0
  656. package/node_modules/@bufbuild/protobuf/dist/esm/is-message.js +30 -0
  657. package/node_modules/@bufbuild/protobuf/dist/esm/json-value.d.ts +16 -0
  658. package/node_modules/@bufbuild/protobuf/dist/esm/json-value.js +14 -0
  659. package/node_modules/@bufbuild/protobuf/dist/esm/merge.d.ts +13 -0
  660. package/node_modules/@bufbuild/protobuf/dist/esm/merge.js +67 -0
  661. package/node_modules/@bufbuild/protobuf/dist/esm/package.json +4 -0
  662. package/node_modules/@bufbuild/protobuf/dist/esm/proto-int64.d.ts +98 -0
  663. package/node_modules/@bufbuild/protobuf/dist/esm/proto-int64.js +128 -0
  664. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/error.d.ts +9 -0
  665. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/error.js +31 -0
  666. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/guard.d.ts +20 -0
  667. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/guard.js +71 -0
  668. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/index.d.ts +8 -0
  669. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/index.js +21 -0
  670. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/names.d.ts +30 -0
  671. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/names.js +109 -0
  672. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/nested-types.d.ts +35 -0
  673. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/nested-types.js +105 -0
  674. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/path.d.ts +107 -0
  675. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/path.js +369 -0
  676. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-check.d.ts +19 -0
  677. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-check.js +262 -0
  678. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-types.d.ts +217 -0
  679. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-types.js +14 -0
  680. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect.d.ts +43 -0
  681. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect.js +541 -0
  682. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/scalar.d.ts +43 -0
  683. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/scalar.js +124 -0
  684. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/unsafe.d.ts +39 -0
  685. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/unsafe.js +140 -0
  686. package/node_modules/@bufbuild/protobuf/dist/esm/registry.d.ts +98 -0
  687. package/node_modules/@bufbuild/protobuf/dist/esm/registry.js +939 -0
  688. package/node_modules/@bufbuild/protobuf/dist/esm/to-binary.d.ts +24 -0
  689. package/node_modules/@bufbuild/protobuf/dist/esm/to-binary.js +195 -0
  690. package/node_modules/@bufbuild/protobuf/dist/esm/to-json.d.ts +67 -0
  691. package/node_modules/@bufbuild/protobuf/dist/esm/to-json.js +386 -0
  692. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/from-text.d.ts +35 -0
  693. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/from-text.js +680 -0
  694. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/index.d.ts +4 -0
  695. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/index.js +15 -0
  696. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/is-group-like.d.ts +19 -0
  697. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/is-group-like.js +44 -0
  698. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/reader.d.ts +91 -0
  699. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/reader.js +477 -0
  700. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/to-text.d.ts +34 -0
  701. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/to-text.js +355 -0
  702. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/writer.d.ts +76 -0
  703. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/writer.js +214 -0
  704. package/node_modules/@bufbuild/protobuf/dist/esm/types.d.ts +135 -0
  705. package/node_modules/@bufbuild/protobuf/dist/esm/types.js +14 -0
  706. package/node_modules/@bufbuild/protobuf/dist/esm/unknown-enum.d.ts +10 -0
  707. package/node_modules/@bufbuild/protobuf/dist/esm/unknown-enum.js +23 -0
  708. package/node_modules/@bufbuild/protobuf/dist/esm/wire/base64-encoding.d.ts +23 -0
  709. package/node_modules/@bufbuild/protobuf/dist/esm/wire/base64-encoding.js +152 -0
  710. package/node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.d.ts +268 -0
  711. package/node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.js +525 -0
  712. package/node_modules/@bufbuild/protobuf/dist/esm/wire/index.d.ts +5 -0
  713. package/node_modules/@bufbuild/protobuf/dist/esm/wire/index.js +18 -0
  714. package/node_modules/@bufbuild/protobuf/dist/esm/wire/size-delimited.d.ts +69 -0
  715. package/node_modules/@bufbuild/protobuf/dist/esm/wire/size-delimited.js +186 -0
  716. package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-encoding.d.ts +28 -0
  717. package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-encoding.js +57 -0
  718. package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-format.d.ts +13 -0
  719. package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-format.js +195 -0
  720. package/node_modules/@bufbuild/protobuf/dist/esm/wire/varint.d.ts +70 -0
  721. package/node_modules/@bufbuild/protobuf/dist/esm/wire/varint.js +313 -0
  722. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/any.d.ts +38 -0
  723. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/any.js +69 -0
  724. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/duration.d.ts +9 -0
  725. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/duration.js +35 -0
  726. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/any_pb.d.ts +238 -0
  727. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/any_pb.js +24 -0
  728. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/api_pb.d.ts +537 -0
  729. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/api_pb.js +36 -0
  730. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.d.ts +490 -0
  731. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.js +65 -0
  732. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/cpp_features_pb.d.ts +91 -0
  733. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/cpp_features_pb.js +57 -0
  734. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/descriptor_pb.d.ts +4143 -0
  735. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/descriptor_pb.js +888 -0
  736. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/duration_pb.d.ts +161 -0
  737. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/duration_pb.js +24 -0
  738. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/empty_pb.d.ts +39 -0
  739. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/empty_pb.js +24 -0
  740. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/field_mask_pb.d.ts +424 -0
  741. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/field_mask_pb.js +24 -0
  742. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/go_features_pb.d.ts +189 -0
  743. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/go_features_pb.js +123 -0
  744. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/java_features_pb.d.ts +194 -0
  745. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/java_features_pb.js +103 -0
  746. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/source_context_pb.d.ts +43 -0
  747. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/source_context_pb.js +24 -0
  748. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/struct_pb.d.ts +195 -0
  749. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/struct_pb.js +56 -0
  750. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/timestamp_pb.d.ts +222 -0
  751. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/timestamp_pb.js +24 -0
  752. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/type_pb.d.ts +722 -0
  753. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/type_pb.js +239 -0
  754. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/wrappers_pb.d.ts +330 -0
  755. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/wrappers_pb.js +64 -0
  756. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/index.d.ts +19 -0
  757. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/index.js +32 -0
  758. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/timestamp.d.ts +21 -0
  759. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/timestamp.js +50 -0
  760. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/wrappers.d.ts +25 -0
  761. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/wrappers.js +61 -0
  762. package/node_modules/@bufbuild/protobuf/package.json +147 -0
  763. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +28 -0
  764. package/node_modules/@code-yeongyu/senpi-codemode/README.md +5 -0
  765. package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
  766. package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +14 -1
  767. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/call-capture.ts +64 -0
  768. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-handler.ts +45 -61
  769. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-runtime.ts +8 -0
  770. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-execution-event.ts +201 -0
  771. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool-options.ts +2 -0
  772. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +22 -0
  773. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/render.ts +43 -6
  774. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/types.ts +4 -0
  775. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  776. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +59 -17
  777. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  778. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +14 -0
  779. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
  780. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +14 -0
  781. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
  782. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts +25 -0
  783. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
  784. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +77 -12
  785. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
  786. package/node_modules/@earendil-works/pi-agent-core/dist/harness/events.d.ts +43 -0
  787. package/node_modules/@earendil-works/pi-agent-core/dist/harness/events.d.ts.map +1 -0
  788. package/node_modules/@earendil-works/pi-agent-core/dist/harness/events.js +67 -0
  789. package/node_modules/@earendil-works/pi-agent-core/dist/harness/events.js.map +1 -0
  790. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.d.ts +4 -2
  791. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.d.ts.map +1 -1
  792. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.js +127 -88
  793. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.js.map +1 -1
  794. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.d.ts +5 -1
  795. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.d.ts.map +1 -1
  796. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.js +9 -2
  797. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.js.map +1 -1
  798. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.d.ts +12 -3
  799. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.d.ts.map +1 -1
  800. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.js +88 -45
  801. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.js.map +1 -1
  802. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.d.ts +1 -1
  803. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.d.ts.map +1 -1
  804. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.js +28 -19
  805. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.js.map +1 -1
  806. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/types.d.ts +1 -1
  807. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/types.d.ts.map +1 -1
  808. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/types.js.map +1 -1
  809. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.d.ts +1 -1
  810. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.d.ts.map +1 -1
  811. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.js.map +1 -1
  812. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts +6 -1
  813. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -1
  814. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +7 -2
  815. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -1
  816. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.d.ts +1 -1
  817. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.d.ts.map +1 -1
  818. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.js.map +1 -1
  819. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance.d.ts.map +1 -1
  820. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance.js +19 -0
  821. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance.js.map +1 -1
  822. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.d.ts +18 -5
  823. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.d.ts.map +1 -1
  824. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.js.map +1 -1
  825. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +1 -1
  826. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
  827. package/node_modules/@earendil-works/pi-agent-core/dist/index.js +1 -1
  828. package/node_modules/@earendil-works/pi-agent-core/dist/index.js.map +1 -1
  829. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +4 -1
  830. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
  831. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
  832. package/node_modules/@earendil-works/pi-agent-core/dist/search/index.d.ts +21 -0
  833. package/node_modules/@earendil-works/pi-agent-core/dist/search/index.d.ts.map +1 -0
  834. package/node_modules/@earendil-works/pi-agent-core/dist/search/index.js +2 -0
  835. package/node_modules/@earendil-works/pi-agent-core/dist/search/index.js.map +1 -0
  836. package/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.d.ts +29 -0
  837. package/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.d.ts.map +1 -0
  838. package/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.js +103 -0
  839. package/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.js.map +1 -0
  840. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +12 -1
  841. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
  842. package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
  843. package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  844. package/node_modules/@earendil-works/pi-ai/README.md +3 -0
  845. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  846. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +40 -14
  847. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  848. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  849. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +16 -4
  850. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
  851. package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.d.ts +69 -0
  852. package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.d.ts.map +1 -0
  853. package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.js +159 -0
  854. package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.js.map +1 -0
  855. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.d.ts +3 -0
  856. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.d.ts.map +1 -1
  857. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +125 -5
  858. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js.map +1 -1
  859. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/deterministic-id.d.ts +17 -0
  860. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/deterministic-id.d.ts.map +1 -0
  861. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/deterministic-id.js +14 -0
  862. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/deterministic-id.js.map +1 -0
  863. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/exec-lifecycle.d.ts +13 -0
  864. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/exec-lifecycle.d.ts.map +1 -0
  865. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/exec-lifecycle.js +33 -0
  866. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/exec-lifecycle.js.map +1 -0
  867. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/exec-modern.d.ts +79 -0
  868. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/exec-modern.d.ts.map +1 -0
  869. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/exec-modern.js +360 -0
  870. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/exec-modern.js.map +1 -0
  871. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/gen/agent_pb.d.ts +16797 -0
  872. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/gen/agent_pb.d.ts.map +1 -0
  873. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/gen/agent_pb.js +3828 -0
  874. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/gen/agent_pb.js.map +1 -0
  875. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/pi-args.d.ts +55 -0
  876. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/pi-args.d.ts.map +1 -0
  877. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/pi-args.js +76 -0
  878. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/pi-args.js.map +1 -0
  879. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/types.d.ts +116 -0
  880. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/types.d.ts.map +1 -0
  881. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/types.js +16 -0
  882. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/types.js.map +1 -0
  883. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts +191 -0
  884. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts.map +1 -0
  885. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js +3316 -0
  886. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js.map +1 -0
  887. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.lazy.d.ts +29 -0
  888. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.lazy.d.ts.map +1 -0
  889. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.lazy.js +33 -0
  890. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.lazy.js.map +1 -0
  891. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +7 -3
  892. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
  893. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts +1 -1
  894. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts.map +1 -1
  895. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +13 -9
  896. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js.map +1 -1
  897. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +7 -3
  898. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
  899. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts +1 -1
  900. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
  901. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +208 -42
  902. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
  903. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  904. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +13 -4
  905. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  906. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  907. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +10 -7
  908. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  909. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts +1 -0
  910. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
  911. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +31 -7
  912. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
  913. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  914. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +8 -1
  915. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  916. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/cursor.d.ts +16 -0
  917. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/cursor.d.ts.map +1 -0
  918. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/cursor.js +234 -0
  919. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/cursor.js.map +1 -0
  920. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.d.ts.map +1 -1
  921. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.js +6 -3
  922. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.js.map +1 -1
  923. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts +2 -0
  924. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts.map +1 -1
  925. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js +5 -0
  926. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js.map +1 -1
  927. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +44 -9
  928. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
  929. package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +2 -0
  930. package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts.map +1 -1
  931. package/node_modules/@earendil-works/pi-ai/dist/auth/types.js.map +1 -1
  932. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.d.ts.map +1 -1
  933. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js +2 -0
  934. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js.map +1 -1
  935. package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts +1 -0
  936. package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts.map +1 -1
  937. package/node_modules/@earendil-works/pi-ai/dist/compat.js +3 -0
  938. package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
  939. package/node_modules/@earendil-works/pi-ai/dist/cursor-agent-provider.d.ts +11 -0
  940. package/node_modules/@earendil-works/pi-ai/dist/cursor-agent-provider.d.ts.map +1 -0
  941. package/node_modules/@earendil-works/pi-ai/dist/cursor-agent-provider.js +11 -0
  942. package/node_modules/@earendil-works/pi-ai/dist/cursor-agent-provider.js.map +1 -0
  943. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +3 -0
  944. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  945. package/node_modules/@earendil-works/pi-ai/dist/index.js +2 -0
  946. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
  947. package/node_modules/@earendil-works/pi-ai/dist/model.d.ts +6 -1
  948. package/node_modules/@earendil-works/pi-ai/dist/model.d.ts.map +1 -1
  949. package/node_modules/@earendil-works/pi-ai/dist/model.js.map +1 -1
  950. package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts.map +1 -1
  951. package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +2 -0
  952. package/node_modules/@earendil-works/pi-ai/dist/providers/all.js.map +1 -1
  953. package/node_modules/@earendil-works/pi-ai/dist/providers/cursor.d.ts +12 -0
  954. package/node_modules/@earendil-works/pi-ai/dist/providers/cursor.d.ts.map +1 -0
  955. package/node_modules/@earendil-works/pi-ai/dist/providers/cursor.js +65 -0
  956. package/node_modules/@earendil-works/pi-ai/dist/providers/cursor.js.map +1 -0
  957. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  958. package/node_modules/@earendil-works/pi-ai/dist/providers/data/alibaba-token-plan.json +1 -1
  959. package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  960. package/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
  961. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -1
  962. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  963. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  964. package/node_modules/@earendil-works/pi-ai/dist/providers/data/deepseek.json +1 -1
  965. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  966. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  967. package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  968. package/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
  969. package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  970. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
  971. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  972. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  973. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  974. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  975. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
  976. package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  977. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  978. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  979. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  980. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +17 -4
  981. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  982. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  983. package/node_modules/@earendil-works/pi-ai/dist/utils/block-symbols.d.ts +57 -0
  984. package/node_modules/@earendil-works/pi-ai/dist/utils/block-symbols.d.ts.map +1 -0
  985. package/node_modules/@earendil-works/pi-ai/dist/utils/block-symbols.js +57 -0
  986. package/node_modules/@earendil-works/pi-ai/dist/utils/block-symbols.js.map +1 -0
  987. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts +10 -0
  988. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts.map +1 -1
  989. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js +22 -0
  990. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js.map +1 -1
  991. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts.map +1 -1
  992. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +2 -0
  993. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -1
  994. package/node_modules/@earendil-works/pi-ai/dist/utils/pi-user-agent.d.ts +2 -0
  995. package/node_modules/@earendil-works/pi-ai/dist/utils/pi-user-agent.d.ts.map +1 -0
  996. package/node_modules/@earendil-works/pi-ai/dist/utils/pi-user-agent.js +12 -0
  997. package/node_modules/@earendil-works/pi-ai/dist/utils/pi-user-agent.js.map +1 -0
  998. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.d.ts.map +1 -1
  999. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js +3 -2
  1000. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js.map +1 -1
  1001. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
  1002. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -0
  1003. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
  1004. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.d.ts.map +1 -1
  1005. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.js +34 -0
  1006. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.js.map +1 -1
  1007. package/node_modules/@earendil-works/pi-ai/package.json +3 -2
  1008. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  1009. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  1010. package/node_modules/@earendil-works/pi-tui/README.md +1 -1
  1011. package/node_modules/@earendil-works/pi-tui/dist/alt-screen-search.d.ts +26 -0
  1012. package/node_modules/@earendil-works/pi-tui/dist/alt-screen-search.d.ts.map +1 -0
  1013. package/node_modules/@earendil-works/pi-tui/dist/alt-screen-search.js +121 -0
  1014. package/node_modules/@earendil-works/pi-tui/dist/alt-screen-search.js.map +1 -0
  1015. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +1 -1
  1016. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +21 -0
  1017. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +1 -1
  1018. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +1 -1
  1019. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
  1020. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts +6 -1
  1021. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts.map +1 -1
  1022. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.js +23 -7
  1023. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.js.map +1 -1
  1024. package/node_modules/@earendil-works/pi-tui/dist/dollar-invocation-autocomplete.d.ts +9 -0
  1025. package/node_modules/@earendil-works/pi-tui/dist/dollar-invocation-autocomplete.d.ts.map +1 -0
  1026. package/node_modules/@earendil-works/pi-tui/dist/dollar-invocation-autocomplete.js +82 -0
  1027. package/node_modules/@earendil-works/pi-tui/dist/dollar-invocation-autocomplete.js.map +1 -0
  1028. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +4 -1
  1029. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  1030. package/node_modules/@earendil-works/pi-tui/dist/index.js +7 -1
  1031. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
  1032. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +30 -0
  1033. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -1
  1034. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +24 -0
  1035. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
  1036. package/node_modules/@earendil-works/pi-tui/dist/layout.d.ts.map +1 -1
  1037. package/node_modules/@earendil-works/pi-tui/dist/layout.js +9 -2
  1038. package/node_modules/@earendil-works/pi-tui/dist/layout.js.map +1 -1
  1039. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +8 -2
  1040. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +1 -1
  1041. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +6 -2
  1042. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +1 -1
  1043. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +6 -0
  1044. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
  1045. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +18 -1
  1046. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
  1047. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +21 -0
  1048. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts.map +1 -1
  1049. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +243 -5
  1050. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js.map +1 -1
  1051. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +2 -0
  1052. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  1053. package/node_modules/@earendil-works/pi-tui/dist/tui.js +33 -8
  1054. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  1055. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  1056. package/package.json +11 -8
  1057. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search.d.ts +0 -19
  1058. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search.d.ts.map +0 -1
  1059. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search.js +0 -41
  1060. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search.js.map +0 -1
@@ -0,0 +1,159 @@
1
+ /**
2
+ * AI Gateway transport over the Workers AI binding.
3
+ *
4
+ * pi's Cloudflare AI Gateway support speaks HTTPS
5
+ * (`gateway.ai.cloudflare.com/v1/{account}/{gateway}/{provider}/...`, see `api/cloudflare.ts`),
6
+ * which needs a Cloudflare API token even when the caller is a Worker in the gateway's own
7
+ * account.
8
+ *
9
+ * In order to solve for this problem, `createGatewayBindingFetch` returns a {@link FetchFunction}
10
+ * that translates requests under a gateway HTTPS prefix into calls to the Workers AI binding's
11
+ * universal endpoint, `env.AI.gateway(id).run({provider, endpoint, headers, query})`.
12
+ * Binding calls are pre-authenticated in-account and return the provider's native wire format as a
13
+ * regular (streaming) `Response`, so API implementations behave identically over either
14
+ * transport.
15
+ *
16
+ * The result is the transport for one gateway-bound client, not a general-purpose fetch:
17
+ * requests it cannot serve — URLs outside the prefix, or in-prefix requests the universal
18
+ * endpoint cannot express (non-POST, non-JSON body) — reject with a descriptive error.
19
+ * Transport selection is the caller's job, per client: route such traffic over HTTPS with
20
+ * real gateway auth instead of through this shim.
21
+ */
22
+ /**
23
+ * Placeholder value for auth headers on binding-routed requests. API implementations
24
+ * require an API key or a recognized auth header (`authorization`, `x-api-key`,
25
+ * `cf-aig-authorization`) before dispatch; binding calls are pre-authenticated, so pass
26
+ * `cf-aig-authorization: Bearer ${CLOUDFLARE_GATEWAY_BINDING_AUTH_SENTINEL}` to satisfy
27
+ * the check. The shim strips `cf-aig-authorization` before calling the binding. Pair it with
28
+ * `Authorization: null` / `x-api-key: null` so the SDKs' placeholder auth headers never reach
29
+ * the gateway, which would treat a request-supplied auth header as a BYOK provider key that
30
+ * overrides its stored keys — the same as it would over HTTPS.
31
+ */
32
+ export const CLOUDFLARE_GATEWAY_BINDING_AUTH_SENTINEL = "cloudflare-gateway-binding";
33
+ // Never forwarded to the binding: hop-by-hop/derived headers, and gateway auth
34
+ // (binding calls are pre-authenticated; the sentinel must not reach the wire).
35
+ const STRIP_HEADERS = new Set(["content-length", "host", "cf-aig-authorization"]);
36
+ /**
37
+ * Create a `fetch` that routes AI Gateway requests through the Workers AI binding.
38
+ * See the module docs for behavior and composition notes.
39
+ */
40
+ export function createGatewayBindingFetch(options) {
41
+ const { binding, gateway } = options;
42
+ // Prefix matching runs on URL-normalized components (origin + pathname), not raw strings:
43
+ // dot segments resolve away and fragments drop, matching what real fetch would put on the
44
+ // wire, so a lexical variant can't split provider/endpoint differently than HTTPS would.
45
+ const base = new URL(options.baseUrl);
46
+ const basePath = base.pathname.endsWith("/") ? base.pathname : `${base.pathname}/`;
47
+ return async (input, init) => {
48
+ const request = input instanceof Request ? input : undefined;
49
+ const url = request ? request.url : input.toString();
50
+ const method = (init?.method ?? request?.method ?? "GET").toUpperCase();
51
+ let parsed;
52
+ try {
53
+ parsed = new URL(url);
54
+ }
55
+ catch {
56
+ parsed = undefined;
57
+ }
58
+ // Out-of-prefix URLs are a configuration bug, not passthrough traffic: silently
59
+ // forwarding would ship the auth sentinel to whatever host the URL names.
60
+ if (parsed === undefined || parsed.origin !== base.origin || !parsed.pathname.startsWith(basePath)) {
61
+ throw new Error(`createGatewayBindingFetch: ${method} ${url} is outside the configured gateway ` +
62
+ `prefix (${base.origin}${basePath}); this fetch only serves its gateway-bound client`);
63
+ }
64
+ // In-prefix requests the universal endpoint cannot express always reject: forwarding
65
+ // them over HTTPS would send the sentinel to the gateway and fail with a misleading
66
+ // auth error instead of naming the real problem. Callers that need such endpoints
67
+ // route them over HTTPS with real gateway auth themselves.
68
+ const unexpressible = (reason) => {
69
+ throw new Error(`createGatewayBindingFetch: cannot express ${method} ${url} as a universal ` +
70
+ `gateway request (${reason}); route it over HTTPS with gateway auth instead`);
71
+ };
72
+ if (method !== "POST")
73
+ return unexpressible("only POST is supported");
74
+ const rest = parsed.pathname.slice(basePath.length);
75
+ const slash = rest.indexOf("/");
76
+ if (slash <= 0) {
77
+ return unexpressible("missing provider/endpoint path");
78
+ }
79
+ const provider = rest.slice(0, slash);
80
+ // Keep the query string on the endpoint — it's part of what HTTPS would have sent.
81
+ const endpoint = rest.slice(slash + 1) + parsed.search;
82
+ const bodyText = await readBodyText(request, init);
83
+ let query;
84
+ try {
85
+ query = bodyText === undefined ? undefined : JSON.parse(bodyText);
86
+ }
87
+ catch {
88
+ return unexpressible("non-JSON body");
89
+ }
90
+ if (query === undefined) {
91
+ return unexpressible("missing body");
92
+ }
93
+ const headers = collectHeaders(request, init);
94
+ // Per the fetch spec an explicit `signal: null` in init clears a Request input's signal.
95
+ const signal = init?.signal ?? (init && "signal" in init && init.signal === null ? undefined : request?.signal);
96
+ return binding.gateway(gateway).run({ provider, endpoint, headers, query }, signal ? { signal } : {});
97
+ };
98
+ }
99
+ async function readBodyText(request, init) {
100
+ const body = init?.body;
101
+ if (body === undefined || body === null) {
102
+ // Per the fetch spec an explicit `body: null` in init clears a Request input's body.
103
+ if (init && "body" in init && body === null)
104
+ return undefined;
105
+ if (request && request.body !== null)
106
+ return request.clone().text();
107
+ return undefined;
108
+ }
109
+ if (typeof body === "string")
110
+ return body;
111
+ if (body instanceof Uint8Array)
112
+ return new TextDecoder().decode(body);
113
+ if (body instanceof ArrayBuffer)
114
+ return new TextDecoder().decode(new Uint8Array(body));
115
+ // URLSearchParams, FormData, Blob, ReadableStream in init: read via a Request wrapper.
116
+ // Consuming a one-shot stream here is fine — unexpressible requests reject rather than
117
+ // replay, so nothing downstream needs the body again.
118
+ return new Request("http://body.local", {
119
+ method: "POST",
120
+ body,
121
+ // The fetch spec requires `duplex: "half"` to construct a Request with a stream body
122
+ // (Node's undici enforces it; it is ignored for the replayable body types). TypeScript's
123
+ // RequestInit does not declare the field yet, hence the cast.
124
+ duplex: "half",
125
+ }).text();
126
+ }
127
+ // Entry header names are lowercased so case-variant duplicates collapse and stripping is
128
+ // uniform. Per the fetch spec, `init.headers` replaces a Request input's headers entirely.
129
+ function collectHeaders(request, init) {
130
+ const result = {};
131
+ const add = (key, value) => {
132
+ const name = key.toLowerCase();
133
+ if (!STRIP_HEADERS.has(name))
134
+ result[name] = value;
135
+ };
136
+ const headers = init?.headers;
137
+ if (headers === undefined) {
138
+ if (request) {
139
+ for (const [key, value] of request.headers)
140
+ add(key, value);
141
+ }
142
+ }
143
+ else if (headers instanceof Headers) {
144
+ for (const [key, value] of headers)
145
+ add(key, value);
146
+ }
147
+ else if (Array.isArray(headers)) {
148
+ for (const [key, value] of headers)
149
+ add(key, value);
150
+ }
151
+ else {
152
+ for (const [key, value] of Object.entries(headers)) {
153
+ if (value !== undefined)
154
+ add(key, String(value));
155
+ }
156
+ }
157
+ return result;
158
+ }
159
+ //# sourceMappingURL=cloudflare-gateway-binding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloudflare-gateway-binding.js","sourceRoot":"","sources":["../../src/api/cloudflare-gateway-binding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAwBH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,wCAAwC,GAAG,4BAA4B,CAAC;AAcrF,+EAA+E;AAC/E,+EAA+E;AAC/E,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAAC;AAIlF;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAmC;IAC5E,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACrC,0FAA0F;IAC1F,0FAA0F;IAC1F,yFAAyF;IACzF,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,OAA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AI Gateway transport over the Workers AI binding.\n *\n * pi's Cloudflare AI Gateway support speaks HTTPS\n * (`gateway.ai.cloudflare.com/v1/{account}/{gateway}/{provider}/...`, see `api/cloudflare.ts`),\n * which needs a Cloudflare API token even when the caller is a Worker in the gateway's own\n * account.\n *\n * In order to solve for this problem, `createGatewayBindingFetch` returns a {@link FetchFunction}\n * that translates requests under a gateway HTTPS prefix into calls to the Workers AI binding's\n * universal endpoint, `env.AI.gateway(id).run({provider, endpoint, headers, query})`.\n * Binding calls are pre-authenticated in-account and return the provider's native wire format as a\n * regular (streaming) `Response`, so API implementations behave identically over either\n * transport.\n *\n * The result is the transport for one gateway-bound client, not a general-purpose fetch:\n * requests it cannot serve — URLs outside the prefix, or in-prefix requests the universal\n * endpoint cannot express (non-POST, non-JSON body) — reject with a descriptive error.\n * Transport selection is the caller's job, per client: route such traffic over HTTPS with\n * real gateway auth instead of through this shim.\n */\n\nimport type { FetchFunction } from \"../types.ts\";\n\n/**\n * Structural type for the Workers AI binding's gateway surface (`env.AI`), so this\n * module does not depend on `@cloudflare/workers-types`. Any real `Ai` binding satisfies it.\n */\nexport interface AiGatewayBinding {\n\tgateway(id: string): AiGatewayBindingGateway;\n}\n\nexport interface AiGatewayBindingGateway {\n\trun(data: AiGatewayUniversalRequestLike, options?: { signal?: AbortSignal }): Promise<Response>;\n}\n\n/** One universal-endpoint request entry, as accepted by `AiGateway.run()`. */\nexport interface AiGatewayUniversalRequestLike {\n\tprovider: string;\n\tendpoint: string;\n\theaders: Record<string, string>;\n\tquery: unknown;\n}\n\n/**\n * Placeholder value for auth headers on binding-routed requests. API implementations\n * require an API key or a recognized auth header (`authorization`, `x-api-key`,\n * `cf-aig-authorization`) before dispatch; binding calls are pre-authenticated, so pass\n * `cf-aig-authorization: Bearer ${CLOUDFLARE_GATEWAY_BINDING_AUTH_SENTINEL}` to satisfy\n * the check. The shim strips `cf-aig-authorization` before calling the binding. Pair it with\n * `Authorization: null` / `x-api-key: null` so the SDKs' placeholder auth headers never reach\n * the gateway, which would treat a request-supplied auth header as a BYOK provider key that\n * overrides its stored keys — the same as it would over HTTPS.\n */\nexport const CLOUDFLARE_GATEWAY_BINDING_AUTH_SENTINEL = \"cloudflare-gateway-binding\";\n\nexport interface GatewayBindingFetchOptions {\n\t/** The Workers AI binding (e.g. `env.AI`). */\n\tbinding: AiGatewayBinding;\n\t/**\n\t * Gateway HTTPS prefix every request must fall under, without a trailing slash:\n\t * `https://gateway.ai.cloudflare.com/v1/{accountId}/{gatewayName}`.\n\t */\n\tbaseUrl: string;\n\t/** Gateway name passed to `binding.gateway()`. Must match the `baseUrl` gateway. */\n\tgateway: string;\n}\n\n// Never forwarded to the binding: hop-by-hop/derived headers, and gateway auth\n// (binding calls are pre-authenticated; the sentinel must not reach the wire).\nconst STRIP_HEADERS = new Set([\"content-length\", \"host\", \"cf-aig-authorization\"]);\n\ntype FetchInput = Parameters<FetchFunction>[0];\n\n/**\n * Create a `fetch` that routes AI Gateway requests through the Workers AI binding.\n * See the module docs for behavior and composition notes.\n */\nexport function createGatewayBindingFetch(options: GatewayBindingFetchOptions): FetchFunction {\n\tconst { binding, gateway } = options;\n\t// Prefix matching runs on URL-normalized components (origin + pathname), not raw strings:\n\t// dot segments resolve away and fragments drop, matching what real fetch would put on the\n\t// wire, so a lexical variant can't split provider/endpoint differently than HTTPS would.\n\tconst base = new URL(options.baseUrl);\n\tconst basePath = base.pathname.endsWith(\"/\") ? base.pathname : `${base.pathname}/`;\n\n\treturn async (input: FetchInput, init?: RequestInit): Promise<Response> => {\n\t\tconst request = input instanceof Request ? input : undefined;\n\t\tconst url = request ? request.url : input.toString();\n\t\tconst method = (init?.method ?? request?.method ?? \"GET\").toUpperCase();\n\t\tlet parsed: URL | undefined;\n\t\ttry {\n\t\t\tparsed = new URL(url);\n\t\t} catch {\n\t\t\tparsed = undefined;\n\t\t}\n\t\t// Out-of-prefix URLs are a configuration bug, not passthrough traffic: silently\n\t\t// forwarding would ship the auth sentinel to whatever host the URL names.\n\t\tif (parsed === undefined || parsed.origin !== base.origin || !parsed.pathname.startsWith(basePath)) {\n\t\t\tthrow new Error(\n\t\t\t\t`createGatewayBindingFetch: ${method} ${url} is outside the configured gateway ` +\n\t\t\t\t\t`prefix (${base.origin}${basePath}); this fetch only serves its gateway-bound client`,\n\t\t\t);\n\t\t}\n\n\t\t// In-prefix requests the universal endpoint cannot express always reject: forwarding\n\t\t// them over HTTPS would send the sentinel to the gateway and fail with a misleading\n\t\t// auth error instead of naming the real problem. Callers that need such endpoints\n\t\t// route them over HTTPS with real gateway auth themselves.\n\t\tconst unexpressible = (reason: string): never => {\n\t\t\tthrow new Error(\n\t\t\t\t`createGatewayBindingFetch: cannot express ${method} ${url} as a universal ` +\n\t\t\t\t\t`gateway request (${reason}); route it over HTTPS with gateway auth instead`,\n\t\t\t);\n\t\t};\n\t\tif (method !== \"POST\") return unexpressible(\"only POST is supported\");\n\n\t\tconst rest = parsed.pathname.slice(basePath.length);\n\t\tconst slash = rest.indexOf(\"/\");\n\t\tif (slash <= 0) {\n\t\t\treturn unexpressible(\"missing provider/endpoint path\");\n\t\t}\n\t\tconst provider = rest.slice(0, slash);\n\t\t// Keep the query string on the endpoint — it's part of what HTTPS would have sent.\n\t\tconst endpoint = rest.slice(slash + 1) + parsed.search;\n\n\t\tconst bodyText = await readBodyText(request, init);\n\t\tlet query: unknown;\n\t\ttry {\n\t\t\tquery = bodyText === undefined ? undefined : JSON.parse(bodyText);\n\t\t} catch {\n\t\t\treturn unexpressible(\"non-JSON body\");\n\t\t}\n\t\tif (query === undefined) {\n\t\t\treturn unexpressible(\"missing body\");\n\t\t}\n\n\t\tconst headers = collectHeaders(request, init);\n\t\t// Per the fetch spec an explicit `signal: null` in init clears a Request input's signal.\n\t\tconst signal = init?.signal ?? (init && \"signal\" in init && init.signal === null ? undefined : request?.signal);\n\t\treturn binding.gateway(gateway).run({ provider, endpoint, headers, query }, signal ? { signal } : {});\n\t};\n}\n\nasync function readBodyText(request: Request | undefined, init?: RequestInit): Promise<string | undefined> {\n\tconst body = init?.body;\n\tif (body === undefined || body === null) {\n\t\t// Per the fetch spec an explicit `body: null` in init clears a Request input's body.\n\t\tif (init && \"body\" in init && body === null) return undefined;\n\t\tif (request && request.body !== null) return request.clone().text();\n\t\treturn undefined;\n\t}\n\tif (typeof body === \"string\") return body;\n\tif (body instanceof Uint8Array) return new TextDecoder().decode(body);\n\tif (body instanceof ArrayBuffer) return new TextDecoder().decode(new Uint8Array(body));\n\t// URLSearchParams, FormData, Blob, ReadableStream in init: read via a Request wrapper.\n\t// Consuming a one-shot stream here is fine — unexpressible requests reject rather than\n\t// replay, so nothing downstream needs the body again.\n\treturn new Request(\"http://body.local\", {\n\t\tmethod: \"POST\",\n\t\tbody,\n\t\t// The fetch spec requires `duplex: \"half\"` to construct a Request with a stream body\n\t\t// (Node's undici enforces it; it is ignored for the replayable body types). TypeScript's\n\t\t// RequestInit does not declare the field yet, hence the cast.\n\t\tduplex: \"half\",\n\t} as RequestInit).text();\n}\n\n// Entry header names are lowercased so case-variant duplicates collapse and stripping is\n// uniform. Per the fetch spec, `init.headers` replaces a Request input's headers entirely.\nfunction collectHeaders(request: Request | undefined, init?: RequestInit): Record<string, string> {\n\tconst result: Record<string, string> = {};\n\tconst add = (key: string, value: string) => {\n\t\tconst name = key.toLowerCase();\n\t\tif (!STRIP_HEADERS.has(name)) result[name] = value;\n\t};\n\tconst headers = init?.headers;\n\tif (headers === undefined) {\n\t\tif (request) {\n\t\t\tfor (const [key, value] of request.headers) add(key, value);\n\t\t}\n\t} else if (headers instanceof Headers) {\n\t\tfor (const [key, value] of headers) add(key, value);\n\t} else if (Array.isArray(headers)) {\n\t\tfor (const [key, value] of headers) add(key, value);\n\t} else {\n\t\tfor (const [key, value] of Object.entries(headers)) {\n\t\t\tif (value !== undefined) add(key, String(value));\n\t\t}\n\t}\n\treturn result;\n}\n"]}
@@ -1,4 +1,7 @@
1
1
  import type { Tool } from "../types.ts";
2
+ /** Convert a tool schema to the strict subset expected by provider constrained sampling. */
3
+ export declare function makeStrictJsonSchema(schema: Tool["parameters"]): Record<string, unknown>;
4
+ export declare function getJsonSchemaToolParameters(tool: Tool, strict: boolean | undefined): Tool["parameters"];
2
5
  export interface GrammarConstrainedSampling {
3
6
  format: "lark" | "regex";
4
7
  definition: string;
@@ -1 +1 @@
1
- {"version":3,"file":"constrained-sampling.d.ts","sourceRoot":"","sources":["../../src/api/constrained-sampling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAQxC,MAAM,WAAW,0BAA0B;IAC1C,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,mBAAmB,CAClC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,aAAa,EAAE,MAAM,GACnB,MAAM,CAMR;AAED,wBAAgB,+BAA+B,CAC9C,MAAM,EAAE,0BAA0B,EAClC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,GACZ,MAAM,GAAG,SAAS,CAyBpB;AAqBD,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAgB5G;AAED,wBAAgB,iCAAiC,CAChD,IAAI,EAAE,IAAI,EACV,0BAA0B,EAAE,OAAO,GACjC,0BAA0B,GAAG,SAAS,CA+BxC;AAED,wBAAgB,gCAAgC,CAC/C,KAAK,EAAE,IAAI,EAAE,GAAG,SAAS,EACzB,0BAA0B,EAAE,OAAO,GACjC,WAAW,CAAC,MAAM,EAAE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AAG,SAAS,EACzB,0BAA0B,EAAE,OAAO,GACjC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAS7B"}
@@ -1,3 +1,116 @@
1
+ class UnsupportedStrictJsonSchemaError extends Error {
2
+ }
3
+ const UNSUPPORTED_STRICT_SCHEMA_KEYS = [
4
+ "$ref",
5
+ "$defs",
6
+ "definitions",
7
+ "allOf",
8
+ "oneOf",
9
+ "patternProperties",
10
+ "dependentSchemas",
11
+ "dependencies",
12
+ "unevaluatedProperties",
13
+ "propertyNames",
14
+ "contains",
15
+ "prefixItems",
16
+ "not",
17
+ "if",
18
+ "then",
19
+ "else",
20
+ ];
21
+ function isJsonSchemaObject(value) {
22
+ return typeof value === "object" && value !== null && !Array.isArray(value);
23
+ }
24
+ function isStructuredSchema(schema) {
25
+ if (!isJsonSchemaObject(schema))
26
+ return false;
27
+ const types = typeof schema.type === "string" ? [schema.type] : Array.isArray(schema.type) ? schema.type : [];
28
+ return (types.includes("object") ||
29
+ types.includes("array") ||
30
+ schema.properties !== undefined ||
31
+ schema.items !== undefined);
32
+ }
33
+ function schemaAllowsNull(schema) {
34
+ if (!isJsonSchemaObject(schema))
35
+ return false;
36
+ if (schema.type === "null" || (Array.isArray(schema.type) && schema.type.includes("null")))
37
+ return true;
38
+ if (schema.const === null || (Array.isArray(schema.enum) && schema.enum.includes(null)))
39
+ return true;
40
+ return Array.isArray(schema.anyOf) && schema.anyOf.some((variant) => schemaAllowsNull(variant));
41
+ }
42
+ function makeJsonSchemaNodeStrict(schema) {
43
+ if (!isJsonSchemaObject(schema)) {
44
+ throw new UnsupportedStrictJsonSchemaError("boolean schemas are unsupported");
45
+ }
46
+ for (const key of UNSUPPORTED_STRICT_SCHEMA_KEYS) {
47
+ if (schema[key] !== undefined) {
48
+ throw new UnsupportedStrictJsonSchemaError(`${key} schemas are unsupported`);
49
+ }
50
+ }
51
+ if (schema.anyOf !== undefined) {
52
+ if (!Array.isArray(schema.anyOf) || schema.anyOf.length === 0) {
53
+ throw new UnsupportedStrictJsonSchemaError("anyOf must contain at least one schema");
54
+ }
55
+ for (const variant of schema.anyOf) {
56
+ if (isStructuredSchema(variant)) {
57
+ throw new UnsupportedStrictJsonSchemaError("object and array unions are unsupported");
58
+ }
59
+ makeJsonSchemaNodeStrict(variant);
60
+ }
61
+ }
62
+ if (schema.items !== undefined) {
63
+ if (Array.isArray(schema.items)) {
64
+ throw new UnsupportedStrictJsonSchemaError("tuple schemas are unsupported");
65
+ }
66
+ makeJsonSchemaNodeStrict(schema.items);
67
+ }
68
+ const isObjectSchema = schema.type === "object";
69
+ if (schema.properties !== undefined && !isObjectSchema) {
70
+ throw new UnsupportedStrictJsonSchemaError("properties require type object");
71
+ }
72
+ if (!isObjectSchema)
73
+ return;
74
+ if (schema.additionalProperties !== undefined && schema.additionalProperties !== false) {
75
+ throw new UnsupportedStrictJsonSchemaError("schema-valued or true additionalProperties is unsupported");
76
+ }
77
+ if (schema.properties !== undefined && !isJsonSchemaObject(schema.properties)) {
78
+ throw new UnsupportedStrictJsonSchemaError("object properties must be a schema map");
79
+ }
80
+ if (schema.required !== undefined &&
81
+ (!Array.isArray(schema.required) || schema.required.some((key) => typeof key !== "string"))) {
82
+ throw new UnsupportedStrictJsonSchemaError("object required must be a string array");
83
+ }
84
+ const properties = schema.properties ?? {};
85
+ const propertyNames = Object.keys(properties);
86
+ const required = new Set(Array.isArray(schema.required) ? schema.required : []);
87
+ if ([...required].some((key) => !propertyNames.includes(key))) {
88
+ throw new UnsupportedStrictJsonSchemaError("required contains an unknown property");
89
+ }
90
+ for (const [key, property] of Object.entries(properties)) {
91
+ makeJsonSchemaNodeStrict(property);
92
+ if (!required.has(key) && !schemaAllowsNull(property)) {
93
+ properties[key] = { anyOf: [property, { type: "null" }] };
94
+ }
95
+ }
96
+ schema.required = propertyNames;
97
+ schema.additionalProperties = false;
98
+ }
99
+ /** Convert a tool schema to the strict subset expected by provider constrained sampling. */
100
+ export function makeStrictJsonSchema(schema) {
101
+ const cloned = structuredClone(schema);
102
+ if (!isJsonSchemaObject(cloned)) {
103
+ throw new UnsupportedStrictJsonSchemaError("root schema must have type object");
104
+ }
105
+ makeJsonSchemaNodeStrict(cloned);
106
+ if (cloned.type !== "object") {
107
+ throw new UnsupportedStrictJsonSchemaError("root schema must have type object");
108
+ }
109
+ return cloned;
110
+ }
111
+ export function getJsonSchemaToolParameters(tool, strict) {
112
+ return (strict === true ? makeStrictJsonSchema(tool.parameters) : tool.parameters);
113
+ }
1
114
  export function getGrammarToolInput(toolName, arguments_, inputProperty) {
2
115
  const input = arguments_[inputProperty];
3
116
  if (typeof input !== "string") {
@@ -49,13 +162,20 @@ function inferGrammarInputProperty(tool) {
49
162
  }
50
163
  export function resolveJsonSchemaStrictSampling(tool, supportsStrictMode) {
51
164
  const config = tool.constrainedSampling;
52
- if (!config)
53
- return undefined;
54
- if (config.type !== "json_schema") {
165
+ if (config === false || config?.type !== "json_schema")
55
166
  return undefined;
56
- }
57
167
  if (supportsStrictMode) {
58
- return true;
168
+ try {
169
+ makeStrictJsonSchema(tool.parameters);
170
+ return true;
171
+ }
172
+ catch (error) {
173
+ if (!(error instanceof UnsupportedStrictJsonSchemaError))
174
+ throw error;
175
+ if (config.strict !== "require")
176
+ return undefined;
177
+ throw new Error(`Tool "${tool.name}" requires JSON-schema constrained sampling, but ${error.message}.`);
178
+ }
59
179
  }
60
180
  if (config.strict === "require") {
61
181
  throw new Error(`Tool "${tool.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`);
@@ -1 +1 @@
1
- {"version":3,"file":"constrained-sampling.js","sourceRoot":"","sources":["../../src/api/constrained-sampling.ts"],"names":[],"mappings":"AAoBA,MAAM,UAAU,mBAAmB,CAClC,QAAgB,EAChB,UAAmC,EACnC,aAAqB;IAErB,MAAM,KAAK,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,sBAAsB,Q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C,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,8CAA8C,OAAO,GAAG,CAAC,CAAC;IAC7F,CAAC;AACF,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC/C,KAAyB,EACzB,0BAAmC;IAEnC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7C,KAAK,MAAM,IAAI,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,iCAAiC,CAAC,IAAI,EAAE,0BAA0B,CAAC,CAAC;QACpF,IAAI,OAAO,EAAE,CAAC;YACb,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;QAClD,CAAC;IACF,CAAC;IACD,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["import type { Tool } from \"../types.ts\";\n\ninterface JsonSchemaObject {\n\ttype?: unknown;\n\tproperties?: Record<string, JsonSchemaObject | undefined>;\n\trequired?: unknown;\n}\n\nexport interface GrammarConstrainedSampling {\n\tformat: \"lark\" | \"regex\";\n\tdefinition: string;\n\tinputProperty: string;\n}\n\nexport interface GrammarToolInputJsonBuffer {\n\tinput: string;\n\tstarted: boolean;\n\tclosed: boolean;\n}\n\nexport function getGrammarToolInput(\n\ttoolName: string,\n\targuments_: Record<string, unknown>,\n\tinputProperty: string,\n): string {\n\tconst input = arguments_[inputProperty];\n\tif (typeof input !== \"string\") {\n\t\tthrow new Error(`Grammar tool call \"${toolName}\" requires argument \"${inputProperty}\" to be a string.`);\n\t}\n\treturn input;\n}\n\nexport function appendGrammarToolInputJsonDelta(\n\tbuffer: GrammarToolInputJsonBuffer,\n\tinputProperty: string,\n\tnextInput: string,\n\tclose: boolean,\n): string | undefined {\n\tif (buffer.closed) {\n\t\tif (close && nextInput === buffer.input) return undefined;\n\t\tthrow new Error(`grammar tool input for property \"${inputProperty}\" changed after it was closed`);\n\t}\n\tif (!nextInput.startsWith(buffer.input)) {\n\t\tthrow new Error(`grammar tool input for property \"${inputProperty}\" changed non-monotonically`);\n\t}\n\n\tconst inputDelta = nextInput.slice(buffer.input.length);\n\tif (!close && inputDelta.length === 0) return undefined;\n\n\tlet delta = \"\";\n\tif (!buffer.started) {\n\t\tdelta += `{${JSON.stringify(inputProperty)}:\"`;\n\t\tbuffer.started = true;\n\t}\n\tdelta += JSON.stringify(inputDelta).slice(1, -1);\n\tbuffer.input = nextInput;\n\n\tif (close) {\n\t\tdelta += '\"}';\n\t\tbuffer.closed = true;\n\t}\n\treturn delta;\n}\n\nfunction inferGrammarInputProperty(tool: Tool): string {\n\tconst schema = tool.parameters as JsonSchemaObject;\n\tif (schema.type !== \"object\") {\n\t\tthrow new Error(\"grammar constrained sampling requires an object parameter schema\");\n\t}\n\tif (!Array.isArray(schema.required) || schema.required.length !== 1 || typeof schema.required[0] !== \"string\") {\n\t\tthrow new Error(\"grammar constrained sampling requires exactly one required string property\");\n\t}\n\n\tconst inputProperty = schema.required[0];\n\tif (!schema.properties?.[inputProperty]) {\n\t\tthrow new Error(`grammar constrained sampling requires a properties entry for ${inputProperty}`);\n\t}\n\tif (schema.properties[inputProperty]?.type !== \"string\") {\n\t\tthrow new Error(`grammar constrained sampling property ${inputProperty} must have type string`);\n\t}\n\treturn inputProperty;\n}\n\nexport function resolveJsonSchemaStrictSampling(tool: Tool, supportsStrictMode: boolean): boolean | undefined {\n\tconst config = tool.constrainedSampling;\n\tif (!config) return undefined;\n\tif (config.type !== \"json_schema\") {\n\t\treturn undefined;\n\t}\n\n\tif (supportsStrictMode) {\n\t\treturn true;\n\t}\n\tif (config.strict === \"require\") {\n\t\tthrow new Error(\n\t\t\t`Tool \"${tool.name}\" requires JSON-schema constrained sampling, but strict tools are unsupported.`,\n\t\t);\n\t}\n\treturn undefined;\n}\n\nexport function resolveGrammarConstrainedSampling(\n\ttool: Tool,\n\tsupportsOpenAIGrammarTools: boolean,\n): GrammarConstrainedSampling | undefined {\n\tconst config = tool.constrainedSampling;\n\tif (!config) return undefined;\n\tif (config.type !== \"grammar\") {\n\t\treturn undefined;\n\t}\n\n\tif (!supportsOpenAIGrammarTools) {\n\t\treturn undefined;\n\t}\n\n\tconst larkDefinition = config.variants.openai_lark;\n\tconst regexDefinition = config.variants.openai_regex;\n\tconst hasLarkDefinition = typeof larkDefinition === \"string\" && larkDefinition.trim().length > 0;\n\tconst hasRegexDefinition = typeof regexDefinition === \"string\" && regexDefinition.trim().length > 0;\n\tif (!hasLarkDefinition && !hasRegexDefinition) {\n\t\tthrow new Error(\n\t\t\t`Tool \"${tool.name}\" cannot use grammar constrained sampling: no supported grammar variant was provided.`,\n\t\t);\n\t}\n\n\ttry {\n\t\treturn {\n\t\t\tformat: hasLarkDefinition ? \"lark\" : \"regex\",\n\t\t\tdefinition: hasLarkDefinition ? larkDefinition : regexDefinition!,\n\t\t\tinputProperty: inferGrammarInputProperty(tool),\n\t\t};\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`Tool \"${tool.name}\" cannot use grammar constrained sampling: ${message}.`);\n\t}\n}\n\nexport function createGrammarToolInputProperties(\n\ttools: Tool[] | undefined,\n\tsupportsOpenAIGrammarTools: boolean,\n): ReadonlyMap<string, string> {\n\tconst properties = new Map<string, string>();\n\tfor (const tool of tools ?? []) {\n\t\tconst grammar = resolveGrammarConstrainedSampling(tool, supportsOpenAIGrammarTools);\n\t\tif (grammar) {\n\t\t\tproperties.set(tool.name, grammar.inputProperty);\n\t\t}\n\t}\n\treturn properties;\n}\n"]}
1
+ {"version":3,"file":"constrained-sampling.js","sourceRoot":"","sources":["../../src/api/constrained-sampling.ts"],"names":[],"mappings":"AASA,MAAM,gCAAiC,SAAQ,KAAK;CAAG;AAEvD,MAAM,8BAA8B,GAAG;IACtC,MAAM;IACN,OAAO;IACP,aAAa;IACb,OAAO;IACP,OAAO;IACP,mBAAm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C;AACnB,CAAC","sourcesContent":["import type { Tool } from \"../types.ts\";\n\ninterface JsonSchemaObject {\n\t[key: string]: unknown;\n\ttype?: unknown;\n\tproperties?: Record<string, JsonSchemaObject | undefined>;\n\trequired?: unknown;\n}\n\nclass UnsupportedStrictJsonSchemaError extends Error {}\n\nconst UNSUPPORTED_STRICT_SCHEMA_KEYS = [\n\t\"$ref\",\n\t\"$defs\",\n\t\"definitions\",\n\t\"allOf\",\n\t\"oneOf\",\n\t\"patternProperties\",\n\t\"dependentSchemas\",\n\t\"dependencies\",\n\t\"unevaluatedProperties\",\n\t\"propertyNames\",\n\t\"contains\",\n\t\"prefixItems\",\n\t\"not\",\n\t\"if\",\n\t\"then\",\n\t\"else\",\n] as const;\n\nfunction isJsonSchemaObject(value: unknown): value is JsonSchemaObject {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isStructuredSchema(schema: unknown): boolean {\n\tif (!isJsonSchemaObject(schema)) return false;\n\tconst types = typeof schema.type === \"string\" ? [schema.type] : Array.isArray(schema.type) ? schema.type : [];\n\treturn (\n\t\ttypes.includes(\"object\") ||\n\t\ttypes.includes(\"array\") ||\n\t\tschema.properties !== undefined ||\n\t\tschema.items !== undefined\n\t);\n}\n\nfunction schemaAllowsNull(schema: unknown): boolean {\n\tif (!isJsonSchemaObject(schema)) return false;\n\tif (schema.type === \"null\" || (Array.isArray(schema.type) && schema.type.includes(\"null\"))) return true;\n\tif (schema.const === null || (Array.isArray(schema.enum) && schema.enum.includes(null))) return true;\n\treturn Array.isArray(schema.anyOf) && schema.anyOf.some((variant) => schemaAllowsNull(variant));\n}\n\nfunction makeJsonSchemaNodeStrict(schema: unknown): void {\n\tif (!isJsonSchemaObject(schema)) {\n\t\tthrow new UnsupportedStrictJsonSchemaError(\"boolean schemas are unsupported\");\n\t}\n\tfor (const key of UNSUPPORTED_STRICT_SCHEMA_KEYS) {\n\t\tif (schema[key] !== undefined) {\n\t\t\tthrow new UnsupportedStrictJsonSchemaError(`${key} schemas are unsupported`);\n\t\t}\n\t}\n\n\tif (schema.anyOf !== undefined) {\n\t\tif (!Array.isArray(schema.anyOf) || schema.anyOf.length === 0) {\n\t\t\tthrow new UnsupportedStrictJsonSchemaError(\"anyOf must contain at least one schema\");\n\t\t}\n\t\tfor (const variant of schema.anyOf) {\n\t\t\tif (isStructuredSchema(variant)) {\n\t\t\t\tthrow new UnsupportedStrictJsonSchemaError(\"object and array unions are unsupported\");\n\t\t\t}\n\t\t\tmakeJsonSchemaNodeStrict(variant);\n\t\t}\n\t}\n\n\tif (schema.items !== undefined) {\n\t\tif (Array.isArray(schema.items)) {\n\t\t\tthrow new UnsupportedStrictJsonSchemaError(\"tuple schemas are unsupported\");\n\t\t}\n\t\tmakeJsonSchemaNodeStrict(schema.items);\n\t}\n\n\tconst isObjectSchema = schema.type === \"object\";\n\tif (schema.properties !== undefined && !isObjectSchema) {\n\t\tthrow new UnsupportedStrictJsonSchemaError(\"properties require type object\");\n\t}\n\tif (!isObjectSchema) return;\n\tif (schema.additionalProperties !== undefined && schema.additionalProperties !== false) {\n\t\tthrow new UnsupportedStrictJsonSchemaError(\"schema-valued or true additionalProperties is unsupported\");\n\t}\n\tif (schema.properties !== undefined && !isJsonSchemaObject(schema.properties)) {\n\t\tthrow new UnsupportedStrictJsonSchemaError(\"object properties must be a schema map\");\n\t}\n\tif (\n\t\tschema.required !== undefined &&\n\t\t(!Array.isArray(schema.required) || schema.required.some((key) => typeof key !== \"string\"))\n\t) {\n\t\tthrow new UnsupportedStrictJsonSchemaError(\"object required must be a string array\");\n\t}\n\n\tconst properties = schema.properties ?? {};\n\tconst propertyNames = Object.keys(properties);\n\tconst required = new Set(Array.isArray(schema.required) ? schema.required : []);\n\tif ([...required].some((key) => !propertyNames.includes(key))) {\n\t\tthrow new UnsupportedStrictJsonSchemaError(\"required contains an unknown property\");\n\t}\n\tfor (const [key, property] of Object.entries(properties)) {\n\t\tmakeJsonSchemaNodeStrict(property);\n\t\tif (!required.has(key) && !schemaAllowsNull(property)) {\n\t\t\tproperties[key] = { anyOf: [property, { type: \"null\" }] };\n\t\t}\n\t}\n\tschema.required = propertyNames;\n\tschema.additionalProperties = false;\n}\n\n/** Convert a tool schema to the strict subset expected by provider constrained sampling. */\nexport function makeStrictJsonSchema(schema: Tool[\"parameters\"]): Record<string, unknown> {\n\tconst cloned: unknown = structuredClone(schema);\n\tif (!isJsonSchemaObject(cloned)) {\n\t\tthrow new UnsupportedStrictJsonSchemaError(\"root schema must have type object\");\n\t}\n\tmakeJsonSchemaNodeStrict(cloned);\n\tif (cloned.type !== \"object\") {\n\t\tthrow new UnsupportedStrictJsonSchemaError(\"root schema must have type object\");\n\t}\n\treturn cloned;\n}\n\nexport function getJsonSchemaToolParameters(tool: Tool, strict: boolean | undefined): Tool[\"parameters\"] {\n\treturn (strict === true ? makeStrictJsonSchema(tool.parameters) : tool.parameters) as Tool[\"parameters\"];\n}\n\nexport interface GrammarConstrainedSampling {\n\tformat: \"lark\" | \"regex\";\n\tdefinition: string;\n\tinputProperty: string;\n}\n\nexport interface GrammarToolInputJsonBuffer {\n\tinput: string;\n\tstarted: boolean;\n\tclosed: boolean;\n}\n\nexport function getGrammarToolInput(\n\ttoolName: string,\n\targuments_: Record<string, unknown>,\n\tinputProperty: string,\n): string {\n\tconst input = arguments_[inputProperty];\n\tif (typeof input !== \"string\") {\n\t\tthrow new Error(`Grammar tool call \"${toolName}\" requires argument \"${inputProperty}\" to be a string.`);\n\t}\n\treturn input;\n}\n\nexport function appendGrammarToolInputJsonDelta(\n\tbuffer: GrammarToolInputJsonBuffer,\n\tinputProperty: string,\n\tnextInput: string,\n\tclose: boolean,\n): string | undefined {\n\tif (buffer.closed) {\n\t\tif (close && nextInput === buffer.input) return undefined;\n\t\tthrow new Error(`grammar tool input for property \"${inputProperty}\" changed after it was closed`);\n\t}\n\tif (!nextInput.startsWith(buffer.input)) {\n\t\tthrow new Error(`grammar tool input for property \"${inputProperty}\" changed non-monotonically`);\n\t}\n\n\tconst inputDelta = nextInput.slice(buffer.input.length);\n\tif (!close && inputDelta.length === 0) return undefined;\n\n\tlet delta = \"\";\n\tif (!buffer.started) {\n\t\tdelta += `{${JSON.stringify(inputProperty)}:\"`;\n\t\tbuffer.started = true;\n\t}\n\tdelta += JSON.stringify(inputDelta).slice(1, -1);\n\tbuffer.input = nextInput;\n\n\tif (close) {\n\t\tdelta += '\"}';\n\t\tbuffer.closed = true;\n\t}\n\treturn delta;\n}\n\nfunction inferGrammarInputProperty(tool: Tool): string {\n\tconst schema = tool.parameters as JsonSchemaObject;\n\tif (schema.type !== \"object\") {\n\t\tthrow new Error(\"grammar constrained sampling requires an object parameter schema\");\n\t}\n\tif (!Array.isArray(schema.required) || schema.required.length !== 1 || typeof schema.required[0] !== \"string\") {\n\t\tthrow new Error(\"grammar constrained sampling requires exactly one required string property\");\n\t}\n\n\tconst inputProperty = schema.required[0];\n\tif (!schema.properties?.[inputProperty]) {\n\t\tthrow new Error(`grammar constrained sampling requires a properties entry for ${inputProperty}`);\n\t}\n\tif (schema.properties[inputProperty]?.type !== \"string\") {\n\t\tthrow new Error(`grammar constrained sampling property ${inputProperty} must have type string`);\n\t}\n\treturn inputProperty;\n}\n\nexport function resolveJsonSchemaStrictSampling(tool: Tool, supportsStrictMode: boolean): boolean | undefined {\n\tconst config = tool.constrainedSampling;\n\tif (config === false || config?.type !== \"json_schema\") return undefined;\n\n\tif (supportsStrictMode) {\n\t\ttry {\n\t\t\tmakeStrictJsonSchema(tool.parameters);\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof UnsupportedStrictJsonSchemaError)) throw error;\n\t\t\tif (config.strict !== \"require\") return undefined;\n\t\t\tthrow new Error(`Tool \"${tool.name}\" requires JSON-schema constrained sampling, but ${error.message}.`);\n\t\t}\n\t}\n\tif (config.strict === \"require\") {\n\t\tthrow new Error(\n\t\t\t`Tool \"${tool.name}\" requires JSON-schema constrained sampling, but strict tools are unsupported.`,\n\t\t);\n\t}\n\treturn undefined;\n}\n\nexport function resolveGrammarConstrainedSampling(\n\ttool: Tool,\n\tsupportsOpenAIGrammarTools: boolean,\n): GrammarConstrainedSampling | undefined {\n\tconst config = tool.constrainedSampling;\n\tif (!config) return undefined;\n\tif (config.type !== \"grammar\") {\n\t\treturn undefined;\n\t}\n\n\tif (!supportsOpenAIGrammarTools) {\n\t\treturn undefined;\n\t}\n\n\tconst larkDefinition = config.variants.openai_lark;\n\tconst regexDefinition = config.variants.openai_regex;\n\tconst hasLarkDefinition = typeof larkDefinition === \"string\" && larkDefinition.trim().length > 0;\n\tconst hasRegexDefinition = typeof regexDefinition === \"string\" && regexDefinition.trim().length > 0;\n\tif (!hasLarkDefinition && !hasRegexDefinition) {\n\t\tthrow new Error(\n\t\t\t`Tool \"${tool.name}\" cannot use grammar constrained sampling: no supported grammar variant was provided.`,\n\t\t);\n\t}\n\n\ttry {\n\t\treturn {\n\t\t\tformat: hasLarkDefinition ? \"lark\" : \"regex\",\n\t\t\tdefinition: hasLarkDefinition ? larkDefinition : regexDefinition!,\n\t\t\tinputProperty: inferGrammarInputProperty(tool),\n\t\t};\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`Tool \"${tool.name}\" cannot use grammar constrained sampling: ${message}.`);\n\t}\n}\n\nexport function createGrammarToolInputProperties(\n\ttools: Tool[] | undefined,\n\tsupportsOpenAIGrammarTools: boolean,\n): ReadonlyMap<string, string> {\n\tconst properties = new Map<string, string>();\n\tfor (const tool of tools ?? []) {\n\t\tconst grammar = resolveGrammarConstrainedSampling(tool, supportsOpenAIGrammarTools);\n\t\tif (grammar) {\n\t\t\tproperties.set(tool.name, grammar.inputProperty);\n\t\t}\n\t}\n\treturn properties;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A UUID-shaped string: five hex groups in the canonical 8-4-4-4-12 layout.
3
+ *
4
+ * NOT a spec-compliant RFC 4122 UUID — the version/variant nibbles are left as
5
+ * raw hash output — but the shape passes everywhere a UUID string is expected.
6
+ */
7
+ export type DeterministicUuid = `${string}-${string}-${string}-${string}-${string}`;
8
+ /**
9
+ * Format the leading 128 bits of `seed`'s SHA-256 digest as a v4-shape UUID
10
+ * (8-4-4-4-12 hex groups).
11
+ *
12
+ * Deterministic: identical seeds always map to the same id, so callers get
13
+ * stable ids across requests / conversation turns (reusing message-blob ids,
14
+ * keying prompt caches) without persisting a seed→id mapping.
15
+ */
16
+ export declare function deterministicUuid(seed: string): DeterministicUuid;
17
+ //# sourceMappingURL=deterministic-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deterministic-id.d.ts","sourceRoot":"","sources":["../../../src/api/cursor-agent/deterministic-id.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;AAEpF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAGjE"}
@@ -0,0 +1,14 @@
1
+ import { createHash } from "node:crypto";
2
+ /**
3
+ * Format the leading 128 bits of `seed`'s SHA-256 digest as a v4-shape UUID
4
+ * (8-4-4-4-12 hex groups).
5
+ *
6
+ * Deterministic: identical seeds always map to the same id, so callers get
7
+ * stable ids across requests / conversation turns (reusing message-blob ids,
8
+ * keying prompt caches) without persisting a seed→id mapping.
9
+ */
10
+ export function deterministicUuid(seed) {
11
+ const hex = createHash("sha256").update(seed).digest("hex");
12
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
13
+ }
14
+ //# sourceMappingURL=deterministic-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deterministic-id.js","sourceRoot":"","sources":["../../../src/api/cursor-agent/deterministic-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAUzC;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC7C,MAAM,GAAG,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5D,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;AAChH,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\n\n/**\n * A UUID-shaped string: five hex groups in the canonical 8-4-4-4-12 layout.\n *\n * NOT a spec-compliant RFC 4122 UUID — the version/variant nibbles are left as\n * raw hash output — but the shape passes everywhere a UUID string is expected.\n */\nexport type DeterministicUuid = `${string}-${string}-${string}-${string}-${string}`;\n\n/**\n * Format the leading 128 bits of `seed`'s SHA-256 digest as a v4-shape UUID\n * (8-4-4-4-12 hex groups).\n *\n * Deterministic: identical seeds always map to the same id, so callers get\n * stable ids across requests / conversation turns (reusing message-blob ids,\n * keying prompt caches) without persisting a seed→id mapping.\n */\nexport function deterministicUuid(seed: string): DeterministicUuid {\n\tconst hex = createHash(\"sha256\").update(seed).digest(\"hex\");\n\treturn `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ export type ExecHeartbeatOptions = {
2
+ readonly intervalMs: number;
3
+ readonly isClosed: () => boolean;
4
+ readonly writeHeartbeat: (onComplete: (error?: Error | null) => void) => void;
5
+ };
6
+ /**
7
+ * Arm one exec-scoped heartbeat at a time.
8
+ *
9
+ * The next timer starts only after the current write callback succeeds, so a
10
+ * slow HTTP/2 write can never accumulate overlapping heartbeat frames.
11
+ */
12
+ export declare function armExecHeartbeat(options: ExecHeartbeatOptions): () => void;
13
+ //# sourceMappingURL=exec-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/api/cursor-agent/exec-lifecycle.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,KAAK,IAAI,CAAC;CAC9E,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,IAAI,CAwB1E"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Arm one exec-scoped heartbeat at a time.
3
+ *
4
+ * The next timer starts only after the current write callback succeeds, so a
5
+ * slow HTTP/2 write can never accumulate overlapping heartbeat frames.
6
+ */
7
+ export function armExecHeartbeat(options) {
8
+ let active = true;
9
+ let timer;
10
+ const schedule = () => {
11
+ if (!active || options.isClosed())
12
+ return;
13
+ timer = setTimeout(() => {
14
+ timer = undefined;
15
+ if (!active || options.isClosed())
16
+ return;
17
+ options.writeHeartbeat((error) => {
18
+ if (error || !active || options.isClosed())
19
+ return;
20
+ schedule();
21
+ });
22
+ }, options.intervalMs);
23
+ };
24
+ schedule();
25
+ return () => {
26
+ active = false;
27
+ if (timer !== undefined) {
28
+ clearTimeout(timer);
29
+ timer = undefined;
30
+ }
31
+ };
32
+ }
33
+ //# sourceMappingURL=exec-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec-lifecycle.js","sourceRoot":"","sources":["../../../src/api/cursor-agent/exec-lifecycle.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAA6B;IAC7D,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,KAAiC,CAAC;IAEtC,MAAM,QAAQ,GAAG,GAAG,EAAE;QACrB,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,QAAQ,EAAE;YAAE,OAAO;QAC1C,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACvB,KAAK,GAAG,SAAS,CAAC;YAClB,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,QAAQ,EAAE;gBAAE,OAAO;YAC1C,OAAO,CAAC,cAAc,CAAC,CAAC,KAAK,EAAE,EAAE;gBAChC,IAAI,KAAK,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,QAAQ,EAAE;oBAAE,OAAO;gBACnD,QAAQ,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACJ,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACxB,CAAC,CAAC;IAEF,QAAQ,EAAE,CAAC;IACX,OAAO,GAAG,EAAE;QACX,MAAM,GAAG,KAAK,CAAC;QACf,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,KAAK,GAAG,SAAS,CAAC;QACnB,CAAC;IACF,CAAC,CAAC;AACH,CAAC","sourcesContent":["export type ExecHeartbeatOptions = {\n\treadonly intervalMs: number;\n\treadonly isClosed: () => boolean;\n\treadonly writeHeartbeat: (onComplete: (error?: Error | null) => void) => void;\n};\n\n/**\n * Arm one exec-scoped heartbeat at a time.\n *\n * The next timer starts only after the current write callback succeeds, so a\n * slow HTTP/2 write can never accumulate overlapping heartbeat frames.\n */\nexport function armExecHeartbeat(options: ExecHeartbeatOptions): () => void {\n\tlet active = true;\n\tlet timer: NodeJS.Timeout | undefined;\n\n\tconst schedule = () => {\n\t\tif (!active || options.isClosed()) return;\n\t\ttimer = setTimeout(() => {\n\t\t\ttimer = undefined;\n\t\t\tif (!active || options.isClosed()) return;\n\t\t\toptions.writeHeartbeat((error) => {\n\t\t\t\tif (error || !active || options.isClosed()) return;\n\t\t\t\tschedule();\n\t\t\t});\n\t\t}, options.intervalMs);\n\t};\n\n\tschedule();\n\treturn () => {\n\t\tactive = false;\n\t\tif (timer !== undefined) {\n\t\t\tclearTimeout(timer);\n\t\t\ttimer = undefined;\n\t\t}\n\t};\n}\n"]}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Proto builders for the modern Cursor CLI exec frames (`ExecServerMessage`
3
+ * 27-31, 36-38, 40-55).
4
+ *
5
+ * Split out of `cursor-agent.ts` because these are pure `create(...)` shapes
6
+ * with no transport, stream, or block-state coupling: the dispatcher decides
7
+ * *which* answer a frame gets, this module knows *what* that answer looks
8
+ * like on the wire. Every builder returns a result whose oneof case is set —
9
+ * an `ExecClientMessage` carrying a result with an unset oneof is a fake
10
+ * success the server reads as "the tool ran and produced nothing".
11
+ */
12
+ import type { ToolResultMessage } from "../../types.ts";
13
+ import { type ExecuteHookRequest, type ExecuteHookResult, type McpStateExecResult, type McpToolDefinition, type PiBashExecResult, type PiEditExecResult, type PiFindExecResult, type PiGrepExecResult, type PiLsExecResult, type PiReadExecResult, type PiTruncation, type PiWriteExecResult } from "./gen/agent_pb.ts";
14
+ /** Flatten a tool result's content into the single `output` string the Pi frames carry. */
15
+ export declare function piOutputText(toolResult: ToolResultMessage): string;
16
+ /**
17
+ * Translate a local tool's truncation summary into `PiTruncation`.
18
+ *
19
+ * Two shapes reach here: `details.truncation` (carries an explicit
20
+ * `truncated` boolean) and `details.meta.truncation` (whose presence *is* the
21
+ * signal). Returns `undefined` when nothing was truncated: the field is
22
+ * `optional` on every Pi success message, and emitting a zeroed
23
+ * `PiTruncation` would tell the server the output was trimmed to nothing.
24
+ */
25
+ export declare function piTruncation(toolResult: ToolResultMessage): PiTruncation | undefined;
26
+ export declare function buildPiReadResult(toolResult: ToolResultMessage): PiReadExecResult;
27
+ export declare function buildPiReadError(error: string): PiReadExecResult;
28
+ export declare function buildPiBashResult(toolResult: ToolResultMessage): PiBashExecResult;
29
+ export declare function buildPiBashError(error: string): PiBashExecResult;
30
+ /**
31
+ * `PiEditExecSuccess` requires `diff` and `patch` alongside `output`. The
32
+ * local `edit` tool reports them under `details`; when it does not, the
33
+ * strings stay empty rather than being faked from the output text.
34
+ */
35
+ export declare function buildPiEditResult(toolResult: ToolResultMessage): PiEditExecResult;
36
+ export declare function buildPiEditError(error: string): PiEditExecResult;
37
+ /**
38
+ * A refusal is not an execution failure: `PiEditExecResult` models them as
39
+ * separate variants, and answering a denied call with `error` reads as "the
40
+ * edit ran and broke", which invites a retry of an operation that was never
41
+ * permitted.
42
+ */
43
+ export declare function buildPiEditRejected(reason: string): PiEditExecResult;
44
+ export declare function buildPiWriteResult(toolResult: ToolResultMessage): PiWriteExecResult;
45
+ export declare function buildPiWriteError(error: string): PiWriteExecResult;
46
+ /** Same variant split as {@link buildPiEditRejected}. */
47
+ export declare function buildPiWriteRejected(reason: string): PiWriteExecResult;
48
+ export declare function buildPiGrepResult(toolResult: ToolResultMessage): PiGrepExecResult;
49
+ export declare function buildPiGrepError(error: string): PiGrepExecResult;
50
+ export declare function buildPiFindResult(toolResult: ToolResultMessage): PiFindExecResult;
51
+ export declare function buildPiFindError(error: string): PiFindExecResult;
52
+ export declare function buildPiLsResult(toolResult: ToolResultMessage): PiLsExecResult;
53
+ export declare function buildPiLsError(error: string): PiLsExecResult;
54
+ /**
55
+ * Answer `mcpStateExecArgs` (frame 36) from the catalog already advertised in
56
+ * `RequestContext.tools`.
57
+ *
58
+ * This client hosts no MCP servers of its own: every forwarded tool is a
59
+ * local tool published under a synthetic `providerIdentifier`. Regrouping the
60
+ * same list keeps the server's view of "which servers exist and what do they
61
+ * expose" consistent with what it was told at context time.
62
+ *
63
+ * `serverIdentifiers` filters the answer when the server asks about specific
64
+ * servers. A restart request is answered with the same state rather than an
65
+ * error — there is nothing to restart.
66
+ */
67
+ export declare function buildMcpStateResult(tools: McpToolDefinition[], serverIdentifiers: readonly string[]): McpStateExecResult;
68
+ /**
69
+ * Build the neutral response for a hook query: the matching response case
70
+ * with every field unset.
71
+ *
72
+ * This client runs no Cursor hooks, and every field of every response variant
73
+ * is `optional` — so an empty response of the right case means "no hook had
74
+ * anything to say", which is exactly true. Returns `null` for a request case
75
+ * this build does not model, which the dispatcher answers with
76
+ * `ExecClientThrow` rather than guessing a case.
77
+ */
78
+ export declare function buildNeutralHookResult(request: ExecuteHookRequest | undefined): ExecuteHookResult | null;
79
+ //# sourceMappingURL=exec-modern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec-modern.d.ts","sourceRoot":"","sources":["../../../src/api/cursor-agent/exec-modern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAIN,KAAK,kBAAkB,EAGvB,KAAK,iBAAiB,EAEtB,KAAK,kBAAkB,EAIvB,KAAK,iBAAiB,EAEtB,KAAK,gBAAgB,EAKrB,KAAK,gBAAgB,EAIrB,KAAK,gBAAgB,EAIrB,KAAK,gBAAgB,EAIrB,KAAK,cAAc,EAInB,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAIjB,KAAK,iBAAiB,EAUtB,MAAM,mBAAmB,CAAC;AAE3B,2FAA2F;AAC3F,wBAAgB,YAAY,CAAC,UAAU,EAAE,iBAAiB,GAAG,MAAM,CAElE;AA6BD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,iBAAiB,GAAG,YAAY,GAAG,SAAS,CAmBpF;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,iBAAiB,GAAG,gBAAgB,CASjF;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAIhE;AAED,wB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