@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.
- package/.wingman/agents/README.md +161 -0
- package/.wingman/agents/coding/agent.md +147 -0
- package/.wingman/agents/coding/implementor.md +56 -0
- package/.wingman/agents/main/agent.md +19 -0
- package/.wingman/agents/researcher/agent.md +62 -0
- package/.wingman/agents/stock-trader/agent.md +223 -0
- package/.wingman/agents/stock-trader/chain-curator.md +24 -0
- package/.wingman/agents/stock-trader/goal-translator.md +42 -0
- package/.wingman/agents/stock-trader/guardrails-veto.md +11 -0
- package/.wingman/agents/stock-trader/path-planner.md +23 -0
- package/.wingman/agents/stock-trader/regime-analyst.md +15 -0
- package/.wingman/agents/stock-trader/risk.md +20 -0
- package/.wingman/agents/stock-trader/selection.md +22 -0
- package/.wingman/agents/stock-trader/strategy-composer.md +38 -0
- package/.wingman/agents/wingman/agent.json +12 -0
- package/bin/wingman +7 -0
- package/dist/agent/config/agentConfig.cjs +95 -0
- package/dist/agent/config/agentConfig.d.ts +187 -0
- package/dist/agent/config/agentConfig.js +52 -0
- package/dist/agent/config/agentLoader.cjs +242 -0
- package/dist/agent/config/agentLoader.d.ts +42 -0
- package/dist/agent/config/agentLoader.js +208 -0
- package/dist/agent/config/mcpClientManager.cjs +168 -0
- package/dist/agent/config/mcpClientManager.d.ts +41 -0
- package/dist/agent/config/mcpClientManager.js +134 -0
- package/dist/agent/config/modelFactory.cjs +175 -0
- package/dist/agent/config/modelFactory.d.ts +33 -0
- package/dist/agent/config/modelFactory.js +141 -0
- package/dist/agent/config/toolRegistry.cjs +111 -0
- package/dist/agent/config/toolRegistry.d.ts +25 -0
- package/dist/agent/config/toolRegistry.js +71 -0
- package/dist/agent/middleware/additional-messages.cjs +60 -0
- package/dist/agent/middleware/additional-messages.d.ts +7 -0
- package/dist/agent/middleware/additional-messages.js +26 -0
- package/dist/agent/middleware/hooks/executor.cjs +137 -0
- package/dist/agent/middleware/hooks/executor.d.ts +52 -0
- package/dist/agent/middleware/hooks/executor.js +103 -0
- package/dist/agent/middleware/hooks/input-builder.cjs +55 -0
- package/dist/agent/middleware/hooks/input-builder.d.ts +15 -0
- package/dist/agent/middleware/hooks/input-builder.js +21 -0
- package/dist/agent/middleware/hooks/matcher.cjs +59 -0
- package/dist/agent/middleware/hooks/matcher.d.ts +27 -0
- package/dist/agent/middleware/hooks/matcher.js +22 -0
- package/dist/agent/middleware/hooks/merger.cjs +54 -0
- package/dist/agent/middleware/hooks/merger.d.ts +18 -0
- package/dist/agent/middleware/hooks/merger.js +20 -0
- package/dist/agent/middleware/hooks/types.cjs +62 -0
- package/dist/agent/middleware/hooks/types.d.ts +82 -0
- package/dist/agent/middleware/hooks/types.js +19 -0
- package/dist/agent/middleware/hooks.cjs +79 -0
- package/dist/agent/middleware/hooks.d.ts +19 -0
- package/dist/agent/middleware/hooks.js +45 -0
- package/dist/agent/middleware/media-compat.cjs +80 -0
- package/dist/agent/middleware/media-compat.d.ts +7 -0
- package/dist/agent/middleware/media-compat.js +46 -0
- package/dist/agent/tests/agentConfig.test.cjs +132 -0
- package/dist/agent/tests/agentConfig.test.d.ts +1 -0
- package/dist/agent/tests/agentConfig.test.js +126 -0
- package/dist/agent/tests/agentLoader.test.cjs +235 -0
- package/dist/agent/tests/agentLoader.test.d.ts +1 -0
- package/dist/agent/tests/agentLoader.test.js +229 -0
- package/dist/agent/tests/modelFactory.test.cjs +114 -0
- package/dist/agent/tests/modelFactory.test.d.ts +1 -0
- package/dist/agent/tests/modelFactory.test.js +108 -0
- package/dist/agent/tests/test-agent-loader.cjs +33 -0
- package/dist/agent/tests/test-agent-loader.d.ts +1 -0
- package/dist/agent/tests/test-agent-loader.js +27 -0
- package/dist/agent/tests/test-subagent-loading.cjs +99 -0
- package/dist/agent/tests/test-subagent-loading.d.ts +1 -0
- package/dist/agent/tests/test-subagent-loading.js +93 -0
- package/dist/agent/tests/toolRegistry.test.cjs +109 -0
- package/dist/agent/tests/toolRegistry.test.d.ts +1 -0
- package/dist/agent/tests/toolRegistry.test.js +103 -0
- package/dist/agent/tools/code_search.cjs +108 -0
- package/dist/agent/tools/code_search.d.ts +24 -0
- package/dist/agent/tools/code_search.js +74 -0
- package/dist/agent/tools/command_execute.cjs +136 -0
- package/dist/agent/tools/command_execute.d.ts +12 -0
- package/dist/agent/tools/command_execute.js +99 -0
- package/dist/agent/tools/git_status.cjs +126 -0
- package/dist/agent/tools/git_status.d.ts +15 -0
- package/dist/agent/tools/git_status.js +92 -0
- package/dist/agent/tools/internet_search.cjs +93 -0
- package/dist/agent/tools/internet_search.d.ts +25 -0
- package/dist/agent/tools/internet_search.js +56 -0
- package/dist/agent/tools/think.cjs +53 -0
- package/dist/agent/tools/think.d.ts +26 -0
- package/dist/agent/tools/think.js +16 -0
- package/dist/agent/tools/web_crawler.cjs +180 -0
- package/dist/agent/tools/web_crawler.d.ts +31 -0
- package/dist/agent/tools/web_crawler.js +143 -0
- package/dist/agent/utils.cjs +54 -0
- package/dist/agent/utils.d.ts +1 -0
- package/dist/agent/utils.js +10 -0
- package/dist/cli/commands/agent.cjs +169 -0
- package/dist/cli/commands/agent.d.ts +15 -0
- package/dist/cli/commands/agent.js +125 -0
- package/dist/cli/commands/gateway.cjs +601 -0
- package/dist/cli/commands/gateway.d.ts +12 -0
- package/dist/cli/commands/gateway.js +567 -0
- package/dist/cli/commands/init.cjs +681 -0
- package/dist/cli/commands/init.d.ts +10 -0
- package/dist/cli/commands/init.js +634 -0
- package/dist/cli/commands/provider.cjs +208 -0
- package/dist/cli/commands/provider.d.ts +5 -0
- package/dist/cli/commands/provider.js +174 -0
- package/dist/cli/commands/skill.cjs +145 -0
- package/dist/cli/commands/skill.d.ts +10 -0
- package/dist/cli/commands/skill.js +111 -0
- package/dist/cli/config/loader.cjs +143 -0
- package/dist/cli/config/loader.d.ts +14 -0
- package/dist/cli/config/loader.js +109 -0
- package/dist/cli/config/schema.cjs +262 -0
- package/dist/cli/config/schema.d.ts +268 -0
- package/dist/cli/config/schema.js +213 -0
- package/dist/cli/core/agentInvoker.cjs +284 -0
- package/dist/cli/core/agentInvoker.d.ts +77 -0
- package/dist/cli/core/agentInvoker.js +247 -0
- package/dist/cli/core/commandHandler.cjs +257 -0
- package/dist/cli/core/commandHandler.d.ts +62 -0
- package/dist/cli/core/commandHandler.js +223 -0
- package/dist/cli/core/database/bunSqliteAdapter.cjs +87 -0
- package/dist/cli/core/database/bunSqliteAdapter.d.ts +34 -0
- package/dist/cli/core/database/bunSqliteAdapter.js +53 -0
- package/dist/cli/core/loggerBridge.cjs +42 -0
- package/dist/cli/core/loggerBridge.d.ts +8 -0
- package/dist/cli/core/loggerBridge.js +8 -0
- package/dist/cli/core/outputManager.cjs +106 -0
- package/dist/cli/core/outputManager.d.ts +43 -0
- package/dist/cli/core/outputManager.js +72 -0
- package/dist/cli/core/sessionManager.cjs +535 -0
- package/dist/cli/core/sessionManager.d.ts +111 -0
- package/dist/cli/core/sessionManager.js +486 -0
- package/dist/cli/core/streamParser.cjs +328 -0
- package/dist/cli/core/streamParser.d.ts +42 -0
- package/dist/cli/core/streamParser.js +288 -0
- package/dist/cli/index.cjs +211 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +205 -0
- package/dist/cli/services/skillRepository.cjs +178 -0
- package/dist/cli/services/skillRepository.d.ts +35 -0
- package/dist/cli/services/skillRepository.js +144 -0
- package/dist/cli/services/skillService.cjs +336 -0
- package/dist/cli/services/skillService.d.ts +48 -0
- package/dist/cli/services/skillService.js +302 -0
- package/dist/cli/types/gateway.cjs +18 -0
- package/dist/cli/types/gateway.d.ts +18 -0
- package/dist/cli/types/gateway.js +0 -0
- package/dist/cli/types/init.cjs +18 -0
- package/dist/cli/types/init.d.ts +13 -0
- package/dist/cli/types/init.js +0 -0
- package/dist/cli/types/provider.cjs +18 -0
- package/dist/cli/types/provider.d.ts +9 -0
- package/dist/cli/types/provider.js +0 -0
- package/dist/cli/types/skill.cjs +18 -0
- package/dist/cli/types/skill.d.ts +71 -0
- package/dist/cli/types/skill.js +0 -0
- package/dist/cli/types.cjs +18 -0
- package/dist/cli/types.d.ts +175 -0
- package/dist/cli/types.js +0 -0
- package/dist/cli/ui/AgentOutput.cjs +82 -0
- package/dist/cli/ui/AgentOutput.d.ts +8 -0
- package/dist/cli/ui/AgentOutput.js +38 -0
- package/dist/cli/ui/App.cjs +285 -0
- package/dist/cli/ui/App.d.ts +6 -0
- package/dist/cli/ui/App.js +241 -0
- package/dist/cli/ui/ErrorDisplay.cjs +65 -0
- package/dist/cli/ui/ErrorDisplay.d.ts +8 -0
- package/dist/cli/ui/ErrorDisplay.js +21 -0
- package/dist/cli/ui/LogDisplay.cjs +74 -0
- package/dist/cli/ui/LogDisplay.d.ts +13 -0
- package/dist/cli/ui/LogDisplay.js +30 -0
- package/dist/cli/ui/SessionListDisplay.cjs +135 -0
- package/dist/cli/ui/SessionListDisplay.d.ts +9 -0
- package/dist/cli/ui/SessionListDisplay.js +91 -0
- package/dist/cli/ui/blockHelpers.cjs +80 -0
- package/dist/cli/ui/blockHelpers.d.ts +21 -0
- package/dist/cli/ui/blockHelpers.js +40 -0
- package/dist/cli/ui/components/ToolCallDisplay.cjs +207 -0
- package/dist/cli/ui/components/ToolCallDisplay.d.ts +7 -0
- package/dist/cli/ui/components/ToolCallDisplay.js +162 -0
- package/dist/cli/ui/components/ToolResultDisplay.cjs +86 -0
- package/dist/cli/ui/components/ToolResultDisplay.d.ts +8 -0
- package/dist/cli/ui/components/ToolResultDisplay.js +42 -0
- package/dist/cli/ui/toolDisplayHelpers.cjs +112 -0
- package/dist/cli/ui/toolDisplayHelpers.d.ts +3 -0
- package/dist/cli/ui/toolDisplayHelpers.js +72 -0
- package/dist/gateway/adapters/discord.cjs +298 -0
- package/dist/gateway/adapters/discord.d.ts +42 -0
- package/dist/gateway/adapters/discord.js +246 -0
- package/dist/gateway/auth.cjs +94 -0
- package/dist/gateway/auth.d.ts +36 -0
- package/dist/gateway/auth.js +60 -0
- package/dist/gateway/broadcast.cjs +131 -0
- package/dist/gateway/broadcast.d.ts +76 -0
- package/dist/gateway/broadcast.js +97 -0
- package/dist/gateway/client.cjs +282 -0
- package/dist/gateway/client.d.ts +141 -0
- package/dist/gateway/client.js +248 -0
- package/dist/gateway/daemon.cjs +195 -0
- package/dist/gateway/daemon.d.ts +67 -0
- package/dist/gateway/daemon.js +161 -0
- package/dist/gateway/discovery/index.cjs +72 -0
- package/dist/gateway/discovery/index.d.ts +3 -0
- package/dist/gateway/discovery/index.js +3 -0
- package/dist/gateway/discovery/mdns.cjs +221 -0
- package/dist/gateway/discovery/mdns.d.ts +37 -0
- package/dist/gateway/discovery/mdns.js +177 -0
- package/dist/gateway/discovery/tailscale.cjs +140 -0
- package/dist/gateway/discovery/tailscale.d.ts +31 -0
- package/dist/gateway/discovery/tailscale.js +106 -0
- package/dist/gateway/discovery/types.cjs +18 -0
- package/dist/gateway/discovery/types.d.ts +41 -0
- package/dist/gateway/discovery/types.js +0 -0
- package/dist/gateway/env.cjs +45 -0
- package/dist/gateway/env.d.ts +2 -0
- package/dist/gateway/env.js +8 -0
- package/dist/gateway/hooks/loader.cjs +137 -0
- package/dist/gateway/hooks/loader.d.ts +10 -0
- package/dist/gateway/hooks/loader.js +103 -0
- package/dist/gateway/hooks/registry.cjs +128 -0
- package/dist/gateway/hooks/registry.d.ts +13 -0
- package/dist/gateway/hooks/registry.js +94 -0
- package/dist/gateway/hooks/types.cjs +58 -0
- package/dist/gateway/hooks/types.d.ts +50 -0
- package/dist/gateway/hooks/types.js +18 -0
- package/dist/gateway/http/agents.cjs +280 -0
- package/dist/gateway/http/agents.d.ts +2 -0
- package/dist/gateway/http/agents.js +246 -0
- package/dist/gateway/http/fs.cjs +81 -0
- package/dist/gateway/http/fs.d.ts +2 -0
- package/dist/gateway/http/fs.js +47 -0
- package/dist/gateway/http/providers.cjs +120 -0
- package/dist/gateway/http/providers.d.ts +2 -0
- package/dist/gateway/http/providers.js +86 -0
- package/dist/gateway/http/routines.cjs +196 -0
- package/dist/gateway/http/routines.d.ts +20 -0
- package/dist/gateway/http/routines.js +159 -0
- package/dist/gateway/http/sessions.cjs +241 -0
- package/dist/gateway/http/sessions.d.ts +2 -0
- package/dist/gateway/http/sessions.js +207 -0
- package/dist/gateway/http/types.cjs +18 -0
- package/dist/gateway/http/types.d.ts +25 -0
- package/dist/gateway/http/types.js +0 -0
- package/dist/gateway/http/voice.cjs +167 -0
- package/dist/gateway/http/voice.d.ts +2 -0
- package/dist/gateway/http/voice.js +133 -0
- package/dist/gateway/http/webhooks.cjs +353 -0
- package/dist/gateway/http/webhooks.d.ts +22 -0
- package/dist/gateway/http/webhooks.js +313 -0
- package/dist/gateway/index.cjs +119 -0
- package/dist/gateway/index.d.ts +8 -0
- package/dist/gateway/index.js +9 -0
- package/dist/gateway/node.cjs +218 -0
- package/dist/gateway/node.d.ts +112 -0
- package/dist/gateway/node.js +184 -0
- package/dist/gateway/router.cjs +85 -0
- package/dist/gateway/router.d.ts +9 -0
- package/dist/gateway/router.js +51 -0
- package/dist/gateway/rpcClient.cjs +152 -0
- package/dist/gateway/rpcClient.d.ts +24 -0
- package/dist/gateway/rpcClient.js +118 -0
- package/dist/gateway/server.cjs +1175 -0
- package/dist/gateway/server.d.ts +185 -0
- package/dist/gateway/server.js +1138 -0
- package/dist/gateway/transport/http.cjs +153 -0
- package/dist/gateway/transport/http.d.ts +25 -0
- package/dist/gateway/transport/http.js +119 -0
- package/dist/gateway/transport/index.cjs +40 -0
- package/dist/gateway/transport/index.d.ts +3 -0
- package/dist/gateway/transport/index.js +3 -0
- package/dist/gateway/transport/types.cjs +18 -0
- package/dist/gateway/transport/types.d.ts +59 -0
- package/dist/gateway/transport/types.js +0 -0
- package/dist/gateway/transport/websocket.cjs +132 -0
- package/dist/gateway/transport/websocket.d.ts +21 -0
- package/dist/gateway/transport/websocket.js +98 -0
- package/dist/gateway/types.cjs +18 -0
- package/dist/gateway/types.d.ts +215 -0
- package/dist/gateway/types.js +0 -0
- package/dist/gateway/validation.cjs +225 -0
- package/dist/gateway/validation.d.ts +157 -0
- package/dist/gateway/validation.js +158 -0
- package/dist/index.cjs +95 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/logger.cjs +270 -0
- package/dist/logger.d.ts +54 -0
- package/dist/logger.js +215 -0
- package/dist/providers/copilot.cjs +148 -0
- package/dist/providers/copilot.d.ts +3 -0
- package/dist/providers/copilot.js +114 -0
- package/dist/providers/credentials.cjs +154 -0
- package/dist/providers/credentials.d.ts +26 -0
- package/dist/providers/credentials.js +99 -0
- package/dist/providers/oauth.cjs +279 -0
- package/dist/providers/oauth.d.ts +13 -0
- package/dist/providers/oauth.js +245 -0
- package/dist/providers/registry.cjs +138 -0
- package/dist/providers/registry.d.ts +32 -0
- package/dist/providers/registry.js +98 -0
- package/dist/tests/additionalMessageMiddleware.test.cjs +45 -0
- package/dist/tests/additionalMessageMiddleware.test.d.ts +1 -0
- package/dist/tests/additionalMessageMiddleware.test.js +39 -0
- package/dist/tests/agent-config-voice.test.cjs +25 -0
- package/dist/tests/agent-config-voice.test.d.ts +1 -0
- package/dist/tests/agent-config-voice.test.js +19 -0
- package/dist/tests/agentInvokerAttachments.test.cjs +67 -0
- package/dist/tests/agentInvokerAttachments.test.d.ts +1 -0
- package/dist/tests/agentInvokerAttachments.test.js +61 -0
- package/dist/tests/attachments-utils.test.cjs +46 -0
- package/dist/tests/attachments-utils.test.d.ts +1 -0
- package/dist/tests/attachments-utils.test.js +40 -0
- package/dist/tests/bunSqliteAdapter.test.cjs +265 -0
- package/dist/tests/bunSqliteAdapter.test.d.ts +1 -0
- package/dist/tests/bunSqliteAdapter.test.js +259 -0
- package/dist/tests/candleRange.test.cjs +48 -0
- package/dist/tests/candleRange.test.d.ts +1 -0
- package/dist/tests/candleRange.test.js +42 -0
- package/dist/tests/cli-config-loader.test.cjs +364 -0
- package/dist/tests/cli-config-loader.test.d.ts +1 -0
- package/dist/tests/cli-config-loader.test.js +358 -0
- package/dist/tests/cli-init.test.cjs +82 -0
- package/dist/tests/cli-init.test.d.ts +1 -0
- package/dist/tests/cli-init.test.js +76 -0
- package/dist/tests/discord-adapter.test.cjs +55 -0
- package/dist/tests/discord-adapter.test.d.ts +1 -0
- package/dist/tests/discord-adapter.test.js +49 -0
- package/dist/tests/gateway.test.cjs +319 -0
- package/dist/tests/gateway.test.d.ts +1 -0
- package/dist/tests/gateway.test.js +313 -0
- package/dist/tests/hooks-matcher.test.cjs +309 -0
- package/dist/tests/hooks-matcher.test.d.ts +1 -0
- package/dist/tests/hooks-matcher.test.js +303 -0
- package/dist/tests/hooks-merger.test.cjs +528 -0
- package/dist/tests/hooks-merger.test.d.ts +1 -0
- package/dist/tests/hooks-merger.test.js +522 -0
- package/dist/tests/integration/agent-invocation.integration.test.cjs +264 -0
- package/dist/tests/integration/agent-invocation.integration.test.d.ts +1 -0
- package/dist/tests/integration/agent-invocation.integration.test.js +258 -0
- package/dist/tests/integration/finnhub-candles.integration.test.cjs +98 -0
- package/dist/tests/integration/finnhub-candles.integration.test.d.ts +1 -0
- package/dist/tests/integration/finnhub-candles.integration.test.js +92 -0
- package/dist/tests/logger.test.cjs +353 -0
- package/dist/tests/logger.test.d.ts +1 -0
- package/dist/tests/logger.test.js +347 -0
- package/dist/tests/mediaCompatibilityMiddleware.test.cjs +106 -0
- package/dist/tests/mediaCompatibilityMiddleware.test.d.ts +1 -0
- package/dist/tests/mediaCompatibilityMiddleware.test.js +100 -0
- package/dist/tests/routines-api.test.cjs +107 -0
- package/dist/tests/routines-api.test.d.ts +1 -0
- package/dist/tests/routines-api.test.js +101 -0
- package/dist/tests/sessionMessageAttachments.test.cjs +108 -0
- package/dist/tests/sessionMessageAttachments.test.d.ts +1 -0
- package/dist/tests/sessionMessageAttachments.test.js +102 -0
- package/dist/tests/sessionMessageRole.test.cjs +44 -0
- package/dist/tests/sessionMessageRole.test.d.ts +1 -0
- package/dist/tests/sessionMessageRole.test.js +38 -0
- package/dist/tests/sessionStateMessages.test.cjs +72 -0
- package/dist/tests/sessionStateMessages.test.d.ts +1 -0
- package/dist/tests/sessionStateMessages.test.js +66 -0
- package/dist/tests/sessions-api.test.cjs +68 -0
- package/dist/tests/sessions-api.test.d.ts +1 -0
- package/dist/tests/sessions-api.test.js +62 -0
- package/dist/tests/technicalIndicators.test.cjs +82 -0
- package/dist/tests/technicalIndicators.test.d.ts +1 -0
- package/dist/tests/technicalIndicators.test.js +76 -0
- package/dist/tests/toolDisplayHelpers.test.cjs +43 -0
- package/dist/tests/toolDisplayHelpers.test.d.ts +1 -0
- package/dist/tests/toolDisplayHelpers.test.js +37 -0
- package/dist/tests/voice-config.test.cjs +35 -0
- package/dist/tests/voice-config.test.d.ts +1 -0
- package/dist/tests/voice-config.test.js +29 -0
- package/dist/tests/yahooCandles.test.cjs +111 -0
- package/dist/tests/yahooCandles.test.d.ts +1 -0
- package/dist/tests/yahooCandles.test.js +105 -0
- package/dist/tools/finance/candleRange.cjs +71 -0
- package/dist/tools/finance/candleRange.d.ts +21 -0
- package/dist/tools/finance/candleRange.js +28 -0
- package/dist/tools/finance/optionsAnalytics.cjs +222 -0
- package/dist/tools/finance/optionsAnalytics.d.ts +44 -0
- package/dist/tools/finance/optionsAnalytics.js +188 -0
- package/dist/tools/finance/optionsAnalytics.test.cjs +128 -0
- package/dist/tools/finance/optionsAnalytics.test.d.ts +1 -0
- package/dist/tools/finance/optionsAnalytics.test.js +122 -0
- package/dist/tools/finance/technicalIndicators.cjs +111 -0
- package/dist/tools/finance/technicalIndicators.d.ts +15 -0
- package/dist/tools/finance/technicalIndicators.js +68 -0
- package/dist/tools/finance/yahooCandles.cjs +125 -0
- package/dist/tools/finance/yahooCandles.d.ts +41 -0
- package/dist/tools/finance/yahooCandles.js +85 -0
- package/dist/tools/mcp-finance.cjs +649 -0
- package/dist/tools/mcp-finance.d.ts +1 -0
- package/dist/tools/mcp-finance.js +631 -0
- package/dist/types/agents.cjs +18 -0
- package/dist/types/agents.d.ts +11 -0
- package/dist/types/agents.js +0 -0
- package/dist/types/hooks.cjs +18 -0
- package/dist/types/hooks.d.ts +82 -0
- package/dist/types/hooks.js +0 -0
- package/dist/types/mcp.cjs +86 -0
- package/dist/types/mcp.d.ts +107 -0
- package/dist/types/mcp.js +40 -0
- package/dist/types/voice.cjs +103 -0
- package/dist/types/voice.d.ts +117 -0
- package/dist/types/voice.js +51 -0
- package/dist/utils/attachments.cjs +46 -0
- package/dist/utils/attachments.d.ts +7 -0
- package/dist/utils/attachments.js +12 -0
- package/dist/voice/config.cjs +52 -0
- package/dist/voice/config.d.ts +8 -0
- package/dist/voice/config.js +18 -0
- package/dist/webui/assets/index-BA0HaStz.css +1 -0
- package/dist/webui/assets/index-NHgTZsWN.js +112 -0
- package/dist/webui/assets/wingman_icon-DOy91UEF.webp +0 -0
- package/dist/webui/assets/wingman_logo-Cogyt3qm.webp +0 -0
- package/dist/webui/index.html +19 -0
- package/package.json +130 -0
|
@@ -0,0 +1,328 @@
|
|
|
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
|
+
processStreamChunk: ()=>processStreamChunk,
|
|
28
|
+
formatParsedChunk: ()=>formatParsedChunk,
|
|
29
|
+
parseStreamChunk: ()=>parseStreamChunk
|
|
30
|
+
});
|
|
31
|
+
const external_uuid_namespaceObject = require("uuid");
|
|
32
|
+
function parseStreamChunk(chunk) {
|
|
33
|
+
if (!chunk || "object" != typeof chunk) return [];
|
|
34
|
+
const tokenChunk = parseStreamEventChunk(chunk);
|
|
35
|
+
if (tokenChunk) return [
|
|
36
|
+
tokenChunk
|
|
37
|
+
];
|
|
38
|
+
const messageEntries = normalizeMessagesFromChunk(chunk);
|
|
39
|
+
const results = [];
|
|
40
|
+
if (messageEntries.length > 0) for (const entry of messageEntries){
|
|
41
|
+
const msg = entry.message;
|
|
42
|
+
const messageType = getMessageType(msg);
|
|
43
|
+
const normalizedType = messageType ? messageType.toLowerCase() : "";
|
|
44
|
+
const isAIMessage = isAIMessageType(normalizedType);
|
|
45
|
+
const isToolMessage = isToolMessageType(normalizedType);
|
|
46
|
+
const messageId = isAIMessage ? getMessageId(msg, entry) : void 0;
|
|
47
|
+
if (isAIMessage) {
|
|
48
|
+
const toolCalls = extractToolCalls(msg, messageId);
|
|
49
|
+
if (toolCalls.length > 0) for (const toolCall of toolCalls)results.push({
|
|
50
|
+
messageId,
|
|
51
|
+
toolCall: toolCall,
|
|
52
|
+
type: "tool",
|
|
53
|
+
timestamp: Date.now()
|
|
54
|
+
});
|
|
55
|
+
const text = extractTextContent(msg);
|
|
56
|
+
if (text) results.push({
|
|
57
|
+
messageId,
|
|
58
|
+
text,
|
|
59
|
+
isDelta: isMessageDelta(msg, normalizedType),
|
|
60
|
+
type: "text",
|
|
61
|
+
timestamp: Date.now()
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (isToolMessage) {
|
|
65
|
+
const toolResult = extractToolResult(msg);
|
|
66
|
+
if (toolResult) results.push({
|
|
67
|
+
toolResult,
|
|
68
|
+
type: "tool-result",
|
|
69
|
+
timestamp: Date.now()
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (results.length > 0) return results;
|
|
74
|
+
if (chunk.content) {
|
|
75
|
+
if ("string" == typeof chunk.content) return [
|
|
76
|
+
{
|
|
77
|
+
text: chunk.content,
|
|
78
|
+
type: "text",
|
|
79
|
+
timestamp: Date.now()
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
if (chunk.tool_calls && Array.isArray(chunk.tool_calls)) {
|
|
84
|
+
const toolResults = [];
|
|
85
|
+
for (const toolCall of chunk.tool_calls){
|
|
86
|
+
const normalized = normalizeToolCall(toolCall);
|
|
87
|
+
if (normalized) toolResults.push({
|
|
88
|
+
toolCall: normalized,
|
|
89
|
+
type: "tool",
|
|
90
|
+
timestamp: Date.now()
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (toolResults.length > 0) return toolResults;
|
|
94
|
+
}
|
|
95
|
+
chunk.next || chunk.metadata;
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
function parseStreamEventChunk(chunk) {
|
|
99
|
+
if (!chunk || "object" != typeof chunk) return null;
|
|
100
|
+
if ("string" != typeof chunk.event) return null;
|
|
101
|
+
if ("on_chat_model_stream" === chunk.event) {
|
|
102
|
+
const messageChunk = chunk.data?.chunk ?? chunk.data?.message;
|
|
103
|
+
const text = extractTextContent(messageChunk);
|
|
104
|
+
if (!text) return null;
|
|
105
|
+
return {
|
|
106
|
+
messageId: "string" == typeof chunk.run_id ? chunk.run_id : void 0,
|
|
107
|
+
text,
|
|
108
|
+
isDelta: true,
|
|
109
|
+
type: "text",
|
|
110
|
+
timestamp: Date.now()
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if ("on_llm_stream" === chunk.event) {
|
|
114
|
+
const llmChunk = chunk.data?.chunk;
|
|
115
|
+
let text;
|
|
116
|
+
if ("string" == typeof llmChunk) text = llmChunk;
|
|
117
|
+
else if ("string" == typeof llmChunk?.text) text = llmChunk.text;
|
|
118
|
+
if (!text) return null;
|
|
119
|
+
return {
|
|
120
|
+
messageId: "string" == typeof chunk.run_id ? chunk.run_id : void 0,
|
|
121
|
+
text,
|
|
122
|
+
isDelta: true,
|
|
123
|
+
type: "text",
|
|
124
|
+
timestamp: Date.now()
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if ("on_tool_start" === chunk.event) {
|
|
128
|
+
const toolName = "string" == typeof chunk.name ? chunk.name : "tool";
|
|
129
|
+
const toolId = "string" == typeof chunk.run_id ? chunk.run_id : (0, external_uuid_namespaceObject.v4)();
|
|
130
|
+
const args = normalizeToolArgs(chunk.data?.input);
|
|
131
|
+
return {
|
|
132
|
+
toolCall: {
|
|
133
|
+
id: toolId,
|
|
134
|
+
name: toolName,
|
|
135
|
+
args
|
|
136
|
+
},
|
|
137
|
+
type: "tool",
|
|
138
|
+
timestamp: Date.now()
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
if ("on_tool_end" === chunk.event) {
|
|
142
|
+
const toolId = "string" == typeof chunk.run_id ? chunk.run_id : void 0;
|
|
143
|
+
if (!toolId) return null;
|
|
144
|
+
return {
|
|
145
|
+
toolResult: {
|
|
146
|
+
id: toolId,
|
|
147
|
+
output: chunk.data?.output ?? "",
|
|
148
|
+
error: chunk.data?.error
|
|
149
|
+
},
|
|
150
|
+
type: "tool-result",
|
|
151
|
+
timestamp: Date.now()
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
function normalizeMessagesFromChunk(chunk) {
|
|
157
|
+
if (Array.isArray(chunk) && chunk.length >= 3 && "messages" === chunk[1]) return normalizeMessagesPayload(chunk[2], String(chunk[0] ?? "messages"));
|
|
158
|
+
const entries = [];
|
|
159
|
+
if (Array.isArray(chunk.messages)) for (const [index, message] of chunk.messages.entries())entries.push({
|
|
160
|
+
message,
|
|
161
|
+
sourceKey: "messages",
|
|
162
|
+
index
|
|
163
|
+
});
|
|
164
|
+
if ("object" == typeof chunk) for (const [key, value] of Object.entries(chunk)){
|
|
165
|
+
const messages = value?.messages;
|
|
166
|
+
if (Array.isArray(messages)) for (const [index, message] of messages.entries())entries.push({
|
|
167
|
+
message,
|
|
168
|
+
sourceKey: key,
|
|
169
|
+
index
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return entries;
|
|
173
|
+
}
|
|
174
|
+
function normalizeMessagesPayload(payload, sourceKey) {
|
|
175
|
+
if (!Array.isArray(payload) || 0 === payload.length) return [];
|
|
176
|
+
if (2 === payload.length && !Array.isArray(payload[0])) return [
|
|
177
|
+
{
|
|
178
|
+
message: payload[0],
|
|
179
|
+
meta: payload[1],
|
|
180
|
+
sourceKey,
|
|
181
|
+
index: 0
|
|
182
|
+
}
|
|
183
|
+
];
|
|
184
|
+
if (Array.isArray(payload[0])) return payload.map((entry, index)=>{
|
|
185
|
+
if (!Array.isArray(entry)) return;
|
|
186
|
+
return {
|
|
187
|
+
message: entry[0],
|
|
188
|
+
meta: entry[1],
|
|
189
|
+
sourceKey,
|
|
190
|
+
index
|
|
191
|
+
};
|
|
192
|
+
}).filter(Boolean);
|
|
193
|
+
return [
|
|
194
|
+
{
|
|
195
|
+
message: payload[0],
|
|
196
|
+
sourceKey,
|
|
197
|
+
index: 0
|
|
198
|
+
}
|
|
199
|
+
];
|
|
200
|
+
}
|
|
201
|
+
function getMessageType(msg) {
|
|
202
|
+
if (!msg) return;
|
|
203
|
+
if ("function" == typeof msg._getType) return msg._getType();
|
|
204
|
+
if ("function" == typeof msg.getType) return msg.getType();
|
|
205
|
+
if ("string" == typeof msg.type) return msg.type;
|
|
206
|
+
if (Array.isArray(msg.id) && msg.id.length > 0) return String(msg.id[msg.id.length - 1]);
|
|
207
|
+
if (Array.isArray(msg.lc_id) && msg.lc_id.length > 0) return String(msg.lc_id[msg.lc_id.length - 1]);
|
|
208
|
+
const constructorName = "string" == typeof msg.constructor?.name ? msg.constructor.name : "";
|
|
209
|
+
if (constructorName && "Object" !== constructorName) return constructorName;
|
|
210
|
+
}
|
|
211
|
+
function isAIMessageType(normalizedType) {
|
|
212
|
+
return "ai" === normalizedType || "assistant" === normalizedType || "aimessage" === normalizedType || "aimessagechunk" === normalizedType;
|
|
213
|
+
}
|
|
214
|
+
function isToolMessageType(normalizedType) {
|
|
215
|
+
return "tool" === normalizedType || "toolmessage" === normalizedType || "toolmessagechunk" === normalizedType;
|
|
216
|
+
}
|
|
217
|
+
function isMessageDelta(msg, normalizedType) {
|
|
218
|
+
if (normalizedType.includes("chunk")) return true;
|
|
219
|
+
const idParts = Array.isArray(msg?.id) ? msg.id : [];
|
|
220
|
+
if (idParts.some((part)=>String(part).toLowerCase().includes("chunk"))) return true;
|
|
221
|
+
const lcIdParts = Array.isArray(msg?.lc_id) ? msg.lc_id : [];
|
|
222
|
+
if (lcIdParts.some((part)=>String(part).toLowerCase().includes("chunk"))) return true;
|
|
223
|
+
const constructorName = "string" == typeof msg?.constructor?.name ? msg.constructor.name : "";
|
|
224
|
+
return constructorName.toLowerCase().includes("chunk");
|
|
225
|
+
}
|
|
226
|
+
function getMessageId(msg, entry) {
|
|
227
|
+
if ("string" == typeof msg?.id) return msg.id;
|
|
228
|
+
if ("string" == typeof msg?.kwargs?.id) return msg.kwargs.id;
|
|
229
|
+
if ("string" == typeof msg?.additional_kwargs?.id) return msg.additional_kwargs.id;
|
|
230
|
+
if ("string" == typeof msg?.lc_kwargs?.id) return msg.lc_kwargs.id;
|
|
231
|
+
if ("string" == typeof entry.meta?.id) return entry.meta.id;
|
|
232
|
+
const fallbackParts = [];
|
|
233
|
+
if (entry.meta && "object" == typeof entry.meta) {
|
|
234
|
+
if (entry.meta.langgraph_node) fallbackParts.push(String(entry.meta.langgraph_node));
|
|
235
|
+
if (void 0 !== entry.meta.langgraph_step) fallbackParts.push(String(entry.meta.langgraph_step));
|
|
236
|
+
}
|
|
237
|
+
if (0 === fallbackParts.length && entry.sourceKey) fallbackParts.push(entry.sourceKey);
|
|
238
|
+
if (void 0 !== entry.index) fallbackParts.push(String(entry.index));
|
|
239
|
+
return fallbackParts.length > 0 ? fallbackParts.join(":") : void 0;
|
|
240
|
+
}
|
|
241
|
+
function extractTextContent(msg) {
|
|
242
|
+
const content = msg?.content ?? msg?.kwargs?.content ?? msg?.additional_kwargs?.content;
|
|
243
|
+
if ("string" == typeof content) return content.length > 0 ? content : void 0;
|
|
244
|
+
if (Array.isArray(content)) {
|
|
245
|
+
const textBlocks = content.filter((block)=>block?.type === "text" && block.text).map((block)=>block.text);
|
|
246
|
+
if (textBlocks.length > 0) return textBlocks.join("");
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function extractToolCalls(msg, messageId) {
|
|
250
|
+
const calls = [];
|
|
251
|
+
const toolCalls = msg?.tool_calls ?? msg?.kwargs?.tool_calls ?? msg?.additional_kwargs?.tool_calls;
|
|
252
|
+
if (Array.isArray(toolCalls)) calls.push(...toolCalls);
|
|
253
|
+
const toolCallChunks = msg?.tool_call_chunks ?? msg?.kwargs?.tool_call_chunks ?? msg?.additional_kwargs?.tool_call_chunks;
|
|
254
|
+
if (Array.isArray(toolCallChunks)) calls.push(...toolCallChunks);
|
|
255
|
+
return calls.map((call)=>normalizeToolCall(call, messageId)).filter(Boolean);
|
|
256
|
+
}
|
|
257
|
+
function normalizeToolCall(toolCall, messageId) {
|
|
258
|
+
if (!toolCall) return;
|
|
259
|
+
const name = toolCall.name || toolCall.function?.name;
|
|
260
|
+
if (!name) return;
|
|
261
|
+
const index = "number" == typeof toolCall.index ? toolCall.index : void 0;
|
|
262
|
+
const id = toolCall.id || (void 0 !== index && messageId ? `${messageId}:${index}` : void 0) || (messageId ? `${messageId}:${(0, external_uuid_namespaceObject.v4)()}` : (0, external_uuid_namespaceObject.v4)());
|
|
263
|
+
return {
|
|
264
|
+
id,
|
|
265
|
+
name,
|
|
266
|
+
args: normalizeToolArgs(toolCall.args ?? toolCall.function?.arguments)
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function normalizeToolArgs(args) {
|
|
270
|
+
if (!args) return {};
|
|
271
|
+
if ("string" == typeof args) {
|
|
272
|
+
try {
|
|
273
|
+
const parsed = JSON.parse(args);
|
|
274
|
+
if (parsed && "object" == typeof parsed) return parsed;
|
|
275
|
+
} catch {}
|
|
276
|
+
return {
|
|
277
|
+
raw: args
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
if ("object" == typeof args) return args;
|
|
281
|
+
return {
|
|
282
|
+
value: args
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function extractToolResult(msg) {
|
|
286
|
+
const toolCallId = msg?.tool_call_id ?? msg?.kwargs?.tool_call_id ?? msg?.additional_kwargs?.tool_call_id;
|
|
287
|
+
if (!toolCallId) return null;
|
|
288
|
+
return {
|
|
289
|
+
id: toolCallId,
|
|
290
|
+
output: msg?.content ?? msg?.kwargs?.content ?? "",
|
|
291
|
+
error: msg?.kwargs?.error ?? msg?.additional_kwargs?.error
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
function formatParsedChunk(parsed) {
|
|
295
|
+
switch(parsed.type){
|
|
296
|
+
case "text":
|
|
297
|
+
return parsed.text || null;
|
|
298
|
+
case "tool":
|
|
299
|
+
if (parsed.toolCall) {
|
|
300
|
+
const argsStr = parsed.toolCall.args ? ` ${JSON.stringify(parsed.toolCall.args)}` : "";
|
|
301
|
+
return `\n🔧 Using tool: ${parsed.toolCall.name}${argsStr}\n`;
|
|
302
|
+
}
|
|
303
|
+
return null;
|
|
304
|
+
case "state":
|
|
305
|
+
return null;
|
|
306
|
+
case "unknown":
|
|
307
|
+
return null;
|
|
308
|
+
default:
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function processStreamChunk(chunk) {
|
|
313
|
+
const parsedArray = parseStreamChunk(chunk);
|
|
314
|
+
if (!parsedArray || 0 === parsedArray.length) return null;
|
|
315
|
+
const formatted = parsedArray.map((parsed)=>formatParsedChunk(parsed)).filter((text)=>null !== text).join("");
|
|
316
|
+
return formatted.length > 0 ? formatted : null;
|
|
317
|
+
}
|
|
318
|
+
exports.formatParsedChunk = __webpack_exports__.formatParsedChunk;
|
|
319
|
+
exports.parseStreamChunk = __webpack_exports__.parseStreamChunk;
|
|
320
|
+
exports.processStreamChunk = __webpack_exports__.processStreamChunk;
|
|
321
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
322
|
+
"formatParsedChunk",
|
|
323
|
+
"parseStreamChunk",
|
|
324
|
+
"processStreamChunk"
|
|
325
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
326
|
+
Object.defineProperty(exports, '__esModule', {
|
|
327
|
+
value: true
|
|
328
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse LangGraph streaming chunks for display
|
|
3
|
+
*
|
|
4
|
+
* LangGraph/DeepAgents streams chunks in various formats:
|
|
5
|
+
* - AIMessage updates with content deltas
|
|
6
|
+
* - Tool calls
|
|
7
|
+
* - Tool results
|
|
8
|
+
* - State updates
|
|
9
|
+
*
|
|
10
|
+
* This parser extracts displayable text for CLI output.
|
|
11
|
+
*/
|
|
12
|
+
export interface ParsedChunk {
|
|
13
|
+
text?: string;
|
|
14
|
+
messageId?: string;
|
|
15
|
+
isDelta?: boolean;
|
|
16
|
+
toolCall?: {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
args?: any;
|
|
20
|
+
};
|
|
21
|
+
toolResult?: {
|
|
22
|
+
id: string;
|
|
23
|
+
output: any;
|
|
24
|
+
error?: string;
|
|
25
|
+
};
|
|
26
|
+
type: "text" | "tool" | "tool-result" | "state" | "unknown";
|
|
27
|
+
timestamp: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Parse a raw LangGraph stream chunk
|
|
31
|
+
* Returns an array of parsed chunks to handle multiple messages/events in a single chunk
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseStreamChunk(chunk: any): ParsedChunk[];
|
|
34
|
+
/**
|
|
35
|
+
* Format parsed chunk for CLI display
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatParsedChunk(parsed: ParsedChunk): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Process a stream chunk and return displayable text
|
|
40
|
+
* Returns null if nothing should be displayed
|
|
41
|
+
*/
|
|
42
|
+
export declare function processStreamChunk(chunk: any): string | null;
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { v4 } from "uuid";
|
|
2
|
+
function parseStreamChunk(chunk) {
|
|
3
|
+
if (!chunk || "object" != typeof chunk) return [];
|
|
4
|
+
const tokenChunk = parseStreamEventChunk(chunk);
|
|
5
|
+
if (tokenChunk) return [
|
|
6
|
+
tokenChunk
|
|
7
|
+
];
|
|
8
|
+
const messageEntries = normalizeMessagesFromChunk(chunk);
|
|
9
|
+
const results = [];
|
|
10
|
+
if (messageEntries.length > 0) for (const entry of messageEntries){
|
|
11
|
+
const msg = entry.message;
|
|
12
|
+
const messageType = getMessageType(msg);
|
|
13
|
+
const normalizedType = messageType ? messageType.toLowerCase() : "";
|
|
14
|
+
const isAIMessage = isAIMessageType(normalizedType);
|
|
15
|
+
const isToolMessage = isToolMessageType(normalizedType);
|
|
16
|
+
const messageId = isAIMessage ? getMessageId(msg, entry) : void 0;
|
|
17
|
+
if (isAIMessage) {
|
|
18
|
+
const toolCalls = extractToolCalls(msg, messageId);
|
|
19
|
+
if (toolCalls.length > 0) for (const toolCall of toolCalls)results.push({
|
|
20
|
+
messageId,
|
|
21
|
+
toolCall: toolCall,
|
|
22
|
+
type: "tool",
|
|
23
|
+
timestamp: Date.now()
|
|
24
|
+
});
|
|
25
|
+
const text = extractTextContent(msg);
|
|
26
|
+
if (text) results.push({
|
|
27
|
+
messageId,
|
|
28
|
+
text,
|
|
29
|
+
isDelta: isMessageDelta(msg, normalizedType),
|
|
30
|
+
type: "text",
|
|
31
|
+
timestamp: Date.now()
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (isToolMessage) {
|
|
35
|
+
const toolResult = extractToolResult(msg);
|
|
36
|
+
if (toolResult) results.push({
|
|
37
|
+
toolResult,
|
|
38
|
+
type: "tool-result",
|
|
39
|
+
timestamp: Date.now()
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (results.length > 0) return results;
|
|
44
|
+
if (chunk.content) {
|
|
45
|
+
if ("string" == typeof chunk.content) return [
|
|
46
|
+
{
|
|
47
|
+
text: chunk.content,
|
|
48
|
+
type: "text",
|
|
49
|
+
timestamp: Date.now()
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
if (chunk.tool_calls && Array.isArray(chunk.tool_calls)) {
|
|
54
|
+
const toolResults = [];
|
|
55
|
+
for (const toolCall of chunk.tool_calls){
|
|
56
|
+
const normalized = normalizeToolCall(toolCall);
|
|
57
|
+
if (normalized) toolResults.push({
|
|
58
|
+
toolCall: normalized,
|
|
59
|
+
type: "tool",
|
|
60
|
+
timestamp: Date.now()
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (toolResults.length > 0) return toolResults;
|
|
64
|
+
}
|
|
65
|
+
chunk.next || chunk.metadata;
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
function parseStreamEventChunk(chunk) {
|
|
69
|
+
if (!chunk || "object" != typeof chunk) return null;
|
|
70
|
+
if ("string" != typeof chunk.event) return null;
|
|
71
|
+
if ("on_chat_model_stream" === chunk.event) {
|
|
72
|
+
const messageChunk = chunk.data?.chunk ?? chunk.data?.message;
|
|
73
|
+
const text = extractTextContent(messageChunk);
|
|
74
|
+
if (!text) return null;
|
|
75
|
+
return {
|
|
76
|
+
messageId: "string" == typeof chunk.run_id ? chunk.run_id : void 0,
|
|
77
|
+
text,
|
|
78
|
+
isDelta: true,
|
|
79
|
+
type: "text",
|
|
80
|
+
timestamp: Date.now()
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if ("on_llm_stream" === chunk.event) {
|
|
84
|
+
const llmChunk = chunk.data?.chunk;
|
|
85
|
+
let text;
|
|
86
|
+
if ("string" == typeof llmChunk) text = llmChunk;
|
|
87
|
+
else if ("string" == typeof llmChunk?.text) text = llmChunk.text;
|
|
88
|
+
if (!text) return null;
|
|
89
|
+
return {
|
|
90
|
+
messageId: "string" == typeof chunk.run_id ? chunk.run_id : void 0,
|
|
91
|
+
text,
|
|
92
|
+
isDelta: true,
|
|
93
|
+
type: "text",
|
|
94
|
+
timestamp: Date.now()
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if ("on_tool_start" === chunk.event) {
|
|
98
|
+
const toolName = "string" == typeof chunk.name ? chunk.name : "tool";
|
|
99
|
+
const toolId = "string" == typeof chunk.run_id ? chunk.run_id : v4();
|
|
100
|
+
const args = normalizeToolArgs(chunk.data?.input);
|
|
101
|
+
return {
|
|
102
|
+
toolCall: {
|
|
103
|
+
id: toolId,
|
|
104
|
+
name: toolName,
|
|
105
|
+
args
|
|
106
|
+
},
|
|
107
|
+
type: "tool",
|
|
108
|
+
timestamp: Date.now()
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if ("on_tool_end" === chunk.event) {
|
|
112
|
+
const toolId = "string" == typeof chunk.run_id ? chunk.run_id : void 0;
|
|
113
|
+
if (!toolId) return null;
|
|
114
|
+
return {
|
|
115
|
+
toolResult: {
|
|
116
|
+
id: toolId,
|
|
117
|
+
output: chunk.data?.output ?? "",
|
|
118
|
+
error: chunk.data?.error
|
|
119
|
+
},
|
|
120
|
+
type: "tool-result",
|
|
121
|
+
timestamp: Date.now()
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
function normalizeMessagesFromChunk(chunk) {
|
|
127
|
+
if (Array.isArray(chunk) && chunk.length >= 3 && "messages" === chunk[1]) return normalizeMessagesPayload(chunk[2], String(chunk[0] ?? "messages"));
|
|
128
|
+
const entries = [];
|
|
129
|
+
if (Array.isArray(chunk.messages)) for (const [index, message] of chunk.messages.entries())entries.push({
|
|
130
|
+
message,
|
|
131
|
+
sourceKey: "messages",
|
|
132
|
+
index
|
|
133
|
+
});
|
|
134
|
+
if ("object" == typeof chunk) for (const [key, value] of Object.entries(chunk)){
|
|
135
|
+
const messages = value?.messages;
|
|
136
|
+
if (Array.isArray(messages)) for (const [index, message] of messages.entries())entries.push({
|
|
137
|
+
message,
|
|
138
|
+
sourceKey: key,
|
|
139
|
+
index
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return entries;
|
|
143
|
+
}
|
|
144
|
+
function normalizeMessagesPayload(payload, sourceKey) {
|
|
145
|
+
if (!Array.isArray(payload) || 0 === payload.length) return [];
|
|
146
|
+
if (2 === payload.length && !Array.isArray(payload[0])) return [
|
|
147
|
+
{
|
|
148
|
+
message: payload[0],
|
|
149
|
+
meta: payload[1],
|
|
150
|
+
sourceKey,
|
|
151
|
+
index: 0
|
|
152
|
+
}
|
|
153
|
+
];
|
|
154
|
+
if (Array.isArray(payload[0])) return payload.map((entry, index)=>{
|
|
155
|
+
if (!Array.isArray(entry)) return;
|
|
156
|
+
return {
|
|
157
|
+
message: entry[0],
|
|
158
|
+
meta: entry[1],
|
|
159
|
+
sourceKey,
|
|
160
|
+
index
|
|
161
|
+
};
|
|
162
|
+
}).filter(Boolean);
|
|
163
|
+
return [
|
|
164
|
+
{
|
|
165
|
+
message: payload[0],
|
|
166
|
+
sourceKey,
|
|
167
|
+
index: 0
|
|
168
|
+
}
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
function getMessageType(msg) {
|
|
172
|
+
if (!msg) return;
|
|
173
|
+
if ("function" == typeof msg._getType) return msg._getType();
|
|
174
|
+
if ("function" == typeof msg.getType) return msg.getType();
|
|
175
|
+
if ("string" == typeof msg.type) return msg.type;
|
|
176
|
+
if (Array.isArray(msg.id) && msg.id.length > 0) return String(msg.id[msg.id.length - 1]);
|
|
177
|
+
if (Array.isArray(msg.lc_id) && msg.lc_id.length > 0) return String(msg.lc_id[msg.lc_id.length - 1]);
|
|
178
|
+
const constructorName = "string" == typeof msg.constructor?.name ? msg.constructor.name : "";
|
|
179
|
+
if (constructorName && "Object" !== constructorName) return constructorName;
|
|
180
|
+
}
|
|
181
|
+
function isAIMessageType(normalizedType) {
|
|
182
|
+
return "ai" === normalizedType || "assistant" === normalizedType || "aimessage" === normalizedType || "aimessagechunk" === normalizedType;
|
|
183
|
+
}
|
|
184
|
+
function isToolMessageType(normalizedType) {
|
|
185
|
+
return "tool" === normalizedType || "toolmessage" === normalizedType || "toolmessagechunk" === normalizedType;
|
|
186
|
+
}
|
|
187
|
+
function isMessageDelta(msg, normalizedType) {
|
|
188
|
+
if (normalizedType.includes("chunk")) return true;
|
|
189
|
+
const idParts = Array.isArray(msg?.id) ? msg.id : [];
|
|
190
|
+
if (idParts.some((part)=>String(part).toLowerCase().includes("chunk"))) return true;
|
|
191
|
+
const lcIdParts = Array.isArray(msg?.lc_id) ? msg.lc_id : [];
|
|
192
|
+
if (lcIdParts.some((part)=>String(part).toLowerCase().includes("chunk"))) return true;
|
|
193
|
+
const constructorName = "string" == typeof msg?.constructor?.name ? msg.constructor.name : "";
|
|
194
|
+
return constructorName.toLowerCase().includes("chunk");
|
|
195
|
+
}
|
|
196
|
+
function getMessageId(msg, entry) {
|
|
197
|
+
if ("string" == typeof msg?.id) return msg.id;
|
|
198
|
+
if ("string" == typeof msg?.kwargs?.id) return msg.kwargs.id;
|
|
199
|
+
if ("string" == typeof msg?.additional_kwargs?.id) return msg.additional_kwargs.id;
|
|
200
|
+
if ("string" == typeof msg?.lc_kwargs?.id) return msg.lc_kwargs.id;
|
|
201
|
+
if ("string" == typeof entry.meta?.id) return entry.meta.id;
|
|
202
|
+
const fallbackParts = [];
|
|
203
|
+
if (entry.meta && "object" == typeof entry.meta) {
|
|
204
|
+
if (entry.meta.langgraph_node) fallbackParts.push(String(entry.meta.langgraph_node));
|
|
205
|
+
if (void 0 !== entry.meta.langgraph_step) fallbackParts.push(String(entry.meta.langgraph_step));
|
|
206
|
+
}
|
|
207
|
+
if (0 === fallbackParts.length && entry.sourceKey) fallbackParts.push(entry.sourceKey);
|
|
208
|
+
if (void 0 !== entry.index) fallbackParts.push(String(entry.index));
|
|
209
|
+
return fallbackParts.length > 0 ? fallbackParts.join(":") : void 0;
|
|
210
|
+
}
|
|
211
|
+
function extractTextContent(msg) {
|
|
212
|
+
const content = msg?.content ?? msg?.kwargs?.content ?? msg?.additional_kwargs?.content;
|
|
213
|
+
if ("string" == typeof content) return content.length > 0 ? content : void 0;
|
|
214
|
+
if (Array.isArray(content)) {
|
|
215
|
+
const textBlocks = content.filter((block)=>block?.type === "text" && block.text).map((block)=>block.text);
|
|
216
|
+
if (textBlocks.length > 0) return textBlocks.join("");
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function extractToolCalls(msg, messageId) {
|
|
220
|
+
const calls = [];
|
|
221
|
+
const toolCalls = msg?.tool_calls ?? msg?.kwargs?.tool_calls ?? msg?.additional_kwargs?.tool_calls;
|
|
222
|
+
if (Array.isArray(toolCalls)) calls.push(...toolCalls);
|
|
223
|
+
const toolCallChunks = msg?.tool_call_chunks ?? msg?.kwargs?.tool_call_chunks ?? msg?.additional_kwargs?.tool_call_chunks;
|
|
224
|
+
if (Array.isArray(toolCallChunks)) calls.push(...toolCallChunks);
|
|
225
|
+
return calls.map((call)=>normalizeToolCall(call, messageId)).filter(Boolean);
|
|
226
|
+
}
|
|
227
|
+
function normalizeToolCall(toolCall, messageId) {
|
|
228
|
+
if (!toolCall) return;
|
|
229
|
+
const name = toolCall.name || toolCall.function?.name;
|
|
230
|
+
if (!name) return;
|
|
231
|
+
const index = "number" == typeof toolCall.index ? toolCall.index : void 0;
|
|
232
|
+
const id = toolCall.id || (void 0 !== index && messageId ? `${messageId}:${index}` : void 0) || (messageId ? `${messageId}:${v4()}` : v4());
|
|
233
|
+
return {
|
|
234
|
+
id,
|
|
235
|
+
name,
|
|
236
|
+
args: normalizeToolArgs(toolCall.args ?? toolCall.function?.arguments)
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function normalizeToolArgs(args) {
|
|
240
|
+
if (!args) return {};
|
|
241
|
+
if ("string" == typeof args) {
|
|
242
|
+
try {
|
|
243
|
+
const parsed = JSON.parse(args);
|
|
244
|
+
if (parsed && "object" == typeof parsed) return parsed;
|
|
245
|
+
} catch {}
|
|
246
|
+
return {
|
|
247
|
+
raw: args
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
if ("object" == typeof args) return args;
|
|
251
|
+
return {
|
|
252
|
+
value: args
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
function extractToolResult(msg) {
|
|
256
|
+
const toolCallId = msg?.tool_call_id ?? msg?.kwargs?.tool_call_id ?? msg?.additional_kwargs?.tool_call_id;
|
|
257
|
+
if (!toolCallId) return null;
|
|
258
|
+
return {
|
|
259
|
+
id: toolCallId,
|
|
260
|
+
output: msg?.content ?? msg?.kwargs?.content ?? "",
|
|
261
|
+
error: msg?.kwargs?.error ?? msg?.additional_kwargs?.error
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
function formatParsedChunk(parsed) {
|
|
265
|
+
switch(parsed.type){
|
|
266
|
+
case "text":
|
|
267
|
+
return parsed.text || null;
|
|
268
|
+
case "tool":
|
|
269
|
+
if (parsed.toolCall) {
|
|
270
|
+
const argsStr = parsed.toolCall.args ? ` ${JSON.stringify(parsed.toolCall.args)}` : "";
|
|
271
|
+
return `\n🔧 Using tool: ${parsed.toolCall.name}${argsStr}\n`;
|
|
272
|
+
}
|
|
273
|
+
return null;
|
|
274
|
+
case "state":
|
|
275
|
+
return null;
|
|
276
|
+
case "unknown":
|
|
277
|
+
return null;
|
|
278
|
+
default:
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function processStreamChunk(chunk) {
|
|
283
|
+
const parsedArray = parseStreamChunk(chunk);
|
|
284
|
+
if (!parsedArray || 0 === parsedArray.length) return null;
|
|
285
|
+
const formatted = parsedArray.map((parsed)=>formatParsedChunk(parsed)).filter((text)=>null !== text).join("");
|
|
286
|
+
return formatted.length > 0 ? formatted : null;
|
|
287
|
+
}
|
|
288
|
+
export { formatParsedChunk, parseStreamChunk, processStreamChunk };
|