agent-world 0.11.1 → 0.12.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 (267) hide show
  1. package/README.md +17 -7
  2. package/dist/cli/commands.d.ts +109 -0
  3. package/dist/cli/commands.js +2024 -0
  4. package/dist/cli/display.d.ts +124 -0
  5. package/dist/cli/display.js +381 -0
  6. package/dist/cli/hitl.d.ts +33 -0
  7. package/dist/cli/hitl.js +81 -0
  8. package/dist/cli/index.d.ts +2 -0
  9. package/dist/cli/stream.d.ts +41 -0
  10. package/dist/cli/stream.js +222 -0
  11. package/dist/core/activity-tracker.d.ts +16 -0
  12. package/dist/core/activity-tracker.d.ts.map +1 -0
  13. package/dist/core/activity-tracker.js +91 -0
  14. package/dist/core/activity-tracker.js.map +1 -0
  15. package/dist/core/ai-commands.d.ts +16 -0
  16. package/dist/core/ai-commands.d.ts.map +1 -0
  17. package/dist/core/ai-commands.js +24 -0
  18. package/dist/core/ai-commands.js.map +1 -0
  19. package/dist/core/ai-sdk-patch.d.ts +24 -0
  20. package/dist/core/ai-sdk-patch.d.ts.map +1 -0
  21. package/dist/core/ai-sdk-patch.js +169 -0
  22. package/dist/core/ai-sdk-patch.js.map +1 -0
  23. package/dist/core/anthropic-direct.d.ts +52 -0
  24. package/dist/core/anthropic-direct.d.ts.map +1 -0
  25. package/dist/core/anthropic-direct.js +301 -0
  26. package/dist/core/anthropic-direct.js.map +1 -0
  27. package/dist/core/approval-cache.d.ts +104 -0
  28. package/dist/core/approval-cache.d.ts.map +1 -0
  29. package/dist/core/approval-cache.js +150 -0
  30. package/dist/core/approval-cache.js.map +1 -0
  31. package/dist/core/chat-constants.d.ts +20 -0
  32. package/dist/core/chat-constants.d.ts.map +1 -0
  33. package/dist/core/chat-constants.js +22 -0
  34. package/dist/core/chat-constants.js.map +1 -0
  35. package/dist/core/create-agent-tool.d.ts +66 -0
  36. package/dist/core/create-agent-tool.d.ts.map +1 -0
  37. package/dist/core/create-agent-tool.js +212 -0
  38. package/dist/core/create-agent-tool.js.map +1 -0
  39. package/dist/core/events/approval-checker.d.ts +61 -0
  40. package/dist/core/events/approval-checker.d.ts.map +1 -0
  41. package/dist/core/events/approval-checker.js +226 -0
  42. package/dist/core/events/approval-checker.js.map +1 -0
  43. package/dist/core/events/index.d.ts +25 -0
  44. package/dist/core/events/index.d.ts.map +1 -0
  45. package/dist/core/events/index.js +30 -0
  46. package/dist/core/events/index.js.map +1 -0
  47. package/dist/core/events/memory-manager.d.ts +73 -0
  48. package/dist/core/events/memory-manager.d.ts.map +1 -0
  49. package/dist/core/events/memory-manager.js +1218 -0
  50. package/dist/core/events/memory-manager.js.map +1 -0
  51. package/dist/core/events/mention-logic.d.ts +39 -0
  52. package/dist/core/events/mention-logic.d.ts.map +1 -0
  53. package/dist/core/events/mention-logic.js +163 -0
  54. package/dist/core/events/mention-logic.js.map +1 -0
  55. package/dist/core/events/orchestrator.d.ts +69 -0
  56. package/dist/core/events/orchestrator.d.ts.map +1 -0
  57. package/dist/core/events/orchestrator.js +883 -0
  58. package/dist/core/events/orchestrator.js.map +1 -0
  59. package/dist/core/events/persistence.d.ts +41 -0
  60. package/dist/core/events/persistence.d.ts.map +1 -0
  61. package/dist/core/events/persistence.js +296 -0
  62. package/dist/core/events/persistence.js.map +1 -0
  63. package/dist/core/events/publishers.d.ts +81 -0
  64. package/dist/core/events/publishers.d.ts.map +1 -0
  65. package/dist/core/events/publishers.js +272 -0
  66. package/dist/core/events/publishers.js.map +1 -0
  67. package/dist/core/events/subscribers.d.ts +45 -0
  68. package/dist/core/events/subscribers.d.ts.map +1 -0
  69. package/dist/core/events/subscribers.js +288 -0
  70. package/dist/core/events/subscribers.js.map +1 -0
  71. package/dist/core/events/tool-bridge-logging.d.ts +28 -0
  72. package/dist/core/events/tool-bridge-logging.d.ts.map +1 -0
  73. package/dist/core/events/tool-bridge-logging.js +94 -0
  74. package/dist/core/events/tool-bridge-logging.js.map +1 -0
  75. package/dist/core/events-metadata.d.ts +72 -0
  76. package/dist/core/events-metadata.d.ts.map +1 -0
  77. package/dist/core/events-metadata.js +167 -0
  78. package/dist/core/events-metadata.js.map +1 -0
  79. package/dist/core/events.d.ts +186 -0
  80. package/dist/core/events.d.ts.map +1 -0
  81. package/dist/core/events.js +1248 -0
  82. package/dist/core/events.js.map +1 -0
  83. package/dist/core/export.d.ts +106 -0
  84. package/dist/core/export.d.ts.map +1 -0
  85. package/dist/core/export.js +705 -0
  86. package/dist/core/export.js.map +1 -0
  87. package/dist/core/file-tools.d.ts +114 -0
  88. package/dist/core/file-tools.d.ts.map +1 -0
  89. package/dist/core/file-tools.js +370 -0
  90. package/dist/core/file-tools.js.map +1 -0
  91. package/dist/core/google-direct.d.ts +58 -0
  92. package/dist/core/google-direct.d.ts.map +1 -0
  93. package/dist/core/google-direct.js +298 -0
  94. package/dist/core/google-direct.js.map +1 -0
  95. package/dist/core/hitl.d.ts +54 -0
  96. package/dist/core/hitl.d.ts.map +1 -0
  97. package/dist/core/hitl.js +153 -0
  98. package/dist/core/hitl.js.map +1 -0
  99. package/dist/core/index.d.ts +59 -0
  100. package/dist/core/index.d.ts.map +1 -0
  101. package/dist/core/index.js +70 -0
  102. package/dist/core/index.js.map +1 -0
  103. package/dist/core/llm-config.d.ts +128 -0
  104. package/dist/core/llm-config.d.ts.map +1 -0
  105. package/dist/core/llm-config.js +164 -0
  106. package/dist/core/llm-config.js.map +1 -0
  107. package/dist/core/llm-manager.d.ts +163 -0
  108. package/dist/core/llm-manager.d.ts.map +1 -0
  109. package/dist/core/llm-manager.js +669 -0
  110. package/dist/core/llm-manager.js.map +1 -0
  111. package/dist/core/load-skill-tool.d.ts +55 -0
  112. package/dist/core/load-skill-tool.d.ts.map +1 -0
  113. package/dist/core/load-skill-tool.js +468 -0
  114. package/dist/core/load-skill-tool.js.map +1 -0
  115. package/dist/core/logger.d.ts +88 -0
  116. package/dist/core/logger.d.ts.map +1 -0
  117. package/dist/core/logger.js +358 -0
  118. package/dist/core/logger.js.map +1 -0
  119. package/dist/core/managers.d.ts +131 -0
  120. package/dist/core/managers.d.ts.map +1 -0
  121. package/dist/core/managers.js +1223 -0
  122. package/dist/core/managers.js.map +1 -0
  123. package/dist/core/mcp-server-registry.d.ts +304 -0
  124. package/dist/core/mcp-server-registry.d.ts.map +1 -0
  125. package/dist/core/mcp-server-registry.js +1769 -0
  126. package/dist/core/mcp-server-registry.js.map +1 -0
  127. package/dist/core/mcp-tools.d.ts +56 -0
  128. package/dist/core/mcp-tools.d.ts.map +1 -0
  129. package/dist/core/mcp-tools.js +186 -0
  130. package/dist/core/mcp-tools.js.map +1 -0
  131. package/dist/core/message-prep.d.ts +81 -0
  132. package/dist/core/message-prep.d.ts.map +1 -0
  133. package/dist/core/message-prep.js +223 -0
  134. package/dist/core/message-prep.js.map +1 -0
  135. package/dist/core/message-processing-control.d.ts +54 -0
  136. package/dist/core/message-processing-control.d.ts.map +1 -0
  137. package/dist/core/message-processing-control.js +139 -0
  138. package/dist/core/message-processing-control.js.map +1 -0
  139. package/dist/core/openai-direct.d.ts +80 -0
  140. package/dist/core/openai-direct.d.ts.map +1 -0
  141. package/dist/core/openai-direct.js +374 -0
  142. package/dist/core/openai-direct.js.map +1 -0
  143. package/dist/core/shell-cmd-tool.d.ts +235 -0
  144. package/dist/core/shell-cmd-tool.d.ts.map +1 -0
  145. package/dist/core/shell-cmd-tool.js +1157 -0
  146. package/dist/core/shell-cmd-tool.js.map +1 -0
  147. package/dist/core/shell-process-registry.d.ts +88 -0
  148. package/dist/core/shell-process-registry.d.ts.map +1 -0
  149. package/dist/core/shell-process-registry.js +309 -0
  150. package/dist/core/shell-process-registry.js.map +1 -0
  151. package/dist/core/skill-registry.d.ts +75 -0
  152. package/dist/core/skill-registry.d.ts.map +1 -0
  153. package/dist/core/skill-registry.js +369 -0
  154. package/dist/core/skill-registry.js.map +1 -0
  155. package/dist/core/skill-script-runner.d.ts +89 -0
  156. package/dist/core/skill-script-runner.d.ts.map +1 -0
  157. package/dist/core/skill-script-runner.js +274 -0
  158. package/dist/core/skill-script-runner.js.map +1 -0
  159. package/dist/core/skill-selector.d.ts +65 -0
  160. package/dist/core/skill-selector.d.ts.map +1 -0
  161. package/dist/core/skill-selector.js +190 -0
  162. package/dist/core/skill-selector.js.map +1 -0
  163. package/dist/core/skill-settings.d.ts +20 -0
  164. package/dist/core/skill-settings.d.ts.map +1 -0
  165. package/dist/core/skill-settings.js +40 -0
  166. package/dist/core/skill-settings.js.map +1 -0
  167. package/dist/core/storage/agent-storage.d.ts +134 -0
  168. package/dist/core/storage/agent-storage.d.ts.map +1 -0
  169. package/dist/core/storage/agent-storage.js +498 -0
  170. package/dist/core/storage/agent-storage.js.map +1 -0
  171. package/dist/core/storage/eventStorage/fileEventStorage.d.ts +100 -0
  172. package/dist/core/storage/eventStorage/fileEventStorage.d.ts.map +1 -0
  173. package/dist/core/storage/eventStorage/fileEventStorage.js +494 -0
  174. package/dist/core/storage/eventStorage/fileEventStorage.js.map +1 -0
  175. package/dist/core/storage/eventStorage/index.d.ts +31 -0
  176. package/dist/core/storage/eventStorage/index.d.ts.map +1 -0
  177. package/dist/core/storage/eventStorage/index.js +31 -0
  178. package/dist/core/storage/eventStorage/index.js.map +1 -0
  179. package/dist/core/storage/eventStorage/memoryEventStorage.d.ts +87 -0
  180. package/dist/core/storage/eventStorage/memoryEventStorage.d.ts.map +1 -0
  181. package/dist/core/storage/eventStorage/memoryEventStorage.js +244 -0
  182. package/dist/core/storage/eventStorage/memoryEventStorage.js.map +1 -0
  183. package/dist/core/storage/eventStorage/sqliteEventStorage.d.ts +45 -0
  184. package/dist/core/storage/eventStorage/sqliteEventStorage.d.ts.map +1 -0
  185. package/dist/core/storage/eventStorage/sqliteEventStorage.js +301 -0
  186. package/dist/core/storage/eventStorage/sqliteEventStorage.js.map +1 -0
  187. package/dist/core/storage/eventStorage/types.d.ts +142 -0
  188. package/dist/core/storage/eventStorage/types.d.ts.map +1 -0
  189. package/dist/core/storage/eventStorage/types.js +43 -0
  190. package/dist/core/storage/eventStorage/types.js.map +1 -0
  191. package/dist/core/storage/eventStorage/validation.d.ts +30 -0
  192. package/dist/core/storage/eventStorage/validation.d.ts.map +1 -0
  193. package/dist/core/storage/eventStorage/validation.js +68 -0
  194. package/dist/core/storage/eventStorage/validation.js.map +1 -0
  195. package/dist/core/storage/legacy-migrations.d.ts +45 -0
  196. package/dist/core/storage/legacy-migrations.d.ts.map +1 -0
  197. package/dist/core/storage/legacy-migrations.js +295 -0
  198. package/dist/core/storage/legacy-migrations.js.map +1 -0
  199. package/dist/core/storage/memory-storage.d.ts +105 -0
  200. package/dist/core/storage/memory-storage.d.ts.map +1 -0
  201. package/dist/core/storage/memory-storage.js +415 -0
  202. package/dist/core/storage/memory-storage.js.map +1 -0
  203. package/dist/core/storage/migration-runner.d.ts +96 -0
  204. package/dist/core/storage/migration-runner.d.ts.map +1 -0
  205. package/dist/core/storage/migration-runner.js +306 -0
  206. package/dist/core/storage/migration-runner.js.map +1 -0
  207. package/dist/core/storage/queue-storage.d.ts +147 -0
  208. package/dist/core/storage/queue-storage.d.ts.map +1 -0
  209. package/dist/core/storage/queue-storage.js +290 -0
  210. package/dist/core/storage/queue-storage.js.map +1 -0
  211. package/dist/core/storage/skill-storage.d.ts +136 -0
  212. package/dist/core/storage/skill-storage.d.ts.map +1 -0
  213. package/dist/core/storage/skill-storage.js +474 -0
  214. package/dist/core/storage/skill-storage.js.map +1 -0
  215. package/dist/core/storage/sqlite-schema.d.ts +95 -0
  216. package/dist/core/storage/sqlite-schema.d.ts.map +1 -0
  217. package/dist/core/storage/sqlite-schema.js +156 -0
  218. package/dist/core/storage/sqlite-schema.js.map +1 -0
  219. package/dist/core/storage/sqlite-storage.d.ts +146 -0
  220. package/dist/core/storage/sqlite-storage.d.ts.map +1 -0
  221. package/dist/core/storage/sqlite-storage.js +709 -0
  222. package/dist/core/storage/sqlite-storage.js.map +1 -0
  223. package/dist/core/storage/storage-factory.d.ts +61 -0
  224. package/dist/core/storage/storage-factory.d.ts.map +1 -0
  225. package/dist/core/storage/storage-factory.js +794 -0
  226. package/dist/core/storage/storage-factory.js.map +1 -0
  227. package/dist/core/storage/validation.d.ts +36 -0
  228. package/dist/core/storage/validation.d.ts.map +1 -0
  229. package/dist/core/storage/validation.js +79 -0
  230. package/dist/core/storage/validation.js.map +1 -0
  231. package/dist/core/storage/world-storage.d.ts +114 -0
  232. package/dist/core/storage/world-storage.d.ts.map +1 -0
  233. package/dist/core/storage/world-storage.js +378 -0
  234. package/dist/core/storage/world-storage.js.map +1 -0
  235. package/dist/core/subscription.d.ts +43 -0
  236. package/dist/core/subscription.d.ts.map +1 -0
  237. package/dist/core/subscription.js +227 -0
  238. package/dist/core/subscription.js.map +1 -0
  239. package/dist/core/tool-utils.d.ts +80 -0
  240. package/dist/core/tool-utils.d.ts.map +1 -0
  241. package/dist/core/tool-utils.js +273 -0
  242. package/dist/core/tool-utils.js.map +1 -0
  243. package/dist/core/types.d.ts +595 -0
  244. package/dist/core/types.d.ts.map +1 -0
  245. package/dist/core/types.js +158 -0
  246. package/dist/core/types.js.map +1 -0
  247. package/dist/core/utils.d.ts +138 -0
  248. package/dist/core/utils.d.ts.map +1 -0
  249. package/dist/core/utils.js +478 -0
  250. package/dist/core/utils.js.map +1 -0
  251. package/dist/core/world-class.d.ts +43 -0
  252. package/dist/core/world-class.d.ts.map +1 -0
  253. package/dist/core/world-class.js +90 -0
  254. package/dist/core/world-class.js.map +1 -0
  255. package/dist/index.d.ts +18 -0
  256. package/dist/public/assets/agent-sprites-DJFgj-zP.png +0 -0
  257. package/dist/public/assets/border-KHK37r8y.svg +83 -0
  258. package/dist/public/assets/index-C9kPXL6G.css +1 -0
  259. package/dist/public/assets/index-DOQEHGWt.js +96 -0
  260. package/dist/public/index.html +21 -0
  261. package/dist/server/api.d.ts +2 -0
  262. package/dist/server/api.js +1124 -0
  263. package/dist/server/index.d.ts +29 -0
  264. package/dist/server/sse-handler.d.ts +62 -0
  265. package/dist/server/sse-handler.js +234 -0
  266. package/package.json +15 -3
  267. package/scripts/launch-electron.js +0 -58
@@ -0,0 +1,374 @@
1
+ /**
2
+ * OpenAI Direct Integration Module - Pure Client (LLM Provider Refactoring Phase 2)
3
+ *
4
+ * Features:
5
+ * - Direct OpenAI API integration bypassing AI SDK schema corruption bug
6
+ * - Support for OpenAI, Azure OpenAI, and OpenAI-compatible providers
7
+ * - Streaming and non-streaming responses returning LLMResponse
8
+ * - Function/tool calling detection (NO execution)
9
+ * - Proper error handling and retry logic
10
+ * - Browser-safe configuration injection
11
+ * - Pure client: only calls APIs and returns structured data
12
+ *
13
+ * Provider Support:
14
+ * - OpenAI: Direct integration with OpenAI API
15
+ * - Azure OpenAI: Direct integration with Azure OpenAI endpoints
16
+ * - OpenAI-Compatible: Direct integration with custom OpenAI-compatible APIs
17
+ * - XAI: Direct integration using OpenAI package with custom base URL
18
+ * - Ollama: Direct integration using OpenAI package with Ollama's OpenAI-compatible endpoint
19
+ *
20
+ * Implementation Details:
21
+ * - Uses official OpenAI package for reliable API access
22
+ * - Converts AI SDK message format to OpenAI format
23
+ * - Returns LLMResponse with type='text' or type='tool_calls'
24
+ * - Streaming support with chunk-by-chunk processing via onChunk callback
25
+ * - Error handling with descriptive messages
26
+ * - Configuration injection from llm-config module
27
+ * - NO event emission, NO storage, NO tool execution
28
+ *
29
+ * Recent Changes:
30
+ * - 2026-02-16: Fixed streaming tool-call chunk merge to preserve delayed tool `id`/`name` fields across deltas.
31
+ * - 2026-02-13: Added abort-signal support for streaming and non-streaming calls to enable chat stop cancellation.
32
+ * - 2026-02-10: Added env-flagged Ollama tool attachment support via ENABLE_OLLAMA_TOOLS
33
+ * - 2026-02-07: Disabled tool definitions for Ollama provider requests
34
+ * - 2025-11-09: Phase 2 - Removed ALL tool execution logic (~200 lines)
35
+ * - Provider is now a pure client - only API calls and data transformation
36
+ * - Returns LLMResponse interface with type discriminator
37
+ * - Filters invalid tool calls (empty/missing names) and logs warnings
38
+ * - Includes usage tracking (prompt_tokens, completion_tokens) for non-streaming
39
+ * - 2025-11-08: Removed ALL event emission from provider (publishToolEvent, publishSSE)
40
+ * - Streaming uses onChunk callback instead of publishSSE
41
+ * - Initial implementation with full OpenAI package integration
42
+ */
43
+ import OpenAI from 'openai';
44
+ import { createCategoryLogger } from './logger.js';
45
+ import { generateFallbackId } from './tool-utils.js';
46
+ const logger = createCategoryLogger('openai');
47
+ const mcpLogger = createCategoryLogger('mcp.execution');
48
+ /**
49
+ * OpenAI client factory for standard OpenAI API
50
+ */
51
+ export function createOpenAIClient(config) {
52
+ return new OpenAI({
53
+ apiKey: config.apiKey,
54
+ });
55
+ }
56
+ /**
57
+ * OpenAI client factory for Azure OpenAI
58
+ */
59
+ export function createAzureOpenAIClient(config) {
60
+ const endpoint = `https://${config.resourceName}.openai.azure.com`;
61
+ const apiVersion = config.apiVersion || '2024-10-21-preview';
62
+ return new OpenAI({
63
+ apiKey: config.apiKey,
64
+ baseURL: `${endpoint}/openai/deployments/${config.deployment}`,
65
+ defaultQuery: { 'api-version': apiVersion },
66
+ defaultHeaders: {
67
+ 'api-key': config.apiKey,
68
+ },
69
+ });
70
+ }
71
+ /**
72
+ * OpenAI client factory for OpenAI-compatible APIs
73
+ */
74
+ export function createOpenAICompatibleClient(config) {
75
+ return new OpenAI({
76
+ apiKey: config.apiKey,
77
+ baseURL: config.baseUrl,
78
+ });
79
+ }
80
+ /**
81
+ * OpenAI client factory for XAI
82
+ */
83
+ export function createXAIClient(config) {
84
+ return new OpenAI({
85
+ apiKey: config.apiKey,
86
+ baseURL: 'https://api.x.ai/v1',
87
+ });
88
+ }
89
+ /**
90
+ * OpenAI client factory for Ollama (OpenAI-compatible endpoint)
91
+ */
92
+ export function createOllamaClient(config) {
93
+ return new OpenAI({
94
+ apiKey: 'ollama', // Required but unused for local Ollama
95
+ baseURL: config.baseUrl,
96
+ });
97
+ }
98
+ function convertMessagesToOpenAI(messages) {
99
+ return messages.map(message => {
100
+ switch (message.role) {
101
+ case 'system':
102
+ return {
103
+ role: 'system',
104
+ content: message.content,
105
+ };
106
+ case 'user':
107
+ return {
108
+ role: 'user',
109
+ content: message.content,
110
+ };
111
+ case 'assistant':
112
+ return {
113
+ role: 'assistant',
114
+ content: message.content,
115
+ ...(message.tool_calls && { tool_calls: message.tool_calls }),
116
+ };
117
+ case 'tool':
118
+ return {
119
+ role: 'tool',
120
+ content: message.content,
121
+ tool_call_id: message.tool_call_id,
122
+ };
123
+ default:
124
+ throw new Error(`Unsupported message role: ${message.role}`);
125
+ }
126
+ });
127
+ }
128
+ /**
129
+ * Convert MCP tools from AI SDK format to OpenAI format
130
+ */
131
+ function convertMCPToolsToOpenAI(mcpTools) {
132
+ return Object.entries(mcpTools).map(([name, tool]) => ({
133
+ type: 'function',
134
+ function: {
135
+ name,
136
+ description: tool.description || '',
137
+ parameters: tool.parameters || {},
138
+ },
139
+ }));
140
+ }
141
+ function isTruthyEnvValue(value) {
142
+ if (!value)
143
+ return false;
144
+ const normalized = value.trim().toLowerCase();
145
+ return normalized === '1' || normalized === 'true' || normalized === 'yes' || normalized === 'on';
146
+ }
147
+ function shouldAttachTools(provider) {
148
+ if (provider !== 'ollama') {
149
+ return true;
150
+ }
151
+ // Ollama frequently behaves better without OpenAI-style tool definitions attached.
152
+ // Opt-in override: ENABLE_OLLAMA_TOOLS=true|1|yes|on
153
+ return isTruthyEnvValue(process.env.ENABLE_OLLAMA_TOOLS);
154
+ }
155
+ /**
156
+ * Streaming OpenAI response handler - Pure client (no tool execution)
157
+ * Returns LLMResponse with type='text' or type='tool_calls'
158
+ */
159
+ export async function streamOpenAIResponse(client, model, messages, agent, mcpTools, world, onChunk, messageId, abortSignal) {
160
+ const openaiMessages = convertMessagesToOpenAI(messages);
161
+ const openaiTools = shouldAttachTools(agent.provider) && Object.keys(mcpTools).length > 0
162
+ ? convertMCPToolsToOpenAI(mcpTools)
163
+ : undefined;
164
+ const requestParams = {
165
+ model,
166
+ messages: openaiMessages,
167
+ stream: true,
168
+ temperature: agent.temperature,
169
+ max_completion_tokens: agent.maxTokens,
170
+ ...(openaiTools && { tools: openaiTools }),
171
+ };
172
+ logger.debug(`OpenAI Direct: Starting streaming request for agent=${agent.id}, model=${model}`, {
173
+ messageCount: messages.length,
174
+ hasTools: !!openaiTools,
175
+ toolCount: openaiTools?.length || 0,
176
+ });
177
+ const stream = await client.chat.completions.create(requestParams, abortSignal ? { signal: abortSignal } : undefined);
178
+ let fullResponse = '';
179
+ let functionCalls = [];
180
+ try {
181
+ for await (const chunk of stream) {
182
+ if (abortSignal?.aborted) {
183
+ throw new DOMException('OpenAI stream aborted', 'AbortError');
184
+ }
185
+ const delta = chunk.choices[0]?.delta;
186
+ if (delta?.content) {
187
+ fullResponse += delta.content;
188
+ onChunk(delta.content);
189
+ }
190
+ // Handle function calls
191
+ if (delta?.tool_calls) {
192
+ for (const toolCall of delta.tool_calls) {
193
+ if (toolCall.index !== undefined) {
194
+ if (!functionCalls[toolCall.index]) {
195
+ functionCalls[toolCall.index] = {
196
+ id: toolCall.id,
197
+ type: 'function',
198
+ function: { name: toolCall.function?.name || '', arguments: '' },
199
+ };
200
+ }
201
+ if (!functionCalls[toolCall.index].id && toolCall.id) {
202
+ functionCalls[toolCall.index].id = toolCall.id;
203
+ }
204
+ if (toolCall.function?.name
205
+ && toolCall.function.name.trim() !== ''
206
+ && !functionCalls[toolCall.index].function.name) {
207
+ functionCalls[toolCall.index].function.name = toolCall.function.name;
208
+ }
209
+ if (toolCall.function?.arguments) {
210
+ functionCalls[toolCall.index].function.arguments += toolCall.function.arguments;
211
+ }
212
+ }
213
+ }
214
+ }
215
+ }
216
+ // Return LLMResponse based on whether we have tool calls or text
217
+ if (functionCalls.length > 0) {
218
+ // Filter out invalid tool calls (empty or missing names)
219
+ const validCalls = functionCalls.filter(fc => fc.function?.name && fc.function.name.trim() !== '');
220
+ const invalidCalls = functionCalls.filter(fc => !fc.function?.name || fc.function.name.trim() === '');
221
+ if (invalidCalls.length > 0) {
222
+ logger.warn(`OpenAI Direct: Filtered ${invalidCalls.length} invalid tool calls (streaming)`, {
223
+ agentId: agent.id,
224
+ invalidCallIds: invalidCalls.map(fc => fc.id || 'no-id')
225
+ });
226
+ }
227
+ logger.debug(`OpenAI Direct: Completed streaming request with tool calls for agent=${agent.id}`, {
228
+ toolCount: validCalls.length,
229
+ toolNames: validCalls.map(fc => fc.function?.name)
230
+ });
231
+ const toolCallsFormatted = validCalls.map(fc => ({
232
+ id: fc.id || generateFallbackId(),
233
+ type: 'function',
234
+ function: {
235
+ name: fc.function.name,
236
+ arguments: fc.function.arguments || '{}',
237
+ },
238
+ }));
239
+ return {
240
+ type: 'tool_calls',
241
+ content: fullResponse,
242
+ tool_calls: toolCallsFormatted,
243
+ assistantMessage: {
244
+ role: 'assistant',
245
+ content: fullResponse || '',
246
+ tool_calls: toolCallsFormatted,
247
+ },
248
+ usage: undefined, // OpenAI streaming doesn't provide usage in final chunk
249
+ };
250
+ }
251
+ logger.debug(`OpenAI Direct: Completed streaming request for agent=${agent.id}, responseLength=${fullResponse.length}`);
252
+ return {
253
+ type: 'text',
254
+ content: fullResponse,
255
+ assistantMessage: {
256
+ role: 'assistant',
257
+ content: fullResponse,
258
+ },
259
+ usage: undefined, // OpenAI streaming doesn't provide usage in final chunk
260
+ };
261
+ }
262
+ catch (error) {
263
+ logger.error(`OpenAI Direct: Streaming error for agent=${agent.id}:`, error);
264
+ throw error;
265
+ }
266
+ }
267
+ /**
268
+ * Non-streaming OpenAI response handler - Pure client (no tool execution)
269
+ * Returns LLMResponse with type='text' or type='tool_calls'
270
+ */
271
+ export async function generateOpenAIResponse(client, model, messages, agent, mcpTools, world, abortSignal) {
272
+ const openaiMessages = convertMessagesToOpenAI(messages);
273
+ const openaiTools = shouldAttachTools(agent.provider) && Object.keys(mcpTools).length > 0
274
+ ? convertMCPToolsToOpenAI(mcpTools)
275
+ : undefined;
276
+ const requestParams = {
277
+ model,
278
+ messages: openaiMessages,
279
+ temperature: agent.temperature,
280
+ max_completion_tokens: agent.maxTokens,
281
+ ...(openaiTools && { tools: openaiTools }),
282
+ };
283
+ logger.debug(`OpenAI Direct: Starting non-streaming request for agent=${agent.id}, model=${model}`, {
284
+ messageCount: messages.length,
285
+ hasTools: !!openaiTools,
286
+ toolCount: openaiTools?.length || 0,
287
+ });
288
+ try {
289
+ const response = await client.chat.completions.create(requestParams, abortSignal ? { signal: abortSignal } : undefined);
290
+ const message = response.choices[0]?.message;
291
+ if (!message) {
292
+ throw new Error('No response message received from OpenAI');
293
+ }
294
+ let content = message.content || '';
295
+ // Return LLMResponse based on whether we have tool calls or text
296
+ if (message.tool_calls && message.tool_calls.length > 0) {
297
+ // Filter out invalid tool calls (empty or missing names)
298
+ const validToolCalls = message.tool_calls.filter(tc => tc.type === 'function' && tc.function?.name && tc.function.name.trim() !== '');
299
+ const invalidToolCalls = message.tool_calls.filter(tc => tc.type !== 'function' || !tc.function?.name || tc.function.name.trim() === '');
300
+ if (invalidToolCalls.length > 0) {
301
+ logger.warn(`OpenAI Direct: Filtered ${invalidToolCalls.length} invalid tool calls (non-streaming)`, {
302
+ agentId: agent.id,
303
+ invalidCallIds: invalidToolCalls.map(tc => tc.id || 'no-id')
304
+ });
305
+ }
306
+ logger.debug(`OpenAI Direct: Completed non-streaming request with tool calls for agent=${agent.id}`, {
307
+ toolCount: validToolCalls.length,
308
+ toolNames: validToolCalls.map(tc => tc.type === 'function' ? tc.function.name : 'unknown')
309
+ });
310
+ const toolCallsFormatted = validToolCalls.map(tc => {
311
+ const funcCall = tc;
312
+ return {
313
+ id: tc.id || generateFallbackId(),
314
+ type: 'function',
315
+ function: {
316
+ name: funcCall.function.name,
317
+ arguments: funcCall.function.arguments || '{}',
318
+ },
319
+ };
320
+ });
321
+ return {
322
+ type: 'tool_calls',
323
+ content: content,
324
+ tool_calls: toolCallsFormatted,
325
+ assistantMessage: {
326
+ role: 'assistant',
327
+ content: content,
328
+ tool_calls: toolCallsFormatted,
329
+ },
330
+ usage: response.usage ? {
331
+ inputTokens: response.usage.prompt_tokens,
332
+ outputTokens: response.usage.completion_tokens,
333
+ } : undefined,
334
+ };
335
+ }
336
+ logger.debug(`OpenAI Direct: Completed non-streaming request for agent=${agent.id}, responseLength=${content.length}`);
337
+ return {
338
+ type: 'text',
339
+ content: content,
340
+ assistantMessage: {
341
+ role: 'assistant',
342
+ content: content,
343
+ },
344
+ usage: response.usage ? {
345
+ inputTokens: response.usage.prompt_tokens,
346
+ outputTokens: response.usage.completion_tokens,
347
+ } : undefined,
348
+ };
349
+ }
350
+ catch (error) {
351
+ logger.error(`OpenAI Direct: Generation error for agent=${agent.id}:`, error);
352
+ throw error;
353
+ }
354
+ }
355
+ /**
356
+ * Factory function to create appropriate OpenAI client based on provider type
357
+ */
358
+ export function createClientForProvider(providerType, config) {
359
+ switch (providerType) {
360
+ case 'openai':
361
+ return createOpenAIClient(config);
362
+ case 'azure':
363
+ return createAzureOpenAIClient(config);
364
+ case 'openai-compatible':
365
+ return createOpenAICompatibleClient(config);
366
+ case 'xai':
367
+ return createXAIClient(config);
368
+ case 'ollama':
369
+ return createOllamaClient(config);
370
+ default:
371
+ throw new Error(`Unsupported OpenAI provider type: ${providerType}`);
372
+ }
373
+ }
374
+ //# sourceMappingURL=openai-direct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-direct.js","sourceRoot":"","sources":["../../core/openai-direct.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,MAAM,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;AAC9C,MAAM,SAAS,GAAG,oBAAoB,CAAC,eAAe,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAoB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B,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,OAAO;aACjB;YACD,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;gBACtB,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,aAAa;gBACzC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,iBAAiB;aAC/C,CAAC,CAAC,CAAC,SAAS;SACd,CAAC;IAEJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,6CAA6C,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QAC9E,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,YAAoB,EAAE,MAAW;IACvE,QAAQ,YAAY,EAAE,CAAC;QACrB,KAAK,QAAQ;YACX,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACpC,KAAK,OAAO;YACV,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC;QACzC,KAAK,mBAAmB;YACtB,OAAO,4BAA4B,CAAC,MAAM,CAAC,CAAC;QAC9C,KAAK,KAAK;YACR,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;QACjC,KAAK,QAAQ;YACX,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACpC;YACE,MAAM,IAAI,KAAK,CAAC,qCAAqC,YAAY,EAAE,CAAC,CAAC;IACzE,CAAC;AACH,CAAC"}
@@ -0,0 +1,235 @@
1
+ /**
2
+ * Shell Command Tool Module - Built-in LLM tool for executing shell commands
3
+ *
4
+ * Features:
5
+ * - Execute shell commands in child processes with parameter support
6
+ * - Capture stdout and stderr output
7
+ * - Persist command execution history (command, parameters, results, exceptions)
8
+ * - Return results to LLM for further processing
9
+ * - Error handling and exception tracking
10
+ * - Long-running command support with 10-minute default timeout
11
+ * - Trusted working-directory enforcement from world/tool context
12
+ * - Explicit rejection when LLM-supplied directory conflicts with trusted working directory
13
+ * - Graceful error handling for invalid tool calls
14
+ * - Universal parameter validation for consistent execution
15
+ * - Explicit execution safety configuration using structured metadata
16
+ *
17
+ * Implementation Details:
18
+ * - Uses Node.js child_process.spawn for command execution
19
+ * - Executes commands through shell for PATH resolution and shell features
20
+ * - Stores execution history in-memory (can be extended to persistent storage)
21
+ * - Provides MCP-compatible tool interface for LLM integration
22
+ * - Timeout support to prevent hanging processes (default: 10 minutes)
23
+ * - Resource cleanup on process completion
24
+ * - Resolves command cwd from trusted world/tool context, not LLM args
25
+ * - Rejects directory mismatch instead of silently overriding requested path
26
+ * - Returns error results instead of throwing to prevent agent crashes
27
+ * - Uses universal validation framework for consistent parameter checking
28
+ *
29
+ * Recent Changes:
30
+ * - 2026-02-15: Moved core cwd-boundary enforcement into `executeShellCommand` via optional `trustedWorkingDirectory` execution option.
31
+ * - 2026-02-15: Added optional `output_format=json` for machine-readable command results.
32
+ * - 2026-02-15: Added optional `artifact_paths` support with SHA-256 hashing and byte-size metadata for files within trusted scope.
33
+ * - 2026-02-14: Default trusted cwd now falls back to shared core default working directory (user home by default) instead of `./` when world variable is unset.
34
+ * - 2026-02-14: Added inline-script execution guard (e.g. `sh -c`, `node -e`) to prevent embedded path bypass outside trusted cwd.
35
+ * - 2026-02-14: Hardened cwd containment checks by canonicalizing absolute paths and validating additional path argument forms (`./`, `../`, and `--flag=/path`).
36
+ * - 2026-02-13: Updated directory-request validation to allow requested folders inside world working_directory and reject only outside paths.
37
+ * - 2026-02-13: Added command/parameter path scope validation so shell_cmd rejects path targets outside trusted world working_directory.
38
+ * - 2026-02-13: Added strict directory-mismatch guard for shell_cmd; mismatched LLM directory requests now fail with explicit error.
39
+ * - 2026-02-13: Fixed validation error result typing by including `executionId` when formatting failed shell_cmd calls.
40
+ * - 2026-02-13: Stopped trusting LLM-provided `directory`; shell commands now resolve working directory from trusted world/tool context only.
41
+ * - 2026-02-13: Added explicit command-cancellation detection and AbortError propagation in tool execution to prevent post-stop continuation.
42
+ * - 2026-02-13: Added chat-scoped shell process tracking and stop controls for Electron stop-message support.
43
+ * - 2026-02-08: Added streaming callback support for real-time output
44
+ * * Added onStdout and onStderr callbacks to executeShellCommand options
45
+ * * Callbacks invoked in real-time as data arrives from child process
46
+ * * Maintains backwards compatibility - callbacks are optional
47
+ * * Full output still accumulated and returned in CommandExecutionResult
48
+ * - 2026-02-06: Removed legacy manual tool-decision metadata
49
+ * - 2025-11-11: CRITICAL FIX - Quote parameters for shell execution
50
+ * * Parameters with spaces/tabs/newlines now properly quoted before spawn
51
+ * * Prevents shell from splitting multi-word parameters
52
+ * * Applied to both execution AND display formatting
53
+ * - 2025-11-10: Fixed shell execution - enabled shell: true to support PATH resolution and installed commands
54
+ * - Integrated universal parameter validation for consistent tool execution
55
+ * - Enhanced validation to check required parameters and auto-correct types
56
+ * - Replaced custom validation with standardized validation framework
57
+ * - Added graceful error handling for empty commands to prevent agent crashes
58
+ * - Changed validation to return error results instead of throwing exceptions
59
+ * - Updated tests to expect error results rather than thrown errors
60
+ * - Added LLM guidance to ask user for directory when not provided
61
+ * - Made directory parameter required for shell command execution
62
+ * - Increased default timeout from 30s to 10 minutes (600000ms) for long-running commands
63
+ * - Initial implementation for shell_cmd LLM tool
64
+ */
65
+ import { type ShellProcessExecutionRecord, type ShellProcessStatusEvent, type ListShellProcessExecutionsOptions, type CancelShellProcessResult, type DeleteShellProcessResult } from './shell-process-registry.js';
66
+ /**
67
+ * Command execution result
68
+ */
69
+ export interface CommandExecutionResult {
70
+ executionId: string;
71
+ command: string;
72
+ parameters: string[];
73
+ stdout: string;
74
+ stderr: string;
75
+ exitCode: number | null;
76
+ signal: string | null;
77
+ error?: string;
78
+ canceled?: boolean;
79
+ timedOut?: boolean;
80
+ executedAt: Date;
81
+ duration: number;
82
+ }
83
+ export interface CommandExecutionArtifact {
84
+ path: string;
85
+ sha256: string;
86
+ bytes: number;
87
+ }
88
+ export interface StructuredCommandExecutionResult {
89
+ exit_code: number | null;
90
+ stdout: string;
91
+ stderr: string;
92
+ timed_out: boolean;
93
+ duration_ms: number;
94
+ artifacts: CommandExecutionArtifact[];
95
+ stdout_truncated?: boolean;
96
+ stderr_truncated?: boolean;
97
+ }
98
+ interface OutputFormattingOptions {
99
+ detail?: 'minimal' | 'full';
100
+ maxOutputChars?: number;
101
+ }
102
+ export declare function resolveTrustedShellWorkingDirectory(context?: {
103
+ world?: {
104
+ variables?: string;
105
+ };
106
+ workingDirectory?: string;
107
+ }): string;
108
+ export declare function validateShellDirectoryRequest(requestedDirectory: unknown, trustedWorkingDirectory: string): {
109
+ valid: true;
110
+ } | {
111
+ valid: false;
112
+ error: string;
113
+ };
114
+ export declare function validateShellCommandScope(command: unknown, parameters: unknown, trustedWorkingDirectory: string): {
115
+ valid: true;
116
+ } | {
117
+ valid: false;
118
+ error: string;
119
+ };
120
+ export declare function stopShellCommandsForChat(worldId: string, chatId: string): {
121
+ killed: number;
122
+ };
123
+ export declare function isCommandExecutionCanceled(result: CommandExecutionResult): boolean;
124
+ /**
125
+ * Execute a shell command with parameters and capture output
126
+ *
127
+ * @param command - The shell command to execute (e.g., 'ls', 'echo', 'cat')
128
+ * @param parameters - Array of parameters for the command (e.g., ['-la', '/tmp'])
129
+ * @param directory - Working directory for command execution (required)
130
+ * @param options - Execution options
131
+ * @returns Promise<CommandExecutionResult> - Execution result with output and metadata
132
+ */
133
+ export declare function executeShellCommand(command: string, parameters: string[] | undefined, directory: string, options?: {
134
+ timeout?: number;
135
+ onStdout?: (data: string) => void;
136
+ onStderr?: (data: string) => void;
137
+ abortSignal?: AbortSignal;
138
+ worldId?: string;
139
+ chatId?: string;
140
+ onStatusChange?: (event: ShellProcessStatusEvent) => void;
141
+ trustedWorkingDirectory?: string;
142
+ }): Promise<CommandExecutionResult>;
143
+ export interface DeleteExecutionHistoryResult {
144
+ executionId: string;
145
+ outcome: DeleteShellProcessResult['outcome'];
146
+ removedHistoryEntries: number;
147
+ }
148
+ export declare function getProcessExecution(executionId: string): ShellProcessExecutionRecord | null;
149
+ export declare function listProcessExecutions(options?: ListShellProcessExecutionsOptions): ShellProcessExecutionRecord[];
150
+ export declare function cancelProcessExecution(executionId: string): CancelShellProcessResult;
151
+ export declare function deleteProcessExecution(executionId: string): DeleteExecutionHistoryResult;
152
+ export declare function subscribeProcessExecutionStatus(listener: (event: ShellProcessStatusEvent) => void): () => void;
153
+ export declare function clearProcessExecutionStateForTests(): {
154
+ historyCleared: number;
155
+ registryExecutionCount: number;
156
+ registryActiveCount: number;
157
+ };
158
+ /**
159
+ * Get command execution history
160
+ *
161
+ * @param limit - Maximum number of results to return (default: 100)
162
+ * @returns Array of command execution results, most recent first
163
+ */
164
+ export declare function getExecutionHistory(limit?: number): CommandExecutionResult[];
165
+ /**
166
+ * Clear execution history
167
+ * Useful for testing or memory management
168
+ *
169
+ * @returns Number of entries cleared
170
+ */
171
+ export declare function clearExecutionHistory(): number;
172
+ export declare function formatStructuredResult(result: CommandExecutionResult, artifacts?: CommandExecutionArtifact[], options?: OutputFormattingOptions): StructuredCommandExecutionResult;
173
+ /**
174
+ * Format command execution result for LLM consumption
175
+ * Provides a human-readable summary of the execution with improved markdown formatting
176
+ *
177
+ * @param result - Command execution result
178
+ * @returns Formatted markdown string suitable for LLM and display
179
+ */
180
+ export declare function formatResultForLLM(result: CommandExecutionResult, options?: OutputFormattingOptions): string;
181
+ /**
182
+ * Create MCP-compatible tool definition for shell_cmd
183
+ * This tool can be registered with the MCP system for LLM use
184
+ *
185
+ * @returns MCP tool definition object
186
+ */
187
+ export declare function createShellCmdToolDefinition(): {
188
+ description: string;
189
+ parameters: {
190
+ type: string;
191
+ properties: {
192
+ command: {
193
+ type: string;
194
+ description: string;
195
+ };
196
+ parameters: {
197
+ type: string;
198
+ items: {
199
+ type: string;
200
+ };
201
+ description: string;
202
+ };
203
+ directory: {
204
+ type: string;
205
+ description: string;
206
+ };
207
+ timeout: {
208
+ type: string;
209
+ description: string;
210
+ };
211
+ output_format: {
212
+ type: string;
213
+ enum: string[];
214
+ description: string;
215
+ };
216
+ output_detail: {
217
+ type: string;
218
+ enum: string[];
219
+ description: string;
220
+ };
221
+ artifact_paths: {
222
+ type: string;
223
+ items: {
224
+ type: string;
225
+ };
226
+ description: string;
227
+ };
228
+ };
229
+ required: string[];
230
+ additionalProperties: boolean;
231
+ };
232
+ execute: (args: any, sequenceId?: string, parentToolCall?: string, context?: any) => Promise<string>;
233
+ };
234
+ export {};
235
+ //# sourceMappingURL=shell-cmd-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-cmd-tool.d.ts","sourceRoot":"","sources":["../../core/shell-cmd-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAWH,OAAO,EAYL,KAAK,2BAA2B,EAChC,KAAK,uBAAuB,EAC5B,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC9B,MAAM,6BAA6B,CAAC;AAiBrC;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,IAAI,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gCAAgC;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