@qlingzzy/qling 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/CHANGELOG.md +122 -0
- package/LICENSE +21 -0
- package/README.en.md +129 -0
- package/README.md +416 -0
- package/dist/agent/subtask.d.ts +21 -0
- package/dist/agent/subtask.d.ts.map +1 -0
- package/dist/agent/subtask.js +55 -0
- package/dist/agent-loop.d.ts +151 -0
- package/dist/agent-loop.d.ts.map +1 -0
- package/dist/agent-loop.js +1498 -0
- package/dist/agents/isolation-policy.d.ts +14 -0
- package/dist/agents/isolation-policy.d.ts.map +1 -0
- package/dist/agents/isolation-policy.js +52 -0
- package/dist/channels/console-channel.d.ts +15 -0
- package/dist/channels/console-channel.d.ts.map +1 -0
- package/dist/channels/console-channel.js +66 -0
- package/dist/channels/registry.d.ts +10 -0
- package/dist/channels/registry.d.ts.map +1 -0
- package/dist/channels/registry.js +25 -0
- package/dist/channels/slack-channel.d.ts +35 -0
- package/dist/channels/slack-channel.d.ts.map +1 -0
- package/dist/channels/slack-channel.js +232 -0
- package/dist/channels/telegram-channel.d.ts +32 -0
- package/dist/channels/telegram-channel.d.ts.map +1 -0
- package/dist/channels/telegram-channel.js +167 -0
- package/dist/channels/types.d.ts +31 -0
- package/dist/channels/types.d.ts.map +1 -0
- package/dist/channels/types.js +4 -0
- package/dist/cli/bootstrap.d.ts +39 -0
- package/dist/cli/bootstrap.d.ts.map +1 -0
- package/dist/cli/bootstrap.js +138 -0
- package/dist/cli/channel-bootstrap.d.ts +23 -0
- package/dist/cli/channel-bootstrap.d.ts.map +1 -0
- package/dist/cli/channel-bootstrap.js +46 -0
- package/dist/cli/daemon-control.d.ts +31 -0
- package/dist/cli/daemon-control.d.ts.map +1 -0
- package/dist/cli/daemon-control.js +177 -0
- package/dist/cli/guidance-panel.d.ts +11 -0
- package/dist/cli/guidance-panel.d.ts.map +1 -0
- package/dist/cli/guidance-panel.js +16 -0
- package/dist/cli/mcp-control.d.ts +7 -0
- package/dist/cli/mcp-control.d.ts.map +1 -0
- package/dist/cli/mcp-control.js +119 -0
- package/dist/cli/mission-views.d.ts +13 -0
- package/dist/cli/mission-views.d.ts.map +1 -0
- package/dist/cli/mission-views.js +82 -0
- package/dist/cli/setup.d.ts +9 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +140 -0
- package/dist/cli/startup-contract.d.ts +23 -0
- package/dist/cli/startup-contract.d.ts.map +1 -0
- package/dist/cli/startup-contract.js +694 -0
- package/dist/commands/agents.d.ts +3 -0
- package/dist/commands/agents.d.ts.map +1 -0
- package/dist/commands/agents.js +44 -0
- package/dist/commands/checkpoint.d.ts +3 -0
- package/dist/commands/checkpoint.d.ts.map +1 -0
- package/dist/commands/checkpoint.js +52 -0
- package/dist/commands/claude-style.d.ts +12 -0
- package/dist/commands/claude-style.d.ts.map +1 -0
- package/dist/commands/claude-style.js +560 -0
- package/dist/commands/clear.d.ts +3 -0
- package/dist/commands/clear.d.ts.map +1 -0
- package/dist/commands/clear.js +20 -0
- package/dist/commands/compact.d.ts +3 -0
- package/dist/commands/compact.d.ts.map +1 -0
- package/dist/commands/compact.js +23 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +22 -0
- package/dist/commands/connect.d.ts +3 -0
- package/dist/commands/connect.d.ts.map +1 -0
- package/dist/commands/connect.js +102 -0
- package/dist/commands/context.d.ts +3 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +13 -0
- package/dist/commands/dashboard.d.ts +3 -0
- package/dist/commands/dashboard.d.ts.map +1 -0
- package/dist/commands/dashboard.js +22 -0
- package/dist/commands/detach.d.ts +3 -0
- package/dist/commands/detach.d.ts.map +1 -0
- package/dist/commands/detach.js +44 -0
- package/dist/commands/distill.d.ts +3 -0
- package/dist/commands/distill.d.ts.map +1 -0
- package/dist/commands/distill.js +23 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +13 -0
- package/dist/commands/dream.d.ts +3 -0
- package/dist/commands/dream.d.ts.map +1 -0
- package/dist/commands/dream.js +59 -0
- package/dist/commands/export.d.ts +3 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +18 -0
- package/dist/commands/exports.d.ts +3 -0
- package/dist/commands/exports.d.ts.map +1 -0
- package/dist/commands/exports.js +15 -0
- package/dist/commands/goal.d.ts +3 -0
- package/dist/commands/goal.d.ts.map +1 -0
- package/dist/commands/goal.js +147 -0
- package/dist/commands/help.d.ts +4 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +75 -0
- package/dist/commands/hooks.d.ts +3 -0
- package/dist/commands/hooks.d.ts.map +1 -0
- package/dist/commands/hooks.js +14 -0
- package/dist/commands/index.d.ts +29 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +417 -0
- package/dist/commands/knowledge.d.ts +8 -0
- package/dist/commands/knowledge.d.ts.map +1 -0
- package/dist/commands/knowledge.js +191 -0
- package/dist/commands/loop.d.ts +3 -0
- package/dist/commands/loop.d.ts.map +1 -0
- package/dist/commands/loop.js +138 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +57 -0
- package/dist/commands/memory.d.ts +3 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +215 -0
- package/dist/commands/mission.d.ts +3 -0
- package/dist/commands/mission.d.ts.map +1 -0
- package/dist/commands/mission.js +129 -0
- package/dist/commands/permissions.d.ts +3 -0
- package/dist/commands/permissions.d.ts.map +1 -0
- package/dist/commands/permissions.js +82 -0
- package/dist/commands/privacy.d.ts +3 -0
- package/dist/commands/privacy.d.ts.map +1 -0
- package/dist/commands/privacy.js +13 -0
- package/dist/commands/recap.d.ts +3 -0
- package/dist/commands/recap.d.ts.map +1 -0
- package/dist/commands/recap.js +11 -0
- package/dist/commands/repomap.d.ts +3 -0
- package/dist/commands/repomap.d.ts.map +1 -0
- package/dist/commands/repomap.js +146 -0
- package/dist/commands/resume.d.ts +3 -0
- package/dist/commands/resume.d.ts.map +1 -0
- package/dist/commands/resume.js +42 -0
- package/dist/commands/runtime.d.ts +61 -0
- package/dist/commands/runtime.d.ts.map +1 -0
- package/dist/commands/runtime.js +20 -0
- package/dist/commands/sessions.d.ts +3 -0
- package/dist/commands/sessions.d.ts.map +1 -0
- package/dist/commands/sessions.js +34 -0
- package/dist/commands/shortcuts.d.ts +3 -0
- package/dist/commands/shortcuts.d.ts.map +1 -0
- package/dist/commands/shortcuts.js +12 -0
- package/dist/commands/skill.d.ts +3 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +20 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +31 -0
- package/dist/commands/statusline.d.ts +3 -0
- package/dist/commands/statusline.d.ts.map +1 -0
- package/dist/commands/statusline.js +40 -0
- package/dist/commands/storage.d.ts +3 -0
- package/dist/commands/storage.d.ts.map +1 -0
- package/dist/commands/storage.js +122 -0
- package/dist/commands/tasks.d.ts +3 -0
- package/dist/commands/tasks.d.ts.map +1 -0
- package/dist/commands/tasks.js +117 -0
- package/dist/commands/types.d.ts +14 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +1 -0
- package/dist/commands/verify.d.ts +3 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +86 -0
- package/dist/config-report.d.ts +35 -0
- package/dist/config-report.d.ts.map +1 -0
- package/dist/config-report.js +100 -0
- package/dist/config.d.ts +217 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +690 -0
- package/dist/context-compactor.d.ts +27 -0
- package/dist/context-compactor.d.ts.map +1 -0
- package/dist/context-compactor.js +489 -0
- package/dist/context-report.d.ts +35 -0
- package/dist/context-report.d.ts.map +1 -0
- package/dist/context-report.js +172 -0
- package/dist/daemon.d.ts +2 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +316 -0
- package/dist/dashboard-server.d.ts +18 -0
- package/dist/dashboard-server.d.ts.map +1 -0
- package/dist/dashboard-server.js +325 -0
- package/dist/discovery-registry.d.ts +28 -0
- package/dist/discovery-registry.d.ts.map +1 -0
- package/dist/discovery-registry.js +106 -0
- package/dist/discovery-types.d.ts +54 -0
- package/dist/discovery-types.d.ts.map +1 -0
- package/dist/discovery-types.js +5 -0
- package/dist/doctor.d.ts +31 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +343 -0
- package/dist/eval/runner.d.ts +10 -0
- package/dist/eval/runner.d.ts.map +1 -0
- package/dist/eval/runner.js +78 -0
- package/dist/eval/tasks.d.ts +3 -0
- package/dist/eval/tasks.d.ts.map +1 -0
- package/dist/eval/tasks.js +179 -0
- package/dist/eval/types.d.ts +31 -0
- package/dist/eval/types.d.ts.map +1 -0
- package/dist/eval/types.js +4 -0
- package/dist/git/auto-commit.d.ts +28 -0
- package/dist/git/auto-commit.d.ts.map +1 -0
- package/dist/git/auto-commit.js +112 -0
- package/dist/guard/approval.d.ts +16 -0
- package/dist/guard/approval.d.ts.map +1 -0
- package/dist/guard/approval.js +68 -0
- package/dist/guard/content-filter.d.ts +15 -0
- package/dist/guard/content-filter.d.ts.map +1 -0
- package/dist/guard/content-filter.js +102 -0
- package/dist/guard/permissions.d.ts +17 -0
- package/dist/guard/permissions.d.ts.map +1 -0
- package/dist/guard/permissions.js +54 -0
- package/dist/guard/rate-limit.d.ts +14 -0
- package/dist/guard/rate-limit.d.ts.map +1 -0
- package/dist/guard/rate-limit.js +47 -0
- package/dist/guard.d.ts +21 -0
- package/dist/guard.d.ts.map +1 -0
- package/dist/guard.js +144 -0
- package/dist/help-topics.d.ts +19 -0
- package/dist/help-topics.d.ts.map +1 -0
- package/dist/help-topics.js +391 -0
- package/dist/hooks-report.d.ts +23 -0
- package/dist/hooks-report.d.ts.map +1 -0
- package/dist/hooks-report.js +44 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +4 -0
- package/dist/i18n/zh-cn.d.ts +180 -0
- package/dist/i18n/zh-cn.d.ts.map +1 -0
- package/dist/i18n/zh-cn.js +184 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1157 -0
- package/dist/knowledge-agent.d.ts +47 -0
- package/dist/knowledge-agent.d.ts.map +1 -0
- package/dist/knowledge-agent.js +320 -0
- package/dist/local-status-report.d.ts +23 -0
- package/dist/local-status-report.d.ts.map +1 -0
- package/dist/local-status-report.js +63 -0
- package/dist/local-storage-report.d.ts +32 -0
- package/dist/local-storage-report.d.ts.map +1 -0
- package/dist/local-storage-report.js +171 -0
- package/dist/mcp/bridge.d.ts +11 -0
- package/dist/mcp/bridge.d.ts.map +1 -0
- package/dist/mcp/bridge.js +37 -0
- package/dist/mcp/client.d.ts +26 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +209 -0
- package/dist/mcp/http-transport.d.ts +21 -0
- package/dist/mcp/http-transport.d.ts.map +1 -0
- package/dist/mcp/http-transport.js +126 -0
- package/dist/mcp/presets.d.ts +22 -0
- package/dist/mcp/presets.d.ts.map +1 -0
- package/dist/mcp/presets.js +80 -0
- package/dist/mcp/registry.d.ts +23 -0
- package/dist/mcp/registry.d.ts.map +1 -0
- package/dist/mcp/registry.js +85 -0
- package/dist/mcp/stdio-transport.d.ts +25 -0
- package/dist/mcp/stdio-transport.d.ts.map +1 -0
- package/dist/mcp/stdio-transport.js +92 -0
- package/dist/mcp/store.d.ts +41 -0
- package/dist/mcp/store.d.ts.map +1 -0
- package/dist/mcp/store.js +100 -0
- package/dist/mcp/types.d.ts +40 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +4 -0
- package/dist/mcp-report.d.ts +30 -0
- package/dist/mcp-report.d.ts.map +1 -0
- package/dist/mcp-report.js +104 -0
- package/dist/memory/cognitive-index.d.ts +56 -0
- package/dist/memory/cognitive-index.d.ts.map +1 -0
- package/dist/memory/cognitive-index.js +265 -0
- package/dist/memory/compactor.d.ts +28 -0
- package/dist/memory/compactor.d.ts.map +1 -0
- package/dist/memory/compactor.js +92 -0
- package/dist/memory/consolidation.d.ts +13 -0
- package/dist/memory/consolidation.d.ts.map +1 -0
- package/dist/memory/consolidation.js +77 -0
- package/dist/memory/embedding.d.ts +15 -0
- package/dist/memory/embedding.d.ts.map +1 -0
- package/dist/memory/embedding.js +59 -0
- package/dist/memory/memory-llm-dream.d.ts +3 -0
- package/dist/memory/memory-llm-dream.d.ts.map +1 -0
- package/dist/memory/memory-llm-dream.js +59 -0
- package/dist/memory/projection-worker.d.ts +30 -0
- package/dist/memory/projection-worker.d.ts.map +1 -0
- package/dist/memory/projection-worker.js +92 -0
- package/dist/memory/semantic-index.d.ts +18 -0
- package/dist/memory/semantic-index.d.ts.map +1 -0
- package/dist/memory/semantic-index.js +86 -0
- package/dist/memory/wal.d.ts +33 -0
- package/dist/memory/wal.d.ts.map +1 -0
- package/dist/memory/wal.js +131 -0
- package/dist/memory-report.d.ts +120 -0
- package/dist/memory-report.d.ts.map +1 -0
- package/dist/memory-report.js +726 -0
- package/dist/memory.d.ts +149 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +632 -0
- package/dist/metrics/agent-telemetry.d.ts +14 -0
- package/dist/metrics/agent-telemetry.d.ts.map +1 -0
- package/dist/metrics/agent-telemetry.js +44 -0
- package/dist/metrics/collector.d.ts +17 -0
- package/dist/metrics/collector.d.ts.map +1 -0
- package/dist/metrics/collector.js +137 -0
- package/dist/metrics/types.d.ts +14 -0
- package/dist/metrics/types.d.ts.map +1 -0
- package/dist/metrics/types.js +4 -0
- package/dist/mission/manager.d.ts +28 -0
- package/dist/mission/manager.d.ts.map +1 -0
- package/dist/mission/manager.js +208 -0
- package/dist/mission/types.d.ts +37 -0
- package/dist/mission/types.d.ts.map +1 -0
- package/dist/mission/types.js +5 -0
- package/dist/onboarding/tutorial.d.ts +33 -0
- package/dist/onboarding/tutorial.d.ts.map +1 -0
- package/dist/onboarding/tutorial.js +96 -0
- package/dist/output-style.d.ts +14 -0
- package/dist/output-style.d.ts.map +1 -0
- package/dist/output-style.js +29 -0
- package/dist/package-version.d.ts +12 -0
- package/dist/package-version.d.ts.map +1 -0
- package/dist/package-version.js +42 -0
- package/dist/permissions-report.d.ts +42 -0
- package/dist/permissions-report.d.ts.map +1 -0
- package/dist/permissions-report.js +120 -0
- package/dist/pipeline/consistency-checker.d.ts +8 -0
- package/dist/pipeline/consistency-checker.d.ts.map +1 -0
- package/dist/pipeline/consistency-checker.js +40 -0
- package/dist/pipeline/example-generator.d.ts +4 -0
- package/dist/pipeline/example-generator.d.ts.map +1 -0
- package/dist/pipeline/example-generator.js +64 -0
- package/dist/pipeline/hooks.d.ts +68 -0
- package/dist/pipeline/hooks.d.ts.map +1 -0
- package/dist/pipeline/hooks.js +377 -0
- package/dist/pipeline/sections.d.ts +41 -0
- package/dist/pipeline/sections.d.ts.map +1 -0
- package/dist/pipeline/sections.js +244 -0
- package/dist/pipeline/verification.d.ts +12 -0
- package/dist/pipeline/verification.d.ts.map +1 -0
- package/dist/pipeline/verification.js +138 -0
- package/dist/privacy-report.d.ts +24 -0
- package/dist/privacy-report.d.ts.map +1 -0
- package/dist/privacy-report.js +78 -0
- package/dist/providers/presets.d.ts +25 -0
- package/dist/providers/presets.d.ts.map +1 -0
- package/dist/providers/presets.js +205 -0
- package/dist/recap.d.ts +38 -0
- package/dist/recap.d.ts.map +1 -0
- package/dist/recap.js +154 -0
- package/dist/repl.d.ts +41 -0
- package/dist/repl.d.ts.map +1 -0
- package/dist/repl.js +396 -0
- package/dist/runtime-paths.d.ts +32 -0
- package/dist/runtime-paths.d.ts.map +1 -0
- package/dist/runtime-paths.js +134 -0
- package/dist/sdk.d.ts +12 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +18 -0
- package/dist/session/daemon-session-api.d.ts +22 -0
- package/dist/session/daemon-session-api.d.ts.map +1 -0
- package/dist/session/daemon-session-api.js +48 -0
- package/dist/session/durable-session-supervisor.d.ts +24 -0
- package/dist/session/durable-session-supervisor.d.ts.map +1 -0
- package/dist/session/durable-session-supervisor.js +195 -0
- package/dist/session/goal-controller.d.ts +43 -0
- package/dist/session/goal-controller.d.ts.map +1 -0
- package/dist/session/goal-controller.js +77 -0
- package/dist/session/goal-evaluator.d.ts +29 -0
- package/dist/session/goal-evaluator.d.ts.map +1 -0
- package/dist/session/goal-evaluator.js +100 -0
- package/dist/session/loop-prompt.d.ts +14 -0
- package/dist/session/loop-prompt.d.ts.map +1 -0
- package/dist/session/loop-prompt.js +49 -0
- package/dist/session/session-goal-manager.d.ts +51 -0
- package/dist/session/session-goal-manager.d.ts.map +1 -0
- package/dist/session/session-goal-manager.js +118 -0
- package/dist/session/session-registry.d.ts +40 -0
- package/dist/session/session-registry.d.ts.map +1 -0
- package/dist/session/session-registry.js +124 -0
- package/dist/session/session-scheduler.d.ts +59 -0
- package/dist/session/session-scheduler.d.ts.map +1 -0
- package/dist/session/session-scheduler.js +170 -0
- package/dist/session-checkpoint-report.d.ts +22 -0
- package/dist/session-checkpoint-report.d.ts.map +1 -0
- package/dist/session-checkpoint-report.js +99 -0
- package/dist/session-export-index.d.ts +23 -0
- package/dist/session-export-index.d.ts.map +1 -0
- package/dist/session-export-index.js +96 -0
- package/dist/session-export.d.ts +28 -0
- package/dist/session-export.d.ts.map +1 -0
- package/dist/session-export.js +99 -0
- package/dist/session-goal-report.d.ts +37 -0
- package/dist/session-goal-report.d.ts.map +1 -0
- package/dist/session-goal-report.js +219 -0
- package/dist/session-list-report.d.ts +16 -0
- package/dist/session-list-report.d.ts.map +1 -0
- package/dist/session-list-report.js +60 -0
- package/dist/session-task-report.d.ts +23 -0
- package/dist/session-task-report.d.ts.map +1 -0
- package/dist/session-task-report.js +183 -0
- package/dist/shortcuts.d.ts +2 -0
- package/dist/shortcuts.d.ts.map +1 -0
- package/dist/shortcuts.js +32 -0
- package/dist/skills/registry.d.ts +8 -0
- package/dist/skills/registry.d.ts.map +1 -0
- package/dist/skills/registry.js +119 -0
- package/dist/skills/types.d.ts +7 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +4 -0
- package/dist/statusline.d.ts +37 -0
- package/dist/statusline.d.ts.map +1 -0
- package/dist/statusline.js +207 -0
- package/dist/tools/bash.d.ts +10 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +278 -0
- package/dist/tools/browser-fetch.d.ts +7 -0
- package/dist/tools/browser-fetch.d.ts.map +1 -0
- package/dist/tools/browser-fetch.js +133 -0
- package/dist/tools/error-utils.d.ts +9 -0
- package/dist/tools/error-utils.d.ts.map +1 -0
- package/dist/tools/error-utils.js +35 -0
- package/dist/tools/index.d.ts +27 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +86 -0
- package/dist/tools/patch.d.ts +22 -0
- package/dist/tools/patch.d.ts.map +1 -0
- package/dist/tools/patch.js +458 -0
- package/dist/tools/planner.d.ts +7 -0
- package/dist/tools/planner.d.ts.map +1 -0
- package/dist/tools/planner.js +148 -0
- package/dist/tools/read.d.ts +8 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/read.js +114 -0
- package/dist/tools/search.d.ts +11 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +636 -0
- package/dist/tools/skill.d.ts +8 -0
- package/dist/tools/skill.d.ts.map +1 -0
- package/dist/tools/skill.js +181 -0
- package/dist/tools/subtask.d.ts +9 -0
- package/dist/tools/subtask.d.ts.map +1 -0
- package/dist/tools/subtask.js +120 -0
- package/dist/tools/todo.d.ts +8 -0
- package/dist/tools/todo.d.ts.map +1 -0
- package/dist/tools/todo.js +170 -0
- package/dist/tools/url-fetch.d.ts +11 -0
- package/dist/tools/url-fetch.d.ts.map +1 -0
- package/dist/tools/url-fetch.js +208 -0
- package/dist/tools/vision-analyze.d.ts +9 -0
- package/dist/tools/vision-analyze.d.ts.map +1 -0
- package/dist/tools/vision-analyze.js +179 -0
- package/dist/tools/write.d.ts +7 -0
- package/dist/tools/write.d.ts.map +1 -0
- package/dist/tools/write.js +128 -0
- package/dist/tui/chrome.d.ts +7 -0
- package/dist/tui/chrome.d.ts.map +1 -0
- package/dist/tui/chrome.js +22 -0
- package/dist/tui/input-buffer.d.ts +37 -0
- package/dist/tui/input-buffer.d.ts.map +1 -0
- package/dist/tui/input-buffer.js +228 -0
- package/dist/tui/input-history.d.ts +11 -0
- package/dist/tui/input-history.d.ts.map +1 -0
- package/dist/tui/input-history.js +69 -0
- package/dist/tui/input-queue.d.ts +27 -0
- package/dist/tui/input-queue.d.ts.map +1 -0
- package/dist/tui/input-queue.js +85 -0
- package/dist/tui/markdown.d.ts +10 -0
- package/dist/tui/markdown.d.ts.map +1 -0
- package/dist/tui/markdown.js +396 -0
- package/dist/tui/progress.d.ts +3 -0
- package/dist/tui/progress.d.ts.map +1 -0
- package/dist/tui/progress.js +13 -0
- package/dist/tui/shell.d.ts +67 -0
- package/dist/tui/shell.d.ts.map +1 -0
- package/dist/tui/shell.js +271 -0
- package/dist/tui/streaming-repl.d.ts +39 -0
- package/dist/tui/streaming-repl.d.ts.map +1 -0
- package/dist/tui/streaming-repl.js +460 -0
- package/dist/tui/streaming-tui.d.ts +174 -0
- package/dist/tui/streaming-tui.d.ts.map +1 -0
- package/dist/tui/streaming-tui.js +1049 -0
- package/dist/types.d.ts +221 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +37 -0
- package/dist/utils/symbol-extractor.d.ts +8 -0
- package/dist/utils/symbol-extractor.d.ts.map +1 -0
- package/dist/utils/symbol-extractor.js +190 -0
- package/dist/workflow-runtime.d.ts +45 -0
- package/dist/workflow-runtime.d.ts.map +1 -0
- package/dist/workflow-runtime.js +146 -0
- package/dist/workflow-types.d.ts +73 -0
- package/dist/workflow-types.d.ts.map +1 -0
- package/dist/workflow-types.js +34 -0
- package/docs/docker.md +66 -0
- package/docs/install.md +159 -0
- package/docs/sdk.md +67 -0
- package/docs/skills.md +51 -0
- package/package.json +102 -0
- package/scripts/bootstrap.mjs +63 -0
- package/scripts/check_image.ps1 +18 -0
- package/scripts/clean-dist.mjs +18 -0
- package/scripts/copy_image.ps1 +5 -0
- package/scripts/eval-smoke.mjs +17 -0
- package/skills/examples/repo-triage/SKILL.md +50 -0
- package/skills/qling.md +42 -0
- package/skills/templates/SKILL.md +37 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface IsolationPolicyInput {
|
|
2
|
+
workspaceDir: string;
|
|
3
|
+
mode: "worktree" | "off";
|
|
4
|
+
requireGit: boolean;
|
|
5
|
+
nonGitPolicy: "warn" | "deny" | "off";
|
|
6
|
+
}
|
|
7
|
+
export interface IsolationPolicyResult {
|
|
8
|
+
level: "ok" | "warn" | "deny";
|
|
9
|
+
useWorktree: boolean;
|
|
10
|
+
isGitWorkspace: boolean;
|
|
11
|
+
message?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function evaluateIsolationPolicy(input: IsolationPolicyInput): Promise<IsolationPolicyResult>;
|
|
14
|
+
//# sourceMappingURL=isolation-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isolation-policy.d.ts","sourceRoot":"","sources":["../../src/agents/isolation-policy.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,UAAU,GAAG,KAAK,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;CACvC;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IAC9B,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAMD,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,qBAAqB,CAAC,CAmDhC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { existsSync } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
function isGitWorkspace(workspaceDir) {
|
|
4
|
+
return existsSync(path.join(workspaceDir, ".git"));
|
|
5
|
+
}
|
|
6
|
+
export async function evaluateIsolationPolicy(input) {
|
|
7
|
+
const gitWorkspace = isGitWorkspace(input.workspaceDir);
|
|
8
|
+
if (input.mode === "off") {
|
|
9
|
+
return {
|
|
10
|
+
level: "ok",
|
|
11
|
+
useWorktree: false,
|
|
12
|
+
isGitWorkspace: gitWorkspace,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
if (gitWorkspace) {
|
|
16
|
+
return {
|
|
17
|
+
level: "ok",
|
|
18
|
+
useWorktree: true,
|
|
19
|
+
isGitWorkspace: true,
|
|
20
|
+
message: "Git workspace detected; worktree isolation is available.",
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (!input.requireGit) {
|
|
24
|
+
return {
|
|
25
|
+
level: "ok",
|
|
26
|
+
useWorktree: false,
|
|
27
|
+
isGitWorkspace: false,
|
|
28
|
+
message: "Non-git workspace; isolation continues without worktree.",
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (input.nonGitPolicy === "deny") {
|
|
32
|
+
return {
|
|
33
|
+
level: "deny",
|
|
34
|
+
useWorktree: false,
|
|
35
|
+
isGitWorkspace: false,
|
|
36
|
+
message: "Non-git workspace blocked by agents.isolation.non_git_policy=deny",
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (input.nonGitPolicy === "warn") {
|
|
40
|
+
return {
|
|
41
|
+
level: "warn",
|
|
42
|
+
useWorktree: false,
|
|
43
|
+
isGitWorkspace: false,
|
|
44
|
+
message: "Non-git workspace; degraded to non-worktree isolation.",
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
level: "ok",
|
|
49
|
+
useWorktree: false,
|
|
50
|
+
isGitWorkspace: false,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Channel, ApprovalRequest, ApprovalResponse } from "./types.js";
|
|
2
|
+
export declare class ConsoleChannel implements Channel {
|
|
3
|
+
name: string;
|
|
4
|
+
private userMessageHandler;
|
|
5
|
+
private rl;
|
|
6
|
+
start(): Promise<void>;
|
|
7
|
+
stop(): Promise<void>;
|
|
8
|
+
sendText(text: string): Promise<void>;
|
|
9
|
+
sendToolStart(toolName: string, args: Record<string, unknown>): Promise<void>;
|
|
10
|
+
sendToolResult(toolName: string, output: string, isError: boolean): Promise<void>;
|
|
11
|
+
sendError(text: string): Promise<void>;
|
|
12
|
+
onUserMessage(handler: (msg: string) => Promise<void>): void;
|
|
13
|
+
requestApproval(request: ApprovalRequest): Promise<ApprovalResponse>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=console-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-channel.d.ts","sourceRoot":"","sources":["../../src/channels/console-channel.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE7E,qBAAa,cAAe,YAAW,OAAO;IAC5C,IAAI,SAAa;IACjB,OAAO,CAAC,kBAAkB,CAAiD;IAC3E,OAAO,CAAC,EAAE,CAAmC;IAEvC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAqBtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAKrB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7E,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjF,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,aAAa,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAItD,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAoB3E"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// 轻灵 - Console Channel(控制台通道)
|
|
3
|
+
// 封装标准输入/输出为 Channel 接口
|
|
4
|
+
// ============================================================
|
|
5
|
+
import * as readline from "readline";
|
|
6
|
+
export class ConsoleChannel {
|
|
7
|
+
name = "console";
|
|
8
|
+
userMessageHandler = null;
|
|
9
|
+
rl = null;
|
|
10
|
+
async start() {
|
|
11
|
+
this.rl = readline.createInterface({
|
|
12
|
+
input: process.stdin,
|
|
13
|
+
output: process.stdout,
|
|
14
|
+
});
|
|
15
|
+
this.rl.on("line", async (line) => {
|
|
16
|
+
const trimmed = line.trim();
|
|
17
|
+
if (trimmed && this.userMessageHandler) {
|
|
18
|
+
await this.userMessageHandler(trimmed);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
this.rl.on("close", () => {
|
|
22
|
+
// Do not force process exit here.
|
|
23
|
+
// In run mode the channel may be attached with non-interactive stdio,
|
|
24
|
+
// and eager exit can terminate one-shot execution before agent.run() completes.
|
|
25
|
+
this.rl = null;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
async stop() {
|
|
29
|
+
this.rl?.close();
|
|
30
|
+
this.rl = null;
|
|
31
|
+
}
|
|
32
|
+
async sendText(text) {
|
|
33
|
+
process.stdout.write(text + "\n");
|
|
34
|
+
}
|
|
35
|
+
async sendToolStart(toolName, args) {
|
|
36
|
+
const preview = JSON.stringify(args).slice(0, 80);
|
|
37
|
+
console.error("[tool] " + toolName + ": " + preview);
|
|
38
|
+
}
|
|
39
|
+
async sendToolResult(toolName, output, isError) {
|
|
40
|
+
const icon = isError ? "x" : "+";
|
|
41
|
+
console.error("[" + icon + "] " + toolName + ": " + output.split("\n")[0].slice(0, 80));
|
|
42
|
+
}
|
|
43
|
+
async sendError(text) {
|
|
44
|
+
console.error("[error] " + text);
|
|
45
|
+
}
|
|
46
|
+
onUserMessage(handler) {
|
|
47
|
+
this.userMessageHandler = handler;
|
|
48
|
+
}
|
|
49
|
+
async requestApproval(request) {
|
|
50
|
+
await this.sendText("\n[Approval Required] Tool: " + request.toolName + "\n" +
|
|
51
|
+
"Reason: " + request.reason + "\n" +
|
|
52
|
+
"Allow? (y/n): ");
|
|
53
|
+
return new Promise((resolve) => {
|
|
54
|
+
const originalHandler = this.userMessageHandler;
|
|
55
|
+
this.userMessageHandler = async (msg) => {
|
|
56
|
+
this.userMessageHandler = originalHandler;
|
|
57
|
+
const answer = msg.toLowerCase();
|
|
58
|
+
resolve({
|
|
59
|
+
requestId: request.id,
|
|
60
|
+
decision: answer === "y" || answer === "yes" ? "allow" : "deny",
|
|
61
|
+
timestamp: Date.now(),
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Channel } from "./types.js";
|
|
2
|
+
export declare class ChannelRegistry {
|
|
3
|
+
private channels;
|
|
4
|
+
register(channel: Channel): void;
|
|
5
|
+
get(name: string): Channel | undefined;
|
|
6
|
+
getAll(): Channel[];
|
|
7
|
+
startAll(): Promise<void>;
|
|
8
|
+
stopAll(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/channels/registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAA8B;IAE9C,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIhC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAItC,MAAM,IAAI,OAAO,EAAE;IAIb,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAMzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAK/B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// 轻灵 - Channel Registry(通道注册表)
|
|
3
|
+
// ============================================================
|
|
4
|
+
export class ChannelRegistry {
|
|
5
|
+
channels = new Map();
|
|
6
|
+
register(channel) {
|
|
7
|
+
this.channels.set(channel.name, channel);
|
|
8
|
+
}
|
|
9
|
+
get(name) {
|
|
10
|
+
return this.channels.get(name);
|
|
11
|
+
}
|
|
12
|
+
getAll() {
|
|
13
|
+
return Array.from(this.channels.values());
|
|
14
|
+
}
|
|
15
|
+
async startAll() {
|
|
16
|
+
for (const channel of this.channels.values()) {
|
|
17
|
+
await channel.start();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async stopAll() {
|
|
21
|
+
for (const channel of this.channels.values()) {
|
|
22
|
+
await channel.stop();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Channel, ApprovalRequest, ApprovalResponse } from "./types.js";
|
|
2
|
+
export interface SlackChannelConfig {
|
|
3
|
+
botToken: string;
|
|
4
|
+
appToken?: string;
|
|
5
|
+
channelIds?: string[];
|
|
6
|
+
pollIntervalMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare class SlackChannel implements Channel {
|
|
9
|
+
name: string;
|
|
10
|
+
private botToken;
|
|
11
|
+
private channelIds;
|
|
12
|
+
private pollIntervalMs;
|
|
13
|
+
private userMessageHandler;
|
|
14
|
+
private running;
|
|
15
|
+
private lastTs;
|
|
16
|
+
private lastActiveChannelId;
|
|
17
|
+
private pollTimer;
|
|
18
|
+
private pendingApprovals;
|
|
19
|
+
constructor(config: SlackChannelConfig);
|
|
20
|
+
start(): Promise<void>;
|
|
21
|
+
stop(): Promise<void>;
|
|
22
|
+
sendText(text: string): Promise<void>;
|
|
23
|
+
sendToolStart(toolName: string, args: Record<string, unknown>): Promise<void>;
|
|
24
|
+
sendToolResult(toolName: string, output: string, isError: boolean): Promise<void>;
|
|
25
|
+
sendError(text: string): Promise<void>;
|
|
26
|
+
onUserMessage(handler: (msg: string) => Promise<void>): void;
|
|
27
|
+
requestApproval(request: ApprovalRequest): Promise<ApprovalResponse>;
|
|
28
|
+
private apiCall;
|
|
29
|
+
private discoverChannels;
|
|
30
|
+
private pollAllChannels;
|
|
31
|
+
private resolveTargetChannelIds;
|
|
32
|
+
private tryHandleApprovalText;
|
|
33
|
+
private resolvePendingApprovalKey;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=slack-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack-channel.d.ts","sourceRoot":"","sources":["../../src/channels/slack-channel.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE7E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,YAAa,YAAW,OAAO;IAC1C,IAAI,SAAW;IACf,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAW;IAC7B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,kBAAkB,CAAiD;IAC3E,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,mBAAmB,CAAuB;IAClD,OAAO,CAAC,SAAS,CAA+C;IAChE,OAAO,CAAC,gBAAgB,CAOpB;gBAEQ,MAAM,EAAE,kBAAkB;IAMhC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAkBtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAarB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBrC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7E,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjF,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,aAAa,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAItD,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;YAmD5D,OAAO;YAcP,gBAAgB;YAiBhB,eAAe;IAsC7B,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,qBAAqB;IAqB7B,OAAO,CAAC,yBAAyB;CAUlC"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// 轻灵 - Slack Bot Channel(Slack Bot 通道)
|
|
3
|
+
// axios + Web API polling,无 SDK 依赖
|
|
4
|
+
// ============================================================
|
|
5
|
+
import axios from "axios";
|
|
6
|
+
export class SlackChannel {
|
|
7
|
+
name = "slack";
|
|
8
|
+
botToken;
|
|
9
|
+
channelIds;
|
|
10
|
+
pollIntervalMs;
|
|
11
|
+
userMessageHandler = null;
|
|
12
|
+
running = false;
|
|
13
|
+
lastTs = new Map();
|
|
14
|
+
lastActiveChannelId = null;
|
|
15
|
+
pollTimer = null;
|
|
16
|
+
pendingApprovals = new Map();
|
|
17
|
+
constructor(config) {
|
|
18
|
+
this.botToken = config.botToken;
|
|
19
|
+
this.channelIds = config.channelIds ?? [];
|
|
20
|
+
this.pollIntervalMs = config.pollIntervalMs ?? 3000;
|
|
21
|
+
}
|
|
22
|
+
async start() {
|
|
23
|
+
if (!this.botToken) {
|
|
24
|
+
console.error("[Slack] No bot token configured");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.running = true;
|
|
28
|
+
if (this.channelIds.length === 0) {
|
|
29
|
+
await this.discoverChannels();
|
|
30
|
+
}
|
|
31
|
+
this.pollTimer = setInterval(() => {
|
|
32
|
+
this.pollAllChannels().catch((err) => {
|
|
33
|
+
console.error("[Slack] Poll error: " + err.message);
|
|
34
|
+
});
|
|
35
|
+
}, this.pollIntervalMs);
|
|
36
|
+
}
|
|
37
|
+
async stop() {
|
|
38
|
+
this.running = false;
|
|
39
|
+
if (this.pollTimer) {
|
|
40
|
+
clearInterval(this.pollTimer);
|
|
41
|
+
this.pollTimer = null;
|
|
42
|
+
}
|
|
43
|
+
for (const [shortId, pending] of this.pendingApprovals) {
|
|
44
|
+
clearTimeout(pending.timer);
|
|
45
|
+
pending.resolve({ requestId: pending.requestId, decision: "deny", timestamp: Date.now() });
|
|
46
|
+
this.pendingApprovals.delete(shortId);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async sendText(text) {
|
|
50
|
+
const targets = this.resolveTargetChannelIds();
|
|
51
|
+
if (targets.length === 0) {
|
|
52
|
+
console.error("[Slack] sendText skipped: no target channel");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const body = text.length > 3000 ? text.slice(0, 3000) + "\n... [truncated]" : text;
|
|
56
|
+
for (const channelId of targets) {
|
|
57
|
+
try {
|
|
58
|
+
await this.apiCall("chat.postMessage", {
|
|
59
|
+
channel: channelId,
|
|
60
|
+
text: body,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
console.error("[Slack] sendText failed: " + err.message);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async sendToolStart(toolName, args) {
|
|
69
|
+
const preview = JSON.stringify(args).slice(0, 200);
|
|
70
|
+
await this.sendText("[tool:start] " + toolName + "\n```" + preview + "```");
|
|
71
|
+
}
|
|
72
|
+
async sendToolResult(toolName, output, isError) {
|
|
73
|
+
const status = isError ? "error" : "ok";
|
|
74
|
+
await this.sendText("[tool:" + status + "] " + toolName + "\n" + output.slice(0, 500));
|
|
75
|
+
}
|
|
76
|
+
async sendError(text) {
|
|
77
|
+
await this.sendText("[error] " + text);
|
|
78
|
+
}
|
|
79
|
+
onUserMessage(handler) {
|
|
80
|
+
this.userMessageHandler = handler;
|
|
81
|
+
}
|
|
82
|
+
async requestApproval(request) {
|
|
83
|
+
const targets = this.resolveTargetChannelIds();
|
|
84
|
+
if (targets.length === 0) {
|
|
85
|
+
return { requestId: request.id, decision: "deny", timestamp: Date.now() };
|
|
86
|
+
}
|
|
87
|
+
const text = ":warning: *Approval Required*\n" +
|
|
88
|
+
"*Tool:* " + request.toolName + "\n" +
|
|
89
|
+
"*Reason:* " + request.reason + "\n" +
|
|
90
|
+
"Reply with `allow " + request.id.slice(0, 8) + "` or `deny " + request.id.slice(0, 8) + "`";
|
|
91
|
+
for (const channelId of targets) {
|
|
92
|
+
try {
|
|
93
|
+
await this.apiCall("chat.postMessage", {
|
|
94
|
+
channel: channelId,
|
|
95
|
+
text,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
console.error("[Slack] Approval send failed: " + err.message);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const shortId = request.id.slice(0, 8).toLowerCase();
|
|
103
|
+
return new Promise((resolve) => {
|
|
104
|
+
const existing = this.pendingApprovals.get(shortId);
|
|
105
|
+
if (existing) {
|
|
106
|
+
clearTimeout(existing.timer);
|
|
107
|
+
existing.resolve({ requestId: existing.requestId, decision: "deny", timestamp: Date.now() });
|
|
108
|
+
this.pendingApprovals.delete(shortId);
|
|
109
|
+
}
|
|
110
|
+
const timer = setTimeout(() => {
|
|
111
|
+
const pending = this.pendingApprovals.get(shortId);
|
|
112
|
+
if (!pending || pending.requestId !== request.id) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
this.pendingApprovals.delete(shortId);
|
|
116
|
+
pending.resolve({ requestId: request.id, decision: "deny", timestamp: Date.now() });
|
|
117
|
+
}, 300_000);
|
|
118
|
+
this.pendingApprovals.set(shortId, {
|
|
119
|
+
requestId: request.id,
|
|
120
|
+
resolve,
|
|
121
|
+
timer,
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
// --- Private ---
|
|
126
|
+
async apiCall(method, body) {
|
|
127
|
+
const resp = await axios.post("https://slack.com/api/" + method, body, {
|
|
128
|
+
headers: {
|
|
129
|
+
Authorization: "Bearer " + this.botToken,
|
|
130
|
+
"Content-Type": "application/json",
|
|
131
|
+
},
|
|
132
|
+
timeout: 10000,
|
|
133
|
+
});
|
|
134
|
+
if (resp.data && resp.data.ok === false) {
|
|
135
|
+
throw new Error("Slack API error: " + (resp.data.error ?? "unknown"));
|
|
136
|
+
}
|
|
137
|
+
return resp.data;
|
|
138
|
+
}
|
|
139
|
+
async discoverChannels() {
|
|
140
|
+
try {
|
|
141
|
+
const resp = await this.apiCall("conversations.list", {
|
|
142
|
+
types: "public_channel,private_channel",
|
|
143
|
+
limit: 100,
|
|
144
|
+
});
|
|
145
|
+
const channels = resp.channels;
|
|
146
|
+
if (channels) {
|
|
147
|
+
this.channelIds = channels
|
|
148
|
+
.filter((c) => c.is_member)
|
|
149
|
+
.map((c) => String(c.id));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
console.error("[Slack] Channel discovery failed: " + err.message);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async pollAllChannels() {
|
|
157
|
+
if (!this.running || !this.userMessageHandler)
|
|
158
|
+
return;
|
|
159
|
+
for (const channelId of this.channelIds) {
|
|
160
|
+
try {
|
|
161
|
+
const params = { channel: channelId, limit: 10 };
|
|
162
|
+
const last = this.lastTs.get(channelId);
|
|
163
|
+
if (last)
|
|
164
|
+
params.oldest = last;
|
|
165
|
+
const resp = await this.apiCall("conversations.history", params);
|
|
166
|
+
const messages = resp.messages;
|
|
167
|
+
if (!messages || messages.length === 0)
|
|
168
|
+
continue;
|
|
169
|
+
for (const msg of messages) {
|
|
170
|
+
if (msg.bot_id)
|
|
171
|
+
continue;
|
|
172
|
+
if (msg.subtype)
|
|
173
|
+
continue;
|
|
174
|
+
const ts = String(msg.ts ?? "");
|
|
175
|
+
const text = String(msg.text ?? "");
|
|
176
|
+
if (!text.trim())
|
|
177
|
+
continue;
|
|
178
|
+
if (!last || ts > last) {
|
|
179
|
+
this.lastTs.set(channelId, ts);
|
|
180
|
+
}
|
|
181
|
+
if (this.tryHandleApprovalText(text)) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
this.lastActiveChannelId = channelId;
|
|
185
|
+
await this.userMessageHandler(text);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
catch (err) {
|
|
189
|
+
console.error("[Slack] Poll channel " + channelId + " error: " + err.message);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
resolveTargetChannelIds() {
|
|
194
|
+
if (this.channelIds.length > 0) {
|
|
195
|
+
return [...this.channelIds];
|
|
196
|
+
}
|
|
197
|
+
if (this.lastActiveChannelId !== null) {
|
|
198
|
+
return [this.lastActiveChannelId];
|
|
199
|
+
}
|
|
200
|
+
return [];
|
|
201
|
+
}
|
|
202
|
+
tryHandleApprovalText(text) {
|
|
203
|
+
const m = /^\s*(allow|deny)\s+([a-z0-9]{4,})\b/i.exec(text.trim());
|
|
204
|
+
if (!m) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
const decision = m[1].toLowerCase() === "allow" ? "allow" : "deny";
|
|
208
|
+
const token = m[2].toLowerCase();
|
|
209
|
+
const key = this.resolvePendingApprovalKey(token);
|
|
210
|
+
if (!key) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
const pending = this.pendingApprovals.get(key);
|
|
214
|
+
if (!pending) {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
clearTimeout(pending.timer);
|
|
218
|
+
this.pendingApprovals.delete(key);
|
|
219
|
+
pending.resolve({ requestId: pending.requestId, decision, timestamp: Date.now() });
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
resolvePendingApprovalKey(token) {
|
|
223
|
+
if (this.pendingApprovals.has(token)) {
|
|
224
|
+
return token;
|
|
225
|
+
}
|
|
226
|
+
const matches = [...this.pendingApprovals.keys()].filter((k) => k.startsWith(token));
|
|
227
|
+
if (matches.length === 1) {
|
|
228
|
+
return matches[0];
|
|
229
|
+
}
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Channel, ApprovalRequest, ApprovalResponse } from "./types.js";
|
|
2
|
+
export interface TelegramChannelConfig {
|
|
3
|
+
token: string;
|
|
4
|
+
pollIntervalMs?: number;
|
|
5
|
+
allowedChatIds?: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare class TelegramChannel implements Channel {
|
|
8
|
+
name: string;
|
|
9
|
+
private token;
|
|
10
|
+
private pollIntervalMs;
|
|
11
|
+
private allowedChatIds;
|
|
12
|
+
private baseUrl;
|
|
13
|
+
private userMessageHandler;
|
|
14
|
+
private running;
|
|
15
|
+
private lastUpdateId;
|
|
16
|
+
private lastActiveChatId;
|
|
17
|
+
private pendingApprovals;
|
|
18
|
+
constructor(config: TelegramChannelConfig);
|
|
19
|
+
start(): Promise<void>;
|
|
20
|
+
stop(): Promise<void>;
|
|
21
|
+
sendText(text: string): Promise<void>;
|
|
22
|
+
sendToolStart(toolName: string, args: Record<string, unknown>): Promise<void>;
|
|
23
|
+
sendToolResult(toolName: string, output: string, isError: boolean): Promise<void>;
|
|
24
|
+
sendError(text: string): Promise<void>;
|
|
25
|
+
onUserMessage(handler: (msg: string) => Promise<void>): void;
|
|
26
|
+
requestApproval(request: ApprovalRequest): Promise<ApprovalResponse>;
|
|
27
|
+
handleCallbackQuery(callbackData: string, callbackQueryId: string): void;
|
|
28
|
+
private pollLoop;
|
|
29
|
+
private isAllowedChat;
|
|
30
|
+
private resolveTargetChatIds;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=telegram-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telegram-channel.d.ts","sourceRoot":"","sources":["../../src/channels/telegram-channel.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE7E,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,qBAAa,eAAgB,YAAW,OAAO;IAC7C,IAAI,SAAc;IAClB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,cAAc,CAAW;IACjC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,kBAAkB,CAAiD;IAC3E,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,gBAAgB,CAA2D;gBAEvE,MAAM,EAAE,qBAAqB;IAOnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAStB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAerC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7E,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjF,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,aAAa,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAItD,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAyC1E,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI;YA+B1D,QAAQ;IAkCtB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,oBAAoB;CAS7B"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// 轻灵 - Telegram Bot Channel(Telegram Bot 通道)
|
|
3
|
+
// axios + long-poll,无额外 SDK
|
|
4
|
+
// ============================================================
|
|
5
|
+
import axios from "axios";
|
|
6
|
+
export class TelegramChannel {
|
|
7
|
+
name = "telegram";
|
|
8
|
+
token;
|
|
9
|
+
pollIntervalMs;
|
|
10
|
+
allowedChatIds;
|
|
11
|
+
baseUrl;
|
|
12
|
+
userMessageHandler = null;
|
|
13
|
+
running = false;
|
|
14
|
+
lastUpdateId = 0;
|
|
15
|
+
lastActiveChatId = null;
|
|
16
|
+
pendingApprovals = new Map();
|
|
17
|
+
constructor(config) {
|
|
18
|
+
this.token = config.token;
|
|
19
|
+
this.pollIntervalMs = config.pollIntervalMs ?? 3000;
|
|
20
|
+
this.allowedChatIds = (config.allowedChatIds ?? []).map(Number);
|
|
21
|
+
this.baseUrl = "https://api.telegram.org/bot" + this.token;
|
|
22
|
+
}
|
|
23
|
+
async start() {
|
|
24
|
+
if (!this.token) {
|
|
25
|
+
console.error("[Telegram] No token configured");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.running = true;
|
|
29
|
+
this.pollLoop().catch(() => { });
|
|
30
|
+
}
|
|
31
|
+
async stop() {
|
|
32
|
+
this.running = false;
|
|
33
|
+
}
|
|
34
|
+
async sendText(text) {
|
|
35
|
+
const targets = this.resolveTargetChatIds();
|
|
36
|
+
if (targets.length === 0) {
|
|
37
|
+
console.error("[Telegram] sendText skipped: no target chat id");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const body = text.length > 4000 ? text.slice(0, 4000) + "\n... [truncated]" : text;
|
|
41
|
+
for (const chatId of targets) {
|
|
42
|
+
await axios.post(this.baseUrl + "/sendMessage", {
|
|
43
|
+
chat_id: chatId,
|
|
44
|
+
text: body,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async sendToolStart(toolName, args) {
|
|
49
|
+
const preview = JSON.stringify(args).slice(0, 200);
|
|
50
|
+
await this.sendText("[tool:start] " + toolName + "\n" + preview);
|
|
51
|
+
}
|
|
52
|
+
async sendToolResult(toolName, output, isError) {
|
|
53
|
+
const status = isError ? "error" : "ok";
|
|
54
|
+
await this.sendText("[tool:" + status + "] " + toolName + "\n" + output.slice(0, 500));
|
|
55
|
+
}
|
|
56
|
+
async sendError(text) {
|
|
57
|
+
await this.sendText("[error] " + text);
|
|
58
|
+
}
|
|
59
|
+
onUserMessage(handler) {
|
|
60
|
+
this.userMessageHandler = handler;
|
|
61
|
+
}
|
|
62
|
+
async requestApproval(request) {
|
|
63
|
+
const targets = this.resolveTargetChatIds();
|
|
64
|
+
if (targets.length === 0) {
|
|
65
|
+
return {
|
|
66
|
+
requestId: request.id,
|
|
67
|
+
decision: "deny",
|
|
68
|
+
timestamp: Date.now(),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const text = "[Approval Required]\n" +
|
|
72
|
+
"Tool: " + request.toolName + "\n" +
|
|
73
|
+
"Reason: " + request.reason + "\n" +
|
|
74
|
+
"Approve this tool call?";
|
|
75
|
+
return new Promise((resolve) => {
|
|
76
|
+
this.pendingApprovals.set(request.id, resolve);
|
|
77
|
+
const keyboard = {
|
|
78
|
+
inline_keyboard: [
|
|
79
|
+
[
|
|
80
|
+
{ text: "Allow", callback_data: request.id + ":allow" },
|
|
81
|
+
{ text: "Deny", callback_data: request.id + ":deny" },
|
|
82
|
+
],
|
|
83
|
+
],
|
|
84
|
+
};
|
|
85
|
+
Promise.all(targets.map((chatId) => axios.post(this.baseUrl + "/sendMessage", {
|
|
86
|
+
chat_id: chatId,
|
|
87
|
+
text,
|
|
88
|
+
reply_markup: keyboard,
|
|
89
|
+
}))).catch((err) => {
|
|
90
|
+
console.error("[Telegram] Approval send failed: " + err.message);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
handleCallbackQuery(callbackData, callbackQueryId) {
|
|
95
|
+
const match = /^(.*):(allow|deny)$/.exec(callbackData);
|
|
96
|
+
if (!match) {
|
|
97
|
+
axios
|
|
98
|
+
.post(this.baseUrl + "/answerCallbackQuery", {
|
|
99
|
+
callback_query_id: callbackQueryId,
|
|
100
|
+
text: "Unsupported callback",
|
|
101
|
+
})
|
|
102
|
+
.catch(() => { });
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const requestId = match[1];
|
|
106
|
+
const decision = match[2];
|
|
107
|
+
const resolver = this.pendingApprovals.get(requestId);
|
|
108
|
+
if (resolver) {
|
|
109
|
+
this.pendingApprovals.delete(requestId);
|
|
110
|
+
resolver({
|
|
111
|
+
requestId,
|
|
112
|
+
decision: decision === "allow" ? "allow" : "deny",
|
|
113
|
+
timestamp: Date.now(),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
// Acknowledge callback
|
|
117
|
+
axios.post(this.baseUrl + "/answerCallbackQuery", {
|
|
118
|
+
callback_query_id: callbackQueryId,
|
|
119
|
+
text: "Processed",
|
|
120
|
+
}).catch(() => { });
|
|
121
|
+
}
|
|
122
|
+
// --- Private ---
|
|
123
|
+
async pollLoop() {
|
|
124
|
+
while (this.running) {
|
|
125
|
+
try {
|
|
126
|
+
const resp = await axios.post(this.baseUrl + "/getUpdates", {
|
|
127
|
+
offset: this.lastUpdateId + 1,
|
|
128
|
+
timeout: this.pollIntervalMs + 5000,
|
|
129
|
+
allowed_updates: ["message", "callback_query"],
|
|
130
|
+
}, { timeout: this.pollIntervalMs + 10000 });
|
|
131
|
+
const updates = resp.data?.result ?? [];
|
|
132
|
+
for (const update of updates) {
|
|
133
|
+
if (update.update_id > this.lastUpdateId) {
|
|
134
|
+
this.lastUpdateId = update.update_id;
|
|
135
|
+
}
|
|
136
|
+
if (update.message && this.userMessageHandler) {
|
|
137
|
+
if (this.isAllowedChat(update.message.chat.id)) {
|
|
138
|
+
this.lastActiveChatId = Number(update.message.chat.id);
|
|
139
|
+
await this.userMessageHandler(update.message.text ?? "");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (update.callback_query) {
|
|
143
|
+
this.handleCallbackQuery(update.callback_query.data ?? "", update.callback_query.id);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
console.error("[Telegram] Poll error: " + err.message);
|
|
149
|
+
}
|
|
150
|
+
await new Promise((r) => setTimeout(r, this.pollIntervalMs));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
isAllowedChat(chatId) {
|
|
154
|
+
if (this.allowedChatIds.length === 0)
|
|
155
|
+
return true;
|
|
156
|
+
return this.allowedChatIds.includes(chatId);
|
|
157
|
+
}
|
|
158
|
+
resolveTargetChatIds() {
|
|
159
|
+
if (this.allowedChatIds.length > 0) {
|
|
160
|
+
return [...this.allowedChatIds];
|
|
161
|
+
}
|
|
162
|
+
if (this.lastActiveChatId !== null) {
|
|
163
|
+
return [this.lastActiveChatId];
|
|
164
|
+
}
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
}
|