indusagi 0.12.32 → 0.12.33

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 (1135) hide show
  1. package/CHANGELOG.md +329 -0
  2. package/CREDITS.md +22 -0
  3. package/NOTICE +17 -0
  4. package/README.md +47 -388
  5. package/dist/agent.js +27512 -0
  6. package/dist/ai.js +19758 -0
  7. package/dist/capabilities.js +2663 -0
  8. package/dist/cli.js +10399 -0
  9. package/dist/connectors-saas.js +3289 -0
  10. package/dist/index.js +15279 -0
  11. package/dist/interop.js +3181 -0
  12. package/dist/knowledge/guides/authoring-an-agent.md +53 -0
  13. package/dist/knowledge/guides/choosing-tools.md +49 -0
  14. package/dist/knowledge/guides/model-selection.md +51 -0
  15. package/dist/knowledge/guides/writing-system-prompts.md +53 -0
  16. package/dist/knowledge/index.ts +19 -0
  17. package/dist/knowledge/loader.ts +200 -0
  18. package/dist/knowledge/manifest.json +29 -0
  19. package/dist/llmgateway.js +3209 -0
  20. package/dist/mcp.js +1732 -0
  21. package/dist/memory.js +0 -0
  22. package/dist/react-host/index.js +101 -0
  23. package/dist/react-host/ink.js +97 -0
  24. package/dist/react-host/jsx-runtime.js +95 -0
  25. package/dist/react-ink.js +2475 -0
  26. package/dist/runtime.js +4387 -0
  27. package/dist/shell-app.js +10968 -0
  28. package/dist/smithy.js +7932 -0
  29. package/dist/swarm.js +8717 -0
  30. package/dist/tracing.js +724 -0
  31. package/dist/tui.js +2213 -0
  32. package/dist/types/capabilities/backends/index.d.ts +10 -0
  33. package/dist/types/capabilities/backends/node-backends.d.ts +28 -0
  34. package/dist/types/capabilities/capabilities.test.d.ts +14 -0
  35. package/dist/types/capabilities/files/diff.d.ts +49 -0
  36. package/dist/types/capabilities/files/edit.d.ts +21 -0
  37. package/dist/types/capabilities/files/ls.d.ts +16 -0
  38. package/dist/types/capabilities/files/read.d.ts +15 -0
  39. package/dist/types/capabilities/files/write.d.ts +16 -0
  40. package/dist/types/capabilities/index.d.ts +29 -0
  41. package/dist/types/capabilities/kernel/backends.d.ts +119 -0
  42. package/dist/types/capabilities/kernel/context.d.ts +48 -0
  43. package/dist/types/capabilities/kernel/index.d.ts +24 -0
  44. package/dist/types/capabilities/kernel/output.d.ts +40 -0
  45. package/dist/types/capabilities/kernel/registry.d.ts +61 -0
  46. package/dist/types/capabilities/kernel/spec.d.ts +113 -0
  47. package/dist/types/capabilities/planning/todo.d.ts +62 -0
  48. package/dist/types/capabilities/registry.d.ts +44 -0
  49. package/dist/types/capabilities/search/find.d.ts +33 -0
  50. package/dist/types/capabilities/search/grep.d.ts +30 -0
  51. package/dist/types/capabilities/shell/bash.d.ts +18 -0
  52. package/dist/types/capabilities/shell/process.d.ts +33 -0
  53. package/dist/types/capabilities/web/webfetch.d.ts +25 -0
  54. package/dist/types/capabilities/web/websearch.d.ts +23 -0
  55. package/dist/types/connectors-saas/connectors-saas.test.d.ts +12 -0
  56. package/dist/types/connectors-saas/index.d.ts +16 -0
  57. package/dist/types/connectors-saas/saas/adapter/composio-backend.d.ts +60 -0
  58. package/dist/types/connectors-saas/saas/control/connect.d.ts +114 -0
  59. package/dist/types/connectors-saas/saas/control/tools.d.ts +67 -0
  60. package/dist/types/connectors-saas/saas/core/builder.d.ts +86 -0
  61. package/dist/types/connectors-saas/saas/core/cache.d.ts +53 -0
  62. package/dist/types/connectors-saas/saas/core/index.d.ts +14 -0
  63. package/dist/types/connectors-saas/saas/core/port.d.ts +157 -0
  64. package/dist/types/connectors-saas/saas/core/scope-planner.d.ts +74 -0
  65. package/dist/types/connectors-saas/saas/gateway.d.ts +133 -0
  66. package/dist/types/connectors-saas/saas/render/format.d.ts +54 -0
  67. package/dist/types/connectors-saas/saas/render/index.d.ts +19 -0
  68. package/dist/types/connectors-saas/saas/render/summarizers.d.ts +58 -0
  69. package/dist/types/facade/agent.d.ts +1 -0
  70. package/dist/types/facade/ai.d.ts +1 -0
  71. package/dist/types/facade/bot/actions/bash.d.ts +56 -0
  72. package/dist/types/facade/bot/actions/composio/accounts.d.ts +22 -0
  73. package/dist/types/facade/bot/actions/composio/client.d.ts +39 -0
  74. package/dist/types/facade/bot/actions/composio/connect.d.ts +19 -0
  75. package/dist/types/facade/bot/actions/composio/enable.d.ts +25 -0
  76. package/dist/types/facade/bot/actions/composio/execute.d.ts +26 -0
  77. package/dist/types/facade/bot/actions/composio/helpers.d.ts +16 -0
  78. package/dist/types/facade/bot/actions/composio/index.d.ts +9 -0
  79. package/dist/types/facade/bot/actions/composio/provider.d.ts +8 -0
  80. package/dist/types/facade/bot/actions/composio/toolkits.d.ts +22 -0
  81. package/dist/types/facade/bot/actions/composio/tools.d.ts +28 -0
  82. package/dist/types/facade/bot/actions/composio/types.d.ts +137 -0
  83. package/dist/types/facade/bot/actions/crew/activity-tracker.d.ts +65 -0
  84. package/dist/types/facade/bot/actions/crew/cleanup.d.ts +50 -0
  85. package/dist/types/facade/bot/actions/crew/fs-lock.d.ts +11 -0
  86. package/dist/types/facade/bot/actions/crew/index.d.ts +11 -0
  87. package/dist/types/facade/bot/actions/crew/mailbox.d.ts +20 -0
  88. package/dist/types/facade/bot/actions/crew/model-policy.d.ts +22 -0
  89. package/dist/types/facade/bot/actions/crew/names.d.ts +27 -0
  90. package/dist/types/facade/bot/actions/crew/protocol.d.ts +74 -0
  91. package/dist/types/facade/bot/actions/crew/task-store.d.ts +88 -0
  92. package/dist/types/facade/bot/actions/crew/team-attach-claim.d.ts +35 -0
  93. package/dist/types/facade/bot/actions/crew/team-config.d.ts +54 -0
  94. package/dist/types/facade/bot/actions/crew/worktree.d.ts +39 -0
  95. package/dist/types/facade/bot/actions/edit-diff.d.ts +66 -0
  96. package/dist/types/facade/bot/actions/edit.d.ts +41 -0
  97. package/dist/types/facade/bot/actions/find.d.ts +25 -0
  98. package/dist/types/facade/bot/actions/grep.d.ts +43 -0
  99. package/dist/types/facade/bot/actions/index.d.ts +300 -0
  100. package/dist/types/facade/bot/actions/kit/hook-runner.d.ts +12 -0
  101. package/dist/types/facade/bot/actions/kit/image-resize.d.ts +19 -0
  102. package/dist/types/facade/bot/actions/kit/mime.d.ts +1 -0
  103. package/dist/types/facade/bot/actions/kit/shell.d.ts +12 -0
  104. package/dist/types/facade/bot/actions/ls.d.ts +41 -0
  105. package/dist/types/facade/bot/actions/path-utils.d.ts +8 -0
  106. package/dist/types/facade/bot/actions/process-controller.d.ts +14 -0
  107. package/dist/types/facade/bot/actions/process-manager.d.ts +59 -0
  108. package/dist/types/facade/bot/actions/process-types.d.ts +73 -0
  109. package/dist/types/facade/bot/actions/process.d.ts +37 -0
  110. package/dist/types/facade/bot/actions/read.d.ts +36 -0
  111. package/dist/types/facade/bot/actions/registry.d.ts +20 -0
  112. package/dist/types/facade/bot/actions/todo-store.d.ts +76 -0
  113. package/dist/types/facade/bot/actions/todo-types.d.ts +72 -0
  114. package/dist/types/facade/bot/actions/todo.d.ts +76 -0
  115. package/dist/types/facade/bot/actions/truncate.d.ts +78 -0
  116. package/dist/types/facade/bot/actions/webfetch.d.ts +35 -0
  117. package/dist/types/facade/bot/actions/websearch.d.ts +34 -0
  118. package/dist/types/facade/bot/actions/write.d.ts +30 -0
  119. package/dist/types/facade/bot/agent-loop.d.ts +20 -0
  120. package/dist/types/facade/bot/agent.d.ts +132 -0
  121. package/dist/types/facade/bot/error-handler.d.ts +7 -0
  122. package/dist/types/facade/bot/event-bus.d.ts +8 -0
  123. package/dist/types/facade/bot/index.d.ts +7 -0
  124. package/dist/types/facade/bot/messages.d.ts +83 -0
  125. package/dist/types/facade/bot/proxy.d.ts +70 -0
  126. package/dist/types/facade/bot/session-manager.d.ts +409 -0
  127. package/dist/types/facade/bot/state-manager.d.ts +21 -0
  128. package/dist/types/facade/bot/telemetry.d.ts +6 -0
  129. package/dist/types/facade/bot/types.d.ts +207 -0
  130. package/dist/types/facade/mcp-core/client-pool.d.ts +105 -0
  131. package/dist/types/facade/mcp-core/client.d.ts +157 -0
  132. package/dist/types/facade/mcp-core/config.d.ts +60 -0
  133. package/dist/types/facade/mcp-core/errors.d.ts +103 -0
  134. package/dist/types/facade/mcp-core/index.d.ts +55 -0
  135. package/dist/types/facade/mcp-core/schema-converter.d.ts +67 -0
  136. package/dist/types/facade/mcp-core/server.d.ts +110 -0
  137. package/dist/types/facade/mcp-core/tool-factory.d.ts +62 -0
  138. package/dist/types/facade/mcp-core/types.d.ts +288 -0
  139. package/dist/types/facade/mcp.d.ts +1 -0
  140. package/dist/types/facade/memory.d.ts +1 -0
  141. package/dist/types/facade/ml/adapters/amazon-bedrock.d.ts +32 -0
  142. package/dist/types/facade/ml/adapters/anthropic.d.ts +61 -0
  143. package/dist/types/facade/ml/adapters/azure-openai-responses.d.ts +14 -0
  144. package/dist/types/facade/ml/adapters/google-shared.d.ts +99 -0
  145. package/dist/types/facade/ml/adapters/google-vertex.d.ts +14 -0
  146. package/dist/types/facade/ml/adapters/google.d.ts +15 -0
  147. package/dist/types/facade/ml/adapters/kimi.d.ts +21 -0
  148. package/dist/types/facade/ml/adapters/mock.d.ts +9 -0
  149. package/dist/types/facade/ml/adapters/nvidia.d.ts +12 -0
  150. package/dist/types/facade/ml/adapters/openai-codex-responses.d.ts +8 -0
  151. package/dist/types/facade/ml/adapters/openai-completions.d.ts +24 -0
  152. package/dist/types/facade/ml/adapters/openai-responses-shared.d.ts +25 -0
  153. package/dist/types/facade/ml/adapters/openai-responses.d.ts +12 -0
  154. package/dist/types/facade/ml/adapters/openai-scaffold.d.ts +3 -0
  155. package/dist/types/facade/ml/adapters/register-builtins.d.ts +2 -0
  156. package/dist/types/facade/ml/adapters/simple-options.d.ts +26 -0
  157. package/dist/types/facade/ml/adapters/transform-messages.d.ts +23 -0
  158. package/dist/types/facade/ml/api-registry.d.ts +49 -0
  159. package/dist/types/facade/ml/cli.d.ts +2 -0
  160. package/dist/types/facade/ml/env-api-keys.d.ts +19 -0
  161. package/dist/types/facade/ml/index.d.ts +27 -0
  162. package/dist/types/facade/ml/kit/auth/anthropic.d.ts +17 -0
  163. package/dist/types/facade/ml/kit/auth/github-copilot.d.ts +22 -0
  164. package/dist/types/facade/ml/kit/auth/index.d.ts +50 -0
  165. package/dist/types/facade/ml/kit/auth/kimi.d.ts +23 -0
  166. package/dist/types/facade/ml/kit/auth/oauth-page.d.ts +2 -0
  167. package/dist/types/facade/ml/kit/auth/openai-codex.d.ts +36 -0
  168. package/dist/types/facade/ml/kit/auth/pkce.d.ts +12 -0
  169. package/dist/types/facade/ml/kit/auth/types.d.ts +67 -0
  170. package/dist/types/facade/ml/kit/base-stream-handler.d.ts +30 -0
  171. package/dist/types/facade/ml/kit/event-stream.d.ts +63 -0
  172. package/dist/types/facade/ml/kit/index.d.ts +14 -0
  173. package/dist/types/facade/ml/kit/json-parse.d.ts +23 -0
  174. package/dist/types/facade/ml/kit/message-transform.d.ts +32 -0
  175. package/dist/types/facade/ml/kit/output-factory.d.ts +8 -0
  176. package/dist/types/facade/ml/kit/overflow.d.ts +9 -0
  177. package/dist/types/facade/ml/kit/provider-adapter.d.ts +56 -0
  178. package/dist/types/facade/ml/kit/provider-client-builder.d.ts +36 -0
  179. package/dist/types/facade/ml/kit/provider-consolidation.d.ts +3 -0
  180. package/dist/types/facade/ml/kit/provider-constants.d.ts +34 -0
  181. package/dist/types/facade/ml/kit/provider-errors.d.ts +52 -0
  182. package/dist/types/facade/ml/kit/sanitize-unicode.d.ts +2 -0
  183. package/dist/types/facade/ml/kit/stream-event-helper.d.ts +38 -0
  184. package/dist/types/facade/ml/kit/stream-handler-types.d.ts +46 -0
  185. package/dist/types/facade/ml/kit/streaming-state-manager.d.ts +42 -0
  186. package/dist/types/facade/ml/kit/tool-converter.d.ts +49 -0
  187. package/dist/types/facade/ml/kit/typebox-helpers.d.ts +24 -0
  188. package/dist/types/facade/ml/kit/validation.d.ts +26 -0
  189. package/dist/types/facade/ml/models.d.ts +41 -0
  190. package/dist/types/facade/ml/models.generated.d.ts +12261 -0
  191. package/dist/types/facade/ml/stream.d.ts +27 -0
  192. package/dist/types/facade/ml/types.d.ts +269 -0
  193. package/dist/types/index.d.ts +16 -0
  194. package/dist/types/interop/index.d.ts +12 -0
  195. package/dist/types/interop/interop.test.d.ts +19 -0
  196. package/dist/types/interop/protocol-bridge/bridge.d.ts +52 -0
  197. package/dist/types/interop/protocol-bridge/contract.d.ts +249 -0
  198. package/dist/types/interop/protocol-bridge/endpoint.d.ts +124 -0
  199. package/dist/types/interop/protocol-bridge/fleet.d.ts +92 -0
  200. package/dist/types/interop/protocol-bridge/host.d.ts +61 -0
  201. package/dist/types/interop/protocol-bridge/index.d.ts +16 -0
  202. package/dist/types/interop/protocol-bridge/schema.d.ts +29 -0
  203. package/dist/types/llmgateway/catalog/cards.d.ts +18 -0
  204. package/dist/types/llmgateway/catalog/cost.d.ts +15 -0
  205. package/dist/types/llmgateway/catalog/index.d.ts +7 -0
  206. package/dist/types/llmgateway/catalog/query.d.ts +40 -0
  207. package/dist/types/llmgateway/connectors/anthropic.d.ts +35 -0
  208. package/dist/types/llmgateway/connectors/azure-openai.d.ts +33 -0
  209. package/dist/types/llmgateway/connectors/bedrock.d.ts +113 -0
  210. package/dist/types/llmgateway/connectors/google-vertex.d.ts +38 -0
  211. package/dist/types/llmgateway/connectors/google.d.ts +40 -0
  212. package/dist/types/llmgateway/connectors/index.d.ts +26 -0
  213. package/dist/types/llmgateway/connectors/kimi.d.ts +28 -0
  214. package/dist/types/llmgateway/connectors/mock.d.ts +37 -0
  215. package/dist/types/llmgateway/connectors/nvidia.d.ts +27 -0
  216. package/dist/types/llmgateway/connectors/ollama.d.ts +45 -0
  217. package/dist/types/llmgateway/connectors/openai-chat.d.ts +25 -0
  218. package/dist/types/llmgateway/connectors/openai-responses.d.ts +49 -0
  219. package/dist/types/llmgateway/contract/connector.d.ts +32 -0
  220. package/dist/types/llmgateway/contract/conversation.d.ts +86 -0
  221. package/dist/types/llmgateway/contract/emission.d.ts +55 -0
  222. package/dist/types/llmgateway/contract/errors.d.ts +27 -0
  223. package/dist/types/llmgateway/contract/index.d.ts +13 -0
  224. package/dist/types/llmgateway/contract/model-card.d.ts +42 -0
  225. package/dist/types/llmgateway/contract/options.d.ts +31 -0
  226. package/dist/types/llmgateway/contract/reply.d.ts +33 -0
  227. package/dist/types/llmgateway/conversion/index.d.ts +10 -0
  228. package/dist/types/llmgateway/conversion/mappers.d.ts +65 -0
  229. package/dist/types/llmgateway/conversion/openai-compatible.d.ts +46 -0
  230. package/dist/types/llmgateway/conversion/reduce.d.ts +20 -0
  231. package/dist/types/llmgateway/credentials/oauth.d.ts +73 -0
  232. package/dist/types/llmgateway/credentials/pkce.d.ts +52 -0
  233. package/dist/types/llmgateway/credentials/secrets.d.ts +74 -0
  234. package/dist/types/llmgateway/gateway.d.ts +34 -0
  235. package/dist/types/llmgateway/gateway.test.d.ts +14 -0
  236. package/dist/types/llmgateway/index.d.ts +11 -0
  237. package/dist/types/llmgateway/streaming/channel.d.ts +24 -0
  238. package/dist/types/llmgateway/streaming/index.d.ts +10 -0
  239. package/dist/types/llmgateway/streaming/ndjson.d.ts +17 -0
  240. package/dist/types/llmgateway/streaming/sse.d.ts +31 -0
  241. package/dist/types/react-host/index.d.ts +9 -0
  242. package/dist/types/react-host/ink.d.ts +5 -0
  243. package/dist/types/react-host/jsx-runtime.d.ts +4 -0
  244. package/dist/types/react-host/loader.d.ts +3 -0
  245. package/dist/types/react-ink/components/ChangelogBlock.d.ts +8 -0
  246. package/dist/types/react-ink/components/DisplayBlockView.d.ts +8 -0
  247. package/dist/types/react-ink/components/Footer.d.ts +11 -0
  248. package/dist/types/react-ink/components/MessageList.d.ts +14 -0
  249. package/dist/types/react-ink/components/MessageRow.d.ts +13 -0
  250. package/dist/types/react-ink/components/StatusLine.d.ts +9 -0
  251. package/dist/types/react-ink/components/TaskPanel.d.ts +11 -0
  252. package/dist/types/react-ink/components/ToolEventBlock.d.ts +17 -0
  253. package/dist/types/react-ink/components/dialogs/DialogFrame.d.ts +8 -0
  254. package/dist/types/react-ink/components/dialogs/LoginDialog.d.ts +14 -0
  255. package/dist/types/react-ink/components/dialogs/ModelDialog.d.ts +9 -0
  256. package/dist/types/react-ink/components/dialogs/OAuthDialog.d.ts +9 -0
  257. package/dist/types/react-ink/components/dialogs/ScopedModelsDialog.d.ts +9 -0
  258. package/dist/types/react-ink/components/dialogs/SelectableDialog.d.ts +16 -0
  259. package/dist/types/react-ink/components/dialogs/SessionDialog.d.ts +13 -0
  260. package/dist/types/react-ink/components/dialogs/SettingsDialog.d.ts +14 -0
  261. package/dist/types/react-ink/components/dialogs/StartupSessionPicker.d.ts +9 -0
  262. package/dist/types/react-ink/components/dialogs/ThemeDialog.d.ts +7 -0
  263. package/dist/types/react-ink/components/dialogs/TreeDialog.d.ts +8 -0
  264. package/dist/types/react-ink/components/dialogs/UserMessageDialog.d.ts +8 -0
  265. package/dist/types/react-ink/components/messages/AssistantMessage.d.ts +12 -0
  266. package/dist/types/react-ink/components/messages/BashMessage.d.ts +8 -0
  267. package/dist/types/react-ink/components/messages/BranchSummaryMessage.d.ts +8 -0
  268. package/dist/types/react-ink/components/messages/CompactionMessage.d.ts +8 -0
  269. package/dist/types/react-ink/components/messages/CustomMessage.d.ts +9 -0
  270. package/dist/types/react-ink/components/messages/SkillInvocationMessage.d.ts +7 -0
  271. package/dist/types/react-ink/components/messages/ToolCallMessage.d.ts +8 -0
  272. package/dist/types/react-ink/components/messages/ToolResultBlock.d.ts +12 -0
  273. package/dist/types/react-ink/components/messages/UserMessage.d.ts +9 -0
  274. package/dist/types/react-ink/index.d.ts +34 -0
  275. package/dist/types/react-ink/theme-adapter.d.ts +9 -0
  276. package/dist/types/react-ink/types.d.ts +133 -0
  277. package/dist/types/react-ink/utils/message-groups.d.ts +25 -0
  278. package/dist/types/react-ink/utils/selection-dialog.d.ts +2 -0
  279. package/dist/types/react-ink/utils/session-browser.d.ts +27 -0
  280. package/dist/types/react-ink/utils/tool-display.d.ts +21 -0
  281. package/dist/types/runtime/cadence/cadence.test.d.ts +6 -0
  282. package/dist/types/runtime/cadence/fold.d.ts +48 -0
  283. package/dist/types/runtime/cadence/index.d.ts +12 -0
  284. package/dist/types/runtime/cadence/reducer.d.ts +44 -0
  285. package/dist/types/runtime/conductor/agent.d.ts +71 -0
  286. package/dist/types/runtime/conductor/index.d.ts +11 -0
  287. package/dist/types/runtime/contract/config.d.ts +44 -0
  288. package/dist/types/runtime/contract/effect.d.ts +41 -0
  289. package/dist/types/runtime/contract/errors.d.ts +22 -0
  290. package/dist/types/runtime/contract/events.d.ts +63 -0
  291. package/dist/types/runtime/contract/index.d.ts +18 -0
  292. package/dist/types/runtime/contract/run-state.d.ts +57 -0
  293. package/dist/types/runtime/contract/session.d.ts +42 -0
  294. package/dist/types/runtime/contract/signal.d.ts +49 -0
  295. package/dist/types/runtime/contract/tools.d.ts +45 -0
  296. package/dist/types/runtime/dispatch/index.d.ts +9 -0
  297. package/dist/types/runtime/dispatch/scheduler.d.ts +53 -0
  298. package/dist/types/runtime/index.d.ts +22 -0
  299. package/dist/types/runtime/ledger/accumulator.d.ts +44 -0
  300. package/dist/types/runtime/ledger/bus.d.ts +50 -0
  301. package/dist/types/runtime/ledger/index.d.ts +11 -0
  302. package/dist/types/runtime/memory/compactor.d.ts +56 -0
  303. package/dist/types/runtime/memory/estimate.d.ts +21 -0
  304. package/dist/types/runtime/memory/index.d.ts +8 -0
  305. package/dist/types/runtime/runtime.test.d.ts +15 -0
  306. package/dist/types/runtime/store/dag.d.ts +72 -0
  307. package/dist/types/runtime/store/hash.d.ts +18 -0
  308. package/dist/types/runtime/store/index.d.ts +12 -0
  309. package/dist/types/runtime/store/persist.d.ts +49 -0
  310. package/dist/types/runtime/turn/driver.d.ts +32 -0
  311. package/dist/types/runtime/turn/index.d.ts +8 -0
  312. package/dist/types/runtime/wire/index.d.ts +10 -0
  313. package/dist/types/runtime/wire/projectors.d.ts +53 -0
  314. package/dist/types/shell-app/auth-cli/index.d.ts +9 -0
  315. package/dist/types/shell-app/auth-cli/oauth-cli.d.ts +73 -0
  316. package/dist/types/shell-app/boot/context.d.ts +108 -0
  317. package/dist/types/shell-app/boot/index.d.ts +13 -0
  318. package/dist/types/shell-app/boot/pipeline.d.ts +66 -0
  319. package/dist/types/shell-app/boot/stages.d.ts +77 -0
  320. package/dist/types/shell-app/cli.d.ts +75 -0
  321. package/dist/types/shell-app/config/index.d.ts +11 -0
  322. package/dist/types/shell-app/config/locator.d.ts +85 -0
  323. package/dist/types/shell-app/config/settings.d.ts +91 -0
  324. package/dist/types/shell-app/index.d.ts +26 -0
  325. package/dist/types/shell-app/invocation/flags.d.ts +89 -0
  326. package/dist/types/shell-app/invocation/parse.d.ts +89 -0
  327. package/dist/types/shell-app/locate/brand.d.ts +71 -0
  328. package/dist/types/shell-app/locate/index.d.ts +12 -0
  329. package/dist/types/shell-app/locate/locator.d.ts +122 -0
  330. package/dist/types/shell-app/runners/contract.d.ts +116 -0
  331. package/dist/types/shell-app/runners/index.d.ts +15 -0
  332. package/dist/types/shell-app/runners/one-shot.d.ts +21 -0
  333. package/dist/types/shell-app/runners/registry.d.ts +34 -0
  334. package/dist/types/shell-app/runners/repl.d.ts +51 -0
  335. package/dist/types/shell-app/runners/wire.d.ts +34 -0
  336. package/dist/types/shell-app/shell-app.test.d.ts +14 -0
  337. package/dist/types/shell-app/upgrade/index.d.ts +9 -0
  338. package/dist/types/shell-app/upgrade/upgrades.d.ts +62 -0
  339. package/dist/types/smithy/config/flag-reader.d.ts +128 -0
  340. package/dist/types/smithy/config/index.d.ts +9 -0
  341. package/dist/types/smithy/forge.d.ts +135 -0
  342. package/dist/types/smithy/index.d.ts +36 -0
  343. package/dist/types/smithy/knowledge/index.d.ts +10 -0
  344. package/dist/types/smithy/knowledge/loader.d.ts +64 -0
  345. package/dist/types/smithy/persona/blueprint.d.ts +75 -0
  346. package/dist/types/smithy/persona/define-agent.d.ts +51 -0
  347. package/dist/types/smithy/persona/index.d.ts +14 -0
  348. package/dist/types/smithy/persona/profiles.d.ts +44 -0
  349. package/dist/types/smithy/runtime/index.d.ts +9 -0
  350. package/dist/types/smithy/runtime/tool-ledger.d.ts +130 -0
  351. package/dist/types/smithy/smithy.test.d.ts +20 -0
  352. package/dist/types/smithy/ui/index.d.ts +11 -0
  353. package/dist/types/smithy/ui/transcript.d.ts +183 -0
  354. package/dist/types/swarm/coordinator.d.ts +192 -0
  355. package/dist/types/swarm/index.d.ts +33 -0
  356. package/dist/types/swarm/isolation/index.d.ts +14 -0
  357. package/dist/types/swarm/isolation/runner.d.ts +61 -0
  358. package/dist/types/swarm/isolation/worktree.d.ts +142 -0
  359. package/dist/types/swarm/kernel/faults.d.ts +52 -0
  360. package/dist/types/swarm/kernel/ids.d.ts +25 -0
  361. package/dist/types/swarm/kernel/index.d.ts +26 -0
  362. package/dist/types/swarm/kernel/json-cell.d.ts +113 -0
  363. package/dist/types/swarm/kernel/jsonl-log.d.ts +81 -0
  364. package/dist/types/swarm/postbox/channel.d.ts +88 -0
  365. package/dist/types/swarm/postbox/codecs.d.ts +253 -0
  366. package/dist/types/swarm/postbox/index.d.ts +16 -0
  367. package/dist/types/swarm/roster/index.d.ts +16 -0
  368. package/dist/types/swarm/roster/manifest.d.ts +185 -0
  369. package/dist/types/swarm/swarm.test.d.ts +24 -0
  370. package/dist/types/swarm/telemetry/activity.d.ts +143 -0
  371. package/dist/types/swarm/workboard/board.d.ts +174 -0
  372. package/dist/types/swarm/workboard/dep-graph.d.ts +77 -0
  373. package/dist/types/swarm/workboard/index.d.ts +12 -0
  374. package/dist/types/tracing/adapter/index.d.ts +12 -0
  375. package/dist/types/tracing/adapter/runtime-trace.d.ts +54 -0
  376. package/dist/types/tracing/channel/index.d.ts +9 -0
  377. package/dist/types/tracing/channel/signal.d.ts +93 -0
  378. package/dist/types/tracing/index.d.ts +25 -0
  379. package/dist/types/tracing/recorder/index.d.ts +12 -0
  380. package/dist/types/tracing/recorder/recorder.d.ts +75 -0
  381. package/dist/types/tracing/recorder/sampling.d.ts +55 -0
  382. package/dist/types/tracing/redaction/index.d.ts +8 -0
  383. package/dist/types/tracing/redaction/secret-scrubber.d.ts +95 -0
  384. package/dist/types/tracing/registry/hub.d.ts +57 -0
  385. package/dist/types/tracing/registry/index.d.ts +7 -0
  386. package/dist/types/tracing/signal/handle.d.ts +73 -0
  387. package/dist/types/tracing/signal/index.d.ts +12 -0
  388. package/dist/types/tracing/signal/segment.d.ts +124 -0
  389. package/dist/types/tracing/sinks/base.d.ts +51 -0
  390. package/dist/types/tracing/sinks/console.d.ts +44 -0
  391. package/dist/types/tracing/sinks/file.d.ts +47 -0
  392. package/dist/types/tracing/sinks/index.d.ts +16 -0
  393. package/dist/types/tracing/sinks/stream.d.ts +46 -0
  394. package/dist/types/tracing/tracing.test.d.ts +7 -0
  395. package/dist/types/ui/autocomplete.d.ts +59 -0
  396. package/dist/types/ui/contracts.d.ts +38 -0
  397. package/dist/types/ui/editor-component.d.ts +100 -0
  398. package/dist/types/ui/fuzzy.d.ts +29 -0
  399. package/dist/types/ui/index.d.ts +8 -0
  400. package/dist/types/ui/keybindings.d.ts +62 -0
  401. package/dist/types/ui/keys.d.ts +171 -0
  402. package/dist/types/ui/theme-types.d.ts +36 -0
  403. package/dist/types/ui/utils.d.ts +101 -0
  404. package/dist/types/ui-bridge/InteractiveApp.d.ts +38 -0
  405. package/dist/types/ui-bridge/adapter.d.ts +90 -0
  406. package/dist/types/ui-bridge/index.d.ts +37 -0
  407. package/package.json +116 -107
  408. package/LICENSE +0 -8
  409. package/LICENSE-THIRD-PARTY.txt +0 -30
  410. package/local-dist-new/IndusForge/examples/research-agent.d.ts +0 -3
  411. package/local-dist-new/IndusForge/examples/research-agent.d.ts.map +0 -1
  412. package/local-dist-new/IndusForge/examples/research-agent.js +0 -18
  413. package/local-dist-new/IndusForge/examples/research-agent.js.map +0 -1
  414. package/local-dist-new/IndusForge/examples/review-agent.d.ts +0 -3
  415. package/local-dist-new/IndusForge/examples/review-agent.d.ts.map +0 -1
  416. package/local-dist-new/IndusForge/examples/review-agent.js +0 -18
  417. package/local-dist-new/IndusForge/examples/review-agent.js.map +0 -1
  418. package/local-dist-new/IndusForge/examples/terminal-builder-agent.d.ts +0 -3
  419. package/local-dist-new/IndusForge/examples/terminal-builder-agent.d.ts.map +0 -1
  420. package/local-dist-new/IndusForge/examples/terminal-builder-agent.js +0 -18
  421. package/local-dist-new/IndusForge/examples/terminal-builder-agent.js.map +0 -1
  422. package/local-dist-new/IndusForge/terminal-chat.d.ts +0 -2
  423. package/local-dist-new/IndusForge/terminal-chat.d.ts.map +0 -1
  424. package/local-dist-new/IndusForge/terminal-chat.js +0 -557
  425. package/local-dist-new/IndusForge/terminal-chat.js.map +0 -1
  426. package/local-dist-new/agent.d.ts +0 -6
  427. package/local-dist-new/agent.d.ts.map +0 -1
  428. package/local-dist-new/agent.js +0 -6
  429. package/local-dist-new/agent.js.map +0 -1
  430. package/local-dist-new/ai.d.ts +0 -6
  431. package/local-dist-new/ai.d.ts.map +0 -1
  432. package/local-dist-new/ai.js +0 -6
  433. package/local-dist-new/ai.js.map +0 -1
  434. package/local-dist-new/bot/actions/bash.d.ts +0 -56
  435. package/local-dist-new/bot/actions/bash.d.ts.map +0 -1
  436. package/local-dist-new/bot/actions/bash.js +0 -275
  437. package/local-dist-new/bot/actions/bash.js.map +0 -1
  438. package/local-dist-new/bot/actions/composio/accounts.d.ts +0 -23
  439. package/local-dist-new/bot/actions/composio/accounts.d.ts.map +0 -1
  440. package/local-dist-new/bot/actions/composio/accounts.js +0 -40
  441. package/local-dist-new/bot/actions/composio/accounts.js.map +0 -1
  442. package/local-dist-new/bot/actions/composio/client.d.ts +0 -40
  443. package/local-dist-new/bot/actions/composio/client.d.ts.map +0 -1
  444. package/local-dist-new/bot/actions/composio/client.js +0 -361
  445. package/local-dist-new/bot/actions/composio/client.js.map +0 -1
  446. package/local-dist-new/bot/actions/composio/connect.d.ts +0 -20
  447. package/local-dist-new/bot/actions/composio/connect.d.ts.map +0 -1
  448. package/local-dist-new/bot/actions/composio/connect.js +0 -41
  449. package/local-dist-new/bot/actions/composio/connect.js.map +0 -1
  450. package/local-dist-new/bot/actions/composio/enable.d.ts +0 -26
  451. package/local-dist-new/bot/actions/composio/enable.d.ts.map +0 -1
  452. package/local-dist-new/bot/actions/composio/enable.js +0 -66
  453. package/local-dist-new/bot/actions/composio/enable.js.map +0 -1
  454. package/local-dist-new/bot/actions/composio/execute.d.ts +0 -27
  455. package/local-dist-new/bot/actions/composio/execute.d.ts.map +0 -1
  456. package/local-dist-new/bot/actions/composio/execute.js +0 -46
  457. package/local-dist-new/bot/actions/composio/execute.js.map +0 -1
  458. package/local-dist-new/bot/actions/composio/helpers.d.ts +0 -17
  459. package/local-dist-new/bot/actions/composio/helpers.d.ts.map +0 -1
  460. package/local-dist-new/bot/actions/composio/helpers.js +0 -533
  461. package/local-dist-new/bot/actions/composio/helpers.js.map +0 -1
  462. package/local-dist-new/bot/actions/composio/index.d.ts +0 -10
  463. package/local-dist-new/bot/actions/composio/index.d.ts.map +0 -1
  464. package/local-dist-new/bot/actions/composio/index.js +0 -9
  465. package/local-dist-new/bot/actions/composio/index.js.map +0 -1
  466. package/local-dist-new/bot/actions/composio/provider.d.ts +0 -9
  467. package/local-dist-new/bot/actions/composio/provider.d.ts.map +0 -1
  468. package/local-dist-new/bot/actions/composio/provider.js +0 -54
  469. package/local-dist-new/bot/actions/composio/provider.js.map +0 -1
  470. package/local-dist-new/bot/actions/composio/toolkits.d.ts +0 -23
  471. package/local-dist-new/bot/actions/composio/toolkits.d.ts.map +0 -1
  472. package/local-dist-new/bot/actions/composio/toolkits.js +0 -40
  473. package/local-dist-new/bot/actions/composio/toolkits.js.map +0 -1
  474. package/local-dist-new/bot/actions/composio/tools.d.ts +0 -29
  475. package/local-dist-new/bot/actions/composio/tools.d.ts.map +0 -1
  476. package/local-dist-new/bot/actions/composio/tools.js +0 -72
  477. package/local-dist-new/bot/actions/composio/tools.js.map +0 -1
  478. package/local-dist-new/bot/actions/composio/types.d.ts +0 -138
  479. package/local-dist-new/bot/actions/composio/types.d.ts.map +0 -1
  480. package/local-dist-new/bot/actions/composio/types.js +0 -2
  481. package/local-dist-new/bot/actions/composio/types.js.map +0 -1
  482. package/local-dist-new/bot/actions/crew/activity-tracker.d.ts +0 -66
  483. package/local-dist-new/bot/actions/crew/activity-tracker.d.ts.map +0 -1
  484. package/local-dist-new/bot/actions/crew/activity-tracker.js +0 -480
  485. package/local-dist-new/bot/actions/crew/activity-tracker.js.map +0 -1
  486. package/local-dist-new/bot/actions/crew/cleanup.d.ts +0 -51
  487. package/local-dist-new/bot/actions/crew/cleanup.d.ts.map +0 -1
  488. package/local-dist-new/bot/actions/crew/cleanup.js +0 -219
  489. package/local-dist-new/bot/actions/crew/cleanup.js.map +0 -1
  490. package/local-dist-new/bot/actions/crew/fs-lock.d.ts +0 -12
  491. package/local-dist-new/bot/actions/crew/fs-lock.d.ts.map +0 -1
  492. package/local-dist-new/bot/actions/crew/fs-lock.js +0 -74
  493. package/local-dist-new/bot/actions/crew/fs-lock.js.map +0 -1
  494. package/local-dist-new/bot/actions/crew/index.d.ts +0 -12
  495. package/local-dist-new/bot/actions/crew/index.d.ts.map +0 -1
  496. package/local-dist-new/bot/actions/crew/index.js +0 -12
  497. package/local-dist-new/bot/actions/crew/index.js.map +0 -1
  498. package/local-dist-new/bot/actions/crew/mailbox.d.ts +0 -21
  499. package/local-dist-new/bot/actions/crew/mailbox.d.ts.map +0 -1
  500. package/local-dist-new/bot/actions/crew/mailbox.js +0 -106
  501. package/local-dist-new/bot/actions/crew/mailbox.js.map +0 -1
  502. package/local-dist-new/bot/actions/crew/model-policy.d.ts +0 -23
  503. package/local-dist-new/bot/actions/crew/model-policy.d.ts.map +0 -1
  504. package/local-dist-new/bot/actions/crew/model-policy.js +0 -113
  505. package/local-dist-new/bot/actions/crew/model-policy.js.map +0 -1
  506. package/local-dist-new/bot/actions/crew/names.d.ts +0 -28
  507. package/local-dist-new/bot/actions/crew/names.d.ts.map +0 -1
  508. package/local-dist-new/bot/actions/crew/names.js +0 -109
  509. package/local-dist-new/bot/actions/crew/names.js.map +0 -1
  510. package/local-dist-new/bot/actions/crew/protocol.d.ts +0 -75
  511. package/local-dist-new/bot/actions/crew/protocol.d.ts.map +0 -1
  512. package/local-dist-new/bot/actions/crew/protocol.js +0 -205
  513. package/local-dist-new/bot/actions/crew/protocol.js.map +0 -1
  514. package/local-dist-new/bot/actions/crew/task-store.d.ts +0 -89
  515. package/local-dist-new/bot/actions/crew/task-store.d.ts.map +0 -1
  516. package/local-dist-new/bot/actions/crew/task-store.js +0 -445
  517. package/local-dist-new/bot/actions/crew/task-store.js.map +0 -1
  518. package/local-dist-new/bot/actions/crew/team-attach-claim.d.ts +0 -36
  519. package/local-dist-new/bot/actions/crew/team-attach-claim.d.ts.map +0 -1
  520. package/local-dist-new/bot/actions/crew/team-attach-claim.js +0 -144
  521. package/local-dist-new/bot/actions/crew/team-attach-claim.js.map +0 -1
  522. package/local-dist-new/bot/actions/crew/team-config.d.ts +0 -55
  523. package/local-dist-new/bot/actions/crew/team-config.d.ts.map +0 -1
  524. package/local-dist-new/bot/actions/crew/team-config.js +0 -252
  525. package/local-dist-new/bot/actions/crew/team-config.js.map +0 -1
  526. package/local-dist-new/bot/actions/crew/worktree.d.ts +0 -40
  527. package/local-dist-new/bot/actions/crew/worktree.d.ts.map +0 -1
  528. package/local-dist-new/bot/actions/crew/worktree.js +0 -213
  529. package/local-dist-new/bot/actions/crew/worktree.js.map +0 -1
  530. package/local-dist-new/bot/actions/edit-diff.d.ts +0 -63
  531. package/local-dist-new/bot/actions/edit-diff.d.ts.map +0 -1
  532. package/local-dist-new/bot/actions/edit-diff.js +0 -255
  533. package/local-dist-new/bot/actions/edit-diff.js.map +0 -1
  534. package/local-dist-new/bot/actions/edit.d.ts +0 -42
  535. package/local-dist-new/bot/actions/edit.d.ts.map +0 -1
  536. package/local-dist-new/bot/actions/edit.js +0 -176
  537. package/local-dist-new/bot/actions/edit.js.map +0 -1
  538. package/local-dist-new/bot/actions/find.d.ts +0 -26
  539. package/local-dist-new/bot/actions/find.d.ts.map +0 -1
  540. package/local-dist-new/bot/actions/find.js +0 -170
  541. package/local-dist-new/bot/actions/find.js.map +0 -1
  542. package/local-dist-new/bot/actions/grep.d.ts +0 -43
  543. package/local-dist-new/bot/actions/grep.d.ts.map +0 -1
  544. package/local-dist-new/bot/actions/grep.js +0 -218
  545. package/local-dist-new/bot/actions/grep.js.map +0 -1
  546. package/local-dist-new/bot/actions/index.d.ts +0 -301
  547. package/local-dist-new/bot/actions/index.d.ts.map +0 -1
  548. package/local-dist-new/bot/actions/index.js +0 -255
  549. package/local-dist-new/bot/actions/index.js.map +0 -1
  550. package/local-dist-new/bot/actions/kit/hook-runner.d.ts +0 -13
  551. package/local-dist-new/bot/actions/kit/hook-runner.d.ts.map +0 -1
  552. package/local-dist-new/bot/actions/kit/hook-runner.js +0 -33
  553. package/local-dist-new/bot/actions/kit/hook-runner.js.map +0 -1
  554. package/local-dist-new/bot/actions/kit/image-resize.d.ts +0 -20
  555. package/local-dist-new/bot/actions/kit/image-resize.d.ts.map +0 -1
  556. package/local-dist-new/bot/actions/kit/image-resize.js +0 -93
  557. package/local-dist-new/bot/actions/kit/image-resize.js.map +0 -1
  558. package/local-dist-new/bot/actions/kit/mime.d.ts +0 -2
  559. package/local-dist-new/bot/actions/kit/mime.d.ts.map +0 -1
  560. package/local-dist-new/bot/actions/kit/mime.js +0 -65
  561. package/local-dist-new/bot/actions/kit/mime.js.map +0 -1
  562. package/local-dist-new/bot/actions/kit/shell.d.ts +0 -13
  563. package/local-dist-new/bot/actions/kit/shell.d.ts.map +0 -1
  564. package/local-dist-new/bot/actions/kit/shell.js +0 -103
  565. package/local-dist-new/bot/actions/kit/shell.js.map +0 -1
  566. package/local-dist-new/bot/actions/ls.d.ts +0 -41
  567. package/local-dist-new/bot/actions/ls.d.ts.map +0 -1
  568. package/local-dist-new/bot/actions/ls.js +0 -174
  569. package/local-dist-new/bot/actions/ls.js.map +0 -1
  570. package/local-dist-new/bot/actions/path-utils.d.ts +0 -8
  571. package/local-dist-new/bot/actions/path-utils.d.ts.map +0 -1
  572. package/local-dist-new/bot/actions/path-utils.js +0 -75
  573. package/local-dist-new/bot/actions/path-utils.js.map +0 -1
  574. package/local-dist-new/bot/actions/process-controller.d.ts +0 -15
  575. package/local-dist-new/bot/actions/process-controller.d.ts.map +0 -1
  576. package/local-dist-new/bot/actions/process-controller.js +0 -39
  577. package/local-dist-new/bot/actions/process-controller.js.map +0 -1
  578. package/local-dist-new/bot/actions/process-manager.d.ts +0 -60
  579. package/local-dist-new/bot/actions/process-manager.d.ts.map +0 -1
  580. package/local-dist-new/bot/actions/process-manager.js +0 -485
  581. package/local-dist-new/bot/actions/process-manager.js.map +0 -1
  582. package/local-dist-new/bot/actions/process-types.d.ts +0 -74
  583. package/local-dist-new/bot/actions/process-types.d.ts.map +0 -1
  584. package/local-dist-new/bot/actions/process-types.js +0 -7
  585. package/local-dist-new/bot/actions/process-types.js.map +0 -1
  586. package/local-dist-new/bot/actions/process.d.ts +0 -38
  587. package/local-dist-new/bot/actions/process.d.ts.map +0 -1
  588. package/local-dist-new/bot/actions/process.js +0 -360
  589. package/local-dist-new/bot/actions/process.js.map +0 -1
  590. package/local-dist-new/bot/actions/read.d.ts +0 -37
  591. package/local-dist-new/bot/actions/read.d.ts.map +0 -1
  592. package/local-dist-new/bot/actions/read.js +0 -190
  593. package/local-dist-new/bot/actions/read.js.map +0 -1
  594. package/local-dist-new/bot/actions/registry.d.ts +0 -21
  595. package/local-dist-new/bot/actions/registry.d.ts.map +0 -1
  596. package/local-dist-new/bot/actions/registry.js +0 -23
  597. package/local-dist-new/bot/actions/registry.js.map +0 -1
  598. package/local-dist-new/bot/actions/todo-store.d.ts +0 -77
  599. package/local-dist-new/bot/actions/todo-store.d.ts.map +0 -1
  600. package/local-dist-new/bot/actions/todo-store.js +0 -137
  601. package/local-dist-new/bot/actions/todo-store.js.map +0 -1
  602. package/local-dist-new/bot/actions/todo-types.d.ts +0 -73
  603. package/local-dist-new/bot/actions/todo-types.d.ts.map +0 -1
  604. package/local-dist-new/bot/actions/todo-types.js +0 -8
  605. package/local-dist-new/bot/actions/todo-types.js.map +0 -1
  606. package/local-dist-new/bot/actions/todo.d.ts +0 -77
  607. package/local-dist-new/bot/actions/todo.d.ts.map +0 -1
  608. package/local-dist-new/bot/actions/todo.js +0 -122
  609. package/local-dist-new/bot/actions/todo.js.map +0 -1
  610. package/local-dist-new/bot/actions/truncate.d.ts +0 -73
  611. package/local-dist-new/bot/actions/truncate.d.ts.map +0 -1
  612. package/local-dist-new/bot/actions/truncate.js +0 -221
  613. package/local-dist-new/bot/actions/truncate.js.map +0 -1
  614. package/local-dist-new/bot/actions/webfetch.d.ts +0 -36
  615. package/local-dist-new/bot/actions/webfetch.d.ts.map +0 -1
  616. package/local-dist-new/bot/actions/webfetch.js +0 -247
  617. package/local-dist-new/bot/actions/webfetch.js.map +0 -1
  618. package/local-dist-new/bot/actions/websearch.d.ts +0 -35
  619. package/local-dist-new/bot/actions/websearch.d.ts.map +0 -1
  620. package/local-dist-new/bot/actions/websearch.js +0 -132
  621. package/local-dist-new/bot/actions/websearch.js.map +0 -1
  622. package/local-dist-new/bot/actions/write.d.ts +0 -31
  623. package/local-dist-new/bot/actions/write.d.ts.map +0 -1
  624. package/local-dist-new/bot/actions/write.js +0 -139
  625. package/local-dist-new/bot/actions/write.js.map +0 -1
  626. package/local-dist-new/bot/agent-loop.d.ts +0 -15
  627. package/local-dist-new/bot/agent-loop.d.ts.map +0 -1
  628. package/local-dist-new/bot/agent-loop.js +0 -293
  629. package/local-dist-new/bot/agent-loop.js.map +0 -1
  630. package/local-dist-new/bot/agent.d.ts +0 -122
  631. package/local-dist-new/bot/agent.d.ts.map +0 -1
  632. package/local-dist-new/bot/agent.js +0 -393
  633. package/local-dist-new/bot/agent.js.map +0 -1
  634. package/local-dist-new/bot/error-handler.d.ts +0 -8
  635. package/local-dist-new/bot/error-handler.d.ts.map +0 -1
  636. package/local-dist-new/bot/error-handler.js +0 -8
  637. package/local-dist-new/bot/error-handler.js.map +0 -1
  638. package/local-dist-new/bot/event-bus.d.ts +0 -9
  639. package/local-dist-new/bot/event-bus.d.ts.map +0 -1
  640. package/local-dist-new/bot/event-bus.js +0 -15
  641. package/local-dist-new/bot/event-bus.js.map +0 -1
  642. package/local-dist-new/bot/index.d.ts +0 -8
  643. package/local-dist-new/bot/index.d.ts.map +0 -1
  644. package/local-dist-new/bot/index.js +0 -8
  645. package/local-dist-new/bot/index.js.map +0 -1
  646. package/local-dist-new/bot/messages.d.ts +0 -77
  647. package/local-dist-new/bot/messages.d.ts.map +0 -1
  648. package/local-dist-new/bot/messages.js +0 -116
  649. package/local-dist-new/bot/messages.js.map +0 -1
  650. package/local-dist-new/bot/proxy.d.ts +0 -66
  651. package/local-dist-new/bot/proxy.d.ts.map +0 -1
  652. package/local-dist-new/bot/proxy.js +0 -228
  653. package/local-dist-new/bot/proxy.js.map +0 -1
  654. package/local-dist-new/bot/session-manager.d.ts +0 -448
  655. package/local-dist-new/bot/session-manager.d.ts.map +0 -1
  656. package/local-dist-new/bot/session-manager.js +0 -1232
  657. package/local-dist-new/bot/session-manager.js.map +0 -1
  658. package/local-dist-new/bot/state-manager.d.ts +0 -22
  659. package/local-dist-new/bot/state-manager.d.ts.map +0 -1
  660. package/local-dist-new/bot/state-manager.js +0 -60
  661. package/local-dist-new/bot/state-manager.js.map +0 -1
  662. package/local-dist-new/bot/telemetry.d.ts +0 -7
  663. package/local-dist-new/bot/telemetry.d.ts.map +0 -1
  664. package/local-dist-new/bot/telemetry.js +0 -18
  665. package/local-dist-new/bot/telemetry.js.map +0 -1
  666. package/local-dist-new/bot/types.d.ts +0 -205
  667. package/local-dist-new/bot/types.d.ts.map +0 -1
  668. package/local-dist-new/bot/types.js +0 -60
  669. package/local-dist-new/bot/types.js.map +0 -1
  670. package/local-dist-new/cli.d.ts +0 -3
  671. package/local-dist-new/cli.d.ts.map +0 -1
  672. package/local-dist-new/cli.js +0 -3
  673. package/local-dist-new/cli.js.map +0 -1
  674. package/local-dist-new/index.d.ts +0 -7
  675. package/local-dist-new/index.d.ts.map +0 -1
  676. package/local-dist-new/index.js +0 -7
  677. package/local-dist-new/index.js.map +0 -1
  678. package/local-dist-new/mcp/client-pool.d.ts +0 -106
  679. package/local-dist-new/mcp/client-pool.d.ts.map +0 -1
  680. package/local-dist-new/mcp/client-pool.js +0 -234
  681. package/local-dist-new/mcp/client-pool.js.map +0 -1
  682. package/local-dist-new/mcp/client.d.ts +0 -158
  683. package/local-dist-new/mcp/client.d.ts.map +0 -1
  684. package/local-dist-new/mcp/client.js +0 -611
  685. package/local-dist-new/mcp/client.js.map +0 -1
  686. package/local-dist-new/mcp/config.d.ts +0 -61
  687. package/local-dist-new/mcp/config.d.ts.map +0 -1
  688. package/local-dist-new/mcp/config.js +0 -250
  689. package/local-dist-new/mcp/config.js.map +0 -1
  690. package/local-dist-new/mcp/errors.d.ts +0 -104
  691. package/local-dist-new/mcp/errors.d.ts.map +0 -1
  692. package/local-dist-new/mcp/errors.js +0 -146
  693. package/local-dist-new/mcp/errors.js.map +0 -1
  694. package/local-dist-new/mcp/index.d.ts +0 -56
  695. package/local-dist-new/mcp/index.d.ts.map +0 -1
  696. package/local-dist-new/mcp/index.js +0 -83
  697. package/local-dist-new/mcp/index.js.map +0 -1
  698. package/local-dist-new/mcp/schema-converter.d.ts +0 -68
  699. package/local-dist-new/mcp/schema-converter.d.ts.map +0 -1
  700. package/local-dist-new/mcp/schema-converter.js +0 -230
  701. package/local-dist-new/mcp/schema-converter.js.map +0 -1
  702. package/local-dist-new/mcp/server.d.ts +0 -111
  703. package/local-dist-new/mcp/server.d.ts.map +0 -1
  704. package/local-dist-new/mcp/server.js +0 -305
  705. package/local-dist-new/mcp/server.js.map +0 -1
  706. package/local-dist-new/mcp/tool-factory.d.ts +0 -63
  707. package/local-dist-new/mcp/tool-factory.d.ts.map +0 -1
  708. package/local-dist-new/mcp/tool-factory.js +0 -228
  709. package/local-dist-new/mcp/tool-factory.js.map +0 -1
  710. package/local-dist-new/mcp/types.d.ts +0 -289
  711. package/local-dist-new/mcp/types.d.ts.map +0 -1
  712. package/local-dist-new/mcp/types.js +0 -8
  713. package/local-dist-new/mcp/types.js.map +0 -1
  714. package/local-dist-new/mcp.d.ts +0 -2
  715. package/local-dist-new/mcp.d.ts.map +0 -1
  716. package/local-dist-new/mcp.js +0 -2
  717. package/local-dist-new/mcp.js.map +0 -1
  718. package/local-dist-new/ml/adapters/amazon-bedrock.d.ts +0 -33
  719. package/local-dist-new/ml/adapters/amazon-bedrock.d.ts.map +0 -1
  720. package/local-dist-new/ml/adapters/amazon-bedrock.js +0 -610
  721. package/local-dist-new/ml/adapters/amazon-bedrock.js.map +0 -1
  722. package/local-dist-new/ml/adapters/anthropic.d.ts +0 -62
  723. package/local-dist-new/ml/adapters/anthropic.d.ts.map +0 -1
  724. package/local-dist-new/ml/adapters/anthropic.js +0 -682
  725. package/local-dist-new/ml/adapters/anthropic.js.map +0 -1
  726. package/local-dist-new/ml/adapters/azure-openai-responses.d.ts +0 -15
  727. package/local-dist-new/ml/adapters/azure-openai-responses.d.ts.map +0 -1
  728. package/local-dist-new/ml/adapters/azure-openai-responses.js +0 -233
  729. package/local-dist-new/ml/adapters/azure-openai-responses.js.map +0 -1
  730. package/local-dist-new/ml/adapters/google-shared.d.ts +0 -60
  731. package/local-dist-new/ml/adapters/google-shared.d.ts.map +0 -1
  732. package/local-dist-new/ml/adapters/google-shared.js +0 -316
  733. package/local-dist-new/ml/adapters/google-shared.js.map +0 -1
  734. package/local-dist-new/ml/adapters/google-vertex.d.ts +0 -15
  735. package/local-dist-new/ml/adapters/google-vertex.d.ts.map +0 -1
  736. package/local-dist-new/ml/adapters/google-vertex.js +0 -396
  737. package/local-dist-new/ml/adapters/google-vertex.js.map +0 -1
  738. package/local-dist-new/ml/adapters/google.d.ts +0 -16
  739. package/local-dist-new/ml/adapters/google.d.ts.map +0 -1
  740. package/local-dist-new/ml/adapters/google.js +0 -381
  741. package/local-dist-new/ml/adapters/google.js.map +0 -1
  742. package/local-dist-new/ml/adapters/kimi.d.ts +0 -22
  743. package/local-dist-new/ml/adapters/kimi.d.ts.map +0 -1
  744. package/local-dist-new/ml/adapters/kimi.js +0 -249
  745. package/local-dist-new/ml/adapters/kimi.js.map +0 -1
  746. package/local-dist-new/ml/adapters/mock.d.ts +0 -10
  747. package/local-dist-new/ml/adapters/mock.d.ts.map +0 -1
  748. package/local-dist-new/ml/adapters/mock.js +0 -64
  749. package/local-dist-new/ml/adapters/mock.js.map +0 -1
  750. package/local-dist-new/ml/adapters/nvidia.d.ts +0 -14
  751. package/local-dist-new/ml/adapters/nvidia.d.ts.map +0 -1
  752. package/local-dist-new/ml/adapters/nvidia.js +0 -377
  753. package/local-dist-new/ml/adapters/nvidia.js.map +0 -1
  754. package/local-dist-new/ml/adapters/openai-codex-responses.d.ts +0 -9
  755. package/local-dist-new/ml/adapters/openai-codex-responses.d.ts.map +0 -1
  756. package/local-dist-new/ml/adapters/openai-codex-responses.js +0 -397
  757. package/local-dist-new/ml/adapters/openai-codex-responses.js.map +0 -1
  758. package/local-dist-new/ml/adapters/openai-completions.d.ts +0 -25
  759. package/local-dist-new/ml/adapters/openai-completions.d.ts.map +0 -1
  760. package/local-dist-new/ml/adapters/openai-completions.js +0 -831
  761. package/local-dist-new/ml/adapters/openai-completions.js.map +0 -1
  762. package/local-dist-new/ml/adapters/openai-responses-shared.d.ts +0 -26
  763. package/local-dist-new/ml/adapters/openai-responses-shared.d.ts.map +0 -1
  764. package/local-dist-new/ml/adapters/openai-responses-shared.js +0 -461
  765. package/local-dist-new/ml/adapters/openai-responses-shared.js.map +0 -1
  766. package/local-dist-new/ml/adapters/openai-responses.d.ts +0 -13
  767. package/local-dist-new/ml/adapters/openai-responses.d.ts.map +0 -1
  768. package/local-dist-new/ml/adapters/openai-responses.js +0 -209
  769. package/local-dist-new/ml/adapters/openai-responses.js.map +0 -1
  770. package/local-dist-new/ml/adapters/openai-scaffold.d.ts +0 -4
  771. package/local-dist-new/ml/adapters/openai-scaffold.d.ts.map +0 -1
  772. package/local-dist-new/ml/adapters/openai-scaffold.js +0 -33
  773. package/local-dist-new/ml/adapters/openai-scaffold.js.map +0 -1
  774. package/local-dist-new/ml/adapters/register-builtins.d.ts +0 -3
  775. package/local-dist-new/ml/adapters/register-builtins.d.ts.map +0 -1
  776. package/local-dist-new/ml/adapters/register-builtins.js +0 -143
  777. package/local-dist-new/ml/adapters/register-builtins.js.map +0 -1
  778. package/local-dist-new/ml/adapters/simple-options.d.ts +0 -27
  779. package/local-dist-new/ml/adapters/simple-options.d.ts.map +0 -1
  780. package/local-dist-new/ml/adapters/simple-options.js +0 -96
  781. package/local-dist-new/ml/adapters/simple-options.js.map +0 -1
  782. package/local-dist-new/ml/adapters/transform-messages.d.ts +0 -22
  783. package/local-dist-new/ml/adapters/transform-messages.d.ts.map +0 -1
  784. package/local-dist-new/ml/adapters/transform-messages.js +0 -147
  785. package/local-dist-new/ml/adapters/transform-messages.js.map +0 -1
  786. package/local-dist-new/ml/api-registry.d.ts +0 -50
  787. package/local-dist-new/ml/api-registry.d.ts.map +0 -1
  788. package/local-dist-new/ml/api-registry.js +0 -121
  789. package/local-dist-new/ml/api-registry.js.map +0 -1
  790. package/local-dist-new/ml/cli.d.ts +0 -3
  791. package/local-dist-new/ml/cli.d.ts.map +0 -1
  792. package/local-dist-new/ml/cli.js +0 -117
  793. package/local-dist-new/ml/cli.js.map +0 -1
  794. package/local-dist-new/ml/env-api-keys.d.ts +0 -18
  795. package/local-dist-new/ml/env-api-keys.d.ts.map +0 -1
  796. package/local-dist-new/ml/env-api-keys.js +0 -122
  797. package/local-dist-new/ml/env-api-keys.js.map +0 -1
  798. package/local-dist-new/ml/index.d.ts +0 -28
  799. package/local-dist-new/ml/index.d.ts.map +0 -1
  800. package/local-dist-new/ml/index.js +0 -28
  801. package/local-dist-new/ml/index.js.map +0 -1
  802. package/local-dist-new/ml/kit/auth/anthropic.d.ts +0 -18
  803. package/local-dist-new/ml/kit/auth/anthropic.d.ts.map +0 -1
  804. package/local-dist-new/ml/kit/auth/anthropic.js +0 -152
  805. package/local-dist-new/ml/kit/auth/anthropic.js.map +0 -1
  806. package/local-dist-new/ml/kit/auth/github-copilot.d.ts +0 -23
  807. package/local-dist-new/ml/kit/auth/github-copilot.d.ts.map +0 -1
  808. package/local-dist-new/ml/kit/auth/github-copilot.js +0 -275
  809. package/local-dist-new/ml/kit/auth/github-copilot.js.map +0 -1
  810. package/local-dist-new/ml/kit/auth/index.d.ts +0 -50
  811. package/local-dist-new/ml/kit/auth/index.d.ts.map +0 -1
  812. package/local-dist-new/ml/kit/auth/index.js +0 -112
  813. package/local-dist-new/ml/kit/auth/index.js.map +0 -1
  814. package/local-dist-new/ml/kit/auth/kimi.d.ts +0 -24
  815. package/local-dist-new/ml/kit/auth/kimi.d.ts.map +0 -1
  816. package/local-dist-new/ml/kit/auth/kimi.js +0 -30
  817. package/local-dist-new/ml/kit/auth/kimi.js.map +0 -1
  818. package/local-dist-new/ml/kit/auth/oauth-page.d.ts +0 -3
  819. package/local-dist-new/ml/kit/auth/oauth-page.d.ts.map +0 -1
  820. package/local-dist-new/ml/kit/auth/oauth-page.js +0 -105
  821. package/local-dist-new/ml/kit/auth/oauth-page.js.map +0 -1
  822. package/local-dist-new/ml/kit/auth/openai-codex.d.ts +0 -34
  823. package/local-dist-new/ml/kit/auth/openai-codex.d.ts.map +0 -1
  824. package/local-dist-new/ml/kit/auth/openai-codex.js +0 -373
  825. package/local-dist-new/ml/kit/auth/openai-codex.js.map +0 -1
  826. package/local-dist-new/ml/kit/auth/pkce.d.ts +0 -13
  827. package/local-dist-new/ml/kit/auth/pkce.d.ts.map +0 -1
  828. package/local-dist-new/ml/kit/auth/pkce.js +0 -31
  829. package/local-dist-new/ml/kit/auth/pkce.js.map +0 -1
  830. package/local-dist-new/ml/kit/auth/types.d.ts +0 -72
  831. package/local-dist-new/ml/kit/auth/types.d.ts.map +0 -1
  832. package/local-dist-new/ml/kit/auth/types.js +0 -11
  833. package/local-dist-new/ml/kit/auth/types.js.map +0 -1
  834. package/local-dist-new/ml/kit/base-stream-handler.d.ts +0 -16
  835. package/local-dist-new/ml/kit/base-stream-handler.d.ts.map +0 -1
  836. package/local-dist-new/ml/kit/base-stream-handler.js +0 -25
  837. package/local-dist-new/ml/kit/base-stream-handler.js.map +0 -1
  838. package/local-dist-new/ml/kit/event-stream.d.ts +0 -45
  839. package/local-dist-new/ml/kit/event-stream.d.ts.map +0 -1
  840. package/local-dist-new/ml/kit/event-stream.js +0 -178
  841. package/local-dist-new/ml/kit/event-stream.js.map +0 -1
  842. package/local-dist-new/ml/kit/index.d.ts +0 -15
  843. package/local-dist-new/ml/kit/index.d.ts.map +0 -1
  844. package/local-dist-new/ml/kit/index.js +0 -15
  845. package/local-dist-new/ml/kit/index.js.map +0 -1
  846. package/local-dist-new/ml/kit/json-parse.d.ts +0 -21
  847. package/local-dist-new/ml/kit/json-parse.d.ts.map +0 -1
  848. package/local-dist-new/ml/kit/json-parse.js +0 -44
  849. package/local-dist-new/ml/kit/json-parse.js.map +0 -1
  850. package/local-dist-new/ml/kit/message-transform.d.ts +0 -29
  851. package/local-dist-new/ml/kit/message-transform.d.ts.map +0 -1
  852. package/local-dist-new/ml/kit/message-transform.js +0 -55
  853. package/local-dist-new/ml/kit/message-transform.js.map +0 -1
  854. package/local-dist-new/ml/kit/output-factory.d.ts +0 -3
  855. package/local-dist-new/ml/kit/output-factory.d.ts.map +0 -1
  856. package/local-dist-new/ml/kit/output-factory.js +0 -23
  857. package/local-dist-new/ml/kit/output-factory.js.map +0 -1
  858. package/local-dist-new/ml/kit/overflow.d.ts +0 -10
  859. package/local-dist-new/ml/kit/overflow.d.ts.map +0 -1
  860. package/local-dist-new/ml/kit/overflow.js +0 -76
  861. package/local-dist-new/ml/kit/overflow.js.map +0 -1
  862. package/local-dist-new/ml/kit/provider-adapter.d.ts +0 -57
  863. package/local-dist-new/ml/kit/provider-adapter.d.ts.map +0 -1
  864. package/local-dist-new/ml/kit/provider-adapter.js +0 -37
  865. package/local-dist-new/ml/kit/provider-adapter.js.map +0 -1
  866. package/local-dist-new/ml/kit/provider-client-builder.d.ts +0 -37
  867. package/local-dist-new/ml/kit/provider-client-builder.d.ts.map +0 -1
  868. package/local-dist-new/ml/kit/provider-client-builder.js +0 -50
  869. package/local-dist-new/ml/kit/provider-client-builder.js.map +0 -1
  870. package/local-dist-new/ml/kit/provider-consolidation.d.ts +0 -4
  871. package/local-dist-new/ml/kit/provider-consolidation.d.ts.map +0 -1
  872. package/local-dist-new/ml/kit/provider-consolidation.js +0 -33
  873. package/local-dist-new/ml/kit/provider-consolidation.js.map +0 -1
  874. package/local-dist-new/ml/kit/provider-constants.d.ts +0 -35
  875. package/local-dist-new/ml/kit/provider-constants.d.ts.map +0 -1
  876. package/local-dist-new/ml/kit/provider-constants.js +0 -35
  877. package/local-dist-new/ml/kit/provider-constants.js.map +0 -1
  878. package/local-dist-new/ml/kit/provider-errors.d.ts +0 -46
  879. package/local-dist-new/ml/kit/provider-errors.d.ts.map +0 -1
  880. package/local-dist-new/ml/kit/provider-errors.js +0 -103
  881. package/local-dist-new/ml/kit/provider-errors.js.map +0 -1
  882. package/local-dist-new/ml/kit/sanitize-unicode.d.ts +0 -3
  883. package/local-dist-new/ml/kit/sanitize-unicode.d.ts.map +0 -1
  884. package/local-dist-new/ml/kit/sanitize-unicode.js +0 -60
  885. package/local-dist-new/ml/kit/sanitize-unicode.js.map +0 -1
  886. package/local-dist-new/ml/kit/stream-event-helper.d.ts +0 -28
  887. package/local-dist-new/ml/kit/stream-event-helper.d.ts.map +0 -1
  888. package/local-dist-new/ml/kit/stream-event-helper.js +0 -52
  889. package/local-dist-new/ml/kit/stream-event-helper.js.map +0 -1
  890. package/local-dist-new/ml/kit/stream-handler-types.d.ts +0 -43
  891. package/local-dist-new/ml/kit/stream-handler-types.d.ts.map +0 -1
  892. package/local-dist-new/ml/kit/stream-handler-types.js +0 -23
  893. package/local-dist-new/ml/kit/stream-handler-types.js.map +0 -1
  894. package/local-dist-new/ml/kit/streaming-state-manager.d.ts +0 -50
  895. package/local-dist-new/ml/kit/streaming-state-manager.d.ts.map +0 -1
  896. package/local-dist-new/ml/kit/streaming-state-manager.js +0 -67
  897. package/local-dist-new/ml/kit/streaming-state-manager.js.map +0 -1
  898. package/local-dist-new/ml/kit/tool-converter.d.ts +0 -50
  899. package/local-dist-new/ml/kit/tool-converter.d.ts.map +0 -1
  900. package/local-dist-new/ml/kit/tool-converter.js +0 -54
  901. package/local-dist-new/ml/kit/tool-converter.js.map +0 -1
  902. package/local-dist-new/ml/kit/typebox-helpers.d.ts +0 -24
  903. package/local-dist-new/ml/kit/typebox-helpers.d.ts.map +0 -1
  904. package/local-dist-new/ml/kit/typebox-helpers.js +0 -46
  905. package/local-dist-new/ml/kit/typebox-helpers.js.map +0 -1
  906. package/local-dist-new/ml/kit/validation.d.ts +0 -24
  907. package/local-dist-new/ml/kit/validation.d.ts.map +0 -1
  908. package/local-dist-new/ml/kit/validation.js +0 -119
  909. package/local-dist-new/ml/kit/validation.js.map +0 -1
  910. package/local-dist-new/ml/models.d.ts +0 -41
  911. package/local-dist-new/ml/models.d.ts.map +0 -1
  912. package/local-dist-new/ml/models.generated.d.ts +0 -12245
  913. package/local-dist-new/ml/models.generated.d.ts.map +0 -1
  914. package/local-dist-new/ml/models.generated.js +0 -12080
  915. package/local-dist-new/ml/models.generated.js.map +0 -1
  916. package/local-dist-new/ml/models.js +0 -126
  917. package/local-dist-new/ml/models.js.map +0 -1
  918. package/local-dist-new/ml/stream.d.ts +0 -12
  919. package/local-dist-new/ml/stream.d.ts.map +0 -1
  920. package/local-dist-new/ml/stream.js +0 -54
  921. package/local-dist-new/ml/stream.js.map +0 -1
  922. package/local-dist-new/ml/types.d.ts +0 -270
  923. package/local-dist-new/ml/types.d.ts.map +0 -1
  924. package/local-dist-new/ml/types.js +0 -169
  925. package/local-dist-new/ml/types.js.map +0 -1
  926. package/local-dist-new/observability.d.ts +0 -2
  927. package/local-dist-new/observability.d.ts.map +0 -1
  928. package/local-dist-new/observability.js +0 -2
  929. package/local-dist-new/observability.js.map +0 -1
  930. package/local-dist-new/react-host/index.d.ts +0 -10
  931. package/local-dist-new/react-host/index.d.ts.map +0 -1
  932. package/local-dist-new/react-host/index.js +0 -9
  933. package/local-dist-new/react-host/index.js.map +0 -1
  934. package/local-dist-new/react-host/ink.d.ts +0 -6
  935. package/local-dist-new/react-host/ink.d.ts.map +0 -1
  936. package/local-dist-new/react-host/ink.js +0 -7
  937. package/local-dist-new/react-host/ink.js.map +0 -1
  938. package/local-dist-new/react-host/jsx-runtime.d.ts +0 -5
  939. package/local-dist-new/react-host/jsx-runtime.d.ts.map +0 -1
  940. package/local-dist-new/react-host/jsx-runtime.js +0 -6
  941. package/local-dist-new/react-host/jsx-runtime.js.map +0 -1
  942. package/local-dist-new/react-host/loader.d.ts +0 -4
  943. package/local-dist-new/react-host/loader.d.ts.map +0 -1
  944. package/local-dist-new/react-host/loader.js +0 -108
  945. package/local-dist-new/react-host/loader.js.map +0 -1
  946. package/local-dist-new/react-ink/components/ChangelogBlock.d.ts +0 -9
  947. package/local-dist-new/react-ink/components/ChangelogBlock.d.ts.map +0 -1
  948. package/local-dist-new/react-ink/components/ChangelogBlock.js +0 -58
  949. package/local-dist-new/react-ink/components/ChangelogBlock.js.map +0 -1
  950. package/local-dist-new/react-ink/components/DisplayBlockView.d.ts +0 -9
  951. package/local-dist-new/react-ink/components/DisplayBlockView.d.ts.map +0 -1
  952. package/local-dist-new/react-ink/components/DisplayBlockView.js +0 -11
  953. package/local-dist-new/react-ink/components/DisplayBlockView.js.map +0 -1
  954. package/local-dist-new/react-ink/components/Footer.d.ts +0 -12
  955. package/local-dist-new/react-ink/components/Footer.d.ts.map +0 -1
  956. package/local-dist-new/react-ink/components/Footer.js +0 -113
  957. package/local-dist-new/react-ink/components/Footer.js.map +0 -1
  958. package/local-dist-new/react-ink/components/MessageList.d.ts +0 -15
  959. package/local-dist-new/react-ink/components/MessageList.d.ts.map +0 -1
  960. package/local-dist-new/react-ink/components/MessageList.js +0 -43
  961. package/local-dist-new/react-ink/components/MessageList.js.map +0 -1
  962. package/local-dist-new/react-ink/components/MessageRow.d.ts +0 -14
  963. package/local-dist-new/react-ink/components/MessageRow.d.ts.map +0 -1
  964. package/local-dist-new/react-ink/components/MessageRow.js +0 -35
  965. package/local-dist-new/react-ink/components/MessageRow.js.map +0 -1
  966. package/local-dist-new/react-ink/components/StatusLine.d.ts +0 -10
  967. package/local-dist-new/react-ink/components/StatusLine.d.ts.map +0 -1
  968. package/local-dist-new/react-ink/components/StatusLine.js +0 -39
  969. package/local-dist-new/react-ink/components/StatusLine.js.map +0 -1
  970. package/local-dist-new/react-ink/components/TaskPanel.d.ts +0 -12
  971. package/local-dist-new/react-ink/components/TaskPanel.d.ts.map +0 -1
  972. package/local-dist-new/react-ink/components/TaskPanel.js +0 -23
  973. package/local-dist-new/react-ink/components/TaskPanel.js.map +0 -1
  974. package/local-dist-new/react-ink/components/ToolEventBlock.d.ts +0 -18
  975. package/local-dist-new/react-ink/components/ToolEventBlock.d.ts.map +0 -1
  976. package/local-dist-new/react-ink/components/ToolEventBlock.js +0 -61
  977. package/local-dist-new/react-ink/components/ToolEventBlock.js.map +0 -1
  978. package/local-dist-new/react-ink/components/dialogs/DialogFrame.d.ts +0 -9
  979. package/local-dist-new/react-ink/components/dialogs/DialogFrame.d.ts.map +0 -1
  980. package/local-dist-new/react-ink/components/dialogs/DialogFrame.js +0 -6
  981. package/local-dist-new/react-ink/components/dialogs/DialogFrame.js.map +0 -1
  982. package/local-dist-new/react-ink/components/dialogs/LoginDialog.d.ts +0 -15
  983. package/local-dist-new/react-ink/components/dialogs/LoginDialog.d.ts.map +0 -1
  984. package/local-dist-new/react-ink/components/dialogs/LoginDialog.js +0 -10
  985. package/local-dist-new/react-ink/components/dialogs/LoginDialog.js.map +0 -1
  986. package/local-dist-new/react-ink/components/dialogs/ModelDialog.d.ts +0 -10
  987. package/local-dist-new/react-ink/components/dialogs/ModelDialog.d.ts.map +0 -1
  988. package/local-dist-new/react-ink/components/dialogs/ModelDialog.js +0 -64
  989. package/local-dist-new/react-ink/components/dialogs/ModelDialog.js.map +0 -1
  990. package/local-dist-new/react-ink/components/dialogs/OAuthDialog.d.ts +0 -10
  991. package/local-dist-new/react-ink/components/dialogs/OAuthDialog.d.ts.map +0 -1
  992. package/local-dist-new/react-ink/components/dialogs/OAuthDialog.js +0 -24
  993. package/local-dist-new/react-ink/components/dialogs/OAuthDialog.js.map +0 -1
  994. package/local-dist-new/react-ink/components/dialogs/ScopedModelsDialog.d.ts +0 -10
  995. package/local-dist-new/react-ink/components/dialogs/ScopedModelsDialog.d.ts.map +0 -1
  996. package/local-dist-new/react-ink/components/dialogs/ScopedModelsDialog.js +0 -95
  997. package/local-dist-new/react-ink/components/dialogs/ScopedModelsDialog.js.map +0 -1
  998. package/local-dist-new/react-ink/components/dialogs/SelectableDialog.d.ts +0 -17
  999. package/local-dist-new/react-ink/components/dialogs/SelectableDialog.d.ts.map +0 -1
  1000. package/local-dist-new/react-ink/components/dialogs/SelectableDialog.js +0 -66
  1001. package/local-dist-new/react-ink/components/dialogs/SelectableDialog.js.map +0 -1
  1002. package/local-dist-new/react-ink/components/dialogs/SessionDialog.d.ts +0 -14
  1003. package/local-dist-new/react-ink/components/dialogs/SessionDialog.d.ts.map +0 -1
  1004. package/local-dist-new/react-ink/components/dialogs/SessionDialog.js +0 -201
  1005. package/local-dist-new/react-ink/components/dialogs/SessionDialog.js.map +0 -1
  1006. package/local-dist-new/react-ink/components/dialogs/SettingsDialog.d.ts +0 -15
  1007. package/local-dist-new/react-ink/components/dialogs/SettingsDialog.d.ts.map +0 -1
  1008. package/local-dist-new/react-ink/components/dialogs/SettingsDialog.js +0 -79
  1009. package/local-dist-new/react-ink/components/dialogs/SettingsDialog.js.map +0 -1
  1010. package/local-dist-new/react-ink/components/dialogs/StartupSessionPicker.d.ts +0 -10
  1011. package/local-dist-new/react-ink/components/dialogs/StartupSessionPicker.d.ts.map +0 -1
  1012. package/local-dist-new/react-ink/components/dialogs/StartupSessionPicker.js +0 -100
  1013. package/local-dist-new/react-ink/components/dialogs/StartupSessionPicker.js.map +0 -1
  1014. package/local-dist-new/react-ink/components/dialogs/ThemeDialog.d.ts +0 -8
  1015. package/local-dist-new/react-ink/components/dialogs/ThemeDialog.d.ts.map +0 -1
  1016. package/local-dist-new/react-ink/components/dialogs/ThemeDialog.js +0 -7
  1017. package/local-dist-new/react-ink/components/dialogs/ThemeDialog.js.map +0 -1
  1018. package/local-dist-new/react-ink/components/dialogs/TreeDialog.d.ts +0 -9
  1019. package/local-dist-new/react-ink/components/dialogs/TreeDialog.d.ts.map +0 -1
  1020. package/local-dist-new/react-ink/components/dialogs/TreeDialog.js +0 -7
  1021. package/local-dist-new/react-ink/components/dialogs/TreeDialog.js.map +0 -1
  1022. package/local-dist-new/react-ink/components/dialogs/UserMessageDialog.d.ts +0 -9
  1023. package/local-dist-new/react-ink/components/dialogs/UserMessageDialog.d.ts.map +0 -1
  1024. package/local-dist-new/react-ink/components/dialogs/UserMessageDialog.js +0 -7
  1025. package/local-dist-new/react-ink/components/dialogs/UserMessageDialog.js.map +0 -1
  1026. package/local-dist-new/react-ink/components/messages/AssistantMessage.d.ts +0 -13
  1027. package/local-dist-new/react-ink/components/messages/AssistantMessage.d.ts.map +0 -1
  1028. package/local-dist-new/react-ink/components/messages/AssistantMessage.js +0 -20
  1029. package/local-dist-new/react-ink/components/messages/AssistantMessage.js.map +0 -1
  1030. package/local-dist-new/react-ink/components/messages/BashMessage.d.ts +0 -9
  1031. package/local-dist-new/react-ink/components/messages/BashMessage.d.ts.map +0 -1
  1032. package/local-dist-new/react-ink/components/messages/BashMessage.js +0 -11
  1033. package/local-dist-new/react-ink/components/messages/BashMessage.js.map +0 -1
  1034. package/local-dist-new/react-ink/components/messages/BranchSummaryMessage.d.ts +0 -9
  1035. package/local-dist-new/react-ink/components/messages/BranchSummaryMessage.d.ts.map +0 -1
  1036. package/local-dist-new/react-ink/components/messages/BranchSummaryMessage.js +0 -6
  1037. package/local-dist-new/react-ink/components/messages/BranchSummaryMessage.js.map +0 -1
  1038. package/local-dist-new/react-ink/components/messages/CompactionMessage.d.ts +0 -9
  1039. package/local-dist-new/react-ink/components/messages/CompactionMessage.d.ts.map +0 -1
  1040. package/local-dist-new/react-ink/components/messages/CompactionMessage.js +0 -6
  1041. package/local-dist-new/react-ink/components/messages/CompactionMessage.js.map +0 -1
  1042. package/local-dist-new/react-ink/components/messages/CustomMessage.d.ts +0 -10
  1043. package/local-dist-new/react-ink/components/messages/CustomMessage.d.ts.map +0 -1
  1044. package/local-dist-new/react-ink/components/messages/CustomMessage.js +0 -9
  1045. package/local-dist-new/react-ink/components/messages/CustomMessage.js.map +0 -1
  1046. package/local-dist-new/react-ink/components/messages/SkillInvocationMessage.d.ts +0 -8
  1047. package/local-dist-new/react-ink/components/messages/SkillInvocationMessage.d.ts.map +0 -1
  1048. package/local-dist-new/react-ink/components/messages/SkillInvocationMessage.js +0 -10
  1049. package/local-dist-new/react-ink/components/messages/SkillInvocationMessage.js.map +0 -1
  1050. package/local-dist-new/react-ink/components/messages/ToolCallMessage.d.ts +0 -9
  1051. package/local-dist-new/react-ink/components/messages/ToolCallMessage.d.ts.map +0 -1
  1052. package/local-dist-new/react-ink/components/messages/ToolCallMessage.js +0 -8
  1053. package/local-dist-new/react-ink/components/messages/ToolCallMessage.js.map +0 -1
  1054. package/local-dist-new/react-ink/components/messages/ToolResultBlock.d.ts +0 -13
  1055. package/local-dist-new/react-ink/components/messages/ToolResultBlock.d.ts.map +0 -1
  1056. package/local-dist-new/react-ink/components/messages/ToolResultBlock.js +0 -8
  1057. package/local-dist-new/react-ink/components/messages/ToolResultBlock.js.map +0 -1
  1058. package/local-dist-new/react-ink/components/messages/UserMessage.d.ts +0 -10
  1059. package/local-dist-new/react-ink/components/messages/UserMessage.d.ts.map +0 -1
  1060. package/local-dist-new/react-ink/components/messages/UserMessage.js +0 -9
  1061. package/local-dist-new/react-ink/components/messages/UserMessage.js.map +0 -1
  1062. package/local-dist-new/react-ink/index.d.ts +0 -35
  1063. package/local-dist-new/react-ink/index.d.ts.map +0 -1
  1064. package/local-dist-new/react-ink/index.js +0 -35
  1065. package/local-dist-new/react-ink/index.js.map +0 -1
  1066. package/local-dist-new/react-ink/theme-adapter.d.ts +0 -10
  1067. package/local-dist-new/react-ink/theme-adapter.d.ts.map +0 -1
  1068. package/local-dist-new/react-ink/theme-adapter.js +0 -44
  1069. package/local-dist-new/react-ink/theme-adapter.js.map +0 -1
  1070. package/local-dist-new/react-ink/types.d.ts +0 -134
  1071. package/local-dist-new/react-ink/types.d.ts.map +0 -1
  1072. package/local-dist-new/react-ink/types.js +0 -2
  1073. package/local-dist-new/react-ink/types.js.map +0 -1
  1074. package/local-dist-new/react-ink/utils/message-groups.d.ts +0 -26
  1075. package/local-dist-new/react-ink/utils/message-groups.d.ts.map +0 -1
  1076. package/local-dist-new/react-ink/utils/message-groups.js +0 -240
  1077. package/local-dist-new/react-ink/utils/message-groups.js.map +0 -1
  1078. package/local-dist-new/react-ink/utils/selection-dialog.d.ts +0 -3
  1079. package/local-dist-new/react-ink/utils/selection-dialog.d.ts.map +0 -1
  1080. package/local-dist-new/react-ink/utils/selection-dialog.js +0 -18
  1081. package/local-dist-new/react-ink/utils/selection-dialog.js.map +0 -1
  1082. package/local-dist-new/react-ink/utils/session-browser.d.ts +0 -28
  1083. package/local-dist-new/react-ink/utils/session-browser.d.ts.map +0 -1
  1084. package/local-dist-new/react-ink/utils/session-browser.js +0 -191
  1085. package/local-dist-new/react-ink/utils/session-browser.js.map +0 -1
  1086. package/local-dist-new/react-ink/utils/tool-display.d.ts +0 -22
  1087. package/local-dist-new/react-ink/utils/tool-display.d.ts.map +0 -1
  1088. package/local-dist-new/react-ink/utils/tool-display.js +0 -349
  1089. package/local-dist-new/react-ink/utils/tool-display.js.map +0 -1
  1090. package/local-dist-new/react-ink.d.ts +0 -3
  1091. package/local-dist-new/react-ink.d.ts.map +0 -1
  1092. package/local-dist-new/react-ink.js +0 -2
  1093. package/local-dist-new/react-ink.js.map +0 -1
  1094. package/local-dist-new/tui.d.ts +0 -9
  1095. package/local-dist-new/tui.d.ts.map +0 -1
  1096. package/local-dist-new/tui.js +0 -8
  1097. package/local-dist-new/tui.js.map +0 -1
  1098. package/local-dist-new/ui/autocomplete.d.ts +0 -60
  1099. package/local-dist-new/ui/autocomplete.d.ts.map +0 -1
  1100. package/local-dist-new/ui/autocomplete.js +0 -393
  1101. package/local-dist-new/ui/autocomplete.js.map +0 -1
  1102. package/local-dist-new/ui/contracts.d.ts +0 -39
  1103. package/local-dist-new/ui/contracts.d.ts.map +0 -1
  1104. package/local-dist-new/ui/contracts.js +0 -2
  1105. package/local-dist-new/ui/contracts.js.map +0 -1
  1106. package/local-dist-new/ui/editor-component.d.ts +0 -101
  1107. package/local-dist-new/ui/editor-component.d.ts.map +0 -1
  1108. package/local-dist-new/ui/editor-component.js +0 -2
  1109. package/local-dist-new/ui/editor-component.js.map +0 -1
  1110. package/local-dist-new/ui/fuzzy.d.ts +0 -26
  1111. package/local-dist-new/ui/fuzzy.d.ts.map +0 -1
  1112. package/local-dist-new/ui/fuzzy.js +0 -177
  1113. package/local-dist-new/ui/fuzzy.js.map +0 -1
  1114. package/local-dist-new/ui/index.d.ts +0 -9
  1115. package/local-dist-new/ui/index.d.ts.map +0 -1
  1116. package/local-dist-new/ui/index.js +0 -6
  1117. package/local-dist-new/ui/index.js.map +0 -1
  1118. package/local-dist-new/ui/keybindings.d.ts +0 -52
  1119. package/local-dist-new/ui/keybindings.d.ts.map +0 -1
  1120. package/local-dist-new/ui/keybindings.js +0 -193
  1121. package/local-dist-new/ui/keybindings.js.map +0 -1
  1122. package/local-dist-new/ui/keys.d.ts +0 -168
  1123. package/local-dist-new/ui/keys.d.ts.map +0 -1
  1124. package/local-dist-new/ui/keys.js +0 -1093
  1125. package/local-dist-new/ui/keys.js.map +0 -1
  1126. package/local-dist-new/ui/theme-types.d.ts +0 -37
  1127. package/local-dist-new/ui/theme-types.d.ts.map +0 -1
  1128. package/local-dist-new/ui/theme-types.js +0 -2
  1129. package/local-dist-new/ui/theme-types.js.map +0 -1
  1130. package/local-dist-new/ui/utils.d.ts +0 -97
  1131. package/local-dist-new/ui/utils.d.ts.map +0 -1
  1132. package/local-dist-new/ui/utils.js +0 -860
  1133. package/local-dist-new/ui/utils.js.map +0 -1
  1134. package/observe.d.ts +0 -1
  1135. package/observe.js +0 -1
@@ -0,0 +1,3289 @@
1
+ // src/capabilities/kernel/spec.ts
2
+ function coerceInput(raw) {
3
+ if (typeof raw === "string") {
4
+ const trimmed = raw.trim();
5
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
6
+ try {
7
+ return JSON.parse(trimmed);
8
+ } catch {
9
+ }
10
+ }
11
+ return raw;
12
+ }
13
+ if (raw === null || raw === void 0) {
14
+ return {};
15
+ }
16
+ return raw;
17
+ }
18
+ function describeThrow(err) {
19
+ if (err instanceof Error) return err.message;
20
+ if (typeof err === "string") return err;
21
+ try {
22
+ return JSON.stringify(err);
23
+ } catch {
24
+ return String(err);
25
+ }
26
+ }
27
+ function projectOutcome(id, result) {
28
+ const blocks = result.content;
29
+ let output;
30
+ if (blocks.length === 1) {
31
+ const only = blocks[0];
32
+ output = only.kind === "text" ? only.text : only.value;
33
+ } else {
34
+ output = blocks;
35
+ }
36
+ return { id, output, isError: result.isError === true };
37
+ }
38
+ function defineTool(spec) {
39
+ return {
40
+ name: spec.name,
41
+ // Facade `AgentTool` surface: top-level schema fields + an `execute` adapter
42
+ // so the tool is usable by the high-level `Agent` as well as the kernel.
43
+ label: spec.name,
44
+ description: spec.description,
45
+ parameters: spec.parameters,
46
+ async execute(_toolCallId, params, signal) {
47
+ const ctx = {
48
+ cwd: process.cwd(),
49
+ signal: signal ?? new AbortController().signal
50
+ };
51
+ try {
52
+ const result = await spec.run(coerceInput(params), ctx);
53
+ return {
54
+ content: result.content.map(
55
+ (block) => block.kind === "text" ? { type: "text", text: block.text } : { type: "text", text: JSON.stringify(block.value) }
56
+ ),
57
+ details: {},
58
+ isError: result.isError ?? false
59
+ };
60
+ } catch (err) {
61
+ return {
62
+ content: [{ type: "text", text: `${spec.name} did not finish: ${describeThrow(err)}` }],
63
+ details: {},
64
+ isError: true
65
+ };
66
+ }
67
+ },
68
+ descriptor() {
69
+ return {
70
+ name: spec.name,
71
+ description: spec.description,
72
+ parameters: spec.parameters
73
+ };
74
+ },
75
+ async invoke(call, ctx) {
76
+ if (ctx.signal.aborted) {
77
+ return {
78
+ id: call.id,
79
+ output: `Cancelled before ${spec.name} could begin.`,
80
+ isError: true
81
+ };
82
+ }
83
+ try {
84
+ const input = coerceInput(call.input);
85
+ const result = await spec.run(input, ctx);
86
+ return projectOutcome(call.id, result);
87
+ } catch (err) {
88
+ return {
89
+ id: call.id,
90
+ output: `${spec.name} did not finish: ${describeThrow(err)}`,
91
+ isError: true
92
+ };
93
+ }
94
+ }
95
+ };
96
+ }
97
+
98
+ // src/capabilities/kernel/output.ts
99
+ function defaultNotice(omitted) {
100
+ return `
101
+ \u2026 trimmed ${omitted} byte${omitted === 1 ? "" : "s"} to fit the window \u2026
102
+ `;
103
+ }
104
+ function boundaryFromStart(text, byteTarget) {
105
+ let bytes = 0;
106
+ let i = 0;
107
+ while (i < text.length) {
108
+ const cp = text.codePointAt(i);
109
+ const width = utf8Width(cp);
110
+ if (bytes + width > byteTarget) break;
111
+ bytes += width;
112
+ i += cp > 65535 ? 2 : 1;
113
+ }
114
+ return i;
115
+ }
116
+ function boundaryFromEnd(text, byteTarget) {
117
+ let bytes = 0;
118
+ let i = text.length;
119
+ while (i > 0) {
120
+ let prev = i - 1;
121
+ if (prev > 0 && isLowSurrogate(text.charCodeAt(prev)) && isHighSurrogate(text.charCodeAt(prev - 1))) {
122
+ prev -= 1;
123
+ }
124
+ const cp = text.codePointAt(prev);
125
+ const width = utf8Width(cp);
126
+ if (bytes + width > byteTarget) break;
127
+ bytes += width;
128
+ i = prev;
129
+ }
130
+ return i;
131
+ }
132
+ function utf8Width(cp) {
133
+ if (cp <= 127) return 1;
134
+ if (cp <= 2047) return 2;
135
+ if (cp <= 65535) return 3;
136
+ return 4;
137
+ }
138
+ function isHighSurrogate(unit) {
139
+ return unit >= 55296 && unit <= 56319;
140
+ }
141
+ function isLowSurrogate(unit) {
142
+ return unit >= 56320 && unit <= 57343;
143
+ }
144
+ function clamp(text, policy) {
145
+ const total = Buffer.byteLength(text, "utf8");
146
+ if (total <= policy.maxBytes) return text;
147
+ const mark = policy.notice ?? defaultNotice;
148
+ if (policy.kind === "head") {
149
+ const cut = boundaryFromStart(text, policy.maxBytes);
150
+ const kept = text.slice(0, cut);
151
+ const omitted2 = total - Buffer.byteLength(kept, "utf8");
152
+ return kept + mark(omitted2);
153
+ }
154
+ if (policy.kind === "tail") {
155
+ const cut = boundaryFromEnd(text, policy.maxBytes);
156
+ const kept = text.slice(cut);
157
+ const omitted2 = total - Buffer.byteLength(kept, "utf8");
158
+ return mark(omitted2) + kept;
159
+ }
160
+ const headShare = Math.floor(policy.maxBytes / 2);
161
+ const tailShare = policy.maxBytes - headShare;
162
+ const headCut = boundaryFromStart(text, headShare);
163
+ const tailCut = boundaryFromEnd(text, tailShare);
164
+ if (tailCut <= headCut) return text;
165
+ const headKept = text.slice(0, headCut);
166
+ const tailKept = text.slice(tailCut);
167
+ const omitted = total - Buffer.byteLength(headKept, "utf8") - Buffer.byteLength(tailKept, "utf8");
168
+ return headKept + mark(omitted) + tailKept;
169
+ }
170
+
171
+ // src/capabilities/kernel/registry.ts
172
+ var UnknownToolError = class extends Error {
173
+ /** The offending tool or collection name. */
174
+ missing;
175
+ constructor(kind, missing) {
176
+ super(`No ${kind} named "${missing}" is registered.`);
177
+ this.name = "UnknownToolError";
178
+ this.missing = missing;
179
+ }
180
+ };
181
+ var ToolRegistry = class {
182
+ tools = /* @__PURE__ */ new Map();
183
+ collections = /* @__PURE__ */ new Map();
184
+ /** Add a defined tool. A later registration under the same name replaces it. */
185
+ register(tool) {
186
+ this.tools.set(tool.name, tool);
187
+ return this;
188
+ }
189
+ /** Register several tools in one call. */
190
+ registerAll(tools) {
191
+ for (const tool of tools) this.register(tool);
192
+ return this;
193
+ }
194
+ /** True when a tool with this name has been registered. */
195
+ has(name) {
196
+ return this.tools.has(name);
197
+ }
198
+ /** Fetch a registered tool, or throw {@link UnknownToolError} if absent. */
199
+ get(name) {
200
+ const tool = this.tools.get(name);
201
+ if (!tool) throw new UnknownToolError("tool", name);
202
+ return tool;
203
+ }
204
+ /** The names of every registered tool, in registration order. */
205
+ names() {
206
+ return [...this.tools.keys()];
207
+ }
208
+ /**
209
+ * Define (or redefine) a named collection as the given list of tool names.
210
+ * Every listed tool must already be registered.
211
+ */
212
+ collection(name, toolNames) {
213
+ for (const toolName of toolNames) {
214
+ if (!this.tools.has(toolName)) throw new UnknownToolError("tool", toolName);
215
+ }
216
+ this.collections.set(name, [...toolNames]);
217
+ return this;
218
+ }
219
+ /** The tool names belonging to a collection, or throw if it is undefined. */
220
+ membersOf(collectionName) {
221
+ const members = this.collections.get(collectionName);
222
+ if (!members) throw new UnknownToolError("collection", collectionName);
223
+ return [...members];
224
+ }
225
+ /** The names of every defined collection. */
226
+ collectionNames() {
227
+ return [...this.collections.keys()];
228
+ }
229
+ /**
230
+ * Build a runtime {@link ToolBox} from a set of tools.
231
+ *
232
+ * Pass a collection name to box that collection, or omit it to box every
233
+ * registered tool. `ctxFactory` is invoked once per dispatched call to mint
234
+ * the {@link ToolContext} the chosen tool runs under.
235
+ */
236
+ toToolBox(ctxFactory, collectionName) {
237
+ const selected = collectionName === void 0 ? [...this.tools.values()] : this.membersOf(collectionName).map((n) => this.get(n));
238
+ const byName = new Map(selected.map((t) => [t.name, t]));
239
+ const runner = {
240
+ async run(call, signal) {
241
+ const tool = byName.get(call.name);
242
+ if (!tool) {
243
+ return {
244
+ id: call.id,
245
+ output: `This session exposes no tool called "${call.name}".`,
246
+ isError: true
247
+ };
248
+ }
249
+ const base = ctxFactory();
250
+ const ctx = { ...base, signal };
251
+ return tool.invoke(call, ctx);
252
+ }
253
+ };
254
+ return {
255
+ descriptors() {
256
+ return selected.map((t) => t.descriptor());
257
+ },
258
+ runner
259
+ };
260
+ }
261
+ };
262
+
263
+ // src/capabilities/backends/node-backends.ts
264
+ import { promises as fsp } from "node:fs";
265
+ import { spawn as childSpawn } from "node:child_process";
266
+ var NodeFs = class {
267
+ async readFile(path, encoding) {
268
+ if (encoding === void 0) {
269
+ const buf = await fsp.readFile(path);
270
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
271
+ }
272
+ return fsp.readFile(path, { encoding });
273
+ }
274
+ async writeFile(path, data, encoding) {
275
+ if (typeof data === "string") {
276
+ await fsp.writeFile(path, data, { encoding: encoding ?? "utf8" });
277
+ return;
278
+ }
279
+ await fsp.writeFile(path, data);
280
+ }
281
+ async stat(path) {
282
+ const link = await fsp.lstat(path);
283
+ const isSymlink = link.isSymbolicLink();
284
+ const resolved = isSymlink ? await fsp.stat(path) : link;
285
+ return {
286
+ isFile: resolved.isFile(),
287
+ isDirectory: resolved.isDirectory(),
288
+ isSymlink,
289
+ size: resolved.size,
290
+ modifiedMs: resolved.mtimeMs
291
+ };
292
+ }
293
+ async readdir(path) {
294
+ const entries = await fsp.readdir(path, { withFileTypes: true });
295
+ return entries.map((entry) => ({
296
+ name: entry.name,
297
+ isDirectory: entry.isDirectory()
298
+ }));
299
+ }
300
+ async mkdir(path, options) {
301
+ await fsp.mkdir(path, { recursive: options?.recursive ?? false });
302
+ }
303
+ async rm(path, options) {
304
+ await fsp.rm(path, {
305
+ recursive: options?.recursive ?? false,
306
+ force: options?.ignoreMissing ?? false
307
+ });
308
+ }
309
+ async exists(path) {
310
+ try {
311
+ await fsp.stat(path);
312
+ return true;
313
+ } catch {
314
+ return false;
315
+ }
316
+ }
317
+ };
318
+ var nodeFs = new NodeFs();
319
+ function joinChunks(chunks) {
320
+ return Buffer.concat(chunks).toString("utf8");
321
+ }
322
+ function asSignal(signal) {
323
+ return signal;
324
+ }
325
+ var NodeShell = class {
326
+ exec(command, options) {
327
+ if (typeof command !== "string" || command.length === 0) {
328
+ return Promise.reject(
329
+ new Error("A shell command must be a non-empty string.")
330
+ );
331
+ }
332
+ return new Promise((resolve, reject) => {
333
+ const child = childSpawn(command, {
334
+ shell: true,
335
+ cwd: options?.cwd,
336
+ env: options?.env ? { ...process.env, ...options.env } : process.env,
337
+ signal: options?.signal
338
+ });
339
+ const out = [];
340
+ const err = [];
341
+ let settled = false;
342
+ let timedOut = false;
343
+ let timer;
344
+ const finish = (fn) => {
345
+ if (settled) return;
346
+ settled = true;
347
+ if (timer !== void 0) clearTimeout(timer);
348
+ fn();
349
+ };
350
+ child.stdout?.on("data", (chunk) => out.push(chunk));
351
+ child.stderr?.on("data", (chunk) => err.push(chunk));
352
+ if (options?.input !== void 0 && child.stdin) {
353
+ child.stdin.write(options.input);
354
+ child.stdin.end();
355
+ } else {
356
+ child.stdin?.end();
357
+ }
358
+ const limit = options?.timeoutMs;
359
+ if (limit !== void 0 && limit > 0) {
360
+ timer = setTimeout(() => {
361
+ timedOut = true;
362
+ child.kill("SIGTERM");
363
+ }, limit);
364
+ }
365
+ child.on("error", (cause) => {
366
+ finish(() => reject(cause));
367
+ });
368
+ child.on("close", (code, signal) => {
369
+ finish(() => {
370
+ if (timedOut) {
371
+ reject(
372
+ new Error(
373
+ `The command exceeded its ${limit}ms deadline and was stopped.`
374
+ )
375
+ );
376
+ return;
377
+ }
378
+ resolve({
379
+ stdout: joinChunks(out),
380
+ stderr: joinChunks(err),
381
+ // On a signalled exit Node reports a null code; preserve that so the
382
+ // caller can tell "killed" apart from "exited 0".
383
+ code: signal !== null ? null : code
384
+ });
385
+ });
386
+ });
387
+ });
388
+ }
389
+ spawn(command, options) {
390
+ if (typeof command !== "string" || command.length === 0) {
391
+ throw new Error("A shell command must be a non-empty string.");
392
+ }
393
+ const child = childSpawn(command, {
394
+ shell: true,
395
+ cwd: options?.cwd,
396
+ env: options?.env ? { ...process.env, ...options.env } : process.env,
397
+ signal: options?.signal
398
+ });
399
+ return new NodeShellHandle(child);
400
+ }
401
+ };
402
+ var NodeShellHandle = class {
403
+ child;
404
+ listeners = /* @__PURE__ */ new Set();
405
+ exited = false;
406
+ exitCode = null;
407
+ exitSignal = null;
408
+ constructor(child) {
409
+ this.child = child;
410
+ child.once(
411
+ "close",
412
+ (code, signal) => {
413
+ this.exited = true;
414
+ this.exitCode = code;
415
+ this.exitSignal = asSignal(signal);
416
+ for (const listener of [...this.listeners]) {
417
+ listener(this.exitCode, this.exitSignal);
418
+ }
419
+ this.listeners.clear();
420
+ }
421
+ );
422
+ }
423
+ get pid() {
424
+ return this.child.pid;
425
+ }
426
+ kill(signal) {
427
+ if (this.exited) return;
428
+ this.child.kill(signal ?? "SIGTERM");
429
+ }
430
+ onExit(listener) {
431
+ if (this.exited) {
432
+ const code = this.exitCode;
433
+ const signal = this.exitSignal;
434
+ queueMicrotask(() => listener(code, signal));
435
+ return () => {
436
+ };
437
+ }
438
+ this.listeners.add(listener);
439
+ return () => {
440
+ this.listeners.delete(listener);
441
+ };
442
+ }
443
+ };
444
+ var nodeShell = new NodeShell();
445
+ var standardBudget = {
446
+ kind: "middle",
447
+ maxBytes: 64 * 1024,
448
+ notice: (omitted) => `
449
+ [${omitted} bytes elided to stay within the output ceiling]
450
+ `
451
+ };
452
+
453
+ // src/capabilities/files/read.ts
454
+ var GUTTER_WIDTH = 6;
455
+ var DESCRIPTION = [
456
+ "Return the contents of a UTF-8 text file, with each line preceded by its",
457
+ "1-based line number. Pass `offset` to begin partway down a large file and",
458
+ "`limit` to cap how many lines come back; together they let you page through",
459
+ "a file in chunks. Output is automatically bounded to fit the model context \u2014",
460
+ "if the selected text is still too large it is shortened and a marker is left",
461
+ "in place of the removed portion."
462
+ ].join(" ");
463
+ function readPositiveInt(value, label) {
464
+ if (value === void 0 || value === null) {
465
+ return { ok: true, value: void 0 };
466
+ }
467
+ if (typeof value !== "number" || !Number.isFinite(value)) {
468
+ return { ok: false, reason: `${label} must be a number when provided.` };
469
+ }
470
+ if (!Number.isInteger(value)) {
471
+ return { ok: false, reason: `${label} must be a whole number, not ${value}.` };
472
+ }
473
+ if (value < 1) {
474
+ return { ok: false, reason: `${label} must be at least 1; got ${value}.` };
475
+ }
476
+ return { ok: true, value };
477
+ }
478
+ function failure(message) {
479
+ return { content: [{ kind: "text", text: message }], isError: true };
480
+ }
481
+ function withGutter(slice, firstLineNumber) {
482
+ const rendered = [];
483
+ for (let i = 0; i < slice.length; i += 1) {
484
+ const lineNo = firstLineNumber + i;
485
+ const label = String(lineNo).padStart(GUTTER_WIDTH, " ");
486
+ rendered.push(`${label} ${slice[i]}`);
487
+ }
488
+ return rendered.join("\n");
489
+ }
490
+ function toLines(text) {
491
+ if (text.length === 0) return [];
492
+ const lines = text.split("\n");
493
+ if (lines.length > 0 && lines[lines.length - 1] === "") {
494
+ lines.pop();
495
+ }
496
+ return lines;
497
+ }
498
+ var readTool = defineTool({
499
+ name: "read",
500
+ description: DESCRIPTION,
501
+ parameters: {
502
+ type: "object",
503
+ properties: {
504
+ path: {
505
+ type: "string",
506
+ description: "Filesystem path of the text file to open."
507
+ },
508
+ offset: {
509
+ type: "integer",
510
+ minimum: 1,
511
+ description: "1-based line number to start reading at. Defaults to the first line."
512
+ },
513
+ limit: {
514
+ type: "integer",
515
+ minimum: 1,
516
+ description: "Greatest number of lines to return, counting from the start line."
517
+ }
518
+ },
519
+ required: ["path"],
520
+ additionalProperties: false
521
+ },
522
+ async run(input, ctx) {
523
+ const raw = input;
524
+ const bag = raw !== null && typeof raw === "object" ? raw : {};
525
+ const rawPath = bag.path;
526
+ if (typeof rawPath !== "string" || rawPath.trim().length === 0) {
527
+ return failure("A non-empty `path` string is required to read a file.");
528
+ }
529
+ const path = rawPath;
530
+ const offsetParse = readPositiveInt(bag.offset, "offset");
531
+ if (!offsetParse.ok) return failure(offsetParse.reason);
532
+ const offset = offsetParse.value;
533
+ const limitParse = readPositiveInt(bag.limit, "limit");
534
+ if (!limitParse.ok) return failure(limitParse.reason);
535
+ const limit = limitParse.value;
536
+ let info;
537
+ try {
538
+ info = await ctx.fs.stat(path);
539
+ } catch {
540
+ return failure(`Nothing readable was found at ${path}.`);
541
+ }
542
+ if (info.isDirectory) {
543
+ return failure(`${path} is a directory, so there is no file text to show.`);
544
+ }
545
+ if (!info.isFile) {
546
+ return failure(`${path} is not a regular file and cannot be read as text.`);
547
+ }
548
+ let text;
549
+ try {
550
+ text = await ctx.fs.readFile(path, "utf8");
551
+ } catch (err) {
552
+ const detail = err instanceof Error ? err.message : String(err);
553
+ return failure(`Could not read ${path}: ${detail}`);
554
+ }
555
+ const allLines = toLines(text);
556
+ const totalLines = allLines.length;
557
+ if (totalLines === 0) {
558
+ return {
559
+ content: [{ kind: "text", text: `${path} is empty (no lines to show).` }]
560
+ };
561
+ }
562
+ const startIndex = offset === void 0 ? 0 : offset - 1;
563
+ if (startIndex >= totalLines) {
564
+ return failure(
565
+ `Start line ${offset} is past the end of ${path}, which has ${totalLines} line${totalLines === 1 ? "" : "s"}.`
566
+ );
567
+ }
568
+ const endIndex = limit === void 0 ? totalLines : Math.min(totalLines, startIndex + limit);
569
+ const windowLines = allLines.slice(startIndex, endIndex);
570
+ const firstLineNumber = startIndex + 1;
571
+ const lastLineNumber = endIndex;
572
+ const windowed = startIndex > 0 || endIndex < totalLines;
573
+ const gutterText = withGutter(windowLines, firstLineNumber);
574
+ const clamped = clamp(gutterText, {
575
+ kind: ctx.budget.kind,
576
+ maxBytes: ctx.budget.maxBytes,
577
+ notice: (omitted) => `
578
+ [read: ${omitted} more byte${omitted === 1 ? "" : "s"} of this file were left out to stay within the response budget]
579
+ `
580
+ });
581
+ const byteTrimmed = clamped !== gutterText;
582
+ const headerParts = [];
583
+ if (windowed) {
584
+ headerParts.push(
585
+ `Showing lines ${firstLineNumber}\u2013${lastLineNumber} of ${totalLines} in ${path}.`
586
+ );
587
+ } else {
588
+ headerParts.push(
589
+ `Showing all ${totalLines} line${totalLines === 1 ? "" : "s"} of ${path}.`
590
+ );
591
+ }
592
+ if (windowed && lastLineNumber < totalLines) {
593
+ const remaining = totalLines - lastLineNumber;
594
+ headerParts.push(
595
+ `${remaining} further line${remaining === 1 ? "" : "s"} follow; raise the start line to keep reading.`
596
+ );
597
+ }
598
+ if (byteTrimmed) {
599
+ headerParts.push(
600
+ "This slice was additionally shortened to fit the response budget (see the inline marker)."
601
+ );
602
+ }
603
+ const body = `${headerParts.join(" ")}
604
+
605
+ ${clamped}`;
606
+ return { content: [{ kind: "text", text: body }] };
607
+ }
608
+ });
609
+
610
+ // src/capabilities/files/write.ts
611
+ var writeParameters = {
612
+ type: "object",
613
+ additionalProperties: false,
614
+ required: ["path", "content"],
615
+ properties: {
616
+ path: {
617
+ type: "string",
618
+ description: "Where the file should be written. A relative path is taken against the session's working directory. Any missing parent folders are created automatically."
619
+ },
620
+ content: {
621
+ type: "string",
622
+ description: "The full text to store. An existing file at this path is replaced wholesale, not appended to."
623
+ }
624
+ }
625
+ };
626
+ function asText(text, failed = false) {
627
+ return { content: [{ kind: "text", text }], isError: failed };
628
+ }
629
+ function readPath(raw) {
630
+ if (typeof raw !== "string") {
631
+ throw new Error("the 'path' argument must be a string naming the file to write");
632
+ }
633
+ if (raw.trim().length === 0) {
634
+ throw new Error("the 'path' argument cannot be empty or whitespace-only");
635
+ }
636
+ return raw;
637
+ }
638
+ function readContent(raw) {
639
+ if (raw === void 0 || raw === null) {
640
+ return "";
641
+ }
642
+ if (typeof raw !== "string") {
643
+ throw new Error("the 'content' argument must be a string of text to write");
644
+ }
645
+ return raw;
646
+ }
647
+ function parentDir(path) {
648
+ const normalized = path.replace(/\\/g, "/");
649
+ const cut = normalized.lastIndexOf("/");
650
+ if (cut <= 0) {
651
+ return "";
652
+ }
653
+ return normalized.slice(0, cut);
654
+ }
655
+ var writeTool = defineTool({
656
+ name: "write",
657
+ description: "Save a UTF-8 text file at the given path, overwriting any file already there. Missing parent directories are created first. Returns a short confirmation including the byte count that was written. Use this to produce or replace whole-file contents; it does not merge or patch.",
658
+ parameters: writeParameters,
659
+ async run(input, ctx) {
660
+ const path = readPath(input?.path);
661
+ const content = readContent(input?.content);
662
+ const folder = parentDir(path);
663
+ if (folder.length > 0) {
664
+ await ctx.fs.mkdir(folder, { recursive: true });
665
+ }
666
+ await ctx.fs.writeFile(path, content, "utf8");
667
+ const bytes = Buffer.byteLength(content, "utf8");
668
+ const unit = bytes === 1 ? "byte" : "bytes";
669
+ return asText(`Saved ${bytes} ${unit} to ${path}.`);
670
+ }
671
+ });
672
+
673
+ // src/capabilities/files/diff.ts
674
+ function splitLines(text) {
675
+ if (text.length === 0) return [""];
676
+ const normalized = text.replace(/\r\n/g, "\n");
677
+ const parts = normalized.split("\n");
678
+ if (parts.length > 1 && parts[parts.length - 1] === "") {
679
+ parts.pop();
680
+ }
681
+ return parts;
682
+ }
683
+ function computeTrace(a, b) {
684
+ const n = a.length;
685
+ const m = b.length;
686
+ const max = n + m;
687
+ const offset = max;
688
+ const v = new Array(2 * max + 1).fill(0);
689
+ const trace = [];
690
+ for (let d = 0; d <= max; d++) {
691
+ trace.push(v.slice());
692
+ for (let k = -d; k <= d; k += 2) {
693
+ let x;
694
+ if (k === -d || k !== d && v[offset + k - 1] < v[offset + k + 1]) {
695
+ x = v[offset + k + 1];
696
+ } else {
697
+ x = v[offset + k - 1] + 1;
698
+ }
699
+ let y = x - k;
700
+ while (x < n && y < m && a[x] === b[y]) {
701
+ x++;
702
+ y++;
703
+ }
704
+ v[offset + k] = x;
705
+ if (x >= n && y >= m) {
706
+ return trace;
707
+ }
708
+ }
709
+ }
710
+ return trace;
711
+ }
712
+ function backtrack(a, b, trace) {
713
+ const n = a.length;
714
+ const m = b.length;
715
+ const offset = n + m;
716
+ const ops = [];
717
+ let x = n;
718
+ let y = m;
719
+ for (let d = trace.length - 1; d >= 0; d--) {
720
+ const v = trace[d];
721
+ const k = x - y;
722
+ let prevK;
723
+ if (k === -d || k !== d && v[offset + k - 1] < v[offset + k + 1]) {
724
+ prevK = k + 1;
725
+ } else {
726
+ prevK = k - 1;
727
+ }
728
+ const prevX = v[offset + prevK];
729
+ const prevY = prevX - prevK;
730
+ while (x > prevX && y > prevY) {
731
+ ops.push({
732
+ kind: "keep",
733
+ text: a[x - 1],
734
+ beforeLine: x,
735
+ afterLine: y
736
+ });
737
+ x--;
738
+ y--;
739
+ }
740
+ if (d > 0) {
741
+ if (x === prevX) {
742
+ ops.push({ kind: "add", text: b[prevY], afterLine: prevY + 1 });
743
+ } else {
744
+ ops.push({ kind: "remove", text: a[prevX], beforeLine: prevX + 1 });
745
+ }
746
+ }
747
+ x = prevX;
748
+ y = prevY;
749
+ }
750
+ ops.reverse();
751
+ return ops;
752
+ }
753
+ function diffLines(before, after) {
754
+ const a = splitLines(before);
755
+ const b = splitLines(after);
756
+ const trace = computeTrace(a, b);
757
+ const ops = backtrack(a, b, trace);
758
+ let added = 0;
759
+ let removed = 0;
760
+ for (const op of ops) {
761
+ if (op.kind === "add") added++;
762
+ else if (op.kind === "remove") removed++;
763
+ }
764
+ return { ops, added, removed };
765
+ }
766
+ function buildHunks(ops, context) {
767
+ const hunks = [];
768
+ let current = null;
769
+ let trailingKeeps = 0;
770
+ const openHunk = (atIndex) => {
771
+ const lead = [];
772
+ for (let i = atIndex - 1; i >= 0 && lead.length < context && ops[i].kind === "keep"; i--) {
773
+ lead.unshift(ops[i]);
774
+ }
775
+ const first = lead[0] ?? ops[atIndex];
776
+ const hunk = {
777
+ beforeStart: first.beforeLine ?? 1,
778
+ beforeCount: 0,
779
+ afterStart: first.afterLine ?? 1,
780
+ afterCount: 0,
781
+ ops: [...lead]
782
+ };
783
+ return hunk;
784
+ };
785
+ for (let i = 0; i < ops.length; i++) {
786
+ const op = ops[i];
787
+ if (op.kind === "keep") {
788
+ if (current) {
789
+ if (trailingKeeps < context) {
790
+ current.ops.push(op);
791
+ trailingKeeps++;
792
+ } else {
793
+ hunks.push(current);
794
+ current = null;
795
+ trailingKeeps = 0;
796
+ }
797
+ }
798
+ continue;
799
+ }
800
+ if (!current) {
801
+ current = openHunk(i);
802
+ }
803
+ current.ops.push(op);
804
+ trailingKeeps = 0;
805
+ }
806
+ if (current) hunks.push(current);
807
+ for (const hunk of hunks) {
808
+ let beforeCount = 0;
809
+ let afterCount = 0;
810
+ let beforeStart = 0;
811
+ let afterStart = 0;
812
+ for (const op of hunk.ops) {
813
+ if (op.kind !== "add") {
814
+ if (beforeStart === 0 && op.beforeLine) beforeStart = op.beforeLine;
815
+ beforeCount++;
816
+ }
817
+ if (op.kind !== "remove") {
818
+ if (afterStart === 0 && op.afterLine) afterStart = op.afterLine;
819
+ afterCount++;
820
+ }
821
+ }
822
+ hunk.beforeStart = beforeStart || (beforeCount === 0 ? 0 : 1);
823
+ hunk.afterStart = afterStart || (afterCount === 0 ? 0 : 1);
824
+ hunk.beforeCount = beforeCount;
825
+ hunk.afterCount = afterCount;
826
+ }
827
+ return hunks;
828
+ }
829
+ function prefixFor(kind) {
830
+ if (kind === "add") return "+";
831
+ if (kind === "remove") return "-";
832
+ return " ";
833
+ }
834
+ function renderUnifiedDiff(before, after, context = 3) {
835
+ const { ops } = diffLines(before, after);
836
+ const hasChange = ops.some((op) => op.kind !== "keep");
837
+ if (!hasChange) return "";
838
+ const hunks = buildHunks(ops, context);
839
+ const lines = [];
840
+ for (const hunk of hunks) {
841
+ lines.push(
842
+ `@@ -${hunk.beforeStart},${hunk.beforeCount} +${hunk.afterStart},${hunk.afterCount} @@`
843
+ );
844
+ for (const op of hunk.ops) {
845
+ lines.push(prefixFor(op.kind) + op.text);
846
+ }
847
+ }
848
+ return lines.join("\n");
849
+ }
850
+
851
+ // src/capabilities/files/edit.ts
852
+ var DIFF_BYTE_CEILING = 16e3;
853
+ function canonicalizeWhitespace(text) {
854
+ return text.replace(/\s+/g, " ").trim();
855
+ }
856
+ function countLiteral(haystack, needle) {
857
+ if (needle.length === 0) return 0;
858
+ let count = 0;
859
+ let from = 0;
860
+ for (; ; ) {
861
+ const at = haystack.indexOf(needle, from);
862
+ if (at === -1) break;
863
+ count++;
864
+ from = at + needle.length;
865
+ }
866
+ return count;
867
+ }
868
+ function replaceAllLiteral(haystack, needle, value) {
869
+ const pieces = [];
870
+ let from = 0;
871
+ for (; ; ) {
872
+ const at = haystack.indexOf(needle, from);
873
+ if (at === -1) {
874
+ pieces.push(haystack.slice(from));
875
+ break;
876
+ }
877
+ pieces.push(haystack.slice(from, at), value);
878
+ from = at + needle.length;
879
+ }
880
+ return pieces.join("");
881
+ }
882
+ function findFuzzySpans(source, target) {
883
+ const wantCanonical = canonicalizeWhitespace(target);
884
+ if (wantCanonical.length === 0) return [];
885
+ const isSpace = (ch) => /\s/.test(ch);
886
+ const spans = [];
887
+ for (let start = 0; start < source.length; start++) {
888
+ if (isSpace(source[start])) continue;
889
+ for (let end = start + 1; end <= source.length; end++) {
890
+ const windowCanonical = canonicalizeWhitespace(source.slice(start, end));
891
+ if (windowCanonical.length > wantCanonical.length) {
892
+ break;
893
+ }
894
+ if (windowCanonical === wantCanonical) {
895
+ let trimmedEnd = end;
896
+ while (trimmedEnd > start && isSpace(source[trimmedEnd - 1])) {
897
+ trimmedEnd--;
898
+ }
899
+ spans.push({ start, end: trimmedEnd });
900
+ start = trimmedEnd - 1;
901
+ break;
902
+ }
903
+ }
904
+ }
905
+ return spans;
906
+ }
907
+ function failure2(message) {
908
+ return { content: [{ kind: "text", text: message }], isError: true };
909
+ }
910
+ function success(path, before, after, replacements) {
911
+ const rawDiff = renderUnifiedDiff(before, after);
912
+ const diff = clamp(rawDiff, {
913
+ kind: "middle",
914
+ maxBytes: DIFF_BYTE_CEILING,
915
+ notice: (omitted) => `
916
+ \u2026 diff shortened, ${omitted} byte(s) of the middle omitted \u2026
917
+ `
918
+ });
919
+ const plural = replacements === 1 ? "" : "s";
920
+ const summary = `Updated ${path} \u2014 applied ${replacements} replacement${plural}.`;
921
+ const json = {
922
+ kind: "json",
923
+ value: { path, replacements, diff }
924
+ };
925
+ return { content: [{ kind: "text", text: summary }, json] };
926
+ }
927
+ async function runEdit(input, ctx) {
928
+ if (typeof input !== "object" || input === null) {
929
+ return failure2("The edit tool expects an object with path, oldText, and newText.");
930
+ }
931
+ const { path, oldText, newText } = input;
932
+ if (typeof path !== "string" || path.trim().length === 0) {
933
+ return failure2("Provide a non-empty `path` string naming the file to edit.");
934
+ }
935
+ if (typeof oldText !== "string") {
936
+ return failure2("`oldText` must be a string holding the snippet to replace.");
937
+ }
938
+ if (typeof newText !== "string") {
939
+ return failure2("`newText` must be a string holding the replacement snippet.");
940
+ }
941
+ if (oldText.length === 0) {
942
+ return failure2("`oldText` cannot be empty \u2014 give the exact text you want replaced.");
943
+ }
944
+ if (oldText === newText) {
945
+ return failure2("`oldText` and `newText` are identical, so there is nothing to change.");
946
+ }
947
+ const replaceAll = input.replaceAll === true;
948
+ const present = await ctx.fs.exists(path);
949
+ if (!present) {
950
+ return failure2(`No file exists at ${path}; nothing to edit.`);
951
+ }
952
+ const info = await ctx.fs.stat(path);
953
+ if (!info.isFile) {
954
+ return failure2(`${path} is not a regular file, so it cannot be edited.`);
955
+ }
956
+ const before = await ctx.fs.readFile(path, "utf8");
957
+ const literalHits = countLiteral(before, oldText);
958
+ if (literalHits > 0) {
959
+ if (!replaceAll && literalHits > 1) {
960
+ return failure2(
961
+ `Found ${literalHits} exact matches for the snippet in ${path}. Pass replaceAll: true to change them all, or widen \`oldText\` so it pinpoints a single location.`
962
+ );
963
+ }
964
+ const after2 = replaceAll ? replaceAllLiteral(before, oldText, newText) : before.replace(oldText, newText);
965
+ if (after2 === before) {
966
+ return failure2(`The replacement left ${path} unchanged.`);
967
+ }
968
+ await ctx.fs.writeFile(path, after2, "utf8");
969
+ return success(path, before, after2, replaceAll ? literalHits : 1);
970
+ }
971
+ const spans = findFuzzySpans(before, oldText);
972
+ if (spans.length === 0) {
973
+ return failure2(
974
+ `Could not locate the snippet in ${path}, even after ignoring whitespace differences. Re-check \`oldText\` against the file's current contents.`
975
+ );
976
+ }
977
+ if (!replaceAll && spans.length > 1) {
978
+ return failure2(
979
+ `The snippet matches ${spans.length} regions of ${path} once whitespace is ignored. Pass replaceAll: true, or extend \`oldText\` to target one region.`
980
+ );
981
+ }
982
+ const targets = replaceAll ? spans : [spans[0]];
983
+ let after = before;
984
+ for (let i = targets.length - 1; i >= 0; i--) {
985
+ const { start, end } = targets[i];
986
+ after = after.slice(0, start) + newText + after.slice(end);
987
+ }
988
+ if (after === before) {
989
+ return failure2(`The fuzzy replacement left ${path} unchanged.`);
990
+ }
991
+ await ctx.fs.writeFile(path, after, "utf8");
992
+ return success(path, before, after, targets.length);
993
+ }
994
+ var editTool = defineTool({
995
+ name: "edit",
996
+ description: "Replace a snippet of text inside one file. By default the snippet (`oldText`) must appear exactly once; if no exact match is found, a single whitespace-tolerant match is attempted. Set `replaceAll` to change every occurrence. Returns a unified-style diff of what changed. The edit is refused when the snippet is missing or matches ambiguously.",
997
+ parameters: {
998
+ type: "object",
999
+ additionalProperties: false,
1000
+ required: ["path", "oldText", "newText"],
1001
+ properties: {
1002
+ path: {
1003
+ type: "string",
1004
+ description: "Path to the file to edit, relative to the working directory or absolute."
1005
+ },
1006
+ oldText: {
1007
+ type: "string",
1008
+ description: "The exact text to find and replace. Must be non-empty."
1009
+ },
1010
+ newText: {
1011
+ type: "string",
1012
+ description: "The text to put in place of `oldText`."
1013
+ },
1014
+ replaceAll: {
1015
+ type: "boolean",
1016
+ description: "Replace every occurrence instead of requiring a single unique match. Defaults to false."
1017
+ }
1018
+ }
1019
+ },
1020
+ run: runEdit
1021
+ });
1022
+
1023
+ // src/capabilities/files/ls.ts
1024
+ var lsParameters = {
1025
+ type: "object",
1026
+ additionalProperties: false,
1027
+ properties: {
1028
+ path: {
1029
+ type: "string",
1030
+ description: "Directory whose immediate contents should be listed. Leave this out to enumerate the session's current working directory."
1031
+ },
1032
+ showHidden: {
1033
+ type: "boolean",
1034
+ description: "Set to true to also surface dot-prefixed entries (such as `.git` or `.env`), which are omitted otherwise."
1035
+ }
1036
+ },
1037
+ required: []
1038
+ };
1039
+ var DESCRIPTION2 = [
1040
+ "List the direct children of a directory, reporting each entry's name, its",
1041
+ "kind (file, directory, symlink, or other), and its size in bytes. Only the",
1042
+ "immediate level is shown \u2014 this does not descend into subdirectories. Pass",
1043
+ "`path` to point at a specific folder, or omit it to read the working",
1044
+ "directory; set `showHidden` to true to include dot-prefixed entries. Long",
1045
+ "listings are trimmed to stay within the response budget."
1046
+ ].join(" ");
1047
+ function failure3(message) {
1048
+ return { content: [{ kind: "text", text: message }], isError: true };
1049
+ }
1050
+ function isHiddenName(name) {
1051
+ return name.startsWith(".");
1052
+ }
1053
+ function compareEntries(a, b) {
1054
+ const aDir = a.kind === "directory";
1055
+ const bDir = b.kind === "directory";
1056
+ if (aDir !== bDir) return aDir ? -1 : 1;
1057
+ const aKey = a.name.toLowerCase();
1058
+ const bKey = b.name.toLowerCase();
1059
+ if (aKey < bKey) return -1;
1060
+ if (aKey > bKey) return 1;
1061
+ if (a.name < b.name) return -1;
1062
+ if (a.name > b.name) return 1;
1063
+ return 0;
1064
+ }
1065
+ function renderRow(entry, kindWidth, sizeWidth) {
1066
+ const kindCell = entry.kind.padEnd(kindWidth, " ");
1067
+ const sizeCell = String(entry.size).padStart(sizeWidth, " ");
1068
+ const display = entry.kind === "directory" ? `${entry.name}/` : entry.name;
1069
+ return `${kindCell} ${sizeCell} ${display}`;
1070
+ }
1071
+ var lsTool = defineTool({
1072
+ name: "ls",
1073
+ description: DESCRIPTION2,
1074
+ parameters: lsParameters,
1075
+ async run(input, ctx) {
1076
+ const raw = input;
1077
+ const bag = raw !== null && typeof raw === "object" ? raw : {};
1078
+ const rawPath = bag.path;
1079
+ let path;
1080
+ if (rawPath === void 0 || rawPath === null) {
1081
+ path = ctx.cwd;
1082
+ } else if (typeof rawPath === "string") {
1083
+ const trimmed = rawPath.trim();
1084
+ path = trimmed.length === 0 ? ctx.cwd : rawPath;
1085
+ } else {
1086
+ return failure3("`path` must be a string when provided.");
1087
+ }
1088
+ const rawShowHidden = bag.showHidden;
1089
+ let showHidden = false;
1090
+ if (rawShowHidden !== void 0 && rawShowHidden !== null) {
1091
+ if (typeof rawShowHidden !== "boolean") {
1092
+ return failure3("`showHidden` must be a boolean when provided.");
1093
+ }
1094
+ showHidden = rawShowHidden;
1095
+ }
1096
+ let info;
1097
+ try {
1098
+ info = await ctx.fs.stat(path);
1099
+ } catch {
1100
+ return failure3(`No directory was found at ${path}.`);
1101
+ }
1102
+ if (!info.isDirectory) {
1103
+ return failure3(`${path} is not a directory, so it cannot be listed.`);
1104
+ }
1105
+ let children;
1106
+ try {
1107
+ children = await ctx.fs.readdir(path);
1108
+ } catch (err) {
1109
+ const detail = err instanceof Error ? err.message : String(err);
1110
+ return failure3(`Could not read the contents of ${path}: ${detail}`);
1111
+ }
1112
+ const entries = [];
1113
+ let hiddenSkipped = 0;
1114
+ for (const child of children) {
1115
+ if (!showHidden && isHiddenName(child.name)) {
1116
+ hiddenSkipped += 1;
1117
+ continue;
1118
+ }
1119
+ const childPath = joinPath(path, child.name);
1120
+ let kind;
1121
+ let size = 0;
1122
+ try {
1123
+ const childInfo = await ctx.fs.stat(childPath);
1124
+ if (childInfo.isSymlink) {
1125
+ kind = "symlink";
1126
+ } else if (childInfo.isDirectory) {
1127
+ kind = "directory";
1128
+ } else if (childInfo.isFile) {
1129
+ kind = "file";
1130
+ } else {
1131
+ kind = "other";
1132
+ }
1133
+ size = childInfo.isDirectory ? 0 : childInfo.size;
1134
+ } catch {
1135
+ kind = child.isDirectory ? "directory" : "other";
1136
+ size = 0;
1137
+ }
1138
+ entries.push({ name: child.name, kind, size });
1139
+ }
1140
+ if (entries.length === 0) {
1141
+ const note = hiddenSkipped > 0 ? ` (${hiddenSkipped} hidden entr${hiddenSkipped === 1 ? "y was" : "ies were"} omitted; pass showHidden to reveal them)` : "";
1142
+ return {
1143
+ content: [
1144
+ { kind: "text", text: `${path} contains no listable entries${note}.` }
1145
+ ]
1146
+ };
1147
+ }
1148
+ entries.sort(compareEntries);
1149
+ let kindWidth = 0;
1150
+ let sizeWidth = 0;
1151
+ for (const entry of entries) {
1152
+ if (entry.kind.length > kindWidth) kindWidth = entry.kind.length;
1153
+ const sizeLen = String(entry.size).length;
1154
+ if (sizeLen > sizeWidth) sizeWidth = sizeLen;
1155
+ }
1156
+ const rows = entries.map((entry) => renderRow(entry, kindWidth, sizeWidth));
1157
+ const table2 = rows.join("\n");
1158
+ const clamped = clamp(table2, {
1159
+ kind: ctx.budget.kind,
1160
+ maxBytes: ctx.budget.maxBytes,
1161
+ notice: (omitted) => `
1162
+ [ls: ${omitted} more byte${omitted === 1 ? "" : "s"} of this listing were withheld to fit the response budget]
1163
+ `
1164
+ });
1165
+ const byteTrimmed = clamped !== table2;
1166
+ const headerParts = [];
1167
+ headerParts.push(
1168
+ `${entries.length} entr${entries.length === 1 ? "y" : "ies"} in ${path}:`
1169
+ );
1170
+ if (!showHidden && hiddenSkipped > 0) {
1171
+ headerParts.push(
1172
+ `(${hiddenSkipped} hidden entr${hiddenSkipped === 1 ? "y" : "ies"} not shown; pass showHidden to include them.)`
1173
+ );
1174
+ }
1175
+ if (byteTrimmed) {
1176
+ headerParts.push(
1177
+ "This listing was shortened to fit the response budget (see the inline marker)."
1178
+ );
1179
+ }
1180
+ const body = `${headerParts.join(" ")}
1181
+
1182
+ ${clamped}`;
1183
+ return { content: [{ kind: "text", text: body }] };
1184
+ }
1185
+ });
1186
+ function joinPath(dir, name) {
1187
+ if (dir.length === 0) return name;
1188
+ const last = dir[dir.length - 1];
1189
+ if (last === "/" || last === "\\") {
1190
+ return `${dir}${name}`;
1191
+ }
1192
+ return `${dir}/${name}`;
1193
+ }
1194
+
1195
+ // src/capabilities/search/grep.ts
1196
+ var PRUNED_DIRS = /* @__PURE__ */ new Set([".git", "node_modules"]);
1197
+ var DEFAULT_HIT_CAP = 200;
1198
+ var ABSOLUTE_HIT_CAP = 5e3;
1199
+ var MAX_FILE_BYTES = 2 * 1024 * 1024;
1200
+ var BadRequest = class extends Error {
1201
+ };
1202
+ function asPositiveInt(value) {
1203
+ if (typeof value !== "number" || !Number.isFinite(value)) return null;
1204
+ const floored = Math.floor(value);
1205
+ return floored > 0 ? floored : null;
1206
+ }
1207
+ function sanitizeFlags(flags) {
1208
+ if (flags === void 0 || flags === null) return "";
1209
+ if (typeof flags !== "string") {
1210
+ throw new BadRequest(
1211
+ 'The `flags` argument, when present, must be a string of letters such as "i" or "m".'
1212
+ );
1213
+ }
1214
+ if (!/^[gimsuy]*$/.test(flags)) {
1215
+ throw new BadRequest(
1216
+ `Unrecognized regex flag in "${flags}"; only the letters g, i, m, s, u and y are accepted.`
1217
+ );
1218
+ }
1219
+ return flags;
1220
+ }
1221
+ function compile(pattern, flags) {
1222
+ try {
1223
+ return new RegExp(pattern, flags);
1224
+ } catch (err) {
1225
+ const why = err instanceof Error ? err.message : String(err);
1226
+ throw new BadRequest(`Could not compile the search pattern: ${why}`);
1227
+ }
1228
+ }
1229
+ function looksBinary(text) {
1230
+ const limit = Math.min(text.length, 4096);
1231
+ for (let i = 0; i < limit; i++) {
1232
+ if (text.charCodeAt(i) === 0) return true;
1233
+ }
1234
+ return false;
1235
+ }
1236
+ function relativize(root, full) {
1237
+ if (full === root) return full;
1238
+ const prefix = root.endsWith("/") ? root : root + "/";
1239
+ return full.startsWith(prefix) ? full.slice(prefix.length) : full;
1240
+ }
1241
+ function joinPath2(parent, child) {
1242
+ return parent.endsWith("/") ? parent + child : parent + "/" + child;
1243
+ }
1244
+ async function scanFile(ctx, root, full, matcher, cap, sink) {
1245
+ let body;
1246
+ try {
1247
+ body = await ctx.fs.readFile(full, "utf8");
1248
+ } catch {
1249
+ return false;
1250
+ }
1251
+ if (looksBinary(body)) return false;
1252
+ const lines = body.split("\n");
1253
+ const shown = relativize(root, full);
1254
+ for (let i = 0; i < lines.length; i++) {
1255
+ if (ctx.signal.aborted) return true;
1256
+ matcher.lastIndex = 0;
1257
+ if (matcher.test(lines[i])) {
1258
+ sink.push({ path: shown, line: i + 1, text: lines[i] });
1259
+ if (sink.length >= cap) return true;
1260
+ }
1261
+ }
1262
+ return false;
1263
+ }
1264
+ async function walk(ctx, root, dir, matcher, cap, sink) {
1265
+ if (ctx.signal.aborted) return true;
1266
+ let children;
1267
+ try {
1268
+ children = await ctx.fs.readdir(dir);
1269
+ } catch {
1270
+ return false;
1271
+ }
1272
+ children.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
1273
+ for (const child of children) {
1274
+ if (ctx.signal.aborted) return true;
1275
+ const full = joinPath2(dir, child.name);
1276
+ if (child.isDirectory) {
1277
+ if (PRUNED_DIRS.has(child.name)) continue;
1278
+ if (await walk(ctx, root, full, matcher, cap, sink)) return true;
1279
+ continue;
1280
+ }
1281
+ try {
1282
+ const info = await ctx.fs.stat(full);
1283
+ if (info.size > MAX_FILE_BYTES) continue;
1284
+ } catch {
1285
+ }
1286
+ if (await scanFile(ctx, root, full, matcher, cap, sink)) return true;
1287
+ }
1288
+ return false;
1289
+ }
1290
+ function renderReport(hits, pattern, cap) {
1291
+ if (hits.length === 0) {
1292
+ return `No lines matched /${pattern}/.`;
1293
+ }
1294
+ const lines = hits.map((h) => `${h.path}:${h.line}: ${h.text}`);
1295
+ const header = hits.length >= cap ? `Reached the ${cap}-hit limit; showing the first ${hits.length} matches:` : `Found ${hits.length} matching line${hits.length === 1 ? "" : "s"}:`;
1296
+ return `${header}
1297
+ ${lines.join("\n")}`;
1298
+ }
1299
+ var grepTool = defineTool({
1300
+ name: "grep",
1301
+ description: 'Search the contents of files for a regular expression. Walks the given path recursively (skipping node_modules and .git), tests each line of every readable text file, and returns matches as `path:line` plus the matching line. Provide `pattern` (a JS regex), and optionally `path` to root the search, `flags` (e.g. "i" for case-insensitive), and `maxMatches` to cap the number of hits. Use this to find where a symbol, string, or phrase appears across a codebase.',
1302
+ parameters: {
1303
+ type: "object",
1304
+ additionalProperties: false,
1305
+ required: ["pattern"],
1306
+ properties: {
1307
+ pattern: {
1308
+ type: "string",
1309
+ description: "The regular expression matched against each line of file content."
1310
+ },
1311
+ path: {
1312
+ type: "string",
1313
+ description: "File or directory to search beneath; defaults to the working directory."
1314
+ },
1315
+ flags: {
1316
+ type: "string",
1317
+ description: "JS regex flag letters (g, i, m, s, u, y); omit for none."
1318
+ },
1319
+ maxMatches: {
1320
+ type: "integer",
1321
+ minimum: 1,
1322
+ description: "Upper bound on reported matches. Defaults to a sensible cap."
1323
+ }
1324
+ }
1325
+ },
1326
+ async run(input, ctx) {
1327
+ try {
1328
+ if (input === null || typeof input !== "object") {
1329
+ throw new BadRequest(
1330
+ "Expected an object of arguments with at least a `pattern` field."
1331
+ );
1332
+ }
1333
+ const pattern = input.pattern;
1334
+ if (typeof pattern !== "string" || pattern.length === 0) {
1335
+ throw new BadRequest(
1336
+ "The `pattern` argument is required and must be a non-empty string."
1337
+ );
1338
+ }
1339
+ const flags = sanitizeFlags(input.flags);
1340
+ const matcher = compile(pattern, flags);
1341
+ const requested = asPositiveInt(input.maxMatches);
1342
+ const cap = Math.min(requested ?? DEFAULT_HIT_CAP, ABSOLUTE_HIT_CAP);
1343
+ let rawPath = ctx.cwd;
1344
+ if (input.path !== void 0 && input.path !== null) {
1345
+ if (typeof input.path !== "string") {
1346
+ throw new BadRequest("The `path` argument, when present, must be a string.");
1347
+ }
1348
+ if (input.path.length > 0) rawPath = input.path;
1349
+ }
1350
+ let rootInfo;
1351
+ try {
1352
+ rootInfo = await ctx.fs.stat(rawPath);
1353
+ } catch {
1354
+ return {
1355
+ content: [
1356
+ {
1357
+ kind: "text",
1358
+ text: `Nothing to search: the path "${rawPath}" does not exist or is unreadable.`
1359
+ }
1360
+ ],
1361
+ isError: true
1362
+ };
1363
+ }
1364
+ const hits = [];
1365
+ if (rootInfo.isDirectory) {
1366
+ await walk(ctx, rawPath, rawPath, matcher, cap, hits);
1367
+ } else if (rootInfo.isFile) {
1368
+ await scanFile(ctx, rawPath, rawPath, matcher, cap, hits);
1369
+ } else {
1370
+ return {
1371
+ content: [
1372
+ {
1373
+ kind: "text",
1374
+ text: `The path "${rawPath}" is neither a file nor a directory; nothing was searched.`
1375
+ }
1376
+ ],
1377
+ isError: true
1378
+ };
1379
+ }
1380
+ if (ctx.signal.aborted) {
1381
+ return {
1382
+ content: [{ kind: "text", text: "Search was cancelled before it finished." }],
1383
+ isError: true
1384
+ };
1385
+ }
1386
+ const report = renderReport(hits, pattern, cap);
1387
+ return { content: [{ kind: "text", text: clamp(report, ctx.budget) }] };
1388
+ } catch (err) {
1389
+ if (err instanceof BadRequest) {
1390
+ return { content: [{ kind: "text", text: err.message }], isError: true };
1391
+ }
1392
+ throw err;
1393
+ }
1394
+ }
1395
+ });
1396
+
1397
+ // src/capabilities/search/find.ts
1398
+ var PRUNED_DIRS2 = /* @__PURE__ */ new Set([".git", "node_modules"]);
1399
+ var DEFAULT_RESULT_CAP = 500;
1400
+ var ABSOLUTE_RESULT_CAP = 1e4;
1401
+ var BadRequest2 = class extends Error {
1402
+ };
1403
+ function escapeRegex(literal) {
1404
+ return literal.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1405
+ }
1406
+ function looksGlob(query) {
1407
+ return query.includes("*") || query.includes("?");
1408
+ }
1409
+ function compileGlob(query) {
1410
+ let body = "";
1411
+ for (const ch of query) {
1412
+ if (ch === "*") {
1413
+ body += ".*";
1414
+ } else if (ch === "?") {
1415
+ body += ".";
1416
+ } else {
1417
+ body += escapeRegex(ch);
1418
+ }
1419
+ }
1420
+ try {
1421
+ return new RegExp(`^${body}$`, "i");
1422
+ } catch (err) {
1423
+ const why = err instanceof Error ? err.message : String(err);
1424
+ throw new BadRequest2(`The glob "${query}" could not be turned into a matcher: ${why}`);
1425
+ }
1426
+ }
1427
+ function buildMatcher(query) {
1428
+ if (looksGlob(query)) {
1429
+ const re = compileGlob(query);
1430
+ return (name) => re.test(name);
1431
+ }
1432
+ const needle = query.toLowerCase();
1433
+ return (name) => name.toLowerCase().includes(needle);
1434
+ }
1435
+ function readKind(value) {
1436
+ if (value === void 0 || value === null) return void 0;
1437
+ if (value !== "file" && value !== "dir") {
1438
+ throw new BadRequest2('The `type` argument, when present, must be exactly "file" or "dir".');
1439
+ }
1440
+ return value;
1441
+ }
1442
+ function relativize2(root, full) {
1443
+ if (full === root) return ".";
1444
+ const prefix = root.endsWith("/") ? root : root + "/";
1445
+ return full.startsWith(prefix) ? full.slice(prefix.length) : full;
1446
+ }
1447
+ function joinPath3(parent, child) {
1448
+ return parent.endsWith("/") ? parent + child : parent + "/" + child;
1449
+ }
1450
+ async function walk2(ctx, root, dir, matcher, wanted, cap, sink) {
1451
+ if (ctx.signal.aborted) return true;
1452
+ let children;
1453
+ try {
1454
+ children = await ctx.fs.readdir(dir);
1455
+ } catch {
1456
+ return false;
1457
+ }
1458
+ children.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
1459
+ for (const child of children) {
1460
+ if (ctx.signal.aborted) return true;
1461
+ const full = joinPath3(dir, child.name);
1462
+ const kindMatches = wanted === void 0 || (wanted === "dir" ? child.isDirectory : !child.isDirectory);
1463
+ if (kindMatches && matcher(child.name)) {
1464
+ sink.push(relativize2(root, full));
1465
+ if (sink.length >= cap) return true;
1466
+ }
1467
+ if (child.isDirectory) {
1468
+ if (PRUNED_DIRS2.has(child.name)) continue;
1469
+ if (await walk2(ctx, root, full, matcher, wanted, cap, sink)) return true;
1470
+ }
1471
+ }
1472
+ return false;
1473
+ }
1474
+ function renderReport2(hits, query, cap) {
1475
+ if (hits.length === 0) {
1476
+ return `Nothing matched "${query}".`;
1477
+ }
1478
+ const header = hits.length >= cap ? `Hit the ${cap}-entry limit; listing the first ${hits.length} matches:` : `Matched ${hits.length} entr${hits.length === 1 ? "y" : "ies"}:`;
1479
+ return `${header}
1480
+ ${hits.join("\n")}`;
1481
+ }
1482
+ var findTool = defineTool({
1483
+ name: "find",
1484
+ description: 'Locate files and folders by name beneath a path. Walks the given directory recursively (skipping node_modules and .git) and reports every entry whose name matches `query`. The query is treated as a glob when it contains `*` or `?` (anchored to the whole name, case-insensitive), and otherwise as a case-insensitive substring. Optionally pass `path` to root the search and `type` ("file" or "dir") to keep only one kind of entry. Returns matching paths relative to the search root. Use this to find where a file lives when you know part of its name rather than its contents.',
1485
+ parameters: {
1486
+ type: "object",
1487
+ additionalProperties: false,
1488
+ required: ["query"],
1489
+ properties: {
1490
+ query: {
1491
+ type: "string",
1492
+ description: "Glob (with `*`/`?`, matched against the whole name) or plain substring to match entry names against."
1493
+ },
1494
+ path: {
1495
+ type: "string",
1496
+ description: "Directory to search beneath; defaults to the working directory."
1497
+ },
1498
+ type: {
1499
+ type: "string",
1500
+ enum: ["file", "dir"],
1501
+ description: 'Restrict results to regular files ("file") or directories ("dir"); omit for both.'
1502
+ }
1503
+ }
1504
+ },
1505
+ async run(input, ctx) {
1506
+ try {
1507
+ if (input === null || typeof input !== "object") {
1508
+ throw new BadRequest2("Expected an object of arguments with at least a `query` field.");
1509
+ }
1510
+ const query = input.query;
1511
+ if (typeof query !== "string" || query.length === 0) {
1512
+ throw new BadRequest2("The `query` argument is required and must be a non-empty string.");
1513
+ }
1514
+ const wanted = readKind(input.type);
1515
+ const matcher = buildMatcher(query);
1516
+ let rawPath = ctx.cwd;
1517
+ if (input.path !== void 0 && input.path !== null) {
1518
+ if (typeof input.path !== "string") {
1519
+ throw new BadRequest2("The `path` argument, when present, must be a string.");
1520
+ }
1521
+ if (input.path.length > 0) rawPath = input.path;
1522
+ }
1523
+ let rootInfo;
1524
+ try {
1525
+ rootInfo = await ctx.fs.stat(rawPath);
1526
+ } catch {
1527
+ return {
1528
+ content: [
1529
+ {
1530
+ kind: "text",
1531
+ text: `Cannot search: the path "${rawPath}" does not exist or is unreadable.`
1532
+ }
1533
+ ],
1534
+ isError: true
1535
+ };
1536
+ }
1537
+ if (!rootInfo.isDirectory) {
1538
+ return {
1539
+ content: [
1540
+ {
1541
+ kind: "text",
1542
+ text: `The path "${rawPath}" is not a directory, so there is nothing to walk.`
1543
+ }
1544
+ ],
1545
+ isError: true
1546
+ };
1547
+ }
1548
+ const cap = Math.min(DEFAULT_RESULT_CAP, ABSOLUTE_RESULT_CAP);
1549
+ const hits = [];
1550
+ await walk2(ctx, rawPath, rawPath, matcher, wanted, cap, hits);
1551
+ if (ctx.signal.aborted) {
1552
+ return {
1553
+ content: [{ kind: "text", text: "The search was cancelled before it finished." }],
1554
+ isError: true
1555
+ };
1556
+ }
1557
+ const report = renderReport2(hits, query, cap);
1558
+ return { content: [{ kind: "text", text: clamp(report, ctx.budget) }] };
1559
+ } catch (err) {
1560
+ if (err instanceof BadRequest2) {
1561
+ return { content: [{ kind: "text", text: err.message }], isError: true };
1562
+ }
1563
+ throw err;
1564
+ }
1565
+ }
1566
+ });
1567
+
1568
+ // src/capabilities/shell/bash.ts
1569
+ var DEADLINE_CEILING_MS = 10 * 60 * 1e3;
1570
+ var DEFAULT_DEADLINE_MS = 2 * 60 * 1e3;
1571
+ var PARAMETERS = {
1572
+ type: "object",
1573
+ additionalProperties: false,
1574
+ required: ["command"],
1575
+ properties: {
1576
+ command: {
1577
+ type: "string",
1578
+ description: "The shell command line to run, exactly as you would type it at a prompt."
1579
+ },
1580
+ timeoutMs: {
1581
+ type: "number",
1582
+ description: "Optional time limit in milliseconds. The command is terminated once it elapses; omit it to use the default window."
1583
+ },
1584
+ cwd: {
1585
+ type: "string",
1586
+ description: "Optional directory to run the command in. Defaults to the session's current working directory when left out."
1587
+ }
1588
+ }
1589
+ };
1590
+ var DESCRIPTION3 = [
1591
+ "Run one shell command and get back its combined output and exit status.",
1592
+ "The command runs to completion (subject to an optional time limit), and you receive its standard output, standard error, and the numeric exit code.",
1593
+ "Use this for build steps, test runs, version-control queries, and other one-off shell work; it is not a persistent session, so each call starts fresh."
1594
+ ].join(" ");
1595
+ function readInput(raw) {
1596
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
1597
+ throw new Error("Expected an arguments object carrying at least a `command` string.");
1598
+ }
1599
+ const bag = raw;
1600
+ const command = bag.command;
1601
+ if (typeof command !== "string") {
1602
+ throw new Error("The `command` argument is required and must be a string.");
1603
+ }
1604
+ if (command.trim().length === 0) {
1605
+ throw new Error("The `command` argument cannot be empty or whitespace only.");
1606
+ }
1607
+ let timeoutMs;
1608
+ if (bag.timeoutMs !== void 0) {
1609
+ const raw2 = bag.timeoutMs;
1610
+ if (typeof raw2 !== "number" || !Number.isFinite(raw2) || raw2 <= 0) {
1611
+ throw new Error("When given, `timeoutMs` must be a positive, finite number of milliseconds.");
1612
+ }
1613
+ timeoutMs = Math.min(Math.floor(raw2), DEADLINE_CEILING_MS);
1614
+ }
1615
+ let cwd;
1616
+ if (bag.cwd !== void 0) {
1617
+ if (typeof bag.cwd !== "string" || bag.cwd.trim().length === 0) {
1618
+ throw new Error("When given, `cwd` must be a non-empty directory path.");
1619
+ }
1620
+ cwd = bag.cwd;
1621
+ }
1622
+ return { command, timeoutMs, cwd };
1623
+ }
1624
+ function renderReport3(stdout, stderr, code) {
1625
+ const sections = [];
1626
+ if (stdout.length > 0) {
1627
+ sections.push(`stdout:
1628
+ ${stdout}`);
1629
+ }
1630
+ if (stderr.length > 0) {
1631
+ sections.push(`stderr:
1632
+ ${stderr}`);
1633
+ }
1634
+ if (sections.length === 0) {
1635
+ sections.push("(the command produced no output)");
1636
+ }
1637
+ const status = code === null ? "status: the command was halted by a signal before it could return an exit code" : `status: exited with code ${code}`;
1638
+ sections.push(status);
1639
+ return sections.join("\n\n");
1640
+ }
1641
+ async function run(input, ctx) {
1642
+ const deadline = input.timeoutMs ?? DEFAULT_DEADLINE_MS;
1643
+ const result = await ctx.shell.exec(input.command, {
1644
+ cwd: input.cwd ?? ctx.cwd,
1645
+ signal: ctx.signal,
1646
+ timeoutMs: deadline
1647
+ });
1648
+ const report = renderReport3(result.stdout, result.stderr, result.code);
1649
+ const windowed = clamp(report, ctx.budget);
1650
+ const failed = result.code === null || result.code !== 0;
1651
+ return {
1652
+ content: [{ kind: "text", text: windowed }],
1653
+ isError: failed
1654
+ };
1655
+ }
1656
+ var bashTool = defineTool({
1657
+ name: "bash",
1658
+ description: DESCRIPTION3,
1659
+ parameters: PARAMETERS,
1660
+ async run(input, ctx) {
1661
+ const parsed = readInput(input);
1662
+ return run(parsed, ctx);
1663
+ }
1664
+ });
1665
+
1666
+ // src/capabilities/shell/process.ts
1667
+ var ProcessTable = class {
1668
+ jobs = /* @__PURE__ */ new Map();
1669
+ counter = 0;
1670
+ /** Mint a fresh, collision-free job id. */
1671
+ nextId() {
1672
+ this.counter += 1;
1673
+ return `job-${this.counter}`;
1674
+ }
1675
+ add(entry) {
1676
+ this.jobs.set(entry.id, entry);
1677
+ }
1678
+ get(id) {
1679
+ return this.jobs.get(id);
1680
+ }
1681
+ remove(id) {
1682
+ const entry = this.jobs.get(id);
1683
+ if (entry !== void 0) {
1684
+ this.jobs.delete(id);
1685
+ }
1686
+ return entry;
1687
+ }
1688
+ all() {
1689
+ return [...this.jobs.values()];
1690
+ }
1691
+ /**
1692
+ * Empty the table. Any job still running is killed and its exit listener
1693
+ * dropped, so a test (or a host shutting down) leaves nothing dangling.
1694
+ */
1695
+ reset() {
1696
+ for (const entry of this.jobs.values()) {
1697
+ entry.unsubscribe();
1698
+ if (entry.state === "running") {
1699
+ try {
1700
+ entry.handle.kill();
1701
+ } catch {
1702
+ }
1703
+ }
1704
+ }
1705
+ this.jobs.clear();
1706
+ this.counter = 0;
1707
+ }
1708
+ };
1709
+ var table = new ProcessTable();
1710
+ var POLL_WINDOW_BYTES = 32 * 1024;
1711
+ var SCRATCH_DIR = ".indus-process";
1712
+ function joinPath4(base, tail) {
1713
+ if (base.length === 0) return tail;
1714
+ const last = base[base.length - 1];
1715
+ if (last === "/" || last === "\\") return `${base}${tail}`;
1716
+ return `${base}/${tail}`;
1717
+ }
1718
+ var processParameters = {
1719
+ type: "object",
1720
+ additionalProperties: false,
1721
+ required: ["action"],
1722
+ properties: {
1723
+ action: {
1724
+ type: "string",
1725
+ enum: ["start", "list", "poll", "stop"],
1726
+ description: "Which operation to run: 'start' a new background command, 'list' all tracked jobs, 'poll' a job for output it has printed since you last looked, or 'stop' a job and discard it."
1727
+ },
1728
+ command: {
1729
+ type: "string",
1730
+ description: "The shell command line to launch in the background. Required for 'start' and ignored by the other actions."
1731
+ },
1732
+ id: {
1733
+ type: "string",
1734
+ description: "The identifier of the job to act on, as returned by 'start'. Required for 'poll' and 'stop'."
1735
+ }
1736
+ }
1737
+ };
1738
+ var DESCRIPTION4 = [
1739
+ "Manage commands that keep running in the background across turns.",
1740
+ "Unlike a one-shot shell call, a started job stays alive so you can launch a server, watcher, or long task and check on it later.",
1741
+ "Use action='start' with a command to launch one and get a job id back; 'list' to see every job and its status; 'poll' with the id to read whatever output has accumulated since your last poll; and 'stop' with the id to terminate it."
1742
+ ].join(" ");
1743
+ function asText2(text, failed = false) {
1744
+ return { content: [{ kind: "text", text }], isError: failed };
1745
+ }
1746
+ function asJson(value) {
1747
+ return { content: [{ kind: "json", value }] };
1748
+ }
1749
+ function readInput2(raw) {
1750
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
1751
+ throw new Error(
1752
+ "Expected an arguments object with an 'action' of start, list, poll, or stop."
1753
+ );
1754
+ }
1755
+ const bag = raw;
1756
+ const action = bag.action;
1757
+ if (action !== "start" && action !== "list" && action !== "poll" && action !== "stop") {
1758
+ throw new Error(
1759
+ "The 'action' argument must be one of: start, list, poll, stop."
1760
+ );
1761
+ }
1762
+ let command;
1763
+ if (bag.command !== void 0) {
1764
+ if (typeof bag.command !== "string") {
1765
+ throw new Error("When given, 'command' must be a string command line.");
1766
+ }
1767
+ command = bag.command;
1768
+ }
1769
+ let id;
1770
+ if (bag.id !== void 0) {
1771
+ if (typeof bag.id !== "string") {
1772
+ throw new Error("When given, 'id' must be a string job identifier.");
1773
+ }
1774
+ id = bag.id;
1775
+ }
1776
+ return { action, command, id };
1777
+ }
1778
+ function shellQuote(value) {
1779
+ return `'${value.replace(/'/g, `'\\''`)}'`;
1780
+ }
1781
+ async function drainCapture(ctx, path, alreadyRead) {
1782
+ let full;
1783
+ try {
1784
+ full = await ctx.fs.readFile(path, "utf8");
1785
+ } catch {
1786
+ return { fresh: "", total: alreadyRead };
1787
+ }
1788
+ const total = Buffer.byteLength(full, "utf8");
1789
+ if (total <= alreadyRead) {
1790
+ return { fresh: "", total };
1791
+ }
1792
+ const fresh = Buffer.from(full, "utf8").subarray(alreadyRead).toString("utf8");
1793
+ return { fresh, total };
1794
+ }
1795
+ function describeStatus(entry) {
1796
+ if (entry.state === "running") {
1797
+ const pid = entry.pid === void 0 ? "unknown pid" : `pid ${entry.pid}`;
1798
+ return `running (${pid})`;
1799
+ }
1800
+ if (entry.exitSignal !== null) {
1801
+ return `stopped by signal ${entry.exitSignal}`;
1802
+ }
1803
+ if (entry.exitCode === null) {
1804
+ return "finished (no exit code reported)";
1805
+ }
1806
+ return `exited with code ${entry.exitCode}`;
1807
+ }
1808
+ async function startJob(ctx, command) {
1809
+ const id = table.nextId();
1810
+ const scratchDir = joinPath4(ctx.cwd, SCRATCH_DIR);
1811
+ const outPath = joinPath4(scratchDir, `${id}.out`);
1812
+ const errPath = joinPath4(scratchDir, `${id}.err`);
1813
+ await ctx.fs.mkdir(scratchDir, { recursive: true });
1814
+ await ctx.fs.writeFile(outPath, "", "utf8");
1815
+ await ctx.fs.writeFile(errPath, "", "utf8");
1816
+ const wrapped = `( ${command} ) >${shellQuote(outPath)} 2>${shellQuote(errPath)}`;
1817
+ const handle = ctx.shell.spawn(wrapped, { cwd: ctx.cwd });
1818
+ const entry = {
1819
+ id,
1820
+ command,
1821
+ handle,
1822
+ pid: handle.pid,
1823
+ outPath,
1824
+ errPath,
1825
+ startedMs: Date.now(),
1826
+ state: "running",
1827
+ exitCode: null,
1828
+ exitSignal: null,
1829
+ readOut: 0,
1830
+ readErr: 0,
1831
+ unsubscribe: () => {
1832
+ }
1833
+ };
1834
+ const unsubscribe = handle.onExit((code, signal) => {
1835
+ entry.state = "finished";
1836
+ entry.exitCode = code;
1837
+ entry.exitSignal = signal;
1838
+ });
1839
+ entry.unsubscribe = unsubscribe;
1840
+ table.add(entry);
1841
+ return asJson({
1842
+ action: "start",
1843
+ id,
1844
+ pid: entry.pid ?? null,
1845
+ command,
1846
+ status: describeStatus(entry),
1847
+ note: `Started job ${id}. Use action='poll' with this id to read its output.`
1848
+ });
1849
+ }
1850
+ function listJobs() {
1851
+ const entries = table.all();
1852
+ if (entries.length === 0) {
1853
+ return asJson({
1854
+ action: "list",
1855
+ jobs: [],
1856
+ note: "No background jobs are currently tracked."
1857
+ });
1858
+ }
1859
+ const jobs = entries.map((entry) => ({
1860
+ id: entry.id,
1861
+ command: entry.command,
1862
+ pid: entry.pid ?? null,
1863
+ state: entry.state,
1864
+ status: describeStatus(entry),
1865
+ ageMs: Date.now() - entry.startedMs
1866
+ }));
1867
+ return asJson({ action: "list", jobs });
1868
+ }
1869
+ async function pollJob(ctx, id) {
1870
+ const entry = table.get(id);
1871
+ if (entry === void 0) {
1872
+ return asText2(
1873
+ `No background job is tracked under id '${id}'. Use action='list' to see active jobs.`,
1874
+ true
1875
+ );
1876
+ }
1877
+ const out = await drainCapture(ctx, entry.outPath, entry.readOut);
1878
+ const err = await drainCapture(ctx, entry.errPath, entry.readErr);
1879
+ entry.readOut = out.total;
1880
+ entry.readErr = err.total;
1881
+ const window = { kind: "tail", maxBytes: POLL_WINDOW_BYTES };
1882
+ const stdout = clamp(out.fresh, window);
1883
+ const stderr = clamp(err.fresh, window);
1884
+ return asJson({
1885
+ action: "poll",
1886
+ id: entry.id,
1887
+ state: entry.state,
1888
+ status: describeStatus(entry),
1889
+ exitCode: entry.exitCode,
1890
+ exitSignal: entry.exitSignal,
1891
+ stdout,
1892
+ stderr,
1893
+ hadNewOutput: out.fresh.length > 0 || err.fresh.length > 0
1894
+ });
1895
+ }
1896
+ function stopJob(id) {
1897
+ const entry = table.remove(id);
1898
+ if (entry === void 0) {
1899
+ return asText2(
1900
+ `No background job is tracked under id '${id}'. It may have already been stopped.`,
1901
+ true
1902
+ );
1903
+ }
1904
+ entry.unsubscribe();
1905
+ const wasRunning = entry.state === "running";
1906
+ if (wasRunning) {
1907
+ try {
1908
+ entry.handle.kill();
1909
+ } catch {
1910
+ }
1911
+ }
1912
+ return asJson({
1913
+ action: "stop",
1914
+ id: entry.id,
1915
+ wasRunning,
1916
+ finalStatus: wasRunning ? "signalled to terminate and removed" : describeStatus(entry)
1917
+ });
1918
+ }
1919
+ var processTool = defineTool({
1920
+ name: "process",
1921
+ description: DESCRIPTION4,
1922
+ parameters: processParameters,
1923
+ async run(input, ctx) {
1924
+ const parsed = readInput2(input);
1925
+ switch (parsed.action) {
1926
+ case "start": {
1927
+ const command = parsed.command;
1928
+ if (typeof command !== "string" || command.trim().length === 0) {
1929
+ return asText2(
1930
+ "Starting a job needs a non-empty 'command' to run.",
1931
+ true
1932
+ );
1933
+ }
1934
+ return startJob(ctx, command);
1935
+ }
1936
+ case "list":
1937
+ return listJobs();
1938
+ case "poll": {
1939
+ const id = parsed.id;
1940
+ if (typeof id !== "string" || id.trim().length === 0) {
1941
+ return asText2("Polling a job needs the 'id' it was given at start.", true);
1942
+ }
1943
+ return pollJob(ctx, id);
1944
+ }
1945
+ case "stop": {
1946
+ const id = parsed.id;
1947
+ if (typeof id !== "string" || id.trim().length === 0) {
1948
+ return asText2("Stopping a job needs the 'id' it was given at start.", true);
1949
+ }
1950
+ return stopJob(id);
1951
+ }
1952
+ default:
1953
+ return asText2("Unsupported action.", true);
1954
+ }
1955
+ }
1956
+ });
1957
+
1958
+ // src/capabilities/planning/todo.ts
1959
+ var VALID_STATUSES = /* @__PURE__ */ new Set([
1960
+ "pending",
1961
+ "active",
1962
+ "done"
1963
+ ]);
1964
+ var TodoStore = class {
1965
+ lists = /* @__PURE__ */ new Map();
1966
+ /** Return the list recorded for `ctx`, or an empty array if none was set yet. */
1967
+ read(ctx) {
1968
+ return this.lists.get(ctx) ?? [];
1969
+ }
1970
+ /** Replace the entire list recorded for `ctx` with `items`. */
1971
+ replace(ctx, items) {
1972
+ this.lists.set(ctx, items);
1973
+ }
1974
+ /** Discard every stored list. Intended for test isolation only. */
1975
+ reset() {
1976
+ this.lists.clear();
1977
+ }
1978
+ };
1979
+ var todoStore = new TodoStore();
1980
+ function failure4(message) {
1981
+ return { content: [{ kind: "text", text: message }], isError: true };
1982
+ }
1983
+ function asBag(input) {
1984
+ if (input !== null && typeof input === "object" && !Array.isArray(input)) {
1985
+ return input;
1986
+ }
1987
+ return {};
1988
+ }
1989
+ function parseItem(raw, position) {
1990
+ const where = `item ${position + 1}`;
1991
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
1992
+ return { ok: false, reason: `${where} must be an object describing a task.` };
1993
+ }
1994
+ const bag = raw;
1995
+ const id = bag.id;
1996
+ if (typeof id !== "string" || id.trim().length === 0) {
1997
+ return { ok: false, reason: `${where} needs a non-empty string \`id\`.` };
1998
+ }
1999
+ const text = bag.text;
2000
+ if (typeof text !== "string" || text.trim().length === 0) {
2001
+ return { ok: false, reason: `${where} needs a non-empty string \`text\`.` };
2002
+ }
2003
+ const status = bag.status;
2004
+ if (typeof status !== "string" || !VALID_STATUSES.has(status)) {
2005
+ return {
2006
+ ok: false,
2007
+ reason: `${where} has an unrecognised \`status\`; use one of pending, active, or done.`
2008
+ };
2009
+ }
2010
+ return { ok: true, item: { id, text, status } };
2011
+ }
2012
+ function parseItems(raw) {
2013
+ if (!Array.isArray(raw)) {
2014
+ return { ok: false, reason: "`items` must be an array of task objects (send [] to clear the list)." };
2015
+ }
2016
+ const items = [];
2017
+ const seen = /* @__PURE__ */ new Set();
2018
+ for (let i = 0; i < raw.length; i += 1) {
2019
+ const parsed = parseItem(raw[i], i);
2020
+ if (!parsed.ok) return parsed;
2021
+ if (seen.has(parsed.item.id)) {
2022
+ return { ok: false, reason: `Duplicate id "${parsed.item.id}"; each task id must be unique.` };
2023
+ }
2024
+ seen.add(parsed.item.id);
2025
+ items.push(parsed.item);
2026
+ }
2027
+ return { ok: true, items };
2028
+ }
2029
+ function renderList(items) {
2030
+ if (items.length === 0) {
2031
+ return "The task list is currently empty.";
2032
+ }
2033
+ const glyph = {
2034
+ pending: "[ ]",
2035
+ active: "[~]",
2036
+ done: "[x]"
2037
+ };
2038
+ const lines = items.map(
2039
+ (item) => `${glyph[item.status]} (${item.id}) ${item.text}`
2040
+ );
2041
+ const counts = summarise(items);
2042
+ return `${counts}
2043
+ ${lines.join("\n")}`;
2044
+ }
2045
+ function summarise(items) {
2046
+ let pending = 0;
2047
+ let active = 0;
2048
+ let done = 0;
2049
+ for (const item of items) {
2050
+ if (item.status === "pending") pending += 1;
2051
+ else if (item.status === "active") active += 1;
2052
+ else done += 1;
2053
+ }
2054
+ return `${items.length} task${items.length === 1 ? "" : "s"}: ${active} active, ${pending} pending, ${done} done.`;
2055
+ }
2056
+ var setParameters = {
2057
+ type: "object",
2058
+ additionalProperties: false,
2059
+ required: ["items"],
2060
+ properties: {
2061
+ items: {
2062
+ type: "array",
2063
+ description: "The complete task list to store, replacing whatever was tracked before. Send an empty array to clear the list entirely.",
2064
+ items: {
2065
+ type: "object",
2066
+ additionalProperties: false,
2067
+ required: ["id", "text", "status"],
2068
+ properties: {
2069
+ id: {
2070
+ type: "string",
2071
+ description: "Stable identifier for the task; must be unique within the list."
2072
+ },
2073
+ text: {
2074
+ type: "string",
2075
+ description: "Short description of what the task involves."
2076
+ },
2077
+ status: {
2078
+ type: "string",
2079
+ enum: ["pending", "active", "done"],
2080
+ description: "Lifecycle stage: pending (not started), active (in progress), or done (finished)."
2081
+ }
2082
+ }
2083
+ }
2084
+ }
2085
+ }
2086
+ };
2087
+ var SET_DESCRIPTION = [
2088
+ "Record the full task checklist for the current session, overwriting any list",
2089
+ "stored earlier. Pass the entire desired list every time \u2014 this is a replace,",
2090
+ "not a merge \u2014 so keep finished tasks in the array (with status done) until you",
2091
+ "no longer want them shown. Use this to plan multi-step work and to mark progress",
2092
+ "as each step starts and completes."
2093
+ ].join(" ");
2094
+ var todoSetTool = defineTool({
2095
+ name: "todo_set",
2096
+ description: SET_DESCRIPTION,
2097
+ parameters: setParameters,
2098
+ async run(input, ctx) {
2099
+ const bag = asBag(input);
2100
+ if (!("items" in bag)) {
2101
+ return failure4("An `items` array is required; send [] to empty the list.");
2102
+ }
2103
+ const parsed = parseItems(bag.items);
2104
+ if (!parsed.ok) return failure4(parsed.reason);
2105
+ todoStore.replace(ctx, parsed.items);
2106
+ const body = `Task list updated. ${renderList(parsed.items)}`;
2107
+ return { content: [{ kind: "text", text: body }] };
2108
+ }
2109
+ });
2110
+ var READ_DESCRIPTION = [
2111
+ "Show the task checklist currently stored for this session, including each",
2112
+ "task's id, description, and status. Use it to remind yourself of the plan and",
2113
+ "of what is still outstanding before deciding what to do next. This is read-only",
2114
+ "and changes nothing."
2115
+ ].join(" ");
2116
+ var todoReadTool = defineTool({
2117
+ name: "todo_read",
2118
+ description: READ_DESCRIPTION,
2119
+ parameters: {
2120
+ type: "object",
2121
+ additionalProperties: false,
2122
+ properties: {}
2123
+ },
2124
+ async run(_input, ctx) {
2125
+ const items = todoStore.read(ctx);
2126
+ return { content: [{ kind: "text", text: renderList(items) }] };
2127
+ }
2128
+ });
2129
+
2130
+ // src/capabilities/web/websearch.ts
2131
+ var DEFAULT_RESULTS = 5;
2132
+ var MAX_RESULTS = 25;
2133
+ var REQUEST_TIMEOUT_MS = 1e4;
2134
+ var SEARCH_ENDPOINT = "https://html.duckduckgo.com/html/";
2135
+ var USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0 Safari/537.36";
2136
+ var DESCRIPTION5 = [
2137
+ "Search the public web for a query and return the leading results as a list of",
2138
+ "{ title, url, snippet } entries. Useful for finding current information,",
2139
+ "documentation, or sources that are not already in the workspace. Use",
2140
+ "`maxResults` to ask for more or fewer hits; the count is capped to keep the",
2141
+ "response compact. If the network is unreachable the tool reports a failure",
2142
+ "instead of throwing."
2143
+ ].join(" ");
2144
+ function failure5(message) {
2145
+ return { content: [{ kind: "text", text: message }], isError: true };
2146
+ }
2147
+ function resolveMaxResults(value) {
2148
+ if (value === void 0 || value === null) {
2149
+ return { ok: true, value: DEFAULT_RESULTS };
2150
+ }
2151
+ if (typeof value !== "number" || !Number.isFinite(value)) {
2152
+ return { ok: false, reason: "`maxResults` must be a number when provided." };
2153
+ }
2154
+ if (!Number.isInteger(value)) {
2155
+ return { ok: false, reason: `\`maxResults\` must be a whole number, not ${value}.` };
2156
+ }
2157
+ if (value < 1) {
2158
+ return { ok: false, reason: `\`maxResults\` must be at least 1; got ${value}.` };
2159
+ }
2160
+ return { ok: true, value: Math.min(value, MAX_RESULTS) };
2161
+ }
2162
+ function toPlainText(html) {
2163
+ const withoutTags = html.replace(/<[^>]*>/g, "");
2164
+ const decoded = withoutTags.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&#x27;/g, "'").replace(/&nbsp;/g, " ");
2165
+ return decoded.replace(/\s+/g, " ").trim();
2166
+ }
2167
+ function unwrapTarget(href) {
2168
+ let candidate = href;
2169
+ const redirectMatch = /[?&]uddg=([^&]+)/.exec(candidate);
2170
+ if (redirectMatch) {
2171
+ try {
2172
+ candidate = decodeURIComponent(redirectMatch[1]);
2173
+ } catch {
2174
+ }
2175
+ }
2176
+ if (candidate.startsWith("//")) {
2177
+ candidate = `https:${candidate}`;
2178
+ }
2179
+ return candidate;
2180
+ }
2181
+ function extractHits(body, limit) {
2182
+ const hits = [];
2183
+ const seen = /* @__PURE__ */ new Set();
2184
+ const titleAnchor = /<a\b[^>]*\bclass="[^"]*\bresult__a\b[^"]*"[^>]*\bhref="([^"]*)"[^>]*>([\s\S]*?)<\/a>/gi;
2185
+ const snippetBlock = /\bclass="[^"]*\bresult__snippet\b[^"]*"[^>]*>([\s\S]*?)<\/[a-z]+>/i;
2186
+ let match;
2187
+ while ((match = titleAnchor.exec(body)) !== null) {
2188
+ if (hits.length >= limit) break;
2189
+ const url = unwrapTarget(match[1]);
2190
+ const title = toPlainText(match[2]);
2191
+ if (url.length === 0 || title.length === 0) continue;
2192
+ if (seen.has(url)) continue;
2193
+ const tail = body.slice(titleAnchor.lastIndex);
2194
+ const snippetMatch = snippetBlock.exec(tail);
2195
+ const snippet = snippetMatch ? toPlainText(snippetMatch[1]) : "";
2196
+ seen.add(url);
2197
+ hits.push({ title, url, snippet });
2198
+ }
2199
+ return hits;
2200
+ }
2201
+ function renderHits(query, hits) {
2202
+ const lines = [
2203
+ `${hits.length} result${hits.length === 1 ? "" : "s"} for "${query}":`,
2204
+ ""
2205
+ ];
2206
+ hits.forEach((hit, index) => {
2207
+ lines.push(`${index + 1}. ${hit.title}`);
2208
+ lines.push(` ${hit.url}`);
2209
+ if (hit.snippet.length > 0) {
2210
+ lines.push(` ${hit.snippet}`);
2211
+ }
2212
+ lines.push("");
2213
+ });
2214
+ return lines.join("\n").trimEnd();
2215
+ }
2216
+ var webSearchTool = defineTool({
2217
+ name: "websearch",
2218
+ description: DESCRIPTION5,
2219
+ parameters: {
2220
+ type: "object",
2221
+ properties: {
2222
+ query: {
2223
+ type: "string",
2224
+ description: "The words to search the web for."
2225
+ },
2226
+ maxResults: {
2227
+ type: "integer",
2228
+ minimum: 1,
2229
+ maximum: MAX_RESULTS,
2230
+ description: `How many hits to return at most. Defaults to ${DEFAULT_RESULTS}; values above ${MAX_RESULTS} are pulled down to that ceiling.`
2231
+ }
2232
+ },
2233
+ required: ["query"],
2234
+ additionalProperties: false
2235
+ },
2236
+ async run(input, ctx) {
2237
+ const raw = input;
2238
+ const bag = raw !== null && typeof raw === "object" ? raw : {};
2239
+ const rawQuery = bag.query;
2240
+ if (typeof rawQuery !== "string" || rawQuery.trim().length === 0) {
2241
+ return failure5("A non-empty `query` string is required to run a web search.");
2242
+ }
2243
+ const query = rawQuery.trim();
2244
+ const limitParse = resolveMaxResults(bag.maxResults);
2245
+ if (!limitParse.ok) return failure5(limitParse.reason);
2246
+ const limit = limitParse.value;
2247
+ const timeout = new AbortController();
2248
+ const onOuterAbort = () => timeout.abort();
2249
+ if (ctx.signal.aborted) {
2250
+ return failure5("The search was cancelled before the request went out.");
2251
+ }
2252
+ ctx.signal.addEventListener("abort", onOuterAbort, { once: true });
2253
+ const timer = setTimeout(() => timeout.abort(), REQUEST_TIMEOUT_MS);
2254
+ let body;
2255
+ try {
2256
+ const form = new URLSearchParams({ q: query });
2257
+ const response = await fetch(SEARCH_ENDPOINT, {
2258
+ method: "POST",
2259
+ signal: timeout.signal,
2260
+ headers: {
2261
+ "Content-Type": "application/x-www-form-urlencoded",
2262
+ "User-Agent": USER_AGENT,
2263
+ Accept: "text/html"
2264
+ },
2265
+ body: form.toString()
2266
+ });
2267
+ if (!response.ok) {
2268
+ return failure5(
2269
+ `The search service answered with status ${response.status} (${response.statusText || "no reason given"}).`
2270
+ );
2271
+ }
2272
+ body = await response.text();
2273
+ } catch (err) {
2274
+ if (ctx.signal.aborted) {
2275
+ return failure5("The search was cancelled before it finished.");
2276
+ }
2277
+ if (timeout.signal.aborted) {
2278
+ return failure5(
2279
+ `The search timed out after ${REQUEST_TIMEOUT_MS / 1e3}s with no response.`
2280
+ );
2281
+ }
2282
+ const detail = err instanceof Error ? err.message : String(err);
2283
+ return failure5(`The web search could not reach the network: ${detail}`);
2284
+ } finally {
2285
+ clearTimeout(timer);
2286
+ ctx.signal.removeEventListener("abort", onOuterAbort);
2287
+ }
2288
+ const hits = extractHits(body, limit);
2289
+ if (hits.length === 0) {
2290
+ return failure5(
2291
+ `The search for "${query}" came back with no results that could be read.`
2292
+ );
2293
+ }
2294
+ const rendered = renderHits(query, hits);
2295
+ const clamped = clamp(rendered, {
2296
+ kind: ctx.budget.kind,
2297
+ maxBytes: ctx.budget.maxBytes,
2298
+ notice: (omitted) => `
2299
+ [websearch: ${omitted} byte${omitted === 1 ? "" : "s"} of results were left out to stay within the response budget]
2300
+ `
2301
+ });
2302
+ return {
2303
+ content: [
2304
+ { kind: "text", text: clamped },
2305
+ { kind: "json", value: hits }
2306
+ ]
2307
+ };
2308
+ }
2309
+ });
2310
+
2311
+ // src/capabilities/web/webfetch.ts
2312
+ var ABSOLUTE_BODY_CEILING = 5 * 1024 * 1024;
2313
+ var DEFAULT_BODY_CEILING = 1024 * 1024;
2314
+ var REQUEST_TIMEOUT_MS2 = 3e4;
2315
+ var DESCRIPTION6 = [
2316
+ "Download a single web page over HTTP or HTTPS and return its text in a",
2317
+ "stripped-down, reading-friendly form. The page's HTML is reduced to plain",
2318
+ "text: headings, paragraphs, list items and links are kept in a simple layout,",
2319
+ "while scripts, styles, markup tags and boilerplate are removed. Supply an",
2320
+ "absolute `url`; optionally cap the amount of page data considered with",
2321
+ "`maxBytes`. The reply is always trimmed to fit the model's context, so very",
2322
+ "large pages come back partial with a marker showing where text was cut."
2323
+ ].join(" ");
2324
+ function failure6(message) {
2325
+ return { content: [{ kind: "text", text: message }], isError: true };
2326
+ }
2327
+ function readByteCap(value) {
2328
+ if (value === void 0 || value === null) {
2329
+ return { ok: true, value: void 0 };
2330
+ }
2331
+ if (typeof value !== "number" || !Number.isFinite(value)) {
2332
+ return { ok: false, reason: "`maxBytes` must be a number when you include it." };
2333
+ }
2334
+ if (!Number.isInteger(value)) {
2335
+ return { ok: false, reason: `\`maxBytes\` must be a whole number, not ${value}.` };
2336
+ }
2337
+ if (value < 1) {
2338
+ return { ok: false, reason: `\`maxBytes\` must be at least 1; got ${value}.` };
2339
+ }
2340
+ return { ok: true, value };
2341
+ }
2342
+ function parseTarget(raw) {
2343
+ let url;
2344
+ try {
2345
+ url = new URL(raw);
2346
+ } catch {
2347
+ return {
2348
+ ok: false,
2349
+ reason: `That does not look like a valid absolute URL: ${raw}`
2350
+ };
2351
+ }
2352
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
2353
+ return {
2354
+ ok: false,
2355
+ reason: `Only http and https addresses are supported; received "${url.protocol}".`
2356
+ };
2357
+ }
2358
+ return { ok: true, url };
2359
+ }
2360
+ var NAMED_ENTITIES = {
2361
+ amp: "&",
2362
+ lt: "<",
2363
+ gt: ">",
2364
+ quot: '"',
2365
+ apos: "'",
2366
+ nbsp: " ",
2367
+ hellip: "\u2026",
2368
+ mdash: "\u2014",
2369
+ ndash: "\u2013",
2370
+ copy: "\xA9",
2371
+ reg: "\xAE",
2372
+ trade: "\u2122"
2373
+ };
2374
+ function decodeEntities(text) {
2375
+ return text.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]*);/g, (whole, body) => {
2376
+ if (body[0] === "#") {
2377
+ const isHex = body[1] === "x" || body[1] === "X";
2378
+ const digits = isHex ? body.slice(2) : body.slice(1);
2379
+ const code = Number.parseInt(digits, isHex ? 16 : 10);
2380
+ if (!Number.isFinite(code) || code < 0 || code > 1114111) return whole;
2381
+ try {
2382
+ return String.fromCodePoint(code);
2383
+ } catch {
2384
+ return whole;
2385
+ }
2386
+ }
2387
+ const named = NAMED_ENTITIES[body.toLowerCase()];
2388
+ return named ?? whole;
2389
+ });
2390
+ }
2391
+ function dropRegion(html, tag) {
2392
+ const pattern = new RegExp(`<${tag}\\b[^>]*>[\\s\\S]*?<\\/${tag}\\s*>`, "gi");
2393
+ return html.replace(pattern, " ");
2394
+ }
2395
+ function htmlToText(html) {
2396
+ let s = html;
2397
+ s = s.replace(/<!--[\s\S]*?-->/g, " ");
2398
+ for (const tag of ["script", "style", "noscript", "template", "head", "svg", "iframe"]) {
2399
+ s = dropRegion(s, tag);
2400
+ }
2401
+ s = s.replace(
2402
+ /<a\b[^>]*\bhref\s*=\s*("([^"]*)"|'([^']*)'|([^\s">]+))[^>]*>([\s\S]*?)<\/a\s*>/gi,
2403
+ (_whole, _q, dq, sq, bare, label) => {
2404
+ const href = (dq ?? sq ?? bare ?? "").trim();
2405
+ const text = label.trim();
2406
+ if (!href) return text;
2407
+ if (!text) return href;
2408
+ return `${text} (${href})`;
2409
+ }
2410
+ );
2411
+ s = s.replace(/<h([1-6])\b[^>]*>([\s\S]*?)<\/h\1\s*>/gi, (_whole, level, inner) => {
2412
+ const hashes = "#".repeat(Number.parseInt(level, 10));
2413
+ return `
2414
+
2415
+ ${hashes} ${inner.trim()}
2416
+
2417
+ `;
2418
+ });
2419
+ s = s.replace(/<li\b[^>]*>/gi, "\n- ");
2420
+ s = s.replace(/<br\s*\/?>/gi, "\n");
2421
+ s = s.replace(
2422
+ /<\/?(p|div|section|article|header|footer|main|ul|ol|table|tr|h[1-6]|blockquote|pre)\b[^>]*>/gi,
2423
+ "\n\n"
2424
+ );
2425
+ s = s.replace(/<[^>]+>/g, " ");
2426
+ s = decodeEntities(s);
2427
+ const lines = s.split("\n").map((line4) => line4.replace(/[ \t\f\v ]+/g, " ").trim());
2428
+ const out = [];
2429
+ let blankRun = 0;
2430
+ for (const line4 of lines) {
2431
+ if (line4 === "") {
2432
+ blankRun += 1;
2433
+ if (blankRun <= 1) out.push("");
2434
+ } else {
2435
+ blankRun = 0;
2436
+ out.push(line4);
2437
+ }
2438
+ }
2439
+ return out.join("\n").trim();
2440
+ }
2441
+ var webFetchTool = defineTool({
2442
+ name: "webfetch",
2443
+ description: DESCRIPTION6,
2444
+ parameters: {
2445
+ type: "object",
2446
+ properties: {
2447
+ url: {
2448
+ type: "string",
2449
+ description: "Absolute http or https address of the page to download."
2450
+ },
2451
+ maxBytes: {
2452
+ type: "integer",
2453
+ minimum: 1,
2454
+ description: "Optional ceiling on how many bytes of the page body to process before conversion."
2455
+ }
2456
+ },
2457
+ required: ["url"],
2458
+ additionalProperties: false
2459
+ },
2460
+ async run(input, ctx) {
2461
+ const raw = input;
2462
+ const bag = raw !== null && typeof raw === "object" ? raw : {};
2463
+ const rawUrl = bag.url;
2464
+ if (typeof rawUrl !== "string" || rawUrl.trim().length === 0) {
2465
+ return failure6("A non-empty `url` string is required to fetch a page.");
2466
+ }
2467
+ const target = parseTarget(rawUrl.trim());
2468
+ if (!target.ok) return failure6(target.reason);
2469
+ const capParse = readByteCap(bag.maxBytes);
2470
+ if (!capParse.ok) return failure6(capParse.reason);
2471
+ const requested = capParse.value ?? DEFAULT_BODY_CEILING;
2472
+ const bodyCeiling = Math.min(requested, ABSOLUTE_BODY_CEILING);
2473
+ const timeout = new AbortController();
2474
+ const timer = setTimeout(() => {
2475
+ timeout.abort();
2476
+ }, REQUEST_TIMEOUT_MS2);
2477
+ const onOuterAbort = () => {
2478
+ timeout.abort();
2479
+ };
2480
+ ctx.signal.addEventListener("abort", onOuterAbort, { once: true });
2481
+ let response;
2482
+ try {
2483
+ response = await fetch(target.url.toString(), {
2484
+ method: "GET",
2485
+ redirect: "follow",
2486
+ signal: timeout.signal,
2487
+ headers: {
2488
+ // A neutral, honest accept header; many servers vary on it.
2489
+ accept: "text/html,application/xhtml+xml,text/plain;q=0.9,*/*;q=0.8"
2490
+ }
2491
+ });
2492
+ } catch (err) {
2493
+ clearTimeout(timer);
2494
+ ctx.signal.removeEventListener("abort", onOuterAbort);
2495
+ if (ctx.signal.aborted) {
2496
+ return failure6(`The fetch of ${target.url.toString()} was cancelled before it completed.`);
2497
+ }
2498
+ const detail = err instanceof Error ? err.message : String(err);
2499
+ return failure6(`Could not reach ${target.url.toString()}: ${detail}`);
2500
+ }
2501
+ if (!response.ok) {
2502
+ clearTimeout(timer);
2503
+ ctx.signal.removeEventListener("abort", onOuterAbort);
2504
+ return failure6(
2505
+ `The server answered ${response.status} (${response.statusText || "no status text"}) for ${target.url.toString()}.`
2506
+ );
2507
+ }
2508
+ let body;
2509
+ try {
2510
+ body = await response.text();
2511
+ } catch (err) {
2512
+ const detail = err instanceof Error ? err.message : String(err);
2513
+ return failure6(`Downloaded ${target.url.toString()} but its body could not be decoded: ${detail}`);
2514
+ } finally {
2515
+ clearTimeout(timer);
2516
+ ctx.signal.removeEventListener("abort", onOuterAbort);
2517
+ }
2518
+ let rawTrimmed = false;
2519
+ if (Buffer.byteLength(body, "utf8") > bodyCeiling) {
2520
+ const clipped = clamp(body, { kind: "head", maxBytes: bodyCeiling });
2521
+ body = clipped;
2522
+ rawTrimmed = true;
2523
+ }
2524
+ const contentType = (response.headers.get("content-type") ?? "").toLowerCase();
2525
+ const looksHtml = contentType.includes("html") || contentType.includes("xml") || contentType === "" && /<\s*\/?[a-z][\s\S]*>/i.test(body);
2526
+ const rendered = looksHtml ? htmlToText(body) : body.trim();
2527
+ if (rendered.length === 0) {
2528
+ return {
2529
+ content: [
2530
+ {
2531
+ kind: "text",
2532
+ text: `Fetched ${target.url.toString()} successfully, but no readable text remained after stripping the page.`
2533
+ }
2534
+ ]
2535
+ };
2536
+ }
2537
+ const clamped = clamp(rendered, {
2538
+ kind: ctx.budget.kind,
2539
+ maxBytes: ctx.budget.maxBytes,
2540
+ notice: (omitted) => `
2541
+ [webfetch: dropped ${omitted} byte${omitted === 1 ? "" : "s"} of page text to stay inside the response budget]
2542
+ `
2543
+ });
2544
+ const budgetTrimmed = clamped !== rendered;
2545
+ const headerParts = [];
2546
+ headerParts.push(`Fetched ${target.url.toString()}.`);
2547
+ if (contentType) {
2548
+ headerParts.push(`Content type: ${contentType}.`);
2549
+ }
2550
+ if (rawTrimmed) {
2551
+ headerParts.push(
2552
+ "The downloaded page exceeded the byte ceiling, so only its opening portion was processed."
2553
+ );
2554
+ }
2555
+ if (budgetTrimmed) {
2556
+ headerParts.push(
2557
+ "The rendered text was further shortened to fit the response budget (see the inline marker)."
2558
+ );
2559
+ }
2560
+ const documentBody = `${headerParts.join(" ")}
2561
+
2562
+ ${clamped}`;
2563
+ return { content: [{ kind: "text", text: documentBody }] };
2564
+ }
2565
+ });
2566
+
2567
+ // src/connectors-saas/saas/core/scope-planner.ts
2568
+ function normalize(values) {
2569
+ const seen = /* @__PURE__ */ new Set();
2570
+ for (const raw of values) {
2571
+ const trimmed = raw.trim();
2572
+ if (trimmed.length > 0) seen.add(trimmed);
2573
+ }
2574
+ return [...seen].sort();
2575
+ }
2576
+ var ScopePlanner = class _ScopePlanner {
2577
+ constructor(toolkits, tools) {
2578
+ this.toolkits = toolkits;
2579
+ this.tools = tools;
2580
+ }
2581
+ toolkits;
2582
+ tools;
2583
+ /** Start from an empty scope — nothing included, nothing pinned. */
2584
+ static create() {
2585
+ return new _ScopePlanner([], []);
2586
+ }
2587
+ /**
2588
+ * Add one or more toolkits to the scope. Returns a new planner with those
2589
+ * toolkits unioned into the existing set; duplicates and blanks are dropped.
2590
+ */
2591
+ include(...toolkits) {
2592
+ return new _ScopePlanner(
2593
+ normalize([...this.toolkits, ...toolkits]),
2594
+ this.tools
2595
+ );
2596
+ }
2597
+ /**
2598
+ * Pin the scope to specific tool slugs. Returns a new planner whose tool set is
2599
+ * the union of the prior pinned tools and these. Pinned tools take precedence
2600
+ * over a bare toolkit list when the scope is resolved.
2601
+ */
2602
+ only(...toolNames) {
2603
+ return new _ScopePlanner(
2604
+ this.toolkits,
2605
+ normalize([...this.tools, ...toolNames])
2606
+ );
2607
+ }
2608
+ /** Whether anything at all has been declared. */
2609
+ isEmpty() {
2610
+ return this.toolkits.length === 0 && this.tools.length === 0;
2611
+ }
2612
+ /**
2613
+ * Resolve the accumulated intent into one explicit {@link ResolvedScope}.
2614
+ *
2615
+ * Pinned tools win: if any were declared, the scope is `byTools` (carrying the
2616
+ * included toolkits as context). Otherwise, if toolkits were included, it is
2617
+ * `byToolkits`. With nothing declared the scope is `empty` — callers decide
2618
+ * whether that is an error in their context.
2619
+ */
2620
+ plan() {
2621
+ if (this.tools.length > 0) {
2622
+ return { kind: "byTools", tools: this.tools, toolkits: this.toolkits };
2623
+ }
2624
+ if (this.toolkits.length > 0) {
2625
+ return { kind: "byToolkits", toolkits: this.toolkits };
2626
+ }
2627
+ return { kind: "empty" };
2628
+ }
2629
+ };
2630
+
2631
+ // src/connectors-saas/saas/core/cache.ts
2632
+ import { createHash } from "node:crypto";
2633
+ function canonicalize(value) {
2634
+ if (value === null || typeof value !== "object") {
2635
+ return value;
2636
+ }
2637
+ if (Array.isArray(value)) {
2638
+ return value.map(canonicalize);
2639
+ }
2640
+ const source = value;
2641
+ const out = {};
2642
+ for (const key of Object.keys(source).sort()) {
2643
+ const child = source[key];
2644
+ if (child === void 0) continue;
2645
+ out[key] = canonicalize(child);
2646
+ }
2647
+ return out;
2648
+ }
2649
+ function hashKey(value) {
2650
+ const canonical = JSON.stringify(canonicalize(value));
2651
+ return createHash("sha256").update(canonical ?? "null").digest("hex");
2652
+ }
2653
+ var HashCache = class {
2654
+ slots = /* @__PURE__ */ new Map();
2655
+ /**
2656
+ * Return the cached promise for `shape`, creating it via `factory` on first
2657
+ * request. If the factory's promise rejects, the slot is evicted so a later
2658
+ * call can retry rather than re-serving the failure forever.
2659
+ */
2660
+ take(shape, factory) {
2661
+ const key = hashKey(shape);
2662
+ const existing = this.slots.get(key);
2663
+ if (existing) return existing;
2664
+ const created = factory().catch((err) => {
2665
+ this.slots.delete(key);
2666
+ throw err;
2667
+ });
2668
+ this.slots.set(key, created);
2669
+ return created;
2670
+ }
2671
+ /** Whether a slot for this request shape currently exists. */
2672
+ has(shape) {
2673
+ return this.slots.has(hashKey(shape));
2674
+ }
2675
+ /** Drop the slot for this request shape, if any; returns whether one existed. */
2676
+ drop(shape) {
2677
+ return this.slots.delete(hashKey(shape));
2678
+ }
2679
+ /** Evict every entry. */
2680
+ clear() {
2681
+ this.slots.clear();
2682
+ }
2683
+ /** How many slots are currently populated. */
2684
+ get size() {
2685
+ return this.slots.size;
2686
+ }
2687
+ };
2688
+
2689
+ // src/connectors-saas/saas/core/builder.ts
2690
+ var REMOTE_PREFIX = "ext";
2691
+ function line(text, isError = false) {
2692
+ return { content: [{ kind: "text", text }], isError };
2693
+ }
2694
+ function renderRemoteResult(slug, result) {
2695
+ if (!result.ok) {
2696
+ const why = result.error ?? "the operation reported a failure";
2697
+ return line(`${slug} failed: ${why}`, true);
2698
+ }
2699
+ const blocks = [
2700
+ { kind: "text", text: `${slug} completed.` }
2701
+ ];
2702
+ if (result.data !== void 0) {
2703
+ blocks.push({ kind: "json", value: result.data });
2704
+ }
2705
+ return { content: blocks, isError: false };
2706
+ }
2707
+ function coinRemoteName(ref) {
2708
+ return `${REMOTE_PREFIX}:${ref.toolkit}.${ref.name}`;
2709
+ }
2710
+ function buildRemoteTool(ref, deps) {
2711
+ return defineTool({
2712
+ name: coinRemoteName(ref),
2713
+ description: ref.description,
2714
+ parameters: ref.inputSchema,
2715
+ async run(input) {
2716
+ const result = await deps.backend.execute(ref.name, input, {
2717
+ accountId: deps.accountId
2718
+ });
2719
+ return renderRemoteResult(ref.name, result);
2720
+ }
2721
+ });
2722
+ }
2723
+
2724
+ // src/connectors-saas/saas/control/tools.ts
2725
+ function line2(text, isError = false) {
2726
+ return { content: [{ kind: "text", text }], isError };
2727
+ }
2728
+ function readString(input, key) {
2729
+ const value = input[key];
2730
+ if (typeof value !== "string") return void 0;
2731
+ const trimmed = value.trim();
2732
+ return trimmed.length > 0 ? trimmed : void 0;
2733
+ }
2734
+ function readStringList(input, key) {
2735
+ const value = input[key];
2736
+ if (!Array.isArray(value)) return [];
2737
+ const out = [];
2738
+ for (const item of value) {
2739
+ if (typeof item === "string" && item.trim().length > 0) out.push(item.trim());
2740
+ }
2741
+ return out;
2742
+ }
2743
+ function renderEnable(report) {
2744
+ const head = report.hydrated.length > 0 ? `Enabled ${report.hydrated.length} tool(s) from ${report.toolkit}.` : `No tools were enabled from ${report.toolkit}.`;
2745
+ return { content: [{ kind: "text", text: head }, { kind: "json", value: report }] };
2746
+ }
2747
+ function renderConnect(report) {
2748
+ let head;
2749
+ switch (report.action) {
2750
+ case "done":
2751
+ head = `${report.toolkit} is connected.`;
2752
+ break;
2753
+ case "await-auth":
2754
+ head = report.authUrl ? `Authorize ${report.toolkit} here: ${report.authUrl}` : `${report.toolkit} is awaiting authorization.`;
2755
+ break;
2756
+ case "expired":
2757
+ head = `The connection attempt for ${report.toolkit} expired; try again.`;
2758
+ break;
2759
+ default:
2760
+ head = `Connecting ${report.toolkit} failed: ${report.reason ?? "unknown error"}.`;
2761
+ break;
2762
+ }
2763
+ const isError = report.action === "failed";
2764
+ return { content: [{ kind: "text", text: head }, { kind: "json", value: report }], isError };
2765
+ }
2766
+ var CONTROL_SPECS = [
2767
+ {
2768
+ id: "saas_enable",
2769
+ description: "Hydrate a SaaS toolkit's operations into the live tool set so they can be called as native tools on later turns. Supply the toolkit slug; optionally pin specific operation slugs via `only` to enable just those.",
2770
+ parameters: {
2771
+ type: "object",
2772
+ properties: {
2773
+ toolkit: {
2774
+ type: "string",
2775
+ description: 'Slug of the toolkit to enable (e.g. "github").'
2776
+ },
2777
+ only: {
2778
+ type: "array",
2779
+ items: { type: "string" },
2780
+ description: "Optional operation slugs to enable instead of the whole toolkit."
2781
+ }
2782
+ },
2783
+ required: ["toolkit"],
2784
+ additionalProperties: false
2785
+ },
2786
+ async run(gateway, input) {
2787
+ const toolkit = readString(input, "toolkit");
2788
+ if (!toolkit) return line2("`toolkit` is required to enable a toolkit.", true);
2789
+ const only = readStringList(input, "only");
2790
+ const report = await gateway.enable(toolkit, only.length > 0 ? only : void 0);
2791
+ return renderEnable(report);
2792
+ }
2793
+ },
2794
+ {
2795
+ id: "saas_execute",
2796
+ description: "Directly execute any remote SaaS operation by its slug, passing its arguments. Use as a fallback when the operation has not been enabled as a native tool.",
2797
+ parameters: {
2798
+ type: "object",
2799
+ properties: {
2800
+ tool: { type: "string", description: "The remote operation slug to execute." },
2801
+ arguments: {
2802
+ type: "object",
2803
+ description: "Arguments for the operation, matching its input schema."
2804
+ },
2805
+ accountId: {
2806
+ type: "string",
2807
+ description: "Optional connected-account id to run the operation under."
2808
+ }
2809
+ },
2810
+ required: ["tool"],
2811
+ additionalProperties: false
2812
+ },
2813
+ async run(gateway, input) {
2814
+ const tool = readString(input, "tool");
2815
+ if (!tool) return line2("`tool` is required to execute an operation.", true);
2816
+ const args = input.arguments ?? {};
2817
+ return gateway.execute(tool, args, readString(input, "accountId"));
2818
+ }
2819
+ },
2820
+ {
2821
+ id: "saas_connect",
2822
+ description: "Begin connecting (authorizing) a SaaS toolkit and drive the flow toward an active link. Returns an authorization URL to share with the user when one is required.",
2823
+ parameters: {
2824
+ type: "object",
2825
+ properties: {
2826
+ toolkit: { type: "string", description: "Slug of the toolkit to connect." },
2827
+ callbackUrl: {
2828
+ type: "string",
2829
+ description: "Optional URL to return the user to after authorizing."
2830
+ },
2831
+ authConfigId: {
2832
+ type: "string",
2833
+ description: "Optional pre-existing auth-config id to reuse."
2834
+ }
2835
+ },
2836
+ required: ["toolkit"],
2837
+ additionalProperties: false
2838
+ },
2839
+ async run(gateway, input) {
2840
+ const toolkit = readString(input, "toolkit");
2841
+ if (!toolkit) return line2("`toolkit` is required to start a connection.", true);
2842
+ const report = await gateway.connect(toolkit, {
2843
+ callbackUrl: readString(input, "callbackUrl"),
2844
+ authConfigId: readString(input, "authConfigId")
2845
+ });
2846
+ return renderConnect(report);
2847
+ }
2848
+ },
2849
+ {
2850
+ id: "saas_status",
2851
+ description: "Report SaaS connection status: the connected accounts and the remote operations currently enabled (in scope) as native tools.",
2852
+ parameters: {
2853
+ type: "object",
2854
+ properties: {},
2855
+ additionalProperties: false
2856
+ },
2857
+ async run(gateway) {
2858
+ const status = await gateway.status();
2859
+ const head = `${status.accounts.length} connected account(s); ${status.enabledTools.length} operation(s) in scope.`;
2860
+ return { content: [{ kind: "text", text: head }, { kind: "json", value: status }] };
2861
+ }
2862
+ }
2863
+ ];
2864
+ function buildControlTools2(gateway) {
2865
+ return CONTROL_SPECS.map(
2866
+ (spec) => defineTool({
2867
+ name: spec.id,
2868
+ description: spec.description,
2869
+ parameters: spec.parameters,
2870
+ run: (input) => spec.run(gateway, input ?? {})
2871
+ })
2872
+ );
2873
+ }
2874
+
2875
+ // src/connectors-saas/saas/control/connect.ts
2876
+ function isTerminal(action) {
2877
+ return action.kind === "done" || action.kind === "expired" || action.kind === "failed";
2878
+ }
2879
+ var CONNECT_RULES = [
2880
+ {
2881
+ when: "active",
2882
+ decide: (state) => ({ kind: "done", accountId: state.accountId })
2883
+ },
2884
+ {
2885
+ when: "pending",
2886
+ decide: (state) => state.authUrl ? { kind: "await-auth", authUrl: state.authUrl } : { kind: "poll" }
2887
+ },
2888
+ {
2889
+ when: "expired",
2890
+ decide: () => ({ kind: "expired" })
2891
+ },
2892
+ {
2893
+ when: "failed",
2894
+ decide: () => ({
2895
+ kind: "failed",
2896
+ reason: "the authorization attempt failed"
2897
+ })
2898
+ }
2899
+ ];
2900
+ var RULE_BY_STATUS = new Map(
2901
+ CONNECT_RULES.map((rule) => [rule.when, rule])
2902
+ );
2903
+ function planConnect(state) {
2904
+ const rule = RULE_BY_STATUS.get(state.status);
2905
+ if (!rule) {
2906
+ return { kind: "failed", reason: `unknown connection status "${state.status}"` };
2907
+ }
2908
+ return rule.decide(state);
2909
+ }
2910
+ function asState(request) {
2911
+ return {
2912
+ id: request.id,
2913
+ status: request.status,
2914
+ authUrl: request.authUrl
2915
+ };
2916
+ }
2917
+ function realSleep(ms) {
2918
+ return new Promise((resolve) => setTimeout(resolve, ms));
2919
+ }
2920
+ async function initiateAndAwait(backend, toolkit, options = {}) {
2921
+ const pollIntervalMs = options.pollIntervalMs ?? 1500;
2922
+ const maxPolls = options.maxPolls ?? 40;
2923
+ const sleep = options.sleep ?? realSleep;
2924
+ const request = await backend.initiateConnection(toolkit, {
2925
+ authConfigId: options.authConfigId,
2926
+ callbackUrl: options.callbackUrl
2927
+ });
2928
+ let state = asState(request);
2929
+ let lastAuthUrl = request.authUrl;
2930
+ for (let polls = 0; polls < maxPolls; polls += 1) {
2931
+ const action = planConnect(state);
2932
+ if (action.kind === "await-auth" && action.authUrl) {
2933
+ lastAuthUrl = action.authUrl;
2934
+ }
2935
+ if (isTerminal(action)) {
2936
+ return { requestId: request.id, toolkit, action, authUrl: lastAuthUrl };
2937
+ }
2938
+ await sleep(pollIntervalMs);
2939
+ state = await backend.checkConnection(request.id);
2940
+ if (state.authUrl) lastAuthUrl = state.authUrl;
2941
+ }
2942
+ return {
2943
+ requestId: request.id,
2944
+ toolkit,
2945
+ action: {
2946
+ kind: "failed",
2947
+ reason: `connection did not become active within ${maxPolls} checks`
2948
+ },
2949
+ authUrl: lastAuthUrl
2950
+ };
2951
+ }
2952
+
2953
+ // src/connectors-saas/saas/adapter/composio-backend.ts
2954
+ import { Composio } from "@composio/core";
2955
+ var ComposioBackendError = class extends Error {
2956
+ /** The port method that could not be satisfied (e.g. `"checkConnection"`). */
2957
+ method;
2958
+ constructor(method, message, options) {
2959
+ super(message, options);
2960
+ this.name = "ComposioBackendError";
2961
+ this.method = method;
2962
+ }
2963
+ };
2964
+ var DEFAULT_USER = "default";
2965
+ var EMPTY_SCHEMA = {
2966
+ type: "object",
2967
+ properties: {},
2968
+ additionalProperties: false
2969
+ };
2970
+ function normalizeStatus(raw) {
2971
+ switch (String(raw ?? "").toUpperCase()) {
2972
+ case "ACTIVE":
2973
+ return "active";
2974
+ case "INITIALIZING":
2975
+ case "INITIATED":
2976
+ return "pending";
2977
+ case "EXPIRED":
2978
+ return "expired";
2979
+ case "FAILED":
2980
+ case "INACTIVE":
2981
+ case "REVOKED":
2982
+ return "failed";
2983
+ default:
2984
+ return "pending";
2985
+ }
2986
+ }
2987
+ function cleanString(value) {
2988
+ if (typeof value !== "string") return void 0;
2989
+ const trimmed = value.trim();
2990
+ return trimmed.length > 0 ? trimmed : void 0;
2991
+ }
2992
+ function pickAuthUrl(source) {
2993
+ return cleanString(source?.redirectUrl) ?? cleanString(source?.redirect_url);
2994
+ }
2995
+ function toToolkitInfo(raw) {
2996
+ return {
2997
+ slug: String(raw?.slug ?? ""),
2998
+ name: String(raw?.name ?? raw?.slug ?? ""),
2999
+ description: String(raw?.meta?.description ?? raw?.description ?? "")
3000
+ };
3001
+ }
3002
+ function toRemoteTool(raw, toolkitHint) {
3003
+ const schema = raw?.inputParameters;
3004
+ const inputSchema = schema && typeof schema === "object" ? schema : EMPTY_SCHEMA;
3005
+ return {
3006
+ name: String(raw?.slug ?? raw?.name ?? ""),
3007
+ toolkit: String(raw?.toolkit?.slug ?? toolkitHint),
3008
+ description: String(raw?.description ?? ""),
3009
+ inputSchema
3010
+ };
3011
+ }
3012
+ function toConnectedAccount(raw) {
3013
+ const updatedAt = cleanString(raw?.updatedAt) ?? cleanString(raw?.updated_at);
3014
+ return {
3015
+ id: String(raw?.id ?? ""),
3016
+ toolkit: String(raw?.toolkit?.slug ?? raw?.toolkitSlug ?? ""),
3017
+ status: normalizeStatus(raw?.status),
3018
+ ...updatedAt ? { updatedAt } : {}
3019
+ };
3020
+ }
3021
+ var ComposioBackend = class {
3022
+ composio;
3023
+ userId;
3024
+ constructor(options) {
3025
+ this.composio = new Composio({ apiKey: options.apiKey });
3026
+ this.userId = cleanString(options.userId) ?? DEFAULT_USER;
3027
+ }
3028
+ async listToolkits() {
3029
+ const response = await this.composio.toolkits.get({});
3030
+ const items = Array.isArray(response) ? response : Array.isArray(response?.items) ? response.items : [];
3031
+ return items.map(toToolkitInfo).filter((t) => t.slug.length > 0);
3032
+ }
3033
+ async listTools(toolkit) {
3034
+ const slug = cleanString(toolkit);
3035
+ if (!slug) {
3036
+ throw new ComposioBackendError(
3037
+ "listTools",
3038
+ "a toolkit slug is required to list its operations"
3039
+ );
3040
+ }
3041
+ const response = await this.composio.tools.getRawComposioTools({
3042
+ toolkits: [slug]
3043
+ });
3044
+ const items = Array.isArray(response) ? response : Array.isArray(response?.items) ? response.items : [];
3045
+ return items.map((raw) => toRemoteTool(raw, slug)).filter((t) => t.name.length > 0);
3046
+ }
3047
+ async execute(toolName, args, opts) {
3048
+ const slug = cleanString(toolName);
3049
+ if (!slug) {
3050
+ return { ok: false, error: "no operation slug was provided" };
3051
+ }
3052
+ const accountId = cleanString(opts.accountId);
3053
+ try {
3054
+ const response = await this.composio.tools.execute(slug, {
3055
+ userId: this.userId,
3056
+ arguments: args ?? {},
3057
+ ...accountId ? { connectedAccountId: accountId } : {}
3058
+ });
3059
+ const ok = response?.successful === true;
3060
+ const logId = cleanString(response?.logId);
3061
+ if (!ok) {
3062
+ return {
3063
+ ok: false,
3064
+ error: cleanString(response?.error) ?? `${slug} reported a failure`,
3065
+ ...logId ? { logId } : {}
3066
+ };
3067
+ }
3068
+ return {
3069
+ ok: true,
3070
+ data: response?.data,
3071
+ ...logId ? { logId } : {}
3072
+ };
3073
+ } catch (err) {
3074
+ return { ok: false, error: errorMessage(err) };
3075
+ }
3076
+ }
3077
+ async listConnectedAccounts() {
3078
+ const response = await this.composio.connectedAccounts.list({
3079
+ userIds: [this.userId]
3080
+ });
3081
+ const items = Array.isArray(response) ? response : Array.isArray(response?.items) ? response.items : [];
3082
+ return items.map(toConnectedAccount).filter((a) => a.id.length > 0);
3083
+ }
3084
+ async initiateConnection(toolkit, opts) {
3085
+ const slug = cleanString(toolkit);
3086
+ if (!slug) {
3087
+ throw new ComposioBackendError(
3088
+ "initiateConnection",
3089
+ "a toolkit slug is required to open a connection"
3090
+ );
3091
+ }
3092
+ const authConfigId = cleanString(opts?.authConfigId);
3093
+ const request = await this.composio.toolkits.authorize(
3094
+ this.userId,
3095
+ slug,
3096
+ authConfigId
3097
+ );
3098
+ const authUrl = pickAuthUrl(request);
3099
+ return {
3100
+ id: String(request?.id ?? ""),
3101
+ toolkit: slug,
3102
+ status: normalizeStatus(request?.status),
3103
+ ...authUrl ? { authUrl } : {}
3104
+ };
3105
+ }
3106
+ async checkConnection(id) {
3107
+ const handle = cleanString(id);
3108
+ if (!handle) {
3109
+ throw new ComposioBackendError(
3110
+ "checkConnection",
3111
+ "a connection request id is required to poll its state"
3112
+ );
3113
+ }
3114
+ const account = await this.composio.connectedAccounts.get(handle);
3115
+ const status = normalizeStatus(account?.status);
3116
+ const authUrl = pickAuthUrl(account);
3117
+ return {
3118
+ id: handle,
3119
+ status,
3120
+ ...status === "active" ? { accountId: String(account?.id ?? handle) } : {},
3121
+ ...authUrl ? { authUrl } : {}
3122
+ };
3123
+ }
3124
+ };
3125
+ function errorMessage(err) {
3126
+ if (err instanceof Error && err.message.trim().length > 0) return err.message;
3127
+ const text = cleanString(err);
3128
+ return text ?? "the Composio SDK reported an unspecified error";
3129
+ }
3130
+ function createComposioBackend(opts) {
3131
+ const apiKey = cleanString(opts.apiKey);
3132
+ if (!apiKey) {
3133
+ throw new ComposioBackendError(
3134
+ "createComposioBackend",
3135
+ "a Composio API key is required"
3136
+ );
3137
+ }
3138
+ return new ComposioBackend({ apiKey });
3139
+ }
3140
+
3141
+ // src/connectors-saas/saas/gateway.ts
3142
+ function line3(text, isError = false) {
3143
+ return { content: [{ kind: "text", text }], isError };
3144
+ }
3145
+ function renderResult(slug, ok, data, error) {
3146
+ if (!ok) {
3147
+ return line3(`${slug} failed: ${error ?? "the operation reported a failure"}`, true);
3148
+ }
3149
+ const content = [{ kind: "text", text: `${slug} completed.` }];
3150
+ if (data !== void 0) content.push({ kind: "json", value: data });
3151
+ return { content, isError: false };
3152
+ }
3153
+ function reportAction(kind) {
3154
+ return kind === "poll" ? "await-auth" : kind;
3155
+ }
3156
+ function forbidden(what) {
3157
+ return new Proxy({}, {
3158
+ get() {
3159
+ throw new Error(`SaaS tools have no access to ${what}.`);
3160
+ }
3161
+ });
3162
+ }
3163
+ function inertContext() {
3164
+ return {
3165
+ cwd: process.cwd(),
3166
+ fs: forbidden("the filesystem"),
3167
+ shell: forbidden("the shell"),
3168
+ signal: new AbortController().signal,
3169
+ budget: { kind: "tail", maxBytes: 1 << 20 }
3170
+ };
3171
+ }
3172
+ function normalizePins(toolkit, only) {
3173
+ const planner = only && only.length > 0 ? ScopePlanner.create().include(toolkit).only(...only) : ScopePlanner.create().include(toolkit);
3174
+ const scope = planner.plan();
3175
+ const pins = scope.kind === "byTools" ? [...scope.tools] : [];
3176
+ return { toolkit: toolkit.trim(), only: pins };
3177
+ }
3178
+ var LiveSaasGateway = class {
3179
+ backend;
3180
+ accountId;
3181
+ connectOpts;
3182
+ /** The live registry every hydrated remote tool is registered into. */
3183
+ registry = new ToolRegistry();
3184
+ /** The control tools, built once and registered up front. */
3185
+ controlTools;
3186
+ /** The remote tools hydrated so far, in hydration order, keyed by name. */
3187
+ remoteTools = /* @__PURE__ */ new Map();
3188
+ /** Content-hash cache of enable results, keyed by request shape. */
3189
+ enableCache = new HashCache();
3190
+ constructor(backend, opts = {}) {
3191
+ this.backend = backend;
3192
+ this.accountId = opts.accountId;
3193
+ this.connectOpts = opts.connect;
3194
+ this.controlTools = buildControlTools2(this);
3195
+ this.registry.registerAll(this.controlTools);
3196
+ }
3197
+ controlToolBox() {
3198
+ return this.boxOf(this.controlTools);
3199
+ }
3200
+ toolBox() {
3201
+ return this.boxOf([...this.controlTools, ...this.remoteTools.values()]);
3202
+ }
3203
+ async enableToolkit(name, only) {
3204
+ const shape = normalizePins(name, only);
3205
+ const tools = await this.enableCache.take(shape, async () => {
3206
+ const refs = await this.listScopedTools(shape);
3207
+ return refs.map((ref) => this.hydrate(ref));
3208
+ });
3209
+ for (const tool of tools) {
3210
+ this.remoteTools.set(tool.name, tool);
3211
+ this.registry.register(tool);
3212
+ }
3213
+ return [...tools];
3214
+ }
3215
+ async enable(toolkit, only) {
3216
+ const shape = normalizePins(toolkit, only);
3217
+ const cached = this.enableCache.has(shape);
3218
+ const tools = await this.enableToolkit(toolkit, only);
3219
+ return {
3220
+ toolkit: shape.toolkit,
3221
+ hydrated: tools.map((t) => t.name),
3222
+ tools,
3223
+ cached
3224
+ };
3225
+ }
3226
+ async execute(tool, args, accountId) {
3227
+ const slug = tool.trim();
3228
+ if (!slug) return line3("`tool` is required to execute an operation.", true);
3229
+ const result = await this.backend.execute(slug, args ?? {}, {
3230
+ accountId: accountId ?? this.accountId
3231
+ });
3232
+ return renderResult(slug, result.ok, result.data, result.error);
3233
+ }
3234
+ async connect(toolkit, opts = {}) {
3235
+ const slug = toolkit.trim();
3236
+ const outcome = await initiateAndAwait(this.backend, slug, {
3237
+ callbackUrl: opts.callbackUrl,
3238
+ authConfigId: opts.authConfigId,
3239
+ ...this.connectOpts
3240
+ });
3241
+ const action = outcome.action;
3242
+ return {
3243
+ toolkit: slug,
3244
+ action: reportAction(action.kind),
3245
+ requestId: outcome.requestId,
3246
+ ...outcome.authUrl ? { authUrl: outcome.authUrl } : {},
3247
+ ...action.kind === "done" && action.accountId ? { accountId: action.accountId } : {},
3248
+ ...action.kind === "failed" ? { reason: action.reason } : {}
3249
+ };
3250
+ }
3251
+ async status() {
3252
+ const accounts = await this.backend.listConnectedAccounts();
3253
+ return { accounts, enabledTools: [...this.remoteTools.keys()] };
3254
+ }
3255
+ /** Wrap one remote-tool reference into a native tool bound to this gateway's account. */
3256
+ hydrate(ref) {
3257
+ return buildRemoteTool(ref, { backend: this.backend, accountId: this.accountId });
3258
+ }
3259
+ /**
3260
+ * List the remote-tool references a given enable shape resolves to. With pins,
3261
+ * the toolkit's catalog is filtered down to the pinned slugs; without, the whole
3262
+ * toolkit is in scope.
3263
+ */
3264
+ async listScopedTools(shape) {
3265
+ const all = await this.backend.listTools(shape.toolkit);
3266
+ if (shape.only.length === 0) return all;
3267
+ const pinned = new Set(shape.only);
3268
+ return all.filter((tool) => pinned.has(tool.name));
3269
+ }
3270
+ /** Box an explicit tool list, dispatching each call through a stateless context. */
3271
+ boxOf(tools) {
3272
+ const scratch = new ToolRegistry();
3273
+ scratch.registerAll(tools);
3274
+ return scratch.toToolBox(inertContext);
3275
+ }
3276
+ };
3277
+ function createSaasGateway(backend, opts) {
3278
+ return new LiveSaasGateway(backend, opts);
3279
+ }
3280
+ function createComposioGateway(opts) {
3281
+ return createSaasGateway(createComposioBackend({ apiKey: opts.apiKey }));
3282
+ }
3283
+ export {
3284
+ ComposioBackendError,
3285
+ ScopePlanner,
3286
+ createComposioBackend,
3287
+ createComposioGateway,
3288
+ createSaasGateway
3289
+ };