openbotgate 1.0.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/LICENSE +21 -0
- package/README.md +293 -0
- package/bin/openbotgate.js +31 -0
- package/dist/config/config.d.ts +56 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +136 -0
- package/dist/config/config.js.map +1 -0
- package/dist/debug.d.ts +2 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +33 -0
- package/dist/debug.js.map +1 -0
- package/dist/gateway/bluebubbles.d.ts +12 -0
- package/dist/gateway/bluebubbles.d.ts.map +1 -0
- package/dist/gateway/bluebubbles.js +80 -0
- package/dist/gateway/bluebubbles.js.map +1 -0
- package/dist/gateway/catalog.d.ts +10 -0
- package/dist/gateway/catalog.d.ts.map +1 -0
- package/dist/gateway/catalog.js +28 -0
- package/dist/gateway/catalog.js.map +1 -0
- package/dist/gateway/discord.d.ts +12 -0
- package/dist/gateway/discord.d.ts.map +1 -0
- package/dist/gateway/discord.js +83 -0
- package/dist/gateway/discord.js.map +1 -0
- package/dist/gateway/feishu.d.ts +35 -0
- package/dist/gateway/feishu.d.ts.map +1 -0
- package/dist/gateway/feishu.js +290 -0
- package/dist/gateway/feishu.js.map +1 -0
- package/dist/gateway/googlechat.d.ts +11 -0
- package/dist/gateway/googlechat.d.ts.map +1 -0
- package/dist/gateway/googlechat.js +92 -0
- package/dist/gateway/googlechat.js.map +1 -0
- package/dist/gateway/imessage.d.ts +12 -0
- package/dist/gateway/imessage.d.ts.map +1 -0
- package/dist/gateway/imessage.js +84 -0
- package/dist/gateway/imessage.js.map +1 -0
- package/dist/gateway/index.d.ts +9 -0
- package/dist/gateway/index.d.ts.map +1 -0
- package/dist/gateway/index.js +27 -0
- package/dist/gateway/index.js.map +1 -0
- package/dist/gateway/line.d.ts +13 -0
- package/dist/gateway/line.d.ts.map +1 -0
- package/dist/gateway/line.js +80 -0
- package/dist/gateway/line.js.map +1 -0
- package/dist/gateway/matrix.d.ts +12 -0
- package/dist/gateway/matrix.d.ts.map +1 -0
- package/dist/gateway/matrix.js +105 -0
- package/dist/gateway/matrix.js.map +1 -0
- package/dist/gateway/mattermost.d.ts +14 -0
- package/dist/gateway/mattermost.d.ts.map +1 -0
- package/dist/gateway/mattermost.js +92 -0
- package/dist/gateway/mattermost.js.map +1 -0
- package/dist/gateway/msteams.d.ts +12 -0
- package/dist/gateway/msteams.d.ts.map +1 -0
- package/dist/gateway/msteams.js +119 -0
- package/dist/gateway/msteams.js.map +1 -0
- package/dist/gateway/nextcloud-talk.d.ts +11 -0
- package/dist/gateway/nextcloud-talk.d.ts.map +1 -0
- package/dist/gateway/nextcloud-talk.js +93 -0
- package/dist/gateway/nextcloud-talk.js.map +1 -0
- package/dist/gateway/nostr.d.ts +15 -0
- package/dist/gateway/nostr.d.ts.map +1 -0
- package/dist/gateway/nostr.js +95 -0
- package/dist/gateway/nostr.js.map +1 -0
- package/dist/gateway/qq-guild.d.ts +14 -0
- package/dist/gateway/qq-guild.d.ts.map +1 -0
- package/dist/gateway/qq-guild.js +121 -0
- package/dist/gateway/qq-guild.js.map +1 -0
- package/dist/gateway/qq.d.ts +14 -0
- package/dist/gateway/qq.d.ts.map +1 -0
- package/dist/gateway/qq.js +121 -0
- package/dist/gateway/qq.js.map +1 -0
- package/dist/gateway/registry.d.ts +4 -0
- package/dist/gateway/registry.d.ts.map +1 -0
- package/dist/gateway/registry.js +38 -0
- package/dist/gateway/registry.js.map +1 -0
- package/dist/gateway/signal.d.ts +12 -0
- package/dist/gateway/signal.d.ts.map +1 -0
- package/dist/gateway/signal.js +80 -0
- package/dist/gateway/signal.js.map +1 -0
- package/dist/gateway/slack.d.ts +12 -0
- package/dist/gateway/slack.d.ts.map +1 -0
- package/dist/gateway/slack.js +83 -0
- package/dist/gateway/slack.js.map +1 -0
- package/dist/gateway/stub.d.ts +7 -0
- package/dist/gateway/stub.d.ts.map +1 -0
- package/dist/gateway/stub.js +23 -0
- package/dist/gateway/stub.js.map +1 -0
- package/dist/gateway/telegram.d.ts +12 -0
- package/dist/gateway/telegram.d.ts.map +1 -0
- package/dist/gateway/telegram.js +61 -0
- package/dist/gateway/telegram.js.map +1 -0
- package/dist/gateway/tlon.d.ts +12 -0
- package/dist/gateway/tlon.d.ts.map +1 -0
- package/dist/gateway/tlon.js +105 -0
- package/dist/gateway/tlon.js.map +1 -0
- package/dist/gateway/types.d.ts +21 -0
- package/dist/gateway/types.d.ts.map +1 -0
- package/dist/gateway/types.js +3 -0
- package/dist/gateway/types.js.map +1 -0
- package/dist/gateway/whatsapp.d.ts +12 -0
- package/dist/gateway/whatsapp.d.ts.map +1 -0
- package/dist/gateway/whatsapp.js +81 -0
- package/dist/gateway/whatsapp.js.map +1 -0
- package/dist/gateway/zalo.d.ts +12 -0
- package/dist/gateway/zalo.d.ts.map +1 -0
- package/dist/gateway/zalo.js +77 -0
- package/dist/gateway/zalo.js.map +1 -0
- package/dist/gateway/zalouser.d.ts +12 -0
- package/dist/gateway/zalouser.d.ts.map +1 -0
- package/dist/gateway/zalouser.js +85 -0
- package/dist/gateway/zalouser.js.map +1 -0
- package/dist/handler/code/agent.d.ts +10 -0
- package/dist/handler/code/agent.d.ts.map +1 -0
- package/dist/handler/code/agent.js +63 -0
- package/dist/handler/code/agent.js.map +1 -0
- package/dist/handler/code/code.d.ts +15 -0
- package/dist/handler/code/code.d.ts.map +1 -0
- package/dist/handler/code/code.js +129 -0
- package/dist/handler/code/code.js.map +1 -0
- package/dist/handler/code/model.d.ts +10 -0
- package/dist/handler/code/model.d.ts.map +1 -0
- package/dist/handler/code/model.js +63 -0
- package/dist/handler/code/model.js.map +1 -0
- package/dist/handler/code/new.d.ts +7 -0
- package/dist/handler/code/new.d.ts.map +1 -0
- package/dist/handler/code/new.js +27 -0
- package/dist/handler/code/new.js.map +1 -0
- package/dist/handler/code/opencode.d.ts +12 -0
- package/dist/handler/code/opencode.d.ts.map +1 -0
- package/dist/handler/code/opencode.js +88 -0
- package/dist/handler/code/opencode.js.map +1 -0
- package/dist/handler/code/session.d.ts +9 -0
- package/dist/handler/code/session.d.ts.map +1 -0
- package/dist/handler/code/session.js +55 -0
- package/dist/handler/code/session.js.map +1 -0
- package/dist/handler/code/workspace.d.ts +10 -0
- package/dist/handler/code/workspace.d.ts.map +1 -0
- package/dist/handler/code/workspace.js +80 -0
- package/dist/handler/code/workspace.js.map +1 -0
- package/dist/handler/commands/agent.d.ts +10 -0
- package/dist/handler/commands/agent.d.ts.map +1 -0
- package/dist/handler/commands/agent.js +63 -0
- package/dist/handler/commands/agent.js.map +1 -0
- package/dist/handler/commands/async.d.ts +3 -0
- package/dist/handler/commands/async.d.ts.map +1 -0
- package/dist/handler/commands/async.js +30 -0
- package/dist/handler/commands/async.js.map +1 -0
- package/dist/handler/commands/claude.d.ts +3 -0
- package/dist/handler/commands/claude.d.ts.map +1 -0
- package/dist/handler/commands/claude.js +19 -0
- package/dist/handler/commands/claude.js.map +1 -0
- package/dist/handler/commands/code.d.ts +15 -0
- package/dist/handler/commands/code.d.ts.map +1 -0
- package/dist/handler/commands/code.js +133 -0
- package/dist/handler/commands/code.js.map +1 -0
- package/dist/handler/commands/git.d.ts +3 -0
- package/dist/handler/commands/git.d.ts.map +1 -0
- package/dist/handler/commands/git.js +25 -0
- package/dist/handler/commands/git.js.map +1 -0
- package/dist/handler/commands/help.d.ts +3 -0
- package/dist/handler/commands/help.d.ts.map +1 -0
- package/dist/handler/commands/help.js +49 -0
- package/dist/handler/commands/help.js.map +1 -0
- package/dist/handler/commands/index.d.ts +10 -0
- package/dist/handler/commands/index.d.ts.map +1 -0
- package/dist/handler/commands/index.js +43 -0
- package/dist/handler/commands/index.js.map +1 -0
- package/dist/handler/commands/model.d.ts +10 -0
- package/dist/handler/commands/model.d.ts.map +1 -0
- package/dist/handler/commands/model.js +63 -0
- package/dist/handler/commands/model.js.map +1 -0
- package/dist/handler/commands/new.d.ts +3 -0
- package/dist/handler/commands/new.d.ts.map +1 -0
- package/dist/handler/commands/new.js +25 -0
- package/dist/handler/commands/new.js.map +1 -0
- package/dist/handler/commands/opencode.d.ts +12 -0
- package/dist/handler/commands/opencode.d.ts.map +1 -0
- package/dist/handler/commands/opencode.js +131 -0
- package/dist/handler/commands/opencode.js.map +1 -0
- package/dist/handler/commands/session.d.ts +9 -0
- package/dist/handler/commands/session.d.ts.map +1 -0
- package/dist/handler/commands/session.js +55 -0
- package/dist/handler/commands/session.js.map +1 -0
- package/dist/handler/commands/shell.d.ts +11 -0
- package/dist/handler/commands/shell.d.ts.map +1 -0
- package/dist/handler/commands/shell.js +142 -0
- package/dist/handler/commands/shell.js.map +1 -0
- package/dist/handler/commands/status.d.ts +3 -0
- package/dist/handler/commands/status.d.ts.map +1 -0
- package/dist/handler/commands/status.js +21 -0
- package/dist/handler/commands/status.js.map +1 -0
- package/dist/handler/commands/sync.d.ts +3 -0
- package/dist/handler/commands/sync.d.ts.map +1 -0
- package/dist/handler/commands/sync.js +26 -0
- package/dist/handler/commands/sync.js.map +1 -0
- package/dist/handler/commands/tasks.d.ts +10 -0
- package/dist/handler/commands/tasks.d.ts.map +1 -0
- package/dist/handler/commands/tasks.js +58 -0
- package/dist/handler/commands/tasks.js.map +1 -0
- package/dist/handler/commands/utils.d.ts +10 -0
- package/dist/handler/commands/utils.d.ts.map +1 -0
- package/dist/handler/commands/utils.js +63 -0
- package/dist/handler/commands/utils.js.map +1 -0
- package/dist/handler/commands/workspace.d.ts +10 -0
- package/dist/handler/commands/workspace.d.ts.map +1 -0
- package/dist/handler/commands/workspace.js +80 -0
- package/dist/handler/commands/workspace.js.map +1 -0
- package/dist/handler/dedup.d.ts +3 -0
- package/dist/handler/dedup.d.ts.map +1 -0
- package/dist/handler/dedup.js +29 -0
- package/dist/handler/dedup.js.map +1 -0
- package/dist/handler/index.d.ts +21 -0
- package/dist/handler/index.d.ts.map +1 -0
- package/dist/handler/index.js +189 -0
- package/dist/handler/index.js.map +1 -0
- package/dist/handler/parse.d.ts +30 -0
- package/dist/handler/parse.d.ts.map +1 -0
- package/dist/handler/parse.js +57 -0
- package/dist/handler/parse.js.map +1 -0
- package/dist/handler/session/agent.d.ts +10 -0
- package/dist/handler/session/agent.d.ts.map +1 -0
- package/dist/handler/session/agent.js +63 -0
- package/dist/handler/session/agent.js.map +1 -0
- package/dist/handler/session/model.d.ts +10 -0
- package/dist/handler/session/model.d.ts.map +1 -0
- package/dist/handler/session/model.js +63 -0
- package/dist/handler/session/model.js.map +1 -0
- package/dist/handler/session/new.d.ts +3 -0
- package/dist/handler/session/new.d.ts.map +1 -0
- package/dist/handler/session/new.js +25 -0
- package/dist/handler/session/new.js.map +1 -0
- package/dist/handler/session/session.d.ts +9 -0
- package/dist/handler/session/session.d.ts.map +1 -0
- package/dist/handler/session/session.js +55 -0
- package/dist/handler/session/session.js.map +1 -0
- package/dist/handler/session/workspace.d.ts +10 -0
- package/dist/handler/session/workspace.d.ts.map +1 -0
- package/dist/handler/session/workspace.js +80 -0
- package/dist/handler/session/workspace.js.map +1 -0
- package/dist/handler/shell/git.d.ts +3 -0
- package/dist/handler/shell/git.d.ts.map +1 -0
- package/dist/handler/shell/git.js +25 -0
- package/dist/handler/shell/git.js.map +1 -0
- package/dist/handler/shell/runShell.d.ts +7 -0
- package/dist/handler/shell/runShell.d.ts.map +1 -0
- package/dist/handler/shell/runShell.js +42 -0
- package/dist/handler/shell/runShell.js.map +1 -0
- package/dist/handler/shell/utils.d.ts +10 -0
- package/dist/handler/shell/utils.d.ts.map +1 -0
- package/dist/handler/shell/utils.js +63 -0
- package/dist/handler/shell/utils.js.map +1 -0
- package/dist/handler/streamHandler.d.ts +9 -0
- package/dist/handler/streamHandler.d.ts.map +1 -0
- package/dist/handler/streamHandler.js +49 -0
- package/dist/handler/streamHandler.js.map +1 -0
- package/dist/handler/types.d.ts +36 -0
- package/dist/handler/types.d.ts.map +1 -0
- package/dist/handler/types.js +3 -0
- package/dist/handler/types.js.map +1 -0
- package/dist/handlers/messageHandler.d.ts +3 -0
- package/dist/handlers/messageHandler.d.ts.map +1 -0
- package/dist/handlers/messageHandler.js +249 -0
- package/dist/handlers/messageHandler.js.map +1 -0
- package/dist/handlers/messageHandlerOfficial.d.ts +2 -0
- package/dist/handlers/messageHandlerOfficial.d.ts.map +1 -0
- package/dist/handlers/messageHandlerOfficial.js +302 -0
- package/dist/handlers/messageHandlerOfficial.js.map +1 -0
- package/dist/handlers/messageHandlerV2.d.ts +2 -0
- package/dist/handlers/messageHandlerV2.d.ts.map +1 -0
- package/dist/handlers/messageHandlerV2.js +250 -0
- package/dist/handlers/messageHandlerV2.js.map +1 -0
- package/dist/helloWorld.d.ts +5 -0
- package/dist/helloWorld.d.ts.map +1 -0
- package/dist/helloWorld.js +19 -0
- package/dist/helloWorld.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/indexOfficial.d.ts +4 -0
- package/dist/indexOfficial.d.ts.map +1 -0
- package/dist/indexOfficial.js +92 -0
- package/dist/indexOfficial.js.map +1 -0
- package/dist/indexV2.d.ts +4 -0
- package/dist/indexV2.d.ts.map +1 -0
- package/dist/indexV2.js +109 -0
- package/dist/indexV2.js.map +1 -0
- package/dist/runtime/cliTools.d.ts +17 -0
- package/dist/runtime/cliTools.d.ts.map +1 -0
- package/dist/runtime/cliTools.js +97 -0
- package/dist/runtime/cliTools.js.map +1 -0
- package/dist/runtime/executor.d.ts +27 -0
- package/dist/runtime/executor.d.ts.map +1 -0
- package/dist/runtime/executor.js +108 -0
- package/dist/runtime/executor.js.map +1 -0
- package/dist/runtime/sessionManager.d.ts +42 -0
- package/dist/runtime/sessionManager.d.ts.map +1 -0
- package/dist/runtime/sessionManager.js +161 -0
- package/dist/runtime/sessionManager.js.map +1 -0
- package/dist/runtime/streamHandler.d.ts +9 -0
- package/dist/runtime/streamHandler.d.ts.map +1 -0
- package/dist/runtime/streamHandler.js +49 -0
- package/dist/runtime/streamHandler.js.map +1 -0
- package/dist/runtime/taskManager.d.ts +26 -0
- package/dist/runtime/taskManager.d.ts.map +1 -0
- package/dist/runtime/taskManager.js +153 -0
- package/dist/runtime/taskManager.js.map +1 -0
- package/dist/runtime/tools/base.d.ts +81 -0
- package/dist/runtime/tools/base.d.ts.map +1 -0
- package/dist/runtime/tools/base.js +100 -0
- package/dist/runtime/tools/base.js.map +1 -0
- package/dist/runtime/tools/claudecode.d.ts +19 -0
- package/dist/runtime/tools/claudecode.d.ts.map +1 -0
- package/dist/runtime/tools/claudecode.js +59 -0
- package/dist/runtime/tools/claudecode.js.map +1 -0
- package/dist/runtime/tools/codex.d.ts +19 -0
- package/dist/runtime/tools/codex.d.ts.map +1 -0
- package/dist/runtime/tools/codex.js +68 -0
- package/dist/runtime/tools/codex.js.map +1 -0
- package/dist/runtime/tools/cursor.d.ts +15 -0
- package/dist/runtime/tools/cursor.d.ts.map +1 -0
- package/dist/runtime/tools/cursor.js +33 -0
- package/dist/runtime/tools/cursor.js.map +1 -0
- package/dist/runtime/tools/cursorcode.d.ts +20 -0
- package/dist/runtime/tools/cursorcode.d.ts.map +1 -0
- package/dist/runtime/tools/cursorcode.js +99 -0
- package/dist/runtime/tools/cursorcode.js.map +1 -0
- package/dist/runtime/tools/geminicode.d.ts +20 -0
- package/dist/runtime/tools/geminicode.d.ts.map +1 -0
- package/dist/runtime/tools/geminicode.js +65 -0
- package/dist/runtime/tools/geminicode.js.map +1 -0
- package/dist/runtime/tools/index.d.ts +11 -0
- package/dist/runtime/tools/index.d.ts.map +1 -0
- package/dist/runtime/tools/index.js +36 -0
- package/dist/runtime/tools/index.js.map +1 -0
- package/dist/runtime/tools/kimi.d.ts +16 -0
- package/dist/runtime/tools/kimi.d.ts.map +1 -0
- package/dist/runtime/tools/kimi.js +32 -0
- package/dist/runtime/tools/kimi.js.map +1 -0
- package/dist/runtime/tools/kimicode.d.ts +16 -0
- package/dist/runtime/tools/kimicode.d.ts.map +1 -0
- package/dist/runtime/tools/kimicode.js +43 -0
- package/dist/runtime/tools/kimicode.js.map +1 -0
- package/dist/runtime/tools/nanobot.d.ts +19 -0
- package/dist/runtime/tools/nanobot.d.ts.map +1 -0
- package/dist/runtime/tools/nanobot.js +94 -0
- package/dist/runtime/tools/nanobot.js.map +1 -0
- package/dist/runtime/tools/openaicodex.d.ts +17 -0
- package/dist/runtime/tools/openaicodex.d.ts.map +1 -0
- package/dist/runtime/tools/openaicodex.js +54 -0
- package/dist/runtime/tools/openaicodex.js.map +1 -0
- package/dist/runtime/tools/openclaw.d.ts +24 -0
- package/dist/runtime/tools/openclaw.d.ts.map +1 -0
- package/dist/runtime/tools/openclaw.js +88 -0
- package/dist/runtime/tools/openclaw.js.map +1 -0
- package/dist/runtime/tools/opencode.d.ts +23 -0
- package/dist/runtime/tools/opencode.d.ts.map +1 -0
- package/dist/runtime/tools/opencode.js +82 -0
- package/dist/runtime/tools/opencode.js.map +1 -0
- package/dist/runtime/tools/qwencode.d.ts +17 -0
- package/dist/runtime/tools/qwencode.d.ts.map +1 -0
- package/dist/runtime/tools/qwencode.js +49 -0
- package/dist/runtime/tools/qwencode.js.map +1 -0
- package/dist/runtime/tools/registerAll.d.ts +9 -0
- package/dist/runtime/tools/registerAll.d.ts.map +1 -0
- package/dist/runtime/tools/registerAll.js +29 -0
- package/dist/runtime/tools/registerAll.js.map +1 -0
- package/dist/runtime/tools/registry.d.ts +21 -0
- package/dist/runtime/tools/registry.d.ts.map +1 -0
- package/dist/runtime/tools/registry.js +41 -0
- package/dist/runtime/tools/registry.js.map +1 -0
- package/dist/runtime/tools/types.d.ts +67 -0
- package/dist/runtime/tools/types.d.ts.map +1 -0
- package/dist/runtime/tools/types.js +3 -0
- package/dist/runtime/tools/types.js.map +1 -0
- package/dist/services/cliTools.d.ts +32 -0
- package/dist/services/cliTools.d.ts.map +1 -0
- package/dist/services/cliTools.js +149 -0
- package/dist/services/cliTools.js.map +1 -0
- package/dist/services/commandExecutor.d.ts +29 -0
- package/dist/services/commandExecutor.d.ts.map +1 -0
- package/dist/services/commandExecutor.js +125 -0
- package/dist/services/commandExecutor.js.map +1 -0
- package/dist/services/commandExecutor.test.d.ts +2 -0
- package/dist/services/commandExecutor.test.d.ts.map +1 -0
- package/dist/services/commandExecutor.test.js +54 -0
- package/dist/services/commandExecutor.test.js.map +1 -0
- package/dist/services/feishuService.d.ts +14 -0
- package/dist/services/feishuService.d.ts.map +1 -0
- package/dist/services/feishuService.js +103 -0
- package/dist/services/feishuService.js.map +1 -0
- package/dist/services/feishuServiceOfficial.d.ts +15 -0
- package/dist/services/feishuServiceOfficial.d.ts.map +1 -0
- package/dist/services/feishuServiceOfficial.js +167 -0
- package/dist/services/feishuServiceOfficial.js.map +1 -0
- package/dist/services/feishuServiceV2.d.ts +20 -0
- package/dist/services/feishuServiceV2.d.ts.map +1 -0
- package/dist/services/feishuServiceV2.js +222 -0
- package/dist/services/feishuServiceV2.js.map +1 -0
- package/dist/services/taskManager.d.ts +25 -0
- package/dist/services/taskManager.d.ts.map +1 -0
- package/dist/services/taskManager.js +129 -0
- package/dist/services/taskManager.js.map +1 -0
- package/dist/services/taskManagerSimple.d.ts +25 -0
- package/dist/services/taskManagerSimple.d.ts.map +1 -0
- package/dist/services/taskManagerSimple.js +147 -0
- package/dist/services/taskManagerSimple.js.map +1 -0
- package/dist/testHelloWorld.d.ts +2 -0
- package/dist/testHelloWorld.d.ts.map +1 -0
- package/dist/testHelloWorld.js +18 -0
- package/dist/testHelloWorld.js.map +1 -0
- package/dist/utils/encoding.d.ts +3 -0
- package/dist/utils/encoding.d.ts.map +1 -0
- package/dist/utils/encoding.js +110 -0
- package/dist/utils/encoding.js.map +1 -0
- package/dist/utils/logger.d.ts +19 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +192 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/shellEncoding.d.ts +5 -0
- package/dist/utils/shellEncoding.d.ts.map +1 -0
- package/dist/utils/shellEncoding.js +117 -0
- package/dist/utils/shellEncoding.js.map +1 -0
- package/openbotgate.example.yml +60 -0
- package/package.json +81 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.run = run;
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const sessionManager_1 = require("../../runtime/sessionManager");
|
|
42
|
+
const logger_1 = __importDefault(require("../../utils/logger"));
|
|
43
|
+
/**
|
|
44
|
+
* /workspace command - set or view working directory
|
|
45
|
+
*
|
|
46
|
+
* /workspace -> show current cwd
|
|
47
|
+
* /workspace <path> -> set cwd
|
|
48
|
+
* /workspace reset -> reset to default (process.cwd())
|
|
49
|
+
*/
|
|
50
|
+
async function run(ctx) {
|
|
51
|
+
const args = ctx.args.trim();
|
|
52
|
+
const session = sessionManager_1.sessionManager.getSession(ctx.senderId);
|
|
53
|
+
// Reset
|
|
54
|
+
if (args.toLowerCase() === 'reset') {
|
|
55
|
+
sessionManager_1.sessionManager.updateSession(ctx.senderId, { cwd: null });
|
|
56
|
+
await ctx.reply(`Workspace reset to default: ${process.cwd()}`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// Set workspace
|
|
60
|
+
if (args) {
|
|
61
|
+
// Validate path exists
|
|
62
|
+
if (!fs.existsSync(args)) {
|
|
63
|
+
await ctx.reply(`Path does not exist: ${args}`);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const stat = fs.statSync(args);
|
|
67
|
+
if (!stat.isDirectory()) {
|
|
68
|
+
await ctx.reply(`Path is not a directory: ${args}`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
sessionManager_1.sessionManager.updateSession(ctx.senderId, { cwd: args });
|
|
72
|
+
logger_1.default.info(`📂 Workspace set to: ${args}`);
|
|
73
|
+
await ctx.reply(`Workspace set to: ${args}`);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
// Show current
|
|
77
|
+
const cwd = session.cwd || process.cwd();
|
|
78
|
+
await ctx.reply(`Current workspace: ${cwd}${session.cwd ? '' : ' (default)'}`);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../../src/handler/session/workspace.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,kBAkCC;AA9CD,uCAAyB;AAEzB,iEAA8D;AAC9D,gEAAwC;AAExC;;;;;;GAMG;AACI,KAAK,UAAU,GAAG,CAAC,GAAmB;IAC3C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,+BAAc,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAExD,QAAQ;IACR,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE,CAAC;QACnC,+BAAc,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,MAAM,GAAG,CAAC,KAAK,CAAC,+BAA+B,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAChE,OAAO;IACT,CAAC;IAED,gBAAgB;IAChB,IAAI,IAAI,EAAE,CAAC;QACT,uBAAuB;QACvB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,GAAG,CAAC,KAAK,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;YAChD,OAAO;QACT,CAAC;QAED,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,MAAM,GAAG,CAAC,KAAK,CAAC,4BAA4B,IAAI,EAAE,CAAC,CAAC;YACpD,OAAO;QACT,CAAC;QAED,+BAAc,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,gBAAM,CAAC,IAAI,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;QAC5C,MAAM,GAAG,CAAC,KAAK,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;QAC7C,OAAO;IACT,CAAC;IAED,eAAe;IACf,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACzC,MAAM,GAAG,CAAC,KAAK,CAAC,sBAAsB,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../../src/handler/shell/git.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAK/C,wBAAsB,GAAG,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB5D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.run = run;
|
|
7
|
+
const taskManager_1 = require("../../runtime/taskManager");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
const logger_1 = __importDefault(require("../../utils/logger"));
|
|
10
|
+
async function run(ctx) {
|
|
11
|
+
const command = ctx.args.trim();
|
|
12
|
+
if (!command) {
|
|
13
|
+
logger_1.default.info('💬 Reply: Usage: /git <command>');
|
|
14
|
+
await ctx.reply('Usage: /git <command>\nExample: /git status');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
logger_1.default.info('🚀 Running Git...');
|
|
18
|
+
// await ctx.reply('🔧 Running Git...');
|
|
19
|
+
const task = await taskManager_1.taskManager.createTask(ctx.senderId, command, 'git');
|
|
20
|
+
const result = await taskManager_1.taskManager.executeTask(task.id);
|
|
21
|
+
if (result) {
|
|
22
|
+
await (0, utils_1.sendResult)(result, ctx.reply);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/handler/shell/git.ts"],"names":[],"mappings":";;;;;AAKA,kBAkBC;AAtBD,2DAAwD;AACxD,mCAAqC;AACrC,gEAAwC;AAEjC,KAAK,UAAU,GAAG,CAAC,GAAmB;IAC3C,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAEhC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,gBAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAC/C,MAAM,GAAG,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;QAC/D,OAAO;IACT,CAAC;IAED,gBAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACjC,wCAAwC;IAExC,MAAM,IAAI,GAAG,MAAM,yBAAW,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACxE,MAAM,MAAM,GAAG,MAAM,yBAAW,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEtD,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,IAAA,kBAAU,EAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CommandContext } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a command handler that runs the given shell command name (e.g. 'git', 'ls').
|
|
4
|
+
* Used when getCommand finds the slash command in allowedShellCommands but not in the static commands map.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createShellHandler(commandName: string): (ctx: CommandContext) => Promise<void>;
|
|
7
|
+
//# sourceMappingURL=runShell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runShell.d.ts","sourceRoot":"","sources":["../../../src/handler/shell/runShell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAoC/C;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,IAC5C,KAAK,cAAc,mBAC5B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createShellHandler = createShellHandler;
|
|
7
|
+
const taskManager_1 = require("../../runtime/taskManager");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
const config_1 = require("../../config/config");
|
|
10
|
+
const logger_1 = __importDefault(require("../../utils/logger"));
|
|
11
|
+
/**
|
|
12
|
+
* Run a shell command (allowed by config.allowedShellCommands).
|
|
13
|
+
* For "git", tool is 'git' and command is args only.
|
|
14
|
+
* For others (e.g. ls, cat), tool is 'shell' and command is "name args".
|
|
15
|
+
*/
|
|
16
|
+
async function runShell(ctx, commandName) {
|
|
17
|
+
if (!config_1.config.allowedShellCommands.includes(commandName)) {
|
|
18
|
+
await ctx.reply(`Command "${commandName}" is not in allowed shell commands.`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const isGit = commandName === 'git';
|
|
22
|
+
const command = isGit ? ctx.args.trim() : (commandName + ' ' + ctx.args.trim()).trim();
|
|
23
|
+
if (isGit && !command) {
|
|
24
|
+
await ctx.reply('Usage: /git <command>\nExample: /git status');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
logger_1.default.info(`🚀 Running ${commandName}...`);
|
|
28
|
+
const tool = isGit ? 'git' : 'shell';
|
|
29
|
+
const task = await taskManager_1.taskManager.createTask(ctx.senderId, command, tool);
|
|
30
|
+
const result = await taskManager_1.taskManager.executeTask(task.id);
|
|
31
|
+
if (result) {
|
|
32
|
+
await (0, utils_1.sendResult)(result, ctx.reply);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns a command handler that runs the given shell command name (e.g. 'git', 'ls').
|
|
37
|
+
* Used when getCommand finds the slash command in allowedShellCommands but not in the static commands map.
|
|
38
|
+
*/
|
|
39
|
+
function createShellHandler(commandName) {
|
|
40
|
+
return (ctx) => runShell(ctx, commandName);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=runShell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runShell.js","sourceRoot":"","sources":["../../../src/handler/shell/runShell.ts"],"names":[],"mappings":";;;;;AAwCA,gDAEC;AAzCD,2DAAwD;AACxD,mCAAqC;AACrC,gDAA6C;AAC7C,gEAAwC;AAExC;;;;GAIG;AACH,KAAK,UAAU,QAAQ,CAAC,GAAmB,EAAE,WAAmB;IAC9D,IAAI,CAAC,eAAM,CAAC,oBAAoB,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACvD,MAAM,GAAG,CAAC,KAAK,CAAC,YAAY,WAAW,qCAAqC,CAAC,CAAC;QAC9E,OAAO;IACT,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,KAAK,KAAK,CAAC;IACpC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAEvF,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;QACtB,MAAM,GAAG,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;QAC/D,OAAO;IACT,CAAC;IAED,gBAAM,CAAC,IAAI,CAAC,cAAc,WAAW,KAAK,CAAC,CAAC;IAE5C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;IACrC,MAAM,IAAI,GAAG,MAAM,yBAAW,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACvE,MAAM,MAAM,GAAG,MAAM,yBAAW,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEtD,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,IAAA,kBAAU,EAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,WAAmB;IACpD,OAAO,CAAC,GAAmB,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ToolResult } from '../../runtime/tools/base';
|
|
2
|
+
/**
|
|
3
|
+
* Format and send execution result
|
|
4
|
+
*/
|
|
5
|
+
export declare function sendResult(result: ToolResult, reply: (text: string) => Promise<void>): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Split string into chunks at newline boundaries
|
|
8
|
+
*/
|
|
9
|
+
export declare function splitString(str: string, maxLength: number): string[];
|
|
10
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/handler/shell/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG3D;;GAEG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GACrC,OAAO,CAAC,IAAI,CAAC,CAmCf;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAoBpE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.sendResult = sendResult;
|
|
7
|
+
exports.splitString = splitString;
|
|
8
|
+
const logger_1 = __importDefault(require("../../utils/logger"));
|
|
9
|
+
/**
|
|
10
|
+
* Format and send execution result
|
|
11
|
+
*/
|
|
12
|
+
async function sendResult(result, reply) {
|
|
13
|
+
const output = result.success ? result.output : result.error;
|
|
14
|
+
if (!output || output.trim() === '') {
|
|
15
|
+
if (process.env.DEBUG === 'true') {
|
|
16
|
+
logger_1.default.debug(`No output from ${result.tool}.`);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
logger_1.default.info(`💬 Reply: No output from ${result.tool}.`);
|
|
20
|
+
await reply(`No output from ${result.tool}.`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const maxLength = 8000;
|
|
24
|
+
const chunks = splitString(output, maxLength);
|
|
25
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
26
|
+
const prefix = i === 0
|
|
27
|
+
? `📦 *${result.tool} Output* (${result.duration}ms)\n\n`
|
|
28
|
+
: '';
|
|
29
|
+
const messageContent = prefix + chunks[i];
|
|
30
|
+
if (process.env.DEBUG === 'true') {
|
|
31
|
+
logger_1.default.debug(messageContent);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
logger_1.default.info(`💬 Reply: ${result.tool} output chunk ${i + 1}/${chunks.length}`);
|
|
35
|
+
await reply(messageContent);
|
|
36
|
+
}
|
|
37
|
+
// Rate limiting
|
|
38
|
+
if (i < chunks.length - 1) {
|
|
39
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Split string into chunks at newline boundaries
|
|
45
|
+
*/
|
|
46
|
+
function splitString(str, maxLength) {
|
|
47
|
+
const chunks = [];
|
|
48
|
+
let remaining = str;
|
|
49
|
+
while (remaining.length > 0) {
|
|
50
|
+
if (remaining.length <= maxLength) {
|
|
51
|
+
chunks.push(remaining);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
let splitIndex = remaining.lastIndexOf('\n', maxLength);
|
|
55
|
+
if (splitIndex === -1) {
|
|
56
|
+
splitIndex = maxLength;
|
|
57
|
+
}
|
|
58
|
+
chunks.push(remaining.substring(0, splitIndex));
|
|
59
|
+
remaining = remaining.substring(splitIndex + 1);
|
|
60
|
+
}
|
|
61
|
+
return chunks;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/handler/shell/utils.ts"],"names":[],"mappings":";;;;;AAMA,gCAsCC;AAKD,kCAoBC;AApED,gEAAwC;AAExC;;GAEG;AACI,KAAK,UAAU,UAAU,CAC9B,MAAkB,EAClB,KAAsC;IAEtC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IAE7D,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACpC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;YACjC,gBAAM,CAAC,KAAK,CAAC,kBAAkB,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;YAC/C,OAAO;QACT,CAAC;QACD,gBAAM,CAAC,IAAI,CAAC,4BAA4B,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;QACxD,MAAM,KAAK,CAAC,kBAAkB,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;QAC9C,OAAO;IACT,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC;IACvB,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAE9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC;YACpB,CAAC,CAAC,OAAO,MAAM,CAAC,IAAI,aAAa,MAAM,CAAC,QAAQ,SAAS;YACzD,CAAC,CAAC,EAAE,CAAC;QAEP,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAE1C,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;YACjC,gBAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,gBAAM,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YAC/E,MAAM,KAAK,CAAC,cAAc,CAAC,CAAC;QAC9B,CAAC;QAED,gBAAgB;QAChB,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,GAAW,EAAE,SAAiB;IACxD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,SAAS,GAAG,GAAG,CAAC;IAEpB,OAAO,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,IAAI,SAAS,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;YAClC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACvB,MAAM;QACR,CAAC;QAED,IAAI,UAAU,GAAG,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACxD,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;YACtB,UAAU,GAAG,SAAS,CAAC;QACzB,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;QAChD,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a throttled stream handler that batches output and sends periodically.
|
|
3
|
+
* Used by code commands (e.g. opencode) for streaming tool output to Feishu.
|
|
4
|
+
*/
|
|
5
|
+
export declare function createStreamHandler(reply: (text: string) => Promise<void>): {
|
|
6
|
+
onOutput: (chunk: string) => void;
|
|
7
|
+
complete: () => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=streamHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamHandler.d.ts","sourceRoot":"","sources":["../../src/handler/streamHandler.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;sBAc/C,MAAM;;EA6BhC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStreamHandler = createStreamHandler;
|
|
4
|
+
/** Throttle interval for streaming output (ms) */
|
|
5
|
+
const STREAM_THROTTLE_MS = 1000;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a throttled stream handler that batches output and sends periodically.
|
|
8
|
+
* Used by code commands (e.g. opencode) for streaming tool output to Feishu.
|
|
9
|
+
*/
|
|
10
|
+
function createStreamHandler(reply) {
|
|
11
|
+
let buffer = '';
|
|
12
|
+
let lastSendTime = 0;
|
|
13
|
+
let pendingTimeout = null;
|
|
14
|
+
const flush = async () => {
|
|
15
|
+
if (buffer) {
|
|
16
|
+
const content = buffer;
|
|
17
|
+
buffer = '';
|
|
18
|
+
lastSendTime = Date.now();
|
|
19
|
+
await reply(content).catch(() => { });
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const onOutput = (chunk) => {
|
|
23
|
+
buffer += (buffer ? '\n' : '') + chunk;
|
|
24
|
+
const now = Date.now();
|
|
25
|
+
const timeSinceLastSend = now - lastSendTime;
|
|
26
|
+
if (timeSinceLastSend >= STREAM_THROTTLE_MS) {
|
|
27
|
+
if (pendingTimeout) {
|
|
28
|
+
clearTimeout(pendingTimeout);
|
|
29
|
+
pendingTimeout = null;
|
|
30
|
+
}
|
|
31
|
+
flush();
|
|
32
|
+
}
|
|
33
|
+
else if (!pendingTimeout) {
|
|
34
|
+
pendingTimeout = setTimeout(() => {
|
|
35
|
+
pendingTimeout = null;
|
|
36
|
+
flush();
|
|
37
|
+
}, STREAM_THROTTLE_MS - timeSinceLastSend);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const complete = async () => {
|
|
41
|
+
if (pendingTimeout) {
|
|
42
|
+
clearTimeout(pendingTimeout);
|
|
43
|
+
pendingTimeout = null;
|
|
44
|
+
}
|
|
45
|
+
await flush();
|
|
46
|
+
};
|
|
47
|
+
return { onOutput, complete };
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=streamHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamHandler.js","sourceRoot":"","sources":["../../src/handler/streamHandler.ts"],"names":[],"mappings":";;AAOA,kDA2CC;AAlDD,kDAAkD;AAClD,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,KAAsC;IACxE,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,cAAc,GAA0B,IAAI,CAAC;IAEjD,MAAM,KAAK,GAAG,KAAK,IAAI,EAAE;QACvB,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,OAAO,GAAG,MAAM,CAAC;YACvB,MAAM,GAAG,EAAE,CAAC;YACZ,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAC1B,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACvC,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE;QACjC,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;QAEvC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,iBAAiB,GAAG,GAAG,GAAG,YAAY,CAAC;QAE7C,IAAI,iBAAiB,IAAI,kBAAkB,EAAE,CAAC;YAC5C,IAAI,cAAc,EAAE,CAAC;gBACnB,YAAY,CAAC,cAAc,CAAC,CAAC;gBAC7B,cAAc,GAAG,IAAI,CAAC;YACxB,CAAC;YACD,KAAK,EAAE,CAAC;QACV,CAAC;aAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAC3B,cAAc,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC/B,cAAc,GAAG,IAAI,CAAC;gBACtB,KAAK,EAAE,CAAC;YACV,CAAC,EAAE,kBAAkB,GAAG,iBAAiB,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;QAC1B,IAAI,cAAc,EAAE,CAAC;YACnB,YAAY,CAAC,cAAc,CAAC,CAAC;YAC7B,cAAc,GAAG,IAAI,CAAC;QACxB,CAAC;QACD,MAAM,KAAK,EAAE,CAAC;IAChB,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsed event from Feishu message
|
|
3
|
+
*/
|
|
4
|
+
export interface ParsedEvent {
|
|
5
|
+
messageId: string;
|
|
6
|
+
chatId: string;
|
|
7
|
+
/** 用于会话标识,优先 open_id */
|
|
8
|
+
senderId: string;
|
|
9
|
+
/** open_id / user_id 分别用于 contact.user.get 不同 id_type */
|
|
10
|
+
senderOpenId?: string;
|
|
11
|
+
senderUserId?: string;
|
|
12
|
+
senderName?: string;
|
|
13
|
+
chatType?: string;
|
|
14
|
+
channel: string;
|
|
15
|
+
text: string;
|
|
16
|
+
messageType: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Command execution context
|
|
20
|
+
*/
|
|
21
|
+
export interface CommandContext {
|
|
22
|
+
senderId: string;
|
|
23
|
+
chatId: string;
|
|
24
|
+
messageId: string;
|
|
25
|
+
/** p2p = 1-on-1, group = group chat (from Feishu chat_type) */
|
|
26
|
+
chatType?: 'p2p' | 'group';
|
|
27
|
+
command: string;
|
|
28
|
+
args: string;
|
|
29
|
+
reply: (text: string) => Promise<void>;
|
|
30
|
+
send: (title: string, content: string) => Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Command handler function type
|
|
34
|
+
*/
|
|
35
|
+
export type CommandHandler = (ctx: CommandContext) => Promise<void>;
|
|
36
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/handler/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACzD;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/handler/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/messageHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAoB5C,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,GACZ,OAAO,CAAC,IAAI,CAAC,CAqCf"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleFeishuWebhook = handleFeishuWebhook;
|
|
4
|
+
const taskManager_1 = require("../services/taskManager");
|
|
5
|
+
const feishuService_1 = require("../services/feishuService");
|
|
6
|
+
async function handleFeishuWebhook(req, res) {
|
|
7
|
+
const payload = req.body;
|
|
8
|
+
// Handle URL verification challenge
|
|
9
|
+
if (payload.challenge) {
|
|
10
|
+
res.json({ challenge: payload.challenge });
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
// Handle event callbacks
|
|
14
|
+
if (payload.type === 'event_callback') {
|
|
15
|
+
const event = payload.event;
|
|
16
|
+
const messageContent = event.message.content;
|
|
17
|
+
const userId = event.message.sender.open_id;
|
|
18
|
+
try {
|
|
19
|
+
const content = JSON.parse(Buffer.from(messageContent, 'base64').toString('utf-8'));
|
|
20
|
+
const text = content.text || '';
|
|
21
|
+
// Handle commands
|
|
22
|
+
if (text.startsWith('/')) {
|
|
23
|
+
await handleCommand(userId, text);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
await handlePrompt(userId, text);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error('Error processing message:', error);
|
|
31
|
+
await feishuService_1.feishuService.sendTextMessage(userId, 'Failed to process your message. Please try again.');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
res.status(200).json({ code: 0 });
|
|
35
|
+
}
|
|
36
|
+
async function handleCommand(userId, command) {
|
|
37
|
+
const parts = command.split(' ');
|
|
38
|
+
const cmd = parts[0].toLowerCase();
|
|
39
|
+
const args = parts.slice(1).join(' ');
|
|
40
|
+
switch (cmd) {
|
|
41
|
+
case '/help':
|
|
42
|
+
await showHelp(userId);
|
|
43
|
+
break;
|
|
44
|
+
case '/status':
|
|
45
|
+
await showStatus(userId);
|
|
46
|
+
break;
|
|
47
|
+
case '/cancel':
|
|
48
|
+
await cancelTask(userId, args);
|
|
49
|
+
break;
|
|
50
|
+
case '/tasks':
|
|
51
|
+
await listTasks(userId);
|
|
52
|
+
break;
|
|
53
|
+
case '/sync':
|
|
54
|
+
await executeSync(userId, args);
|
|
55
|
+
break;
|
|
56
|
+
case '/async':
|
|
57
|
+
await executeAsync(userId, args);
|
|
58
|
+
break;
|
|
59
|
+
case '/opencode':
|
|
60
|
+
await executeOpenCode(userId, args);
|
|
61
|
+
break;
|
|
62
|
+
case '/claude':
|
|
63
|
+
await executeClaudeCode(userId, args);
|
|
64
|
+
break;
|
|
65
|
+
case '/git':
|
|
66
|
+
await executeGit(userId, args);
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
await feishuService_1.feishuService.sendTextMessage(userId, `Unknown command: ${cmd}\nUse /help to see available commands.`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function handlePrompt(userId, prompt) {
|
|
73
|
+
// Default behavior: use opencode for general prompts
|
|
74
|
+
await executeOpenCode(userId, prompt);
|
|
75
|
+
}
|
|
76
|
+
async function showHelp(userId) {
|
|
77
|
+
const helpText = `
|
|
78
|
+
*AI Code Gateway - Help*
|
|
79
|
+
|
|
80
|
+
Available Commands:
|
|
81
|
+
|
|
82
|
+
*Tool Execution:*
|
|
83
|
+
• \`/opencode <prompt>\` - Execute OpenCode with prompt
|
|
84
|
+
• \`/claude <prompt>\` - Execute Claude Code with prompt
|
|
85
|
+
• \`/git <command>\` - Execute Git command
|
|
86
|
+
• \`/shell <command>\` - Execute Shell command (if enabled)
|
|
87
|
+
|
|
88
|
+
*Execution Mode:*
|
|
89
|
+
• \`/sync <tool> <command>\` - Execute synchronously, wait for result
|
|
90
|
+
• \`/async <tool> <command>\` - Execute asynchronously, notify when done
|
|
91
|
+
|
|
92
|
+
*Task Management:*
|
|
93
|
+
• \`/status\` - Show system status
|
|
94
|
+
• \`/tasks\` - List your running tasks
|
|
95
|
+
• \`/cancel <task_id>\` - Cancel a running task
|
|
96
|
+
|
|
97
|
+
*Examples:*
|
|
98
|
+
• \`/opencode Write a function to calculate fibonacci\`
|
|
99
|
+
• \`/git status\`
|
|
100
|
+
• \`/sync opencode Summarize this code\`
|
|
101
|
+
• \`/async claude Generate unit tests for all files\`
|
|
102
|
+
`;
|
|
103
|
+
await feishuService_1.feishuService.sendRichTextMessage(userId, 'AI Code Gateway Help', helpText);
|
|
104
|
+
}
|
|
105
|
+
async function showStatus(userId) {
|
|
106
|
+
const statusText = `
|
|
107
|
+
*AI Code Gateway - Status*
|
|
108
|
+
|
|
109
|
+
✅ Gateway is running
|
|
110
|
+
✅ Connected to Feishu
|
|
111
|
+
🟡 Task queue: Active
|
|
112
|
+
|
|
113
|
+
Use /tasks to see your running tasks.
|
|
114
|
+
`;
|
|
115
|
+
await feishuService_1.feishuService.sendRichTextMessage(userId, 'System Status', statusText);
|
|
116
|
+
}
|
|
117
|
+
async function listTasks(userId) {
|
|
118
|
+
const tasks = taskManager_1.taskManager.getUserTasks(userId);
|
|
119
|
+
if (tasks.length === 0) {
|
|
120
|
+
await feishuService_1.feishuService.sendTextMessage(userId, 'No running tasks.');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const taskList = tasks
|
|
124
|
+
.filter((t) => t.status === 'running' || t.status === 'pending')
|
|
125
|
+
.map((t) => `• [${t.status.toUpperCase()}] ${t.tool}: ${t.command.substring(0, 50)}... (ID: ${t.id})`)
|
|
126
|
+
.join('\n');
|
|
127
|
+
await feishuService_1.feishuService.sendRichTextMessage(userId, 'Your Tasks', taskList || 'No active tasks.');
|
|
128
|
+
}
|
|
129
|
+
async function cancelTask(userId, taskId) {
|
|
130
|
+
const task = taskManager_1.taskManager.getTask(taskId);
|
|
131
|
+
if (!task) {
|
|
132
|
+
await feishuService_1.feishuService.sendTextMessage(userId, `Task ${taskId} not found.`);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (task.userId !== userId) {
|
|
136
|
+
await feishuService_1.feishuService.sendTextMessage(userId, 'You can only cancel your own tasks.');
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const success = taskManager_1.taskManager.cancelTask(taskId);
|
|
140
|
+
if (success) {
|
|
141
|
+
await feishuService_1.feishuService.sendTextMessage(userId, `Task ${taskId} has been cancelled.`);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
await feishuService_1.feishuService.sendTextMessage(userId, `Failed to cancel task ${taskId}.`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async function executeSync(userId, args) {
|
|
148
|
+
const [tool, ...commandParts] = args.split(' ');
|
|
149
|
+
const command = commandParts.join(' ');
|
|
150
|
+
if (!tool || !command) {
|
|
151
|
+
await feishuService_1.feishuService.sendTextMessage(userId, 'Usage: /sync <tool> <command>\nExample: /sync opencode Hello');
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
await feishuService_1.feishuService.sendTextMessage(userId, `Executing ${tool} synchronously...`);
|
|
155
|
+
const result = await taskManager_1.taskManager.createTask(userId, command, tool.toLowerCase());
|
|
156
|
+
const executionResult = await taskManager_1.taskManager.executeTask(result.id);
|
|
157
|
+
if (executionResult) {
|
|
158
|
+
await sendResult(userId, executionResult);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async function executeAsync(userId, args) {
|
|
162
|
+
const [tool, ...commandParts] = args.split(' ');
|
|
163
|
+
const command = commandParts.join(' ');
|
|
164
|
+
if (!tool || !command) {
|
|
165
|
+
await feishuService_1.feishuService.sendTextMessage(userId, 'Usage: /async <tool> <command>\nExample: /async opencode Complex task');
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
await feishuService_1.feishuService.sendTextMessage(userId, `Executing ${tool} asynchronously...`);
|
|
169
|
+
const task = await taskManager_1.taskManager.createTask(userId, command, tool.toLowerCase());
|
|
170
|
+
// Execute in background and notify when done
|
|
171
|
+
taskManager_1.taskManager.executeTask(task.id).then(async (result) => {
|
|
172
|
+
if (result) {
|
|
173
|
+
await feishuService_1.feishuService.sendTextMessage(userId, `✅ Task completed! ID: ${task.id}\n\nUse /tasks to view results.`);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
await feishuService_1.feishuService.sendTextMessage(userId, `Task started! ID: ${task.id}\nI'll notify you when it's complete.`);
|
|
177
|
+
}
|
|
178
|
+
async function executeOpenCode(userId, prompt) {
|
|
179
|
+
if (!prompt.trim()) {
|
|
180
|
+
await feishuService_1.feishuService.sendTextMessage(userId, 'Usage: /opencode <prompt>\nExample: /opencode Write a hello world function');
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
await feishuService_1.feishuService.sendTextMessage(userId, '🤖 Running OpenCode...');
|
|
184
|
+
const result = await taskManager_1.taskManager.createTask(userId, prompt, 'opencode');
|
|
185
|
+
const executionResult = await taskManager_1.taskManager.executeTask(result.id);
|
|
186
|
+
if (executionResult) {
|
|
187
|
+
await sendResult(userId, executionResult);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
async function executeClaudeCode(userId, prompt) {
|
|
191
|
+
if (!prompt.trim()) {
|
|
192
|
+
await feishuService_1.feishuService.sendTextMessage(userId, 'Usage: /claude <prompt>\nExample: /claude Write a unit test');
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
await feishuService_1.feishuService.sendTextMessage(userId, '🤖 Running Claude Code...');
|
|
196
|
+
const result = await taskManager_1.taskManager.createTask(userId, prompt, 'claude-code');
|
|
197
|
+
const executionResult = await taskManager_1.taskManager.executeTask(result.id);
|
|
198
|
+
if (executionResult) {
|
|
199
|
+
await sendResult(userId, executionResult);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async function executeGit(userId, command) {
|
|
203
|
+
if (!command.trim()) {
|
|
204
|
+
await feishuService_1.feishuService.sendTextMessage(userId, 'Usage: /git <command>\nExample: /git status');
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
await feishuService_1.feishuService.sendTextMessage(userId, '🔧 Running Git...');
|
|
208
|
+
const result = await taskManager_1.taskManager.createTask(userId, command, 'git');
|
|
209
|
+
const executionResult = await taskManager_1.taskManager.executeTask(result.id);
|
|
210
|
+
if (executionResult) {
|
|
211
|
+
await sendResult(userId, executionResult);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
async function sendResult(userId, result) {
|
|
215
|
+
const output = result.success ? result.output : result.error;
|
|
216
|
+
if (!output || output.trim() === '') {
|
|
217
|
+
await feishuService_1.feishuService.sendTextMessage(userId, `No output from ${result.tool}.`);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
// Send in chunks if too long
|
|
221
|
+
const maxLength = 8000;
|
|
222
|
+
const chunks = splitString(output, maxLength);
|
|
223
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
224
|
+
const prefix = i === 0 ? `📦 *${result.tool} Output* (${result.duration}ms)\n\n` : '';
|
|
225
|
+
await feishuService_1.feishuService.sendTextMessage(userId, prefix + chunks[i]);
|
|
226
|
+
// Rate limiting
|
|
227
|
+
if (i < chunks.length - 1) {
|
|
228
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function splitString(str, maxLength) {
|
|
233
|
+
const chunks = [];
|
|
234
|
+
let remaining = str;
|
|
235
|
+
while (remaining.length > 0) {
|
|
236
|
+
if (remaining.length <= maxLength) {
|
|
237
|
+
chunks.push(remaining);
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
let splitIndex = remaining.lastIndexOf('\n', maxLength);
|
|
241
|
+
if (splitIndex === -1) {
|
|
242
|
+
splitIndex = maxLength;
|
|
243
|
+
}
|
|
244
|
+
chunks.push(remaining.substring(0, splitIndex));
|
|
245
|
+
remaining = remaining.substring(splitIndex + 1);
|
|
246
|
+
}
|
|
247
|
+
return chunks;
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=messageHandler.js.map
|