agent-world 0.11.1 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/README.md +24 -11
  2. package/bin/agent-world-cli.js +41 -0
  3. package/bin/agent-world-server.js +40 -0
  4. package/bin/agent-world.js +53 -0
  5. package/dist/cli/commands.d.ts +109 -0
  6. package/dist/cli/commands.js +2024 -0
  7. package/dist/cli/display.d.ts +124 -0
  8. package/dist/cli/display.js +381 -0
  9. package/dist/cli/hitl.d.ts +33 -0
  10. package/dist/cli/hitl.js +81 -0
  11. package/dist/cli/index.d.ts +2 -0
  12. package/dist/cli/index.js +4 -4
  13. package/dist/cli/stream.d.ts +41 -0
  14. package/dist/cli/stream.js +222 -0
  15. package/dist/core/activity-tracker.d.ts +15 -0
  16. package/dist/core/activity-tracker.d.ts.map +1 -0
  17. package/dist/core/activity-tracker.js +90 -0
  18. package/dist/core/activity-tracker.js.map +1 -0
  19. package/dist/core/ai-commands.d.ts +16 -0
  20. package/dist/core/ai-commands.d.ts.map +1 -0
  21. package/dist/core/ai-commands.js +24 -0
  22. package/dist/core/ai-commands.js.map +1 -0
  23. package/dist/core/ai-sdk-patch.d.ts +24 -0
  24. package/dist/core/ai-sdk-patch.d.ts.map +1 -0
  25. package/dist/core/ai-sdk-patch.js +169 -0
  26. package/dist/core/ai-sdk-patch.js.map +1 -0
  27. package/dist/core/anthropic-direct.d.ts +51 -0
  28. package/dist/core/anthropic-direct.d.ts.map +1 -0
  29. package/dist/core/anthropic-direct.js +300 -0
  30. package/dist/core/anthropic-direct.js.map +1 -0
  31. package/dist/core/approval-cache.d.ts +104 -0
  32. package/dist/core/approval-cache.d.ts.map +1 -0
  33. package/dist/core/approval-cache.js +150 -0
  34. package/dist/core/approval-cache.js.map +1 -0
  35. package/dist/core/chat-constants.d.ts +19 -0
  36. package/dist/core/chat-constants.d.ts.map +1 -0
  37. package/dist/core/chat-constants.js +21 -0
  38. package/dist/core/chat-constants.js.map +1 -0
  39. package/dist/core/create-agent-tool.d.ts +65 -0
  40. package/dist/core/create-agent-tool.d.ts.map +1 -0
  41. package/dist/core/create-agent-tool.js +211 -0
  42. package/dist/core/create-agent-tool.js.map +1 -0
  43. package/dist/core/events/approval-checker.d.ts +61 -0
  44. package/dist/core/events/approval-checker.d.ts.map +1 -0
  45. package/dist/core/events/approval-checker.js +226 -0
  46. package/dist/core/events/approval-checker.js.map +1 -0
  47. package/dist/core/events/index.d.ts +24 -0
  48. package/dist/core/events/index.d.ts.map +1 -0
  49. package/dist/core/events/index.js +29 -0
  50. package/dist/core/events/index.js.map +1 -0
  51. package/dist/core/events/memory-manager.d.ts +72 -0
  52. package/dist/core/events/memory-manager.d.ts.map +1 -0
  53. package/dist/core/events/memory-manager.js +1217 -0
  54. package/dist/core/events/memory-manager.js.map +1 -0
  55. package/dist/core/events/mention-logic.d.ts +38 -0
  56. package/dist/core/events/mention-logic.d.ts.map +1 -0
  57. package/dist/core/events/mention-logic.js +162 -0
  58. package/dist/core/events/mention-logic.js.map +1 -0
  59. package/dist/core/events/orchestrator.d.ts +68 -0
  60. package/dist/core/events/orchestrator.d.ts.map +1 -0
  61. package/dist/core/events/orchestrator.js +882 -0
  62. package/dist/core/events/orchestrator.js.map +1 -0
  63. package/dist/core/events/persistence.d.ts +40 -0
  64. package/dist/core/events/persistence.d.ts.map +1 -0
  65. package/dist/core/events/persistence.js +295 -0
  66. package/dist/core/events/persistence.js.map +1 -0
  67. package/dist/core/events/publishers.d.ts +80 -0
  68. package/dist/core/events/publishers.d.ts.map +1 -0
  69. package/dist/core/events/publishers.js +271 -0
  70. package/dist/core/events/publishers.js.map +1 -0
  71. package/dist/core/events/subscribers.d.ts +44 -0
  72. package/dist/core/events/subscribers.d.ts.map +1 -0
  73. package/dist/core/events/subscribers.js +287 -0
  74. package/dist/core/events/subscribers.js.map +1 -0
  75. package/dist/core/events/tool-bridge-logging.d.ts +27 -0
  76. package/dist/core/events/tool-bridge-logging.d.ts.map +1 -0
  77. package/dist/core/events/tool-bridge-logging.js +93 -0
  78. package/dist/core/events/tool-bridge-logging.js.map +1 -0
  79. package/dist/core/events-metadata.d.ts +71 -0
  80. package/dist/core/events-metadata.d.ts.map +1 -0
  81. package/dist/core/events-metadata.js +166 -0
  82. package/dist/core/events-metadata.js.map +1 -0
  83. package/dist/core/events.d.ts +186 -0
  84. package/dist/core/events.d.ts.map +1 -0
  85. package/dist/core/events.js +1248 -0
  86. package/dist/core/events.js.map +1 -0
  87. package/dist/core/export.d.ts +105 -0
  88. package/dist/core/export.d.ts.map +1 -0
  89. package/dist/core/export.js +704 -0
  90. package/dist/core/export.js.map +1 -0
  91. package/dist/core/file-tools.d.ts +113 -0
  92. package/dist/core/file-tools.d.ts.map +1 -0
  93. package/dist/core/file-tools.js +369 -0
  94. package/dist/core/file-tools.js.map +1 -0
  95. package/dist/core/google-direct.d.ts +57 -0
  96. package/dist/core/google-direct.d.ts.map +1 -0
  97. package/dist/core/google-direct.js +297 -0
  98. package/dist/core/google-direct.js.map +1 -0
  99. package/dist/core/hitl.d.ts +53 -0
  100. package/dist/core/hitl.d.ts.map +1 -0
  101. package/dist/core/hitl.js +152 -0
  102. package/dist/core/hitl.js.map +1 -0
  103. package/dist/core/index.d.ts +58 -0
  104. package/dist/core/index.d.ts.map +1 -0
  105. package/dist/core/index.js +69 -0
  106. package/dist/core/index.js.map +1 -0
  107. package/dist/core/llm-config.d.ts +127 -0
  108. package/dist/core/llm-config.d.ts.map +1 -0
  109. package/dist/core/llm-config.js +163 -0
  110. package/dist/core/llm-config.js.map +1 -0
  111. package/dist/core/llm-manager.d.ts +162 -0
  112. package/dist/core/llm-manager.d.ts.map +1 -0
  113. package/dist/core/llm-manager.js +668 -0
  114. package/dist/core/llm-manager.js.map +1 -0
  115. package/dist/core/load-skill-tool.d.ts +54 -0
  116. package/dist/core/load-skill-tool.d.ts.map +1 -0
  117. package/dist/core/load-skill-tool.js +467 -0
  118. package/dist/core/load-skill-tool.js.map +1 -0
  119. package/dist/core/logger.d.ts +87 -0
  120. package/dist/core/logger.d.ts.map +1 -0
  121. package/dist/core/logger.js +357 -0
  122. package/dist/core/logger.js.map +1 -0
  123. package/dist/core/managers.d.ts +130 -0
  124. package/dist/core/managers.d.ts.map +1 -0
  125. package/dist/core/managers.js +1222 -0
  126. package/dist/core/managers.js.map +1 -0
  127. package/dist/core/mcp-server-registry.d.ts +303 -0
  128. package/dist/core/mcp-server-registry.d.ts.map +1 -0
  129. package/dist/core/mcp-server-registry.js +1768 -0
  130. package/dist/core/mcp-server-registry.js.map +1 -0
  131. package/dist/core/mcp-tools.d.ts +56 -0
  132. package/dist/core/mcp-tools.d.ts.map +1 -0
  133. package/dist/core/mcp-tools.js +186 -0
  134. package/dist/core/mcp-tools.js.map +1 -0
  135. package/dist/core/message-prep.d.ts +80 -0
  136. package/dist/core/message-prep.d.ts.map +1 -0
  137. package/dist/core/message-prep.js +222 -0
  138. package/dist/core/message-prep.js.map +1 -0
  139. package/dist/core/message-processing-control.d.ts +53 -0
  140. package/dist/core/message-processing-control.d.ts.map +1 -0
  141. package/dist/core/message-processing-control.js +138 -0
  142. package/dist/core/message-processing-control.js.map +1 -0
  143. package/dist/core/openai-direct.d.ts +79 -0
  144. package/dist/core/openai-direct.d.ts.map +1 -0
  145. package/dist/core/openai-direct.js +373 -0
  146. package/dist/core/openai-direct.js.map +1 -0
  147. package/dist/core/shell-cmd-tool.d.ts +234 -0
  148. package/dist/core/shell-cmd-tool.d.ts.map +1 -0
  149. package/dist/core/shell-cmd-tool.js +1156 -0
  150. package/dist/core/shell-cmd-tool.js.map +1 -0
  151. package/dist/core/shell-process-registry.d.ts +87 -0
  152. package/dist/core/shell-process-registry.d.ts.map +1 -0
  153. package/dist/core/shell-process-registry.js +308 -0
  154. package/dist/core/shell-process-registry.js.map +1 -0
  155. package/dist/core/skill-registry.d.ts +74 -0
  156. package/dist/core/skill-registry.d.ts.map +1 -0
  157. package/dist/core/skill-registry.js +368 -0
  158. package/dist/core/skill-registry.js.map +1 -0
  159. package/dist/core/skill-script-runner.d.ts +89 -0
  160. package/dist/core/skill-script-runner.d.ts.map +1 -0
  161. package/dist/core/skill-script-runner.js +274 -0
  162. package/dist/core/skill-script-runner.js.map +1 -0
  163. package/dist/core/skill-selector.d.ts +65 -0
  164. package/dist/core/skill-selector.d.ts.map +1 -0
  165. package/dist/core/skill-selector.js +190 -0
  166. package/dist/core/skill-selector.js.map +1 -0
  167. package/dist/core/skill-settings.d.ts +19 -0
  168. package/dist/core/skill-settings.d.ts.map +1 -0
  169. package/dist/core/skill-settings.js +39 -0
  170. package/dist/core/skill-settings.js.map +1 -0
  171. package/dist/core/storage/agent-storage.d.ts +133 -0
  172. package/dist/core/storage/agent-storage.d.ts.map +1 -0
  173. package/dist/core/storage/agent-storage.js +497 -0
  174. package/dist/core/storage/agent-storage.js.map +1 -0
  175. package/dist/core/storage/eventStorage/fileEventStorage.d.ts +99 -0
  176. package/dist/core/storage/eventStorage/fileEventStorage.d.ts.map +1 -0
  177. package/dist/core/storage/eventStorage/fileEventStorage.js +493 -0
  178. package/dist/core/storage/eventStorage/fileEventStorage.js.map +1 -0
  179. package/dist/core/storage/eventStorage/index.d.ts +30 -0
  180. package/dist/core/storage/eventStorage/index.d.ts.map +1 -0
  181. package/dist/core/storage/eventStorage/index.js +30 -0
  182. package/dist/core/storage/eventStorage/index.js.map +1 -0
  183. package/dist/core/storage/eventStorage/memoryEventStorage.d.ts +86 -0
  184. package/dist/core/storage/eventStorage/memoryEventStorage.d.ts.map +1 -0
  185. package/dist/core/storage/eventStorage/memoryEventStorage.js +243 -0
  186. package/dist/core/storage/eventStorage/memoryEventStorage.js.map +1 -0
  187. package/dist/core/storage/eventStorage/sqliteEventStorage.d.ts +44 -0
  188. package/dist/core/storage/eventStorage/sqliteEventStorage.d.ts.map +1 -0
  189. package/dist/core/storage/eventStorage/sqliteEventStorage.js +300 -0
  190. package/dist/core/storage/eventStorage/sqliteEventStorage.js.map +1 -0
  191. package/dist/core/storage/eventStorage/types.d.ts +141 -0
  192. package/dist/core/storage/eventStorage/types.d.ts.map +1 -0
  193. package/dist/core/storage/eventStorage/types.js +42 -0
  194. package/dist/core/storage/eventStorage/types.js.map +1 -0
  195. package/dist/core/storage/eventStorage/validation.d.ts +29 -0
  196. package/dist/core/storage/eventStorage/validation.d.ts.map +1 -0
  197. package/dist/core/storage/eventStorage/validation.js +67 -0
  198. package/dist/core/storage/eventStorage/validation.js.map +1 -0
  199. package/dist/core/storage/legacy-migrations.d.ts +45 -0
  200. package/dist/core/storage/legacy-migrations.d.ts.map +1 -0
  201. package/dist/core/storage/legacy-migrations.js +295 -0
  202. package/dist/core/storage/legacy-migrations.js.map +1 -0
  203. package/dist/core/storage/memory-storage.d.ts +104 -0
  204. package/dist/core/storage/memory-storage.d.ts.map +1 -0
  205. package/dist/core/storage/memory-storage.js +414 -0
  206. package/dist/core/storage/memory-storage.js.map +1 -0
  207. package/dist/core/storage/migration-runner.d.ts +95 -0
  208. package/dist/core/storage/migration-runner.d.ts.map +1 -0
  209. package/dist/core/storage/migration-runner.js +299 -0
  210. package/dist/core/storage/migration-runner.js.map +1 -0
  211. package/dist/core/storage/queue-storage.d.ts +147 -0
  212. package/dist/core/storage/queue-storage.d.ts.map +1 -0
  213. package/dist/core/storage/queue-storage.js +290 -0
  214. package/dist/core/storage/queue-storage.js.map +1 -0
  215. package/dist/core/storage/skill-storage.d.ts +136 -0
  216. package/dist/core/storage/skill-storage.d.ts.map +1 -0
  217. package/dist/core/storage/skill-storage.js +474 -0
  218. package/dist/core/storage/skill-storage.js.map +1 -0
  219. package/dist/core/storage/sqlite-schema.d.ts +94 -0
  220. package/dist/core/storage/sqlite-schema.d.ts.map +1 -0
  221. package/dist/core/storage/sqlite-schema.js +155 -0
  222. package/dist/core/storage/sqlite-schema.js.map +1 -0
  223. package/dist/core/storage/sqlite-storage.d.ts +145 -0
  224. package/dist/core/storage/sqlite-storage.d.ts.map +1 -0
  225. package/dist/core/storage/sqlite-storage.js +708 -0
  226. package/dist/core/storage/sqlite-storage.js.map +1 -0
  227. package/dist/core/storage/storage-factory.d.ts +60 -0
  228. package/dist/core/storage/storage-factory.d.ts.map +1 -0
  229. package/dist/core/storage/storage-factory.js +793 -0
  230. package/dist/core/storage/storage-factory.js.map +1 -0
  231. package/dist/core/storage/validation.d.ts +35 -0
  232. package/dist/core/storage/validation.d.ts.map +1 -0
  233. package/dist/core/storage/validation.js +78 -0
  234. package/dist/core/storage/validation.js.map +1 -0
  235. package/dist/core/storage/world-storage.d.ts +113 -0
  236. package/dist/core/storage/world-storage.d.ts.map +1 -0
  237. package/dist/core/storage/world-storage.js +377 -0
  238. package/dist/core/storage/world-storage.js.map +1 -0
  239. package/dist/core/subscription.d.ts +42 -0
  240. package/dist/core/subscription.d.ts.map +1 -0
  241. package/dist/core/subscription.js +226 -0
  242. package/dist/core/subscription.js.map +1 -0
  243. package/dist/core/tool-utils.d.ts +79 -0
  244. package/dist/core/tool-utils.d.ts.map +1 -0
  245. package/dist/core/tool-utils.js +272 -0
  246. package/dist/core/tool-utils.js.map +1 -0
  247. package/dist/core/types.d.ts +594 -0
  248. package/dist/core/types.d.ts.map +1 -0
  249. package/dist/core/types.js +157 -0
  250. package/dist/core/types.js.map +1 -0
  251. package/dist/core/utils.d.ts +137 -0
  252. package/dist/core/utils.d.ts.map +1 -0
  253. package/dist/core/utils.js +477 -0
  254. package/dist/core/utils.js.map +1 -0
  255. package/dist/core/world-class.d.ts +43 -0
  256. package/dist/core/world-class.d.ts.map +1 -0
  257. package/dist/core/world-class.js +90 -0
  258. package/dist/core/world-class.js.map +1 -0
  259. package/dist/index.d.ts +18 -0
  260. package/dist/public/assets/agent-sprites-DJFgj-zP.png +0 -0
  261. package/dist/public/assets/border-KHK37r8y.svg +83 -0
  262. package/dist/public/assets/index-BO20H4xt.js +96 -0
  263. package/dist/public/assets/index-ETY7W5_S.css +1 -0
  264. package/dist/public/index.html +21 -0
  265. package/dist/server/api.d.ts +2 -0
  266. package/dist/server/api.js +1152 -0
  267. package/dist/server/index.d.ts +29 -0
  268. package/dist/server/index.js +4 -4
  269. package/dist/server/sse-handler.d.ts +63 -0
  270. package/dist/server/sse-handler.js +243 -0
  271. package/migrations/0000_init_base_schema.sql +129 -0
  272. package/migrations/0001_add_chat_id.sql +12 -0
  273. package/migrations/0002_add_llm_config.sql +9 -0
  274. package/migrations/0003_add_current_chat_id.sql +8 -0
  275. package/migrations/0004_add_mcp_config.sql +8 -0
  276. package/migrations/0005_add_message_id.sql +12 -0
  277. package/migrations/0006_add_reply_to_message_id.sql +12 -0
  278. package/migrations/0007_create_world_chats.sql +35 -0
  279. package/migrations/0008_create_events_table.sql +78 -0
  280. package/migrations/0009_add_event_sequences.sql +40 -0
  281. package/migrations/0010_add_tool_call_fields.sql +27 -0
  282. package/migrations/0011_add_event_metadata_indexes.sql +79 -0
  283. package/migrations/0012_add_tool_role.sql +78 -0
  284. package/migrations/0013_add_world_variables.sql +7 -0
  285. package/migrations/0014_add_main_agent_and_auto_reply.sql +10 -0
  286. package/package.json +18 -6
  287. package/scripts/launch-electron.js +0 -58
package/README.md CHANGED
@@ -43,17 +43,18 @@ Paste that prompt. Agents come alive instantly.
43
43
  - ✅ Multiple AI Providers - Use different models for different agents
44
44
  - ✅ Web + CLI + Electron - Modern interfaces with real-time streaming and status feedback
45
45
 
46
- ## Latest Highlights (v0.11.0)
46
+ ## Latest Highlights (since v0.11.1)
47
47
 
48
- - Electron desktop app with workspace-folder world loading, recents, and improved world info
49
- - Concurrent chat session isolation with chat-scoped event routing and stop controls
50
- - World-level `mainAgent` routing and agent-level `autoReply` configuration
51
- - Core-owned edit/resubmit and chat-title flows for consistent behavior across clients
52
- - World variables as `.env` text with runtime interpolation support
53
- - Progressive skills (`load_skill`) with skill registry sync and HITL-gated activation
48
+ - Web app now includes a Settings page, chat-history search, and branch-from-message workflow
49
+ - Built-in `create_agent` tool now supports approval-first creation and inherits world chat defaults
50
+ - File exploration is easier with built-in `read_file`, `list_files` (including recursive mode), and `grep`
51
+ - Electron now supports folder-based world import/export with validation and conflict handling
52
+ - Chat UX is smoother with clearer inline working status, better streaming feedback, and UI refinements
53
+ - Real-time refresh behavior is improved across web and desktop when agents/world data changes
54
54
 
55
55
  ## Release Notes
56
56
 
57
+ - **v0.12.0** - Web settings/search/branching, built-in `create_agent`, new file tools, Electron folder import/export, and chat/status UX improvements
57
58
  - **v0.11.0** - Electron desktop workflow, concurrent chat sessions, main-agent routing, progressive skills + HITL, and runtime safety hardening
58
59
  - Full history: [CHANGELOG.md](CHANGELOG.md)
59
60
 
@@ -139,23 +140,26 @@ Each Agent World has a collection of agents that can communicate through a share
139
140
 
140
141
  ### Quick Start
141
142
 
143
+ Use npm package invocations (shown below). GitHub shorthand commands such as
144
+ `npx agent-world/agent-world` are not supported entrypoints.
145
+
142
146
  **Option 1: Web Interface**
143
147
  ```bash
144
- npx agent-world-server
148
+ npx agent-world@latest
145
149
  ```
146
150
 
147
151
  **Option 2: CLI Interface**
148
152
  1. Interactive Mode
149
153
  ```bash
150
- npx agent-world
154
+ npx -p agent-world@latest agent-world-cli
151
155
  ```
152
156
  2. Command Mode
153
157
  ```bash
154
- npx agent-world -w default-world "hi"
158
+ npx -p agent-world@latest agent-world-cli -w default-world "hi"
155
159
  ```
156
160
  3. Pipeline Mode
157
161
  ```bash
158
- echo "hi" | npx agent-world -w default-world
162
+ echo "hi" | npx -p agent-world@latest agent-world-cli -w default-world
159
163
  ```
160
164
 
161
165
  **Option 3: Electron Desktop App (repo)**
@@ -204,12 +208,17 @@ npm run test:watch # Watch mode
204
208
  ### Environment Setup
205
209
 
206
210
  Export your API keys as environment variables
211
+ For Azure OpenAI, all four `AZURE_OPENAI_*` variables are required together.
207
212
 
208
213
  ```bash
209
214
  # Required if Choose one or more
210
215
  export OPENAI_API_KEY="your-key-here"
211
216
  export ANTHROPIC_API_KEY="your-key-here"
212
217
  export GOOGLE_API_KEY="your-key-here"
218
+ export AZURE_OPENAI_API_KEY="your-key-here"
219
+ export AZURE_OPENAI_RESOURCE_NAME="your-resource-name"
220
+ export AZURE_OPENAI_DEPLOYMENT_NAME="your-deployment-name"
221
+ export AZURE_OPENAI_API_VERSION="2024-10-21-preview"
213
222
 
214
223
  # Default: For local models
215
224
  export OLLAMA_BASE_URL="http://localhost:11434"
@@ -221,6 +230,10 @@ Or create a `.env` file in your working directory with:
221
230
  OPENAI_API_KEY=your-key-here
222
231
  ANTHROPIC_API_KEY=your-key-here
223
232
  GOOGLE_API_KEY=your-key-here
233
+ AZURE_OPENAI_API_KEY=your-key-here
234
+ AZURE_OPENAI_RESOURCE_NAME=your-resource-name
235
+ AZURE_OPENAI_DEPLOYMENT_NAME=your-deployment-name
236
+ AZURE_OPENAI_API_VERSION=2024-10-21-preview
224
237
  OLLAMA_BASE_URL=http://localhost:11434
225
238
  ```
226
239
 
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Agent World Bin Launcher (CLI entry).
4
+ *
5
+ * Purpose:
6
+ * - Provide a stable npm bin entry for `agent-world-cli`.
7
+ *
8
+ * Key Features:
9
+ * - Performs a Node.js runtime preflight check with a clear user-facing error.
10
+ * - Defers to the published CLI runtime after validation.
11
+ *
12
+ * Notes on Implementation:
13
+ * - Uses dynamic import so the preflight runs before loading modern runtime dependencies.
14
+ *
15
+ * Recent Changes:
16
+ * - 2026-02-19: Added wrapper to avoid silent exits on unsupported Node versions.
17
+ */
18
+
19
+ const MIN_NODE_MAJOR = 20;
20
+
21
+ function getNodeMajor() {
22
+ const major = Number.parseInt((process.versions.node || '').split('.')[0] || '0', 10);
23
+ return Number.isFinite(major) ? major : 0;
24
+ }
25
+
26
+ function ensureSupportedNode() {
27
+ const nodeMajor = getNodeMajor();
28
+ if (nodeMajor >= MIN_NODE_MAJOR) return;
29
+
30
+ console.error(`[agent-world-cli] Node.js ${MIN_NODE_MAJOR}+ is required. Detected ${process.version}.`);
31
+ console.error('[agent-world-cli] Please upgrade Node.js and run the command again.');
32
+ process.exit(1);
33
+ }
34
+
35
+ ensureSupportedNode();
36
+
37
+ import('../dist/cli/index.js').catch((error) => {
38
+ console.error('[agent-world-cli] Failed to start CLI:', error);
39
+ process.exit(1);
40
+ });
41
+
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Agent World Bin Launcher (server entry).
4
+ *
5
+ * Purpose:
6
+ * - Provide a stable npm bin entry for `agent-world-server`.
7
+ *
8
+ * Key Features:
9
+ * - Performs a Node.js runtime preflight check with a clear user-facing error.
10
+ * - Defers to the published server runtime after validation.
11
+ *
12
+ * Notes on Implementation:
13
+ * - Uses dynamic import so the preflight runs before loading modern runtime dependencies.
14
+ *
15
+ * Recent Changes:
16
+ * - 2026-02-19: Added wrapper to avoid silent exits on unsupported Node versions.
17
+ */
18
+
19
+ const MIN_NODE_MAJOR = 20;
20
+
21
+ function getNodeMajor() {
22
+ const major = Number.parseInt((process.versions.node || '').split('.')[0] || '0', 10);
23
+ return Number.isFinite(major) ? major : 0;
24
+ }
25
+
26
+ function ensureSupportedNode() {
27
+ const nodeMajor = getNodeMajor();
28
+ if (nodeMajor >= MIN_NODE_MAJOR) return;
29
+
30
+ console.error(`[agent-world-server] Node.js ${MIN_NODE_MAJOR}+ is required. Detected ${process.version}.`);
31
+ console.error('[agent-world-server] Please upgrade Node.js and run the command again.');
32
+ process.exit(1);
33
+ }
34
+
35
+ ensureSupportedNode();
36
+
37
+ import('../dist/server/index.js').catch((error) => {
38
+ console.error('[agent-world-server] Failed to start server:', error);
39
+ process.exit(1);
40
+ });
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Agent World Bin Launcher (default server entry).
4
+ *
5
+ * Purpose:
6
+ * - Provide a stable npm bin entry for `agent-world`.
7
+ *
8
+ * Key Features:
9
+ * - Performs a Node.js runtime preflight check with a clear user-facing error.
10
+ * - Defers to the published server runtime after validation.
11
+ *
12
+ * Notes on Implementation:
13
+ * - Uses dynamic import so the preflight runs before loading modern runtime dependencies.
14
+ *
15
+ * Recent Changes:
16
+ * - 2026-02-19: Added wrapper to avoid silent exits on unsupported Node versions.
17
+ */
18
+
19
+ const MIN_NODE_MAJOR = 20;
20
+
21
+ function getNodeMajor() {
22
+ const major = Number.parseInt((process.versions.node || '').split('.')[0] || '0', 10);
23
+ return Number.isFinite(major) ? major : 0;
24
+ }
25
+
26
+ function ensureSupportedNode() {
27
+ const nodeMajor = getNodeMajor();
28
+ if (nodeMajor >= MIN_NODE_MAJOR) return;
29
+
30
+ console.error(`[agent-world] Node.js ${MIN_NODE_MAJOR}+ is required. Detected ${process.version}.`);
31
+ console.error('[agent-world] Please upgrade Node.js and run the command again.');
32
+ process.exit(1);
33
+ }
34
+
35
+ ensureSupportedNode();
36
+
37
+ import('../dist/server/index.js')
38
+ .then(({ startWebServer }) => {
39
+ const port = Number(process.env.PORT) || 0;
40
+ const host = process.env.HOST || '127.0.0.1';
41
+ const shouldOpenBrowser = process.env.AGENT_WORLD_AUTO_OPEN !== 'false';
42
+
43
+ return startWebServer(port, host, {
44
+ openBrowser: shouldOpenBrowser,
45
+ registerProcessHandlers: true,
46
+ }).then(() => {
47
+ console.log('Server started successfully');
48
+ });
49
+ })
50
+ .catch((error) => {
51
+ console.error('[agent-world] Failed to start server:', error);
52
+ process.exit(1);
53
+ });
@@ -0,0 +1,109 @@
1
+ /**
2
+ * CLI Commands Implementation - Direct Core Integration with Space-Separated and Bidirectional Aliases
3
+ *
4
+ * Features:
5
+ * - Direct command mapping system with interactive parameter collection
6
+ * - Core function calls without command processing layer
7
+ * - User-friendly messages with technical details for debugging
8
+ * - Automatic world state management and refreshing
9
+ * - Help message generation with command documentation
10
+ * - Dual input handling for commands and messages
11
+ * - World instance isolation and proper cleanup during refresh
12
+ * - Space-separated command aliases for natural command syntax
13
+ * - Bidirectional aliases (e.g., /chat new and /new chat both work)
14
+ * - Backward compatibility with hyphenated aliases
15
+ * - Context-sensitive commands that adapt based on world selection
16
+ * - World data persistence to File Storage or SQLite with folder selection
17
+ *
18
+ * Available Commands:
19
+ * - World: list, show, create, update, delete, select, export, save
20
+ * - Agent: list, show, create, update, delete, clear
21
+ * - Chat: list, create, select, switch, delete, rename, export
22
+ * - System: help, quit, exit
23
+ * - Short Explicit: lsw (list worlds), lsa (list agents)
24
+ *
25
+ * Alias System:
26
+ * - Space-separated format: /new chat, /add agent, /list worlds (preferred)
27
+ * - Bidirectional aliases: /chat new = /new chat, /agent add = /add agent
28
+ * - Backward compatible: /new-chat, /add-agent, /list-worlds (still work)
29
+ * - Context-sensitive: /new creates world, /add creates agent (when world selected)
30
+ * - Explicit aliases like /lsw, /lsa provide unambiguous targeting
31
+ *
32
+ * World Refresh Mechanism:
33
+ * - Commands that modify world state signal refresh requirement via `refreshWorld: true`
34
+ * - CLI properly destroys old world instances and creates fresh ones
35
+ * - Event subscriptions are cleanly transferred to new world instances
36
+ * - Prevents memory leaks and ensures event isolation between old/new worlds
37
+ * - Agent persistence maintained across refresh cycles
38
+ *
39
+ * World Save Feature:
40
+ * - Interactive storage type selection (File or SQLite)
41
+ * - Custom folder path with default option
42
+ * - Saves world, all agents, all chat histories, and all events
43
+ * - Creates target directory if it doesn't exist
44
+ * - Supports migration between storage types
45
+ * - Event history preserved across different storage backends
46
+ */
47
+ import { World } from '../core/types.js';
48
+ export interface CLIResponse {
49
+ success: boolean;
50
+ message: string;
51
+ data?: any;
52
+ technicalDetails?: string;
53
+ needsWorldRefresh?: boolean;
54
+ refreshWorld?: boolean;
55
+ error?: string;
56
+ }
57
+ export interface CLIContext {
58
+ currentWorldName?: string;
59
+ currentWorld?: World | null;
60
+ }
61
+ export type PromptFunction = (question: string, options?: string[]) => Promise<string>;
62
+ /**
63
+ * Display chat messages in a formatted, readable way
64
+ * Shows sender, timestamp, and content for each message
65
+ * Logic:
66
+ * - HUMAN messages: deduplicate by messageId (they're replicated across all agents)
67
+ * - Agent messages: only show if sender matches agentId (the agent that created it)
68
+ * - System messages: deduplicate by messageId
69
+ */
70
+ export declare function displayChatMessages(worldId: string, chatId?: string | null): Promise<void>;
71
+ type CLICommandCategory = 'world' | 'agent' | 'chat' | 'system';
72
+ interface CLICommandParameter {
73
+ name: string;
74
+ required: boolean;
75
+ description: string;
76
+ type: 'string' | 'number' | 'boolean';
77
+ options?: string[];
78
+ }
79
+ export interface CLICommandDefinition {
80
+ type: string;
81
+ requiresWorld: boolean;
82
+ description: string;
83
+ usage: string;
84
+ parameters: CLICommandParameter[];
85
+ aliases?: string[];
86
+ category: CLICommandCategory;
87
+ }
88
+ export declare const CLI_COMMAND_MAP: Record<string, CLICommandDefinition>;
89
+ export declare const CLI_COMMAND_ALIASES: Record<string, string>;
90
+ export declare function parseCLICommand(input: string): {
91
+ command: string;
92
+ args: string[];
93
+ commandType: string;
94
+ isValid: boolean;
95
+ error?: string;
96
+ };
97
+ export declare function generateHelpMessage(target?: string): string;
98
+ export declare function checkTargetExists(targetPath: string, storageType: 'file' | 'sqlite', worldId: string): Promise<{
99
+ exists: boolean;
100
+ message: string;
101
+ }>;
102
+ export declare function deleteExistingData(targetPath: string, storageType: 'file' | 'sqlite', worldId: string): Promise<{
103
+ success: boolean;
104
+ error?: string;
105
+ }>;
106
+ export declare function performWorldSave(world: World, storageType: 'file' | 'sqlite', targetPath: string): Promise<CLIResponse>;
107
+ export declare function processCLICommand(input: string, context: CLIContext, promptFn: PromptFunction): Promise<CLIResponse>;
108
+ export declare function processCLIInput(input: string, world: World | null, sender?: string): Promise<CLIResponse>;
109
+ export {};