moi-computer 0.13.1-next.4 → 0.14.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 (666) hide show
  1. package/README.md +1 -1
  2. package/bin/moi.mjs +10 -6
  3. package/dist/{chunk-k32585ne.js → chunk-828s864r.js} +61 -61
  4. package/dist/chunk-9ffaaaw3.css +1 -0
  5. package/dist/chunk-gh11h6dc.js +2 -0
  6. package/dist/chunk-hhgsmxsq.js +1 -0
  7. package/dist/chunk-ht9zmff2.js +5 -0
  8. package/dist/{chunk-0t8m1ehd.js → chunk-jqa4c92z.js} +2 -2
  9. package/dist/{chunk-qtkv7hp8.js → chunk-kkhswjz8.js} +2 -2
  10. package/dist/{chunk-wjbejzek.js → chunk-nqh3kx2x.js} +1 -1
  11. package/dist/chunk-rb2vsqvb.js +1 -0
  12. package/dist/{chunk-c8g5x288.js → chunk-t22yw8s6.js} +1 -1
  13. package/dist/chunk-yv6n9e3z.js +72 -0
  14. package/dist/dot-2bdkpg3k.png +0 -0
  15. package/dist/duet-3ab8xyzd.png +0 -0
  16. package/dist/grok-bot-yv07qj9f.png +0 -0
  17. package/dist/index.html +1 -1
  18. package/dist/instinct-ypmq6t0w.png +0 -0
  19. package/dist/muse-qr7zwsvf.png +0 -0
  20. package/package.json +39 -40
  21. package/runtime/applets/chunk-bzxakh65.js +2 -0
  22. package/runtime/applets/chunk-qhjskz2m.js +2 -0
  23. package/runtime/applets/collab.js +1 -0
  24. package/runtime/applets/moi.js +1 -0
  25. package/runtime/applets/rpc.js +2 -0
  26. package/runtime/assets/shadcn.css +629 -0
  27. package/runtime/assets/tw-animate.css +1 -0
  28. package/runtime/build-worker-entry.js +2 -0
  29. package/runtime/chunk-00rk365r.js +83 -0
  30. package/runtime/chunk-4wj1jzhr.js +3 -0
  31. package/runtime/chunk-5egvk1rz.js +3 -0
  32. package/runtime/chunk-7c0zbz74.js +3 -0
  33. package/runtime/chunk-8fvgvm56.js +2 -0
  34. package/runtime/chunk-c3qyet60.js +128 -0
  35. package/runtime/chunk-ewc55jga.js +32623 -0
  36. package/runtime/chunk-gbkjshyt.js +26 -0
  37. package/runtime/chunk-ggphq7nk.js +66 -0
  38. package/runtime/chunk-h2bwhk81.js +3 -0
  39. package/runtime/chunk-hjzfk1cr.js +3 -0
  40. package/runtime/chunk-j0nd7kw0.js +52 -0
  41. package/runtime/chunk-jb63ns1z.js +2 -0
  42. package/runtime/chunk-k049dtaq.js +3 -0
  43. package/runtime/chunk-kjp60rqs.js +3 -0
  44. package/runtime/chunk-q06m17nb.js +3 -0
  45. package/runtime/chunk-r5s8rm8n.js +3 -0
  46. package/runtime/chunk-sdyqhxe1.js +10 -0
  47. package/runtime/chunk-w1fx9tsc.js +3 -0
  48. package/runtime/chunk-w6ksnv8y.js +2 -0
  49. package/runtime/chunk-wvarpvem.js +78 -0
  50. package/runtime/chunk-zm7k0v1c.js +3 -0
  51. package/runtime/chunk-zwvtkb81.js +139 -0
  52. package/runtime/cli.js +246 -0
  53. package/runtime/functions-worker.js +2 -0
  54. package/runtime/gateway-client.js +2 -0
  55. package/runtime/third-party-notices.txt +6830 -0
  56. package/runtime/worker.js +2 -0
  57. package/runtime/xdg-open +1267 -0
  58. package/bunfig.toml +0 -7
  59. package/client/AGENTS.md +0 -40
  60. package/client/api/app-config.ts +0 -58
  61. package/client/api/http.ts +0 -44
  62. package/client/api/query-client.ts +0 -5
  63. package/client/api/query-options.ts +0 -6
  64. package/client/api/workspace-keys.ts +0 -18
  65. package/client/app/app-provider.tsx +0 -39
  66. package/client/app/app-router.tsx +0 -57
  67. package/client/app/routes/home-route.tsx +0 -27
  68. package/client/app/routes/onboarding-route.tsx +0 -11
  69. package/client/app/routes/settings-route.tsx +0 -10
  70. package/client/app/routes/workspace-registration.tsx +0 -68
  71. package/client/app/routes/workspace-route.tsx +0 -127
  72. package/client/app/shell/sidebar-layout.tsx +0 -247
  73. package/client/assets/claude.svg +0 -3
  74. package/client/assets/favicon.png +0 -0
  75. package/client/assets/floppy-disk.webp +0 -0
  76. package/client/assets/hermes.png +0 -0
  77. package/client/assets/mcp/.gitkeep +0 -0
  78. package/client/assets/mcp/airtable.png +0 -0
  79. package/client/assets/mcp/apollo.png +0 -0
  80. package/client/assets/mcp/asana.png +0 -0
  81. package/client/assets/mcp/atlassian.png +0 -0
  82. package/client/assets/mcp/box.png +0 -0
  83. package/client/assets/mcp/chrome.svg +0 -33
  84. package/client/assets/mcp/clickup.png +0 -0
  85. package/client/assets/mcp/cloudflare.png +0 -0
  86. package/client/assets/mcp/context7.png +0 -0
  87. package/client/assets/mcp/datadog.png +0 -0
  88. package/client/assets/mcp/discord.png +0 -0
  89. package/client/assets/mcp/dropbox.png +0 -0
  90. package/client/assets/mcp/elevenlabs.png +0 -0
  91. package/client/assets/mcp/exa.png +0 -0
  92. package/client/assets/mcp/figma.png +0 -0
  93. package/client/assets/mcp/firecrawl.png +0 -0
  94. package/client/assets/mcp/github.png +0 -0
  95. package/client/assets/mcp/gitlab.png +0 -0
  96. package/client/assets/mcp/gmail.png +0 -0
  97. package/client/assets/mcp/googlecalendar.png +0 -0
  98. package/client/assets/mcp/googledrive.png +0 -0
  99. package/client/assets/mcp/grafana.png +0 -0
  100. package/client/assets/mcp/granola.png +0 -0
  101. package/client/assets/mcp/hubspot.png +0 -0
  102. package/client/assets/mcp/huggingface.png +0 -0
  103. package/client/assets/mcp/intercom.png +0 -0
  104. package/client/assets/mcp/linear.png +0 -0
  105. package/client/assets/mcp/monday.png +0 -0
  106. package/client/assets/mcp/mongodb.png +0 -0
  107. package/client/assets/mcp/neon.png +0 -0
  108. package/client/assets/mcp/notion.png +0 -0
  109. package/client/assets/mcp/paper.png +0 -0
  110. package/client/assets/mcp/paypal.png +0 -0
  111. package/client/assets/mcp/perplexity.png +0 -0
  112. package/client/assets/mcp/postgresql.png +0 -0
  113. package/client/assets/mcp/posthog.png +0 -0
  114. package/client/assets/mcp/puppeteer.png +0 -0
  115. package/client/assets/mcp/railway.png +0 -0
  116. package/client/assets/mcp/redis.png +0 -0
  117. package/client/assets/mcp/salesforce.png +0 -0
  118. package/client/assets/mcp/sentry.png +0 -0
  119. package/client/assets/mcp/shopify.png +0 -0
  120. package/client/assets/mcp/slack.png +0 -0
  121. package/client/assets/mcp/snowflake.png +0 -0
  122. package/client/assets/mcp/stripe.png +0 -0
  123. package/client/assets/mcp/supabase.png +0 -0
  124. package/client/assets/mcp/telegram.png +0 -0
  125. package/client/assets/mcp/twilio.png +0 -0
  126. package/client/assets/mcp/vercel.png +0 -0
  127. package/client/assets/mcp/zapier.png +0 -0
  128. package/client/assets/moi-logo.svg +0 -11
  129. package/client/assets/openai.svg +0 -1
  130. package/client/assets/openclaw.svg +0 -22
  131. package/client/assets.d.ts +0 -14
  132. package/client/components/shared/agent-blobatar.tsx +0 -93
  133. package/client/components/shared/bottom-panel.tsx +0 -65
  134. package/client/components/shared/composer.tsx +0 -125
  135. package/client/components/shared/led-logo.tsx +0 -181
  136. package/client/components/shared/panel-header.tsx +0 -16
  137. package/client/components/shared/reorderable-list.tsx +0 -204
  138. package/client/components/shared/screen-shell.tsx +0 -23
  139. package/client/components/shared/ultrafast-icon.tsx +0 -61
  140. package/client/components/shared/workspace-icon.tsx +0 -83
  141. package/client/components/ui/alert-dialog.tsx +0 -1
  142. package/client/components/ui/button.tsx +0 -1
  143. package/client/components/ui/checkbox.tsx +0 -1
  144. package/client/components/ui/collapsible.tsx +0 -1
  145. package/client/components/ui/dialog.tsx +0 -1
  146. package/client/components/ui/dropdown-menu.tsx +0 -1
  147. package/client/components/ui/hover-card.tsx +0 -1
  148. package/client/components/ui/inline-input.tsx +0 -84
  149. package/client/components/ui/input.tsx +0 -1
  150. package/client/components/ui/popover.tsx +0 -1
  151. package/client/components/ui/resizable.tsx +0 -1
  152. package/client/components/ui/skeleton.tsx +0 -1
  153. package/client/components/ui/slider.tsx +0 -1
  154. package/client/components/ui/spinner.tsx +0 -1
  155. package/client/components/ui/switch.tsx +0 -1
  156. package/client/components/ui/tabs.tsx +0 -1
  157. package/client/components/ui/textarea.tsx +0 -1
  158. package/client/components/ui/toast.tsx +0 -220
  159. package/client/components/ui/tooltip.tsx +0 -1
  160. package/client/dev/index.html +0 -43
  161. package/client/dev/index.ts +0 -15
  162. package/client/externalize-react.ts +0 -41
  163. package/client/features/account/account-menu.tsx +0 -96
  164. package/client/features/account/account-provider.tsx +0 -93
  165. package/client/features/account/account-test-utils.tsx +0 -310
  166. package/client/features/account/api.ts +0 -67
  167. package/client/features/account/profile-actions.ts +0 -29
  168. package/client/features/app-settings/api.ts +0 -33
  169. package/client/features/app-settings/avatar-upload.tsx +0 -62
  170. package/client/features/app-settings/general-settings.tsx +0 -39
  171. package/client/features/app-settings/profile-settings.tsx +0 -105
  172. package/client/features/app-settings/settings-page.tsx +0 -45
  173. package/client/features/app-settings/settings-section.tsx +0 -26
  174. package/client/features/applets/api.ts +0 -38
  175. package/client/features/applets/applet-cache.ts +0 -95
  176. package/client/features/applets/applet-container.tsx +0 -33
  177. package/client/features/applets/applet-log.ts +0 -81
  178. package/client/features/applets/applet-runtime.ts +0 -325
  179. package/client/features/applets/applet-styles.ts +0 -81
  180. package/client/features/applets/applet-thumbnail.ts +0 -294
  181. package/client/features/applets/use-applet.ts +0 -210
  182. package/client/features/applets/widget-error-boundary.tsx +0 -62
  183. package/client/features/applets/widget-shell.tsx +0 -56
  184. package/client/features/chat/applet-chat-intents.ts +0 -173
  185. package/client/features/chat/chat-panel.tsx +0 -326
  186. package/client/features/chat/chat-popup.tsx +0 -175
  187. package/client/features/chat/chat-send.ts +0 -259
  188. package/client/features/chat/chat-store.ts +0 -328
  189. package/client/features/chat/composer/attachments/attachment-chip.tsx +0 -99
  190. package/client/features/chat/composer/attachments/draft-attachments.ts +0 -185
  191. package/client/features/chat/composer/attachments/drawing-attachment-chip.tsx +0 -37
  192. package/client/features/chat/composer/attachments/file-attachment-chip.tsx +0 -22
  193. package/client/features/chat/composer/attachments/text-attachment-chip.tsx +0 -11
  194. package/client/features/chat/composer/attachments/types.ts +0 -25
  195. package/client/features/chat/composer/attachments/uploads.ts +0 -26
  196. package/client/features/chat/composer/banners/composer-banner.tsx +0 -16
  197. package/client/features/chat/composer/banners/error-banner.tsx +0 -36
  198. package/client/features/chat/composer/banners/skill-update-banner.tsx +0 -93
  199. package/client/features/chat/composer/chat-composer.tsx +0 -290
  200. package/client/features/chat/composer/model-order.ts +0 -110
  201. package/client/features/chat/composer/model-picker.tsx +0 -408
  202. package/client/features/chat/composer/use-workspace-composer-state.tsx +0 -69
  203. package/client/features/chat/composer/use-workspace-skill-updates.ts +0 -160
  204. package/client/features/chat/connection/chat-connection.ts +0 -64
  205. package/client/features/chat/connection/chat-frames.ts +0 -153
  206. package/client/features/chat/messages/chat-empty-state.tsx +0 -294
  207. package/client/features/chat/messages/chat-prompt-bubbles.tsx +0 -72
  208. package/client/features/chat/messages/fork-history.ts +0 -14
  209. package/client/features/chat/messages/group-turns.ts +0 -74
  210. package/client/features/chat/messages/interleave-notices.ts +0 -80
  211. package/client/features/chat/messages/markdown-content.tsx +0 -89
  212. package/client/features/chat/messages/preview-turn.ts +0 -37
  213. package/client/features/chat/messages/shimmer-text.tsx +0 -20
  214. package/client/features/chat/messages/tool-group/code-block.tsx +0 -41
  215. package/client/features/chat/messages/tool-group/collapse.tsx +0 -28
  216. package/client/features/chat/messages/tool-group/detect.ts +0 -93
  217. package/client/features/chat/messages/tool-group/fixtures.ts +0 -309
  218. package/client/features/chat/messages/tool-group/format/claude.ts +0 -49
  219. package/client/features/chat/messages/tool-group/format/codex.ts +0 -130
  220. package/client/features/chat/messages/tool-group/format/hermes.ts +0 -69
  221. package/client/features/chat/messages/tool-group/format/index.ts +0 -34
  222. package/client/features/chat/messages/tool-group/format/mcp.ts +0 -68
  223. package/client/features/chat/messages/tool-group/format/openclaw.ts +0 -120
  224. package/client/features/chat/messages/tool-group/format/shared.ts +0 -49
  225. package/client/features/chat/messages/tool-group/format/shell.ts +0 -162
  226. package/client/features/chat/messages/tool-group/index.ts +0 -9
  227. package/client/features/chat/messages/tool-group/read-image-preview.tsx +0 -46
  228. package/client/features/chat/messages/tool-group/subagent-card.tsx +0 -138
  229. package/client/features/chat/messages/tool-group/timeline-row.tsx +0 -159
  230. package/client/features/chat/messages/tool-group/tool-call-group.tsx +0 -279
  231. package/client/features/chat/messages/tool-group/tool-output.tsx +0 -125
  232. package/client/features/chat/messages/turn-view.tsx +0 -270
  233. package/client/features/chat/messages/use-stick-to-bottom.ts +0 -96
  234. package/client/features/chat/messages/user-message-bubble.tsx +0 -63
  235. package/client/features/chat/sessions/api.ts +0 -193
  236. package/client/features/chat/sessions/chat-selector.tsx +0 -399
  237. package/client/features/chat/sessions/session-view.ts +0 -53
  238. package/client/features/chat/sessions/use-selected-session.ts +0 -171
  239. package/client/features/chat/use-chat.ts +0 -229
  240. package/client/features/collab/applet-api.ts +0 -35
  241. package/client/features/collab/components/cursors.tsx +0 -241
  242. package/client/features/collab/components/presence-avatars.tsx +0 -74
  243. package/client/features/collab/components/presence-frame.tsx +0 -122
  244. package/client/features/collab/components/presence-group.tsx +0 -31
  245. package/client/features/collab/components/presence-helpers.ts +0 -50
  246. package/client/features/collab/components/user-avatar-group.tsx +0 -35
  247. package/client/features/collab/components/user-avatar.tsx +0 -65
  248. package/client/features/collab/components/user.tsx +0 -69
  249. package/client/features/collab/host-state.ts +0 -160
  250. package/client/features/collab/index.ts +0 -5
  251. package/client/features/collab/local-user.ts +0 -46
  252. package/client/features/collab/members/api.ts +0 -17
  253. package/client/features/collab/members/hooks.ts +0 -97
  254. package/client/features/collab/members/store.ts +0 -148
  255. package/client/features/collab/members/types.ts +0 -55
  256. package/client/features/collab/presence/client.ts +0 -242
  257. package/client/features/collab/presence/hooks.tsx +0 -160
  258. package/client/features/collab/presence/presence-publisher.ts +0 -30
  259. package/client/features/collab/presence/presence-target.ts +0 -8
  260. package/client/features/collab/presence/provider.tsx +0 -74
  261. package/client/features/collab/presence/store.ts +0 -156
  262. package/client/features/collab/presence/users.ts +0 -87
  263. package/client/features/collab/proxy-user.ts +0 -28
  264. package/client/features/collab/sharing/agent-invite.tsx +0 -30
  265. package/client/features/collab/sharing/workspace-members.tsx +0 -269
  266. package/client/features/collab/sharing/workspace-sharing-menu.tsx +0 -179
  267. package/client/features/collab/testing/component-fixtures.tsx +0 -54
  268. package/client/features/collab/testing/fake-engine.ts +0 -120
  269. package/client/features/connectors/api.ts +0 -25
  270. package/client/features/connectors/icon-mcp.tsx +0 -21
  271. package/client/features/connectors/mcp-icons.ts +0 -183
  272. package/client/features/connectors/mcp-server-cards.tsx +0 -105
  273. package/client/features/connectors/read-connectors.ts +0 -35
  274. package/client/features/demo/demo-dialog.tsx +0 -194
  275. package/client/features/dev/blobatar-shapes-page.tsx +0 -344
  276. package/client/features/dev/chat-states-fixtures.ts +0 -755
  277. package/client/features/dev/chat-states-page.tsx +0 -476
  278. package/client/features/dev/collab/collab-page.tsx +0 -24
  279. package/client/features/dev/collab/collab-playground.tsx +0 -614
  280. package/client/features/dev/collab/local-user-settings.tsx +0 -120
  281. package/client/features/dev/collab/playground-room.ts +0 -33
  282. package/client/features/dev/dev-index-page.tsx +0 -83
  283. package/client/features/dev/dev-routes.tsx +0 -43
  284. package/client/features/dev/harness-debug-page.tsx +0 -607
  285. package/client/features/dev/onboarding-preview-page.tsx +0 -76
  286. package/client/features/dev/texture-lab-page.tsx +0 -149
  287. package/client/features/dev/tool-calls-page.tsx +0 -79
  288. package/client/features/dev/ui-components/ui-component-previews.tsx +0 -855
  289. package/client/features/dev/ui-components/ui-components-page.tsx +0 -60
  290. package/client/features/dev/workspace-setup-mocks.ts +0 -103
  291. package/client/features/dev/workspace-setup-page.tsx +0 -11
  292. package/client/features/dev/workspace-setup-preview.tsx +0 -249
  293. package/client/features/drawings/capture-element.ts +0 -57
  294. package/client/features/drawings/drawing-layer.tsx +0 -49
  295. package/client/features/drawings/drawing-toolbar.tsx +0 -95
  296. package/client/features/drawings/use-chat-annotation.ts +0 -228
  297. package/client/features/drawings/use-drawing-layer.ts +0 -756
  298. package/client/features/drawings/use-view-sketch.ts +0 -154
  299. package/client/features/harness/api.ts +0 -69
  300. package/client/features/harness/device-login-steps.tsx +0 -103
  301. package/client/features/harness/harness-login-panel.tsx +0 -232
  302. package/client/features/harness/harness-presentation.ts +0 -15
  303. package/client/features/harness/harness-selector.tsx +0 -119
  304. package/client/features/harness/use-harness-login.ts +0 -77
  305. package/client/features/home/api.ts +0 -135
  306. package/client/features/home/home-logo.tsx +0 -344
  307. package/client/features/home/home-page.tsx +0 -305
  308. package/client/features/home/shared-workspaces.tsx +0 -70
  309. package/client/features/home/workspace-invitations.tsx +0 -101
  310. package/client/features/home/workspace-preview.tsx +0 -213
  311. package/client/features/identity/host-api.ts +0 -35
  312. package/client/features/identity/store.ts +0 -26
  313. package/client/features/identity/types.ts +0 -41
  314. package/client/features/identity/use-identity.ts +0 -6
  315. package/client/features/onboarding/agent-setup-step.tsx +0 -57
  316. package/client/features/onboarding/api.ts +0 -42
  317. package/client/features/onboarding/onboarding-idea-disk.tsx +0 -129
  318. package/client/features/onboarding/onboarding-page.tsx +0 -33
  319. package/client/features/onboarding/onboarding-screen.tsx +0 -20
  320. package/client/features/onboarding/onboarding-status.tsx +0 -24
  321. package/client/features/onboarding/workspace-setup-step.tsx +0 -239
  322. package/client/features/overview/api.ts +0 -28
  323. package/client/features/overview/default/registry.tsx +0 -34
  324. package/client/features/overview/default/views-widget.tsx +0 -246
  325. package/client/features/overview/grid.ts +0 -77
  326. package/client/features/overview/hidden-panel.tsx +0 -111
  327. package/client/features/overview/overview.tsx +0 -299
  328. package/client/features/overview/use-grid-reconcile.ts +0 -94
  329. package/client/features/overview/widget-canvas.tsx +0 -166
  330. package/client/features/overview/widget-frame.tsx +0 -77
  331. package/client/features/overview/workspace-name.tsx +0 -55
  332. package/client/features/scratchpad/scratch-session.ts +0 -71
  333. package/client/features/scratchpad/scratchpad-controls.tsx +0 -516
  334. package/client/features/scratchpad/scratchpad.tsx +0 -360
  335. package/client/features/scratchpad/use-scratchpad-snapshot.tsx +0 -133
  336. package/client/features/update/api.ts +0 -35
  337. package/client/features/update/update-control.tsx +0 -102
  338. package/client/features/views/api.ts +0 -188
  339. package/client/features/views/pending-view-screen.tsx +0 -303
  340. package/client/features/views/use-view-actions.ts +0 -119
  341. package/client/features/views/use-view-drafts.ts +0 -88
  342. package/client/features/views/view-manager.tsx +0 -293
  343. package/client/features/views/view-presentation.ts +0 -12
  344. package/client/features/views/view-residency.ts +0 -77
  345. package/client/features/views/view-submission.ts +0 -56
  346. package/client/features/workspace/add/api.ts +0 -61
  347. package/client/features/workspace/add/create-workspace-dialog.tsx +0 -230
  348. package/client/features/workspace/add/import-workspace-dialog.tsx +0 -81
  349. package/client/features/workspace/add/use-workspace-import.ts +0 -61
  350. package/client/features/workspace/add/workspace-agent-options.ts +0 -53
  351. package/client/features/workspace/add/workspace-agent-selector.tsx +0 -96
  352. package/client/features/workspace/add/workspace-dialog-content.tsx +0 -22
  353. package/client/features/workspace/api.ts +0 -180
  354. package/client/features/workspace/harness-transition.ts +0 -81
  355. package/client/features/workspace/moi-context.ts +0 -129
  356. package/client/features/workspace/remote.ts +0 -34
  357. package/client/features/workspace/settings/api.ts +0 -112
  358. package/client/features/workspace/settings/connectors-settings.tsx +0 -110
  359. package/client/features/workspace/settings/environment-settings.tsx +0 -149
  360. package/client/features/workspace/settings/general-settings.tsx +0 -180
  361. package/client/features/workspace/settings/icon-picker-options.ts +0 -30
  362. package/client/features/workspace/settings/settings-layout.tsx +0 -53
  363. package/client/features/workspace/settings/use-env-vars.ts +0 -20
  364. package/client/features/workspace/settings/workspace-icon-picker.tsx +0 -318
  365. package/client/features/workspace/settings/workspace-settings-dialog.tsx +0 -65
  366. package/client/features/workspace/setup/workspace-login-state.tsx +0 -56
  367. package/client/features/workspace/setup/workspace-recovery-states.tsx +0 -142
  368. package/client/features/workspace/setup/workspace-setup.tsx +0 -98
  369. package/client/features/workspace/setup/workspace-welcome-state.tsx +0 -81
  370. package/client/features/workspace/tab-resolution.ts +0 -32
  371. package/client/features/workspace/theme-panel.tsx +0 -191
  372. package/client/features/workspace/unavailable-page.tsx +0 -21
  373. package/client/features/workspace/use-fits-split-layout.ts +0 -69
  374. package/client/features/workspace/use-workspace-navigation.ts +0 -265
  375. package/client/features/workspace/use-workspace-socket.ts +0 -51
  376. package/client/features/workspace/workspace-content.tsx +0 -597
  377. package/client/features/workspace/workspace-context.tsx +0 -21
  378. package/client/features/workspace/workspace-frame.tsx +0 -64
  379. package/client/features/workspace/workspace-identity.tsx +0 -40
  380. package/client/features/workspace/workspace-layout-context.tsx +0 -156
  381. package/client/features/workspace/workspace-menu.tsx +0 -67
  382. package/client/features/workspace/workspace-pane.tsx +0 -22
  383. package/client/features/workspace/workspace-pending-screen.tsx +0 -26
  384. package/client/features/workspace/workspace-preferences.ts +0 -91
  385. package/client/features/workspace/workspace-presentation.tsx +0 -35
  386. package/client/features/workspace/workspace-screen.tsx +0 -28
  387. package/client/features/workspace/workspace-split-layout.tsx +0 -116
  388. package/client/features/workspace/workspace-state.ts +0 -206
  389. package/client/features/workspace/workspace-tabs.tsx +0 -233
  390. package/client/features/workspace/workspace-test-utils.ts +0 -23
  391. package/client/global.d.ts +0 -5
  392. package/client/index.css +0 -247
  393. package/client/index.html +0 -81
  394. package/client/index.tsx +0 -45
  395. package/client/lib/agent-availability.ts +0 -14
  396. package/client/lib/browser-tab-id.ts +0 -4
  397. package/client/lib/cn.ts +0 -6
  398. package/client/lib/flags.ts +0 -11
  399. package/client/lib/identity-icon-registry.ts +0 -150
  400. package/client/lib/rate-limit.ts +0 -77
  401. package/client/lib/use-latest-ref.ts +0 -11
  402. package/client/lib/user-display-name.ts +0 -6
  403. package/client/lib/ws-url.ts +0 -10
  404. package/client/main.tsx +0 -43
  405. package/client/runtime/app-context.ts +0 -20
  406. package/client/runtime/app-events.ts +0 -75
  407. package/client/runtime/hmr-watchdog.ts +0 -39
  408. package/client/runtime/reconnecting-socket.ts +0 -115
  409. package/client/runtime/use-client-events.ts +0 -69
  410. package/client/runtime/workspace-theme.ts +0 -175
  411. package/client/store/ui.ts +0 -94
  412. package/client/store/workspace-session.ts +0 -30
  413. package/client/structured-clone-shim.ts +0 -14
  414. package/client/tailwind-config.ts +0 -43
  415. package/dist/chunk-851bx8ss.js +0 -72
  416. package/dist/chunk-cty37f3v.js +0 -1
  417. package/dist/chunk-dy6f6h3e.js +0 -5
  418. package/dist/chunk-j6928pwm.js +0 -1
  419. package/dist/chunk-kffcah9w.css +0 -1
  420. package/dist/chunk-rh58dc0y.js +0 -2
  421. package/lib/applet-selector.ts +0 -24
  422. package/lib/attachment-note.ts +0 -66
  423. package/lib/chat-title.ts +0 -11
  424. package/lib/collab/colors.ts +0 -30
  425. package/lib/collab/protocol.ts +0 -84
  426. package/lib/collab/types.ts +0 -52
  427. package/lib/default-widgets.ts +0 -32
  428. package/lib/events.ts +0 -61
  429. package/lib/format.ts +0 -348
  430. package/lib/harness-instructions.ts +0 -30
  431. package/lib/harness-types.ts +0 -13
  432. package/lib/identity-icons.ts +0 -73
  433. package/lib/ids.ts +0 -33
  434. package/lib/message-attachments.ts +0 -40
  435. package/lib/moi-attachments.ts +0 -204
  436. package/lib/moi-context.ts +0 -305
  437. package/lib/navigation.ts +0 -65
  438. package/lib/onboarding.ts +0 -41
  439. package/lib/scratchpad-skew.ts +0 -64
  440. package/lib/session-drafts.ts +0 -10
  441. package/lib/speed-mode.ts +0 -5
  442. package/lib/system-messages.ts +0 -241
  443. package/lib/themes.ts +0 -241
  444. package/lib/types.ts +0 -776
  445. package/lib/update.ts +0 -2
  446. package/lib/view-build-directives.ts +0 -11
  447. package/lib/workspace-config.ts +0 -48
  448. package/lib/workspace-icon.ts +0 -20
  449. package/lib/workspace-layout.ts +0 -15
  450. package/lib/workspace-name.ts +0 -17
  451. package/lib/workspace-tabs.ts +0 -29
  452. package/server/AGENTS.md +0 -17
  453. package/server/README.md +0 -123
  454. package/server/agent-caller.ts +0 -16
  455. package/server/agent-launcher.ts +0 -27
  456. package/server/api/harnesses.ts +0 -79
  457. package/server/api/index.ts +0 -1351
  458. package/server/api/onboarding.ts +0 -46
  459. package/server/app-config.ts +0 -264
  460. package/server/app-settings.ts +0 -69
  461. package/server/applets/api-base.ts +0 -4
  462. package/server/applets/applet-css.ts +0 -55
  463. package/server/applets/build-applet.ts +0 -475
  464. package/server/applets/build-worker.ts +0 -179
  465. package/server/applets/bundle-queue.ts +0 -19
  466. package/server/applets/config.ts +0 -226
  467. package/server/applets/declarations.ts +0 -45
  468. package/server/applets/dependencies.ts +0 -206
  469. package/server/applets/functions-worker.ts +0 -121
  470. package/server/applets/functions.ts +0 -392
  471. package/server/applets/index.ts +0 -504
  472. package/server/applets/log.ts +0 -149
  473. package/server/applets/runtime/collab.ts +0 -94
  474. package/server/applets/runtime/moi.ts +0 -35
  475. package/server/applets/runtime/rpc.ts +0 -15
  476. package/server/applets/thumbnails.ts +0 -200
  477. package/server/applets/typecheck.ts +0 -100
  478. package/server/applets/ui-components.ts +0 -241
  479. package/server/applets/view-source.ts +0 -73
  480. package/server/applets/views.ts +0 -323
  481. package/server/applets/widgets.ts +0 -181
  482. package/server/cli/applet-selector.ts +0 -19
  483. package/server/cli/args.ts +0 -5
  484. package/server/cli/colors.ts +0 -20
  485. package/server/cli/commands/bundle.ts +0 -119
  486. package/server/cli/commands/call-server-fn.ts +0 -42
  487. package/server/cli/commands/check.ts +0 -53
  488. package/server/cli/commands/config.ts +0 -120
  489. package/server/cli/commands/debug.ts +0 -119
  490. package/server/cli/commands/env.ts +0 -162
  491. package/server/cli/commands/hermes.ts +0 -149
  492. package/server/cli/commands/init.ts +0 -323
  493. package/server/cli/commands/navigate.ts +0 -35
  494. package/server/cli/commands/openclaw.ts +0 -168
  495. package/server/cli/commands/refresh.ts +0 -45
  496. package/server/cli/commands/remote.ts +0 -330
  497. package/server/cli/commands/scratch.ts +0 -496
  498. package/server/cli/commands/service.ts +0 -298
  499. package/server/cli/commands/skill.ts +0 -121
  500. package/server/cli/commands/start.ts +0 -112
  501. package/server/cli/commands/status.ts +0 -80
  502. package/server/cli/commands/tabs.ts +0 -36
  503. package/server/cli/commands/theme.ts +0 -192
  504. package/server/cli/commands/ui-components.ts +0 -15
  505. package/server/cli/commands/update.ts +0 -192
  506. package/server/cli/commands/version.ts +0 -9
  507. package/server/cli/commands/views.ts +0 -87
  508. package/server/cli/control.ts +0 -120
  509. package/server/cli/env.ts +0 -259
  510. package/server/cli/index.ts +0 -175
  511. package/server/cli/pc.ts +0 -20
  512. package/server/cli/provider.ts +0 -25
  513. package/server/cli/remote-command.ts +0 -77
  514. package/server/cli/remote-control.ts +0 -73
  515. package/server/cli/remote-operations.ts +0 -247
  516. package/server/cli/server-version.ts +0 -16
  517. package/server/cli/server.ts +0 -93
  518. package/server/cli/ui-components.ts +0 -294
  519. package/server/cli/ui.ts +0 -52
  520. package/server/cli.ts +0 -3
  521. package/server/collab/cloudflare-access.ts +0 -78
  522. package/server/collab/config.ts +0 -13
  523. package/server/collab/manager.ts +0 -413
  524. package/server/collab/service.ts +0 -136
  525. package/server/collab/skill/index.ts +0 -7
  526. package/server/collab/worker-messages.ts +0 -10
  527. package/server/collab/worker.ts +0 -52
  528. package/server/constants.ts +0 -13
  529. package/server/control-client.ts +0 -124
  530. package/server/control.ts +0 -572
  531. package/server/data-dir.ts +0 -22
  532. package/server/debug.ts +0 -10
  533. package/server/events.ts +0 -25
  534. package/server/harness/README.md +0 -381
  535. package/server/harness/acp/NOTES.md +0 -426
  536. package/server/harness/acp/adapter.ts +0 -206
  537. package/server/harness/acp/archived.ts +0 -88
  538. package/server/harness/acp/client.ts +0 -329
  539. package/server/harness/acp/discovery.ts +0 -127
  540. package/server/harness/acp/model-state.ts +0 -57
  541. package/server/harness/acp/run-durations.ts +0 -68
  542. package/server/harness/acp/session.ts +0 -786
  543. package/server/harness/acp/wire.ts +0 -132
  544. package/server/harness/auth.ts +0 -272
  545. package/server/harness/claude-code/NOTES.md +0 -651
  546. package/server/harness/claude-code/adapter.ts +0 -876
  547. package/server/harness/claude-code/auth.ts +0 -178
  548. package/server/harness/claude-code/cli.ts +0 -42
  549. package/server/harness/claude-code/git-worktree.ts +0 -35
  550. package/server/harness/claude-code/index.ts +0 -171
  551. package/server/harness/claude-code/mcp.ts +0 -152
  552. package/server/harness/claude-code/models.ts +0 -102
  553. package/server/harness/claude-code/permissions.ts +0 -34
  554. package/server/harness/claude-code/run-action.ts +0 -123
  555. package/server/harness/claude-code/session-title.ts +0 -104
  556. package/server/harness/claude-code/session.ts +0 -969
  557. package/server/harness/claude-code/sessions.ts +0 -153
  558. package/server/harness/codex/NOTES.md +0 -259
  559. package/server/harness/codex/adapter.ts +0 -633
  560. package/server/harness/codex/auth.ts +0 -140
  561. package/server/harness/codex/client.ts +0 -439
  562. package/server/harness/codex/connectors.ts +0 -92
  563. package/server/harness/codex/discovery.ts +0 -106
  564. package/server/harness/codex/index.ts +0 -107
  565. package/server/harness/codex/pagination.ts +0 -27
  566. package/server/harness/codex/permissions.ts +0 -80
  567. package/server/harness/codex/probe.ts +0 -183
  568. package/server/harness/codex/run-action.ts +0 -93
  569. package/server/harness/codex/session-title.ts +0 -147
  570. package/server/harness/codex/session.ts +0 -1196
  571. package/server/harness/codex/status.ts +0 -31
  572. package/server/harness/codex/thread-list.ts +0 -78
  573. package/server/harness/codex/transport.ts +0 -191
  574. package/server/harness/command.ts +0 -45
  575. package/server/harness/debug.ts +0 -57
  576. package/server/harness/detect.ts +0 -164
  577. package/server/harness/executable.ts +0 -125
  578. package/server/harness/fork.ts +0 -14
  579. package/server/harness/hermes/NOTES.md +0 -833
  580. package/server/harness/hermes/discovery.ts +0 -175
  581. package/server/harness/hermes/index.ts +0 -167
  582. package/server/harness/hermes/models.ts +0 -99
  583. package/server/harness/install.ts +0 -49
  584. package/server/harness/openclaw/NOTES.md +0 -749
  585. package/server/harness/openclaw/adapter.ts +0 -336
  586. package/server/harness/openclaw/compat.ts +0 -95
  587. package/server/harness/openclaw/cron-view.ts +0 -78
  588. package/server/harness/openclaw/discovery.ts +0 -456
  589. package/server/harness/openclaw/gateway.ts +0 -467
  590. package/server/harness/openclaw/index.ts +0 -125
  591. package/server/harness/openclaw/session.ts +0 -1512
  592. package/server/harness/openclaw/strip.ts +0 -184
  593. package/server/harness/openclaw/thinking.ts +0 -150
  594. package/server/harness/registry.ts +0 -39
  595. package/server/harness/run-action.ts +0 -85
  596. package/server/harness/session-title.ts +0 -59
  597. package/server/harness/shell-path.ts +0 -89
  598. package/server/harness/types.ts +0 -170
  599. package/server/navigation-relay.ts +0 -110
  600. package/server/onboarding/brief.ts +0 -29
  601. package/server/onboarding/ideas.ts +0 -48
  602. package/server/onboarding/jobs.ts +0 -291
  603. package/server/open-browser.ts +0 -7
  604. package/server/operations/commands.ts +0 -46
  605. package/server/operations/files.ts +0 -148
  606. package/server/operations/server.ts +0 -206
  607. package/server/remote/agent.ts +0 -103
  608. package/server/remote/broker-client.ts +0 -76
  609. package/server/remote/broker.ts +0 -81
  610. package/server/remote/client.ts +0 -725
  611. package/server/remote/errors.ts +0 -2
  612. package/server/remote/routes.ts +0 -121
  613. package/server/remote/workspace.ts +0 -34
  614. package/server/scratchpad/assets.ts +0 -258
  615. package/server/scratchpad/document.ts +0 -312
  616. package/server/scratchpad/executor.ts +0 -499
  617. package/server/scratchpad/relay.ts +0 -44
  618. package/server/scratchpad/shape-defaults.ts +0 -82
  619. package/server/server-cwd.ts +0 -23
  620. package/server/service.ts +0 -800
  621. package/server/sessions/archive.ts +0 -23
  622. package/server/sessions/attachment-message.ts +0 -95
  623. package/server/sessions/config.ts +0 -45
  624. package/server/sessions/lifecycle.ts +0 -19
  625. package/server/sessions/pending-views.ts +0 -158
  626. package/server/sessions/selected.ts +0 -113
  627. package/server/sessions/send-message.ts +0 -102
  628. package/server/sessions/store.ts +0 -54
  629. package/server/sessions/view-sessions.ts +0 -192
  630. package/server/skills/locations.ts +0 -82
  631. package/server/skills/lock.ts +0 -29
  632. package/server/skills/template.ts +0 -94
  633. package/server/skills/update.ts +0 -94
  634. package/server/skills/version.ts +0 -129
  635. package/server/skills/workspace.ts +0 -121
  636. package/server/state.ts +0 -40
  637. package/server/static.ts +0 -25
  638. package/server/status.ts +0 -110
  639. package/server/tldraw-package.d.ts +0 -4
  640. package/server/update.ts +0 -429
  641. package/server/uploads.ts +0 -290
  642. package/server/vendor.ts +0 -63
  643. package/server/version.ts +0 -41
  644. package/server/web.ts +0 -350
  645. package/server/workspace-state/file.ts +0 -181
  646. package/server/workspace-state/index.ts +0 -169
  647. package/server/workspace-state/lock.ts +0 -42
  648. package/server/workspace-state/types.ts +0 -16
  649. package/server/workspaces/api.ts +0 -24
  650. package/server/workspaces/change-harness.ts +0 -77
  651. package/server/workspaces/config.ts +0 -42
  652. package/server/workspaces/env-apply.ts +0 -20
  653. package/server/workspaces/env.ts +0 -424
  654. package/server/workspaces/harness-transition.ts +0 -29
  655. package/server/workspaces/icon.ts +0 -13
  656. package/server/workspaces/import.ts +0 -74
  657. package/server/workspaces/init.ts +0 -74
  658. package/server/workspaces/layout.ts +0 -190
  659. package/server/workspaces/preview.ts +0 -72
  660. package/server/workspaces/registry.ts +0 -330
  661. package/server/workspaces/required-env.ts +0 -19
  662. package/server/workspaces/scaffold.ts +0 -189
  663. package/server/workspaces/shared.ts +0 -74
  664. package/server/workspaces/tabs.ts +0 -35
  665. package/server/workspaces/theme.ts +0 -58
  666. package/tsconfig.json +0 -20
package/runtime/cli.js ADDED
@@ -0,0 +1,246 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+ import{vt,Ls,p,H,C,tr,rr,nt,he}from"./chunk-kjp60rqs.js";import{w,W,ue,N,K,pt,ge,O,Pr,_e,Wt,M,fe,bs,vs,$r,gt,Jn,Xn,Ss,Ts,Es,Ke,Xr,ve,Ns,Ie,ti,z,D,bt}from"./chunk-c3qyet60.js";import"./chunk-zwvtkb81.js";import{ye,J,It,Sn,Ct,ct,Ne,dr,te,Dt}from"./chunk-r5s8rm8n.js";import{a,cn,hi,it,yi,t,un,st,Et,xt,we,qe,R,ot,Te,dn,fn,vi,Si,Ti,At,He,mn,lt,oe,V,hn,Ei,ar,xi,yn,gn,_n,or,Pi,bn,vn,lr,Pt,Je,le,Ee,xe,ki,ce,De}from"./chunk-wvarpvem.js";import{ut}from"./chunk-4wj1jzhr.js";import{$i}from"./chunk-hjzfk1cr.js";import{r,m,s,Qt,o}from"./chunk-ggphq7nk.js";if(!process.stdout.isTTY&&!process.env.FORCE_COLOR&&process.env.NO_COLOR==null)process.env.NO_COLOR="1";var Nt=["MOI_AGENT","CLAUDECODE","CODEX_SANDBOX","CURSOR_TRACE_ID"];function Qe(e=process.env){return Nt.some((n)=>!!e[n])}import{resolve as zt}from"path";var q={type:"string",description:'Limit to "widgets", "views", "widgets/<id>", or "views/<id>"'};function F(e){if(e===void 0)return;if(it(e))return e;console.error(`
4
+ `+t.red("\u2717")+` Invalid --only value "${e}" \u2014 use "widgets", "views", "widgets/<id>", or "views/<id>".
5
+ `),process.exit(1)}import{basename as jt}from"path";import{resolve as Le}from"path";async function B(e=process.cwd()){let n=await dr(Le(e)),i=await O(n);return i.remote?{path:n,...i.remote}:void 0}async function eo(e,n){if(n=K(n),!(await $r()).some((d)=>d.id===n.workspace_id&&d.owner.id===n.user_id))throw Error("This workspace is not shared with this account");let l=Le(e),c=(await D()).find((d)=>d.remote?.user_id===n.user_id&&d.remote.workspace_id===n.workspace_id&&Le(d.path)!==l);if(c)throw Error(`This workspace is already initialized at ${c.path} \u2014 remove that registration in Moi first`);let f=await un(l,n);return{path:l,id:f.id,...n}}var{views:Lt,config:Mt,icon:_t,scratchpadOps:Ut}=M,Ht={views:Lt,config:Mt,icon:_t,scratchpadOps:Ut};async function oo(e,n){if(!["config","scratch","tabs"].includes(String(n.type)))return;let i=n.op;if(n.type==="scratch"&&i?.kind==="view")return;let l=await B(e);if(!l)return;let c={remote:l},f=(u,g)=>Ke(Ht[u].path(l),g);if(n.type==="tabs"){let{views:u}=await(await f("views")).json();return{tabs:st(u)}}if(n.type==="config"){if(typeof n.iconPath==="string"){let g=Bun.file(n.iconPath);if(!await g.exists())throw Error("Local icon file not found");return{ok:!0,...await(await f("icon",{method:"PUT",body:g})).json()}}if(n.clearIcon)return await f("icon",{method:"DELETE"}),{ok:!0,clearedIcon:!0};if(n.name!==void 0||n.clearName)return{...await(await f("config",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({name:n.clearName?null:n.name})})).json(),ok:!0,clearedName:n.clearName===!0};let u=await(await f("config")).json();return{...u,hasIcon:!!u.icon}}if(!i)throw Error("Missing scratch operation");if(i.kind==="read")return{shapes:await xt(c)};if(i.kind==="read-image")return Et(c,i.name);let d=new FormData;if(i.kind.startsWith("add-")&&"name"in i&&!i.name)i.name=`s_${crypto.randomUUID().slice(0,8)}`;if(i.kind==="add-image"){let u=Bun.file(i.path);if(!await u.exists())throw Error("Local image file not found");d.set("image",u),d.set("op",JSON.stringify({...i,path:jt(i.path)}))}else d.set("op",JSON.stringify(i));return{ok:!0,result:await(await f("scratchpadOps",{method:"POST",body:d})).json()}}import{accessSync as qt,constants as Me}from"fs";async function P(){return(await we()).status==="running"}async function _(){console.error(qe(await we())),process.exit(1)}async function to(e=1e4){let n=Date.now()+e;while(Date.now()<n){if(await P())return!0;await Bun.sleep(200)}return!1}async function ee(e){try{qt(e,Me.R_OK|Me.W_OK|Me.X_OK)}catch{console.error(`
6
+ `+t.red("\u2717")+` Can't open ${e} for reading and writing
7
+ `),process.exit(1)}return new Promise((n,i)=>{let l=new WebSocket(N);l.onopen=()=>l.send(JSON.stringify({type:"workspace:register",path:e})),l.onmessage=(c)=>{let f=JSON.parse(String(c.data));if(f.id)l.close(),n(f.id)},l.onerror=()=>void we().then((c)=>i(Error(qe(c))))})}function no(e,n=3000){return new Promise((i)=>{let l=new WebSocket(N),c=()=>{clearTimeout(f),l.close(),i()},f=setTimeout(c,n);l.onopen=()=>l.send(JSON.stringify(e)),l.onmessage=c,l.onerror=c})}async function j(e,n,i){try{let d=await oo(e,n);if(d){if(d.error)throw Error(String(d.error));await i(d);let u=await te(e);if(u)console.error(`
8
+ `+t.yellow(u)+`
9
+ `);return}}catch(d){console.error(d instanceof Error?d.message:"Remote command failed"),process.exitCode=1;return}let l=new WebSocket(N),c=!1,f=!1;l.onopen=()=>{c=!0,l.send(JSON.stringify(n))},l.onmessage=async(d)=>{f=!0;let u=JSON.parse(String(d.data));if(u.error)console.error(`
10
+ `+t.red("\u2717")+" "+u.error+`
11
+ `),l.close(),process.exit(1);await i(u);let g=await te(e);if(g)console.error(`
12
+ `+t.yellow(g)+`
13
+ `);l.close(),process.exit(0)},l.onclose=()=>{if(c&&!f)console.error("The server disconnected before acknowledging the command. Check the browser before retrying."),process.exit(1)},l.onerror=()=>void _()}function Ft(e){if(e==="built")return t.green(e);if(e==="failed")return t.red(e);return t.dim(e)}var ro=a({meta:{name:"bundle",description:"Rebuild changed widgets and views"},args:{dir:{type:"positional",default:".",description:"Workspace directory (default: current)"},force:{type:"boolean",description:"Rebuild the selected applets, ignoring file modification times",default:!1},only:q},async run({args:e}){let n=F(e.only),i=zt(e.dir),l=await te(i),c=new WebSocket(N);c.onopen=()=>c.send(JSON.stringify({type:"bundle",path:i,force:e.force,only:n})),c.onmessage=(f)=>{let d=JSON.parse(String(f.data));if(d.error)console.error(`
14
+ `+t.red(t.bold("Error:"))+" "+d.error+`
15
+ `),c.close(),process.exit(1);let u=Array.isArray(d.results)?d.results:[],g=typeof d.workspacePath==="string"?d.workspacePath:i;if(u.length===0){if(console.log(`
16
+ `+t.bold("moi bundle")+t.dim(" \u2014 nothing to build")+`
17
+
18
+ `+t.dim(` No widgets or views found in ${g}/.moi/`)+`
19
+ `),l)console.log(t.yellow(l)+`
20
+ `);c.close(),process.exit(0)}let h={};for(let k of u)h[k.status]=(h[k.status]??0)+1;let v=["built","skipped","failed"].filter((k)=>h[k]).map((k)=>`${h[k]} ${k}`).join(" \xB7 ");console.log(`
21
+ `+t.bold("moi bundle")+t.dim(` \u2014 ${v}`)+`
22
+ `),console.log(R(["kind","name","status"].map((k)=>t.dim(k)),u.map((k)=>[t.dim(k.kind??""),k.name,Ft(k.status)])));let b=u.filter((k)=>k.status==="failed");console.log();for(let k of b)console.log(t.red(t.bold(k.name+":"))),console.log(" "+k.error+`
23
+ `);let x=typeof d.logCount==="number"?d.logCount:0;if(x>0)console.log(t.yellow(`\u2139 ${x} applet runtime error(s) on record \u2014 run \`moi debug logs\`.`)+`
24
+ `);if(l)console.log(t.yellow(l)+`
25
+ `);c.close(),process.exit(b.length>0?1:0)},c.onerror=()=>void _()}});import{resolve as Jt}from"path";var S={type:"string",default:".",description:"Workspace directory (default: current)"};var io=a({meta:{name:"call-server-fn",description:"Invoke an applet .server.ts function in an isolated one-shot worker (smoke test)"},args:{fn:{type:"positional",required:!0,description:"Function path: <module>/<fn>, e.g. widgets/hello/getGreeting"},args:{type:"positional",required:!1,description:`Arguments as one JSON array, e.g. '["ann", 10]' (default [])`},dir:S},run({args:e}){let n=Jt(e.dir);j(n,{type:"call-server-fn",path:n,fn:e.fn,args:e.args??"[]"},(i)=>{let l=ut(String(i.result));console.log(Bun.inspect(l,{depth:8,colors:process.stdout.isTTY})),console.error(t.dim(`\u21A9 ${i.ms}ms`))})}});import{existsSync as Bt}from"fs";import{join as Vt,resolve as Kt}from"path";var so=a({meta:{name:"check",description:"Run applet checks"},args:{dir:{type:"positional",default:".",description:"Workspace directory (default: current)"},only:q},async run({args:e}){let n=F(e.only),{root:i}=await Ne(Kt(e.dir));if(!Bt(Vt(i,".moi")))console.error(`
26
+ `+t.red("\u2717")+` No Moi workspace found at ${i}
27
+ `),process.exit(1);let{formatAppletTypecheckDiagnostics:l,typecheckApplets:c}=await import("./chunk-h2bwhk81.js"),f=await c(i,n);if(n?.includes("/")&&f.files.length===0)console.error(`
28
+ `+t.red("\u2717")+` Applet "${n}" not found.
29
+ `),process.exit(1);if(f.diagnostics.length>0)console.error(`
30
+ `+t.red("\u2717")+` Applet check failed: TypeScript
31
+ `),console.error(l(f.diagnostics)),process.exit(1);if(f.files.length===0){let u=e.only?`.moi/${e.only}`:".moi/widgets or .moi/views";console.log(`
32
+ `+t.green("\u2713")+` No applet source files found in ${u}
33
+ `);return}let d=n?` (${n})`:"";console.log(`
34
+ `+t.green("\u2713")+` Applet checks passed: TypeScript \xB7 ${f.files.length} file${f.files.length===1?"":"s"}${d}
35
+ `)}});import{resolve as ao}from"path";async function de(e){await j(e.path,{type:"config",...e},(n)=>{if(console.log(),n.ok){if(n.clearedName)console.log(t.green("\u2713")+" Name reset to "+t.dim("(folder name)"));else if(n.name)console.log(t.green("\u2713")+" Name set to "+t.bold(String(n.name)));if(n.clearedIcon)console.log(t.green("\u2713")+" Icon reset to "+t.dim("default (provider)"));else if(n.icon)console.log(t.green("\u2713")+" Icon updated "+t.dim("(128\xD7128 webp)"))}else console.log(t.bold("moi config")+` \u2014 workspace identity
36
+ `),console.log(" "+t.dim("name")+" "+(n.name?t.bold(String(n.name)):t.dim("(folder name)"))),console.log(" "+t.dim("icon")+" "+(n.hasIcon?t.green("custom"):t.dim("default (provider)")));console.log()})}function Ue(){let e=(n,i)=>" "+t.cyan(n.padEnd(34))+t.dim(i);console.log(),console.log(t.bold("moi config")+t.dim(" \u2014 workspace name & icon")),console.log(),console.log(e("moi config","Show current name & icon")),console.log(e('moi config name "My WS"',"Set the display name")),console.log(e("moi config name --clear","Reset name to folder default")),console.log(e("moi config icon ./logo.png","Set icon (png/jpg/gif/webp \u2192 128\xD7128 webp)")),console.log(e("moi config icon --clear","Reset icon to provider default")),console.log(e(" --dir <path>","Target workspace (default: current dir)")),console.log()}var lo=a({meta:{name:"config",description:"Show or set the workspace name and icon (moi config [name|icon] <value>)"},args:{field:{type:"positional",required:!1,description:'"name" or "icon" \u2014 omit to show the current config'},value:{type:"positional",required:!1,description:"The new name, or a path to an image file (png/jpg/gif/webp)"},clear:{type:"boolean",description:"Reset the field to its default (folder name / provider icon)"},dir:{type:"string",default:".",description:"Workspace directory (default: current)"}},run({args:e}){let n=ao(e.dir);if(e.field==="help"){Ue();return}if(!e.field){de({path:n});return}if(e.field==="name"){if(e.clear){de({path:n,clearName:!0});return}if(!e.value)console.error(t.red("Usage:")+' moi config name "<workspace name>"'),process.exit(1);de({path:n,name:e.value})}else if(e.field==="icon"){if(e.clear){de({path:n,clearIcon:!0});return}if(!e.value)console.error(t.red("Usage:")+" moi config icon <path-to-image>"),process.exit(1);de({path:n,iconPath:ao(e.value)})}else console.error(t.red(`Unknown field "${e.field}".`)+" Use "+t.bold("name")+" or "+t.bold("icon")+"."),process.exit(1)}});import{resolve as Yt}from"path";function Gt(e){let n=Math.max(0,Math.round((Date.now()-e)/1000));if(n<60)return"just now";if(n<3600)return`${Math.round(n/60)}m ago`;if(n<86400)return`${Math.round(n/3600)}h ago`;return`${Math.round(n/86400)}d ago`}function Xt(e){if(e.module)return`${e.module}/${e.fn??"?"}`;if(e.name)return`${e.kind??"applet"} ${e.name}`;return"unattributed"}var ze=12,Zt=a({meta:{name:"logs",description:"Applet runtime errors on record (load / render / rpc / build failures)"},args:{dir:S,only:q,json:{type:"boolean",default:!1,description:"Machine-readable output, includes stacks and epoch timestamps"},clear:{type:"boolean",default:!1,description:"Wipe the journal"}},run({args:e}){let n=F(e.only),i=Yt(e.dir);if(e.clear){if(n)console.error(`
37
+ `+t.red("\u2717")+` Cannot combine --only with --clear.
38
+ `),process.exit(1);j(i,{type:"debug:logs",path:i,clear:!0},(l)=>{console.log(`
39
+ `+t.green("\u2713")+` cleared ${l.cleared??0} entries
40
+ `)});return}j(i,{type:"debug:logs",path:i},(l)=>{let c=Array.isArray(l.entries)?l.entries:[];if(n)c=c.filter((d)=>d.kind&&d.name&&yi(n,d.kind==="widget"?"widgets":"views",d.name));if(e.json){console.log(JSON.stringify(c,null,2));return}if(c.length===0){let d=n?` for ${n}`:"";console.log(`
41
+ `+t.bold("moi debug logs")+t.dim(` \u2014 no applet errors on record${d}`)+`
42
+ `);return}let f=n?` for ${n}`:"";console.log(`
43
+ `+t.bold("moi debug logs")+t.dim(` \u2014 ${c.length} error(s) on record${f}`)+`
44
+ `);for(let d of c){let u=d.count>1?t.dim(` \xD7${d.count}`):"";console.log(` ${t.dim(Gt(d.ts).padEnd(10))} ${d.source.padEnd(7)} ${t.bold(Xt(d))}${u}`);let g=d.message.split(`
45
+ `);for(let h of g.slice(0,ze))console.log(" "+h);if(g.length>ze)console.log(t.dim(` \u2026 ${g.length-ze} more lines (--json)`));console.log()}console.log(t.dim(" Entries clear when their applet next builds successfully, or via --clear.")+`
46
+ `)})}}),co=a({meta:{name:"debug",description:"Debug the workspace (experimental) \u2014 `moi debug logs` for applet errors"},subCommands:{logs:Zt}});function me(e){console.error(`
47
+ `+t.red("\u2717")+" "+e+`
48
+ `),process.exit(1)}var en=a({meta:{name:"set",description:"Set custom secrets: `moi env set KEY=value [KEY=value...]`, or `moi env set KEY` to read one value from stdin"},args:{key:{type:"positional",required:!0,description:"KEY=value pair(s), or a single bare KEY to read the value from stdin"}},async run({args:e}){let n=await Te(),i=e._,l={};if(i.length===1&&!i[0].includes("=")){let f=i[0];if(!Wt(f))me(`Invalid env key: ${f}`);let d;try{d=await Si(f)}catch{process.exit(1)}if(d==="")me(`Empty value for ${f} \u2014 pipe a non-empty value or pass ${f}=value`);l[f]=d}else for(let f of i){let d=f.indexOf("=");if(d===-1)me(`Missing value for ${f} \u2014 use KEY=value (bare KEY reads stdin only when set alone)`);let u=f.slice(0,d),g=f.slice(d+1);if(!Wt(u))me(`Invalid env key: ${u}`);if(g==="")me(`Empty value for ${u} \u2014 use \`moi env unset ${u}\` to remove a key`);l[u]=g}let c=await fn(n.path,{set:l});for(let f of Object.keys(l))console.log(t.green("\u2713")+` Set ${t.bold(f)} ${t.dim("(custom)")}`);if(c==="file")console.log(t.dim(" Stored in a 0600 file \u2014 OS keychain unavailable."));process.exit(0)}}),on=a({meta:{name:"unset",description:"Remove custom secrets: `moi env unset KEY [KEY...]`"},args:{key:{type:"positional",required:!0,description:"Key(s) to remove"}},async run({args:e}){let n=await Te(),i=await dn(n.path),l=new Map(i.vars.map((d)=>[d.key,d])),c=[],f=!1;for(let d of e._){let u=l.get(d);if(!u){console.warn(t.yellow("!")+` ${d} is not set \u2014 skipping`);continue}if(u.source==="dotenv"){console.error(t.red("\u2717")+` ${d} comes from ${(u.files??[]).join(", ")} \u2014 edit that file instead`+t.dim(" (moi env unset only removes custom secrets)")),f=!0;continue}c.push(d)}if(c.length>0){await fn(n.path,{remove:c});for(let d of c){let u=l.get(d),g=u?.source==="both"?t.dim(` (falls back to ${(u.files??[]).join(", ")})`):"";console.log(t.green("\u2713")+` Removed ${t.bold(d)}${g}`)}}process.exit(f?1:0)}}),tn=a({meta:{name:"exec",description:"Run a command with the workspace env: `moi env exec -- <cmd> [args...]`"},async run({rawArgs:e}){let n=e.indexOf("--"),i=n===-1?[]:e.slice(n+1);if(i.length===0)console.error(`
49
+ `+t.red("\u2717")+` Usage: moi env exec -- <cmd> [args...]
50
+ `),process.exit(1);let l=await Te();process.exit(await Ti(l.path,i))}}),mo={set:en,unset:on,exec:tn},po=a({meta:{name:"env",description:"Show the workspace env (key names only \u2014 never values)"},subCommands:mo,async run({rawArgs:e}){let n=e.find((c)=>!c.startsWith("-"));if(n&&Object.hasOwn(mo,n))return;let i=await Te(),l=await dn(i.path);console.log(`
51
+ `+vi(i,l)+`
52
+ `),process.exit(0)}});function $e(e,n){console.log(`
53
+ `+t.bold(" Commands")),console.log(ot([[t.bold(`moi ${e} init`)+" "+t.dim(n),"Install Moi skills and register the workspace"]]," "))}function Re(e,n,i){return n===1?`moi ${e} init`:`moi ${e} init <${i}>`}function Fe(e){console.log(R(["","profile","model","workspace"].map((n)=>t.dim(n)),e.map((n)=>[n.isDefault?t.green("\u25CF"):" ",n.isDefault?t.bold(n.agentId):n.agentId,n.model??t.dim("\u2014"),t.dim(n.path)])))}var nn=a({meta:{name:"init",description:"Install Moi skills into a Hermes profile workspace. Run without args to list discovered profiles."},args:{profile:{type:"positional",required:!1,description:"Profile id or description (omit to list profiles)"}},async run({args:e}){let n=await ve();if(n.length===0)console.error(`
54
+ `+t.red("\u2717")+` No Hermes profiles discovered.
55
+ `+t.dim(" Install Hermes and run "+t.bold("hermes setup")+` first.
56
+ `)),process.exit(1);if(!e.profile&&n.length>1)console.log(`
57
+ `+t.bold("Hermes profiles")),console.log(t.dim(" Run "+t.bold("moi hermes init <profile>")+` to install skills.
58
+ `)),Fe(n),console.log(),process.exit(0);let i=e.profile?Ns(n,e.profile):n[0];if(!i)console.error(`
59
+ `+t.red("\u2717")+" Profile not found: "+t.bold(e.profile)+`
60
+ `),console.log(` Available:
61
+ `),Fe(n),console.log(),process.exit(1);let{scaffold:l,skillsDir:c,installLogPath:f}=await J(i.path,"hermes");if(l!=="exists"&&l!=="skipped")if(l==="installing")console.log(`
62
+ `+t.dim(" Widget dependencies still installing in .moi/ (background)")),console.log(t.dim(" Install log: "+f));else if(l===0)console.log(`
63
+ `+t.dim(" Installed widget dependencies in .moi/"));else console.warn(`
64
+ `+t.yellow(` bun install failed (exit ${l}) \u2014 run it manually in .moi/`)),console.warn(t.dim(" Install log: "+f));let d=await z(i.path,{harness:"hermes",name:i.name,agentId:i.agentId,isDefault:i.isDefault});console.log(`
65
+ `+t.green("\u2713")+" Installed skills to "+t.bold(c)),console.log(t.dim(" Profile: ")+t.bold(i.agentId)+(i.model?t.dim(" ("+i.model+")"):""));let u=process.stdout.isTTY;if(await P()){let h=`http://localhost:${w}/workspace/${d.id}`;if(await ee(i.path),u)console.log(" Opening "+t.bold(h)+`
66
+ `),await _e(h);else console.log(" Ready at "+t.bold(h)+`
67
+ `)}else console.log(" Run "+t.bold("moi start")+` to open in the browser
68
+ `);process.exit(0)}}),fo=a({meta:{name:"hermes",description:"Hermes Agent integration commands"},async run({rawArgs:e}){if(e.some((i)=>!i.startsWith("-")))return;console.log(`
69
+ `+t.bold("Hermes")),$e("hermes","[profile]");let n=await ve().catch(()=>[]);if(n.length===0){console.log(`
70
+ `+t.dim("No profiles discovered \u2014 install Hermes and run ")+t.dim("hermes setup")+`
71
+ `);return}console.log(`
72
+ `+t.bold(" Profiles")),Fe(n),console.log(t.dim(`
73
+ Run `)+t.bold(Re("hermes",n.length,"profile"))+`
74
+ `)},subCommands:{init:nn}});import{existsSync as xn}from"fs";import{join as xo,resolve as Cn}from"path";import{existsSync as rn}from"fs";import{join as sn,resolve as uo}from"path";var pe=["claude-code","codex","hermes","openclaw"],re={"claude-code":"Claude Code",codex:"Codex",hermes:"Hermes",openclaw:"OpenClaw"};function go(e){return pe.includes(e)}var ho={hermesProfiles:ve,openclawAgents:Ie,codexWorkspaces:async()=>(await Xr(new Set)).map((e)=>e.path),claudeCodeWorkspaces:async()=>{let{claudeCodeHarness:e}=await import("./chunk-jb63ns1z.js");return(await e.discoverWorkspaces?.(new Set)??[]).map((i)=>i.path)},hasClaudeConfigDir:(e)=>rn(sn(e,".claude"))};async function ne(e,n){try{return await e()}catch{return n}}function wo(e){return{harness:"hermes",agent:{agentId:e.agentId,...e.name?{name:e.name}:{},isDefault:e.isDefault},reason:`a Hermes profile workspace (${e.agentId})`}}function yo(e){return{harness:"openclaw",agent:{agentId:e.agentId,...e.name?{name:e.name}:{},isDefault:e.isDefault,...e.lastRunAt?{lastRunAt:e.lastRunAt}:{}},reason:`an OpenClaw agent workspace (${e.agentId}${e.name?", "+e.name:""})`}}async function vo(e,n={}){let i={...ho,...n},l=uo(e),c=(await ne(i.hermesProfiles,[])).find((d)=>d.path===l);if(c)return wo(c);let f=(await ne(i.openclawAgents,[])).find((d)=>d.path===l);if(f)return yo(f);if((await ne(i.codexWorkspaces,[])).includes(l))return{harness:"codex",reason:"Codex session history here"};if((await ne(i.claudeCodeWorkspaces,[])).includes(l))return{harness:"claude-code",reason:"Claude Code session history here"};if(i.hasClaudeConfigDir(l))return{harness:"claude-code",reason:"a .claude/ directory here"};return null}async function bo(e,n,i={}){let l={...ho,...i},c=uo(n);if(e==="hermes"){let f=(await ne(l.hermesProfiles,[])).find((d)=>d.path===c);return f?wo(f).agent??null:null}if(e==="openclaw"){let f=(await ne(l.openclawAgents,[])).find((d)=>d.path===c);return f?yo(f).agent??null:null}return null}import{existsSync as an}from"fs";import{homedir as ln,tmpdir as pn}from"os";import{join as wn}from"path";function Oe(e,n){if(n||!an(wn(e,"dist","index.html")))return e;return ln()||pn()||e}import{join as kn}from"path";function ko(e=Bun.version){if(nt)throw Error("Development mode requires a Moi source checkout");let n=$i.slice(4);if(!Bun.semver.satisfies(e,`>=${n}`))throw Error(`Moi development requires Bun ${n} or newer (running ${e}). Run \`bun upgrade --version ${n}\`, then restart \`bun run dev\`.`)}function Y(e,n=process.env,i=[]){let l=[process.execPath,he("cli.ts"),"start",...i];return Bun.spawn(l,{stdin:"inherit",stdout:"inherit",stderr:"inherit",cwd:e,env:{...n,MOI_SERVER:"1"}})}async function So(e,n){let{watch:i}=await import("fs"),l=Y(e,n),c=!1,f;async function d(u){if(c)return;c=!0,console.log(t.dim(`
75
+ \u21BB ${u} \u2014 restarting server\u2026`));try{l.kill("SIGTERM")}catch{}let g=setTimeout(()=>{try{l.kill("SIGKILL")}catch{}},3000);await l.exited,clearTimeout(g),c=!1,l=Y(e,n)}for(let u of["server","lib"])i(kn(e,u),{recursive:!0},(g,h)=>{if(!h||!h.endsWith(".ts"))return;clearTimeout(f),f=setTimeout(()=>d(`${h} changed`),100)});for(let u of["SIGINT","SIGTERM"])process.on(u,()=>{try{l.kill("SIGTERM")}catch{}process.exit(0)});await new Promise(()=>{})}async function $n(e,n){if(n!==void 0){let c=n.trim();if(!go(c))console.error(`
76
+ `+t.red("\u2717")+" Unknown harness: "+t.bold(n)),console.error(t.dim(" Valid values: "+pe.join(", "))+`
77
+ `),process.exit(1);let f=await bo(c,e);if(!f&&(c==="openclaw"||c==="hermes")){let d=c==="hermes"?"profile":"agent";console.log(`
78
+ `+t.yellow("\u26A0")+" No "+re[c]+" "+d+` found at this path \u2014 registering without one.
79
+ `+t.dim(" Run ")+t.bold("moi "+c+" init")+t.dim(" to bind it once "+re[c]+" can see the workspace."))}return{harness:c,agent:f}}let i=(await D()).find((c)=>c.path===e);if(i){let c=i.harness??"claude-code";return console.log(`
80
+ `+t.dim(" Already registered \u2014 initializing for ")+t.bold(re[c])),{harness:c,agent:i.agentId?{agentId:i.agentId,...i.name?{name:i.name}:{},isDefault:i.isDefault??!1,...i.lastRunAt?{lastRunAt:i.lastRunAt}:{}}:null}}let l=await vo(e);if(l)return console.log(`
81
+ `+t.yellow("\u25C6")+" Detected "+l.reason+" \u2014 initializing for "+t.bold(re[l.harness])+"."),{harness:l.harness,agent:l.agent??null};console.error(`
82
+ `+t.red("\u2717")+" No agent harness detected in "+t.bold(e)),console.error(t.dim(` Looked for a Hermes profile, an OpenClaw agent, and Codex or Claude Code history.
83
+ `)),console.error(` Pick one:
84
+ `),console.error(ot(pe.map((c)=>[t.bold("moi init --harness="+c),re[c]])," ")),console.error(),process.exit(1)}var Co=a({meta:{name:"init",description:"Initialize a local or remote workspace and install its skill"},args:{remote:{type:"string",description:"Remote workspace address: ownerId:workspaceId"},json:{type:"boolean",description:"Print remote initialization as JSON"},dir:{type:"positional",default:".",description:"Target directory (default: current)"},harness:{type:"string",description:"Agent harness: "+pe.join(", ")+" (default: auto-detect)"},web:{type:"boolean",default:!1,description:"Start the web server if not already running"},id:{type:"string",description:"Register under this id instead of a generated one \u2014 fails if the workspace is already registered"}},async run({args:e}){if(e.remote!==void 0&&(e.harness||e.id)||e.json&&(e.remote===void 0||e.web)){console.error("--remote cannot be combined with --harness or --id; --json requires --remote without --web"),process.exitCode=1;return}let n=Cn(e.dir),i=bt(n);if(i!==n&&!e.json)console.log(`
85
+ `+t.yellow("\u25C6")+" Ran inside "+t.bold(".moi")+" \u2014 using the workspace root "+t.bold(i)+" instead (no nested .moi created).");let l=xo(i,".moi",".moi");if(xn(l)&&!e.json)console.log(`
86
+ `+t.yellow("\u26A0")+" Found a stray nested "+t.bold(".moi/.moi")+` (from an older bug). Safe to remove:
87
+ `+t.dim(" rm -rf "+l));if(e.id)try{await ti(i,e.id)}catch(g){console.error(`
88
+ `+t.red("\u2717")+" "+g.message+`
89
+ `),process.exit(1)}let c=H,f=process.stdout.isTTY,d;if(e.remote!==void 0)try{let g=await eo(i,pt(e.remote));if(e.json){console.log(JSON.stringify(g));return}if(d=g,console.log(t.green("\u2713")+" Linked "+t.bold(g.path)+" to "+e.remote),console.log(`
90
+ Next:`),console.log(" 1. Read "+xo(ye(g.path),"moi-workspace","SKILL.md")),console.log(" 2. Run commands from "+g.path),console.log(" 3. Run `moi remote` for available commands\n"),!e.web)return}catch(g){console.error(g instanceof Error?g.message:"Remote initialization failed"),process.exitCode=1;return}else{let g=await O(i);if(g.remote){console.error(`This is a remote workspace \u2014 use moi init --remote ${g.remote.user_id}:${g.remote.workspace_id}`),process.exitCode=1;return}let{harness:h,agent:v}=await $n(i,e.harness);console.log();let{scaffold:b,skillsDir:x,installLogPath:k}=await J(i,h);if(b!=="exists"&&b!=="skipped")if(b==="installing")console.log(t.dim(" Widget dependencies still installing in .moi/ (background)")),console.log(t.dim(" Install log: "+k));else if(b===0)console.log(t.dim(" Installed widget dependencies in .moi/"));else console.warn(t.yellow(` bun install failed (exit ${b}) \u2014 run it manually in .moi/`)),console.warn(t.dim(" Install log: "+k));d=await z(i,{...e.id?{id:e.id}:{},harness:h,...v?{name:v.name,agentId:v.agentId,isDefault:v.isDefault,lastRunAt:v.lastRunAt}:{}}),console.log(t.green("\u2713")+" Initialized "+t.bold(i)+t.dim(" ("+h+")")),console.log(" Skills installed to "+t.dim(x)+" \u2014 ask "+(h==="claude-code"?"Claude":"your agent")+` to build a widget or a view to get started
91
+ `)}let u=await P();if(!u&&e.web){console.log(t.dim(" Starting server\u2026"));let g=Oe(c,!1),h=Y(g);if(u=await to(),!u)console.error(t.red(` Server failed to start
92
+ `)),await h.exited,process.exit(1);let v=`http://localhost:${w}/workspace/${d.id}`;if(console.log(t.green("\u2713")+" Server started on http://localhost:"+w),f)console.log(" Opening "+t.bold(v));if(console.log(t.dim(` Press Ctrl+C to stop
93
+ `)),f)await _e(v);process.exit(await lr(h,()=>Y(g)))}if(u){await ee(i);let g=`http://localhost:${w}/workspace/${d.id}`;if(f)console.log(" Opening "+t.bold(g)+`
94
+ `),await _e(g);else console.log(" Ready at "+t.bold(g)+`
95
+ `);process.exit(0)}console.log(" Run "+t.bold("moi start")+` to open in the browser
96
+ `)}});import{resolve as Rn}from"path";var $o=a({meta:{name:"navigate",description:"Navigate the last active browser showing this workspace"},args:{href:{type:"positional",required:!0,description:"Workspace address, e.g. moi:/views/events?eventId=123"},dir:S},run({args:e}){try{let i=Pt(e.href);if(!i.startsWith("moi:/")||i.startsWith("moi:/files/"))throw Error("Navigation needs a workspace page address")}catch(i){console.error(i instanceof Error?i.message:"Invalid workspace address"),process.exit(1)}let n=Rn(e.dir);j(n,{type:"navigate",path:n,href:e.href},(i)=>{console.log(`
97
+ `+t.green("\u2713")+" Navigated to "+t.bold(String(i.href))+`
98
+ `)})}});function On(e,n){let i=e.find((c)=>c.agentId===n);if(i)return i;let l=n.toLowerCase();return e.find((c)=>c.name?.toLowerCase()===l)??null}function Be(e){console.log(R(["","agentId","name","workspace"].map((n)=>t.dim(n)),e.map((n)=>[n.isDefault?t.green("\u25CF"):" ",n.isDefault?t.bold(n.agentId):n.agentId,n.name??t.dim("\u2014"),t.dim(n.path)])))}var An=a({meta:{name:"init",description:"Install Moi skills into an OpenClaw agent workspace. Run without args to list discovered agents."},args:{agent:{type:"positional",required:!1,description:"Agent id or name (omit to list agents)"}},async run({args:e}){let n=await Ie();if(n.length===0)console.error(`
99
+ `+t.red("\u2717")+` No OpenClaw agents discovered.
100
+ `+t.dim(` Make sure the OpenClaw gateway is running and ~/.openclaw/openclaw.json is set.
101
+ `)),process.exit(1);if(!e.agent&&n.length>1)console.log(`
102
+ `+t.bold("OpenClaw agents")),console.log(t.dim(" Run "+t.bold("moi openclaw init <agentId>")+` to install skills.
103
+ `)),Be(n),console.log(),process.exit(0);let i=e.agent?On(n,e.agent):n[0];if(!i)console.error(`
104
+ `+t.red("\u2717")+" Agent not found: "+t.bold(e.agent)+`
105
+ `),console.log(` Available:
106
+ `),Be(n),console.log(),process.exit(1);let{scaffold:l,skillsDir:c,installLogPath:f}=await J(i.path,"openclaw");if(l!=="exists"&&l!=="skipped")if(l==="installing")console.log(`
107
+ `+t.dim(" Widget dependencies still installing in .moi/ (background)")),console.log(t.dim(" Install log: "+f));else if(l===0)console.log(`
108
+ `+t.dim(" Installed widget dependencies in .moi/"));else console.warn(`
109
+ `+t.yellow(` bun install failed (exit ${l}) \u2014 run it manually in .moi/`)),console.warn(t.dim(" Install log: "+f));let d=await z(i.path,{harness:"openclaw",name:i.name,agentId:i.agentId,isDefault:i.isDefault,lastRunAt:i.lastRunAt});console.log(`
110
+ `+t.green("\u2713")+" Installed skills to "+t.bold(c)),console.log(t.dim(" Agent: ")+t.bold(i.agentId)+(i.name?t.dim(" ("+i.name+")"):""));let u=process.stdout.isTTY;if(await P()){let h=`http://localhost:${w}/workspace/${d.id}`;if(await ee(i.path),u)console.log(" Opening "+t.bold(h)+`
111
+ `),await _e(h);else console.log(" Ready at "+t.bold(h)+`
112
+ `)}else console.log(" Run "+t.bold("moi start")+` to open in the browser
113
+ `);process.exit(0)}}),Ro=a({meta:{name:"openclaw",description:"OpenClaw integration commands"},async run({rawArgs:e}){if(e.some((i)=>!i.startsWith("-")))return;console.log(`
114
+ `+t.bold("OpenClaw")),$e("openclaw","[agent]");let n=await Ie().catch(()=>[]);if(n.length===0){console.log(`
115
+ `+t.dim("No agents discovered \u2014 start the OpenClaw gateway and check ")+t.dim("~/.openclaw/openclaw.json")+`
116
+ `);return}console.log(`
117
+ `+t.bold(" Agents")),Be(n),console.log(t.dim(`
118
+ Run `)+t.bold(Re("openclaw",n.length,"agentId"))+`
119
+ `)},subCommands:{init:An}});var Oo=a({meta:{name:"refresh",description:"Refresh widget and view data in your tabs for the current workspace."},args:{only:q},async run({args:e}){let n=F(e.only),i=await te(process.cwd()),l=new WebSocket(N);l.onopen=()=>l.send(JSON.stringify({type:"applets:refresh",only:n,path:process.cwd()})),l.onmessage=(c)=>{let f=JSON.parse(String(c.data));if(f.error)console.error(`
120
+ `+t.red("\u2717")+" "+f.error+`
121
+ `),l.close(),process.exit(1);if(console.log(`
122
+ `+t.green("\u2713")+" Refresh signal sent"+(n?` (${n})`:"")+`
123
+ `),i)console.log(t.yellow(i)+`
124
+ `);l.close(),process.exit(0)},l.onerror=()=>void _()}});import{mkdir as Tn,rename as In,rm as En}from"fs/promises";import{basename as Nn,dirname as Pn,resolve as Ve}from"path";var be={type:"boolean",description:"Print JSON result"},Wn=s({exitCode:m().int(),stdout:r(),stderr:r()});async function jn(e,n=!1){let i=Wn.parse(await e.json());if(n)console.log(JSON.stringify(i));else process.stdout.write(i.stdout),process.stderr.write(i.stderr);process.exitCode=i.exitCode<0?1:i.exitCode}async function To(e,n,i){let l=await B(i);if(!l)return!1;let c=await gt(M.commands.path(l),{method:"POST",body:JSON.stringify({command:e,args:n}),contentType:"application/json"});return await jn(c),!0}var Dn=Qt("type",[s({type:o("stdout"),data:r()}),s({type:o("stderr"),data:r()}),s({type:o("exit"),code:m().int()})]);async function ie(){let e=await B();if(!e){let n=await dr(process.cwd()),i=await O(n),l="This folder is not linked to a remote workspace";if(!i.remote&&await Bun.file(ge(n)).exists()){let c=Bun.stripANSI(i.name||Nn(n)).replace(/[\u0000-\u001f\u007f-\u009f]/g,"");l+=`
125
+ It is an existing local workspace: ${c}`}throw Error(l)}return{file:(n,i)=>gt(M.files.path(e,n),i),exec:(n)=>gt(M.exec.path(e),n)}}async function Ao(){if(process.stdin.isTTY)throw Error("Supply content or pipe it on stdin");return Bun.stdin.text()}function Io(e){let n=a({meta:{name:"read",description:"Read a remote workspace file to stdout"},args:{file:{type:"positional",required:!0}},run:({args:u})=>e(async()=>{let g=await(await ie()).file(u.file);if(g.body)for await(let h of g.body)await Bun.write(Bun.stdout,h)})}),i=a({meta:{name:"write",description:"Write a remote file; content argument or stdin"},args:{file:{type:"positional",required:!0},content:{type:"positional",required:!1},json:be},run:({args:u})=>e(async()=>{let g=await(await ie()).file(u.file,{method:"PUT",body:u.content??await Ao(),contentType:"application/octet-stream"});console.log(u.json?JSON.stringify(await g.json()):`Wrote ${u.file}`)})}),l=a({meta:{name:"patch",description:"Apply a unified diff to a remote file (stdin or --patch-file)"},args:{file:{type:"positional",required:!0},"patch-file":{type:"string"},json:be},run:({args:u})=>e(async()=>{let g=u["patch-file"]?await Bun.file(Ve(u["patch-file"])).text():await Ao(),h=await(await ie()).file(u.file,{method:"PATCH",body:JSON.stringify({patch:g}),contentType:"application/json"});console.log(u.json?JSON.stringify(await h.json()):`Patched ${u.file}`)})}),c=a({meta:{name:"file-upload",description:"Upload a local file to a remote workspace path"},args:{source:{type:"positional",required:!0},destination:{type:"positional",required:!0},json:be},run:({args:u})=>e(async()=>{let g=Bun.file(Ve(u.source));if(!await g.exists())throw Error("Local source file not found");let h=await(await ie()).file(u.destination,{method:"PUT",body:g,contentType:"application/octet-stream"});console.log(u.json?JSON.stringify(await h.json()):`Uploaded ${u.destination}`)})}),f=a({meta:{name:"file-download",description:"Download a remote workspace file to a local path"},args:{source:{type:"positional",required:!0},destination:{type:"positional",required:!0},json:be},run:({args:u})=>e(async()=>{let g=await(await ie()).file(u.source),h=Ve(u.destination),v=`${h}.${crypto.randomUUID()}.tmp`;await Tn(Pn(h),{recursive:!0});try{await Bun.write(v,g),await In(v,h)}finally{await En(v,{force:!0})}console.log(u.json?JSON.stringify({ok:!0,path:h}):`Downloaded ${u.destination}`)})}),d=a({meta:{name:"exec",description:"Run a shell command on the remote host, in this workspace"},args:{command:{type:"positional",required:!0},json:be},run:({args:u})=>e(async()=>{let g=new AbortController,h=await ie(),v=crypto.randomUUID(),b,x=()=>{b??=h.exec({method:"POST",body:JSON.stringify({cancel:v}),contentType:"application/json",signal:AbortSignal.timeout(1e4)}).then(async(k)=>{await k.body?.cancel()}).catch(()=>{console.error("Could not confirm the remote command stopped")}).finally(()=>g.abort())};process.once("SIGINT",x);try{let k=await h.exec({method:"POST",body:JSON.stringify({command:u.command,id:v}),contentType:"application/json",signal:g.signal});if(!k.body)throw Error("Remote execution returned no stream");let y="",A,E=new TextDecoder;for await(let Ot of k.body){y+=E.decode(Ot,{stream:!0});let je;while((je=y.indexOf(`
126
+ `))!==-1){let Tt=y.slice(0,je);y=y.slice(je+1);let ae=Dn.parse(JSON.parse(Tt));if(u.json)console.log(JSON.stringify(ae));if(ae.type==="exit")A=ae.code;else if(!u.json)(ae.type==="stdout"?process.stdout:process.stderr).write(ae.data)}}if(A===void 0||y)throw Error("Remote execution disconnected before the exit code; command may still have run");process.exitCode=A<0?1:A}catch(k){if(!b)throw k}finally{if(process.removeListener("SIGINT",x),await b,b)process.exitCode=130}})});return{read:n,write:i,patch:l,exec:d,"file-upload":c,"file-download":f}}import{clearLine as Ln,cursorTo as Eo}from"readline";var T=(e)=>Bun.stripANSI(e).replace(/[\u0000-\u001f\u007f-\u009f]/g,"");async function No(){try{let{root:e,harness:n}=await Ne(process.cwd());if(!n&&!await Bun.file(ge(e)).exists())return;let i=await te(e);if(i)console.error(`
127
+ `+t.yellow(i))}catch{}}async function U(e){try{await e()}catch(n){if(n instanceof fe||n instanceof Error&&n.message==="Not signed in \u2014 run moi remote login")console.error(`${t.dim("\u203A")} Signed out`),console.error(t.dim("\u203A Run ")+t.cyan("moi remote login")+t.dim(" to connect to Moi Cloud"));else console.error(n instanceof Error?n.message:"Cloud request failed");process.exitCode=1}}function Mn(){if(!process.stderr.isTTY)return console.error("Waiting for authentication\u2026"),()=>{};let n=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],i=0,l=()=>{Eo(process.stderr,0),process.stderr.write(t.dim(`${n[i++%n.length]} ${"Waiting for authentication\u2026"}`))};l();let c=setInterval(l,80),f=()=>{clearInterval(c),Ln(process.stderr,0),Eo(process.stderr,0),process.removeListener("SIGINT",d)},d=()=>{f(),process.exit(130)};return process.once("SIGINT",d),f}var Un=a({meta:{name:"login",description:"Sign in to Moi Cloud in your browser (for humans only)"},args:{browser:{type:"boolean",default:!0,description:"Open the login page (use --no-browser to print its URL only)"}},async run({args:e}){await U(async()=>{let n=()=>{};try{await bs(async(c,f)=>{if(console.log(`
128
+ Visit ${t.bold(c)}
129
+ Code: ${T(f)}
130
+ `),e.browser)await Pr(c).catch(()=>{});n=Mn()})}finally{n()}let{me:i}=await Jn(),l="email"in i?i.email:i.name;console.log(`${t.green("\u2713")} Signed in as ${T(l)}
131
+ `)})}}),Hn=a({meta:{name:"logout",description:"Sign out of Moi Cloud"},args:{yes:{type:"boolean",description:"Confirm permanently revoking this agent login"}},async run({args:e}){await U(async()=>{await vs(e.yes),console.log(`${t.green("\u2713")} Signed out`)})}}),se={type:"boolean",description:"Print JSON"},qn=a({meta:{name:"rename-agent",description:"Change your agent name across workspaces (for agents only)"},args:{name:{type:"positional",required:!0},json:se},async run({args:e}){await U(async()=>{let n=await Ts(e.name);console.log(e.json?JSON.stringify(n):`Agent renamed to ${T(n.name)}`)})}}),zn=a({meta:{name:"invitations",description:"List pending workspace invitations"},args:{json:se},async run({args:e}){await U(async()=>{let n=await Xn();if(e.json)console.log(JSON.stringify(n));else if(!n.length)console.log("No pending invitations");else for(let i of n)console.log(`${T(i.id)} ${T(i.workspaceName)} \u2014 ${T(i.inviter.name)}`)})}}),Fn=a({meta:{name:"workspaces",description:"List shared workspaces and pending invitations"},args:{json:se},async run({args:e}){await U(async()=>{let[n,i]=await Promise.all([$r(),Xn()]);if(e.json){console.log(JSON.stringify({workspaces:n,invitations:i},null,2));return}if(console.log(`
132
+ `+t.bold("Available shared workspaces")+`
133
+ `),n.length)console.log(R(["Workspace","Shared by","Remote ID"].map((l)=>t.dim(l)),n.map((l)=>[T(l.id),T(l.owner.email),T(`${l.owner.id}:${l.id}`)]))),console.log(`
134
+ `+t.dim("To link from a new folder: ")+t.cyan("moi init --remote <remote-id>"));else console.log(" No shared workspaces yet");if(console.log(`
135
+ `+t.bold("Pending invitations")+`
136
+ `),i.length)console.log(R(["Workspace","Invited by","Invitation ID"].map((l)=>t.dim(l)),i.map((l)=>[T(l.workspaceName),T(l.inviter.email),T(l.id)]))),console.log(`
137
+ `+t.dim("To accept: ")+t.cyan("moi remote accept <invitation-id>"));else console.log(" No pending invitations");console.log(`
138
+ Help and full command list: `+t.cyan("moi remote workspaces --help")+`
139
+ `)})}}),Bn=a({meta:{name:"accept",description:"Accept a workspace invitation as a human or agent"},args:{invite:{type:"positional",required:!0},name:{type:"string",description:"Your agent display name, shown to workspace members"},client:{type:"string",description:"The app you run in, as a lowercase id such as dot or grok-bot"},json:se},async run({args:e}){await U(async()=>{let n=await Ss(e.invite,e.name,e.client);console.log(e.json?JSON.stringify(n):`Invitation accepted
140
+
141
+ Create a local linked folder (choose an unused folder name):
142
+ moi init ./workspace-folder --remote ${n.remote.user_id}:${n.remote.workspace_id}`)})}}),Vn=a({meta:{name:"leave",description:"Leave a shared workspace; keep local files"},args:{workspace:{type:"positional",required:!1,description:"ownerId:workspaceId (defaults to current folder)"},json:se},async run({args:e}){await U(async()=>{let n=e.workspace!==void 0?pt(e.workspace):await B();if(!n)throw Error("No remote workspace here \u2014 run from a linked workspace folder or provide ownerId:workspaceId");let i=await Es(n.user_id,n.workspace_id);console.log(e.json?JSON.stringify(i):"Left the workspace; local files kept")})}}),Po={...Io(U),login:Un,logout:Hn,"rename-agent":qn,workspaces:Fn,invitations:zn,accept:Bn,leave:Vn},Wo=a({meta:{name:"remote",description:"Show your identity and linked workspace commands"},args:{json:se},subCommands:Po,setup({rawArgs:e}){let n=e.indexOf("--");if((n<0?e:e.slice(0,n)).some((l)=>l==="--path"||l.startsWith("--path=")))throw Error("Unknown option --path \u2014 run this command from the workspace folder")},async run({args:e,rawArgs:n}){let i=n.find((l)=>!l.startsWith("-"));if(i&&Object.hasOwn(Po,i))return;await U(async()=>{let l={...await Jn(),currentWorkspace:await B()};if(e.json){console.log(JSON.stringify(l,null,2)),await No();return}let c="email"in l.me?l.me.email:l.me.client;console.log(`
143
+ Signed in as `+t.bold(T(l.me.name||c))+t.dim(` <${T(c)}>`));let f=l.currentWorkspace;if(f){let d=l.workspaces.find((u)=>u.id===f.workspace_id&&u.owner.id===f.user_id);console.log(`
144
+ Current workspace is linked to: `+t.bold(T(f.workspace_id))+(d?" by "+T(d.owner.email):"")),console.log("Remote ID: "+T(`${f.user_id}:${f.workspace_id}`)),console.log(`
145
+ `+ot([[t.cyan("moi remote read <remote-path>"),"Read a file"],[t.cyan('moi remote write <remote-path> "content"'),"Write a file"],[t.cyan("moi remote patch <remote-path>"),"Apply a diff from stdin"],[t.cyan('moi remote exec "command"'),"Run a command remotely"],[t.cyan("moi remote file-upload <local-path> <remote-path>"),"Upload a local file"],[t.cyan("moi remote file-download <remote-path> <local-path>"),"Download a remote file"]])),console.log(`
146
+ `+t.cyan("moi check|bundle|theme|config|tabs|ui-components|call-server-fn|debug|scratch")+`
147
+ `+t.dim("These regular commands work on the remote workspace"))}else console.log(`
148
+ This folder is not linked to a remote workspace`);if(console.log(`
149
+ `+t.dim("Help and full command list: ")+t.cyan("moi remote --help")),f)console.log(t.dim("Command help: ")+t.cyan("moi remote <command> --help"));console.log(),await No()})}});import{tmpdir as Lo}from"os";import{join as Mo,resolve as I}from"path";function Q(e){let n=e.split(",").map((i)=>Number(i.trim()));if(n.length!==2||!n.every((i)=>Number.isFinite(i)))throw Error(`Expected "x,y", got "${e}"`);return{x:n[0],y:n[1]}}function jo(e){if(/^-?\d+(?:\.\d+)?\s*,\s*-?\d+(?:\.\d+)?$/.test(e))return Q(e);return{name:e}}var _o={black:"#1d1d1d",red:"#e03131",yellow:"#f1ac4b",green:"#099268",blue:"#4465e9",grey:"#9fa8b2"},Ae=Object.keys(_o),Uo={small:"m",large:"xl"},Ho=Object.keys(Uo),qo={regular:"m",big:"xl"},zo=Object.keys(qo),Fo={none:"none",semi:"solid",pattern:"pattern",solid:"fill"},Jo=Object.keys(Fo);function Do(e){let n=e.trim().replace(/^#/,"");if(n.length===3)n=n.replace(/(.)/g,"$1$1");if(!/^[0-9a-fA-F]{6}$/.test(n))return null;return[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]}function Kn(e){let n=e.trim().toLowerCase();if(Ae.includes(n))return n;let i=Do(e);if(!i)throw Error(`Unknown color "${e}". Use a hex like "#4465e9" or one of: ${Ae.join(", ")}.`);let l="black",c=1/0;for(let f of Ae){let[d,u,g]=Do(_o[f]),h=(d-i[0])**2+(u-i[1])**2+(g-i[2])**2;if(h<c)c=h,l=f}return l}function Yn(e){let n=Uo[e.trim().toLowerCase()];if(!n)throw Error(`Unknown stroke "${e}". Use one of: ${Ho.join(", ")}.`);return n}function Gn(e){let n=qo[e.trim().toLowerCase()];if(!n)throw Error(`Unknown font size "${e}". Use one of: ${zo.join(", ")}.`);return n}function Zn(e){let n=Fo[e.trim().toLowerCase()];if(!n)throw Error(`Unknown fill "${e}". Use one of: ${Jo.join(", ")}.`);return n}function Qn(e){if(!e)return"lo";let n=e.trim().toLowerCase();if(n==="lo"||n==="hi")return n;throw Error(`Unknown quality "${e}". Use "lo" or "hi".`)}var Pe={type:"string",description:`Color: ${Ae.join(", ")}, or any hex (snapped to nearest)`},er={type:"string",description:`Stroke weight: ${Ho.join(", ")}`},Ye={type:"string",description:`Font size: ${zo.join(", ")}`},nr={type:"string",default:"semi",description:`Fill: ${Jo.join(", ")} (default: semi)`};function We(e){return{...e.color?{color:Kn(e.color)}:{},...e.stroke?{size:Yn(e.stroke)}:{},...e.fontSize?{size:Gn(e.fontSize)}:{},...e.fill?{fill:Zn(e.fill)}:{}}}function L(e,n,i){j(e,{type:"scratch",path:e,op:n},i)}function ke(e){let n=e.result;console.log(`
150
+ `+t.green("\u2713")+" added "+t.bold(n?.name??"(shape)")+`
151
+ `)}var ir=a({meta:{name:"read",description:"Print the canvas shapes as JSON (served off disk)"},args:{dir:S},run({args:e}){L(I(e.dir),{kind:"read"},(n)=>{console.log(JSON.stringify(n.shapes??[],null,2))})}}),sr=a({meta:{name:"view",description:"Render the canvas to a PNG (needs an open Scratchpad tab)"},args:{dir:S,out:{type:"string",description:"Output PNG path (default: a temp file)"}},async run({args:e}){L(I(e.dir),{kind:"view"},async(n)=>{let i=n.result;if(!i?.image)console.error(t.red("No image returned")),process.exit(1);let l=i.image.replace(/^data:image\/png;base64,/,""),c=e.out?I(e.out):Mo(Lo(),`moi-scratch-${Date.now()}.png`);await Bun.write(c,Buffer.from(l,"base64")),console.log(c)})}}),cr={"image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/webp":"webp","image/gif":"gif","image/svg+xml":"svg","image/avif":"avif","image/apng":"apng","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov"},mr=a({meta:{name:"read-image",description:"Save an image shape to a file by id (served off disk)"},args:{id:{type:"positional",required:!0,description:"Image shape id (from `scratch read`)"},out:{type:"string",description:"Output file path (default: a temp file)"},dir:S},async run({args:e}){L(I(e.dir),{kind:"read-image",name:e.id},async(n)=>{let i=n.src;if(!i)console.error(t.red("No image data")),process.exit(1);if(/^https?:\/\//.test(i)){console.log(i);return}let l=i.match(/^data:([^;,]+)(;base64)?,(.*)$/s);if(!l)console.error(t.red("Unrecognized image source")),process.exit(1);let[,c,f,d]=l,u=f?Buffer.from(d,"base64"):Buffer.from(decodeURIComponent(d),"utf8"),g=cr[c]??"bin",h=e.id.replace(/[^a-zA-Z0-9_-]/g,"_"),v=e.out?I(e.out):Mo(Lo(),`moi-scratch-${h}-${Date.now()}.${g}`);await Bun.write(v,u),console.log(v)})}}),pr=a({meta:{name:"text",description:"Add a text shape"},args:{at:{type:"string",required:!0,description:'Position "x,y"'},text:{type:"string",required:!0,description:"Text content"},id:{type:"string",description:"Stable name to address this shape later"},color:Pe,fontSize:Ye,dir:S},run({args:e}){let{x:n,y:i}=Q(e.at);L(I(e.dir),{kind:"add-text",name:e.id??"",x:n,y:i,text:e.text,...We({color:e.color,fontSize:e.fontSize})},ke)}}),fr=a({meta:{name:"rect",description:"Add a rectangle"},args:{at:{type:"string",required:!0,description:'Top-left position "x,y"'},size:{type:"string",required:!0,description:'Size "w,h"'},text:{type:"string",description:"Optional label"},id:{type:"string",description:"Stable name to address this shape later"},color:Pe,fill:nr,fontSize:Ye,dir:S},run({args:e}){let{x:n,y:i}=Q(e.at),{x:l,y:c}=Q(e.size);L(I(e.dir),{kind:"add-rect",name:e.id??"",x:n,y:i,w:l,h:c,...e.text?{text:e.text}:{},...We({color:e.color,fill:e.fill,fontSize:e.fontSize})},ke)}}),ur=a({meta:{name:"note",description:"Add a sticky note"},args:{at:{type:"string",required:!0,description:'Position "x,y"'},text:{type:"string",required:!0,description:"Note content"},id:{type:"string",description:"Stable name to address this shape later"},color:Pe,fontSize:Ye,dir:S},run({args:e}){let{x:n,y:i}=Q(e.at);L(I(e.dir),{kind:"add-note",name:e.id??"",x:n,y:i,text:e.text,...We({color:e.color,fontSize:e.fontSize})},ke)}}),gr=a({meta:{name:"arrow",description:"Add an arrow connecting shapes or points"},args:{from:{type:"string",required:!0,description:'Start: a shape name or "x,y"'},to:{type:"string",required:!0,description:'End: a shape name or "x,y"'},id:{type:"string",description:"Stable name to address this shape later"},elbow:{type:"boolean",description:"Right-angle (squared) routing for diagrams; default is a curved arc"},color:Pe,stroke:er,dir:S},run({args:e}){L(I(e.dir),{kind:"add-arrow",name:e.id??"",from:jo(e.from),to:jo(e.to),...e.elbow?{elbow:!0}:{},...We({color:e.color,stroke:e.stroke})},ke)}}),hr=a({meta:{name:"image",description:"Add an image from a file (resized to fit the canvas)"},args:{path:{type:"positional",required:!0,description:"Path to an image file (png/jpg/webp/gif)"},at:{type:"string",description:'Top-left position "x,y" (default: 0,0)'},id:{type:"string",description:"Stable name to address this shape later"},quality:{type:"string",description:"Resize: lo (default, smaller) or hi (sharper)"},dir:S},run({args:e}){let{x:n,y:i}=e.at?Q(e.at):{x:0,y:0};L(I(e.dir),{kind:"add-image",name:e.id??"",x:n,y:i,path:I(e.path),quality:Qn(e.quality)},ke)}}),wr=a({meta:{name:"add",description:"Add a shape: text, rect, note, arrow, or image"},subCommands:{text:pr,rect:fr,note:ur,arrow:gr,image:hr}}),yr=a({meta:{name:"move",description:"Move a shape to a new position"},args:{id:{type:"positional",required:!0,description:"Shape name"},to:{type:"string",required:!0,description:'New position "x,y"'},dir:S},run({args:e}){let{x:n,y:i}=Q(e.to);L(I(e.dir),{kind:"move",name:e.id,x:n,y:i},()=>console.log(`
152
+ `+t.green("\u2713")+" moved "+t.bold(e.id)+`
153
+ `))}}),vr=a({meta:{name:"set",description:"Relabel / edit a shape's text"},args:{id:{type:"positional",required:!0,description:"Shape name"},text:{type:"string",required:!0,description:"New text"},dir:S},run({args:e}){L(I(e.dir),{kind:"set",name:e.id,text:e.text},()=>console.log(`
154
+ `+t.green("\u2713")+" updated "+t.bold(e.id)+`
155
+ `))}}),br=a({meta:{name:"delete",description:"Delete a shape"},args:{id:{type:"positional",required:!0,description:"Shape name"},dir:S},run({args:e}){L(I(e.dir),{kind:"delete",name:e.id},()=>console.log(`
156
+ `+t.green("\u2713")+" deleted "+t.bold(e.id)+`
157
+ `))}}),kr=a({meta:{name:"clear",description:"Delete every shape \u2014 wipe the whole canvas"},args:{dir:S},run({args:e}){L(I(e.dir),{kind:"clear"},()=>console.log(`
158
+ `+t.green("\u2713")+` cleared the canvas
159
+ `))}}),Bo=a({meta:{name:"scratch",description:"Read and draw on the workspace Scratchpad canvas"},subCommands:{read:ir,"read-image":mr,view:sr,add:wr,move:yr,set:vr,delete:br,clear:kr}});import{existsSync as Sr}from"fs";import{dirname as xr}from"path";function Se(e){if(e===C)return null;return t.yellow("\u26A0")+` Server is running v${e}, this CLI is v${C}.
160
+ `+t.dim(" Restart to match: `moi service restart` (service) or Ctrl-C + `moi start`.")}function G(e){let n=e instanceof V?e.message:String(e);console.error(`
161
+ `+t.red("\u2717")+" "+n+`
162
+ `),process.exit(1)}function Ko(e){if(e){console.log(" server "+t.bold(`v${e.version}`)+` running on ${lt(e)}`+t.dim(` (pid ${e.pid})`));let n=Se(e.version);if(n)console.log(`
163
+ `+n)}else console.log(" "+t.yellow("server did not come up \u2014 check `moi service logs`")+t.dim(" (it may still be starting)"))}var Cr=a({meta:{name:"install",description:"Install and start the user service (launchd on macOS, systemd on Linux)"},args:{port:{type:"string",description:"HTTP port for the service server (default: 13337)"},env:{type:"string",description:"Extra env var names to capture from this shell, comma-separated (e.g. --env MY_TOKEN,OTHER)"}},async run({args:e}){if(He().kind!=="global")try{await hn()}catch(h){G(h)}let i=e.port?Number(e.port):void 0;if(i!==void 0&&(!Number.isInteger(i)||i<1||i>65535))G(new V(`Invalid --port value "${e.port}" \u2014 use a port number.`));let c=((Array.isArray(e.env)?e.env.join(","):e.env)??"").split(",").map((h)=>h.trim()).filter(Boolean),f=mn(process.env,xr(process.execPath),c),d=c.filter((h)=>!(h in f));if(d.length>0)G(new V(`--env ${d.join(", ")}: not set in this shell (or the value is not capturable).`));let u=await oe();if(await P()&&!u?.service)G(new V("A foreground server is running"+(u?.pid?` (pid ${u.pid})`:"")+".\n Stop it (Ctrl-C in its terminal), then rerun `moi service install`."));try{let h=await hn({port:i,extraEnv:c});if(console.log(`
164
+ `+t.green("\u2713")+" Service installed "+t.dim(`(${process.platform==="darwin"?"launchd":"systemd user unit"})`)),console.log(" unit "+t.dim(X(h.unitPath))),h.logPath)console.log(" logs "+t.dim(X(h.logPath)));Ko(h.info),console.log(t.dim(`
165
+ Starts on login, restarts on crash, survives reboots.`));for(let v of h.notes)console.log(t.yellow(" "+v));console.log()}catch(h){G(h)}}}),Rr=a({meta:{name:"uninstall",description:"Stop the service and remove its unit"},async run(){try{let{unitPath:e,existed:n}=await Ei();if(!n){console.log(`
166
+ `+t.dim("\u25CB")+" Service is not installed "+t.dim(`(${X(e)})`)+`
167
+ `);return}console.log(`
168
+ `+t.green("\u2713")+" Service removed "+t.dim(`(${X(e)})`)+`
169
+ `)}catch(e){G(e)}}}),Or=a({meta:{name:"restart",description:"Restart the service server"},async run(){try{let e=await ar();console.log(`
170
+ `+t.green("\u2713")+" Service restarted"),Ko(e),console.log()}catch(e){G(e)}}}),Ar=a({meta:{name:"logs",description:"Show server logs (journalctl on Linux, log file on macOS)"},args:{lines:{type:"string",default:"80",description:"How many trailing lines to show"},follow:{type:"boolean",alias:"f",default:!1,description:"Keep following new output"}},async run({args:e}){let n=Math.max(1,Number(e.lines)||80);if(process.platform==="linux"){let c=["journalctl","--user","-u","moi.service","-n",String(n),"--no-pager"];if(e.follow)c.push("-f");let f=Bun.spawn(c,{stdin:"inherit",stdout:"inherit",stderr:"inherit"});process.exit(await f.exited)}let i=At();if(!Sr(i))console.log(`
171
+ `+t.dim("\u25CB")+" No logs yet "+t.dim(`(${X(i)})`)+`
172
+ `),process.exit(0);console.error(t.dim(X(i)));let l=Bun.spawn(["tail","-n",String(n),...e.follow?["-F"]:[],i],{stdin:"inherit",stdout:"inherit",stderr:"inherit"});process.exit(await l.exited)}});function X(e){let n=process.env.HOME;return n&&e.startsWith(n)?"~"+e.slice(n.length):e}async function Tr(){try{let e=await xi(),n=e.platform==="darwin"?"launchd user agent":"systemd user unit";if(console.log(`
173
+ `+t.bold("moi service")+t.dim(` \u2014 ${n}`)),console.log(),!e.installed)console.log(" "+t.dim("\u25CB")+" Not installed"),console.log(t.dim(" Run `moi service install` to start Moi on login and keep it running.")),console.log(),process.exit(0);let i=e.runtime,l=i===null?t.dim("unknown"):i.state==="running"?t.green("\u25CF running")+(i.pid?t.dim(` (pid ${i.pid})`):""):i.state==="failed"?t.red("\u2717 failed")+t.dim(i.detail?` (${i.detail})`:""):i.state==="unavailable"?t.yellow("? unavailable")+t.dim(i.detail?` \u2014 ${i.detail}`:""):t.dim("\u25CB "+i.state);if(console.log(" state "+l),console.log(" unit "+t.dim(X(e.unitPath))),e.logPath)console.log(" logs "+t.dim(X(e.logPath))+t.dim(" (`moi service logs`)"));else console.log(" logs "+t.dim("journalctl --user -u moi.service (`moi service logs`)"));let c=await oe();if(c){if(console.log(" server "+t.bold(`v${c.version}`)+t.dim(` on ${lt(c)} (pid ${c.pid})`)),!c.service)console.log(t.yellow(" \u26A0 The running server is a foreground `moi start`, not the service."))}else if(i?.state==="running")console.log(" server "+t.yellow("unreachable on the control port"));if(console.log(),e.binMissing&&e.bin)console.log(t.yellow(` \u26A0 The service execs ${e.bin}, which no longer exists`)+t.dim(" (Moi moved or was reinstalled elsewhere).")+`
174
+ `+t.dim(" Rerun `moi service install` to re-capture paths."));if(e.bunMissing)console.log(t.yellow(" \u26A0 No bun on the service PATH \u2014 the server cannot start.")+`
175
+ `+t.dim(" Reinstall bun, then rerun `moi service install`."));if(e.linger==="disabled")console.log(t.yellow(" \u26A0 Lingering is off \u2014 the service stops when your last session ends.")+`
176
+ `+t.dim(" Enable: loginctl enable-linger"));let f=c?Se(c.version):null;if(f)console.log(f.replace(/^/gm," ").replace(/^ {2}\u26A0/," \u26A0")+`
177
+ `);process.exit(0)}catch(e){G(e)}}var Vo={install:Cr,uninstall:Rr,restart:Or,logs:Ar},Yo=a({meta:{name:"service",description:"Run Moi as a user service: `moi service install|uninstall|restart|logs`"},subCommands:Vo,async run({rawArgs:e}){let n=e.find((i)=>!i.startsWith("-"));if(n&&Object.hasOwn(Vo,n))return;await Tr()}});import{resolve as Zo}from"path";async function Ir(e){let{root:n,harness:i}=await Ne(e),l=await Dt(n,i),{changedSkills:c,updatedAppletTypes:f}=l,d=c.length>0?"Skills updated in ":"Skills unchanged in ";console.log(`
178
+ `+t.green("\u2713")+" "+d+t.bold(n)+`
179
+ `),Er(n,l);for(let u of f)console.log(t.dim(" Applet types regenerated: ")+t.bold(`.moi/${u}
180
+ `))}function Er(e,{before:n,status:i,changedSkills:l,changedSkillPaths:c}){let f=new Set(c);console.log(R(["skill","path","from","to"].map((u)=>t.dim(u)),i.skills.map((u)=>{let g=n.find((b)=>b.name===u.name&&b.path===u.path)?.installed??null,h=g!==u.installed,v=f.has(u.path);return[u.name,It(e,u.path),g??t.dim("none"),h?t.green(u.installed??"?"):v?t.green((u.installed??"?")+" (files changed)"):t.dim((u.installed??"?")+" (no change)")]})));let d=l.length>0?` Reload changed skills before using them again: ${l.join(", ")}.`:" No skill files changed. Keep using the copies already in context.";console.log(`
181
+ `+t.dim(d)+`
182
+ `)}function Nr(e){if(Sn(e.installed,e.bundled))return t.yellow("update available");if(Ct(e.installed,e.bundled))return t.dim("patch behind");return t.green("up to date")}var Go=(e,n)=>a({meta:{name:e,description:n},args:{dir:S},async run({args:i}){await Ir(Zo(i.dir))}}),Xo={update:Go("update","Update this workspace\u2019s skills to the version shipped with the CLI"),install:Go("install","Alias for `moi skill update`")},Qo=a({meta:{name:"skill",description:"Show or update the workspace skills shipped with Moi"},subCommands:Xo,args:{dir:S},async run({args:e,rawArgs:n}){let i=n.find((d)=>!d.startsWith("-"));if(i&&i in Xo)return;let{root:l,harness:c}=await Ne(Zo(e.dir)),f=await ct(l,c);if(console.log(`
183
+ `+t.bold("moi skill")+t.dim(" \u2014 workspace skills")+`
184
+ `),console.log(R(["skill","path","installed","bundled","status"].map((d)=>t.dim(d)),f.map((d)=>[d.name,It(l,d.path),d.installed??t.dim("\u2014"),d.bundled??t.dim("\u2014"),Nr(d)]))),f.some((d)=>Ct(d.installed,d.bundled)))console.log(`
185
+ `+t.dim(" Run ")+t.bold("moi skill update")+t.dim(" to refresh."));console.log()}});var et=a({meta:{name:"start",description:"Start the Moi web server"},args:{port:{type:"string",description:"HTTP port to listen on (default: 13337)"}},async run({args:e}){let n=H,i=process.argv.includes("--dev");if(i)ko();let l=process.argv.includes("--debug");if(!process.env.MOI_SERVER){if(await P()){let g=await oe();if(g?.service)console.log(`
186
+ `+t.yellow("\u25C6")+" The Moi service is already running on "+lt(g)+t.dim(` (v${g.version})`)+`
187
+ `+t.dim(" Manage it with `moi service` \u2014 restart, logs, uninstall.")+`
188
+ `);else console.log(`
189
+ `+t.yellow("\u25C6")+" Server is already running on "+lt(g)+`
190
+ `);process.exit(0)}let f={...process.env,PUBLIC_TLDRAW_LICENSE_KEY:process.env.PUBLIC_TLDRAW_LICENSE_KEY??"",...e.port?{PORT:e.port}:{},...i?{MOI_DEV:"1"}:{},...l?{MOI_DEBUG:"1"}:{}};if(i){await So(n,f);return}let d=Oe(n,i),u=Y(d,f);process.exit(await lr(u,()=>Y(d,f)))}Ls();try{await import("./chunk-00rk365r.js")}catch(f){if(f?.code==="EADDRINUSE")console.error(`
191
+ ${t.red("\u2717")} Port already in use (http :${w} / control :${W}) \u2014 `+"is another Moi server running?");else console.error(`
192
+ ${t.red("\u2717")} Server failed to start: ${String(f)}`);if(process.env.MOI_SERVICE)console.error(t.dim(" The service stays idle \u2014 fix this, then `moi service restart`.\n")),process.exit(0);process.exit(1)}let{unixSocket:c}=p();console.log(`
193
+ ${t.green("\u2713")} Server started on ${c??`http://localhost:${w}`}`),console.log(t.dim(` Press Ctrl+C to stop
194
+ `))}});var tt=a({meta:{name:"status",description:"Show server status and registered workspaces"},async run(){let e=await we(),n=await te(process.cwd());if(e.status==="not-running")console.log(`
195
+ `+t.dim("\u25CB")+" Server is "+t.bold("not running")),console.log(t.dim(` cli version ${C}`)+`
196
+ `),process.exit(0);if(e.status==="unreachable")console.log(`
197
+ `+t.yellow("\u25C6")+" Server is "+t.bold("unreachable")),console.log(t.dim(` control port ${ue}:${W} \u2014 ${e.reason}`)),console.log(t.dim(` cli version ${C}`)+`
198
+ `),process.exit(1);let i=await oe();if(console.log(`
199
+ `+t.green("\u25CF")+" Server is "+t.bold("running")+t.dim((i?.unixSocket?` (web socket: ${i.unixSocket}`:` (http port: ${i?.port||w}`)+`, control port: ${W}`+(i?.pid?`, pid: ${i.pid}`:"")+")")),i)console.log(t.dim(` server version ${i.version}`)+(i.service?t.dim(" \xB7 service-managed (`moi service`)"):""));console.log(t.dim(` cli version ${C}`));let l=i?Se(i.version):null;if(l)console.log(`
200
+ `+l);if(await new Promise((c,f)=>{let d=new WebSocket(N);d.onopen=()=>d.send(JSON.stringify({type:"workspace:list"})),d.onmessage=(u)=>{let v=(JSON.parse(String(u.data)).workspaces??[]).length;console.log(t.dim(` ${v} workspace${v===1?"":"s"} registered
201
+ `)),d.close(),c()},d.onerror=()=>void we().then((u)=>f(Error(qe(u))))}),n)console.log(t.yellow(n)+`
202
+ `);process.exit(0)}});import{resolve as Wr}from"path";function jr(e){let n=Wr(e);j(n,{type:"tabs",path:n},(i)=>{let l=Array.isArray(i.tabs)?i.tabs:[];console.log(`
203
+ `+t.bold("moi tabs")+t.dim(" \u2014 workspace tabs")+`
204
+ `),console.log(R(["title","address"].map((c)=>t.dim(c)),l.map((c)=>[c.title,c.href]))),console.log(`
205
+ `+t.dim(" Open one: moi navigate <address>")+`
206
+ `)})}var rt=a({meta:{name:"tabs",description:"List workspace tabs and their navigation addresses"},args:{dir:S},run({args:e}){if(e._.length)console.error("moi tabs only lists tabs. Use moi navigate <address> to navigate."),process.exit(1);jr(e.dir)}});var Dr=(e,n)=>Math.round(e*(n=Math.pow(10,n)))/n,Lr=(e=4)=>(n)=>typeof n==="number"?Dr(n,e):n,at=Lr;var bc=at(2),Mr=(e)=>Math.max(0,Math.min(1,e||0)),Ge=(e)=>Math.round(Mr(e)*255),_r=Je("rgb"),kc=Je("hsl"),Ur=(e)=>{if(e===void 0)return;let n=Ge(e.r),i=Ge(e.g),l=Ge(e.b);return"#"+(16777216|n<<16|i<<8|l).toString(16).slice(1)};var Xe=(e)=>Ur(_r(e));import{resolve as Hr}from"path";function dt(e){let n=Number.parseInt(e.slice(1),16);return[n>>16&255,n>>8&255,n&255]}function mt(e,n){if(!process.stdout.isTTY||!e)return" ";let[i,l,c]=dt(e),[f,d,u]=dt(n??"#000000");return`\x1B[48;2;${i};${l};${c}m\x1B[38;2;${f};${d};${u}m Aa \x1B[0m`}function ft(e){if(!e)return mt();let n=ki(e);return mt(Xe(n.primary),Xe(n.primaryForeground))}var ht=a({meta:{name:"theme",description:"Show or set the workspace appearance"},args:{dir:{type:"positional",default:".",description:"Workspace directory (default: current)"},font:{type:"string",description:"Font theme key to apply"},color:{type:"string",description:"Color preset key to apply"},radius:{type:"string",description:"Radius preset key to apply"},agent:{type:"string",description:"Agent preset key to apply"}},async run({args:e}){let n=Hr(e.dir),i=await te(n),l=new WebSocket(N);l.onopen=()=>l.send(JSON.stringify({type:"theme",path:n,font:e.font??null,color:e.color??null,radius:e.radius??null,agent:e.agent??null})),l.onmessage=(c)=>{let f=JSON.parse(String(c.data));if(f.error)console.error(`
207
+ `+t.red(t.bold("Error:"))+" "+f.error+`
208
+ `),l.close(),process.exit(1);if(f.ok){if(console.log(),f.font){let y=le[f.font];console.log(t.green("\u2713")+" Font set to "+t.bold(y.label)+t.dim(` (${y.sans} / ${y.mono})`))}if(f.color){let y=ce[f.color],A=ft(y.primary);console.log(t.green("\u2713")+" Color set to "+t.bold(y.label)+" "+A)}if(f.radius){let y=Ee[f.radius];console.log(t.green("\u2713")+" Radius set to "+t.bold(y.label))}if(f.agent){let y=xe[f.agent];console.log(t.green("\u2713")+" Agent set to "+t.bold(y.label))}if(console.log(),i)console.log(t.yellow(i)+`
209
+ `);l.close(),process.exit(0)}let d=f.currentFont??De.font,u=f.currentColor??De.color,g=f.currentRadius??De.radius,h=f.currentAgent??De.agent;console.log(`
210
+ `+t.bold("moi theme")+" \u2014 workspace appearance"),console.log(t.dim(" Usage: moi theme --font=<key> --color=<key> --radius=<key> --agent=<key>")+`
211
+ `);let v=Object.keys(le).map((y)=>{let A=le[y],E=y===d;return[E?t.green("\u2192"):" ",E?t.bold(y):y,A.label,t.dim(A.sans),t.dim(A.mono)]});console.log(t.dim(" Fonts")),console.log(R(["","key","label","sans","mono"].map((y)=>t.dim(y)),v)+`
212
+ `);let b=Object.keys(ce).map((y)=>{let A=ce[y],E=y===u;return[E?t.green("\u2192"):" ",E?t.bold(y):y,A.label,ft(A.primary)]});console.log(t.dim(" Colors")),console.log(R(["","key","label","swatch"].map((y)=>t.dim(y)),b)+`
213
+ `);let x=Object.keys(Ee).map((y)=>{let A=Ee[y],E=y===g;return[E?t.green("\u2192"):" ",E?t.bold(y):y,A.label,t.dim(A.radius)]});console.log(t.dim(" Radius")),console.log(R(["","key","label","value"].map((y)=>t.dim(y)),x)+`
214
+ `);let k=Object.keys(xe).map((y)=>{let A=xe[y],E=y===h;return[E?t.green("\u2192"):" ",E?t.bold(y):y,A.label]});if(console.log(t.dim(" Agent")),console.log(R(["","key","label"].map((y)=>t.dim(y)),k)+`
215
+ `),i)console.log(t.yellow(i)+`
216
+ `);l.close(),process.exit(0)},l.onerror=()=>void _()}});var wt=a({meta:{name:"ui-components",description:"UI components for applets"},subCommands:()=>import("./chunk-gbkjshyt.js").then((e)=>e.uiComponentsSubCommands),async run({rawArgs:e}){let{runUiComponentsCatalog:n}=await import("./chunk-gbkjshyt.js");await n(e)}});var kt=a({meta:{name:"update",description:"Update Moi to the latest published version"},args:{check:{type:"boolean",default:!1,description:"Only check the registry, change nothing. Exit 0: up to date (or nothing to update), 1: update available, 2: check failed."}},async run({args:e}){let n=He();if(n.kind==="checkout")console.log(`
217
+ `+t.yellow("\u25C6")+` This Moi runs from a source tree (${n.reason}) \u2014 update it with git instead.
218
+ `),process.exit(0);if(console.log(`
219
+ `+t.bold("moi update")+t.dim(` \u2014 installed v${C}`)),tr(C))console.log(`
220
+ `+t.yellow("\u25C6")+` Prerelease installs are updated manually \u2014 pick the tag you want:
221
+ `+t.dim(` bun i -g moi-computer@next (or @latest to leave the prerelease)
222
+ `)),process.exit(0);let i;try{i=await yn()}catch(u){console.error(`
223
+ `+t.red("\u2717")+" "+(u instanceof Error?u.message:String(u))+`
224
+ `),process.exit(e.check?2:1)}if(!gn(i,C)){if(console.log(t.green("\u2713")+` Already up to date (latest is v${i})`),!e.check)await yt();process.exit(0)}if(e.check)console.log(` update available: ${t.bold("v"+i)}`+t.dim(" \u2014 run `moi update` to install\n")),process.exit(1);console.log(` latest is ${t.bold("v"+i)} \u2014 updating`);let l=await _n();if(!l)console.error(`
225
+ `+t.red("\u2717")+" Could not tell which package manager owns this install"+t.dim(` (${n.root})`)+`.
226
+ Update it yourself with the one you installed Moi with:
227
+ `+Pi(i).map((u)=>t.dim(" "+u)).join(`
228
+ `)+`
229
+ `),process.exit(1);let c=or(l,i);console.log(t.dim(` via ${l}: ${c.join(" ")}
230
+ `));let f=await bn(c);if(f!==0){if(console.error(`
231
+ `+t.red("\u2717")+` ${l} exited with code ${f}.`),console.error(t.dim(" Run it manually: ")+c.join(" ")),l==="npm")console.error(t.dim(" If it failed with EACCES, your npm prefix is root-owned \u2014 fix ownership or use a user-level prefix."));console.error(),process.exit(1)}let d=n.kind==="global"?await vn(n.bin):null;if(d===i)console.log(`
232
+ `+t.green("\u2713")+` Moi updated to ${t.bold("v"+i)}`);else if(d)console.log(`
233
+ `+t.yellow("\u26A0")+` ${l} finished, but \`moi\` on PATH reports v${d} (expected v${i}).
234
+ `+t.dim(" Another install may shadow the updated one \u2014 check `which moi`."));else console.log(`
235
+ `+t.green("\u2713")+` ${l} finished (v${i})`);await yt(i),console.log(),process.exit(0)}});async function yt(e){if(!await P())return;let i=await oe();if(!i){console.log(t.yellow("\u26A0")+" A server is running but too old to report its version \u2014 restart it to finish the update.");return}let l=e??C;if(i.version===l){if(e)console.log(t.green("\u2713")+` Server already on v${i.version}`);return}if(i.service){console.log(t.dim(` restarting the service (server was v${i.version})\u2026`));try{let c=await ar();if(c&&c.version===l)console.log(t.green("\u2713")+` Service restarted on ${t.bold("v"+c.version)}`);else if(c)console.log(t.yellow("\u26A0")+` Service restarted but reports v${c.version} (expected v${l}).
236
+ `+t.dim(" The unit may exec a different install \u2014 see `moi service`."));else console.log(t.yellow("\u26A0")+" Service restarted but the server has not come back up \u2014 `moi service logs`.")}catch(c){console.log(t.yellow("\u26A0")+" Could not restart the service: "+(c instanceof Error?c.message:String(c)))}return}console.log(t.yellow("\u26A0")+` A foreground server is still running v${i.version}`+(i.pid?t.dim(` (pid ${i.pid})`):"")+`.
237
+ `+t.dim(` Restart it when convenient (Ctrl-C, then \`moi start\`) to get v${l}.`))}var St=a({meta:{name:"version",description:"Print the Moi version"},run(){console.log(rr())}});import{resolve as $t}from"path";var qr=a({meta:{name:"set",description:"Set a pending view\u2019s title and icon"},args:{id:{type:"positional",required:!0,description:"View id"},dir:{type:"positional",default:".",description:"Workspace directory (default: current)"},title:{type:"string",description:"Display title"},icon:{type:"string",description:"App icon registry id"}},run({args:e}){let n=$t(e.dir),i=new WebSocket(N);i.onopen=()=>i.send(JSON.stringify({type:"view:set",path:n,id:e.id,title:e.title,icon:e.icon})),i.onmessage=(l)=>{let c=JSON.parse(String(l.data));if(c.error)console.error(`
238
+ `+t.red(t.bold("Error:"))+" "+c.error+`
239
+ `),i.close(),process.exit(1);console.log(`
240
+ `+t.green("\u2713")+" View updated "+t.bold(String(c.viewId??e.id))+`
241
+ `),i.close(),process.exit(0)},i.onerror=()=>void _()}}),zr=a({meta:{name:"create",description:"Create a view, optionally forking a source chat to build it"},args:{dir:{type:"positional",default:".",description:"Workspace directory"},"from-session":{type:"string",description:"Session id to fork into a new view chat"},requirements:{type:"string",required:!0,description:"Complete view requirements"}},run({args:e}){let n=new WebSocket(N);n.onopen=()=>n.send(JSON.stringify({type:"view:create",path:$t(e.dir),fromSessionId:e["from-session"],requirements:e.requirements})),n.onmessage=(i)=>{let l=JSON.parse(String(i.data));if(console.log(JSON.stringify(l,null,2)),l.warning)console.error(l.warning);n.close(),process.exit(l.error?1:0)},n.onerror=()=>void _()}}),Rt=a({meta:{name:"views",description:"Create views and set their build details"},subCommands:{create:zr,set:qr}});import{resolve as Fr}from"path";function Z(e,n,i=[]){let l=n.run;return{...n,...n.subCommands?{subCommands:async()=>{let c=typeof n.subCommands==="function"?await n.subCommands():await n.subCommands,f={};for(let[d,u]of Object.entries(c??{})){let g=typeof u==="function"?await u():await u;f[d]=Z(e,g,[...i,d])}return f}}:{},async run(c){if(n.subCommands&&c.args._.length)return l?.(c);let f=c.args,d=Fr(typeof f.dir==="string"?f.dir:process.cwd()),u=typeof n.args==="function"?await n.args():await n.args,g=Object.entries(u??{}).filter(([,b])=>b.type==="positional").findIndex(([b])=>b==="dir"),h=0,v=[];for(let b=0;b<c.rawArgs.length;b++){let x=c.rawArgs[b];if(x==="--dir"){b++;continue}if(x.startsWith("--dir="))continue;if(x.startsWith("-")&&x!=="-"){v.push(x);let k=x.replace(/^--?/,"").split("=")[0];if(!x.includes("=")&&u?.[k]?.type==="string"&&c.rawArgs[b+1]!==void 0)v.push(c.rawArgs[++b])}else if(h++!==g)v.push(x)}try{if(await To(e,[...i,...v],d)){if(e==="bundle"&&!process.exitCode)await no({type:"views:reconcile",path:d});return}}catch(b){console.error(b instanceof Error?b.message:"Remote command failed"),process.exitCode=1;return}return l?.(c)}}}var Ze={bundle:Z("bundle",ro),check:Z("check",so),refresh:Oo,views:Rt,"call-server-fn":Z("call-server-fn",io),debug:Z("debug",co),theme:Z("theme",ht),config:lo,env:po,scratch:Bo,skill:Qo,tabs:rt,navigate:$o,remote:Wo,"ui-components":Z("ui-components",wt)},Ce={init:Co,start:et,status:tt,service:Yo,update:kt,openclaw:Ro,hermes:fo,version:St},Jr=a({meta:()=>({name:"moi",description:"Moi \u2014 local AI workspace",version:rr()}),subCommands:{...Ze,...Ce}});function Br(){let e=process.argv[2];if(!e||e==="version"||e==="start")return;if(!(e in Ce))return;if(!vt())return;let n=p();if(!n.demo)return;console.log(`
242
+ `+t.yellow("\u25C6")+` moi ${e} is not available in the demo.
243
+ `+t.dim(" Get Moi on your computer: ")+t.bold(n.demoInstallUrl)+`
244
+ `),process.exit(1)}function Vr(){let e=process.argv[2];if(!e||e==="version"||e==="status")return;if(!(e in Ce))return;if(vt())return;console.log(`
245
+ `+t.yellow("\u25C6")+` moi ${e} is only available to the user that runs moi.
246
+ `),process.exit(1)}Vr();Br();async function Kr(e){return(typeof e.meta==="function"?await e.meta():await e.meta)?.description??""}async function Yr(){let e=Math.max(...Object.keys({...Ze,...Ce}).map((i)=>i.length))+4,n=async(i,l)=>" "+t.cyan(i.padEnd(e))+t.dim(await Kr(l));console.log(),console.log(t.bold("Moi")+t.dim(" \u2014 local AI workspace ")+t.dim(`v${rr()}`)),console.log(),console.log(t.dim("USAGE ")+"moi <command> [options]"),console.log(),console.log(t.bold("Workspace commands:")+t.dim(" for agents and humans alike")),console.log();for(let[i,l]of Object.entries(Ze))console.log(await n(i,l));if(console.log(),!Qe()){console.log(t.bold("System commands:")+t.dim(" manage Moi itself (server, service, updates)")),console.log(t.yellow(" AGENTS: do not run these unless explicitly asked!")),console.log();for(let[i,l]of Object.entries(Ce))console.log(await n(i,l));console.log()}console.log(t.dim("Use moi <command> --help for more information about a command.")),console.log()}hi(Jr,{async showUsage(e,n){let i=typeof e.meta==="function"?await e.meta():await e.meta;if(i?.name==="moi"){await Yr();return}if(i?.name==="config"){Ue();return}await cn(e,n)}});
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Nt}from"./chunk-k049dtaq.js";import{ut}from"./chunk-4wj1jzhr.js";import{join as u,resolve as d,sep as m}from"path";var l=process.env.MEI_FUNCTIONS_DIR??u(import.meta.dir,"..","..","test-workspace",".moi");if(process.env.MEI_WORKSPACE_ROOT)try{process.chdir(process.env.MEI_WORKSPACE_ROOT)}catch{}var n=new Map;function r(e){try{process.send(e)}catch{}}async function y(e){let s=n.get(e);if(s)return s;let o=u(l,`${e}.server.ts`);if(!d(o).startsWith(d(l)+m))throw Error(`Server module "${e}" not found`);let t=Bun.file(o);if(!await t.exists())throw Error(`Server module "${e}" not found`);let i=await import(o+`?t=${t.lastModified}`);return n.set(e,i),r({type:"loaded",module:e}),i}async function p(e){let s=n.get(e);if(!s)return;if(typeof s.dispose==="function")try{await s.dispose()}catch(o){console.error(`[mei] dispose error in ${e}.server.ts:`,o)}n.delete(e)}process.on("message",async(e)=>{if(e.type==="reload"){for(let s of e.modules)await p(s);return}if(e.type==="shutdown"){for(let s of[...n.keys()])await p(s);process.exit(0)}if(e.type==="call"){let{id:s,module:o,name:t,args:i}=e;if(!s||!o||!t){r({id:s,type:"error",message:"Malformed call message"});return}try{let a=(await y(o))[t];if(typeof a!=="function")throw Error(`"${t}" in ${o}.server.ts is not a function`);let f=ut(i),g=await a(...f);r({id:s,type:"result",data:Nt(g)})}catch(c){let a=c instanceof Error?c.message:"Unknown error";r({id:s,type:"error",message:a})}}});r({type:"ready"});