@wingman-ai/gateway 0.1.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 (418) hide show
  1. package/.wingman/agents/README.md +161 -0
  2. package/.wingman/agents/coding/agent.md +147 -0
  3. package/.wingman/agents/coding/implementor.md +56 -0
  4. package/.wingman/agents/main/agent.md +19 -0
  5. package/.wingman/agents/researcher/agent.md +62 -0
  6. package/.wingman/agents/stock-trader/agent.md +223 -0
  7. package/.wingman/agents/stock-trader/chain-curator.md +24 -0
  8. package/.wingman/agents/stock-trader/goal-translator.md +42 -0
  9. package/.wingman/agents/stock-trader/guardrails-veto.md +11 -0
  10. package/.wingman/agents/stock-trader/path-planner.md +23 -0
  11. package/.wingman/agents/stock-trader/regime-analyst.md +15 -0
  12. package/.wingman/agents/stock-trader/risk.md +20 -0
  13. package/.wingman/agents/stock-trader/selection.md +22 -0
  14. package/.wingman/agents/stock-trader/strategy-composer.md +38 -0
  15. package/.wingman/agents/wingman/agent.json +12 -0
  16. package/bin/wingman +7 -0
  17. package/dist/agent/config/agentConfig.cjs +95 -0
  18. package/dist/agent/config/agentConfig.d.ts +187 -0
  19. package/dist/agent/config/agentConfig.js +52 -0
  20. package/dist/agent/config/agentLoader.cjs +242 -0
  21. package/dist/agent/config/agentLoader.d.ts +42 -0
  22. package/dist/agent/config/agentLoader.js +208 -0
  23. package/dist/agent/config/mcpClientManager.cjs +168 -0
  24. package/dist/agent/config/mcpClientManager.d.ts +41 -0
  25. package/dist/agent/config/mcpClientManager.js +134 -0
  26. package/dist/agent/config/modelFactory.cjs +175 -0
  27. package/dist/agent/config/modelFactory.d.ts +33 -0
  28. package/dist/agent/config/modelFactory.js +141 -0
  29. package/dist/agent/config/toolRegistry.cjs +111 -0
  30. package/dist/agent/config/toolRegistry.d.ts +25 -0
  31. package/dist/agent/config/toolRegistry.js +71 -0
  32. package/dist/agent/middleware/additional-messages.cjs +60 -0
  33. package/dist/agent/middleware/additional-messages.d.ts +7 -0
  34. package/dist/agent/middleware/additional-messages.js +26 -0
  35. package/dist/agent/middleware/hooks/executor.cjs +137 -0
  36. package/dist/agent/middleware/hooks/executor.d.ts +52 -0
  37. package/dist/agent/middleware/hooks/executor.js +103 -0
  38. package/dist/agent/middleware/hooks/input-builder.cjs +55 -0
  39. package/dist/agent/middleware/hooks/input-builder.d.ts +15 -0
  40. package/dist/agent/middleware/hooks/input-builder.js +21 -0
  41. package/dist/agent/middleware/hooks/matcher.cjs +59 -0
  42. package/dist/agent/middleware/hooks/matcher.d.ts +27 -0
  43. package/dist/agent/middleware/hooks/matcher.js +22 -0
  44. package/dist/agent/middleware/hooks/merger.cjs +54 -0
  45. package/dist/agent/middleware/hooks/merger.d.ts +18 -0
  46. package/dist/agent/middleware/hooks/merger.js +20 -0
  47. package/dist/agent/middleware/hooks/types.cjs +62 -0
  48. package/dist/agent/middleware/hooks/types.d.ts +82 -0
  49. package/dist/agent/middleware/hooks/types.js +19 -0
  50. package/dist/agent/middleware/hooks.cjs +79 -0
  51. package/dist/agent/middleware/hooks.d.ts +19 -0
  52. package/dist/agent/middleware/hooks.js +45 -0
  53. package/dist/agent/middleware/media-compat.cjs +80 -0
  54. package/dist/agent/middleware/media-compat.d.ts +7 -0
  55. package/dist/agent/middleware/media-compat.js +46 -0
  56. package/dist/agent/tests/agentConfig.test.cjs +132 -0
  57. package/dist/agent/tests/agentConfig.test.d.ts +1 -0
  58. package/dist/agent/tests/agentConfig.test.js +126 -0
  59. package/dist/agent/tests/agentLoader.test.cjs +235 -0
  60. package/dist/agent/tests/agentLoader.test.d.ts +1 -0
  61. package/dist/agent/tests/agentLoader.test.js +229 -0
  62. package/dist/agent/tests/modelFactory.test.cjs +114 -0
  63. package/dist/agent/tests/modelFactory.test.d.ts +1 -0
  64. package/dist/agent/tests/modelFactory.test.js +108 -0
  65. package/dist/agent/tests/test-agent-loader.cjs +33 -0
  66. package/dist/agent/tests/test-agent-loader.d.ts +1 -0
  67. package/dist/agent/tests/test-agent-loader.js +27 -0
  68. package/dist/agent/tests/test-subagent-loading.cjs +99 -0
  69. package/dist/agent/tests/test-subagent-loading.d.ts +1 -0
  70. package/dist/agent/tests/test-subagent-loading.js +93 -0
  71. package/dist/agent/tests/toolRegistry.test.cjs +109 -0
  72. package/dist/agent/tests/toolRegistry.test.d.ts +1 -0
  73. package/dist/agent/tests/toolRegistry.test.js +103 -0
  74. package/dist/agent/tools/code_search.cjs +108 -0
  75. package/dist/agent/tools/code_search.d.ts +24 -0
  76. package/dist/agent/tools/code_search.js +74 -0
  77. package/dist/agent/tools/command_execute.cjs +136 -0
  78. package/dist/agent/tools/command_execute.d.ts +12 -0
  79. package/dist/agent/tools/command_execute.js +99 -0
  80. package/dist/agent/tools/git_status.cjs +126 -0
  81. package/dist/agent/tools/git_status.d.ts +15 -0
  82. package/dist/agent/tools/git_status.js +92 -0
  83. package/dist/agent/tools/internet_search.cjs +93 -0
  84. package/dist/agent/tools/internet_search.d.ts +25 -0
  85. package/dist/agent/tools/internet_search.js +56 -0
  86. package/dist/agent/tools/think.cjs +53 -0
  87. package/dist/agent/tools/think.d.ts +26 -0
  88. package/dist/agent/tools/think.js +16 -0
  89. package/dist/agent/tools/web_crawler.cjs +180 -0
  90. package/dist/agent/tools/web_crawler.d.ts +31 -0
  91. package/dist/agent/tools/web_crawler.js +143 -0
  92. package/dist/agent/utils.cjs +54 -0
  93. package/dist/agent/utils.d.ts +1 -0
  94. package/dist/agent/utils.js +10 -0
  95. package/dist/cli/commands/agent.cjs +169 -0
  96. package/dist/cli/commands/agent.d.ts +15 -0
  97. package/dist/cli/commands/agent.js +125 -0
  98. package/dist/cli/commands/gateway.cjs +601 -0
  99. package/dist/cli/commands/gateway.d.ts +12 -0
  100. package/dist/cli/commands/gateway.js +567 -0
  101. package/dist/cli/commands/init.cjs +681 -0
  102. package/dist/cli/commands/init.d.ts +10 -0
  103. package/dist/cli/commands/init.js +634 -0
  104. package/dist/cli/commands/provider.cjs +208 -0
  105. package/dist/cli/commands/provider.d.ts +5 -0
  106. package/dist/cli/commands/provider.js +174 -0
  107. package/dist/cli/commands/skill.cjs +145 -0
  108. package/dist/cli/commands/skill.d.ts +10 -0
  109. package/dist/cli/commands/skill.js +111 -0
  110. package/dist/cli/config/loader.cjs +143 -0
  111. package/dist/cli/config/loader.d.ts +14 -0
  112. package/dist/cli/config/loader.js +109 -0
  113. package/dist/cli/config/schema.cjs +262 -0
  114. package/dist/cli/config/schema.d.ts +268 -0
  115. package/dist/cli/config/schema.js +213 -0
  116. package/dist/cli/core/agentInvoker.cjs +284 -0
  117. package/dist/cli/core/agentInvoker.d.ts +77 -0
  118. package/dist/cli/core/agentInvoker.js +247 -0
  119. package/dist/cli/core/commandHandler.cjs +257 -0
  120. package/dist/cli/core/commandHandler.d.ts +62 -0
  121. package/dist/cli/core/commandHandler.js +223 -0
  122. package/dist/cli/core/database/bunSqliteAdapter.cjs +87 -0
  123. package/dist/cli/core/database/bunSqliteAdapter.d.ts +34 -0
  124. package/dist/cli/core/database/bunSqliteAdapter.js +53 -0
  125. package/dist/cli/core/loggerBridge.cjs +42 -0
  126. package/dist/cli/core/loggerBridge.d.ts +8 -0
  127. package/dist/cli/core/loggerBridge.js +8 -0
  128. package/dist/cli/core/outputManager.cjs +106 -0
  129. package/dist/cli/core/outputManager.d.ts +43 -0
  130. package/dist/cli/core/outputManager.js +72 -0
  131. package/dist/cli/core/sessionManager.cjs +535 -0
  132. package/dist/cli/core/sessionManager.d.ts +111 -0
  133. package/dist/cli/core/sessionManager.js +486 -0
  134. package/dist/cli/core/streamParser.cjs +328 -0
  135. package/dist/cli/core/streamParser.d.ts +42 -0
  136. package/dist/cli/core/streamParser.js +288 -0
  137. package/dist/cli/index.cjs +211 -0
  138. package/dist/cli/index.d.ts +2 -0
  139. package/dist/cli/index.js +205 -0
  140. package/dist/cli/services/skillRepository.cjs +178 -0
  141. package/dist/cli/services/skillRepository.d.ts +35 -0
  142. package/dist/cli/services/skillRepository.js +144 -0
  143. package/dist/cli/services/skillService.cjs +336 -0
  144. package/dist/cli/services/skillService.d.ts +48 -0
  145. package/dist/cli/services/skillService.js +302 -0
  146. package/dist/cli/types/gateway.cjs +18 -0
  147. package/dist/cli/types/gateway.d.ts +18 -0
  148. package/dist/cli/types/gateway.js +0 -0
  149. package/dist/cli/types/init.cjs +18 -0
  150. package/dist/cli/types/init.d.ts +13 -0
  151. package/dist/cli/types/init.js +0 -0
  152. package/dist/cli/types/provider.cjs +18 -0
  153. package/dist/cli/types/provider.d.ts +9 -0
  154. package/dist/cli/types/provider.js +0 -0
  155. package/dist/cli/types/skill.cjs +18 -0
  156. package/dist/cli/types/skill.d.ts +71 -0
  157. package/dist/cli/types/skill.js +0 -0
  158. package/dist/cli/types.cjs +18 -0
  159. package/dist/cli/types.d.ts +175 -0
  160. package/dist/cli/types.js +0 -0
  161. package/dist/cli/ui/AgentOutput.cjs +82 -0
  162. package/dist/cli/ui/AgentOutput.d.ts +8 -0
  163. package/dist/cli/ui/AgentOutput.js +38 -0
  164. package/dist/cli/ui/App.cjs +285 -0
  165. package/dist/cli/ui/App.d.ts +6 -0
  166. package/dist/cli/ui/App.js +241 -0
  167. package/dist/cli/ui/ErrorDisplay.cjs +65 -0
  168. package/dist/cli/ui/ErrorDisplay.d.ts +8 -0
  169. package/dist/cli/ui/ErrorDisplay.js +21 -0
  170. package/dist/cli/ui/LogDisplay.cjs +74 -0
  171. package/dist/cli/ui/LogDisplay.d.ts +13 -0
  172. package/dist/cli/ui/LogDisplay.js +30 -0
  173. package/dist/cli/ui/SessionListDisplay.cjs +135 -0
  174. package/dist/cli/ui/SessionListDisplay.d.ts +9 -0
  175. package/dist/cli/ui/SessionListDisplay.js +91 -0
  176. package/dist/cli/ui/blockHelpers.cjs +80 -0
  177. package/dist/cli/ui/blockHelpers.d.ts +21 -0
  178. package/dist/cli/ui/blockHelpers.js +40 -0
  179. package/dist/cli/ui/components/ToolCallDisplay.cjs +207 -0
  180. package/dist/cli/ui/components/ToolCallDisplay.d.ts +7 -0
  181. package/dist/cli/ui/components/ToolCallDisplay.js +162 -0
  182. package/dist/cli/ui/components/ToolResultDisplay.cjs +86 -0
  183. package/dist/cli/ui/components/ToolResultDisplay.d.ts +8 -0
  184. package/dist/cli/ui/components/ToolResultDisplay.js +42 -0
  185. package/dist/cli/ui/toolDisplayHelpers.cjs +112 -0
  186. package/dist/cli/ui/toolDisplayHelpers.d.ts +3 -0
  187. package/dist/cli/ui/toolDisplayHelpers.js +72 -0
  188. package/dist/gateway/adapters/discord.cjs +298 -0
  189. package/dist/gateway/adapters/discord.d.ts +42 -0
  190. package/dist/gateway/adapters/discord.js +246 -0
  191. package/dist/gateway/auth.cjs +94 -0
  192. package/dist/gateway/auth.d.ts +36 -0
  193. package/dist/gateway/auth.js +60 -0
  194. package/dist/gateway/broadcast.cjs +131 -0
  195. package/dist/gateway/broadcast.d.ts +76 -0
  196. package/dist/gateway/broadcast.js +97 -0
  197. package/dist/gateway/client.cjs +282 -0
  198. package/dist/gateway/client.d.ts +141 -0
  199. package/dist/gateway/client.js +248 -0
  200. package/dist/gateway/daemon.cjs +195 -0
  201. package/dist/gateway/daemon.d.ts +67 -0
  202. package/dist/gateway/daemon.js +161 -0
  203. package/dist/gateway/discovery/index.cjs +72 -0
  204. package/dist/gateway/discovery/index.d.ts +3 -0
  205. package/dist/gateway/discovery/index.js +3 -0
  206. package/dist/gateway/discovery/mdns.cjs +221 -0
  207. package/dist/gateway/discovery/mdns.d.ts +37 -0
  208. package/dist/gateway/discovery/mdns.js +177 -0
  209. package/dist/gateway/discovery/tailscale.cjs +140 -0
  210. package/dist/gateway/discovery/tailscale.d.ts +31 -0
  211. package/dist/gateway/discovery/tailscale.js +106 -0
  212. package/dist/gateway/discovery/types.cjs +18 -0
  213. package/dist/gateway/discovery/types.d.ts +41 -0
  214. package/dist/gateway/discovery/types.js +0 -0
  215. package/dist/gateway/env.cjs +45 -0
  216. package/dist/gateway/env.d.ts +2 -0
  217. package/dist/gateway/env.js +8 -0
  218. package/dist/gateway/hooks/loader.cjs +137 -0
  219. package/dist/gateway/hooks/loader.d.ts +10 -0
  220. package/dist/gateway/hooks/loader.js +103 -0
  221. package/dist/gateway/hooks/registry.cjs +128 -0
  222. package/dist/gateway/hooks/registry.d.ts +13 -0
  223. package/dist/gateway/hooks/registry.js +94 -0
  224. package/dist/gateway/hooks/types.cjs +58 -0
  225. package/dist/gateway/hooks/types.d.ts +50 -0
  226. package/dist/gateway/hooks/types.js +18 -0
  227. package/dist/gateway/http/agents.cjs +280 -0
  228. package/dist/gateway/http/agents.d.ts +2 -0
  229. package/dist/gateway/http/agents.js +246 -0
  230. package/dist/gateway/http/fs.cjs +81 -0
  231. package/dist/gateway/http/fs.d.ts +2 -0
  232. package/dist/gateway/http/fs.js +47 -0
  233. package/dist/gateway/http/providers.cjs +120 -0
  234. package/dist/gateway/http/providers.d.ts +2 -0
  235. package/dist/gateway/http/providers.js +86 -0
  236. package/dist/gateway/http/routines.cjs +196 -0
  237. package/dist/gateway/http/routines.d.ts +20 -0
  238. package/dist/gateway/http/routines.js +159 -0
  239. package/dist/gateway/http/sessions.cjs +241 -0
  240. package/dist/gateway/http/sessions.d.ts +2 -0
  241. package/dist/gateway/http/sessions.js +207 -0
  242. package/dist/gateway/http/types.cjs +18 -0
  243. package/dist/gateway/http/types.d.ts +25 -0
  244. package/dist/gateway/http/types.js +0 -0
  245. package/dist/gateway/http/voice.cjs +167 -0
  246. package/dist/gateway/http/voice.d.ts +2 -0
  247. package/dist/gateway/http/voice.js +133 -0
  248. package/dist/gateway/http/webhooks.cjs +353 -0
  249. package/dist/gateway/http/webhooks.d.ts +22 -0
  250. package/dist/gateway/http/webhooks.js +313 -0
  251. package/dist/gateway/index.cjs +119 -0
  252. package/dist/gateway/index.d.ts +8 -0
  253. package/dist/gateway/index.js +9 -0
  254. package/dist/gateway/node.cjs +218 -0
  255. package/dist/gateway/node.d.ts +112 -0
  256. package/dist/gateway/node.js +184 -0
  257. package/dist/gateway/router.cjs +85 -0
  258. package/dist/gateway/router.d.ts +9 -0
  259. package/dist/gateway/router.js +51 -0
  260. package/dist/gateway/rpcClient.cjs +152 -0
  261. package/dist/gateway/rpcClient.d.ts +24 -0
  262. package/dist/gateway/rpcClient.js +118 -0
  263. package/dist/gateway/server.cjs +1175 -0
  264. package/dist/gateway/server.d.ts +185 -0
  265. package/dist/gateway/server.js +1138 -0
  266. package/dist/gateway/transport/http.cjs +153 -0
  267. package/dist/gateway/transport/http.d.ts +25 -0
  268. package/dist/gateway/transport/http.js +119 -0
  269. package/dist/gateway/transport/index.cjs +40 -0
  270. package/dist/gateway/transport/index.d.ts +3 -0
  271. package/dist/gateway/transport/index.js +3 -0
  272. package/dist/gateway/transport/types.cjs +18 -0
  273. package/dist/gateway/transport/types.d.ts +59 -0
  274. package/dist/gateway/transport/types.js +0 -0
  275. package/dist/gateway/transport/websocket.cjs +132 -0
  276. package/dist/gateway/transport/websocket.d.ts +21 -0
  277. package/dist/gateway/transport/websocket.js +98 -0
  278. package/dist/gateway/types.cjs +18 -0
  279. package/dist/gateway/types.d.ts +215 -0
  280. package/dist/gateway/types.js +0 -0
  281. package/dist/gateway/validation.cjs +225 -0
  282. package/dist/gateway/validation.d.ts +157 -0
  283. package/dist/gateway/validation.js +158 -0
  284. package/dist/index.cjs +95 -0
  285. package/dist/index.d.ts +6 -0
  286. package/dist/index.js +6 -0
  287. package/dist/logger.cjs +270 -0
  288. package/dist/logger.d.ts +54 -0
  289. package/dist/logger.js +215 -0
  290. package/dist/providers/copilot.cjs +148 -0
  291. package/dist/providers/copilot.d.ts +3 -0
  292. package/dist/providers/copilot.js +114 -0
  293. package/dist/providers/credentials.cjs +154 -0
  294. package/dist/providers/credentials.d.ts +26 -0
  295. package/dist/providers/credentials.js +99 -0
  296. package/dist/providers/oauth.cjs +279 -0
  297. package/dist/providers/oauth.d.ts +13 -0
  298. package/dist/providers/oauth.js +245 -0
  299. package/dist/providers/registry.cjs +138 -0
  300. package/dist/providers/registry.d.ts +32 -0
  301. package/dist/providers/registry.js +98 -0
  302. package/dist/tests/additionalMessageMiddleware.test.cjs +45 -0
  303. package/dist/tests/additionalMessageMiddleware.test.d.ts +1 -0
  304. package/dist/tests/additionalMessageMiddleware.test.js +39 -0
  305. package/dist/tests/agent-config-voice.test.cjs +25 -0
  306. package/dist/tests/agent-config-voice.test.d.ts +1 -0
  307. package/dist/tests/agent-config-voice.test.js +19 -0
  308. package/dist/tests/agentInvokerAttachments.test.cjs +67 -0
  309. package/dist/tests/agentInvokerAttachments.test.d.ts +1 -0
  310. package/dist/tests/agentInvokerAttachments.test.js +61 -0
  311. package/dist/tests/attachments-utils.test.cjs +46 -0
  312. package/dist/tests/attachments-utils.test.d.ts +1 -0
  313. package/dist/tests/attachments-utils.test.js +40 -0
  314. package/dist/tests/bunSqliteAdapter.test.cjs +265 -0
  315. package/dist/tests/bunSqliteAdapter.test.d.ts +1 -0
  316. package/dist/tests/bunSqliteAdapter.test.js +259 -0
  317. package/dist/tests/candleRange.test.cjs +48 -0
  318. package/dist/tests/candleRange.test.d.ts +1 -0
  319. package/dist/tests/candleRange.test.js +42 -0
  320. package/dist/tests/cli-config-loader.test.cjs +364 -0
  321. package/dist/tests/cli-config-loader.test.d.ts +1 -0
  322. package/dist/tests/cli-config-loader.test.js +358 -0
  323. package/dist/tests/cli-init.test.cjs +82 -0
  324. package/dist/tests/cli-init.test.d.ts +1 -0
  325. package/dist/tests/cli-init.test.js +76 -0
  326. package/dist/tests/discord-adapter.test.cjs +55 -0
  327. package/dist/tests/discord-adapter.test.d.ts +1 -0
  328. package/dist/tests/discord-adapter.test.js +49 -0
  329. package/dist/tests/gateway.test.cjs +319 -0
  330. package/dist/tests/gateway.test.d.ts +1 -0
  331. package/dist/tests/gateway.test.js +313 -0
  332. package/dist/tests/hooks-matcher.test.cjs +309 -0
  333. package/dist/tests/hooks-matcher.test.d.ts +1 -0
  334. package/dist/tests/hooks-matcher.test.js +303 -0
  335. package/dist/tests/hooks-merger.test.cjs +528 -0
  336. package/dist/tests/hooks-merger.test.d.ts +1 -0
  337. package/dist/tests/hooks-merger.test.js +522 -0
  338. package/dist/tests/integration/agent-invocation.integration.test.cjs +264 -0
  339. package/dist/tests/integration/agent-invocation.integration.test.d.ts +1 -0
  340. package/dist/tests/integration/agent-invocation.integration.test.js +258 -0
  341. package/dist/tests/integration/finnhub-candles.integration.test.cjs +98 -0
  342. package/dist/tests/integration/finnhub-candles.integration.test.d.ts +1 -0
  343. package/dist/tests/integration/finnhub-candles.integration.test.js +92 -0
  344. package/dist/tests/logger.test.cjs +353 -0
  345. package/dist/tests/logger.test.d.ts +1 -0
  346. package/dist/tests/logger.test.js +347 -0
  347. package/dist/tests/mediaCompatibilityMiddleware.test.cjs +106 -0
  348. package/dist/tests/mediaCompatibilityMiddleware.test.d.ts +1 -0
  349. package/dist/tests/mediaCompatibilityMiddleware.test.js +100 -0
  350. package/dist/tests/routines-api.test.cjs +107 -0
  351. package/dist/tests/routines-api.test.d.ts +1 -0
  352. package/dist/tests/routines-api.test.js +101 -0
  353. package/dist/tests/sessionMessageAttachments.test.cjs +108 -0
  354. package/dist/tests/sessionMessageAttachments.test.d.ts +1 -0
  355. package/dist/tests/sessionMessageAttachments.test.js +102 -0
  356. package/dist/tests/sessionMessageRole.test.cjs +44 -0
  357. package/dist/tests/sessionMessageRole.test.d.ts +1 -0
  358. package/dist/tests/sessionMessageRole.test.js +38 -0
  359. package/dist/tests/sessionStateMessages.test.cjs +72 -0
  360. package/dist/tests/sessionStateMessages.test.d.ts +1 -0
  361. package/dist/tests/sessionStateMessages.test.js +66 -0
  362. package/dist/tests/sessions-api.test.cjs +68 -0
  363. package/dist/tests/sessions-api.test.d.ts +1 -0
  364. package/dist/tests/sessions-api.test.js +62 -0
  365. package/dist/tests/technicalIndicators.test.cjs +82 -0
  366. package/dist/tests/technicalIndicators.test.d.ts +1 -0
  367. package/dist/tests/technicalIndicators.test.js +76 -0
  368. package/dist/tests/toolDisplayHelpers.test.cjs +43 -0
  369. package/dist/tests/toolDisplayHelpers.test.d.ts +1 -0
  370. package/dist/tests/toolDisplayHelpers.test.js +37 -0
  371. package/dist/tests/voice-config.test.cjs +35 -0
  372. package/dist/tests/voice-config.test.d.ts +1 -0
  373. package/dist/tests/voice-config.test.js +29 -0
  374. package/dist/tests/yahooCandles.test.cjs +111 -0
  375. package/dist/tests/yahooCandles.test.d.ts +1 -0
  376. package/dist/tests/yahooCandles.test.js +105 -0
  377. package/dist/tools/finance/candleRange.cjs +71 -0
  378. package/dist/tools/finance/candleRange.d.ts +21 -0
  379. package/dist/tools/finance/candleRange.js +28 -0
  380. package/dist/tools/finance/optionsAnalytics.cjs +222 -0
  381. package/dist/tools/finance/optionsAnalytics.d.ts +44 -0
  382. package/dist/tools/finance/optionsAnalytics.js +188 -0
  383. package/dist/tools/finance/optionsAnalytics.test.cjs +128 -0
  384. package/dist/tools/finance/optionsAnalytics.test.d.ts +1 -0
  385. package/dist/tools/finance/optionsAnalytics.test.js +122 -0
  386. package/dist/tools/finance/technicalIndicators.cjs +111 -0
  387. package/dist/tools/finance/technicalIndicators.d.ts +15 -0
  388. package/dist/tools/finance/technicalIndicators.js +68 -0
  389. package/dist/tools/finance/yahooCandles.cjs +125 -0
  390. package/dist/tools/finance/yahooCandles.d.ts +41 -0
  391. package/dist/tools/finance/yahooCandles.js +85 -0
  392. package/dist/tools/mcp-finance.cjs +649 -0
  393. package/dist/tools/mcp-finance.d.ts +1 -0
  394. package/dist/tools/mcp-finance.js +631 -0
  395. package/dist/types/agents.cjs +18 -0
  396. package/dist/types/agents.d.ts +11 -0
  397. package/dist/types/agents.js +0 -0
  398. package/dist/types/hooks.cjs +18 -0
  399. package/dist/types/hooks.d.ts +82 -0
  400. package/dist/types/hooks.js +0 -0
  401. package/dist/types/mcp.cjs +86 -0
  402. package/dist/types/mcp.d.ts +107 -0
  403. package/dist/types/mcp.js +40 -0
  404. package/dist/types/voice.cjs +103 -0
  405. package/dist/types/voice.d.ts +117 -0
  406. package/dist/types/voice.js +51 -0
  407. package/dist/utils/attachments.cjs +46 -0
  408. package/dist/utils/attachments.d.ts +7 -0
  409. package/dist/utils/attachments.js +12 -0
  410. package/dist/voice/config.cjs +52 -0
  411. package/dist/voice/config.d.ts +8 -0
  412. package/dist/voice/config.js +18 -0
  413. package/dist/webui/assets/index-BA0HaStz.css +1 -0
  414. package/dist/webui/assets/index-NHgTZsWN.js +112 -0
  415. package/dist/webui/assets/wingman_icon-DOy91UEF.webp +0 -0
  416. package/dist/webui/assets/wingman_logo-Cogyt3qm.webp +0 -0
  417. package/dist/webui/index.html +19 -0
  418. package/package.json +130 -0
@@ -0,0 +1,248 @@
1
+ import { HTTPBridgeTransport, WebSocketTransport } from "./transport/index.js";
2
+ import { createLogger } from "../logger.js";
3
+ function _define_property(obj, key, value) {
4
+ if (key in obj) Object.defineProperty(obj, key, {
5
+ value: value,
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true
9
+ });
10
+ else obj[key] = value;
11
+ return obj;
12
+ }
13
+ class GatewayClient {
14
+ async connect() {
15
+ const transportType = this.selectTransport();
16
+ this.transport = this.createTransport(transportType);
17
+ this.transport.onMessage((message)=>{
18
+ this.handleMessage(message);
19
+ });
20
+ try {
21
+ await this.transport.connect();
22
+ this.reconnectAttempts = 0;
23
+ this.events.connected?.();
24
+ this.register();
25
+ } catch (error) {
26
+ this.logger.error("Transport connection failed", error);
27
+ throw error;
28
+ }
29
+ }
30
+ selectTransport() {
31
+ if ("auto" === this.transportType) {
32
+ if (this.url.startsWith("ws://") || this.url.startsWith("wss://")) return "websocket";
33
+ return "http";
34
+ }
35
+ return this.transportType;
36
+ }
37
+ createTransport(type) {
38
+ const transportOptions = {
39
+ token: this.token,
40
+ autoReconnect: true,
41
+ maxReconnectAttempts: this.maxReconnectAttempts,
42
+ reconnectDelay: this.reconnectDelay
43
+ };
44
+ if ("http" === type) return new HTTPBridgeTransport(this.url, transportOptions);
45
+ return new WebSocketTransport(this.url, transportOptions);
46
+ }
47
+ disconnect() {
48
+ if (this.pingInterval) {
49
+ clearInterval(this.pingInterval);
50
+ this.pingInterval = null;
51
+ }
52
+ if (this.transport) {
53
+ this.transport.disconnect();
54
+ this.transport = null;
55
+ }
56
+ if (this.ws) {
57
+ this.ws.close();
58
+ this.ws = null;
59
+ }
60
+ this.nodeId = null;
61
+ }
62
+ register() {
63
+ const payload = {
64
+ name: this.nodeName,
65
+ capabilities: this.capabilities,
66
+ token: this.token
67
+ };
68
+ this.send({
69
+ type: "register",
70
+ payload,
71
+ timestamp: Date.now()
72
+ });
73
+ }
74
+ async joinGroup(groupName, options = {}) {
75
+ const payload = {
76
+ groupName,
77
+ createIfNotExists: options.createIfNotExists ?? true,
78
+ description: options.description
79
+ };
80
+ this.send({
81
+ type: "join_group",
82
+ nodeId: this.nodeId || void 0,
83
+ payload,
84
+ timestamp: Date.now()
85
+ });
86
+ }
87
+ async leaveGroup(groupId) {
88
+ this.send({
89
+ type: "leave_group",
90
+ nodeId: this.nodeId || void 0,
91
+ groupId,
92
+ timestamp: Date.now()
93
+ });
94
+ }
95
+ broadcast(groupId, message) {
96
+ const payload = {
97
+ groupId,
98
+ message
99
+ };
100
+ this.send({
101
+ type: "broadcast",
102
+ nodeId: this.nodeId || void 0,
103
+ payload,
104
+ timestamp: Date.now()
105
+ });
106
+ }
107
+ sendDirect(targetNodeId, message) {
108
+ const payload = {
109
+ targetNodeId,
110
+ message
111
+ };
112
+ this.send({
113
+ type: "direct",
114
+ nodeId: this.nodeId || void 0,
115
+ payload,
116
+ timestamp: Date.now()
117
+ });
118
+ }
119
+ ping() {
120
+ this.send({
121
+ type: "ping",
122
+ nodeId: this.nodeId || void 0,
123
+ timestamp: Date.now()
124
+ });
125
+ }
126
+ handleMessage(msg) {
127
+ try {
128
+ switch(msg.type){
129
+ case "registered":
130
+ if ("nodeId" in msg && msg.nodeId) {
131
+ this.nodeId = msg.nodeId;
132
+ this.events.registered?.(msg.nodeId, this.nodeName);
133
+ this.startPingInterval();
134
+ }
135
+ break;
136
+ case "ack":
137
+ this.handleAck(msg);
138
+ break;
139
+ case "broadcast":
140
+ this.handleBroadcast(msg);
141
+ break;
142
+ case "direct":
143
+ this.handleDirect(msg);
144
+ break;
145
+ case "ping":
146
+ this.handlePing(msg);
147
+ break;
148
+ case "pong":
149
+ this.handlePong(msg);
150
+ break;
151
+ case "error":
152
+ this.handleError(msg);
153
+ break;
154
+ }
155
+ } catch (error) {
156
+ this.logger.error("Failed to handle message", error);
157
+ }
158
+ }
159
+ handleAck(msg) {
160
+ const payload = msg.payload;
161
+ if (payload.nodeId && !this.nodeId) {
162
+ this.nodeId = payload.nodeId;
163
+ this.events.registered?.(payload.nodeId, payload.name);
164
+ this.startPingInterval();
165
+ }
166
+ if (payload.groupId && payload.groupName) this.events.joinedGroup?.(payload.groupId, payload.groupName);
167
+ if (msg.groupId && !payload.groupName) this.events.leftGroup?.(msg.groupId);
168
+ }
169
+ handleBroadcast(msg) {
170
+ if (msg.nodeId && msg.groupId) this.events.broadcast?.(msg.payload, msg.nodeId, msg.groupId);
171
+ }
172
+ handleDirect(msg) {
173
+ if (msg.nodeId) this.events.direct?.(msg.payload, msg.nodeId);
174
+ }
175
+ handlePing(msg) {
176
+ this.send({
177
+ type: "pong",
178
+ nodeId: this.nodeId || void 0,
179
+ timestamp: Date.now()
180
+ });
181
+ this.events.ping?.();
182
+ }
183
+ handlePong(msg) {
184
+ this.events.pong?.();
185
+ }
186
+ handleError(msg) {
187
+ const error = msg.payload;
188
+ this.events.error?.(error);
189
+ this.logger.error(`Gateway error: ${error.code} - ${error.message}`);
190
+ }
191
+ handleDisconnect() {
192
+ if (this.pingInterval) {
193
+ clearInterval(this.pingInterval);
194
+ this.pingInterval = null;
195
+ }
196
+ this.events.disconnected?.();
197
+ if (this.reconnectAttempts < this.maxReconnectAttempts) {
198
+ this.reconnectAttempts++;
199
+ const delay = this.reconnectDelay * this.reconnectAttempts;
200
+ this.logger.info(`Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts})`);
201
+ setTimeout(()=>this.connect(), delay);
202
+ } else this.logger.error("Max reconnection attempts reached");
203
+ }
204
+ startPingInterval() {
205
+ if (this.pingInterval) clearInterval(this.pingInterval);
206
+ this.pingInterval = setInterval(()=>{
207
+ this.ping();
208
+ }, 30000);
209
+ }
210
+ send(message) {
211
+ if (this.transport && this.transport.isConnected()) return void this.transport.send(message);
212
+ if (this.ws && this.ws.readyState === WebSocket.OPEN) return void this.ws.send(JSON.stringify(message));
213
+ this.logger.error("No transport is connected");
214
+ }
215
+ getNodeId() {
216
+ return this.nodeId;
217
+ }
218
+ getNodeName() {
219
+ return this.nodeName;
220
+ }
221
+ isConnected() {
222
+ return null !== this.ws && this.ws.readyState === WebSocket.OPEN;
223
+ }
224
+ constructor(url, name, options = {}){
225
+ _define_property(this, "url", void 0);
226
+ _define_property(this, "transport", null);
227
+ _define_property(this, "nodeId", null);
228
+ _define_property(this, "nodeName", void 0);
229
+ _define_property(this, "token", void 0);
230
+ _define_property(this, "capabilities", void 0);
231
+ _define_property(this, "events", void 0);
232
+ _define_property(this, "reconnectAttempts", 0);
233
+ _define_property(this, "maxReconnectAttempts", 5);
234
+ _define_property(this, "reconnectDelay", 1000);
235
+ _define_property(this, "pingInterval", null);
236
+ _define_property(this, "transportType", void 0);
237
+ _define_property(this, "logger", void 0);
238
+ _define_property(this, "ws", null);
239
+ this.url = url;
240
+ this.nodeName = name;
241
+ this.token = options.token;
242
+ this.capabilities = options.capabilities;
243
+ this.events = options.events || {};
244
+ this.transportType = options.transport || "auto";
245
+ this.logger = createLogger();
246
+ }
247
+ }
248
+ export { GatewayClient };
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ GatewayDaemon: ()=>GatewayDaemon
28
+ });
29
+ const external_child_process_namespaceObject = require("child_process");
30
+ const external_fs_namespaceObject = require("fs");
31
+ const external_path_namespaceObject = require("path");
32
+ const external_os_namespaceObject = require("os");
33
+ const external_logger_cjs_namespaceObject = require("../logger.cjs");
34
+ function _define_property(obj, key, value) {
35
+ if (key in obj) Object.defineProperty(obj, key, {
36
+ value: value,
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true
40
+ });
41
+ else obj[key] = value;
42
+ return obj;
43
+ }
44
+ class GatewayDaemon {
45
+ resolveRuntime() {
46
+ const isBunRuntime = void 0 !== globalThis.Bun;
47
+ if (isBunRuntime) return process.execPath;
48
+ const probe = (0, external_child_process_namespaceObject.spawnSync)("bun", [
49
+ "--version"
50
+ ], {
51
+ stdio: "ignore"
52
+ });
53
+ if (probe.error || 0 !== probe.status) throw new Error("Bun runtime is required to start the gateway. Install Bun from https://bun.sh and retry.");
54
+ return "bun";
55
+ }
56
+ async start(config) {
57
+ if (this.isRunning()) throw new Error("Gateway is already running");
58
+ this.saveConfig(config);
59
+ const scriptPath = process.argv[1];
60
+ const runtime = this.resolveRuntime();
61
+ const child = (0, external_child_process_namespaceObject.spawn)(runtime, [
62
+ scriptPath,
63
+ "gateway",
64
+ "run",
65
+ "--daemon"
66
+ ], {
67
+ detached: true,
68
+ stdio: [
69
+ "ignore",
70
+ "pipe",
71
+ "pipe"
72
+ ],
73
+ env: {
74
+ ...process.env,
75
+ WINGMAN_GATEWAY_CONFIG: this.configFile
76
+ }
77
+ });
78
+ (0, external_fs_namespaceObject.writeFileSync)(this.pidFile, child.pid.toString());
79
+ child.stdout?.on("data", (data)=>{
80
+ (0, external_logger_cjs_namespaceObject.writeToLogFile)(data);
81
+ });
82
+ child.stderr?.on("data", (data)=>{
83
+ (0, external_logger_cjs_namespaceObject.writeToLogFile)(data);
84
+ });
85
+ child.unref();
86
+ console.log(`Gateway daemon started with PID ${child.pid}`);
87
+ console.log(`Logs: ${this.logFile}`);
88
+ }
89
+ async stop() {
90
+ if (!this.isRunning()) throw new Error("Gateway is not running");
91
+ const pid = this.getPid();
92
+ if (!pid) throw new Error("Could not read PID file");
93
+ try {
94
+ process.kill(pid, "SIGTERM");
95
+ await new Promise((resolve)=>setTimeout(resolve, 2000));
96
+ if (this.isProcessRunning(pid)) process.kill(pid, "SIGKILL");
97
+ this.removePidFile();
98
+ console.log("Gateway daemon stopped");
99
+ } catch (error) {
100
+ this.removePidFile();
101
+ throw error;
102
+ }
103
+ }
104
+ async restart() {
105
+ const config = this.loadConfig();
106
+ if (!config) throw new Error("No saved configuration found");
107
+ if (this.isRunning()) await this.stop();
108
+ await this.start(config);
109
+ }
110
+ getStatus() {
111
+ const running = this.isRunning();
112
+ const pid = this.getPid();
113
+ const config = this.loadConfig();
114
+ if (!running) return {
115
+ running: false
116
+ };
117
+ const uptime = pid ? this.getProcessUptime(pid) : void 0;
118
+ return {
119
+ running: true,
120
+ pid,
121
+ uptime,
122
+ config
123
+ };
124
+ }
125
+ isRunning() {
126
+ const pid = this.getPid();
127
+ if (!pid) return false;
128
+ return this.isProcessRunning(pid);
129
+ }
130
+ getPid() {
131
+ if (!(0, external_fs_namespaceObject.existsSync)(this.pidFile)) return;
132
+ try {
133
+ const pidStr = (0, external_fs_namespaceObject.readFileSync)(this.pidFile, "utf-8").trim();
134
+ return parseInt(pidStr, 10);
135
+ } catch (error) {
136
+ return;
137
+ }
138
+ }
139
+ isProcessRunning(pid) {
140
+ try {
141
+ process.kill(pid, 0);
142
+ return true;
143
+ } catch (error) {
144
+ return false;
145
+ }
146
+ }
147
+ getProcessUptime(pid) {
148
+ try {
149
+ const pidFileStats = (0, external_fs_namespaceObject.statSync)(this.pidFile);
150
+ return Date.now() - pidFileStats.mtimeMs;
151
+ } catch (error) {
152
+ return;
153
+ }
154
+ }
155
+ removePidFile() {
156
+ if ((0, external_fs_namespaceObject.existsSync)(this.pidFile)) (0, external_fs_namespaceObject.unlinkSync)(this.pidFile);
157
+ }
158
+ saveConfig(config) {
159
+ (0, external_fs_namespaceObject.writeFileSync)(this.configFile, JSON.stringify(config, null, 2));
160
+ }
161
+ loadConfig() {
162
+ if (!(0, external_fs_namespaceObject.existsSync)(this.configFile)) return;
163
+ try {
164
+ const configStr = (0, external_fs_namespaceObject.readFileSync)(this.configFile, "utf-8");
165
+ return JSON.parse(configStr);
166
+ } catch (error) {
167
+ return;
168
+ }
169
+ }
170
+ getLogFile() {
171
+ return this.logFile;
172
+ }
173
+ getPidFile() {
174
+ return this.pidFile;
175
+ }
176
+ getConfigFile() {
177
+ return this.configFile;
178
+ }
179
+ constructor(){
180
+ _define_property(this, "pidFile", void 0);
181
+ _define_property(this, "logFile", void 0);
182
+ _define_property(this, "configFile", void 0);
183
+ const wingmanDir = (0, external_path_namespaceObject.join)((0, external_os_namespaceObject.homedir)(), ".wingman");
184
+ this.pidFile = (0, external_path_namespaceObject.join)(wingmanDir, "gateway.pid");
185
+ this.logFile = (0, external_logger_cjs_namespaceObject.getLogFilePath)();
186
+ this.configFile = (0, external_path_namespaceObject.join)(wingmanDir, "gateway.json");
187
+ }
188
+ }
189
+ exports.GatewayDaemon = __webpack_exports__.GatewayDaemon;
190
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
191
+ "GatewayDaemon"
192
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
193
+ Object.defineProperty(exports, '__esModule', {
194
+ value: true
195
+ });
@@ -0,0 +1,67 @@
1
+ import type { GatewayConfig, DaemonStatus } from "./types.js";
2
+ /**
3
+ * Daemon manager for running the gateway in the background
4
+ */
5
+ export declare class GatewayDaemon {
6
+ private pidFile;
7
+ private logFile;
8
+ private configFile;
9
+ constructor();
10
+ private resolveRuntime;
11
+ /**
12
+ * Start the gateway as a daemon
13
+ */
14
+ start(config: GatewayConfig): Promise<void>;
15
+ /**
16
+ * Stop the gateway daemon
17
+ */
18
+ stop(): Promise<void>;
19
+ /**
20
+ * Restart the gateway daemon
21
+ */
22
+ restart(): Promise<void>;
23
+ /**
24
+ * Get the status of the gateway daemon
25
+ */
26
+ getStatus(): DaemonStatus;
27
+ /**
28
+ * Check if the gateway is running
29
+ */
30
+ isRunning(): boolean;
31
+ /**
32
+ * Get the PID from the PID file
33
+ */
34
+ private getPid;
35
+ /**
36
+ * Check if a process is running
37
+ */
38
+ private isProcessRunning;
39
+ /**
40
+ * Get process uptime in milliseconds
41
+ */
42
+ private getProcessUptime;
43
+ /**
44
+ * Remove the PID file
45
+ */
46
+ private removePidFile;
47
+ /**
48
+ * Save gateway configuration
49
+ */
50
+ private saveConfig;
51
+ /**
52
+ * Load gateway configuration
53
+ */
54
+ private loadConfig;
55
+ /**
56
+ * Get the log file path
57
+ */
58
+ getLogFile(): string;
59
+ /**
60
+ * Get the PID file path
61
+ */
62
+ getPidFile(): string;
63
+ /**
64
+ * Get the config file path
65
+ */
66
+ getConfigFile(): string;
67
+ }
@@ -0,0 +1,161 @@
1
+ import { spawn, spawnSync } from "child_process";
2
+ import { existsSync, readFileSync, statSync, unlinkSync, writeFileSync } from "fs";
3
+ import { join } from "path";
4
+ import { homedir } from "os";
5
+ import { getLogFilePath, writeToLogFile } from "../logger.js";
6
+ function _define_property(obj, key, value) {
7
+ if (key in obj) Object.defineProperty(obj, key, {
8
+ value: value,
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true
12
+ });
13
+ else obj[key] = value;
14
+ return obj;
15
+ }
16
+ class GatewayDaemon {
17
+ resolveRuntime() {
18
+ const isBunRuntime = void 0 !== globalThis.Bun;
19
+ if (isBunRuntime) return process.execPath;
20
+ const probe = spawnSync("bun", [
21
+ "--version"
22
+ ], {
23
+ stdio: "ignore"
24
+ });
25
+ if (probe.error || 0 !== probe.status) throw new Error("Bun runtime is required to start the gateway. Install Bun from https://bun.sh and retry.");
26
+ return "bun";
27
+ }
28
+ async start(config) {
29
+ if (this.isRunning()) throw new Error("Gateway is already running");
30
+ this.saveConfig(config);
31
+ const scriptPath = process.argv[1];
32
+ const runtime = this.resolveRuntime();
33
+ const child = spawn(runtime, [
34
+ scriptPath,
35
+ "gateway",
36
+ "run",
37
+ "--daemon"
38
+ ], {
39
+ detached: true,
40
+ stdio: [
41
+ "ignore",
42
+ "pipe",
43
+ "pipe"
44
+ ],
45
+ env: {
46
+ ...process.env,
47
+ WINGMAN_GATEWAY_CONFIG: this.configFile
48
+ }
49
+ });
50
+ writeFileSync(this.pidFile, child.pid.toString());
51
+ child.stdout?.on("data", (data)=>{
52
+ writeToLogFile(data);
53
+ });
54
+ child.stderr?.on("data", (data)=>{
55
+ writeToLogFile(data);
56
+ });
57
+ child.unref();
58
+ console.log(`Gateway daemon started with PID ${child.pid}`);
59
+ console.log(`Logs: ${this.logFile}`);
60
+ }
61
+ async stop() {
62
+ if (!this.isRunning()) throw new Error("Gateway is not running");
63
+ const pid = this.getPid();
64
+ if (!pid) throw new Error("Could not read PID file");
65
+ try {
66
+ process.kill(pid, "SIGTERM");
67
+ await new Promise((resolve)=>setTimeout(resolve, 2000));
68
+ if (this.isProcessRunning(pid)) process.kill(pid, "SIGKILL");
69
+ this.removePidFile();
70
+ console.log("Gateway daemon stopped");
71
+ } catch (error) {
72
+ this.removePidFile();
73
+ throw error;
74
+ }
75
+ }
76
+ async restart() {
77
+ const config = this.loadConfig();
78
+ if (!config) throw new Error("No saved configuration found");
79
+ if (this.isRunning()) await this.stop();
80
+ await this.start(config);
81
+ }
82
+ getStatus() {
83
+ const running = this.isRunning();
84
+ const pid = this.getPid();
85
+ const config = this.loadConfig();
86
+ if (!running) return {
87
+ running: false
88
+ };
89
+ const uptime = pid ? this.getProcessUptime(pid) : void 0;
90
+ return {
91
+ running: true,
92
+ pid,
93
+ uptime,
94
+ config
95
+ };
96
+ }
97
+ isRunning() {
98
+ const pid = this.getPid();
99
+ if (!pid) return false;
100
+ return this.isProcessRunning(pid);
101
+ }
102
+ getPid() {
103
+ if (!existsSync(this.pidFile)) return;
104
+ try {
105
+ const pidStr = readFileSync(this.pidFile, "utf-8").trim();
106
+ return parseInt(pidStr, 10);
107
+ } catch (error) {
108
+ return;
109
+ }
110
+ }
111
+ isProcessRunning(pid) {
112
+ try {
113
+ process.kill(pid, 0);
114
+ return true;
115
+ } catch (error) {
116
+ return false;
117
+ }
118
+ }
119
+ getProcessUptime(pid) {
120
+ try {
121
+ const pidFileStats = statSync(this.pidFile);
122
+ return Date.now() - pidFileStats.mtimeMs;
123
+ } catch (error) {
124
+ return;
125
+ }
126
+ }
127
+ removePidFile() {
128
+ if (existsSync(this.pidFile)) unlinkSync(this.pidFile);
129
+ }
130
+ saveConfig(config) {
131
+ writeFileSync(this.configFile, JSON.stringify(config, null, 2));
132
+ }
133
+ loadConfig() {
134
+ if (!existsSync(this.configFile)) return;
135
+ try {
136
+ const configStr = readFileSync(this.configFile, "utf-8");
137
+ return JSON.parse(configStr);
138
+ } catch (error) {
139
+ return;
140
+ }
141
+ }
142
+ getLogFile() {
143
+ return this.logFile;
144
+ }
145
+ getPidFile() {
146
+ return this.pidFile;
147
+ }
148
+ getConfigFile() {
149
+ return this.configFile;
150
+ }
151
+ constructor(){
152
+ _define_property(this, "pidFile", void 0);
153
+ _define_property(this, "logFile", void 0);
154
+ _define_property(this, "configFile", void 0);
155
+ const wingmanDir = join(homedir(), ".wingman");
156
+ this.pidFile = join(wingmanDir, "gateway.pid");
157
+ this.logFile = getLogFilePath();
158
+ this.configFile = join(wingmanDir, "gateway.json");
159
+ }
160
+ }
161
+ export { GatewayDaemon };