@shuyhere/takotako 0.0.1

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 (653) hide show
  1. package/CONTRIBUTING.md +84 -0
  2. package/LICENSE +21 -0
  3. package/README.md +171 -0
  4. package/dist/agents/communication.d.ts +48 -0
  5. package/dist/agents/communication.d.ts.map +1 -0
  6. package/dist/agents/communication.js +123 -0
  7. package/dist/agents/communication.js.map +1 -0
  8. package/dist/agents/config.d.ts +52 -0
  9. package/dist/agents/config.d.ts.map +1 -0
  10. package/dist/agents/config.js +65 -0
  11. package/dist/agents/config.js.map +1 -0
  12. package/dist/agents/model-catalog.d.ts +49 -0
  13. package/dist/agents/model-catalog.d.ts.map +1 -0
  14. package/dist/agents/model-catalog.js +79 -0
  15. package/dist/agents/model-catalog.js.map +1 -0
  16. package/dist/agents/registry.d.ts +71 -0
  17. package/dist/agents/registry.d.ts.map +1 -0
  18. package/dist/agents/registry.js +297 -0
  19. package/dist/agents/registry.js.map +1 -0
  20. package/dist/agents/roles.d.ts +79 -0
  21. package/dist/agents/roles.d.ts.map +1 -0
  22. package/dist/agents/roles.js +174 -0
  23. package/dist/agents/roles.js.map +1 -0
  24. package/dist/agents/subagent.d.ts +124 -0
  25. package/dist/agents/subagent.d.ts.map +1 -0
  26. package/dist/agents/subagent.js +352 -0
  27. package/dist/agents/subagent.js.map +1 -0
  28. package/dist/agents/templates.d.ts +18 -0
  29. package/dist/agents/templates.d.ts.map +1 -0
  30. package/dist/agents/templates.js +341 -0
  31. package/dist/agents/templates.js.map +1 -0
  32. package/dist/agents/thread-binding.d.ts +77 -0
  33. package/dist/agents/thread-binding.d.ts.map +1 -0
  34. package/dist/agents/thread-binding.js +167 -0
  35. package/dist/agents/thread-binding.js.map +1 -0
  36. package/dist/auth/agent-profiles.d.ts +46 -0
  37. package/dist/auth/agent-profiles.d.ts.map +1 -0
  38. package/dist/auth/agent-profiles.js +97 -0
  39. package/dist/auth/agent-profiles.js.map +1 -0
  40. package/dist/auth/allow-from.d.ts +27 -0
  41. package/dist/auth/allow-from.d.ts.map +1 -0
  42. package/dist/auth/allow-from.js +118 -0
  43. package/dist/auth/allow-from.js.map +1 -0
  44. package/dist/auth/oauth.d.ts +66 -0
  45. package/dist/auth/oauth.d.ts.map +1 -0
  46. package/dist/auth/oauth.js +253 -0
  47. package/dist/auth/oauth.js.map +1 -0
  48. package/dist/auth/storage.d.ts +69 -0
  49. package/dist/auth/storage.d.ts.map +1 -0
  50. package/dist/auth/storage.js +157 -0
  51. package/dist/auth/storage.js.map +1 -0
  52. package/dist/cache/file-cache.d.ts +68 -0
  53. package/dist/cache/file-cache.d.ts.map +1 -0
  54. package/dist/cache/file-cache.js +176 -0
  55. package/dist/cache/file-cache.js.map +1 -0
  56. package/dist/cache/manager.d.ts +69 -0
  57. package/dist/cache/manager.d.ts.map +1 -0
  58. package/dist/cache/manager.js +117 -0
  59. package/dist/cache/manager.js.map +1 -0
  60. package/dist/cache/symbol-index.d.ts +75 -0
  61. package/dist/cache/symbol-index.d.ts.map +1 -0
  62. package/dist/cache/symbol-index.js +267 -0
  63. package/dist/cache/symbol-index.js.map +1 -0
  64. package/dist/cache/tool-cache.d.ts +75 -0
  65. package/dist/cache/tool-cache.d.ts.map +1 -0
  66. package/dist/cache/tool-cache.js +173 -0
  67. package/dist/cache/tool-cache.js.map +1 -0
  68. package/dist/channels/channel.d.ts +156 -0
  69. package/dist/channels/channel.d.ts.map +1 -0
  70. package/dist/channels/channel.js +25 -0
  71. package/dist/channels/channel.js.map +1 -0
  72. package/dist/channels/cli.d.ts +35 -0
  73. package/dist/channels/cli.d.ts.map +1 -0
  74. package/dist/channels/cli.js +94 -0
  75. package/dist/channels/cli.js.map +1 -0
  76. package/dist/channels/delivery-queue.d.ts +31 -0
  77. package/dist/channels/delivery-queue.d.ts.map +1 -0
  78. package/dist/channels/delivery-queue.js +127 -0
  79. package/dist/channels/delivery-queue.js.map +1 -0
  80. package/dist/channels/discord.d.ts +124 -0
  81. package/dist/channels/discord.d.ts.map +1 -0
  82. package/dist/channels/discord.js +664 -0
  83. package/dist/channels/discord.js.map +1 -0
  84. package/dist/channels/retry.d.ts +31 -0
  85. package/dist/channels/retry.d.ts.map +1 -0
  86. package/dist/channels/retry.js +94 -0
  87. package/dist/channels/retry.js.map +1 -0
  88. package/dist/channels/telegram.d.ts +69 -0
  89. package/dist/channels/telegram.d.ts.map +1 -0
  90. package/dist/channels/telegram.js +499 -0
  91. package/dist/channels/telegram.js.map +1 -0
  92. package/dist/channels/tui.d.ts +42 -0
  93. package/dist/channels/tui.d.ts.map +1 -0
  94. package/dist/channels/tui.js +126 -0
  95. package/dist/channels/tui.js.map +1 -0
  96. package/dist/cli/acp.d.ts +10 -0
  97. package/dist/cli/acp.d.ts.map +1 -0
  98. package/dist/cli/acp.js +69 -0
  99. package/dist/cli/acp.js.map +1 -0
  100. package/dist/cli/audit.d.ts +11 -0
  101. package/dist/cli/audit.d.ts.map +1 -0
  102. package/dist/cli/audit.js +55 -0
  103. package/dist/cli/audit.js.map +1 -0
  104. package/dist/cli/cache.d.ts +10 -0
  105. package/dist/cli/cache.d.ts.map +1 -0
  106. package/dist/cli/cache.js +77 -0
  107. package/dist/cli/cache.js.map +1 -0
  108. package/dist/cli/config.d.ts +5 -0
  109. package/dist/cli/config.d.ts.map +1 -0
  110. package/dist/cli/config.js +168 -0
  111. package/dist/cli/config.js.map +1 -0
  112. package/dist/cli/cron.d.ts +5 -0
  113. package/dist/cli/cron.d.ts.map +1 -0
  114. package/dist/cli/cron.js +192 -0
  115. package/dist/cli/cron.js.map +1 -0
  116. package/dist/cli/extensions.d.ts +5 -0
  117. package/dist/cli/extensions.d.ts.map +1 -0
  118. package/dist/cli/extensions.js +53 -0
  119. package/dist/cli/extensions.js.map +1 -0
  120. package/dist/cli/logs.d.ts +5 -0
  121. package/dist/cli/logs.d.ts.map +1 -0
  122. package/dist/cli/logs.js +49 -0
  123. package/dist/cli/logs.js.map +1 -0
  124. package/dist/cli/memory.d.ts +5 -0
  125. package/dist/cli/memory.d.ts.map +1 -0
  126. package/dist/cli/memory.js +78 -0
  127. package/dist/cli/memory.js.map +1 -0
  128. package/dist/cli/message.d.ts +5 -0
  129. package/dist/cli/message.d.ts.map +1 -0
  130. package/dist/cli/message.js +69 -0
  131. package/dist/cli/message.js.map +1 -0
  132. package/dist/cli/service.d.ts +14 -0
  133. package/dist/cli/service.d.ts.map +1 -0
  134. package/dist/cli/service.js +181 -0
  135. package/dist/cli/service.js.map +1 -0
  136. package/dist/cli/symphony.d.ts +5 -0
  137. package/dist/cli/symphony.d.ts.map +1 -0
  138. package/dist/cli/symphony.js +114 -0
  139. package/dist/cli/symphony.js.map +1 -0
  140. package/dist/cli/update.d.ts +5 -0
  141. package/dist/cli/update.d.ts.map +1 -0
  142. package/dist/cli/update.js +48 -0
  143. package/dist/cli/update.js.map +1 -0
  144. package/dist/commands/channel-setup.d.ts +31 -0
  145. package/dist/commands/channel-setup.d.ts.map +1 -0
  146. package/dist/commands/channel-setup.js +138 -0
  147. package/dist/commands/channel-setup.js.map +1 -0
  148. package/dist/commands/dispatch.d.ts +48 -0
  149. package/dist/commands/dispatch.d.ts.map +1 -0
  150. package/dist/commands/dispatch.js +68 -0
  151. package/dist/commands/dispatch.js.map +1 -0
  152. package/dist/commands/model-picker.d.ts +16 -0
  153. package/dist/commands/model-picker.d.ts.map +1 -0
  154. package/dist/commands/model-picker.js +120 -0
  155. package/dist/commands/model-picker.js.map +1 -0
  156. package/dist/commands/parser.d.ts +32 -0
  157. package/dist/commands/parser.d.ts.map +1 -0
  158. package/dist/commands/parser.js +39 -0
  159. package/dist/commands/parser.js.map +1 -0
  160. package/dist/commands/registry.d.ts +76 -0
  161. package/dist/commands/registry.d.ts.map +1 -0
  162. package/dist/commands/registry.js +351 -0
  163. package/dist/commands/registry.js.map +1 -0
  164. package/dist/commands/skill-commands.d.ts +35 -0
  165. package/dist/commands/skill-commands.d.ts.map +1 -0
  166. package/dist/commands/skill-commands.js +61 -0
  167. package/dist/commands/skill-commands.js.map +1 -0
  168. package/dist/config/resolve.d.ts +25 -0
  169. package/dist/config/resolve.d.ts.map +1 -0
  170. package/dist/config/resolve.js +289 -0
  171. package/dist/config/resolve.js.map +1 -0
  172. package/dist/config/schema.d.ts +520 -0
  173. package/dist/config/schema.d.ts.map +1 -0
  174. package/dist/config/schema.js +123 -0
  175. package/dist/config/schema.js.map +1 -0
  176. package/dist/core/agent-loop.d.ts +137 -0
  177. package/dist/core/agent-loop.d.ts.map +1 -0
  178. package/dist/core/agent-loop.js +700 -0
  179. package/dist/core/agent-loop.js.map +1 -0
  180. package/dist/core/audit.d.ts +87 -0
  181. package/dist/core/audit.d.ts.map +1 -0
  182. package/dist/core/audit.js +224 -0
  183. package/dist/core/audit.js.map +1 -0
  184. package/dist/core/bootstrap.d.ts +23 -0
  185. package/dist/core/bootstrap.d.ts.map +1 -0
  186. package/dist/core/bootstrap.js +162 -0
  187. package/dist/core/bootstrap.js.map +1 -0
  188. package/dist/core/context.d.ts +44 -0
  189. package/dist/core/context.d.ts.map +1 -0
  190. package/dist/core/context.js +65 -0
  191. package/dist/core/context.js.map +1 -0
  192. package/dist/core/cron.d.ts +111 -0
  193. package/dist/core/cron.d.ts.map +1 -0
  194. package/dist/core/cron.js +284 -0
  195. package/dist/core/cron.js.map +1 -0
  196. package/dist/core/exec-approvals.d.ts +50 -0
  197. package/dist/core/exec-approvals.d.ts.map +1 -0
  198. package/dist/core/exec-approvals.js +187 -0
  199. package/dist/core/exec-approvals.js.map +1 -0
  200. package/dist/core/heartbeat.d.ts +71 -0
  201. package/dist/core/heartbeat.d.ts.map +1 -0
  202. package/dist/core/heartbeat.js +214 -0
  203. package/dist/core/heartbeat.js.map +1 -0
  204. package/dist/core/message-queue.d.ts +60 -0
  205. package/dist/core/message-queue.d.ts.map +1 -0
  206. package/dist/core/message-queue.js +182 -0
  207. package/dist/core/message-queue.js.map +1 -0
  208. package/dist/core/network-policy.d.ts +39 -0
  209. package/dist/core/network-policy.d.ts.map +1 -0
  210. package/dist/core/network-policy.js +121 -0
  211. package/dist/core/network-policy.js.map +1 -0
  212. package/dist/core/progress.d.ts +48 -0
  213. package/dist/core/progress.d.ts.map +1 -0
  214. package/dist/core/progress.js +81 -0
  215. package/dist/core/progress.js.map +1 -0
  216. package/dist/core/prompt.d.ts +105 -0
  217. package/dist/core/prompt.d.ts.map +1 -0
  218. package/dist/core/prompt.js +411 -0
  219. package/dist/core/prompt.js.map +1 -0
  220. package/dist/core/pruning.d.ts +40 -0
  221. package/dist/core/pruning.d.ts.map +1 -0
  222. package/dist/core/pruning.js +165 -0
  223. package/dist/core/pruning.js.map +1 -0
  224. package/dist/core/rate-limiter.d.ts +64 -0
  225. package/dist/core/rate-limiter.d.ts.map +1 -0
  226. package/dist/core/rate-limiter.js +142 -0
  227. package/dist/core/rate-limiter.js.map +1 -0
  228. package/dist/core/reactions.d.ts +31 -0
  229. package/dist/core/reactions.d.ts.map +1 -0
  230. package/dist/core/reactions.js +67 -0
  231. package/dist/core/reactions.js.map +1 -0
  232. package/dist/core/retry-queue.d.ts +56 -0
  233. package/dist/core/retry-queue.d.ts.map +1 -0
  234. package/dist/core/retry-queue.js +106 -0
  235. package/dist/core/retry-queue.js.map +1 -0
  236. package/dist/core/sanitizer.d.ts +38 -0
  237. package/dist/core/sanitizer.d.ts.map +1 -0
  238. package/dist/core/sanitizer.js +181 -0
  239. package/dist/core/sanitizer.js.map +1 -0
  240. package/dist/core/secret-scanner.d.ts +39 -0
  241. package/dist/core/secret-scanner.d.ts.map +1 -0
  242. package/dist/core/secret-scanner.js +96 -0
  243. package/dist/core/secret-scanner.js.map +1 -0
  244. package/dist/core/secrets.d.ts +38 -0
  245. package/dist/core/secrets.d.ts.map +1 -0
  246. package/dist/core/secrets.js +137 -0
  247. package/dist/core/secrets.js.map +1 -0
  248. package/dist/core/security.d.ts +58 -0
  249. package/dist/core/security.d.ts.map +1 -0
  250. package/dist/core/security.js +120 -0
  251. package/dist/core/security.js.map +1 -0
  252. package/dist/core/self-awareness.d.ts +19 -0
  253. package/dist/core/self-awareness.d.ts.map +1 -0
  254. package/dist/core/self-awareness.js +124 -0
  255. package/dist/core/self-awareness.js.map +1 -0
  256. package/dist/core/session-init.d.ts +34 -0
  257. package/dist/core/session-init.d.ts.map +1 -0
  258. package/dist/core/session-init.js +68 -0
  259. package/dist/core/session-init.js.map +1 -0
  260. package/dist/core/streaming.d.ts +82 -0
  261. package/dist/core/streaming.d.ts.map +1 -0
  262. package/dist/core/streaming.js +264 -0
  263. package/dist/core/streaming.js.map +1 -0
  264. package/dist/core/symphony/orchestrator.d.ts +61 -0
  265. package/dist/core/symphony/orchestrator.d.ts.map +1 -0
  266. package/dist/core/symphony/orchestrator.js +476 -0
  267. package/dist/core/symphony/orchestrator.js.map +1 -0
  268. package/dist/core/symphony/status.d.ts +11 -0
  269. package/dist/core/symphony/status.d.ts.map +1 -0
  270. package/dist/core/symphony/status.js +133 -0
  271. package/dist/core/symphony/status.js.map +1 -0
  272. package/dist/core/symphony/types.d.ts +84 -0
  273. package/dist/core/symphony/types.d.ts.map +1 -0
  274. package/dist/core/symphony/types.js +5 -0
  275. package/dist/core/symphony/types.js.map +1 -0
  276. package/dist/core/symphony/workflow.d.ts +18 -0
  277. package/dist/core/symphony/workflow.d.ts.map +1 -0
  278. package/dist/core/symphony/workflow.js +149 -0
  279. package/dist/core/symphony/workflow.js.map +1 -0
  280. package/dist/core/symphony/workspace.d.ts +24 -0
  281. package/dist/core/symphony/workspace.d.ts.map +1 -0
  282. package/dist/core/symphony/workspace.js +94 -0
  283. package/dist/core/symphony/workspace.js.map +1 -0
  284. package/dist/core/thinking.d.ts +27 -0
  285. package/dist/core/thinking.d.ts.map +1 -0
  286. package/dist/core/thinking.js +83 -0
  287. package/dist/core/thinking.js.map +1 -0
  288. package/dist/core/thread-bindings.d.ts +47 -0
  289. package/dist/core/thread-bindings.d.ts.map +1 -0
  290. package/dist/core/thread-bindings.js +94 -0
  291. package/dist/core/thread-bindings.js.map +1 -0
  292. package/dist/core/timezone.d.ts +28 -0
  293. package/dist/core/timezone.d.ts.map +1 -0
  294. package/dist/core/timezone.js +72 -0
  295. package/dist/core/timezone.js.map +1 -0
  296. package/dist/core/tool-loop-detector.d.ts +41 -0
  297. package/dist/core/tool-loop-detector.d.ts.map +1 -0
  298. package/dist/core/tool-loop-detector.js +83 -0
  299. package/dist/core/tool-loop-detector.js.map +1 -0
  300. package/dist/core/tool-validator.d.ts +44 -0
  301. package/dist/core/tool-validator.d.ts.map +1 -0
  302. package/dist/core/tool-validator.js +175 -0
  303. package/dist/core/tool-validator.js.map +1 -0
  304. package/dist/core/typing.d.ts +25 -0
  305. package/dist/core/typing.d.ts.map +1 -0
  306. package/dist/core/typing.js +48 -0
  307. package/dist/core/typing.js.map +1 -0
  308. package/dist/core/usage-tracker.d.ts +66 -0
  309. package/dist/core/usage-tracker.d.ts.map +1 -0
  310. package/dist/core/usage-tracker.js +163 -0
  311. package/dist/core/usage-tracker.js.map +1 -0
  312. package/dist/daemon/commands.d.ts +16 -0
  313. package/dist/daemon/commands.d.ts.map +1 -0
  314. package/dist/daemon/commands.js +445 -0
  315. package/dist/daemon/commands.js.map +1 -0
  316. package/dist/daemon/pid.d.ts +30 -0
  317. package/dist/daemon/pid.d.ts.map +1 -0
  318. package/dist/daemon/pid.js +62 -0
  319. package/dist/daemon/pid.js.map +1 -0
  320. package/dist/doctor/checks/browser.d.ts +9 -0
  321. package/dist/doctor/checks/browser.d.ts.map +1 -0
  322. package/dist/doctor/checks/browser.js +54 -0
  323. package/dist/doctor/checks/browser.js.map +1 -0
  324. package/dist/doctor/checks/channels.d.ts +9 -0
  325. package/dist/doctor/checks/channels.d.ts.map +1 -0
  326. package/dist/doctor/checks/channels.js +90 -0
  327. package/dist/doctor/checks/channels.js.map +1 -0
  328. package/dist/doctor/checks/config.d.ts +10 -0
  329. package/dist/doctor/checks/config.d.ts.map +1 -0
  330. package/dist/doctor/checks/config.js +89 -0
  331. package/dist/doctor/checks/config.js.map +1 -0
  332. package/dist/doctor/checks/memory.d.ts +10 -0
  333. package/dist/doctor/checks/memory.d.ts.map +1 -0
  334. package/dist/doctor/checks/memory.js +82 -0
  335. package/dist/doctor/checks/memory.js.map +1 -0
  336. package/dist/doctor/checks/permissions.d.ts +9 -0
  337. package/dist/doctor/checks/permissions.d.ts.map +1 -0
  338. package/dist/doctor/checks/permissions.js +53 -0
  339. package/dist/doctor/checks/permissions.js.map +1 -0
  340. package/dist/doctor/checks/providers.d.ts +10 -0
  341. package/dist/doctor/checks/providers.d.ts.map +1 -0
  342. package/dist/doctor/checks/providers.js +93 -0
  343. package/dist/doctor/checks/providers.js.map +1 -0
  344. package/dist/doctor/checks/sessions.d.ts +10 -0
  345. package/dist/doctor/checks/sessions.d.ts.map +1 -0
  346. package/dist/doctor/checks/sessions.js +86 -0
  347. package/dist/doctor/checks/sessions.js.map +1 -0
  348. package/dist/doctor/doctor.d.ts +35 -0
  349. package/dist/doctor/doctor.d.ts.map +1 -0
  350. package/dist/doctor/doctor.js +51 -0
  351. package/dist/doctor/doctor.js.map +1 -0
  352. package/dist/doctor/repairs.d.ts +14 -0
  353. package/dist/doctor/repairs.d.ts.map +1 -0
  354. package/dist/doctor/repairs.js +34 -0
  355. package/dist/doctor/repairs.js.map +1 -0
  356. package/dist/gateway/compaction.d.ts +63 -0
  357. package/dist/gateway/compaction.d.ts.map +1 -0
  358. package/dist/gateway/compaction.js +235 -0
  359. package/dist/gateway/compaction.js.map +1 -0
  360. package/dist/gateway/gateway.d.ts +94 -0
  361. package/dist/gateway/gateway.d.ts.map +1 -0
  362. package/dist/gateway/gateway.js +466 -0
  363. package/dist/gateway/gateway.js.map +1 -0
  364. package/dist/gateway/lock.d.ts +24 -0
  365. package/dist/gateway/lock.d.ts.map +1 -0
  366. package/dist/gateway/lock.js +88 -0
  367. package/dist/gateway/lock.js.map +1 -0
  368. package/dist/gateway/protocol.d.ts +117 -0
  369. package/dist/gateway/protocol.d.ts.map +1 -0
  370. package/dist/gateway/protocol.js +5 -0
  371. package/dist/gateway/protocol.js.map +1 -0
  372. package/dist/gateway/session.d.ts +123 -0
  373. package/dist/gateway/session.d.ts.map +1 -0
  374. package/dist/gateway/session.js +573 -0
  375. package/dist/gateway/session.js.map +1 -0
  376. package/dist/hooks/hooks.d.ts +18 -0
  377. package/dist/hooks/hooks.d.ts.map +1 -0
  378. package/dist/hooks/hooks.js +45 -0
  379. package/dist/hooks/hooks.js.map +1 -0
  380. package/dist/hooks/types.d.ts +112 -0
  381. package/dist/hooks/types.d.ts.map +1 -0
  382. package/dist/hooks/types.js +23 -0
  383. package/dist/hooks/types.js.map +1 -0
  384. package/dist/index.d.ts +27 -0
  385. package/dist/index.d.ts.map +1 -0
  386. package/dist/index.js +2900 -0
  387. package/dist/index.js.map +1 -0
  388. package/dist/media/storage.d.ts +25 -0
  389. package/dist/media/storage.d.ts.map +1 -0
  390. package/dist/media/storage.js +97 -0
  391. package/dist/media/storage.js.map +1 -0
  392. package/dist/memory/embeddings.d.ts +46 -0
  393. package/dist/memory/embeddings.d.ts.map +1 -0
  394. package/dist/memory/embeddings.js +118 -0
  395. package/dist/memory/embeddings.js.map +1 -0
  396. package/dist/memory/hybrid.d.ts +35 -0
  397. package/dist/memory/hybrid.d.ts.map +1 -0
  398. package/dist/memory/hybrid.js +156 -0
  399. package/dist/memory/hybrid.js.map +1 -0
  400. package/dist/memory/markdown.d.ts +48 -0
  401. package/dist/memory/markdown.d.ts.map +1 -0
  402. package/dist/memory/markdown.js +228 -0
  403. package/dist/memory/markdown.js.map +1 -0
  404. package/dist/memory/store.d.ts +88 -0
  405. package/dist/memory/store.d.ts.map +1 -0
  406. package/dist/memory/store.js +21 -0
  407. package/dist/memory/store.js.map +1 -0
  408. package/dist/memory/vector.d.ts +24 -0
  409. package/dist/memory/vector.d.ts.map +1 -0
  410. package/dist/memory/vector.js +63 -0
  411. package/dist/memory/vector.js.map +1 -0
  412. package/dist/mods/mod.d.ts +100 -0
  413. package/dist/mods/mod.d.ts.map +1 -0
  414. package/dist/mods/mod.js +242 -0
  415. package/dist/mods/mod.js.map +1 -0
  416. package/dist/onboard/channels.d.ts +12 -0
  417. package/dist/onboard/channels.d.ts.map +1 -0
  418. package/dist/onboard/channels.js +283 -0
  419. package/dist/onboard/channels.js.map +1 -0
  420. package/dist/onboard/models.d.ts +13 -0
  421. package/dist/onboard/models.d.ts.map +1 -0
  422. package/dist/onboard/models.js +491 -0
  423. package/dist/onboard/models.js.map +1 -0
  424. package/dist/onboard/onboard.d.ts +12 -0
  425. package/dist/onboard/onboard.d.ts.map +1 -0
  426. package/dist/onboard/onboard.js +1137 -0
  427. package/dist/onboard/onboard.js.map +1 -0
  428. package/dist/providers/anthropic.d.ts +83 -0
  429. package/dist/providers/anthropic.d.ts.map +1 -0
  430. package/dist/providers/anthropic.js +583 -0
  431. package/dist/providers/anthropic.js.map +1 -0
  432. package/dist/providers/failover.d.ts +46 -0
  433. package/dist/providers/failover.d.ts.map +1 -0
  434. package/dist/providers/failover.js +149 -0
  435. package/dist/providers/failover.js.map +1 -0
  436. package/dist/providers/litellm.d.ts +38 -0
  437. package/dist/providers/litellm.d.ts.map +1 -0
  438. package/dist/providers/litellm.js +349 -0
  439. package/dist/providers/litellm.js.map +1 -0
  440. package/dist/providers/openai.d.ts +28 -0
  441. package/dist/providers/openai.d.ts.map +1 -0
  442. package/dist/providers/openai.js +321 -0
  443. package/dist/providers/openai.js.map +1 -0
  444. package/dist/providers/prompt-cache.d.ts +50 -0
  445. package/dist/providers/prompt-cache.d.ts.map +1 -0
  446. package/dist/providers/prompt-cache.js +96 -0
  447. package/dist/providers/prompt-cache.js.map +1 -0
  448. package/dist/providers/provider.d.ts +173 -0
  449. package/dist/providers/provider.d.ts.map +1 -0
  450. package/dist/providers/provider.js +22 -0
  451. package/dist/providers/provider.js.map +1 -0
  452. package/dist/sandbox/config.d.ts +42 -0
  453. package/dist/sandbox/config.d.ts.map +1 -0
  454. package/dist/sandbox/config.js +20 -0
  455. package/dist/sandbox/config.js.map +1 -0
  456. package/dist/sandbox/container.d.ts +71 -0
  457. package/dist/sandbox/container.d.ts.map +1 -0
  458. package/dist/sandbox/container.js +193 -0
  459. package/dist/sandbox/container.js.map +1 -0
  460. package/dist/sandbox/sandbox.d.ts +82 -0
  461. package/dist/sandbox/sandbox.d.ts.map +1 -0
  462. package/dist/sandbox/sandbox.js +176 -0
  463. package/dist/sandbox/sandbox.js.map +1 -0
  464. package/dist/skills/channel-loader.d.ts +18 -0
  465. package/dist/skills/channel-loader.d.ts.map +1 -0
  466. package/dist/skills/channel-loader.js +35 -0
  467. package/dist/skills/channel-loader.js.map +1 -0
  468. package/dist/skills/extension-loader.d.ts +15 -0
  469. package/dist/skills/extension-loader.d.ts.map +1 -0
  470. package/dist/skills/extension-loader.js +63 -0
  471. package/dist/skills/extension-loader.js.map +1 -0
  472. package/dist/skills/extension-registry.d.ts +32 -0
  473. package/dist/skills/extension-registry.d.ts.map +1 -0
  474. package/dist/skills/extension-registry.js +57 -0
  475. package/dist/skills/extension-registry.js.map +1 -0
  476. package/dist/skills/extensions.d.ts +91 -0
  477. package/dist/skills/extensions.d.ts.map +1 -0
  478. package/dist/skills/extensions.js +14 -0
  479. package/dist/skills/extensions.js.map +1 -0
  480. package/dist/skills/loader.d.ts +64 -0
  481. package/dist/skills/loader.d.ts.map +1 -0
  482. package/dist/skills/loader.js +382 -0
  483. package/dist/skills/loader.js.map +1 -0
  484. package/dist/skills/marketplace.d.ts +56 -0
  485. package/dist/skills/marketplace.d.ts.map +1 -0
  486. package/dist/skills/marketplace.js +183 -0
  487. package/dist/skills/marketplace.js.map +1 -0
  488. package/dist/skills/types.d.ts +94 -0
  489. package/dist/skills/types.d.ts.map +1 -0
  490. package/dist/skills/types.js +9 -0
  491. package/dist/skills/types.js.map +1 -0
  492. package/dist/tools/acp-sessions.d.ts +89 -0
  493. package/dist/tools/acp-sessions.d.ts.map +1 -0
  494. package/dist/tools/acp-sessions.js +391 -0
  495. package/dist/tools/acp-sessions.js.map +1 -0
  496. package/dist/tools/acp.d.ts +18 -0
  497. package/dist/tools/acp.d.ts.map +1 -0
  498. package/dist/tools/acp.js +102 -0
  499. package/dist/tools/acp.js.map +1 -0
  500. package/dist/tools/agent-tools.d.ts +24 -0
  501. package/dist/tools/agent-tools.d.ts.map +1 -0
  502. package/dist/tools/agent-tools.js +611 -0
  503. package/dist/tools/agent-tools.js.map +1 -0
  504. package/dist/tools/browser.d.ts +26 -0
  505. package/dist/tools/browser.d.ts.map +1 -0
  506. package/dist/tools/browser.js +242 -0
  507. package/dist/tools/browser.js.map +1 -0
  508. package/dist/tools/comms.d.ts +8 -0
  509. package/dist/tools/comms.d.ts.map +1 -0
  510. package/dist/tools/comms.js +39 -0
  511. package/dist/tools/comms.js.map +1 -0
  512. package/dist/tools/cron-tools.d.ts +9 -0
  513. package/dist/tools/cron-tools.d.ts.map +1 -0
  514. package/dist/tools/cron-tools.js +117 -0
  515. package/dist/tools/cron-tools.js.map +1 -0
  516. package/dist/tools/exec-safety.d.ts +71 -0
  517. package/dist/tools/exec-safety.d.ts.map +1 -0
  518. package/dist/tools/exec-safety.js +141 -0
  519. package/dist/tools/exec-safety.js.map +1 -0
  520. package/dist/tools/exec.d.ts +24 -0
  521. package/dist/tools/exec.d.ts.map +1 -0
  522. package/dist/tools/exec.js +191 -0
  523. package/dist/tools/exec.js.map +1 -0
  524. package/dist/tools/fs.d.ts +15 -0
  525. package/dist/tools/fs.d.ts.map +1 -0
  526. package/dist/tools/fs.js +249 -0
  527. package/dist/tools/fs.js.map +1 -0
  528. package/dist/tools/git.d.ts +9 -0
  529. package/dist/tools/git.d.ts.map +1 -0
  530. package/dist/tools/git.js +56 -0
  531. package/dist/tools/git.js.map +1 -0
  532. package/dist/tools/image.d.ts +15 -0
  533. package/dist/tools/image.d.ts.map +1 -0
  534. package/dist/tools/image.js +106 -0
  535. package/dist/tools/image.js.map +1 -0
  536. package/dist/tools/introspect.d.ts +22 -0
  537. package/dist/tools/introspect.d.ts.map +1 -0
  538. package/dist/tools/introspect.js +223 -0
  539. package/dist/tools/introspect.js.map +1 -0
  540. package/dist/tools/memory.d.ts +11 -0
  541. package/dist/tools/memory.d.ts.map +1 -0
  542. package/dist/tools/memory.js +101 -0
  543. package/dist/tools/memory.js.map +1 -0
  544. package/dist/tools/message.d.ts +24 -0
  545. package/dist/tools/message.d.ts.map +1 -0
  546. package/dist/tools/message.js +205 -0
  547. package/dist/tools/message.js.map +1 -0
  548. package/dist/tools/model.d.ts +14 -0
  549. package/dist/tools/model.d.ts.map +1 -0
  550. package/dist/tools/model.js +62 -0
  551. package/dist/tools/model.js.map +1 -0
  552. package/dist/tools/policy.d.ts +101 -0
  553. package/dist/tools/policy.d.ts.map +1 -0
  554. package/dist/tools/policy.js +168 -0
  555. package/dist/tools/policy.js.map +1 -0
  556. package/dist/tools/registry.d.ts +52 -0
  557. package/dist/tools/registry.d.ts.map +1 -0
  558. package/dist/tools/registry.js +154 -0
  559. package/dist/tools/registry.js.map +1 -0
  560. package/dist/tools/search.d.ts +10 -0
  561. package/dist/tools/search.d.ts.map +1 -0
  562. package/dist/tools/search.js +78 -0
  563. package/dist/tools/search.js.map +1 -0
  564. package/dist/tools/session.d.ts +13 -0
  565. package/dist/tools/session.d.ts.map +1 -0
  566. package/dist/tools/session.js +142 -0
  567. package/dist/tools/session.js.map +1 -0
  568. package/dist/tools/spawn.d.ts +10 -0
  569. package/dist/tools/spawn.d.ts.map +1 -0
  570. package/dist/tools/spawn.js +72 -0
  571. package/dist/tools/spawn.js.map +1 -0
  572. package/dist/tools/symphony.d.ts +12 -0
  573. package/dist/tools/symphony.d.ts.map +1 -0
  574. package/dist/tools/symphony.js +142 -0
  575. package/dist/tools/symphony.js.map +1 -0
  576. package/dist/tools/system-tools.d.ts +11 -0
  577. package/dist/tools/system-tools.d.ts.map +1 -0
  578. package/dist/tools/system-tools.js +39 -0
  579. package/dist/tools/system-tools.js.map +1 -0
  580. package/dist/tools/tool.d.ts +119 -0
  581. package/dist/tools/tool.d.ts.map +1 -0
  582. package/dist/tools/tool.js +29 -0
  583. package/dist/tools/tool.js.map +1 -0
  584. package/dist/tools/web.d.ts +10 -0
  585. package/dist/tools/web.d.ts.map +1 -0
  586. package/dist/tools/web.js +105 -0
  587. package/dist/tools/web.js.map +1 -0
  588. package/dist/tui/App.d.ts +43 -0
  589. package/dist/tui/App.d.ts.map +1 -0
  590. package/dist/tui/App.js +265 -0
  591. package/dist/tui/App.js.map +1 -0
  592. package/dist/tui/bridge.d.ts +40 -0
  593. package/dist/tui/bridge.d.ts.map +1 -0
  594. package/dist/tui/bridge.js +29 -0
  595. package/dist/tui/bridge.js.map +1 -0
  596. package/dist/tui/components/Header.d.ts +14 -0
  597. package/dist/tui/components/Header.d.ts.map +1 -0
  598. package/dist/tui/components/Header.js +7 -0
  599. package/dist/tui/components/Header.js.map +1 -0
  600. package/dist/tui/components/InputBar.d.ts +10 -0
  601. package/dist/tui/components/InputBar.d.ts.map +1 -0
  602. package/dist/tui/components/InputBar.js +121 -0
  603. package/dist/tui/components/InputBar.js.map +1 -0
  604. package/dist/tui/components/MessageList.d.ts +18 -0
  605. package/dist/tui/components/MessageList.d.ts.map +1 -0
  606. package/dist/tui/components/MessageList.js +34 -0
  607. package/dist/tui/components/MessageList.js.map +1 -0
  608. package/dist/tui/components/Spinner.d.ts +9 -0
  609. package/dist/tui/components/Spinner.d.ts.map +1 -0
  610. package/dist/tui/components/Spinner.js +18 -0
  611. package/dist/tui/components/Spinner.js.map +1 -0
  612. package/dist/tui/components/StatusBar.d.ts +16 -0
  613. package/dist/tui/components/StatusBar.d.ts.map +1 -0
  614. package/dist/tui/components/StatusBar.js +15 -0
  615. package/dist/tui/components/StatusBar.js.map +1 -0
  616. package/dist/tui/components/ToolCallBox.d.ts +12 -0
  617. package/dist/tui/components/ToolCallBox.d.ts.map +1 -0
  618. package/dist/tui/components/ToolCallBox.js +12 -0
  619. package/dist/tui/components/ToolCallBox.js.map +1 -0
  620. package/dist/tui/theme.d.ts +58 -0
  621. package/dist/tui/theme.d.ts.map +1 -0
  622. package/dist/tui/theme.js +80 -0
  623. package/dist/tui/theme.js.map +1 -0
  624. package/dist/utils/logger.d.ts +16 -0
  625. package/dist/utils/logger.d.ts.map +1 -0
  626. package/dist/utils/logger.js +70 -0
  627. package/dist/utils/logger.js.map +1 -0
  628. package/docs/DEVELOPMENT.md +74 -0
  629. package/docs/INSTALL.md +161 -0
  630. package/docs/USAGE.md +94 -0
  631. package/docs/architecture.md +128 -0
  632. package/docs/channels.md +140 -0
  633. package/docs/configuration.md +209 -0
  634. package/docs/io-system.md +430 -0
  635. package/docs/providers.md +99 -0
  636. package/docs/skill-channels.md +113 -0
  637. package/docs/skills.md +246 -0
  638. package/package.json +89 -0
  639. package/skills/acp-router/SKILL.md +41 -0
  640. package/skills/acp-router/tools/acp-router.mjs +239 -0
  641. package/skills/find-skills/SKILL.md +133 -0
  642. package/skills/security-audit/SKILL.md +181 -0
  643. package/skills/security-audit/audit.sh +67 -0
  644. package/skills/skill-creator/SKILL.md +479 -0
  645. package/skills/skill-security-audit/.clawhub/origin.json +7 -0
  646. package/skills/skill-security-audit/SKILL.md +196 -0
  647. package/skills/skill-security-audit/_meta.json +6 -0
  648. package/skills/skill-security-audit/references/prompt-injection-patterns.md +276 -0
  649. package/skills/skill-security-audit/references/vulnerability-patterns.md +348 -0
  650. package/skills/symphony/README.md +53 -0
  651. package/skills/symphony/SKILL.md +75 -0
  652. package/skills/symphony/tools/symphony-orchestrator.ts +8 -0
  653. package/tako.example.json +33 -0
@@ -0,0 +1,430 @@
1
+ # Tako I/O System Analysis
2
+
3
+ > Deep analysis of message flow, streaming architecture, backpressure handling,
4
+ > and error propagation through Tako's I/O pipeline.
5
+
6
+ ---
7
+
8
+ ## 1. Full I/O Flow Diagram
9
+
10
+ ```
11
+ ┌──────────────────────┐
12
+ │ External World │
13
+ │ (Discord, Telegram, │
14
+ │ CLI stdin, WebSocket)│
15
+ └──────────┬───────────┘
16
+
17
+ ┌────────────────────┼────────────────────┐
18
+ │ │ │
19
+ ┌─────▼──────┐ ┌──────▼──────┐ ┌──────▼──────┐
20
+ │ CLIChannel │ │DiscordChan │ │TelegramChan │
21
+ │ (readline) │ │ (discord.js)│ │ (grammY) │
22
+ └─────┬──────┘ └──────┬──────┘ └──────┬──────┘
23
+ │ │ │
24
+ │ InboundMessage │ InboundMessage │ InboundMessage
25
+ │ { id, channelId, │ │
26
+ │ author, content }│ │
27
+ └────────────────────┼────────────────────┘
28
+
29
+ ┌──────────▼───────────┐
30
+ │ index.ts (router) │
31
+ │ wireChannel() │
32
+ │ onMessage handler │
33
+ └──────────┬───────────┘
34
+
35
+ ┌──────────────┼──────────────┐
36
+ │ │ │
37
+ hooks.emit getSession() hooks.emit
38
+ 'message_ (Map lookup 'before_prompt_
39
+ received' or create) build'
40
+ │ │ │
41
+ └──────────────┼──────────────┘
42
+
43
+ ┌──────────▼───────────┐
44
+ │ AgentLoop.run() │
45
+ │ (AsyncGenerator) │
46
+ └──────────┬───────────┘
47
+
48
+ ┌────────────────────┼────────────────────┐
49
+ │ │ │
50
+ PromptBuilder ContextManager ToolRegistry
51
+ .build('full') .needsCompaction() .getActiveTools()
52
+ │ │ │
53
+ │ system prompt │ token check │ Tool[]
54
+ │ (up to 150KB) │ │
55
+ └────────────────────┼────────────────────┘
56
+
57
+ ┌──────────▼───────────┐
58
+ │ AnthropicProvider │
59
+ │ .chat(req) │
60
+ │ (AsyncIterable) │
61
+ └──────────┬───────────┘
62
+
63
+ ┌──────────▼───────────┐
64
+ │ Anthropic SSE Stream │
65
+ │ │
66
+ │ message_start │
67
+ │ content_block_start │
68
+ │ content_block_delta ─┼──► yield { text: "..." }
69
+ │ content_block_stop │
70
+ │ message_delta │
71
+ │ message_stop ────────┼──► yield { tool_calls, done }
72
+ └──────────┬───────────┘
73
+
74
+ ┌──────────▼───────────┐
75
+ │ Tool Execution │
76
+ │ (sequential loop) │
77
+ │ │
78
+ │ for (tc of calls) { │
79
+ │ hooks: before_call │
80
+ │ tool.execute() │
81
+ │ hooks: after_call │
82
+ │ push toolMsg │
83
+ │ } │
84
+ └──────────┬───────────┘
85
+
86
+ │ (loop back to Provider
87
+ │ if tool_calls existed)
88
+
89
+ ┌──────────▼───────────┐
90
+ │ Response Delivery │
91
+ │ │
92
+ │ CLI: stdout.write() │
93
+ │ Discord: channel.send│
94
+ │ Telegram: api.send │
95
+ │ Gateway: ws.send() │
96
+ └──────────────────────┘
97
+ ```
98
+
99
+ ---
100
+
101
+ ## 2. Message Flow — Detailed Trace
102
+
103
+ ### Phase 1: Channel Intake
104
+
105
+ A message arrives at a channel adapter. Each adapter normalizes it into `InboundMessage`:
106
+
107
+ ```
108
+ User types "hello" in Discord
109
+ → discord.js Events.MessageCreate fires
110
+ → DiscordChannel.convertInbound() creates:
111
+ {
112
+ id: "1234567890",
113
+ channelId: "discord:987654321",
114
+ author: { id: "user123", name: "alice" },
115
+ content: "hello",
116
+ attachments: [],
117
+ timestamp: "2026-03-05T00:00:00.000Z"
118
+ }
119
+ → handler(inbound) called
120
+ ```
121
+
122
+ **Key design**: All three channel adapters (CLI, Discord, Telegram) produce identical `InboundMessage` objects. The agent loop never sees channel-specific types.
123
+
124
+ ### Phase 2: Session Resolution
125
+
126
+ In `index.ts`, the `wireChannel()` closure handles routing:
127
+
128
+ ```typescript
129
+ function getSession(msg: InboundMessage) {
130
+ const key = `${msg.channelId}:${msg.author.id}`; // e.g. "discord:987654321:user123"
131
+ let session = channelSessions.get(key);
132
+ if (!session) {
133
+ session = sessions.create({ name: `${msg.channelId}/${msg.author.name}` });
134
+ channelSessions.set(key, session);
135
+ }
136
+ return session;
137
+ }
138
+ ```
139
+
140
+ Sessions are keyed by `channelId:authorId`. A user on Discord gets a different session than the same concept on Telegram. Sessions persist to disk via `SessionManager` (JSON files in `.sessions/`).
141
+
142
+ ### Phase 3: Agent Loop
143
+
144
+ `AgentLoop.run()` is an `AsyncGenerator` that yields text chunks:
145
+
146
+ ```
147
+ 1. Fire 'agent_start' hook
148
+ 2. Fire 'before_prompt_build' hook
149
+ 3. PromptBuilder.build({ mode: 'full' })
150
+ → Read SOUL.md, IDENTITY.md, AGENTS.md, TOOLS.md, USER.md, HEARTBEAT.md, BOOTSTRAP.md
151
+ → Read memory/MEMORY.md (curated memory)
152
+ → Append skill instructions
153
+ → Append runtime context (date, platform, workspace)
154
+ → Concatenate with "---" separators (up to 150KB total)
155
+ 4. Append user message to session.messages
156
+ 5. Get tool definitions from ToolRegistry
157
+ 6. LOOP (max 20 turns):
158
+ a. Check context window (ContextManager.needsCompaction)
159
+ b. Provider.chat() → stream chunks
160
+ → yield text chunks as they arrive
161
+ → accumulate tool_calls
162
+ c. Append assistant message to session
163
+ d. If no tool_calls → break
164
+ e. Execute tools sequentially
165
+ → Fire 'before_tool_call' for each
166
+ → tool.execute(params, ctx)
167
+ → Fire 'after_tool_call' for each
168
+ → Append tool result messages to session
169
+ f. Continue loop (next inference with tool results)
170
+ 7. Fire 'agent_end' hook
171
+ ```
172
+
173
+ ### Phase 4: Response Delivery
174
+
175
+ For **CLI**: Text chunks are written to `stdout` immediately as they arrive from the generator:
176
+ ```typescript
177
+ for await (const chunk of agentLoop.run(session, msg.content)) {
178
+ process.stdout.write(chunk); // Real-time streaming
179
+ }
180
+ ```
181
+
182
+ For **Discord/Telegram**: The entire response is accumulated, then sent:
183
+ ```typescript
184
+ let response = '';
185
+ for await (const chunk of agentLoop.run(session, msg.content)) {
186
+ response += chunk;
187
+ }
188
+ if (response) {
189
+ await channel.send({ target, content: response, replyTo: msg.id });
190
+ }
191
+ ```
192
+
193
+ For **Gateway (WebSocket)**: Chunks are forwarded individually:
194
+ ```typescript
195
+ for await (const chunk of this.deps.agentLoop.run(session, content)) {
196
+ this.sendToClient(client, { type: 'chunk', sessionId, text: chunk });
197
+ }
198
+ this.sendToClient(client, { type: 'done', sessionId });
199
+ ```
200
+
201
+ ---
202
+
203
+ ## 3. Streaming Architecture
204
+
205
+ ### Anthropic SSE → AsyncIterable → Channel
206
+
207
+ The streaming pipeline has three stages:
208
+
209
+ ```
210
+ Stage 1: Anthropic HTTP SSE
211
+ ↓ HTTP chunked transfer encoding
212
+ ↓ Server-Sent Events (text/event-stream)
213
+ ↓ Event types: message_start, content_block_start,
214
+ ↓ content_block_delta, content_block_stop,
215
+ ↓ message_delta, message_stop
216
+
217
+ Stage 2: AnthropicProvider.chatStreaming()
218
+ ↓ Parses SSE events into ChatChunk objects
219
+ ↓ Text deltas yielded immediately: { text: "...", done: false }
220
+ ↓ Tool call JSON accumulated incrementally (input_json_delta)
221
+ ↓ Final chunk: { tool_calls: [...], done: true, usage: {...} }
222
+
223
+ Stage 3: AgentLoop.run()
224
+ ↓ Re-yields text chunks from provider
225
+ ↓ Accumulates tool calls
226
+ ↓ On provider completion: executes tools, loops back
227
+
228
+ Stage 4: Channel delivery
229
+ ↓ CLI: immediate stdout.write per chunk
230
+ ↓ Discord/Telegram: accumulate full response, then send
231
+ ↓ Gateway WS: forward each chunk as JSON frame
232
+ ```
233
+
234
+ ### Tool Call Streaming Detail
235
+
236
+ Tool calls are streamed incrementally from Anthropic:
237
+
238
+ ```
239
+ content_block_start → { type: "tool_use", id: "toolu_xxx", name: "read" }
240
+ input_json_delta → '{"pa'
241
+ input_json_delta → 'th": '
242
+ input_json_delta → '"src/index.ts"}'
243
+ content_block_stop → (tool call complete)
244
+ message_stop → (parse accumulated JSON, emit as ToolCall)
245
+ ```
246
+
247
+ The `AnthropicProvider` accumulates `inputJson` as a string and only parses it on `message_stop`. This means tool calls are not available until the full response is complete.
248
+
249
+ ### Streaming Gaps
250
+
251
+ 1. **Discord/Telegram don't stream**: They buffer the entire response. reference architecture's channel trait includes `send_draft()` / `update_draft()` / `finalize_draft()` for progressive updates — Tako doesn't have this yet.
252
+
253
+ 2. **Tool results aren't streamed to WebSocket**: The Gateway sends `chunk` messages for text but doesn't emit `tool_call` / `tool_result` events (the protocol types exist but aren't used in `handleChat()`).
254
+
255
+ 3. **No thinking stream**: When using extended thinking, thinking tokens aren't surfaced to the consumer.
256
+
257
+ ---
258
+
259
+ ## 4. Backpressure Analysis
260
+
261
+ ### Does Tako Handle Slow Consumers?
262
+
263
+ **Short answer: No.** There is no backpressure mechanism.
264
+
265
+ ### Analysis by Component
266
+
267
+ #### CLI Channel
268
+ - **Producer**: `agentLoop.run()` yields chunks
269
+ - **Consumer**: `process.stdout.write(chunk)`
270
+ - **Backpressure**: stdout is a writable stream with internal buffering. If the terminal can't keep up, `write()` returns `false`, but Tako ignores the return value. In practice, terminals are fast enough that this never matters.
271
+
272
+ #### Discord Channel
273
+ - **Producer**: Full response accumulated in string
274
+ - **Consumer**: `channel.send()` → Discord API HTTP POST
275
+ - **Backpressure**: Discord rate limits (5 messages/5 seconds per channel). Tako's `splitMessage()` sends chunks sequentially with `await`, so rate limits would cause the sender to wait. But there's no queue or retry — if Discord rejects, the error propagates up.
276
+
277
+ #### Telegram Channel
278
+ - **Producer**: Full response accumulated
279
+ - **Consumer**: `bot.api.sendMessage()` → Telegram Bot API
280
+ - **Backpressure**: Similar to Discord. Telegram rate limits are per-bot. No queue.
281
+
282
+ #### Gateway WebSocket
283
+ - **Producer**: `agentLoop.run()` yields chunks
284
+ - **Consumer**: `client.ws.send(JSON.stringify(msg))`
285
+ - **Backpressure**: The `ws` library buffers sends internally. If the WebSocket buffer fills (client can't drain fast enough), `send()` calls accumulate in memory. The only protection is the `readyState` check:
286
+ ```typescript
287
+ if (client.ws.readyState !== WebSocket.OPEN) break;
288
+ ```
289
+ This stops sending if the connection drops, but doesn't handle slow consumers.
290
+
291
+ ### What Happens When a Channel Can't Keep Up?
292
+
293
+ 1. **Memory grows**: Undelivered messages accumulate in Node.js heap
294
+ 2. **Event loop blocks**: Sequential message sends block other handlers
295
+ 3. **No circuit breaker**: A slow channel blocks the agent loop for that session (but not other sessions, since each session's handler runs independently)
296
+
297
+ ### Recommendations
298
+
299
+ 1. **Add WebSocket buffering limits**: Track `ws.bufferedAmount` and pause the generator if backlog exceeds a threshold
300
+ 2. **Add channel send timeouts**: Wrap `channel.send()` with `AbortSignal.timeout()`
301
+ 3. **Implement draft updates for Discord/Telegram**: Progressive message editing instead of buffering the full response
302
+ 4. **Consider `for await` with buffering**: Use a bounded async queue between the generator and the consumer
303
+
304
+ ---
305
+
306
+ ## 5. Error Propagation
307
+
308
+ ### Error Flow Diagram
309
+
310
+ ```
311
+ Anthropic API Error
312
+ ↓ thrown inside provider.chat() generator
313
+ ↓ caught by for-await-of in AgentLoop.run()
314
+ ↓ NOT caught — propagates out of the generator
315
+
316
+ wireChannel handler catches it:
317
+ catch (err) {
318
+ console.error('[tako] Error:', err.message);
319
+ }
320
+ ↓ CLI: error printed, re-prompt shown
321
+ ↓ Discord/Telegram: error logged, no response sent to user
322
+ ↓ Gateway: caught in handleChat(), sent as { type: 'error' }
323
+ ```
324
+
325
+ ### Error Sources and Handling
326
+
327
+ | Error Source | Where Caught | User Impact |
328
+ |-------------|-------------|-------------|
329
+ | **API auth failure (401/403)** | `AnthropicProvider.wrapAuthError()` | Thrown, logged, no response |
330
+ | **API rate limit (429)** | `AnthropicProvider.chat()` — tries next key | Transparent if multiple keys, error if all exhausted |
331
+ | **API timeout** | Node.js fetch timeout | Thrown, no response |
332
+ | **Tool execution error** | `tool.execute()` returns `{ success: false }` | Model sees error, retries or reports |
333
+ | **JSON parse error (tool args)** | `JSON.parse(tc.inputJson)` in streaming | Thrown, breaks agent loop |
334
+ | **File read error (prompt)** | `PromptBuilder.loadFile()` returns `''` | Silent — missing file treated as empty |
335
+ | **Session not found** | Various — returns error result | Reported to client |
336
+ | **WebSocket disconnect** | `readyState` check in Gateway | Stops streaming, no cleanup |
337
+ | **Channel send failure** | Per-channel error handling | Logged, no retry |
338
+
339
+ ### Error Handling Patterns
340
+
341
+ **Good patterns in Tako:**
342
+ 1. **Graceful file missing**: `loadFile()` catches errors and returns empty string — missing workspace files don't crash
343
+ 2. **Key rotation**: Anthropic provider tries multiple API keys before failing
344
+ 3. **Tool error isolation**: A failing tool returns `ToolResult { success: false }` — the model sees the error and can retry or report it
345
+ 4. **Auth error wrapping**: `wrapAuthError()` provides clear messages for 401/403
346
+
347
+ **Gaps in error handling:**
348
+ 1. **No retry logic**: Network errors on provider calls are not retried
349
+ 2. **Silent channel failures**: If Discord/Telegram `send()` fails, the user gets no response and no notification
350
+ 3. **JSON parse crash**: If Anthropic sends malformed tool call JSON, `JSON.parse()` throws and breaks the loop — should catch and return error to model
351
+ 4. **No error hook**: There's no `'error'` hook event for skills to observe
352
+ 5. **Memory store errors are swallowed**: `HybridMemoryStore.initialize()` catches all errors silently — a corrupted index goes unnoticed
353
+
354
+ ### Error Recovery Recommendations
355
+
356
+ 1. **Add retry with exponential backoff** for provider API calls (network errors, 500s)
357
+ 2. **Wrap JSON.parse in try/catch** in the streaming tool call accumulator
358
+ 3. **Send error messages to channels** — if the agent loop fails, send a user-visible error like "Something went wrong, please try again"
359
+ 4. **Add `'error'` hook event** — skills should be able to observe and react to errors
360
+ 5. **Log + alert on repeated failures** — if the same provider/channel fails repeatedly, surface it in `tako doctor`
361
+
362
+ ---
363
+
364
+ ## 6. Data Contracts Between Layers
365
+
366
+ ### Channel → Router
367
+
368
+ ```typescript
369
+ InboundMessage {
370
+ id: string // platform-specific message ID
371
+ channelId: string // "cli" | "discord:{channelId}" | "telegram:{chatId}"
372
+ author: { id: string; name: string }
373
+ content: string // plain text
374
+ timestamp: string // ISO-8601
375
+ }
376
+ ```
377
+
378
+ ### Router → Agent Loop
379
+
380
+ ```typescript
381
+ // Passes:
382
+ session: Session // from SessionManager
383
+ userMessage: string // msg.content
384
+ // Returns:
385
+ AsyncIterable<string> // text chunks
386
+ ```
387
+
388
+ ### Agent Loop → Provider
389
+
390
+ ```typescript
391
+ ChatRequest {
392
+ model: string
393
+ messages: ChatMessage[] // system + history + user
394
+ tools?: ToolDefinition[]
395
+ stream: true
396
+ }
397
+ // Returns:
398
+ AsyncIterable<ChatChunk> // text + tool_calls
399
+ ```
400
+
401
+ ### Agent Loop → Tools
402
+
403
+ ```typescript
404
+ // Input:
405
+ params: unknown // parsed from model's tool_call.input
406
+ ctx: ToolContext {
407
+ sessionId: string
408
+ workDir: string
409
+ workspaceRoot: string
410
+ }
411
+ // Output:
412
+ ToolResult {
413
+ output: string // fed back to model
414
+ success: boolean
415
+ }
416
+ ```
417
+
418
+ ### Gateway → WebSocket Client
419
+
420
+ ```typescript
421
+ ServerMessage =
422
+ | { type: 'chunk'; sessionId; text } // streaming text
423
+ | { type: 'done'; sessionId } // response complete
424
+ | { type: 'error'; sessionId; message } // error
425
+ | { type: 'session_created'; ... } // session lifecycle
426
+ ```
427
+
428
+ ---
429
+
430
+ *Analysis based on Tako v0.4.0 source code, March 2026.*
@@ -0,0 +1,99 @@
1
+ # Providers
2
+
3
+ Providers adapt LLM APIs into Tako's unified streaming interface.
4
+
5
+ ## Anthropic (Built-in)
6
+
7
+ The primary provider with full native implementation.
8
+
9
+ **Configuration:**
10
+ ```json
11
+ {
12
+ "providers": {
13
+ "primary": "anthropic/claude-sonnet-4-6"
14
+ }
15
+ }
16
+ ```
17
+
18
+ **Auth options:**
19
+ - **Setup token (OAuth):** `tako models auth login --provider anthropic`
20
+ - **API key:** `ANTHROPIC_API_KEY` env var or via `tako onboard`
21
+ - **Multi-key rotation:** `ANTHROPIC_API_KEYS=key1,key2` (comma-separated, rotated per request)
22
+
23
+ **Available models:**
24
+
25
+ | Model | Context | Max Output | Capabilities |
26
+ |-------|---------|------------|--------------|
27
+ | `claude-opus-4-6` | 200K | 32K | vision, tools, streaming |
28
+ | `claude-sonnet-4-6` | 200K | 8K | vision, tools, streaming |
29
+ | `claude-haiku-4-5` | 200K | 8K | vision, tools, streaming |
30
+
31
+ **Features:**
32
+ - Streaming via Server-Sent Events (SSE)
33
+ - Incremental tool call parsing (`input_json_delta`)
34
+ - System prompt extraction from message array
35
+ - Token usage tracking
36
+ - Tool use/result pairing repair for API compatibility
37
+
38
+ ## OpenAI (Built-in)
39
+
40
+ OpenAI Chat Completions API support.
41
+
42
+ ```json
43
+ {
44
+ "providers": {
45
+ "primary": "openai/gpt-5.2"
46
+ }
47
+ }
48
+ ```
49
+
50
+ **Auth:** `OPENAI_API_KEY` env var or `tako models auth login --provider openai`
51
+
52
+ ## LiteLLM (Built-in)
53
+
54
+ Universal proxy adapter for 100+ providers via LiteLLM's OpenAI-compatible API.
55
+
56
+ ```json
57
+ {
58
+ "providers": {
59
+ "primary": "litellm/anthropic/claude-sonnet-4-6",
60
+ "litellm": {
61
+ "baseUrl": "http://localhost:4000",
62
+ "model": "anthropic/claude-sonnet-4-6"
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ **Features:**
69
+ - Preset endpoint support for popular proxies
70
+ - Dynamic model fetching from proxy `/models` endpoint
71
+ - Automatic retry on 400 errors (proxy warmup/transient failures)
72
+ - Message sanitization for proxy compatibility
73
+
74
+ **Setup:** `tako onboard` includes LiteLLM configuration with proxy URL and model selection.
75
+
76
+ ## Custom Providers
77
+
78
+ Implement the `Provider` interface in `src/providers/provider.ts`:
79
+
80
+ ```typescript
81
+ import type { Provider, ChatRequest, ChatChunk, ModelInfo } from './provider.js';
82
+
83
+ export class MyProvider implements Provider {
84
+ id = 'my-provider';
85
+
86
+ async *chat(req: ChatRequest): AsyncIterable<ChatChunk> {
87
+ // Stream chunks from your API
88
+ yield { text: 'Hello!', done: true };
89
+ }
90
+
91
+ models(): ModelInfo[] {
92
+ return [{ id: 'my-model', name: 'My Model', provider: 'my-provider', context_window: 128000, max_output_tokens: 4096, capabilities: ['tools'] }];
93
+ }
94
+
95
+ supports(capability: string): boolean {
96
+ return ['tools', 'streaming'].includes(capability);
97
+ }
98
+ }
99
+ ```
@@ -0,0 +1,113 @@
1
+ # Skill-Loaded Channels
2
+
3
+ Skills can provide channel adapters, letting Tako connect to any messaging
4
+ platform without modifying the kernel.
5
+
6
+ ## Skill structure
7
+
8
+ ```
9
+ skills/feishu/
10
+ ├── SKILL.md # Frontmatter + instructions
11
+ ├── channel/
12
+ │ └── index.ts # exports createChannel(config) → Channel
13
+ ├── tools/ # Optional tools
14
+ │ └── feishu-tools.ts
15
+ └── package.json # Platform SDK dependency
16
+ ```
17
+
18
+ ## SKILL.md
19
+
20
+ ```yaml
21
+ ---
22
+ name: feishu
23
+ description: Feishu/Lark messaging channel
24
+ user-invocable: false
25
+ requires: {"env": ["FEISHU_APP_ID", "FEISHU_APP_SECRET"]}
26
+ ---
27
+ ```
28
+
29
+ ## Channel module
30
+
31
+ ```typescript
32
+ // channel/index.ts
33
+ import type { Channel, InboundMessage, OutboundMessage, MessageHandler } from 'tako/channels/channel';
34
+
35
+ export function createChannel(config: { appId: string; appSecret: string }): Channel {
36
+ return new FeishuChannel(config);
37
+ }
38
+
39
+ class FeishuChannel implements Channel {
40
+ id = 'feishu';
41
+ private handler: MessageHandler | null = null;
42
+
43
+ constructor(private config: { appId: string; appSecret: string }) {}
44
+
45
+ async connect(): Promise<void> {
46
+ // Connect to Feishu API, start webhook listener, etc.
47
+ }
48
+
49
+ async disconnect(): Promise<void> {
50
+ // Clean up connections
51
+ }
52
+
53
+ async send(msg: OutboundMessage): Promise<void> {
54
+ // Send message via Feishu API
55
+ }
56
+
57
+ onMessage(handler: MessageHandler): void {
58
+ this.handler = handler;
59
+ }
60
+ }
61
+ ```
62
+
63
+ ## Configuration (tako.json)
64
+
65
+ ```json
66
+ {
67
+ "skillChannels": {
68
+ "feishu": {
69
+ "appId": "cli_xxx",
70
+ "appSecret": "secret"
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ ## How it works
77
+
78
+ 1. The skill loader discovers skills with a `channel/` subdirectory and sets
79
+ `hasChannel: true` on the manifest.
80
+
81
+ 2. During startup, after all built-in channels (CLI, Discord, Telegram) are
82
+ connected, Tako iterates loaded skills and calls `loadChannelFromSkill()`
83
+ for each skill with `hasChannel`.
84
+
85
+ 3. The channel module's `createChannel(config)` function is called with
86
+ configuration from `skillChannels.<name>` in `tako.json`.
87
+
88
+ 4. The returned `Channel` instance is wired into the same message router as
89
+ built-in channels — it receives the same message handling, session
90
+ management, and command routing.
91
+
92
+ 5. The gateway also exposes `registerChannel()` / `unregisterChannel()` for
93
+ skills that need to register channels dynamically at runtime via hooks
94
+ (e.g., on `gateway_start`).
95
+
96
+ ## Dynamic registration via hooks
97
+
98
+ Skills can also register channels at runtime through the hook system:
99
+
100
+ ```typescript
101
+ // In a skill's hook handler
102
+ hooks.on('gateway_start', async (ctx) => {
103
+ const { registerChannel } = ctx.data;
104
+ const channel = createMyChannel(config);
105
+ await registerChannel(channel);
106
+ });
107
+ ```
108
+
109
+ The `gateway_start` hook context includes:
110
+ - `gateway` — the Gateway instance
111
+ - `registerChannel(channel)` — register and connect a channel
112
+ - `unregisterChannel(id)` — disconnect and remove a channel
113
+ - `config` — gateway configuration