indusagi 0.13.7 → 0.13.8

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 (446) hide show
  1. package/dist/agent.js +28713 -0
  2. package/dist/ai.js +19964 -0
  3. package/dist/capabilities.js +2730 -0
  4. package/dist/cli.js +9 -0
  5. package/dist/connectors-saas.js +3355 -0
  6. package/dist/index.js +18211 -0
  7. package/dist/interop.js +3247 -0
  8. package/dist/llmgateway.js +3343 -0
  9. package/dist/mcp.js +2448 -0
  10. package/dist/memory.js +0 -0
  11. package/dist/react-host/index.js +101 -0
  12. package/dist/react-host/ink.js +97 -0
  13. package/dist/react-host/jsx-runtime.js +95 -0
  14. package/dist/react-ink.js +3834 -0
  15. package/dist/runtime.js +4521 -0
  16. package/dist/sarvam-mcp.js +960 -0
  17. package/dist/shell-app.js +12435 -0
  18. package/dist/smithy.js +8133 -0
  19. package/dist/swarm.js +8918 -0
  20. package/dist/tracing.js +761 -0
  21. package/dist/tui.js +2213 -0
  22. package/dist/types/capabilities/backends/index.d.ts +10 -0
  23. package/dist/types/capabilities/backends/node-backends.d.ts +30 -0
  24. package/dist/types/capabilities/capabilities.test.d.ts +14 -0
  25. package/dist/types/capabilities/files/diff.d.ts +49 -0
  26. package/dist/types/capabilities/files/edit.d.ts +21 -0
  27. package/dist/types/capabilities/files/ls.d.ts +16 -0
  28. package/dist/types/capabilities/files/read-state-gate.d.ts +69 -0
  29. package/dist/types/capabilities/files/read-state-gate.test.d.ts +14 -0
  30. package/dist/types/capabilities/files/read.d.ts +15 -0
  31. package/dist/types/capabilities/files/write.d.ts +16 -0
  32. package/dist/types/capabilities/index.d.ts +29 -0
  33. package/dist/types/capabilities/kernel/backends.d.ts +119 -0
  34. package/dist/types/capabilities/kernel/context.d.ts +52 -0
  35. package/dist/types/capabilities/kernel/index.d.ts +24 -0
  36. package/dist/types/capabilities/kernel/output.d.ts +40 -0
  37. package/dist/types/capabilities/kernel/registry.d.ts +61 -0
  38. package/dist/types/capabilities/kernel/spec.d.ts +168 -0
  39. package/dist/types/capabilities/planning/todo.d.ts +62 -0
  40. package/dist/types/capabilities/registry.d.ts +44 -0
  41. package/dist/types/capabilities/search/find.d.ts +33 -0
  42. package/dist/types/capabilities/search/grep.d.ts +30 -0
  43. package/dist/types/capabilities/shell/bash.d.ts +18 -0
  44. package/dist/types/capabilities/shell/process.d.ts +33 -0
  45. package/dist/types/capabilities/web/webfetch.d.ts +25 -0
  46. package/dist/types/capabilities/web/websearch.d.ts +23 -0
  47. package/dist/types/connectors-saas/connectors-saas.test.d.ts +12 -0
  48. package/dist/types/connectors-saas/index.d.ts +16 -0
  49. package/dist/types/connectors-saas/saas/adapter/composio-backend.d.ts +60 -0
  50. package/dist/types/connectors-saas/saas/control/connect.d.ts +114 -0
  51. package/dist/types/connectors-saas/saas/control/tools.d.ts +67 -0
  52. package/dist/types/connectors-saas/saas/core/builder.d.ts +86 -0
  53. package/dist/types/connectors-saas/saas/core/cache.d.ts +53 -0
  54. package/dist/types/connectors-saas/saas/core/index.d.ts +14 -0
  55. package/dist/types/connectors-saas/saas/core/port.d.ts +157 -0
  56. package/dist/types/connectors-saas/saas/core/scope-planner.d.ts +74 -0
  57. package/dist/types/connectors-saas/saas/gateway.d.ts +133 -0
  58. package/dist/types/connectors-saas/saas/render/format.d.ts +54 -0
  59. package/dist/types/connectors-saas/saas/render/index.d.ts +19 -0
  60. package/dist/types/connectors-saas/saas/render/summarizers.d.ts +58 -0
  61. package/dist/types/connectors-sarvam/connect.d.ts +14 -0
  62. package/dist/types/connectors-sarvam/connectors-sarvam.test.d.ts +14 -0
  63. package/dist/types/connectors-sarvam/index.d.ts +14 -0
  64. package/dist/types/connectors-sarvam/toolbox.d.ts +19 -0
  65. package/dist/types/connectors-sarvam/types.d.ts +49 -0
  66. package/dist/types/connectors-zoho/connect.d.ts +22 -0
  67. package/dist/types/connectors-zoho/connectors-zoho.test.d.ts +10 -0
  68. package/dist/types/connectors-zoho/index.d.ts +13 -0
  69. package/dist/types/connectors-zoho/toolbox.d.ts +19 -0
  70. package/dist/types/connectors-zoho/types.d.ts +56 -0
  71. package/dist/types/facade/agent.d.ts +1 -0
  72. package/dist/types/facade/ai.d.ts +1 -0
  73. package/dist/types/facade/bot/actions/bash.d.ts +71 -0
  74. package/dist/types/facade/bot/actions/bash.test.d.ts +1 -0
  75. package/dist/types/facade/bot/actions/checkpoint.d.ts +49 -0
  76. package/dist/types/facade/bot/actions/checkpoint.test.d.ts +1 -0
  77. package/dist/types/facade/bot/actions/composio/accounts.d.ts +22 -0
  78. package/dist/types/facade/bot/actions/composio/client.d.ts +39 -0
  79. package/dist/types/facade/bot/actions/composio/connect.d.ts +19 -0
  80. package/dist/types/facade/bot/actions/composio/enable.d.ts +25 -0
  81. package/dist/types/facade/bot/actions/composio/execute.d.ts +26 -0
  82. package/dist/types/facade/bot/actions/composio/helpers.d.ts +16 -0
  83. package/dist/types/facade/bot/actions/composio/index.d.ts +9 -0
  84. package/dist/types/facade/bot/actions/composio/provider.d.ts +8 -0
  85. package/dist/types/facade/bot/actions/composio/toolkits.d.ts +22 -0
  86. package/dist/types/facade/bot/actions/composio/tools.d.ts +28 -0
  87. package/dist/types/facade/bot/actions/composio/types.d.ts +137 -0
  88. package/dist/types/facade/bot/actions/crew/activity-tracker.d.ts +65 -0
  89. package/dist/types/facade/bot/actions/crew/cleanup.d.ts +50 -0
  90. package/dist/types/facade/bot/actions/crew/fs-lock.d.ts +11 -0
  91. package/dist/types/facade/bot/actions/crew/index.d.ts +11 -0
  92. package/dist/types/facade/bot/actions/crew/mailbox.d.ts +20 -0
  93. package/dist/types/facade/bot/actions/crew/model-policy.d.ts +22 -0
  94. package/dist/types/facade/bot/actions/crew/names.d.ts +27 -0
  95. package/dist/types/facade/bot/actions/crew/protocol.d.ts +74 -0
  96. package/dist/types/facade/bot/actions/crew/task-store.d.ts +88 -0
  97. package/dist/types/facade/bot/actions/crew/team-attach-claim.d.ts +35 -0
  98. package/dist/types/facade/bot/actions/crew/team-config.d.ts +54 -0
  99. package/dist/types/facade/bot/actions/crew/worktree.d.ts +39 -0
  100. package/dist/types/facade/bot/actions/edit-diff.d.ts +66 -0
  101. package/dist/types/facade/bot/actions/edit-utils.d.ts +86 -0
  102. package/dist/types/facade/bot/actions/edit.d.ts +59 -0
  103. package/dist/types/facade/bot/actions/edit.test.d.ts +1 -0
  104. package/dist/types/facade/bot/actions/find.d.ts +27 -0
  105. package/dist/types/facade/bot/actions/find.test.d.ts +1 -0
  106. package/dist/types/facade/bot/actions/grep.d.ts +53 -0
  107. package/dist/types/facade/bot/actions/grep.test.d.ts +1 -0
  108. package/dist/types/facade/bot/actions/index.d.ts +316 -0
  109. package/dist/types/facade/bot/actions/kit/hook-runner.d.ts +12 -0
  110. package/dist/types/facade/bot/actions/kit/image-resize.d.ts +19 -0
  111. package/dist/types/facade/bot/actions/kit/mime.d.ts +1 -0
  112. package/dist/types/facade/bot/actions/kit/shell.d.ts +12 -0
  113. package/dist/types/facade/bot/actions/ls.d.ts +41 -0
  114. package/dist/types/facade/bot/actions/path-utils.d.ts +8 -0
  115. package/dist/types/facade/bot/actions/process-controller.d.ts +14 -0
  116. package/dist/types/facade/bot/actions/process-manager.d.ts +59 -0
  117. package/dist/types/facade/bot/actions/process-types.d.ts +73 -0
  118. package/dist/types/facade/bot/actions/process.d.ts +37 -0
  119. package/dist/types/facade/bot/actions/read-state.d.ts +83 -0
  120. package/dist/types/facade/bot/actions/read-state.test.d.ts +1 -0
  121. package/dist/types/facade/bot/actions/read.d.ts +43 -0
  122. package/dist/types/facade/bot/actions/read.test.d.ts +1 -0
  123. package/dist/types/facade/bot/actions/registry.d.ts +20 -0
  124. package/dist/types/facade/bot/actions/sandbox-backend.d.ts +99 -0
  125. package/dist/types/facade/bot/actions/sandbox-backend.test.d.ts +1 -0
  126. package/dist/types/facade/bot/actions/todo-store.d.ts +76 -0
  127. package/dist/types/facade/bot/actions/todo-types.d.ts +72 -0
  128. package/dist/types/facade/bot/actions/todo.d.ts +76 -0
  129. package/dist/types/facade/bot/actions/truncate.d.ts +78 -0
  130. package/dist/types/facade/bot/actions/webfetch.d.ts +35 -0
  131. package/dist/types/facade/bot/actions/websearch.d.ts +37 -0
  132. package/dist/types/facade/bot/actions/websearch.test.d.ts +1 -0
  133. package/dist/types/facade/bot/actions/write.d.ts +45 -0
  134. package/dist/types/facade/bot/agent-loop.d.ts +30 -0
  135. package/dist/types/facade/bot/agent-loop.test.d.ts +1 -0
  136. package/dist/types/facade/bot/agent.d.ts +140 -0
  137. package/dist/types/facade/bot/error-handler.d.ts +7 -0
  138. package/dist/types/facade/bot/event-bus.d.ts +8 -0
  139. package/dist/types/facade/bot/index.d.ts +7 -0
  140. package/dist/types/facade/bot/messages.d.ts +83 -0
  141. package/dist/types/facade/bot/permission-gate.test.d.ts +1 -0
  142. package/dist/types/facade/bot/proxy.d.ts +70 -0
  143. package/dist/types/facade/bot/session-manager.d.ts +409 -0
  144. package/dist/types/facade/bot/state-manager.d.ts +21 -0
  145. package/dist/types/facade/bot/telemetry.d.ts +6 -0
  146. package/dist/types/facade/bot/types.d.ts +267 -0
  147. package/dist/types/facade/mcp-core/client-pool.d.ts +105 -0
  148. package/dist/types/facade/mcp-core/client.d.ts +245 -0
  149. package/dist/types/facade/mcp-core/client.test.d.ts +18 -0
  150. package/dist/types/facade/mcp-core/config.d.ts +60 -0
  151. package/dist/types/facade/mcp-core/errors.d.ts +103 -0
  152. package/dist/types/facade/mcp-core/index.d.ts +59 -0
  153. package/dist/types/facade/mcp-core/oauth/flow.d.ts +72 -0
  154. package/dist/types/facade/mcp-core/oauth/index.d.ts +18 -0
  155. package/dist/types/facade/mcp-core/oauth/oauth.test.d.ts +8 -0
  156. package/dist/types/facade/mcp-core/oauth/provider.d.ts +51 -0
  157. package/dist/types/facade/mcp-core/oauth/token-store.d.ts +31 -0
  158. package/dist/types/facade/mcp-core/oauth/types.d.ts +96 -0
  159. package/dist/types/facade/mcp-core/schema-converter.d.ts +67 -0
  160. package/dist/types/facade/mcp-core/server.d.ts +110 -0
  161. package/dist/types/facade/mcp-core/tool-factory.d.ts +62 -0
  162. package/dist/types/facade/mcp-core/toolbox-bridge.d.ts +46 -0
  163. package/dist/types/facade/mcp-core/toolbox-bridge.test.d.ts +8 -0
  164. package/dist/types/facade/mcp-core/types.d.ts +298 -0
  165. package/dist/types/facade/mcp.d.ts +1 -0
  166. package/dist/types/facade/memory.d.ts +1 -0
  167. package/dist/types/facade/ml/adapters/amazon-bedrock.d.ts +32 -0
  168. package/dist/types/facade/ml/adapters/anthropic-retry.test.d.ts +1 -0
  169. package/dist/types/facade/ml/adapters/anthropic.d.ts +78 -0
  170. package/dist/types/facade/ml/adapters/azure-openai-responses.d.ts +14 -0
  171. package/dist/types/facade/ml/adapters/google-shared.d.ts +99 -0
  172. package/dist/types/facade/ml/adapters/google-vertex.d.ts +14 -0
  173. package/dist/types/facade/ml/adapters/google.d.ts +15 -0
  174. package/dist/types/facade/ml/adapters/kimi.d.ts +21 -0
  175. package/dist/types/facade/ml/adapters/mock.d.ts +9 -0
  176. package/dist/types/facade/ml/adapters/nvidia.d.ts +12 -0
  177. package/dist/types/facade/ml/adapters/openai-codex-responses.d.ts +8 -0
  178. package/dist/types/facade/ml/adapters/openai-completions.d.ts +24 -0
  179. package/dist/types/facade/ml/adapters/openai-responses-shared.d.ts +25 -0
  180. package/dist/types/facade/ml/adapters/openai-responses.d.ts +12 -0
  181. package/dist/types/facade/ml/adapters/openai-scaffold.d.ts +3 -0
  182. package/dist/types/facade/ml/adapters/register-builtins.d.ts +2 -0
  183. package/dist/types/facade/ml/adapters/simple-options.d.ts +39 -0
  184. package/dist/types/facade/ml/adapters/simple-options.test.d.ts +1 -0
  185. package/dist/types/facade/ml/adapters/transform-messages.d.ts +23 -0
  186. package/dist/types/facade/ml/api-registry.d.ts +49 -0
  187. package/dist/types/facade/ml/cli.d.ts +2 -0
  188. package/dist/types/facade/ml/env-api-keys.d.ts +19 -0
  189. package/dist/types/facade/ml/index.d.ts +27 -0
  190. package/dist/types/facade/ml/kit/auth/anthropic.d.ts +17 -0
  191. package/dist/types/facade/ml/kit/auth/github-copilot.d.ts +22 -0
  192. package/dist/types/facade/ml/kit/auth/index.d.ts +50 -0
  193. package/dist/types/facade/ml/kit/auth/kimi.d.ts +23 -0
  194. package/dist/types/facade/ml/kit/auth/oauth-page.d.ts +2 -0
  195. package/dist/types/facade/ml/kit/auth/openai-codex.d.ts +36 -0
  196. package/dist/types/facade/ml/kit/auth/pkce.d.ts +12 -0
  197. package/dist/types/facade/ml/kit/auth/types.d.ts +67 -0
  198. package/dist/types/facade/ml/kit/base-stream-handler.d.ts +30 -0
  199. package/dist/types/facade/ml/kit/event-stream.d.ts +63 -0
  200. package/dist/types/facade/ml/kit/index.d.ts +14 -0
  201. package/dist/types/facade/ml/kit/json-parse.d.ts +23 -0
  202. package/dist/types/facade/ml/kit/message-transform.d.ts +32 -0
  203. package/dist/types/facade/ml/kit/output-factory.d.ts +8 -0
  204. package/dist/types/facade/ml/kit/overflow.d.ts +9 -0
  205. package/dist/types/facade/ml/kit/provider-adapter.d.ts +56 -0
  206. package/dist/types/facade/ml/kit/provider-client-builder.d.ts +36 -0
  207. package/dist/types/facade/ml/kit/provider-consolidation.d.ts +3 -0
  208. package/dist/types/facade/ml/kit/provider-constants.d.ts +34 -0
  209. package/dist/types/facade/ml/kit/provider-errors.d.ts +52 -0
  210. package/dist/types/facade/ml/kit/sanitize-unicode.d.ts +2 -0
  211. package/dist/types/facade/ml/kit/stream-event-helper.d.ts +38 -0
  212. package/dist/types/facade/ml/kit/stream-handler-types.d.ts +46 -0
  213. package/dist/types/facade/ml/kit/streaming-state-manager.d.ts +42 -0
  214. package/dist/types/facade/ml/kit/tool-converter.d.ts +49 -0
  215. package/dist/types/facade/ml/kit/typebox-helpers.d.ts +24 -0
  216. package/dist/types/facade/ml/kit/validation.d.ts +26 -0
  217. package/dist/types/facade/ml/models.d.ts +41 -0
  218. package/dist/types/facade/ml/models.generated.d.ts +12405 -0
  219. package/dist/types/facade/ml/stream.d.ts +27 -0
  220. package/dist/types/facade/ml/types.d.ts +269 -0
  221. package/dist/types/index.d.ts +18 -0
  222. package/dist/types/interop/index.d.ts +12 -0
  223. package/dist/types/interop/interop.test.d.ts +19 -0
  224. package/dist/types/interop/protocol-bridge/bridge.d.ts +52 -0
  225. package/dist/types/interop/protocol-bridge/contract.d.ts +249 -0
  226. package/dist/types/interop/protocol-bridge/endpoint.d.ts +124 -0
  227. package/dist/types/interop/protocol-bridge/fleet.d.ts +92 -0
  228. package/dist/types/interop/protocol-bridge/host.d.ts +61 -0
  229. package/dist/types/interop/protocol-bridge/index.d.ts +16 -0
  230. package/dist/types/interop/protocol-bridge/schema.d.ts +29 -0
  231. package/dist/types/llmgateway/catalog/cards.d.ts +18 -0
  232. package/dist/types/llmgateway/catalog/cost.d.ts +15 -0
  233. package/dist/types/llmgateway/catalog/index.d.ts +7 -0
  234. package/dist/types/llmgateway/catalog/query.d.ts +40 -0
  235. package/dist/types/llmgateway/connectors/anthropic.d.ts +35 -0
  236. package/dist/types/llmgateway/connectors/azure-openai.d.ts +33 -0
  237. package/dist/types/llmgateway/connectors/bedrock.d.ts +113 -0
  238. package/dist/types/llmgateway/connectors/google-vertex.d.ts +38 -0
  239. package/dist/types/llmgateway/connectors/google.d.ts +40 -0
  240. package/dist/types/llmgateway/connectors/index.d.ts +26 -0
  241. package/dist/types/llmgateway/connectors/kimi.d.ts +28 -0
  242. package/dist/types/llmgateway/connectors/mock.d.ts +37 -0
  243. package/dist/types/llmgateway/connectors/nvidia.d.ts +27 -0
  244. package/dist/types/llmgateway/connectors/ollama.d.ts +45 -0
  245. package/dist/types/llmgateway/connectors/openai-chat.d.ts +25 -0
  246. package/dist/types/llmgateway/connectors/openai-responses.d.ts +49 -0
  247. package/dist/types/llmgateway/contract/connector.d.ts +32 -0
  248. package/dist/types/llmgateway/contract/conversation.d.ts +86 -0
  249. package/dist/types/llmgateway/contract/emission.d.ts +55 -0
  250. package/dist/types/llmgateway/contract/errors.d.ts +27 -0
  251. package/dist/types/llmgateway/contract/index.d.ts +13 -0
  252. package/dist/types/llmgateway/contract/model-card.d.ts +42 -0
  253. package/dist/types/llmgateway/contract/options.d.ts +31 -0
  254. package/dist/types/llmgateway/contract/reply.d.ts +33 -0
  255. package/dist/types/llmgateway/conversion/index.d.ts +10 -0
  256. package/dist/types/llmgateway/conversion/mappers.d.ts +65 -0
  257. package/dist/types/llmgateway/conversion/openai-compatible.d.ts +46 -0
  258. package/dist/types/llmgateway/conversion/reduce.d.ts +20 -0
  259. package/dist/types/llmgateway/credentials/oauth.d.ts +73 -0
  260. package/dist/types/llmgateway/credentials/pkce.d.ts +52 -0
  261. package/dist/types/llmgateway/credentials/secrets.d.ts +76 -0
  262. package/dist/types/llmgateway/gateway.d.ts +34 -0
  263. package/dist/types/llmgateway/gateway.test.d.ts +14 -0
  264. package/dist/types/llmgateway/index.d.ts +11 -0
  265. package/dist/types/llmgateway/streaming/channel.d.ts +24 -0
  266. package/dist/types/llmgateway/streaming/index.d.ts +10 -0
  267. package/dist/types/llmgateway/streaming/ndjson.d.ts +17 -0
  268. package/dist/types/llmgateway/streaming/sse.d.ts +31 -0
  269. package/dist/types/react-host/index.d.ts +9 -0
  270. package/dist/types/react-host/ink.d.ts +5 -0
  271. package/dist/types/react-host/jsx-runtime.d.ts +4 -0
  272. package/dist/types/react-host/loader.d.ts +3 -0
  273. package/dist/types/react-ink/components/ChangelogBlock.d.ts +8 -0
  274. package/dist/types/react-ink/components/DisplayBlockView.d.ts +8 -0
  275. package/dist/types/react-ink/components/Footer.d.ts +11 -0
  276. package/dist/types/react-ink/components/MessageList.d.ts +14 -0
  277. package/dist/types/react-ink/components/MessageRow.d.ts +13 -0
  278. package/dist/types/react-ink/components/StatusLine.d.ts +18 -0
  279. package/dist/types/react-ink/components/TaskPanel.d.ts +11 -0
  280. package/dist/types/react-ink/components/ToolEventBlock.d.ts +48 -0
  281. package/dist/types/react-ink/components/ToolEventBlock.test.d.ts +1 -0
  282. package/dist/types/react-ink/components/dialogs/DialogFrame.d.ts +8 -0
  283. package/dist/types/react-ink/components/dialogs/LoginDialog.d.ts +14 -0
  284. package/dist/types/react-ink/components/dialogs/ModelDialog.d.ts +9 -0
  285. package/dist/types/react-ink/components/dialogs/OAuthDialog.d.ts +9 -0
  286. package/dist/types/react-ink/components/dialogs/ScopedModelsDialog.d.ts +9 -0
  287. package/dist/types/react-ink/components/dialogs/SelectableDialog.d.ts +22 -0
  288. package/dist/types/react-ink/components/dialogs/SessionDialog.d.ts +13 -0
  289. package/dist/types/react-ink/components/dialogs/SettingsDialog.d.ts +14 -0
  290. package/dist/types/react-ink/components/dialogs/StartupSessionPicker.d.ts +9 -0
  291. package/dist/types/react-ink/components/dialogs/ThemeDialog.d.ts +26 -0
  292. package/dist/types/react-ink/components/dialogs/TreeDialog.d.ts +8 -0
  293. package/dist/types/react-ink/components/dialogs/UserMessageDialog.d.ts +8 -0
  294. package/dist/types/react-ink/components/messages/AssistantMessage.d.ts +12 -0
  295. package/dist/types/react-ink/components/messages/BashMessage.d.ts +8 -0
  296. package/dist/types/react-ink/components/messages/BranchSummaryMessage.d.ts +8 -0
  297. package/dist/types/react-ink/components/messages/CompactionMessage.d.ts +8 -0
  298. package/dist/types/react-ink/components/messages/CustomMessage.d.ts +9 -0
  299. package/dist/types/react-ink/components/messages/SkillInvocationMessage.d.ts +7 -0
  300. package/dist/types/react-ink/components/messages/ToolCallMessage.d.ts +8 -0
  301. package/dist/types/react-ink/components/messages/ToolResultBlock.d.ts +12 -0
  302. package/dist/types/react-ink/components/messages/UserMessage.d.ts +9 -0
  303. package/dist/types/react-ink/diff/Diff.d.ts +22 -0
  304. package/dist/types/react-ink/diff/diff.test.d.ts +1 -0
  305. package/dist/types/react-ink/diff/structured.d.ts +41 -0
  306. package/dist/types/react-ink/diff/word-diff.d.ts +27 -0
  307. package/dist/types/react-ink/index.d.ts +42 -0
  308. package/dist/types/react-ink/markdown/Markdown.d.ts +23 -0
  309. package/dist/types/react-ink/markdown/MarkdownTable.d.ts +19 -0
  310. package/dist/types/react-ink/markdown/StreamingMarkdown.d.ts +34 -0
  311. package/dist/types/react-ink/markdown/format-token.d.ts +39 -0
  312. package/dist/types/react-ink/markdown/highlight.d.ts +31 -0
  313. package/dist/types/react-ink/theme-adapter.d.ts +66 -0
  314. package/dist/types/react-ink/types.d.ts +133 -0
  315. package/dist/types/react-ink/utils/message-groups.d.ts +25 -0
  316. package/dist/types/react-ink/utils/selection-dialog.d.ts +2 -0
  317. package/dist/types/react-ink/utils/session-browser.d.ts +27 -0
  318. package/dist/types/react-ink/utils/tool-display.d.ts +37 -0
  319. package/dist/types/runtime/cadence/cadence.test.d.ts +6 -0
  320. package/dist/types/runtime/cadence/fold.d.ts +48 -0
  321. package/dist/types/runtime/cadence/index.d.ts +12 -0
  322. package/dist/types/runtime/cadence/reducer.d.ts +44 -0
  323. package/dist/types/runtime/conductor/agent.d.ts +71 -0
  324. package/dist/types/runtime/conductor/index.d.ts +11 -0
  325. package/dist/types/runtime/contract/config.d.ts +44 -0
  326. package/dist/types/runtime/contract/effect.d.ts +41 -0
  327. package/dist/types/runtime/contract/errors.d.ts +22 -0
  328. package/dist/types/runtime/contract/events.d.ts +63 -0
  329. package/dist/types/runtime/contract/index.d.ts +18 -0
  330. package/dist/types/runtime/contract/run-state.d.ts +57 -0
  331. package/dist/types/runtime/contract/session.d.ts +42 -0
  332. package/dist/types/runtime/contract/signal.d.ts +49 -0
  333. package/dist/types/runtime/contract/tools.d.ts +45 -0
  334. package/dist/types/runtime/dispatch/index.d.ts +9 -0
  335. package/dist/types/runtime/dispatch/scheduler.d.ts +53 -0
  336. package/dist/types/runtime/index.d.ts +22 -0
  337. package/dist/types/runtime/ledger/accumulator.d.ts +44 -0
  338. package/dist/types/runtime/ledger/bus.d.ts +50 -0
  339. package/dist/types/runtime/ledger/index.d.ts +11 -0
  340. package/dist/types/runtime/memory/compactor.d.ts +56 -0
  341. package/dist/types/runtime/memory/estimate.d.ts +21 -0
  342. package/dist/types/runtime/memory/index.d.ts +8 -0
  343. package/dist/types/runtime/runtime.test.d.ts +15 -0
  344. package/dist/types/runtime/store/dag.d.ts +72 -0
  345. package/dist/types/runtime/store/hash.d.ts +18 -0
  346. package/dist/types/runtime/store/index.d.ts +12 -0
  347. package/dist/types/runtime/store/persist.d.ts +49 -0
  348. package/dist/types/runtime/turn/driver.d.ts +32 -0
  349. package/dist/types/runtime/turn/index.d.ts +8 -0
  350. package/dist/types/runtime/wire/index.d.ts +10 -0
  351. package/dist/types/runtime/wire/projectors.d.ts +53 -0
  352. package/dist/types/shell-app/auth-cli/index.d.ts +9 -0
  353. package/dist/types/shell-app/auth-cli/oauth-cli.d.ts +73 -0
  354. package/dist/types/shell-app/boot/context.d.ts +108 -0
  355. package/dist/types/shell-app/boot/index.d.ts +13 -0
  356. package/dist/types/shell-app/boot/pipeline.d.ts +66 -0
  357. package/dist/types/shell-app/boot/stages.d.ts +77 -0
  358. package/dist/types/shell-app/cli.d.ts +75 -0
  359. package/dist/types/shell-app/config/index.d.ts +11 -0
  360. package/dist/types/shell-app/config/locator.d.ts +85 -0
  361. package/dist/types/shell-app/config/settings.d.ts +91 -0
  362. package/dist/types/shell-app/index.d.ts +26 -0
  363. package/dist/types/shell-app/invocation/flags.d.ts +89 -0
  364. package/dist/types/shell-app/invocation/parse.d.ts +89 -0
  365. package/dist/types/shell-app/locate/brand.d.ts +71 -0
  366. package/dist/types/shell-app/locate/index.d.ts +12 -0
  367. package/dist/types/shell-app/locate/locator.d.ts +122 -0
  368. package/dist/types/shell-app/runners/contract.d.ts +116 -0
  369. package/dist/types/shell-app/runners/index.d.ts +15 -0
  370. package/dist/types/shell-app/runners/one-shot.d.ts +21 -0
  371. package/dist/types/shell-app/runners/registry.d.ts +34 -0
  372. package/dist/types/shell-app/runners/repl.d.ts +51 -0
  373. package/dist/types/shell-app/runners/wire.d.ts +34 -0
  374. package/dist/types/shell-app/shell-app.test.d.ts +14 -0
  375. package/dist/types/shell-app/upgrade/index.d.ts +9 -0
  376. package/dist/types/shell-app/upgrade/upgrades.d.ts +62 -0
  377. package/dist/types/smithy/config/flag-reader.d.ts +128 -0
  378. package/dist/types/smithy/config/index.d.ts +9 -0
  379. package/dist/types/smithy/forge.d.ts +135 -0
  380. package/dist/types/smithy/index.d.ts +36 -0
  381. package/dist/types/smithy/knowledge/index.d.ts +10 -0
  382. package/dist/types/smithy/knowledge/loader.d.ts +64 -0
  383. package/dist/types/smithy/persona/blueprint.d.ts +75 -0
  384. package/dist/types/smithy/persona/define-agent.d.ts +51 -0
  385. package/dist/types/smithy/persona/index.d.ts +14 -0
  386. package/dist/types/smithy/persona/profiles.d.ts +44 -0
  387. package/dist/types/smithy/runtime/index.d.ts +9 -0
  388. package/dist/types/smithy/runtime/tool-ledger.d.ts +130 -0
  389. package/dist/types/smithy/smithy.test.d.ts +20 -0
  390. package/dist/types/smithy/ui/index.d.ts +11 -0
  391. package/dist/types/smithy/ui/transcript.d.ts +183 -0
  392. package/dist/types/swarm/coordinator.d.ts +192 -0
  393. package/dist/types/swarm/index.d.ts +33 -0
  394. package/dist/types/swarm/isolation/index.d.ts +14 -0
  395. package/dist/types/swarm/isolation/runner.d.ts +61 -0
  396. package/dist/types/swarm/isolation/worktree.d.ts +142 -0
  397. package/dist/types/swarm/kernel/faults.d.ts +52 -0
  398. package/dist/types/swarm/kernel/ids.d.ts +25 -0
  399. package/dist/types/swarm/kernel/index.d.ts +26 -0
  400. package/dist/types/swarm/kernel/json-cell.d.ts +113 -0
  401. package/dist/types/swarm/kernel/jsonl-log.d.ts +81 -0
  402. package/dist/types/swarm/postbox/channel.d.ts +88 -0
  403. package/dist/types/swarm/postbox/codecs.d.ts +253 -0
  404. package/dist/types/swarm/postbox/index.d.ts +16 -0
  405. package/dist/types/swarm/roster/index.d.ts +16 -0
  406. package/dist/types/swarm/roster/manifest.d.ts +185 -0
  407. package/dist/types/swarm/swarm.test.d.ts +24 -0
  408. package/dist/types/swarm/telemetry/activity.d.ts +143 -0
  409. package/dist/types/swarm/workboard/board.d.ts +174 -0
  410. package/dist/types/swarm/workboard/dep-graph.d.ts +77 -0
  411. package/dist/types/swarm/workboard/index.d.ts +12 -0
  412. package/dist/types/tracing/adapter/index.d.ts +12 -0
  413. package/dist/types/tracing/adapter/runtime-trace.d.ts +54 -0
  414. package/dist/types/tracing/channel/index.d.ts +9 -0
  415. package/dist/types/tracing/channel/signal.d.ts +93 -0
  416. package/dist/types/tracing/index.d.ts +25 -0
  417. package/dist/types/tracing/recorder/index.d.ts +12 -0
  418. package/dist/types/tracing/recorder/recorder.d.ts +75 -0
  419. package/dist/types/tracing/recorder/sampling.d.ts +55 -0
  420. package/dist/types/tracing/redaction/index.d.ts +8 -0
  421. package/dist/types/tracing/redaction/secret-scrubber.d.ts +95 -0
  422. package/dist/types/tracing/registry/hub.d.ts +57 -0
  423. package/dist/types/tracing/registry/index.d.ts +7 -0
  424. package/dist/types/tracing/signal/handle.d.ts +73 -0
  425. package/dist/types/tracing/signal/index.d.ts +12 -0
  426. package/dist/types/tracing/signal/segment.d.ts +124 -0
  427. package/dist/types/tracing/sinks/base.d.ts +51 -0
  428. package/dist/types/tracing/sinks/console.d.ts +44 -0
  429. package/dist/types/tracing/sinks/file.d.ts +47 -0
  430. package/dist/types/tracing/sinks/index.d.ts +16 -0
  431. package/dist/types/tracing/sinks/stream.d.ts +46 -0
  432. package/dist/types/tracing/tracing.test.d.ts +7 -0
  433. package/dist/types/ui/autocomplete.d.ts +59 -0
  434. package/dist/types/ui/contracts.d.ts +38 -0
  435. package/dist/types/ui/editor-component.d.ts +100 -0
  436. package/dist/types/ui/fuzzy.d.ts +29 -0
  437. package/dist/types/ui/index.d.ts +8 -0
  438. package/dist/types/ui/keybindings.d.ts +62 -0
  439. package/dist/types/ui/keys.d.ts +171 -0
  440. package/dist/types/ui/theme-types.d.ts +36 -0
  441. package/dist/types/ui/utils.d.ts +101 -0
  442. package/dist/types/ui-bridge/InteractiveApp.d.ts +38 -0
  443. package/dist/types/ui-bridge/adapter.d.ts +90 -0
  444. package/dist/types/ui-bridge/index.d.ts +37 -0
  445. package/dist/zoho.js +1451 -0
  446. package/package.json +48 -48
@@ -0,0 +1,960 @@
1
+ // src/facade/mcp-core/client.ts
2
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
3
+ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
4
+ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
5
+ import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
6
+ import {
7
+ UnauthorizedError
8
+ } from "@modelcontextprotocol/sdk/client/auth.js";
9
+ import {
10
+ ListRootsRequestSchema,
11
+ ElicitRequestSchema,
12
+ CreateMessageRequestSchema,
13
+ PingRequestSchema,
14
+ ToolListChangedNotificationSchema,
15
+ ResourceListChangedNotificationSchema,
16
+ ResourceUpdatedNotificationSchema,
17
+ PromptListChangedNotificationSchema,
18
+ ProgressNotificationSchema,
19
+ LoggingMessageNotificationSchema,
20
+ CancelledNotificationSchema
21
+ } from "@modelcontextprotocol/sdk/types.js";
22
+
23
+ // src/facade/mcp-core/errors.ts
24
+ var MCPError = class extends Error {
25
+ /** Error code */
26
+ code;
27
+ /** Additional error details */
28
+ details;
29
+ /** Server name where error occurred */
30
+ serverName;
31
+ /** Tool name if error occurred during tool execution */
32
+ toolName;
33
+ constructor(message, code, details, options) {
34
+ super(message, options?.cause ? { cause: options.cause } : void 0);
35
+ this.name = "MCPError";
36
+ this.code = code;
37
+ this.details = details;
38
+ this.serverName = options?.serverName;
39
+ this.toolName = options?.toolName;
40
+ }
41
+ /**
42
+ * Convert error to JSON for logging/serialization.
43
+ */
44
+ toJSON() {
45
+ return {
46
+ name: this.name,
47
+ message: this.message,
48
+ code: this.code,
49
+ details: this.details,
50
+ serverName: this.serverName,
51
+ toolName: this.toolName
52
+ };
53
+ }
54
+ /**
55
+ * Create a string representation of the error.
56
+ */
57
+ toString() {
58
+ let str = `${this.name} [${this.code}]: ${this.message}`;
59
+ if (this.serverName) str += ` (server: ${this.serverName})`;
60
+ if (this.toolName) str += ` (tool: ${this.toolName})`;
61
+ return str;
62
+ }
63
+ };
64
+ function createServerError(message, serverName, details) {
65
+ return new MCPError(message, "SERVER_ERROR" /* SERVER_ERROR */, details, { serverName });
66
+ }
67
+
68
+ // src/facade/mcp-core/client.ts
69
+ var DEFAULT_REQUEST_TIMEOUT = 6e4;
70
+ var DEFAULT_CONNECT_TIMEOUT = 3e4;
71
+ var MCPClient = class {
72
+ constructor(options) {
73
+ this.options = options;
74
+ this.serverName = options.name;
75
+ this.config = options.config;
76
+ this.timeout = options.timeout ?? DEFAULT_REQUEST_TIMEOUT;
77
+ this.logHandler = options.logger;
78
+ this.enableServerLogs = options.enableServerLogs ?? true;
79
+ this.enableProgressTracking = options.enableProgressTracking ?? false;
80
+ this._roots = options.roots ?? [];
81
+ }
82
+ options;
83
+ client;
84
+ transport;
85
+ isConnected = false;
86
+ connectionPromise = null;
87
+ serverCapabilities;
88
+ logHandler;
89
+ enableServerLogs;
90
+ enableProgressTracking;
91
+ _roots;
92
+ // --- Host-overridable handlers (Core of #13) --------------------------------
93
+ // Server-initiated REQUESTS are answered by request handlers registered on the
94
+ // SDK client; the handlers delegate to these host-supplied callbacks when set,
95
+ // and fall back to sensible defaults otherwise.
96
+ elicitationHandler;
97
+ samplingHandler;
98
+ // Server-initiated NOTIFICATIONS are dispatched to these (so the host can, for
99
+ // example, re-list tools when a `tools/list_changed` arrives).
100
+ resourceUpdatedHandler;
101
+ resourceListChangedHandler;
102
+ toolListChangedHandler;
103
+ promptListChangedHandler;
104
+ progressHandler;
105
+ /** Server name */
106
+ serverName;
107
+ /** Server config */
108
+ config;
109
+ /** Request timeout */
110
+ timeout;
111
+ // ========================================================================
112
+ // Connection Lifecycle
113
+ // ========================================================================
114
+ /**
115
+ * Connect to the MCP server.
116
+ * Safe to call multiple times - returns existing connection if already connected.
117
+ */
118
+ async connect() {
119
+ if (this.isConnected) return;
120
+ if (this.connectionPromise) {
121
+ return this.connectionPromise;
122
+ }
123
+ this.connectionPromise = this.doConnect();
124
+ try {
125
+ await this.connectionPromise;
126
+ } finally {
127
+ this.connectionPromise = null;
128
+ }
129
+ }
130
+ async doConnect() {
131
+ const transport = this.createTransport(this.config);
132
+ this.transport = transport;
133
+ const client = new Client(
134
+ { name: "indusagi-coding-agent", version: "0.13.0" },
135
+ {
136
+ capabilities: {
137
+ roots: { listChanged: true },
138
+ elicitation: {},
139
+ sampling: {}
140
+ }
141
+ }
142
+ );
143
+ this.client = client;
144
+ this.registerServerHandlers(client);
145
+ const prevOnClose = transport.onclose;
146
+ transport.onclose = () => {
147
+ this.isConnected = false;
148
+ this.log("debug", "Transport closed");
149
+ prevOnClose?.();
150
+ };
151
+ try {
152
+ await client.connect(transport, { timeout: DEFAULT_CONNECT_TIMEOUT });
153
+ } catch (err) {
154
+ const recovered = await this.tryFinishOAuthAndReconnect(client, transport, err);
155
+ if (!recovered) {
156
+ throw this.wrapConnectError(err);
157
+ }
158
+ }
159
+ this.serverCapabilities = client.getServerCapabilities();
160
+ this.isConnected = true;
161
+ this.log("info", `Connected to MCP server`);
162
+ }
163
+ /**
164
+ * If `err` is an OAuth challenge and we have a provider + finishAuth-capable
165
+ * transport, wait for the browser code, exchange tokens, then reconnect on a
166
+ * **fresh** transport (the first transport is already `start()`ed and cannot
167
+ * be reused — see StreamableHTTPClientTransport.start).
168
+ *
169
+ * Matches the official SDK CLI example (`simpleOAuthClient`):
170
+ * finishAuth(code) → new StreamableHTTPClientTransport → client.connect again
171
+ *
172
+ * Client.connect already called `close()` on init failure, so the Client is
173
+ * free to attach a new transport.
174
+ */
175
+ async tryFinishOAuthAndReconnect(client, transport, err) {
176
+ if (!isAuthRequiredError(err)) return false;
177
+ const provider = this.options.authProvider;
178
+ if (!provider) return false;
179
+ const finishAuth = transport.finishAuth;
180
+ const waitForCode = provider.waitForAuthorizationCode;
181
+ if (typeof finishAuth !== "function" || typeof waitForCode !== "function") {
182
+ this.log(
183
+ "error",
184
+ "MCP server requires authentication but OAuth finish path is incomplete (need authProvider.waitForAuthorizationCode + transport.finishAuth)."
185
+ );
186
+ return false;
187
+ }
188
+ this.log("info", "MCP server requires OAuth \u2014 complete login in the browser\u2026");
189
+ try {
190
+ const code = await waitForCode.call(provider);
191
+ this.log("info", "OAuth authorization code received \u2014 exchanging tokens\u2026");
192
+ await finishAuth.call(transport, code);
193
+ try {
194
+ await transport.close?.();
195
+ } catch {
196
+ }
197
+ const fresh = this.createTransport(this.config);
198
+ this.transport = fresh;
199
+ const prevOnClose = fresh.onclose;
200
+ fresh.onclose = () => {
201
+ this.isConnected = false;
202
+ this.log("debug", "Transport closed");
203
+ prevOnClose?.();
204
+ };
205
+ this.log("info", "Reconnecting MCP session with OAuth tokens\u2026");
206
+ await client.connect(fresh, { timeout: DEFAULT_CONNECT_TIMEOUT });
207
+ return true;
208
+ } catch (oauthErr) {
209
+ this.log(
210
+ "error",
211
+ `OAuth finish failed: ${oauthErr instanceof Error ? oauthErr.message : String(oauthErr)}`
212
+ );
213
+ throw this.wrapConnectError(oauthErr);
214
+ }
215
+ }
216
+ /** Turn raw SDK / network errors into a clearer MCPError for callers. */
217
+ wrapConnectError(err) {
218
+ if (err instanceof MCPError) return err;
219
+ const message = err instanceof Error ? err.message : String(err);
220
+ if (isAuthRequiredError(err)) {
221
+ return new MCPError(
222
+ `Authentication required for MCP server "${this.serverName}". Pass auth: "auto" (default) to run the OAuth browser flow, or set a Bearer token via headers. Original: ${message}`,
223
+ "CONNECTION_FAILED" /* CONNECTION_FAILED */,
224
+ err,
225
+ { serverName: this.serverName, cause: err instanceof Error ? err : void 0 }
226
+ );
227
+ }
228
+ return new MCPError(
229
+ `Failed to connect to MCP server "${this.serverName}": ${message}`,
230
+ "CONNECTION_FAILED" /* CONNECTION_FAILED */,
231
+ err,
232
+ { serverName: this.serverName, cause: err instanceof Error ? err : void 0 }
233
+ );
234
+ }
235
+ /**
236
+ * Build the SDK transport for the configured server.
237
+ *
238
+ * - stdio: `StdioClientTransport` (inherits the parent env, merges config.env).
239
+ * - http: `StreamableHTTPClientTransport` (POST + server-push SSE channel,
240
+ * reconnect + session-expiry handled by the SDK), unless the config
241
+ * asks for the legacy `SSEClientTransport`.
242
+ */
243
+ createTransport(config) {
244
+ if ("command" in config) {
245
+ return new StdioClientTransport({
246
+ command: config.command,
247
+ args: config.args ?? [],
248
+ env: { ...sanitizeEnv(process.env), ...config.env ?? {} },
249
+ cwd: config.cwd,
250
+ stderr: "pipe"
251
+ });
252
+ }
253
+ if ("url" in config) {
254
+ const requestInit = config.headers ? { headers: config.headers } : void 0;
255
+ if (config.transport === "sse") {
256
+ return new SSEClientTransport(config.url, {
257
+ requestInit,
258
+ ...this.options.authProvider ? { authProvider: this.options.authProvider } : {}
259
+ });
260
+ }
261
+ return new StreamableHTTPClientTransport(config.url, {
262
+ requestInit,
263
+ ...this.options.authProvider ? { authProvider: this.options.authProvider } : {}
264
+ });
265
+ }
266
+ throw new MCPError(
267
+ "Server configuration must include either a command or a url",
268
+ "CONFIG_ERROR" /* CONFIG_ERROR */,
269
+ void 0,
270
+ { serverName: this.serverName }
271
+ );
272
+ }
273
+ /**
274
+ * Register handlers for server-initiated REQUESTS and NOTIFICATIONS.
275
+ *
276
+ * REQUESTS (have both `.method` AND `.id`) must be ANSWERED with a JSON-RPC
277
+ * RESPONSE carrying the matching id — the SDK does this automatically for the
278
+ * value a request handler returns (or rejects). The previous hand-rolled
279
+ * transport routed these into the notification path, so they were never
280
+ * answered (bug #13).
281
+ *
282
+ * Defaults:
283
+ * - ping → {}
284
+ * - roots/list → the configured roots
285
+ * - elicitation/create→ decline ({action:"cancel"}) unless a host handler is set
286
+ * - sampling → reject "Method not found" unless a host handler is set
287
+ */
288
+ registerServerHandlers(client) {
289
+ client.setRequestHandler(PingRequestSchema, async () => ({}));
290
+ client.setRequestHandler(ListRootsRequestSchema, async () => ({
291
+ roots: this._roots.map((r) => ({ uri: r.uri, name: r.name }))
292
+ }));
293
+ client.setRequestHandler(ElicitRequestSchema, async (request) => {
294
+ if (!this.elicitationHandler) {
295
+ return { action: "cancel" };
296
+ }
297
+ const params = request.params;
298
+ const elicitRequest = {
299
+ message: params.message,
300
+ requestedSchema: params.requestedSchema ?? {}
301
+ };
302
+ const result = await this.elicitationHandler(elicitRequest);
303
+ return mapToSdkElicitResult(result);
304
+ });
305
+ client.setRequestHandler(CreateMessageRequestSchema, async (request) => {
306
+ if (!this.samplingHandler) {
307
+ throw new MCPError(
308
+ "Method not found: sampling/createMessage",
309
+ "SERVER_ERROR" /* SERVER_ERROR */,
310
+ { method: "sampling/createMessage" },
311
+ { serverName: this.serverName }
312
+ );
313
+ }
314
+ return await this.samplingHandler(request.params);
315
+ });
316
+ client.setNotificationHandler(ToolListChangedNotificationSchema, () => {
317
+ this.log("debug", "Tool list changed");
318
+ this.toolListChangedHandler?.();
319
+ });
320
+ client.setNotificationHandler(ResourceListChangedNotificationSchema, () => {
321
+ this.log("debug", "Resource list changed");
322
+ this.resourceListChangedHandler?.();
323
+ });
324
+ client.setNotificationHandler(ResourceUpdatedNotificationSchema, (n) => {
325
+ const uri = n.params?.uri;
326
+ this.log("debug", `Resource updated: ${uri}`);
327
+ if (uri) this.resourceUpdatedHandler?.({ uri });
328
+ });
329
+ client.setNotificationHandler(PromptListChangedNotificationSchema, () => {
330
+ this.log("debug", "Prompt list changed");
331
+ this.promptListChangedHandler?.();
332
+ });
333
+ client.setNotificationHandler(ProgressNotificationSchema, (n) => {
334
+ const params = n.params;
335
+ this.log("debug", `Progress: ${JSON.stringify(params)}`);
336
+ if (this.progressHandler && params) {
337
+ const notification = {
338
+ progressToken: params.progressToken,
339
+ progress: params.progress,
340
+ total: params.total,
341
+ message: params.message
342
+ };
343
+ this.progressHandler(notification);
344
+ }
345
+ });
346
+ client.setNotificationHandler(LoggingMessageNotificationSchema, (n) => {
347
+ if (this.enableServerLogs && n.params) {
348
+ const { level, ...rest } = n.params;
349
+ this.log(level || "info", "[SERVER]", rest);
350
+ }
351
+ });
352
+ client.setNotificationHandler(CancelledNotificationSchema, (n) => {
353
+ this.log("debug", `Request cancelled: ${JSON.stringify(n.params)}`);
354
+ });
355
+ }
356
+ /**
357
+ * Disconnect from the MCP server.
358
+ *
359
+ * The SDK's `client.close()` closes the transport and rejects any pending
360
+ * requests — a clean teardown for both stdio (graceful subprocess shutdown)
361
+ * and HTTP (close the push channel / end the session).
362
+ */
363
+ async disconnect() {
364
+ if (!this.client) {
365
+ this.log("debug", "Disconnect called but not connected");
366
+ this.isConnected = false;
367
+ return;
368
+ }
369
+ this.log("debug", "Disconnecting from MCP server");
370
+ try {
371
+ await this.client.close();
372
+ } catch (error) {
373
+ this.log("error", `Error during disconnect: ${error}`);
374
+ } finally {
375
+ this.client = void 0;
376
+ this.transport = void 0;
377
+ this.isConnected = false;
378
+ this.log("debug", "Successfully disconnected");
379
+ }
380
+ }
381
+ /**
382
+ * Whether the client is connected.
383
+ */
384
+ get connected() {
385
+ return this.isConnected;
386
+ }
387
+ // ========================================================================
388
+ // Tool Operations
389
+ // ========================================================================
390
+ /**
391
+ * List all tools available from the server.
392
+ */
393
+ async listTools() {
394
+ this.ensureConnected();
395
+ const result = await this.client.listTools(void 0, {
396
+ timeout: this.timeout
397
+ });
398
+ return result.tools;
399
+ }
400
+ /**
401
+ * Call a tool on the server.
402
+ */
403
+ async callTool(name, args) {
404
+ this.ensureConnected();
405
+ this.log("debug", `Calling tool: ${name}`);
406
+ try {
407
+ const result = await this.client.callTool(
408
+ { name, arguments: args },
409
+ void 0,
410
+ { timeout: this.timeout }
411
+ );
412
+ this.log("debug", `Tool ${name} executed successfully`);
413
+ return result;
414
+ } catch (error) {
415
+ this.log("error", `Tool ${name} failed: ${error}`);
416
+ throw this.wrapError(error);
417
+ }
418
+ }
419
+ // ========================================================================
420
+ // Resource Operations
421
+ // ========================================================================
422
+ /**
423
+ * List all resources available from the server.
424
+ */
425
+ async listResources() {
426
+ this.ensureConnected();
427
+ if (!this.serverCapabilities?.resources) {
428
+ return [];
429
+ }
430
+ const result = await this.client.listResources(void 0, {
431
+ timeout: this.timeout
432
+ });
433
+ return result.resources;
434
+ }
435
+ /**
436
+ * Read a resource from the server.
437
+ */
438
+ async readResource(uri) {
439
+ this.ensureConnected();
440
+ return await this.client.readResource({ uri }, { timeout: this.timeout });
441
+ }
442
+ /**
443
+ * Subscribe to resource updates.
444
+ */
445
+ async subscribeResource(uri) {
446
+ this.ensureConnected();
447
+ await this.client.subscribeResource({ uri }, { timeout: this.timeout });
448
+ }
449
+ /**
450
+ * Unsubscribe from resource updates.
451
+ */
452
+ async unsubscribeResource(uri) {
453
+ this.ensureConnected();
454
+ await this.client.unsubscribeResource({ uri }, { timeout: this.timeout });
455
+ }
456
+ // ========================================================================
457
+ // Prompt Operations
458
+ // ========================================================================
459
+ /**
460
+ * List all prompts available from the server.
461
+ */
462
+ async listPrompts() {
463
+ this.ensureConnected();
464
+ if (!this.serverCapabilities?.prompts) {
465
+ return [];
466
+ }
467
+ const result = await this.client.listPrompts(void 0, {
468
+ timeout: this.timeout
469
+ });
470
+ return result.prompts;
471
+ }
472
+ /**
473
+ * Get a prompt from the server.
474
+ */
475
+ async getPrompt(name, args) {
476
+ this.ensureConnected();
477
+ return await this.client.getPrompt(
478
+ { name, arguments: args },
479
+ { timeout: this.timeout }
480
+ );
481
+ }
482
+ // ========================================================================
483
+ // Roots Operations
484
+ // ========================================================================
485
+ /**
486
+ * Get the configured roots.
487
+ */
488
+ get roots() {
489
+ return [...this._roots];
490
+ }
491
+ /**
492
+ * Update the roots and notify the server.
493
+ */
494
+ async setRoots(roots) {
495
+ this.log("debug", `Updating roots to ${roots.length} entries`);
496
+ this._roots = [...roots];
497
+ if (this.isConnected && this.client) {
498
+ try {
499
+ await this.client.sendRootsListChanged();
500
+ } catch (error) {
501
+ this.log("debug", `Failed to send roots/list_changed: ${error}`);
502
+ }
503
+ }
504
+ }
505
+ // ========================================================================
506
+ // Handler Registration
507
+ //
508
+ // Setters STORE the host handler (and, for notifications, the SDK handler
509
+ // registered in `registerServerHandlers` delegates to the stored callback).
510
+ // This is the host-overridable layer at the core of bug #13.
511
+ // ========================================================================
512
+ /**
513
+ * Set a handler for resource updated notifications.
514
+ */
515
+ setResourceUpdatedHandler(handler) {
516
+ this.resourceUpdatedHandler = handler;
517
+ this.log("debug", "Resource updated handler registered");
518
+ }
519
+ /**
520
+ * Set a handler for resource list changed notifications.
521
+ */
522
+ setResourceListChangedHandler(handler) {
523
+ this.resourceListChangedHandler = handler;
524
+ this.log("debug", "Resource list changed handler registered");
525
+ }
526
+ /**
527
+ * Set a handler for tool list changed notifications.
528
+ */
529
+ setToolListChangedHandler(handler) {
530
+ this.toolListChangedHandler = handler;
531
+ this.log("debug", "Tool list changed handler registered");
532
+ }
533
+ /**
534
+ * Set a handler for prompt list changed notifications.
535
+ */
536
+ setPromptListChangedHandler(handler) {
537
+ this.promptListChangedHandler = handler;
538
+ this.log("debug", "Prompt list changed handler registered");
539
+ }
540
+ /**
541
+ * Set a handler for elicitation requests. When set, the server's
542
+ * `elicitation/create` REQUEST is answered with the host's decision; when
543
+ * unset the request is declined ({action:"cancel"}).
544
+ */
545
+ setElicitationHandler(handler) {
546
+ this.elicitationHandler = handler;
547
+ this.log("debug", "Elicitation handler registered");
548
+ }
549
+ /**
550
+ * Set a handler for sampling (`sampling/createMessage`) requests. When set,
551
+ * the server request is answered with the host's result; when unset the
552
+ * request is rejected with "Method not found".
553
+ */
554
+ setSamplingHandler(handler) {
555
+ this.samplingHandler = handler;
556
+ this.log("debug", "Sampling handler registered");
557
+ }
558
+ /**
559
+ * Set a handler for progress notifications.
560
+ */
561
+ setProgressHandler(handler) {
562
+ this.progressHandler = handler;
563
+ this.log("debug", "Progress handler registered");
564
+ }
565
+ // ========================================================================
566
+ // Private Methods
567
+ // ========================================================================
568
+ ensureConnected() {
569
+ if (!this.isConnected || !this.client) {
570
+ throw new MCPError(
571
+ "Not connected to MCP server",
572
+ "NOT_CONNECTED" /* NOT_CONNECTED */,
573
+ void 0,
574
+ { serverName: this.serverName }
575
+ );
576
+ }
577
+ }
578
+ /**
579
+ * Normalize an SDK/transport error into an MCPError. Session-expiry style
580
+ * failures (404 session / -32001) are surfaced as SESSION_ERROR so callers
581
+ * (the pool) can decide to reconnect; the SDK's StreamableHTTP transport
582
+ * already attempts a bounded reconnect re-using the session id before this.
583
+ */
584
+ wrapError(error) {
585
+ if (error instanceof MCPError) return error;
586
+ const message = error instanceof Error ? error.message : String(error);
587
+ const code = error.code;
588
+ if (code === -32001 || /\b404\b|session/i.test(message)) {
589
+ return new MCPError(message, "SESSION_ERROR" /* SESSION_ERROR */, { code }, {
590
+ serverName: this.serverName
591
+ });
592
+ }
593
+ return new MCPError(message, "SERVER_ERROR" /* SERVER_ERROR */, { code }, {
594
+ serverName: this.serverName
595
+ });
596
+ }
597
+ log(level, message, details) {
598
+ const msg = `[${this.serverName}] ${message}`;
599
+ if (this.logHandler) {
600
+ this.logHandler({
601
+ level,
602
+ message: msg,
603
+ timestamp: /* @__PURE__ */ new Date(),
604
+ serverName: this.serverName,
605
+ details
606
+ });
607
+ } else {
608
+ if (process.env.INDUSAGI_DEBUG || level === "error") {
609
+ const prefix = `[MCP:${level.toUpperCase()}]`;
610
+ if (details) {
611
+ if (level === "error") {
612
+ console.error(prefix, msg, details);
613
+ } else {
614
+ console.log(prefix, msg, details);
615
+ }
616
+ } else {
617
+ if (level === "error") {
618
+ console.error(prefix, msg);
619
+ } else {
620
+ console.log(prefix, msg);
621
+ }
622
+ }
623
+ }
624
+ }
625
+ }
626
+ };
627
+ function mapToSdkElicitResult(result) {
628
+ if (result.action === "accept") {
629
+ return {
630
+ action: "accept",
631
+ content: result.content ?? {}
632
+ };
633
+ }
634
+ return { action: result.action };
635
+ }
636
+ function isAuthRequiredError(err) {
637
+ if (err == null) return false;
638
+ if (err instanceof UnauthorizedError) return true;
639
+ if (typeof err === "object") {
640
+ const code = err.code;
641
+ if (code === 401 || code === "401") return true;
642
+ }
643
+ if (err instanceof Error) {
644
+ const msg = err.message;
645
+ if (/unauthorized/i.test(msg)) return true;
646
+ if (/authentication required/i.test(msg)) return true;
647
+ if (/auth required/i.test(msg)) return true;
648
+ if (err.name === "UnauthorizedError") return true;
649
+ }
650
+ return false;
651
+ }
652
+ function sanitizeEnv(env) {
653
+ const out = {};
654
+ for (const [k, v] of Object.entries(env)) {
655
+ if (typeof v === "string") out[k] = v;
656
+ }
657
+ return out;
658
+ }
659
+
660
+ // src/capabilities/kernel/spec.ts
661
+ function coerceInput(raw) {
662
+ if (typeof raw === "string") {
663
+ const trimmed = raw.trim();
664
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
665
+ try {
666
+ return JSON.parse(trimmed);
667
+ } catch {
668
+ }
669
+ }
670
+ return raw;
671
+ }
672
+ if (raw === null || raw === void 0) {
673
+ return {};
674
+ }
675
+ return raw;
676
+ }
677
+ function describeThrow(err) {
678
+ if (err instanceof Error) return err.message;
679
+ if (typeof err === "string") return err;
680
+ try {
681
+ return JSON.stringify(err);
682
+ } catch {
683
+ return String(err);
684
+ }
685
+ }
686
+ function projectOutcome(id, result) {
687
+ const blocks = result.content;
688
+ let output;
689
+ if (blocks.length === 1) {
690
+ const only = blocks[0];
691
+ output = only.kind === "text" ? only.text : only.value;
692
+ } else {
693
+ output = blocks;
694
+ }
695
+ return { id, output, isError: result.isError === true };
696
+ }
697
+ function defineTool(spec) {
698
+ return {
699
+ name: spec.name,
700
+ // Facade `AgentTool` surface: top-level schema fields + an `execute` adapter
701
+ // so the tool is usable by the high-level `Agent` as well as the kernel.
702
+ label: spec.name,
703
+ description: spec.description,
704
+ parameters: spec.parameters,
705
+ async execute(_toolCallId, params, signal) {
706
+ const ctx = {
707
+ cwd: process.cwd(),
708
+ signal: signal ?? new AbortController().signal
709
+ };
710
+ try {
711
+ const result = await spec.run(coerceInput(params), ctx);
712
+ return {
713
+ content: result.content.map(
714
+ (block) => block.kind === "text" ? { type: "text", text: block.text } : { type: "text", text: JSON.stringify(block.value) }
715
+ ),
716
+ details: {},
717
+ isError: result.isError ?? false
718
+ };
719
+ } catch (err) {
720
+ return {
721
+ content: [{ type: "text", text: `${spec.name} did not finish: ${describeThrow(err)}` }],
722
+ details: {},
723
+ isError: true
724
+ };
725
+ }
726
+ },
727
+ descriptor() {
728
+ return {
729
+ name: spec.name,
730
+ description: spec.description,
731
+ parameters: spec.parameters
732
+ };
733
+ },
734
+ async invoke(call, ctx) {
735
+ if (ctx.signal.aborted) {
736
+ return {
737
+ id: call.id,
738
+ output: `Cancelled before ${spec.name} could begin.`,
739
+ isError: true
740
+ };
741
+ }
742
+ try {
743
+ const input = coerceInput(call.input);
744
+ const result = await spec.run(input, ctx);
745
+ return projectOutcome(call.id, result);
746
+ } catch (err) {
747
+ return {
748
+ id: call.id,
749
+ output: `${spec.name} did not finish: ${describeThrow(err)}`,
750
+ isError: true
751
+ };
752
+ }
753
+ }
754
+ };
755
+ }
756
+
757
+ // src/facade/mcp-core/toolbox-bridge.ts
758
+ var NOOP_FS_NOT_SUPPORTED = "not supported in MCP-wrapped tools";
759
+ var noopFs = {
760
+ readFile: () => {
761
+ throw new MCPError(NOOP_FS_NOT_SUPPORTED, "CONFIG_ERROR");
762
+ },
763
+ writeFile: () => {
764
+ throw new MCPError(NOOP_FS_NOT_SUPPORTED, "CONFIG_ERROR");
765
+ },
766
+ stat: () => {
767
+ throw new MCPError(NOOP_FS_NOT_SUPPORTED, "CONFIG_ERROR");
768
+ },
769
+ readdir: () => {
770
+ throw new MCPError(NOOP_FS_NOT_SUPPORTED, "CONFIG_ERROR");
771
+ },
772
+ mkdir: () => {
773
+ throw new MCPError(NOOP_FS_NOT_SUPPORTED, "CONFIG_ERROR");
774
+ },
775
+ rm: () => {
776
+ throw new MCPError(NOOP_FS_NOT_SUPPORTED, "CONFIG_ERROR");
777
+ },
778
+ exists: () => {
779
+ throw new MCPError(NOOP_FS_NOT_SUPPORTED, "CONFIG_ERROR");
780
+ }
781
+ };
782
+ var noopShell = {
783
+ exec: () => {
784
+ throw new MCPError(NOOP_FS_NOT_SUPPORTED, "CONFIG_ERROR");
785
+ },
786
+ spawn: () => {
787
+ throw new MCPError(NOOP_FS_NOT_SUPPORTED, "CONFIG_ERROR");
788
+ }
789
+ };
790
+ function makeToolContext(signal) {
791
+ return {
792
+ cwd: process.cwd(),
793
+ fs: noopFs,
794
+ shell: noopShell,
795
+ signal,
796
+ budget: { kind: "tail", maxBytes: 5e4 }
797
+ };
798
+ }
799
+ function describeThrow2(err) {
800
+ if (err instanceof Error) return err.message;
801
+ if (typeof err === "string") return err;
802
+ try {
803
+ return JSON.stringify(err);
804
+ } catch {
805
+ return String(err);
806
+ }
807
+ }
808
+ function projectMcpResult(result, logger) {
809
+ const blocks = [];
810
+ if (result.content && result.content.length > 0) {
811
+ for (const block of result.content) {
812
+ if (block.type === "text") {
813
+ blocks.push({ kind: "text", text: block.text });
814
+ } else if (block.type === "image") {
815
+ const len = typeof block.data === "string" ? block.data.length : 0;
816
+ blocks.push({ kind: "text", text: `[image ${block.mimeType}, ${len} chars base64]` });
817
+ logger?.debug(`mcp bridge: image block collapsed to text mention (${block.mimeType})`);
818
+ } else if (block.type === "resource") {
819
+ blocks.push({ kind: "text", text: `[resource ${block.resource.uri}]` });
820
+ } else {
821
+ blocks.push({ kind: "text", text: "[unknown content block]" });
822
+ }
823
+ }
824
+ }
825
+ if (result.structuredContent !== void 0) {
826
+ blocks.push({ kind: "json", value: result.structuredContent });
827
+ }
828
+ const content = blocks.length > 0 ? blocks : [{ kind: "text", text: "(no content)" }];
829
+ return {
830
+ content,
831
+ ...result.isError === true ? { isError: true } : {}
832
+ };
833
+ }
834
+ function makeRunner(client, remoteName, logger) {
835
+ return async (input, ctx) => {
836
+ if (ctx.signal.aborted) {
837
+ return {
838
+ content: [{ kind: "text", text: "Cancelled before tool could start." }],
839
+ isError: true
840
+ };
841
+ }
842
+ try {
843
+ const args = input ?? {};
844
+ const result = await client.callTool(remoteName, args);
845
+ return projectMcpResult(result, logger);
846
+ } catch (err) {
847
+ const wrapped = err instanceof MCPError ? err : createServerError(describeThrow2(err), client.serverName);
848
+ logger?.error(`mcp bridge: tool "${remoteName}" failed: ${wrapped.message}`, wrapped);
849
+ return {
850
+ content: [{ kind: "text", text: `MCP tool failed: ${wrapped.message}` }],
851
+ isError: true
852
+ };
853
+ }
854
+ };
855
+ }
856
+ async function mcpClientToToolBox(client, options = {}) {
857
+ const prefix = options.namePrefix ?? "mcp";
858
+ const logger = options.logger;
859
+ const tools = await client.listTools();
860
+ const filtered = typeof options.filter === "function" ? tools.filter((t) => options.filter(t)) : tools;
861
+ const byName = /* @__PURE__ */ new Map();
862
+ for (const tool of filtered) {
863
+ const remoteName = tool.name;
864
+ const prefixed = `${prefix}__${remoteName}`;
865
+ const description = tool.description && tool.description.length > 0 ? tool.description : `<tool "${remoteName}" from MCP server "${client.serverName}">`;
866
+ const parameters = tool.inputSchema;
867
+ const def = defineTool({
868
+ name: prefixed,
869
+ description,
870
+ parameters,
871
+ run: makeRunner(client, remoteName, logger)
872
+ });
873
+ byName.set(prefixed, def);
874
+ }
875
+ const runner = {
876
+ async run(call, signal) {
877
+ const def = byName.get(call.name);
878
+ if (!def) {
879
+ return {
880
+ id: call.id,
881
+ output: `No tool "${call.name}" on MCP server "${client.serverName}".`,
882
+ isError: true
883
+ };
884
+ }
885
+ return def.invoke(call, makeToolContext(signal));
886
+ }
887
+ };
888
+ return {
889
+ descriptors() {
890
+ return Array.from(byName.values()).map((d) => d.descriptor());
891
+ },
892
+ runner
893
+ };
894
+ }
895
+
896
+ // src/connectors-sarvam/connect.ts
897
+ function resolveHome(p) {
898
+ if (!p.startsWith("~")) return p;
899
+ const home = process.env.HOME ?? process.env.USERPROFILE ?? "";
900
+ return home.length > 0 ? p.replace(/^~/, home) : p;
901
+ }
902
+ async function connectSarvamMcp(options) {
903
+ const id = options.id ?? "sarvam";
904
+ const apiKey = (options.apiKey?.trim() || process.env.SARVAM_API_KEY?.trim() || "").trim();
905
+ if (!apiKey) {
906
+ throw new Error(
907
+ "connectSarvamMcp: SARVAM_API_KEY missing (pass apiKey or set the env var)."
908
+ );
909
+ }
910
+ const baseUrl = options.baseUrl ?? process.env.SARVAM_API_BASE_URL ?? "https://api.sarvam.ai";
911
+ const basePath = resolveHome(options.basePath ?? process.env.SARVAM_MCP_BASE_PATH ?? "~/Desktop");
912
+ const command = options.command ?? "uvx";
913
+ const args = [...options.args ?? ["sarvam-mcp"]];
914
+ const env = {
915
+ ...options.env ? { ...options.env } : {},
916
+ SARVAM_API_KEY: apiKey,
917
+ SARVAM_API_BASE_URL: baseUrl,
918
+ SARVAM_MCP_BASE_PATH: basePath
919
+ };
920
+ const client = new MCPClient({
921
+ name: id,
922
+ config: { command, args, env },
923
+ timeout: options.timeoutMs ?? 6e4
924
+ });
925
+ await client.connect();
926
+ const toolBox = await mcpClientToToolBox(client, {
927
+ namePrefix: id,
928
+ logger: options.logger
929
+ });
930
+ const tools = await client.listTools();
931
+ const prefixed = tools.map((t) => `${id}__${t.name}`);
932
+ let closed = false;
933
+ return {
934
+ id,
935
+ toolBox,
936
+ toolNames: prefixed,
937
+ client,
938
+ async close() {
939
+ if (closed) return;
940
+ closed = true;
941
+ try {
942
+ await client.disconnect();
943
+ } catch (e) {
944
+ options.logger?.error(`sarvam close failed: ${e.message}`, e);
945
+ }
946
+ }
947
+ };
948
+ }
949
+
950
+ // src/connectors-sarvam/toolbox.ts
951
+ async function sarvamToolBoxFromClient(client, options) {
952
+ return mcpClientToToolBox(client, {
953
+ ...options,
954
+ namePrefix: options?.id ?? "sarvam"
955
+ });
956
+ }
957
+ export {
958
+ connectSarvamMcp,
959
+ sarvamToolBoxFromClient
960
+ };