agentix-cli 0.159.0 → 0.161.0

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 (178) hide show
  1. package/README.md +25 -20
  2. package/dist/{App-LFKP4IY5.js → App-MXMKX57A.js} +2 -2
  3. package/dist/{ChatApp-SSVWKETD.js → ChatApp-PSKTL3PQ.js} +2 -2
  4. package/dist/{absorb-eval-IPPP2RZV.js → absorb-eval-NACNM4PW.js} +2 -2
  5. package/dist/{agent-SNNE24LT.js → agent-2RYXBN55.js} +2 -2
  6. package/dist/{board-dashboard-YW6WOQAB.js → board-dashboard-4IM47KL3.js} +827 -398
  7. package/dist/board-dashboard-4IM47KL3.js.map +1 -0
  8. package/dist/{chunk-T2GBLNW7.js → chunk-23J4NAHM.js} +2 -2
  9. package/dist/{chunk-KPYWYMRY.js → chunk-34NONG4B.js} +2 -2
  10. package/dist/chunk-4KMS3ES7.js +90 -0
  11. package/dist/chunk-4KMS3ES7.js.map +1 -0
  12. package/dist/{chunk-CDLRTTHR.js → chunk-55ZCWREX.js} +2 -2
  13. package/dist/{chunk-XWQ3ZEIZ.js → chunk-A75ADFHR.js} +2 -2
  14. package/dist/{chunk-KCT6Y2AG.js → chunk-ATF7JKPR.js} +2 -2
  15. package/dist/{chunk-LLJZMS23.js → chunk-AYK2MO3B.js} +2 -2
  16. package/dist/{chunk-XMU63PSI.js → chunk-AYYWQOGG.js} +3 -3
  17. package/dist/{chunk-IERW7MLU.js → chunk-BH46UJ6V.js} +2 -2
  18. package/dist/{chunk-KXK2OKT5.js → chunk-CKIIBDGR.js} +2 -2
  19. package/dist/{chunk-QH7R4IQS.js → chunk-CO272ZNT.js} +2 -2
  20. package/dist/{chunk-UIVNNH6T.js → chunk-GPNX66NP.js} +2 -2
  21. package/dist/{chunk-UIVNNH6T.js.map → chunk-GPNX66NP.js.map} +1 -1
  22. package/dist/{chunk-Z5RMH5SV.js → chunk-GQWH6PPF.js} +2 -2
  23. package/dist/{chunk-2OY7P3HS.js → chunk-IICCM3LV.js} +246 -246
  24. package/dist/chunk-IICCM3LV.js.map +1 -0
  25. package/dist/{chunk-5IXE5AXR.js → chunk-IKRDLKKJ.js} +16 -7
  26. package/dist/chunk-IKRDLKKJ.js.map +1 -0
  27. package/dist/{chunk-DPNCWHJW.js → chunk-ITIW4UUJ.js} +2 -2
  28. package/dist/{chunk-HWOBHAZD.js → chunk-JJ7GP3YA.js} +2 -2
  29. package/dist/chunk-L5EU7TH2.js +181 -0
  30. package/dist/chunk-L5EU7TH2.js.map +1 -0
  31. package/dist/{chunk-ODAZQH7N.js → chunk-M3SXXUNB.js} +2 -2
  32. package/dist/{chunk-M6YFSYJC.js → chunk-O7ITYFU6.js} +2 -2
  33. package/dist/{chunk-7C67DNT6.js → chunk-OGCZJTGG.js} +2 -2
  34. package/dist/{chunk-5NTWGUSJ.js → chunk-OO7T7E4O.js} +2 -2
  35. package/dist/{chunk-KKTHRSSJ.js → chunk-OQWMP5ZD.js} +2 -2
  36. package/dist/chunk-PTX6NWCQ.js +41 -0
  37. package/dist/chunk-PTX6NWCQ.js.map +1 -0
  38. package/dist/{chunk-MBCXPY6T.js → chunk-QA2ZRM57.js} +2 -2
  39. package/dist/{chunk-P5RTEJUB.js → chunk-SCEQJFQO.js} +2 -2
  40. package/dist/{chunk-EMGB23H5.js → chunk-UKUH662W.js} +2 -2
  41. package/dist/chunk-UKUH662W.js.map +1 -0
  42. package/dist/{chunk-P76PFVMJ.js → chunk-V6FVFN7S.js} +2 -2
  43. package/dist/{chunk-5TTHN7DP.js → chunk-VL74KOR7.js} +18 -13
  44. package/dist/chunk-VL74KOR7.js.map +1 -0
  45. package/dist/{chunk-JYSJDHNS.js → chunk-VUEQ4SL5.js} +18 -9
  46. package/dist/{chunk-JYSJDHNS.js.map → chunk-VUEQ4SL5.js.map} +1 -1
  47. package/dist/{chunk-2J7LN4SR.js → chunk-WEUGS4GI.js} +2 -2
  48. package/dist/{chunk-S5CNKZBP.js → chunk-X45QYAZ2.js} +2 -2
  49. package/dist/{chunk-UIBUZ2N3.js → chunk-XG5FRD7G.js} +19 -8
  50. package/dist/chunk-XG5FRD7G.js.map +1 -0
  51. package/dist/chunk-XIRM45DH.js +11 -0
  52. package/dist/chunk-XIRM45DH.js.map +1 -0
  53. package/dist/{chunk-LSC64WL3.js → chunk-XOQB2M6T.js} +2 -2
  54. package/dist/{chunk-ECY6WMZP.js → chunk-Y3DUSCYH.js} +2 -2
  55. package/dist/cli.js +1 -1
  56. package/dist/{client-GVAZIQQW.js → client-RKJQW7V4.js} +2 -2
  57. package/dist/{config-IWC47ZIT.js → config-VUCSD5CQ.js} +2 -2
  58. package/dist/config-mutate-XGYCOQ2Q.js +2 -0
  59. package/dist/config-mutator-AOZIMD3Q.js +2 -0
  60. package/dist/{contributions-HEPV2YXR.js → contributions-SK2T5B5H.js} +2 -2
  61. package/dist/{doctor-HOTKJEW5.js → doctor-63WBE26X.js} +2 -2
  62. package/dist/{failure-candidates-NQX2JMMS.js → failure-candidates-HNENLQJC.js} +2 -2
  63. package/dist/{follow-up-tool-R2U755ZJ.js → follow-up-tool-Z5AKB2WM.js} +2 -2
  64. package/dist/hub-5XVB256E.js +2 -0
  65. package/dist/index.d.ts +124 -1
  66. package/dist/index.js +1 -1
  67. package/dist/processes-GRS7BSIU.js +2 -0
  68. package/dist/{program-7QU75QNS.js → program-JAODEQ3Y.js} +283 -267
  69. package/dist/program-JAODEQ3Y.js.map +1 -0
  70. package/dist/{promote-QLBR6G6E.js → promote-IPL7FTWA.js} +2 -2
  71. package/dist/{query-L4TULDGS.js → query-OI7WUKYO.js} +2 -2
  72. package/dist/{query-settings-RH2E6JM2.js → query-settings-N2LLPXIW.js} +2 -2
  73. package/dist/{registry-HNCVWFDT.js → registry-HD6A6L7V.js} +2 -2
  74. package/dist/{request-planner-SH5CLEZZ.js → request-planner-EGSNUPFD.js} +2 -2
  75. package/dist/{review-candidates-V7WCKVVJ.js → review-candidates-U3Z46RRY.js} +2 -2
  76. package/dist/routing-U36AIRKZ.js +2 -0
  77. package/dist/schedule-tool-EG3LABHQ.js +2 -0
  78. package/dist/scheduler-4L7UJTN7.js +2 -0
  79. package/dist/{seat-CHFR5HFA.js → seat-ZQTFH7FE.js} +2 -2
  80. package/dist/{select-FTQBN33Y.js → select-JO5USUIR.js} +2 -2
  81. package/dist/{set-enabled-OCXL7V7L.js → set-enabled-PPOAMZ5R.js} +2 -2
  82. package/dist/{surface-usage-WSY4SHHL.js → surface-usage-W33HGXMP.js} +2 -2
  83. package/dist/token-store-F2PHHO5A.js +2 -0
  84. package/dist/token-tracker-B2UFOH46.js +2 -0
  85. package/dist/{tool-6WLBCL22.js → tool-6G7TMVKS.js} +2 -2
  86. package/dist/{tool-ZFSGK53G.js → tool-YHHUBUIP.js} +2 -2
  87. package/dist/traces-G4HRLRA3.js +2 -0
  88. package/dist/wiki-PG6OQEXK.js +2 -0
  89. package/dist/wiki-enrich-WLEWKV45.js +2 -0
  90. package/dist/{workflow-pilot-HCPSMGIC.js → workflow-pilot-25NMZYUO.js} +2 -2
  91. package/package.json +1 -1
  92. package/dist/board-dashboard-YW6WOQAB.js.map +0 -1
  93. package/dist/chunk-2OY7P3HS.js.map +0 -1
  94. package/dist/chunk-36AXN6ZB.js +0 -11
  95. package/dist/chunk-36AXN6ZB.js.map +0 -1
  96. package/dist/chunk-5IXE5AXR.js.map +0 -1
  97. package/dist/chunk-5TTHN7DP.js.map +0 -1
  98. package/dist/chunk-A43C7UUG.js +0 -41
  99. package/dist/chunk-A43C7UUG.js.map +0 -1
  100. package/dist/chunk-A7AVIFNF.js +0 -86
  101. package/dist/chunk-A7AVIFNF.js.map +0 -1
  102. package/dist/chunk-EHUKKZ5H.js +0 -181
  103. package/dist/chunk-EHUKKZ5H.js.map +0 -1
  104. package/dist/chunk-EMGB23H5.js.map +0 -1
  105. package/dist/chunk-UIBUZ2N3.js.map +0 -1
  106. package/dist/config-mutate-W7KUQC72.js +0 -2
  107. package/dist/config-mutator-ZVDBAYHA.js +0 -2
  108. package/dist/hub-5LSCXPYT.js +0 -2
  109. package/dist/processes-XM77XGOO.js +0 -2
  110. package/dist/program-7QU75QNS.js.map +0 -1
  111. package/dist/routing-KCZ6AY66.js +0 -2
  112. package/dist/schedule-tool-PYG4K4RY.js +0 -2
  113. package/dist/scheduler-X56K6BXS.js +0 -2
  114. package/dist/token-store-AY6OBDVI.js +0 -2
  115. package/dist/token-tracker-W7DFDEFN.js +0 -2
  116. package/dist/traces-GVEQZX24.js +0 -2
  117. package/dist/wiki-6UDGACKC.js +0 -2
  118. package/dist/wiki-enrich-6QKT6KCN.js +0 -2
  119. /package/dist/{App-LFKP4IY5.js.map → App-MXMKX57A.js.map} +0 -0
  120. /package/dist/{ChatApp-SSVWKETD.js.map → ChatApp-PSKTL3PQ.js.map} +0 -0
  121. /package/dist/{absorb-eval-IPPP2RZV.js.map → absorb-eval-NACNM4PW.js.map} +0 -0
  122. /package/dist/{agent-SNNE24LT.js.map → agent-2RYXBN55.js.map} +0 -0
  123. /package/dist/{chunk-T2GBLNW7.js.map → chunk-23J4NAHM.js.map} +0 -0
  124. /package/dist/{chunk-KPYWYMRY.js.map → chunk-34NONG4B.js.map} +0 -0
  125. /package/dist/{chunk-CDLRTTHR.js.map → chunk-55ZCWREX.js.map} +0 -0
  126. /package/dist/{chunk-XWQ3ZEIZ.js.map → chunk-A75ADFHR.js.map} +0 -0
  127. /package/dist/{chunk-KCT6Y2AG.js.map → chunk-ATF7JKPR.js.map} +0 -0
  128. /package/dist/{chunk-LLJZMS23.js.map → chunk-AYK2MO3B.js.map} +0 -0
  129. /package/dist/{chunk-XMU63PSI.js.map → chunk-AYYWQOGG.js.map} +0 -0
  130. /package/dist/{chunk-IERW7MLU.js.map → chunk-BH46UJ6V.js.map} +0 -0
  131. /package/dist/{chunk-KXK2OKT5.js.map → chunk-CKIIBDGR.js.map} +0 -0
  132. /package/dist/{chunk-QH7R4IQS.js.map → chunk-CO272ZNT.js.map} +0 -0
  133. /package/dist/{chunk-Z5RMH5SV.js.map → chunk-GQWH6PPF.js.map} +0 -0
  134. /package/dist/{chunk-DPNCWHJW.js.map → chunk-ITIW4UUJ.js.map} +0 -0
  135. /package/dist/{chunk-HWOBHAZD.js.map → chunk-JJ7GP3YA.js.map} +0 -0
  136. /package/dist/{chunk-ODAZQH7N.js.map → chunk-M3SXXUNB.js.map} +0 -0
  137. /package/dist/{chunk-M6YFSYJC.js.map → chunk-O7ITYFU6.js.map} +0 -0
  138. /package/dist/{chunk-7C67DNT6.js.map → chunk-OGCZJTGG.js.map} +0 -0
  139. /package/dist/{chunk-5NTWGUSJ.js.map → chunk-OO7T7E4O.js.map} +0 -0
  140. /package/dist/{chunk-KKTHRSSJ.js.map → chunk-OQWMP5ZD.js.map} +0 -0
  141. /package/dist/{chunk-MBCXPY6T.js.map → chunk-QA2ZRM57.js.map} +0 -0
  142. /package/dist/{chunk-P5RTEJUB.js.map → chunk-SCEQJFQO.js.map} +0 -0
  143. /package/dist/{chunk-P76PFVMJ.js.map → chunk-V6FVFN7S.js.map} +0 -0
  144. /package/dist/{chunk-2J7LN4SR.js.map → chunk-WEUGS4GI.js.map} +0 -0
  145. /package/dist/{chunk-S5CNKZBP.js.map → chunk-X45QYAZ2.js.map} +0 -0
  146. /package/dist/{chunk-LSC64WL3.js.map → chunk-XOQB2M6T.js.map} +0 -0
  147. /package/dist/{chunk-ECY6WMZP.js.map → chunk-Y3DUSCYH.js.map} +0 -0
  148. /package/dist/{client-GVAZIQQW.js.map → client-RKJQW7V4.js.map} +0 -0
  149. /package/dist/{config-IWC47ZIT.js.map → config-VUCSD5CQ.js.map} +0 -0
  150. /package/dist/{config-mutate-W7KUQC72.js.map → config-mutate-XGYCOQ2Q.js.map} +0 -0
  151. /package/dist/{config-mutator-ZVDBAYHA.js.map → config-mutator-AOZIMD3Q.js.map} +0 -0
  152. /package/dist/{contributions-HEPV2YXR.js.map → contributions-SK2T5B5H.js.map} +0 -0
  153. /package/dist/{doctor-HOTKJEW5.js.map → doctor-63WBE26X.js.map} +0 -0
  154. /package/dist/{failure-candidates-NQX2JMMS.js.map → failure-candidates-HNENLQJC.js.map} +0 -0
  155. /package/dist/{follow-up-tool-R2U755ZJ.js.map → follow-up-tool-Z5AKB2WM.js.map} +0 -0
  156. /package/dist/{hub-5LSCXPYT.js.map → hub-5XVB256E.js.map} +0 -0
  157. /package/dist/{processes-XM77XGOO.js.map → processes-GRS7BSIU.js.map} +0 -0
  158. /package/dist/{promote-QLBR6G6E.js.map → promote-IPL7FTWA.js.map} +0 -0
  159. /package/dist/{query-L4TULDGS.js.map → query-OI7WUKYO.js.map} +0 -0
  160. /package/dist/{query-settings-RH2E6JM2.js.map → query-settings-N2LLPXIW.js.map} +0 -0
  161. /package/dist/{registry-HNCVWFDT.js.map → registry-HD6A6L7V.js.map} +0 -0
  162. /package/dist/{request-planner-SH5CLEZZ.js.map → request-planner-EGSNUPFD.js.map} +0 -0
  163. /package/dist/{review-candidates-V7WCKVVJ.js.map → review-candidates-U3Z46RRY.js.map} +0 -0
  164. /package/dist/{routing-KCZ6AY66.js.map → routing-U36AIRKZ.js.map} +0 -0
  165. /package/dist/{schedule-tool-PYG4K4RY.js.map → schedule-tool-EG3LABHQ.js.map} +0 -0
  166. /package/dist/{scheduler-X56K6BXS.js.map → scheduler-4L7UJTN7.js.map} +0 -0
  167. /package/dist/{seat-CHFR5HFA.js.map → seat-ZQTFH7FE.js.map} +0 -0
  168. /package/dist/{select-FTQBN33Y.js.map → select-JO5USUIR.js.map} +0 -0
  169. /package/dist/{set-enabled-OCXL7V7L.js.map → set-enabled-PPOAMZ5R.js.map} +0 -0
  170. /package/dist/{surface-usage-WSY4SHHL.js.map → surface-usage-W33HGXMP.js.map} +0 -0
  171. /package/dist/{token-store-AY6OBDVI.js.map → token-store-F2PHHO5A.js.map} +0 -0
  172. /package/dist/{token-tracker-W7DFDEFN.js.map → token-tracker-B2UFOH46.js.map} +0 -0
  173. /package/dist/{tool-6WLBCL22.js.map → tool-6G7TMVKS.js.map} +0 -0
  174. /package/dist/{tool-ZFSGK53G.js.map → tool-YHHUBUIP.js.map} +0 -0
  175. /package/dist/{traces-GVEQZX24.js.map → traces-G4HRLRA3.js.map} +0 -0
  176. /package/dist/{wiki-6UDGACKC.js.map → wiki-PG6OQEXK.js.map} +0 -0
  177. /package/dist/{wiki-enrich-6QKT6KCN.js.map → wiki-enrich-WLEWKV45.js.map} +0 -0
  178. /package/dist/{workflow-pilot-HCPSMGIC.js.map → workflow-pilot-25NMZYUO.js.map} +0 -0
package/README.md CHANGED
@@ -19,7 +19,9 @@
19
19
 
20
20
  </div>
21
21
 
22
- Give each agent a job and AgentX gets it done where your business already works: it answers clients on WhatsApp and Telegram, sends the daily report on schedule, and takes an issue from GitLab or GitHub and works on the fix. You see every result, and what still needs you, in a browser dashboard. Under the hood AgentX is a harness: the program around an AI model that gives it channels, tools, schedules and memory, and records what it did. It runs on Claude Code, Codex, OpenCode or any model API, on a machine you control.
22
+ 1. **Give each agent a job.** Answer clients, send the daily report, or work on an issue.
23
+ 2. **It works in your team's tools.** WhatsApp, Telegram, GitLab, GitHub and schedules, on a machine you own.
24
+ 3. **You check the result and decide.** The browser dashboard shows what was done and what still needs you.
23
25
 
24
26
  ## Problems we solve
25
27
 
@@ -64,20 +66,6 @@ Short videos show AgentX running, one task each. Click the picture to open the *
64
66
  - [Desktop part 1: Install the AgentX desktop widget on a Mac](https://youtu.be/XwTJjaTt5WE)
65
67
  - [Desktop part 2: The floating widget, the pill and the orb](https://youtu.be/catRqT5LoyY)
66
68
 
67
- ## Current state: usable, experimental, not yet stable
68
-
69
- AgentX works and can be used today, but it is still an **experimental project, not a stable release**. There is plenty to polish and fix, especially the **Settings experience and configuration flows**. Expect rough edges and changes as people try it in real environments.
70
-
71
- Releases ship often; see the [changelog](CHANGELOG.md) for what changed. Our priority is to learn from actual use: what works, what breaks, and what is confusing to set up or operate.
72
-
73
- **Still missing: role-based access control (RBAC) at both mesh and agent levels.** We want to define who can access shared nodes and agents, delegate work, and perform particular actions. This would open up more possibilities for shared teams and multi-user deployments. Existing mesh authentication and tool permissions do not provide this complete role model; RBAC is planned work, not an available feature.
74
-
75
- [Try the demo](#see-it-without-an-account), [check the requirements](docs/requirements.md), or [help us test](#help-test-and-improve-agentx).
76
-
77
- ![AgentX Monitor showing tasks that need your attention in the current dashboard](docs/public/screenshots/monitor-only-you.png)
78
-
79
- *The Monitor dashboard in the isolated demo: review tasks that need you, with in-page agent chat. All displayed tasks are fictional.*
80
-
81
69
  ## See it without an account
82
70
 
83
71
  With Node.js 22.19 or newer, up to 26 (tested on 22, 24, 25 and 26), run:
@@ -92,11 +80,28 @@ The demo starts three local AgentX daemons and sends a task between them. Routin
92
80
 
93
81
  ## What it does
94
82
 
95
- - **Answers where your team works.** Connect a channel and assign its messages to an agent.
96
- - **Runs scheduled work.** Ask an agent for a daily report or another recurring task.
97
- - **Shows what happened.** Live shows current work; Activity records completed runs; Monitor shows reviewed work that needs a person and work agents can handle.
98
- - **Offers several ways to interact.** Use [in-page chat](docs/dashboard/chat.md), the [OpenCode-backed TUI](docs/dashboard/tui.md), or the desktop assistant for voice and computer use.
99
- - **Grows across machines.** Start with one host, then pair another when a job needs its tools or files.
83
+ - **Clients get an answer where they already write.** Connect WhatsApp or Telegram and an agent replies in the same chat.
84
+ - **Reports arrive without anyone remembering them.** A schedule asks an agent for the daily report or another recurring job.
85
+ - **Issues move toward a fix.** An agent takes an issue from GitLab or GitHub and works on the fix.
86
+ - **You see what was done and what still needs you.** Live shows current work; Activity records completed runs; Monitor shows reviewed work that needs a person and work agents can handle.
87
+ - **You reach your agents the way that suits you.** Use [in-page chat](docs/dashboard/chat.md), the [OpenCode-backed TUI](docs/dashboard/tui.md), or the desktop assistant for voice and computer use.
88
+ - **Work goes to the machine that has the right tools.** Start with one host, then pair another when a job needs its tools or files.
89
+
90
+ Under the hood AgentX is a harness: the program around an AI model that gives it channels, tools, schedules and memory, and records what it did. It runs on Claude Code, Codex, OpenCode or any model API, on a machine you control.
91
+
92
+ ![AgentX Monitor showing tasks that need your attention in the current dashboard](docs/public/screenshots/monitor-only-you.png)
93
+
94
+ *The Monitor dashboard in the isolated demo: review tasks that need you, with in-page agent chat. All displayed tasks are fictional.*
95
+
96
+ ## Current state: usable, experimental, not yet stable
97
+
98
+ AgentX works and can be used today, but it is still an **experimental project, not a stable release**. There is plenty to polish and fix, especially the **Settings experience and configuration flows**. Expect rough edges and changes as people try it in real environments.
99
+
100
+ Releases ship often; see the [changelog](CHANGELOG.md) for what changed. Our priority is to learn from actual use: what works, what breaks, and what is confusing to set up or operate.
101
+
102
+ **Still missing: role-based access control (RBAC) at both mesh and agent levels.** We want to define who can access shared nodes and agents, delegate work, and perform particular actions. This would open up more possibilities for shared teams and multi-user deployments. Existing mesh authentication and tool permissions do not provide this complete role model; RBAC is planned work, not an available feature.
103
+
104
+ [Try the demo](#see-it-without-an-account), [check the requirements](docs/requirements.md), or [help us test](#help-test-and-improve-agentx).
100
105
 
101
106
  ## Describe an automation, get an automation
102
107
 
@@ -1,8 +1,8 @@
1
- import{a as F,b as L,c as U,d as N,e as O,f as H,g as j}from"./chunk-U2CKL755.js";import{b as B,c as D,d as A,e as P,g as M}from"./chunk-KXK2OKT5.js";import"./chunk-A7AVIFNF.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";import{useEffect as R,useReducer as V,useRef as G}from"react";import{Box as i,Text as o,useApp as W,useInput as J}from"ink";import{randomUUID as z}from"crypto";async function*q(e){let r=[];e.type&&r.push(`type=${encodeURIComponent(e.type)}`);let t=`${e.baseUrl.replace(/\/+$/,"")}/events${r.length?`?${r.join("&")}`:""}`,n={Accept:"text/event-stream"};e.token&&(n.Authorization=`Bearer ${e.token}`);let s=await fetch(t,{headers:n,signal:e.signal});if(!s.ok||!s.body)throw new Error(`SSE connect failed: HTTP ${s.status}`);let u=s.body.getReader(),p=new TextDecoder,y="";try{for(;;){let{done:f,value:l}=await u.read();if(f)return;y+=p.decode(l,{stream:!0});let d;for(;(d=y.indexOf(`
1
+ import{a as F,b as L,c as U,d as N,e as O,f as H,g as j}from"./chunk-U2CKL755.js";import{b as B,c as D,d as A,e as P,g as M}from"./chunk-CKIIBDGR.js";import"./chunk-4KMS3ES7.js";import"./chunk-BRK6M6LA.js";import"./chunk-XG5FRD7G.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";import{useEffect as R,useReducer as V,useRef as G}from"react";import{Box as i,Text as o,useApp as W,useInput as J}from"ink";import{randomUUID as z}from"crypto";async function*q(e){let r=[];e.type&&r.push(`type=${encodeURIComponent(e.type)}`);let t=`${e.baseUrl.replace(/\/+$/,"")}/events${r.length?`?${r.join("&")}`:""}`,n={Accept:"text/event-stream"};e.token&&(n.Authorization=`Bearer ${e.token}`);let s=await fetch(t,{headers:n,signal:e.signal});if(!s.ok||!s.body)throw new Error(`SSE connect failed: HTTP ${s.status}`);let u=s.body.getReader(),p=new TextDecoder,y="";try{for(;;){let{done:f,value:l}=await u.read();if(f)return;y+=p.decode(l,{stream:!0});let d;for(;(d=y.indexOf(`
2
2
 
3
3
  `))>=0;){let h=y.slice(0,d);y=y.slice(d+2);let m=X(h);m&&(yield m)}}}finally{try{u.releaseLock()}catch{}}}function X(e){let r="message",t="";for(let s of e.split(`
4
4
  `))s.startsWith("event: ")?r=s.slice(7):s.startsWith("data: ")&&(t=s.slice(6));if(!t)return null;let n;try{n=JSON.parse(t)}catch{n=t}return{event:r,data:n}}import{jsx as a,jsxs as c}from"react/jsx-runtime";function $(e,r){return r<=0||e<0?0:e>=r?r-1:e}function E(){return`tui:${z().slice(0,12)}`}function k(e,r){let t=[...e,r];return t.length>50&&t.splice(0,t.length-50),t}function Y(e,r){switch(r.type){case"agents":return{...e,agents:r.data,cursor:{...e.cursor,agents:$(e.cursor.agents,r.data.length)}};case"processes":return{...e,processes:r.data,cursor:{...e.cursor,processes:$(e.cursor.processes,r.data.length)}};case"crons":return{...e,crons:r.data};case"event":{let t=[r.row,...e.events];t.length>200&&(t.length=200);let n=e.channels;return r.channelTally&&(n=new Map(e.channels),n.set(r.channelTally.channel,r.channelTally)),{...e,events:t,channels:n}}case"connError":return{...e,connError:r.error};case"tick":return{...e,lastTick:Date.now()};case"focus":return{...e,focus:r.pane};case"cursor":{let t=r.pane==="agents"?e.agents.length:r.pane==="processes"?e.processes.length:e.events.length;return{...e,cursor:{...e.cursor,[r.pane]:$(e.cursor[r.pane]+r.delta,t)}}}case"bottomRight":return{...e,bottomRight:r.pane};case"chatStart":return{...e,chat:{active:!0,agentId:r.agentId,chatId:E(),history:[],text:"",status:"idle",error:null}};case"chatExit":return{...e,chat:{...e.chat,active:!1}};case"chatClear":return{...e,chat:{...e.chat,chatId:E(),history:[],text:"",status:"idle",error:null}};case"chatText":return{...e,chat:{...e.chat,text:r.text}};case"chatSubmitStart":return{...e,chat:{...e.chat,history:k(e.chat.history,r.you),text:"",status:"sending",error:null}};case"chatSubmitDone":return{...e,chat:{...e.chat,history:k(e.chat.history,r.reply),status:"idle",error:null}};case"chatSubmitError":return{...e,chat:{...e.chat,history:k(e.chat.history,{role:"error",text:r.error,at:Date.now()}),status:"idle",error:r.error}};case"chatStreamStart":{let t=k(e.chat.history,r.you),n=k(t,{role:"agent",text:"",at:Date.now(),streaming:!0,tools:[]});return{...e,chat:{...e.chat,history:n,text:"",status:"sending",error:null}}}case"chatStreamDelta":{let t=e.chat.history.slice(),n=t[t.length-1];return n?.role==="agent"&&n.streaming&&(t[t.length-1]={...n,text:n.text+r.text}),{...e,chat:{...e.chat,history:t}}}case"chatStreamThinking":{let t=e.chat.history.slice(),n=t[t.length-1];return n?.role==="agent"&&n.streaming&&(t[t.length-1]={...n,thinking:(n.thinking??"")+r.text}),{...e,chat:{...e.chat,history:t}}}case"chatStreamTool":{let t=e.chat.history.slice(),n=t[t.length-1];return n?.role==="agent"&&n.streaming&&(t[t.length-1]={...n,tools:[...n.tools??[],{name:r.name,arg:r.arg,error:r.error}]}),{...e,chat:{...e.chat,history:t}}}case"chatStreamEnd":{let t=e.chat.history.slice(),n=t[t.length-1];return n?.role==="agent"&&n.streaming&&(t[t.length-1]=r.error?{...n,streaming:!1,role:"error",text:r.error}:{...n,streaming:!1,elapsedMs:r.elapsedMs,outTokens:r.outTokens}),{...e,chat:{...e.chat,history:t,status:"idle",error:r.error??null}}}case"toast":return{...e,toast:{text:r.text,color:r.color,at:Date.now()}};case"clearToast":return{...e,toast:null}}}var _={agents:[],processes:[],crons:[],events:[],channels:new Map,connError:null,lastTick:0,focus:"agents",cursor:{agents:0,processes:0,events:0},bottomRight:"crons",chat:{active:!1,agentId:null,chatId:E(),history:[],text:"",status:"idle",error:null},toast:null};function be({conn:e,pollMs:r=3e3}){let[t,n]=V(Y,_),{exit:s}=W(),u=G(null),p=G(null),y=t.agents.map(l=>l.id),f=t.chat.active?L(t.chat.text,y,process.cwd()):null;return R(()=>{if(!t.toast)return;let l=setTimeout(()=>n({type:"clearToast"}),3500);return()=>clearTimeout(l)},[t.toast]),J((l,d)=>{if(t.chat.active){if(d.escape){n({type:"chatExit"});return}if(d.ctrl&&l==="l"){n({type:"chatClear"});return}if(d.tab){let m=U(t.chat.text,p,y,process.cwd());m!==null&&n({type:"chatText",text:m});return}if(d.backspace||d.delete){p.current=null,n({type:"chatText",text:t.chat.text.slice(0,-1)});return}if(d.ctrl||d.meta)return;let h=N(l??"",d.return,t.chat.text);if(h.kind==="paste"||h.kind==="type"){p.current=null,n({type:"chatText",text:t.chat.text+h.text});return}if(h.kind==="continue"){n({type:"chatText",text:h.buffer});return}if(h.kind==="submit"){let m=h.text.trim(),g=t.chat.agentId;if(!m||!g||t.chat.status==="sending"){n({type:"chatText",text:""});return}p.current=null;let b=Date.now(),w=t.chat.chatId;n({type:"chatStreamStart",you:{role:"you",text:m,at:b}}),(async()=>{try{let C=await M(e,g,m,{channel:"tui",chatId:w,onText:x=>n({type:"chatStreamDelta",text:x}),onThinking:x=>n({type:"chatStreamThinking",text:x}),onTool:x=>{x.status==="start"&&x.name?n({type:"chatStreamTool",name:x.name,arg:x.arg}):x.status==="result"&&x.error&&n({type:"chatStreamTool",name:x.name??"tool",error:!0})}});n({type:"chatStreamEnd",elapsedMs:Date.now()-b,outTokens:C.usage?.outputTokens,error:C.error})}catch(C){n({type:"chatStreamEnd",elapsedMs:Date.now()-b,error:C?.message||String(C)})}})();return}return}if(l==="q"||d.ctrl&&l==="c"){u.current?.abort(),s();return}if(d.tab){let h=["agents","processes","events"],m=h.indexOf(t.focus);n({type:"focus",pane:h[(m+1)%h.length]});return}if(l==="a"){n({type:"focus",pane:"agents"});return}if(l==="p"){n({type:"focus",pane:"processes"});return}if(l==="e"){n({type:"focus",pane:"events"});return}if(l==="c"){n({type:"bottomRight",pane:t.bottomRight==="crons"?"channels":"crons"});return}if(d.upArrow){n({type:"cursor",pane:t.focus,delta:-1});return}if(d.downArrow){n({type:"cursor",pane:t.focus,delta:1});return}if(d.return&&t.focus==="agents"){let h=t.agents[t.cursor.agents];if(!h){n({type:"toast",text:"no agent selected",color:"yellow"});return}n({type:"chatStart",agentId:h.id});return}if(l==="k"&&t.focus==="processes"){let h=t.processes[t.cursor.processes];if(!h){n({type:"toast",text:"no process selected",color:"yellow"});return}(async()=>{try{await P(e,h.key,"tui"),n({type:"toast",text:`killed ${h.key.agentId}/${h.key.channel}/${h.key.chatId}`,color:"green"})}catch(m){n({type:"toast",text:`kill failed: ${m?.message||m}`,color:"red"})}})();return}}),R(()=>{let l=new AbortController;u.current=l;let d=!1,h=async()=>{try{let[g,b,w]=await Promise.all([B(e,l.signal).catch(()=>[]),D(e,l.signal).catch(()=>[]),A(e,l.signal).catch(()=>[])]);if(d)return;n({type:"agents",data:g}),n({type:"processes",data:b}),n({type:"crons",data:w}),n({type:"tick"}),n({type:"connError",error:null})}catch(g){d||n({type:"connError",error:g?.message||String(g)})}};h();let m=setInterval(h,r);return()=>{d=!0,clearInterval(m),l.abort()}},[e.baseUrl,e.token,r]),R(()=>{let l=!1,d=new AbortController,h=new Map;return(async()=>{let m=500;for(;!l;){try{for await(let g of q({baseUrl:e.baseUrl,token:e.token,signal:d.signal})){let b=ae(g),w;if(g.event==="channel"&&typeof g.data?.channel=="string"){let S=h.get(g.data.channel)??{channel:g.data.channel,inbound:0,outbound:0,lastAt:0,lastPreview:""},C=S.inbound+(g.data.direction==="in"?1:0),x=S.outbound+(g.data.direction==="out"?1:0);w={channel:g.data.channel,inbound:C,outbound:x,lastAt:b.at,lastPreview:(g.data.textPreview||"").slice(0,60)},h.set(g.data.channel,w)}n({type:"event",row:b,channelTally:w}),m=500}}catch(g){if(l)return;n({type:"connError",error:`events: ${g?.message||g}`})}await new Promise(g=>setTimeout(g,m)),m=Math.min(m*2,1e4)}})(),()=>{l=!0,d.abort()}},[e.baseUrl,e.token]),c(i,{flexDirection:"column",width:"100%",children:[a(K,{conn:e,lastTick:t.lastTick,connError:t.connError,chat:t.chat}),c(i,{flexDirection:"row",flexGrow:1,children:[c(i,{flexDirection:"column",width:"50%",children:[a(v,{title:"AGENTS",focused:!t.chat.active&&t.focus==="agents",children:a(Z,{rows:t.agents,cursor:t.cursor.agents,focused:!t.chat.active&&t.focus==="agents",talkingTo:t.chat.active?t.chat.agentId:null})}),a(v,{title:"PROCESSES",focused:!t.chat.active&&t.focus==="processes",children:a(ee,{rows:t.processes,cursor:t.cursor.processes,focused:!t.chat.active&&t.focus==="processes"})})]}),t.chat.active?a(oe,{chat:t.chat,suggest:f,agents:t.agents}):c(i,{flexDirection:"column",width:"50%",children:[a(v,{title:"LIVE EVENTS",focused:t.focus==="events",children:a(ne,{rows:t.events,cursor:t.cursor.events,focused:t.focus==="events"})}),a(v,{title:t.bottomRight==="crons"?"CRONS / SCHEDULES":"CHANNELS",focused:!1,children:t.bottomRight==="crons"?a(te,{rows:t.crons}):a(re,{rows:Array.from(t.channels.values())})})]})]}),a(Q,{focus:t.focus,bottomRight:t.bottomRight,chat:t.chat,toast:t.toast})]})}function K({conn:e,lastTick:r,connError:t,chat:n}){let s=t?c(o,{color:"red",children:["\u25CF ",t]}):r===0?a(o,{color:"yellow",children:"\u25CF connecting\u2026"}):a(o,{color:"green",children:"\u25CF live"}),u=n.active?c(o,{color:"green",bold:!0,children:["CHAT @",n.agentId]}):a(o,{bold:!0,children:"agentx tui"});return c(i,{paddingX:1,justifyContent:"space-between",children:[a(i,{children:u}),a(o,{dimColor:!0,children:e.baseUrl}),a(i,{children:s})]})}function Q({focus:e,bottomRight:r,chat:t,toast:n}){let s=t.active?["[Enter] send","[Esc] exit chat","[Ctrl-L] new session"]:[`[Tab/a/p/e] focus (now: ${e})`,e==="agents"?"[Enter] chat":null,e==="processes"?"[k] kill":null,`[c] ${r==="crons"?"\u2192channels":"\u2192crons"}`,"[\u2191/\u2193] move","[q] quit"].filter(Boolean);return c(i,{paddingX:1,borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,justifyContent:"space-between",children:[a(o,{dimColor:!0,children:s.join(" \xB7 ")}),n?a(o,{color:n.color,children:n.text}):a(o,{children:" "})]})}function v({title:e,focused:r,children:t}){return c(i,{flexDirection:"column",width:"100%",borderStyle:r?"double":"single",borderColor:r?"cyan":void 0,paddingX:1,children:[c(o,{bold:!0,color:r?"cyan":"white",children:[e,r?" \u25CF":""]}),a(i,{flexDirection:"column",marginTop:1,children:t})]})}function I(e,r){return e&&r?{inverse:!0}:{}}function Z({rows:e,cursor:r,focused:t,talkingTo:n}){return e.length===0?a(o,{dimColor:!0,children:"no agents"}):a(i,{flexDirection:"column",children:e.slice(0,12).map((s,u)=>{let p=I(t,u===r),y=s.errors>0?"red":s.active>0?"yellow":"green",f=s.id===n;return c(i,{children:[a(o,{...p,color:y,children:"\u25CF"}),c(o,{...p,children:[" ",T(s.name,14)]}),c(o,{...p,children:[T(s.tier,6)," "]}),c(o,{...p,children:[s.active,"/",s.total]}),s.errors>0?c(o,{...p,color:"red",children:[" err=",s.errors]}):null,f?a(o,{color:"green",children:" \u2194 chatting"}):null]},s.id)})})}function ee({rows:e,cursor:r,focused:t}){if(e.length===0)return a(o,{dimColor:!0,children:"no live processes"});let n=Date.now();return a(i,{flexDirection:"column",children:e.slice(0,12).map((s,u)=>{let p=I(t,u===r),y=Math.max(0,Math.round((n-(s.lastTurnAt||s.spawnedAt))/1e3)),f=s.state==="dead"?"red":s.state==="warm-hot"?"green":"yellow";return c(i,{children:[a(o,{...p,color:f,children:T(s.state,10)}),a(o,{...p,children:T(s.key.agentId,12)}),a(o,{...p,children:T(s.key.channel,10)}),c(o,{...p,children:[s.turnCount,"t ",y,"s"]})]},`${s.key.agentId}-${s.key.channel}-${s.key.chatId}-${u}`)})})}function te({rows:e}){return e.length===0?a(o,{dimColor:!0,children:"no crons"}):a(i,{flexDirection:"column",children:e.slice(0,12).map(r=>{let t=r.enabled?r.consecutiveErrors>0?a(o,{color:"red",children:"err"}):a(o,{color:"green",children:"ok"}):a(o,{dimColor:!0,children:"off"}),n=r.nextRun?new Date(r.nextRun).toLocaleTimeString():"\u2014";return c(i,{children:[a(o,{children:T(r.id,16)}),a(o,{dimColor:!0,children:T(r.schedule,12)}),a(o,{children:T(n,10)}),a(i,{children:t})]},r.id)})})}function re({rows:e}){if(e.length===0)return a(o,{dimColor:!0,children:"(waiting for channel events\u2026)"});let r=[...e].sort((t,n)=>n.lastAt-t.lastAt);return a(i,{flexDirection:"column",children:r.slice(0,12).map(t=>c(i,{children:[a(o,{children:T(t.channel,12)}),c(o,{color:"cyan",children:["\u2190",T(String(t.inbound),4)]}),c(o,{color:"magenta",children:["\u2192",T(String(t.outbound),4)]}),a(o,{dimColor:!0,children:t.lastPreview})]},t.channel))})}function ne({rows:e,cursor:r,focused:t}){return e.length===0?a(o,{dimColor:!0,children:"(waiting for events\u2026)"}):a(i,{flexDirection:"column",children:e.slice(0,18).map((n,s)=>{let u=I(t,s===r);return c(i,{children:[a(o,{...u,dimColor:!0,children:new Date(n.at).toLocaleTimeString().padEnd(10)}),a(o,{...u,color:ce(n.kind),children:T(n.kind,8)}),a(o,{...u,children:n.line})]},`${n.at}-${s}`)})})}function oe({chat:e,suggest:r,agents:t}){let n=e.history.slice(-14),s=t.find(f=>f.id===e.agentId),u=H(s?.tier??"",s?.model),p=e.status==="sending"?[...e.history].reverse().find(f=>f.role==="agent"&&f.streaming):void 0,y=e.status==="sending"?a(O,{startedAt:p?.at??Date.now(),phase:p?.text?"responding":"thinking",indent:""}):e.error?c(o,{color:"red",children:["\u25CF ",e.error]}):a(o,{dimColor:!0,children:"\u25CF ready"});return c(i,{flexDirection:"column",width:"50%",borderStyle:"double",borderColor:"green",paddingX:1,children:[c(i,{justifyContent:"space-between",children:[c(o,{bold:!0,color:"green",children:["CHAT \xB7 @",e.agentId]}),a(i,{children:y})]}),c(o,{children:[c(o,{color:u.color,bold:!0,children:[u.glyph," ",u.label]}),s?.model?c(o,{dimColor:!0,children:[" ",j(s.model)]}):null,c(o,{dimColor:!0,children:[" \xB7 ",e.chatId]})]}),a(i,{flexDirection:"column",flexGrow:1,marginTop:1,children:n.length===0?a(o,{dimColor:!0,children:"(type a message and press Enter \u2014 Esc exits, Ctrl-L starts fresh)"}):n.map((f,l)=>a(se,{turn:f,agentId:e.agentId},`${f.at}-${l}`))}),r?c(o,{dimColor:!0,children:[a(o,{color:"cyan",children:"\u21B9"})," ",r.items.slice(0,5).map((f,l)=>l===0?a(o,{color:"cyan",children:f},l):c(o,{children:[" ",f]},l))]}):null,c(i,{children:[a(o,{color:"cyan",children:"you \u203A "}),a(o,{children:e.text}),a(o,{inverse:!0,children:" "})]})]})}function se({turn:e,agentId:r}){if(e.role==="you")return c(i,{flexDirection:"column",marginBottom:1,children:[a(o,{color:"cyan",children:"you"}),e.text.split(`
5
5
  `).map((s,u)=>c(o,{children:[" ",s]},u))]});if(e.role==="error")return c(i,{flexDirection:"column",marginBottom:1,children:[a(o,{color:"red",children:"error"}),c(o,{color:"red",children:[" ",e.text]})]});let t=e.elapsedMs!=null?` \xB7 ${(e.elapsedMs/1e3).toFixed(1)}s${e.outTokens!=null?`, ${e.outTokens} tok`:""}`:e.streaming?" \xB7 \u2026":"",n=F(e.text,58,{balance:e.streaming});return c(i,{flexDirection:"column",marginBottom:1,children:[c(o,{color:"green",children:["@",r??"agent",a(o,{dimColor:!0,children:t})]}),e.thinking?e.thinking.split(`
6
6
  `).filter(s=>s.trim()).slice(-2).map((s,u)=>c(o,{dimColor:!0,italic:!0,children:[" ",s]},`th${u}`)):null,(e.tools??[]).map((s,u)=>c(o,{color:s.error?"red":"green",children:[" \u25CF ",c(o,{bold:!s.error,dimColor:s.error,children:[s.name,s.arg?c(o,{dimColor:!0,children:["(",s.arg,")"]}):null,s.error?" failed":""]})]},`tool${u}`)),n.split(`
7
7
  `).slice(0,14).map((s,u)=>c(o,{children:[" ",s]},u))]})}function ae(e){let r=e.data??{},t=typeof r.at=="string"||typeof r.at=="number"?new Date(r.at).getTime():Date.now(),n="";switch(e.event){case"run":n=`${r.phase??""} ${r.workflowId??""} ${(r.runId??"").slice(0,8)} ${r.nodeId??""}`.trim();break;case"task":n=`${r.phase??""} ${r.workflowId??""} ${Array.isArray(r.assignedTo)?r.assignedTo.join(","):""} ${r.title?`"${r.title}"`:""}`.trim();break;case"signal":n=`${r.name??""} (${r.scope??""}) ${r.workflowId??""}`.trim();break;case"mesh":n=`${r.peer??""} ${r.healthy?"healthy":"lost"} ${r.delta??""}`.trim();break;case"channel":{n=`${r.direction==="in"?"\u2190":"\u2192"} ${r.channel??""}:${r.chatId??""} ${r.textPreview??""}`.trim();break}case"status":n=`node=${r.node??""} agents=${r.agents??0} active=${(r.active??[]).length}`;break;default:n=typeof r=="string"?r:JSON.stringify(r).slice(0,80)}return{at:Number.isFinite(t)?t:Date.now(),kind:e.event,line:n}}function ce(e){switch(e){case"run":return"cyan";case"task":return"magenta";case"signal":return"green";case"mesh":return"blue";case"channel":return"yellow";default:return"white"}}function T(e,r){let t=(e??"").toString();return t.length>=r?t.slice(0,r-1)+" ":t+" ".repeat(r-t.length)}export{be as App};
8
- //# sourceMappingURL=App-LFKP4IY5.js.map
8
+ //# sourceMappingURL=App-MXMKX57A.js.map
@@ -1,7 +1,7 @@
1
- import{a as Y,b as Z,c as _,d as ee,e as te,f as ne,g as re}from"./chunk-U2CKL755.js";import{b as Q,g as X}from"./chunk-KXK2OKT5.js";import"./chunk-A7AVIFNF.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";import{useCallback as oe,useMemo as H,useRef as P,useState as k}from"react";import{Box as g,Text as t,useApp as he,useInput as xe,useStdout as Te}from"ink";import{randomUUID as se}from"crypto";var m={accent:"cyan",agent:"green",working:"magenta",error:"red",muted:"gray"},q="\u25C7 agentx",F="\u258C";import{jsx as c,jsxs as o}from"react/jsx-runtime";var ie="/help /agent <id> /agents /clear /who /exit",be=[{cmd:"/agent",desc:"switch the target agent (/agent <id>)"},{cmd:"/agents",desc:"list registered agents"},{cmd:"/clear",desc:"start a fresh session"},{cmd:"/who",desc:"show agent + chat id"},{cmd:"/help",desc:"list commands"},{cmd:"/exit",desc:"quit the chat"}];function Pe({conn:n,agentId:p,channel:f,chatId:a,agents:h}){let{exit:w}=he(),{stdout:O}=Te(),V=Math.max(40,Math.min((O?.columns||80)-4,100)),[z,U]=k([]),[$,S]=k(null),[T,le]=k(p),[A,ae]=k(h),[E,ue]=k(a),[y,x]=k(""),[J,de]=k(""),W=P([]),u=P(-1),M=P(null),R=P(null),v=$?.live??!1,j=H(()=>Z(y,A.map(s=>s.id),process.cwd()),[y,A]),N=H(()=>{let s=/^\/(\w*)$/.exec(y);if(!s)return null;let e=be.filter(r=>r.cmd.slice(1).startsWith(s[1].toLowerCase()));return e.length?e:null},[y]),b=s=>de(s),K=oe(s=>{let e=se().slice(0,8),r=Date.now(),i=new AbortController;R.current=i;let d={id:e,you:s,agentId:T,segs:[],live:!0,startedAt:r};S({...d});let L=()=>S({...d,segs:d.segs.map(C=>({...C}))});(async()=>{try{let C=await X(n,T,s,{channel:f,chatId:E,signal:i.signal,onText:l=>{let I=d.segs[d.segs.length-1];I&&I.type==="text"?I.content=(I.content??"")+l:d.segs.push({type:"text",content:l}),L()},onThinking:l=>{d.thinking=(d.thinking??"")+l,L()},onTool:l=>{l.status==="start"&&l.name?(d.segs.push({type:"tool",name:l.name,arg:l.arg}),L()):l.status==="result"&&l.error&&(d.segs.push({type:"tool",name:l.name??"tool",error:!0}),L())}});U(l=>[...l,{...d,live:!1,elapsedMs:Date.now()-r,outTokens:C.usage?.outputTokens,error:C.error}]),S(null)}catch(C){let l=i.signal.aborted||C?.name==="AbortError";U(I=>[...I,{...d,live:!1,elapsedMs:Date.now()-r,interrupted:l,error:l?void 0:C?.message||String(C)}]),S(null)}finally{R.current===i&&(R.current=null)}})()},[n,T,f,E]),me=oe(s=>{let e=s.trim();if(e){if(W.current.push(e),u.current=-1,e==="/exit"||e==="/quit"){w();return}if(e==="/help"){b(ie);return}if(e==="/who"){b(`@${T} \xB7 chatId=${E} \xB7 channel=${f}`);return}if(e==="/clear"){let r=`chat-cli:${se().slice(0,12)}`;ue(r),U([]),b(`fresh chatId=${r} (warm process dropped)`);return}if(e==="/agents"){Q(n).then(r=>{ae(r),b(r.map(i=>i.id===T?`[${i.id}]`:i.id).join(" "))}).catch(r=>b(`failed to list agents: ${r?.message||r}`));return}if(e.startsWith("/agent ")){let r=e.slice(7).replace(/^@/,"").trim();if(!r){b("usage: /agent <id>");return}if(!A.find(i=>i.id===r)){b(`unknown agent: @${r}`);return}le(r),b(`now talking to @${r}`);return}if(e.startsWith("/")){b(`unknown command \xB7 ${ie}`);return}K(e)}},[n,T,A,f,E,w,K]);xe((s,e)=>{if(e.ctrl&&s==="c"){w();return}if(e.escape){if(v&&R.current){R.current.abort();return}w();return}if(e.tab){if(N){x(N[0].cmd+" ");return}let i=_(y,M,A.map(d=>d.id),process.cwd());i!==null&&(x(i),u.current=-1);return}if(e.upArrow){let i=W.current;if(!i.length)return;u.current=u.current<0?i.length-1:Math.max(0,u.current-1),x(i[u.current]??"");return}if(e.downArrow){let i=W.current;if(u.current<0)return;if(u.current=u.current+1,u.current>=i.length){u.current=-1,x("");return}x(i[u.current]??"");return}if(e.backspace||e.delete){M.current=null,x(i=>i.slice(0,-1));return}if(e.ctrl||e.meta)return;let r=ee(s??"",e.return,y);switch(r.kind){case"paste":M.current=null,x(i=>i+r.text),u.current=-1;return;case"type":M.current=null,x(i=>i+r.text),u.current=-1;return;case"continue":x(r.buffer);return;case"submit":if(v)return;M.current=null,x(""),me(r.text);return;case"none":return}});let G=v?m.working:m.accent,ge=y.length?y.split(`
1
+ import{a as Y,b as Z,c as _,d as ee,e as te,f as ne,g as re}from"./chunk-U2CKL755.js";import{b as Q,g as X}from"./chunk-CKIIBDGR.js";import"./chunk-4KMS3ES7.js";import"./chunk-BRK6M6LA.js";import"./chunk-XG5FRD7G.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";import{useCallback as oe,useMemo as H,useRef as P,useState as k}from"react";import{Box as g,Text as t,useApp as he,useInput as xe,useStdout as Te}from"ink";import{randomUUID as se}from"crypto";var m={accent:"cyan",agent:"green",working:"magenta",error:"red",muted:"gray"},q="\u25C7 agentx",F="\u258C";import{jsx as c,jsxs as o}from"react/jsx-runtime";var ie="/help /agent <id> /agents /clear /who /exit",be=[{cmd:"/agent",desc:"switch the target agent (/agent <id>)"},{cmd:"/agents",desc:"list registered agents"},{cmd:"/clear",desc:"start a fresh session"},{cmd:"/who",desc:"show agent + chat id"},{cmd:"/help",desc:"list commands"},{cmd:"/exit",desc:"quit the chat"}];function Pe({conn:n,agentId:p,channel:f,chatId:a,agents:h}){let{exit:w}=he(),{stdout:O}=Te(),V=Math.max(40,Math.min((O?.columns||80)-4,100)),[z,U]=k([]),[$,S]=k(null),[T,le]=k(p),[A,ae]=k(h),[E,ue]=k(a),[y,x]=k(""),[J,de]=k(""),W=P([]),u=P(-1),M=P(null),R=P(null),v=$?.live??!1,j=H(()=>Z(y,A.map(s=>s.id),process.cwd()),[y,A]),N=H(()=>{let s=/^\/(\w*)$/.exec(y);if(!s)return null;let e=be.filter(r=>r.cmd.slice(1).startsWith(s[1].toLowerCase()));return e.length?e:null},[y]),b=s=>de(s),K=oe(s=>{let e=se().slice(0,8),r=Date.now(),i=new AbortController;R.current=i;let d={id:e,you:s,agentId:T,segs:[],live:!0,startedAt:r};S({...d});let L=()=>S({...d,segs:d.segs.map(C=>({...C}))});(async()=>{try{let C=await X(n,T,s,{channel:f,chatId:E,signal:i.signal,onText:l=>{let I=d.segs[d.segs.length-1];I&&I.type==="text"?I.content=(I.content??"")+l:d.segs.push({type:"text",content:l}),L()},onThinking:l=>{d.thinking=(d.thinking??"")+l,L()},onTool:l=>{l.status==="start"&&l.name?(d.segs.push({type:"tool",name:l.name,arg:l.arg}),L()):l.status==="result"&&l.error&&(d.segs.push({type:"tool",name:l.name??"tool",error:!0}),L())}});U(l=>[...l,{...d,live:!1,elapsedMs:Date.now()-r,outTokens:C.usage?.outputTokens,error:C.error}]),S(null)}catch(C){let l=i.signal.aborted||C?.name==="AbortError";U(I=>[...I,{...d,live:!1,elapsedMs:Date.now()-r,interrupted:l,error:l?void 0:C?.message||String(C)}]),S(null)}finally{R.current===i&&(R.current=null)}})()},[n,T,f,E]),me=oe(s=>{let e=s.trim();if(e){if(W.current.push(e),u.current=-1,e==="/exit"||e==="/quit"){w();return}if(e==="/help"){b(ie);return}if(e==="/who"){b(`@${T} \xB7 chatId=${E} \xB7 channel=${f}`);return}if(e==="/clear"){let r=`chat-cli:${se().slice(0,12)}`;ue(r),U([]),b(`fresh chatId=${r} (warm process dropped)`);return}if(e==="/agents"){Q(n).then(r=>{ae(r),b(r.map(i=>i.id===T?`[${i.id}]`:i.id).join(" "))}).catch(r=>b(`failed to list agents: ${r?.message||r}`));return}if(e.startsWith("/agent ")){let r=e.slice(7).replace(/^@/,"").trim();if(!r){b("usage: /agent <id>");return}if(!A.find(i=>i.id===r)){b(`unknown agent: @${r}`);return}le(r),b(`now talking to @${r}`);return}if(e.startsWith("/")){b(`unknown command \xB7 ${ie}`);return}K(e)}},[n,T,A,f,E,w,K]);xe((s,e)=>{if(e.ctrl&&s==="c"){w();return}if(e.escape){if(v&&R.current){R.current.abort();return}w();return}if(e.tab){if(N){x(N[0].cmd+" ");return}let i=_(y,M,A.map(d=>d.id),process.cwd());i!==null&&(x(i),u.current=-1);return}if(e.upArrow){let i=W.current;if(!i.length)return;u.current=u.current<0?i.length-1:Math.max(0,u.current-1),x(i[u.current]??"");return}if(e.downArrow){let i=W.current;if(u.current<0)return;if(u.current=u.current+1,u.current>=i.length){u.current=-1,x("");return}x(i[u.current]??"");return}if(e.backspace||e.delete){M.current=null,x(i=>i.slice(0,-1));return}if(e.ctrl||e.meta)return;let r=ee(s??"",e.return,y);switch(r.kind){case"paste":M.current=null,x(i=>i+r.text),u.current=-1;return;case"type":M.current=null,x(i=>i+r.text),u.current=-1;return;case"continue":x(r.buffer);return;case"submit":if(v)return;M.current=null,x(""),me(r.text);return;case"none":return}});let G=v?m.working:m.accent,ge=y.length?y.split(`
2
2
  `):[""],B=A.find(s=>s.id===T),D=ne(B?.tier??"",B?.model),pe=O?.rows||24,fe=z.slice(-40);return o(g,{flexDirection:"column",height:pe,children:[o(g,{flexDirection:"column",flexGrow:1,justifyContent:"flex-end",overflow:"hidden",children:[z.length===0&&!$?o(g,{flexDirection:"column",children:[o(t,{children:[c(t,{color:m.accent,bold:!0,children:q}),c(t,{dimColor:!0,children:" \u2014 chat with "}),o(t,{color:m.accent,children:["@",T]}),c(t,{dimColor:!0,children:" via "}),o(t,{color:D.color,bold:!0,children:[D.glyph," ",D.label]}),B?.model?o(t,{dimColor:!0,children:[" (",B.model,")"]}):null]}),c(t,{dimColor:!0,children:"streaming \xB7 markdown \xB7 tools \xB7 type a message, or / for commands"})]}):null,fe.map(s=>c(ce,{turn:s,width:V},s.id)),$?c(ce,{turn:$,width:V}):null]}),N?c(g,{flexDirection:"column",marginTop:1,children:N.map((s,e)=>o(g,{children:[c(t,{color:e===0?m.accent:m.muted,bold:e===0,children:s.cmd.padEnd(10)}),c(t,{dimColor:!0,children:s.desc})]},s.cmd))}):j?o(g,{marginTop:1,children:[c(t,{color:m.accent,children:"\u21B9 "}),j.items.map((s,e)=>o(t,{color:e===0?m.accent:m.muted,children:[s,e<j.items.length-1?" ":""]},e))]}):J?c(g,{marginTop:1,children:c(t,{dimColor:!0,children:J})}):null,c(g,{borderStyle:"single",borderColor:G,borderLeft:!1,borderRight:!1,borderDimColor:!v,width:"100%",children:c(g,{flexDirection:"column",width:"100%",children:ge.map((s,e,r)=>o(g,{children:[c(t,{color:G,bold:!0,children:e===0?"\u203A ":" "}),c(t,{children:s}),e===r.length-1&&!v?c(t,{color:G,children:"\u258F"}):null]},e))})}),o(g,{justifyContent:"space-between",children:[o(t,{children:[c(t,{color:m.accent,bold:!0,children:q}),o(t,{dimColor:!0,children:[" \xB7 @",T," \xB7 "]}),o(t,{color:D.color,bold:!0,children:[D.glyph," ",D.label]}),B?.model?o(t,{dimColor:!0,children:[" ",re(B.model)]}):null]}),o(t,{dimColor:!0,children:["\u21B5 send / cmds @ mention esc ",v?"stop":"exit"]})]})]})}function ce({turn:n,width:p}){let f=H(()=>ye(n,p),[n,p]),a=n.segs.some(h=>h.type==="text"&&h.content);return o(g,{flexDirection:"column",marginBottom:1,children:[o(t,{color:m.accent,bold:!0,children:[F," you"]}),n.you.split(`
3
3
  `).map((h,w)=>o(t,{color:"white",children:[" ",h]},`u${w}`)),o(t,{color:m.agent,bold:!0,children:[F," ",n.agentId??"agent"]}),n.thinking?c(g,{flexDirection:"column",children:we(n.thinking,n.live?3:2).map((h,w)=>o(t,{dimColor:!0,italic:!0,children:[" ",h]},`th${w}`))}):null,f,n.live?c(te,{startedAt:n.startedAt,phase:a?"responding":"thinking",hint:"esc to interrupt"}):n.interrupted?o(t,{dimColor:!0,children:[" \u2298 interrupted \xB7 ",(n.elapsedMs/1e3).toFixed(1),"s"]}):n.error?o(t,{color:"red",children:[" \u2717 ",n.error]}):n.elapsedMs!=null?o(t,{dimColor:!0,children:[" \xB7 ",(n.elapsedMs/1e3).toFixed(1),"s",n.outTokens!=null?`, ${n.outTokens} tok`:""]}):null]})}function we(n,p){return n.split(`
4
4
  `).filter(a=>a.trim()).slice(-p)}function ye(n,p){let f=[];return n.segs.forEach((a,h)=>{a.type==="tool"?f.push(o(t,{color:a.error?"red":"green",children:[" ","\u25CF ",o(t,{bold:!a.error,dimColor:a.error,children:[a.name,a.arg?o(t,{dimColor:!0,children:["(",a.arg,")"]}):null,a.error?" failed":""]})]},h)):a.content&&f.push(c(t,{children:Ce(Y(a.content,p,{balance:n.live}))},h))}),f}function Ce(n){return n.split(`
5
5
  `).map(p=>p.length?" "+p:p).join(`
6
6
  `)}export{Pe as ChatApp};
7
- //# sourceMappingURL=ChatApp-SSVWKETD.js.map
7
+ //# sourceMappingURL=ChatApp-PSKTL3PQ.js.map
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-S5CNKZBP.js";import"./chunk-XWQ3ZEIZ.js";import"./chunk-XMU63PSI.js";import"./chunk-6QZKQUAT.js";import"./chunk-IERW7MLU.js";import"./chunk-WPNRDEHW.js";import"./chunk-MWNCS57L.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-ECY6WMZP.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-6TURWSMN.js";import"./chunk-BERWTVG2.js";import"./chunk-QOYAX2FT.js";import"./chunk-6QLRRSKU.js";import"./chunk-7I7IEX4S.js";import"./chunk-A7AVIFNF.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{i as JUDGE_ENTRY_CHARS,e as WEAK_CITATION,j as buildJudgePrompt,l as buildScorecard,f as checkArticle,n as envelopeUsage,h as findDuplicates,k as parseJudgeReply,b as pickSample,m as renderScorecard,a as seededRandom,o as summariseRuns,d as termOverlap,c as terms,g as uncitedWithFacts};
2
- //# sourceMappingURL=absorb-eval-IPPP2RZV.js.map
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-X45QYAZ2.js";import"./chunk-A75ADFHR.js";import"./chunk-AYYWQOGG.js";import"./chunk-6QZKQUAT.js";import"./chunk-BH46UJ6V.js";import"./chunk-WPNRDEHW.js";import"./chunk-MWNCS57L.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-Y3DUSCYH.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-6TURWSMN.js";import"./chunk-BERWTVG2.js";import"./chunk-QOYAX2FT.js";import"./chunk-6QLRRSKU.js";import"./chunk-7I7IEX4S.js";import"./chunk-4KMS3ES7.js";import"./chunk-BRK6M6LA.js";import"./chunk-XG5FRD7G.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{i as JUDGE_ENTRY_CHARS,e as WEAK_CITATION,j as buildJudgePrompt,l as buildScorecard,f as checkArticle,n as envelopeUsage,h as findDuplicates,k as parseJudgeReply,b as pickSample,m as renderScorecard,a as seededRandom,o as summariseRuns,d as termOverlap,c as terms,g as uncitedWithFacts};
2
+ //# sourceMappingURL=absorb-eval-NACNM4PW.js.map
@@ -1,2 +1,2 @@
1
- import{A as a,B as b,C as c}from"./chunk-KKTHRSSJ.js";import"./chunk-SFQUP3BP.js";import"./chunk-QOYAX2FT.js";import"./chunk-6QLRRSKU.js";import"./chunk-7I7IEX4S.js";import"./chunk-JHCI6XCJ.js";import"./chunk-DSYKYZMT.js";import"./chunk-QIJLFPWE.js";export{a as createAgentContext,b as generate,c as generateStream};
2
- //# sourceMappingURL=agent-SNNE24LT.js.map
1
+ import{A as a,B as b,C as c}from"./chunk-OQWMP5ZD.js";import"./chunk-SFQUP3BP.js";import"./chunk-QOYAX2FT.js";import"./chunk-6QLRRSKU.js";import"./chunk-7I7IEX4S.js";import"./chunk-JHCI6XCJ.js";import"./chunk-DSYKYZMT.js";import"./chunk-QIJLFPWE.js";export{a as createAgentContext,b as generate,c as generateStream};
2
+ //# sourceMappingURL=agent-2RYXBN55.js.map