@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
package/dist/config.js
ADDED
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
import { readFile } from "fs/promises";
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import * as os from "os";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
import YAML from "yaml";
|
|
6
|
+
const HOME = os.homedir();
|
|
7
|
+
const DEFAULT_STATE_DIR = path.join(HOME, ".qling");
|
|
8
|
+
const DEFAULT_CACHE_DIR = path.join(DEFAULT_STATE_DIR, "cache");
|
|
9
|
+
export function buildDefaultConfig() {
|
|
10
|
+
return {
|
|
11
|
+
llm: {
|
|
12
|
+
provider: "deepseek",
|
|
13
|
+
model: "deepseek-chat",
|
|
14
|
+
endpoint: "https://api.deepseek.com",
|
|
15
|
+
api_key: "",
|
|
16
|
+
request_timeout_ms: 120000,
|
|
17
|
+
},
|
|
18
|
+
runtime: {
|
|
19
|
+
workspace_dir: process.cwd(),
|
|
20
|
+
file_cache_dir: DEFAULT_CACHE_DIR,
|
|
21
|
+
file_state_dir: DEFAULT_STATE_DIR,
|
|
22
|
+
max_steps: 50,
|
|
23
|
+
parse_retries: 2,
|
|
24
|
+
max_token_budget: 120000,
|
|
25
|
+
tool_repeat_limit: 6,
|
|
26
|
+
timeout_ms: 300000,
|
|
27
|
+
},
|
|
28
|
+
features: {
|
|
29
|
+
semantic_memory: false,
|
|
30
|
+
workflow_runtime: false,
|
|
31
|
+
vision_tool: false,
|
|
32
|
+
dashboard: false,
|
|
33
|
+
dynamic_discovery: false,
|
|
34
|
+
tool_spec_boost: false,
|
|
35
|
+
},
|
|
36
|
+
logging: {
|
|
37
|
+
level: "info",
|
|
38
|
+
format: "text",
|
|
39
|
+
inspect_prompt: false,
|
|
40
|
+
inspect_request: false,
|
|
41
|
+
inspect_dump_dir: path.join(DEFAULT_STATE_DIR, "dump"),
|
|
42
|
+
},
|
|
43
|
+
tools: {
|
|
44
|
+
bash: { enabled: true },
|
|
45
|
+
read: { enabled: true },
|
|
46
|
+
write: { enabled: true },
|
|
47
|
+
todo: { enabled: true },
|
|
48
|
+
skill: { enabled: true },
|
|
49
|
+
search: { enabled: true },
|
|
50
|
+
planner: { enabled: true },
|
|
51
|
+
url_fetch: { enabled: true },
|
|
52
|
+
},
|
|
53
|
+
memory: {
|
|
54
|
+
wal_enabled: true,
|
|
55
|
+
projection_interval_ms: 5000,
|
|
56
|
+
dream_llm_enabled: true,
|
|
57
|
+
dream_turn_threshold: 24,
|
|
58
|
+
max_memories: 1000,
|
|
59
|
+
semantic: {
|
|
60
|
+
provider: "openai",
|
|
61
|
+
model: "text-embedding-3-small",
|
|
62
|
+
dim: 1536,
|
|
63
|
+
top_k: 5,
|
|
64
|
+
rebuild_policy: "incremental",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
workflow: {
|
|
68
|
+
checkpoint_dir: path.join(DEFAULT_STATE_DIR, "workflows"),
|
|
69
|
+
retry_policy: {
|
|
70
|
+
max_attempts: 3,
|
|
71
|
+
initial_delay_ms: 1000,
|
|
72
|
+
backoff_factor: 2,
|
|
73
|
+
},
|
|
74
|
+
max_parallel_states: 1,
|
|
75
|
+
},
|
|
76
|
+
vision: {
|
|
77
|
+
provider: "openai",
|
|
78
|
+
model: "gpt-4o",
|
|
79
|
+
max_image_size_mb: 10,
|
|
80
|
+
timeout_ms: 60000,
|
|
81
|
+
},
|
|
82
|
+
dashboard: {
|
|
83
|
+
enabled: false,
|
|
84
|
+
port: 9999,
|
|
85
|
+
auth_mode: "none",
|
|
86
|
+
},
|
|
87
|
+
discovery: {
|
|
88
|
+
local_dirs: [path.join(DEFAULT_STATE_DIR, "plugins")],
|
|
89
|
+
remote_manifests: [],
|
|
90
|
+
allow_unsigned: false,
|
|
91
|
+
},
|
|
92
|
+
guard: {
|
|
93
|
+
enabled: true,
|
|
94
|
+
network: {
|
|
95
|
+
url_fetch: {
|
|
96
|
+
allowed_url_prefixes: ["https://"],
|
|
97
|
+
deny_private_ips: true,
|
|
98
|
+
follow_redirects: false,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
redaction: {
|
|
102
|
+
enabled: true,
|
|
103
|
+
patterns: [],
|
|
104
|
+
},
|
|
105
|
+
audit: {
|
|
106
|
+
jsonl_path: path.join(DEFAULT_STATE_DIR, "guard", "audit", "guard_audit.jsonl"),
|
|
107
|
+
},
|
|
108
|
+
rate_limit: {
|
|
109
|
+
enabled: false,
|
|
110
|
+
max_per_minute: 30,
|
|
111
|
+
},
|
|
112
|
+
content_filter: {
|
|
113
|
+
enabled: false,
|
|
114
|
+
pii_detection: true,
|
|
115
|
+
injection_detection: true,
|
|
116
|
+
custom_patterns: [],
|
|
117
|
+
},
|
|
118
|
+
permissions: {
|
|
119
|
+
default: "allow",
|
|
120
|
+
rules: [],
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
mcp: {
|
|
124
|
+
servers: {},
|
|
125
|
+
connection_timeout_ms: 10000,
|
|
126
|
+
call_timeout_ms: 30000,
|
|
127
|
+
},
|
|
128
|
+
metrics: {
|
|
129
|
+
enabled: false,
|
|
130
|
+
dir: path.join(DEFAULT_STATE_DIR, "metrics"),
|
|
131
|
+
flush_interval_ms: 10000,
|
|
132
|
+
retention_days: 30,
|
|
133
|
+
},
|
|
134
|
+
channels: {
|
|
135
|
+
default: "console",
|
|
136
|
+
telegram: {
|
|
137
|
+
token: "",
|
|
138
|
+
poll_interval_ms: 3000,
|
|
139
|
+
allowed_chat_ids: [],
|
|
140
|
+
},
|
|
141
|
+
slack: {
|
|
142
|
+
bot_token: "",
|
|
143
|
+
app_token: "",
|
|
144
|
+
channel_ids: [],
|
|
145
|
+
poll_interval_ms: 3000,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
routes: {
|
|
149
|
+
main_loop: {
|
|
150
|
+
profile: "default",
|
|
151
|
+
fallback_profiles: [],
|
|
152
|
+
},
|
|
153
|
+
plan_create: {
|
|
154
|
+
profile: "default",
|
|
155
|
+
fallback_profiles: ["default"],
|
|
156
|
+
},
|
|
157
|
+
verify: {
|
|
158
|
+
profile: "default",
|
|
159
|
+
fallback_profiles: ["default"],
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
agents: {
|
|
163
|
+
isolation: {
|
|
164
|
+
mode: "worktree",
|
|
165
|
+
require_git: true,
|
|
166
|
+
non_git_policy: "warn",
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
export async function loadQlingConfig(cli, env = process.env) {
|
|
172
|
+
const warnings = [];
|
|
173
|
+
const defaults = buildDefaultConfig();
|
|
174
|
+
let fromFile = {};
|
|
175
|
+
let usedConfigPath;
|
|
176
|
+
const configPath = resolveConfigPath(cli.configPath);
|
|
177
|
+
if (cli.configPath && configPath && !existsSync(configPath)) {
|
|
178
|
+
throw new Error(`config file not found: ${configPath}`);
|
|
179
|
+
}
|
|
180
|
+
if (configPath && existsSync(configPath)) {
|
|
181
|
+
const raw = await readFile(configPath, "utf-8");
|
|
182
|
+
const expanded = expandEnvTemplate(raw, env, warnings);
|
|
183
|
+
fromFile = parseConfigByExt(configPath, expanded);
|
|
184
|
+
usedConfigPath = configPath;
|
|
185
|
+
}
|
|
186
|
+
const fromEnv = buildEnvConfig(env, defaults);
|
|
187
|
+
const merged = deepMerge(deepMerge(defaults, fromFile), fromEnv);
|
|
188
|
+
const withCli = applyCliOverrides(merged, cli);
|
|
189
|
+
applyPermissionModeCompat(withCli);
|
|
190
|
+
normalizeAgentsIsolationConfig(withCli);
|
|
191
|
+
normalizeRuntimeRoots(withCli);
|
|
192
|
+
await mergeLocalMcpStore(withCli, warnings);
|
|
193
|
+
return {
|
|
194
|
+
config: withCli,
|
|
195
|
+
warnings,
|
|
196
|
+
usedConfigPath,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/** 合并 ~/.qling/mcp-servers.json;env/config 中同名 server 优先 */
|
|
200
|
+
async function mergeLocalMcpStore(config, warnings) {
|
|
201
|
+
try {
|
|
202
|
+
const { loadMcpStore, defaultMcpStorePath } = await import("./mcp/store.js");
|
|
203
|
+
const storePath = defaultMcpStorePath(config.runtime.file_state_dir);
|
|
204
|
+
const store = await loadMcpStore(storePath);
|
|
205
|
+
const storeCount = Object.keys(store.servers).length;
|
|
206
|
+
if (storeCount === 0)
|
|
207
|
+
return;
|
|
208
|
+
config.mcp.servers = {
|
|
209
|
+
...store.servers,
|
|
210
|
+
...config.mcp.servers,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
catch (err) {
|
|
214
|
+
warnings.push(`mcp store merge skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
export function applyConfigToProcessEnv(config) {
|
|
218
|
+
process.env.QLING_LLM_PROVIDER = config.llm.provider;
|
|
219
|
+
process.env.QLING_LLM_MODEL = config.llm.model;
|
|
220
|
+
process.env.QLING_LLM_ENDPOINT = config.llm.endpoint;
|
|
221
|
+
process.env.QLING_LLM_REQUEST_TIMEOUT_MS = String(config.llm.request_timeout_ms);
|
|
222
|
+
if (config.llm.api_key) {
|
|
223
|
+
process.env.QLING_LLM_API_KEY = config.llm.api_key;
|
|
224
|
+
}
|
|
225
|
+
if (config.runtime.workspace_dir) {
|
|
226
|
+
process.env.QLING_WORKSPACE_DIR = config.runtime.workspace_dir;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
delete process.env.QLING_WORKSPACE_DIR;
|
|
230
|
+
}
|
|
231
|
+
process.env.QLING_FILE_CACHE_DIR = config.runtime.file_cache_dir;
|
|
232
|
+
process.env.QLING_FILE_STATE_DIR = config.runtime.file_state_dir;
|
|
233
|
+
process.env.QLING_GUARD_ENABLED = String(config.guard.enabled);
|
|
234
|
+
process.env.QLING_GUARD_NETWORK_URL_FETCH_ALLOWED_URL_PREFIXES =
|
|
235
|
+
JSON.stringify(config.guard.network.url_fetch.allowed_url_prefixes);
|
|
236
|
+
process.env.QLING_GUARD_NETWORK_URL_FETCH_DENY_PRIVATE_IPS = String(config.guard.network.url_fetch.deny_private_ips);
|
|
237
|
+
process.env.QLING_GUARD_NETWORK_URL_FETCH_FOLLOW_REDIRECTS = String(config.guard.network.url_fetch.follow_redirects);
|
|
238
|
+
process.env.QLING_GUARD_REDACTION_ENABLED = String(config.guard.redaction.enabled);
|
|
239
|
+
process.env.QLING_GUARD_REDACTION_PATTERNS = JSON.stringify(config.guard.redaction.patterns);
|
|
240
|
+
process.env.QLING_GUARD_AUDIT_JSONL_PATH = config.guard.audit.jsonl_path;
|
|
241
|
+
process.env.QLING_GUARD_RATE_LIMIT_ENABLED = String(config.guard.rate_limit.enabled);
|
|
242
|
+
process.env.QLING_GUARD_RATE_LIMIT_MAX_PER_MINUTE = String(config.guard.rate_limit.max_per_minute);
|
|
243
|
+
process.env.QLING_GUARD_CONTENT_FILTER_ENABLED = String(config.guard.content_filter.enabled);
|
|
244
|
+
process.env.QLING_GUARD_CONTENT_FILTER_PII = String(config.guard.content_filter.pii_detection);
|
|
245
|
+
process.env.QLING_GUARD_CONTENT_FILTER_INJECTION = String(config.guard.content_filter.injection_detection);
|
|
246
|
+
process.env.QLING_GUARD_CONTENT_FILTER_CUSTOM = JSON.stringify(config.guard.content_filter.custom_patterns);
|
|
247
|
+
process.env.QLING_GUARD_PERMISSIONS_DEFAULT = config.guard.permissions.default;
|
|
248
|
+
process.env.QLING_GUARD_PERMISSIONS_RULES = JSON.stringify(config.guard.permissions.rules);
|
|
249
|
+
process.env.QLING_PERMISSIONS_MODE = config.guard.permissions.default;
|
|
250
|
+
// Memory (Phase 3)
|
|
251
|
+
process.env.QLING_MEMORY_WAL_ENABLED = String(config.memory.wal_enabled);
|
|
252
|
+
process.env.QLING_MEMORY_PROJECTION_INTERVAL_MS = String(config.memory.projection_interval_ms);
|
|
253
|
+
process.env.QLING_MEMORY_DREAM_LLM_ENABLED = String(config.memory.dream_llm_enabled);
|
|
254
|
+
process.env.QLING_MEMORY_DREAM_TURN_THRESHOLD = String(config.memory.dream_turn_threshold);
|
|
255
|
+
process.env.QLING_MEMORY_MAX_MEMORIES = String(config.memory.max_memories);
|
|
256
|
+
process.env.QLING_MEMORY_SEMANTIC_PROVIDER = config.memory.semantic.provider;
|
|
257
|
+
process.env.QLING_MEMORY_SEMANTIC_MODEL = config.memory.semantic.model;
|
|
258
|
+
process.env.QLING_MEMORY_SEMANTIC_DIM = String(config.memory.semantic.dim);
|
|
259
|
+
process.env.QLING_MEMORY_SEMANTIC_TOP_K = String(config.memory.semantic.top_k);
|
|
260
|
+
process.env.QLING_MEMORY_SEMANTIC_REBUILD_POLICY = config.memory.semantic.rebuild_policy;
|
|
261
|
+
// Features
|
|
262
|
+
process.env.QLING_FEATURES_SEMANTIC_MEMORY = String(config.features.semantic_memory);
|
|
263
|
+
process.env.QLING_FEATURES_WORKFLOW_RUNTIME = String(config.features.workflow_runtime);
|
|
264
|
+
process.env.QLING_FEATURES_VISION_TOOL = String(config.features.vision_tool);
|
|
265
|
+
process.env.QLING_FEATURES_DASHBOARD = String(config.features.dashboard);
|
|
266
|
+
process.env.QLING_FEATURES_DYNAMIC_DISCOVERY = String(config.features.dynamic_discovery);
|
|
267
|
+
process.env.QLING_FEATURES_TOOL_SPEC_BOOST = String(config.features.tool_spec_boost);
|
|
268
|
+
// Workflow
|
|
269
|
+
process.env.QLING_WORKFLOW_CHECKPOINT_DIR = config.workflow.checkpoint_dir;
|
|
270
|
+
process.env.QLING_WORKFLOW_RETRY_POLICY_MAX_ATTEMPTS = String(config.workflow.retry_policy.max_attempts);
|
|
271
|
+
process.env.QLING_WORKFLOW_RETRY_POLICY_INITIAL_DELAY_MS = String(config.workflow.retry_policy.initial_delay_ms);
|
|
272
|
+
process.env.QLING_WORKFLOW_RETRY_POLICY_BACKOFF_FACTOR = String(config.workflow.retry_policy.backoff_factor);
|
|
273
|
+
process.env.QLING_WORKFLOW_MAX_PARALLEL_STATES = String(config.workflow.max_parallel_states);
|
|
274
|
+
// Vision
|
|
275
|
+
process.env.QLING_VISION_PROVIDER = config.vision.provider;
|
|
276
|
+
process.env.QLING_VISION_MODEL = config.vision.model;
|
|
277
|
+
process.env.QLING_VISION_MAX_IMAGE_SIZE_MB = String(config.vision.max_image_size_mb);
|
|
278
|
+
process.env.QLING_VISION_TIMEOUT_MS = String(config.vision.timeout_ms);
|
|
279
|
+
// Dashboard
|
|
280
|
+
process.env.QLING_DASHBOARD_ENABLED = String(config.dashboard.enabled);
|
|
281
|
+
process.env.QLING_DASHBOARD_PORT = String(config.dashboard.port);
|
|
282
|
+
process.env.QLING_DASHBOARD_AUTH_MODE = config.dashboard.auth_mode;
|
|
283
|
+
// Discovery
|
|
284
|
+
process.env.QLING_DISCOVERY_LOCAL_DIRS = JSON.stringify(config.discovery.local_dirs);
|
|
285
|
+
process.env.QLING_DISCOVERY_REMOTE_MANIFESTS = JSON.stringify(config.discovery.remote_manifests);
|
|
286
|
+
process.env.QLING_DISCOVERY_ALLOW_UNSIGNED = String(config.discovery.allow_unsigned);
|
|
287
|
+
// MCP (Phase 4)
|
|
288
|
+
process.env.QLING_MCP_SERVERS = JSON.stringify(config.mcp.servers);
|
|
289
|
+
process.env.QLING_MCP_CONNECTION_TIMEOUT_MS = String(config.mcp.connection_timeout_ms);
|
|
290
|
+
process.env.QLING_MCP_CALL_TIMEOUT_MS = String(config.mcp.call_timeout_ms);
|
|
291
|
+
// Metrics (Phase 5)
|
|
292
|
+
process.env.QLING_METRICS_ENABLED = String(config.metrics.enabled);
|
|
293
|
+
process.env.QLING_METRICS_DIR = config.metrics.dir;
|
|
294
|
+
process.env.QLING_METRICS_FLUSH_INTERVAL_MS = String(config.metrics.flush_interval_ms);
|
|
295
|
+
process.env.QLING_METRICS_RETENTION_DAYS = String(config.metrics.retention_days);
|
|
296
|
+
// Channels (Phase 5)
|
|
297
|
+
process.env.QLING_CHANNEL_DEFAULT = config.channels.default;
|
|
298
|
+
process.env.QLING_CHANNEL_TELEGRAM_TOKEN = config.channels.telegram.token;
|
|
299
|
+
process.env.QLING_CHANNEL_TELEGRAM_POLL_INTERVAL_MS = String(config.channels.telegram.poll_interval_ms);
|
|
300
|
+
process.env.QLING_CHANNEL_TELEGRAM_ALLOWED_CHAT_IDS = JSON.stringify(config.channels.telegram.allowed_chat_ids);
|
|
301
|
+
process.env.QLING_CHANNEL_SLACK_BOT_TOKEN = config.channels.slack.bot_token;
|
|
302
|
+
process.env.QLING_CHANNEL_SLACK_APP_TOKEN = config.channels.slack.app_token;
|
|
303
|
+
process.env.QLING_CHANNEL_SLACK_CHANNEL_IDS = JSON.stringify(config.channels.slack.channel_ids);
|
|
304
|
+
process.env.QLING_CHANNEL_SLACK_POLL_INTERVAL_MS = String(config.channels.slack.poll_interval_ms);
|
|
305
|
+
process.env.QLING_AGENTS_ISOLATION_MODE = config.agents.isolation.mode;
|
|
306
|
+
process.env.QLING_AGENTS_ISOLATION_REQUIRE_GIT = String(config.agents.isolation.require_git);
|
|
307
|
+
process.env.QLING_AGENTS_ISOLATION_NON_GIT_POLICY = config.agents.isolation.non_git_policy;
|
|
308
|
+
}
|
|
309
|
+
export function guardConfigFromEnv(env = process.env) {
|
|
310
|
+
const defaults = buildDefaultConfig().guard;
|
|
311
|
+
const prefixes = parseStringArray(env.QLING_GUARD_NETWORK_URL_FETCH_ALLOWED_URL_PREFIXES, defaults.network.url_fetch.allowed_url_prefixes);
|
|
312
|
+
const redactionPatterns = parseStringArray(env.QLING_GUARD_REDACTION_PATTERNS, defaults.redaction.patterns);
|
|
313
|
+
return {
|
|
314
|
+
enabled: parseBoolean(env.QLING_GUARD_ENABLED, defaults.enabled),
|
|
315
|
+
network: {
|
|
316
|
+
url_fetch: {
|
|
317
|
+
allowed_url_prefixes: prefixes,
|
|
318
|
+
deny_private_ips: parseBoolean(env.QLING_GUARD_NETWORK_URL_FETCH_DENY_PRIVATE_IPS, defaults.network.url_fetch.deny_private_ips),
|
|
319
|
+
follow_redirects: parseBoolean(env.QLING_GUARD_NETWORK_URL_FETCH_FOLLOW_REDIRECTS, defaults.network.url_fetch.follow_redirects),
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
redaction: {
|
|
323
|
+
enabled: parseBoolean(env.QLING_GUARD_REDACTION_ENABLED, defaults.redaction.enabled),
|
|
324
|
+
patterns: redactionPatterns,
|
|
325
|
+
},
|
|
326
|
+
audit: {
|
|
327
|
+
jsonl_path: env.QLING_GUARD_AUDIT_JSONL_PATH ?? defaults.audit.jsonl_path,
|
|
328
|
+
},
|
|
329
|
+
rate_limit: {
|
|
330
|
+
enabled: parseBoolean(env.QLING_GUARD_RATE_LIMIT_ENABLED, defaults.rate_limit.enabled),
|
|
331
|
+
max_per_minute: parseNumber(env.QLING_GUARD_RATE_LIMIT_MAX_PER_MINUTE, defaults.rate_limit.max_per_minute),
|
|
332
|
+
},
|
|
333
|
+
content_filter: {
|
|
334
|
+
enabled: parseBoolean(env.QLING_GUARD_CONTENT_FILTER_ENABLED, defaults.content_filter.enabled),
|
|
335
|
+
pii_detection: parseBoolean(env.QLING_GUARD_CONTENT_FILTER_PII, defaults.content_filter.pii_detection),
|
|
336
|
+
injection_detection: parseBoolean(env.QLING_GUARD_CONTENT_FILTER_INJECTION, defaults.content_filter.injection_detection),
|
|
337
|
+
custom_patterns: parseStringArray(env.QLING_GUARD_CONTENT_FILTER_CUSTOM, defaults.content_filter.custom_patterns),
|
|
338
|
+
},
|
|
339
|
+
permissions: {
|
|
340
|
+
default: resolvePermissionMode(env.QLING_GUARD_PERMISSIONS_DEFAULT ?? env.QLING_PERMISSIONS_MODE, defaults.permissions.default),
|
|
341
|
+
rules: parsePermissionRules(env.QLING_GUARD_PERMISSIONS_RULES, defaults.permissions.rules),
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function resolveConfigPath(input) {
|
|
346
|
+
if (input && input.trim()) {
|
|
347
|
+
return path.resolve(input.trim());
|
|
348
|
+
}
|
|
349
|
+
const candidates = ["qling.config.yaml", "qling.config.yml", "qling.config.json"];
|
|
350
|
+
for (const p of candidates) {
|
|
351
|
+
const abs = path.resolve(process.cwd(), p);
|
|
352
|
+
if (existsSync(abs))
|
|
353
|
+
return abs;
|
|
354
|
+
}
|
|
355
|
+
return undefined;
|
|
356
|
+
}
|
|
357
|
+
function parseConfigByExt(filePath, raw) {
|
|
358
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
359
|
+
if (ext === ".yaml" || ext === ".yml") {
|
|
360
|
+
return YAML.parse(raw) ?? {};
|
|
361
|
+
}
|
|
362
|
+
return JSON.parse(raw);
|
|
363
|
+
}
|
|
364
|
+
function expandEnvTemplate(raw, env, warnings) {
|
|
365
|
+
return raw.replace(/\$\{([A-Z0-9_]+)\}/g, (_match, name) => {
|
|
366
|
+
const val = env[name];
|
|
367
|
+
if (val === undefined) {
|
|
368
|
+
warnings.push(`Missing env variable in config template: ${name}`);
|
|
369
|
+
return "";
|
|
370
|
+
}
|
|
371
|
+
return val;
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
function buildEnvConfig(env, defaults) {
|
|
375
|
+
const flatDefaults = flattenObject(defaults);
|
|
376
|
+
const acc = {};
|
|
377
|
+
for (const [key, defaultValue] of Object.entries(flatDefaults)) {
|
|
378
|
+
const envName = toQlingEnvName(key);
|
|
379
|
+
const raw = env[envName];
|
|
380
|
+
if (raw === undefined)
|
|
381
|
+
continue;
|
|
382
|
+
setByPath(acc, key, parseEnvValue(raw, defaultValue));
|
|
383
|
+
}
|
|
384
|
+
applyLegacyRuntimeEnvAliases(acc, env);
|
|
385
|
+
if (env.QLING_PERMISSIONS_MODE !== undefined) {
|
|
386
|
+
setByPath(acc, "guard.permissions.default", resolvePermissionMode(env.QLING_PERMISSIONS_MODE, defaults.guard.permissions.default));
|
|
387
|
+
}
|
|
388
|
+
if (env.QLING_GUARD_CONTENT_FILTER_CUSTOM !== undefined) {
|
|
389
|
+
setByPath(acc, "guard.content_filter.custom_patterns", parseStringArray(env.QLING_GUARD_CONTENT_FILTER_CUSTOM, defaults.guard.content_filter.custom_patterns));
|
|
390
|
+
}
|
|
391
|
+
return acc;
|
|
392
|
+
}
|
|
393
|
+
function applyLegacyRuntimeEnvAliases(acc, env) {
|
|
394
|
+
if (env.QLING_WORKSPACE_DIR !== undefined) {
|
|
395
|
+
setByPath(acc, "runtime.workspace_dir", env.QLING_WORKSPACE_DIR);
|
|
396
|
+
}
|
|
397
|
+
if (env.QLING_FILE_CACHE_DIR !== undefined) {
|
|
398
|
+
setByPath(acc, "runtime.file_cache_dir", env.QLING_FILE_CACHE_DIR);
|
|
399
|
+
}
|
|
400
|
+
if (env.QLING_FILE_STATE_DIR !== undefined) {
|
|
401
|
+
setByPath(acc, "runtime.file_state_dir", env.QLING_FILE_STATE_DIR);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
function toQlingEnvName(keyPath) {
|
|
405
|
+
return `QLING_${keyPath.replace(/[.-]/g, "_").toUpperCase()}`;
|
|
406
|
+
}
|
|
407
|
+
function parseEnvValue(raw, defaultValue) {
|
|
408
|
+
if (typeof defaultValue === "boolean") {
|
|
409
|
+
return /^(1|true|yes|on)$/i.test(raw.trim());
|
|
410
|
+
}
|
|
411
|
+
if (typeof defaultValue === "number") {
|
|
412
|
+
const n = Number(raw);
|
|
413
|
+
return Number.isFinite(n) ? n : defaultValue;
|
|
414
|
+
}
|
|
415
|
+
if (Array.isArray(defaultValue)) {
|
|
416
|
+
const trimmed = raw.trim();
|
|
417
|
+
if (trimmed.startsWith("[") || trimmed.startsWith("{")) {
|
|
418
|
+
try {
|
|
419
|
+
const parsed = JSON.parse(trimmed);
|
|
420
|
+
return Array.isArray(parsed) ? parsed : defaultValue;
|
|
421
|
+
}
|
|
422
|
+
catch {
|
|
423
|
+
return defaultValue;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return trimmed
|
|
427
|
+
.split(",")
|
|
428
|
+
.map((v) => v.trim())
|
|
429
|
+
.filter(Boolean);
|
|
430
|
+
}
|
|
431
|
+
if (typeof defaultValue === "object" && defaultValue !== null) {
|
|
432
|
+
try {
|
|
433
|
+
const parsed = JSON.parse(raw);
|
|
434
|
+
return typeof parsed === "object" && parsed !== null ? parsed : defaultValue;
|
|
435
|
+
}
|
|
436
|
+
catch {
|
|
437
|
+
return defaultValue;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return raw;
|
|
441
|
+
}
|
|
442
|
+
function parseBoolean(raw, fallback) {
|
|
443
|
+
if (raw === undefined)
|
|
444
|
+
return fallback;
|
|
445
|
+
return /^(1|true|yes|on)$/i.test(raw.trim());
|
|
446
|
+
}
|
|
447
|
+
function parseNumber(raw, fallback) {
|
|
448
|
+
if (raw === undefined)
|
|
449
|
+
return fallback;
|
|
450
|
+
const n = Number(raw);
|
|
451
|
+
return Number.isFinite(n) ? n : fallback;
|
|
452
|
+
}
|
|
453
|
+
function parsePermissionRules(raw, fallback) {
|
|
454
|
+
if (!raw)
|
|
455
|
+
return fallback;
|
|
456
|
+
try {
|
|
457
|
+
const parsed = JSON.parse(raw);
|
|
458
|
+
if (Array.isArray(parsed)) {
|
|
459
|
+
return parsed.filter((r) => typeof r === "object" &&
|
|
460
|
+
typeof r.tool_pattern === "string" &&
|
|
461
|
+
["allow", "deny", "ask"].includes(r.decision));
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
catch {
|
|
465
|
+
// ignore
|
|
466
|
+
}
|
|
467
|
+
return fallback;
|
|
468
|
+
}
|
|
469
|
+
function parseStringArray(raw, fallback) {
|
|
470
|
+
if (!raw)
|
|
471
|
+
return fallback;
|
|
472
|
+
const trimmed = raw.trim();
|
|
473
|
+
if (trimmed.startsWith("[")) {
|
|
474
|
+
try {
|
|
475
|
+
const parsed = JSON.parse(trimmed);
|
|
476
|
+
if (Array.isArray(parsed)) {
|
|
477
|
+
return parsed.map((v) => String(v)).filter(Boolean);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
catch {
|
|
481
|
+
return fallback;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return trimmed
|
|
485
|
+
.split(",")
|
|
486
|
+
.map((v) => v.trim())
|
|
487
|
+
.filter(Boolean);
|
|
488
|
+
}
|
|
489
|
+
function resolvePermissionMode(raw, fallback) {
|
|
490
|
+
if (!raw)
|
|
491
|
+
return fallback;
|
|
492
|
+
const normalized = String(raw).trim().toLowerCase();
|
|
493
|
+
if (normalized === "allow" || normalized === "deny" || normalized === "ask") {
|
|
494
|
+
return normalized;
|
|
495
|
+
}
|
|
496
|
+
return fallback;
|
|
497
|
+
}
|
|
498
|
+
function applyPermissionModeCompat(config) {
|
|
499
|
+
const raw = config?.permissions?.mode;
|
|
500
|
+
const mapped = resolvePermissionMode(raw, config.guard.permissions.default);
|
|
501
|
+
config.guard.permissions.default = mapped;
|
|
502
|
+
}
|
|
503
|
+
function normalizeAgentsIsolationConfig(config) {
|
|
504
|
+
const defaults = buildDefaultConfig().agents.isolation;
|
|
505
|
+
const isolation = config?.agents?.isolation ?? {};
|
|
506
|
+
const modeRaw = String(isolation.mode ?? defaults.mode).toLowerCase();
|
|
507
|
+
const nonGitPolicyRaw = String(isolation.non_git_policy ?? defaults.non_git_policy).toLowerCase();
|
|
508
|
+
config.agents = config.agents ?? { isolation: defaults };
|
|
509
|
+
config.agents.isolation.mode = modeRaw === "off" ? "off" : "worktree";
|
|
510
|
+
config.agents.isolation.require_git =
|
|
511
|
+
typeof isolation.require_git === "boolean" ? isolation.require_git : defaults.require_git;
|
|
512
|
+
config.agents.isolation.non_git_policy =
|
|
513
|
+
nonGitPolicyRaw === "deny" || nonGitPolicyRaw === "off" ? nonGitPolicyRaw : "warn";
|
|
514
|
+
}
|
|
515
|
+
function applyCliOverrides(config, cli) {
|
|
516
|
+
const next = deepClone(config);
|
|
517
|
+
if (cli.workspaceDir)
|
|
518
|
+
next.runtime.workspace_dir = path.resolve(cli.workspaceDir);
|
|
519
|
+
if (cli.noWorkspace)
|
|
520
|
+
next.runtime.workspace_dir = null;
|
|
521
|
+
if (cli.fileCacheDir)
|
|
522
|
+
next.runtime.file_cache_dir = path.resolve(cli.fileCacheDir);
|
|
523
|
+
if (cli.fileStateDir)
|
|
524
|
+
next.runtime.file_state_dir = path.resolve(cli.fileStateDir);
|
|
525
|
+
if (cli.inspectPrompt !== undefined)
|
|
526
|
+
next.logging.inspect_prompt = cli.inspectPrompt;
|
|
527
|
+
if (cli.inspectRequest !== undefined)
|
|
528
|
+
next.logging.inspect_request = cli.inspectRequest;
|
|
529
|
+
if (cli.logFormat)
|
|
530
|
+
next.logging.format = cli.logFormat;
|
|
531
|
+
if (cli.logLevel)
|
|
532
|
+
next.logging.level = cli.logLevel;
|
|
533
|
+
if (cli.model)
|
|
534
|
+
next.llm.model = cli.model;
|
|
535
|
+
if (cli.provider)
|
|
536
|
+
next.llm.provider = cli.provider;
|
|
537
|
+
if (cli.endpoint)
|
|
538
|
+
next.llm.endpoint = cli.endpoint;
|
|
539
|
+
if (cli.apiKey)
|
|
540
|
+
next.llm.api_key = cli.apiKey;
|
|
541
|
+
return next;
|
|
542
|
+
}
|
|
543
|
+
function normalizeRuntimeRoots(config) {
|
|
544
|
+
config.runtime.file_state_dir = path.resolve(config.runtime.file_state_dir);
|
|
545
|
+
config.runtime.file_cache_dir = path.resolve(config.runtime.file_cache_dir);
|
|
546
|
+
if (config.runtime.workspace_dir) {
|
|
547
|
+
config.runtime.workspace_dir = path.resolve(config.runtime.workspace_dir);
|
|
548
|
+
}
|
|
549
|
+
if (!config.runtime.file_cache_dir.startsWith(config.runtime.file_state_dir)) {
|
|
550
|
+
config.runtime.file_cache_dir = path.join(config.runtime.file_state_dir, "cache");
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
function flattenObject(input, parent = "", out = {}) {
|
|
554
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
555
|
+
if (parent)
|
|
556
|
+
out[parent] = input;
|
|
557
|
+
return out;
|
|
558
|
+
}
|
|
559
|
+
const obj = input;
|
|
560
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
561
|
+
const key = parent ? `${parent}.${k}` : k;
|
|
562
|
+
if (typeof v === "object" && v !== null && !Array.isArray(v)) {
|
|
563
|
+
flattenObject(v, key, out);
|
|
564
|
+
}
|
|
565
|
+
else {
|
|
566
|
+
out[key] = v;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
return out;
|
|
570
|
+
}
|
|
571
|
+
function setByPath(target, keyPath, value) {
|
|
572
|
+
const parts = keyPath.split(".");
|
|
573
|
+
let cur = target;
|
|
574
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
575
|
+
const p = parts[i];
|
|
576
|
+
if (typeof cur[p] !== "object" || cur[p] === null || Array.isArray(cur[p])) {
|
|
577
|
+
cur[p] = {};
|
|
578
|
+
}
|
|
579
|
+
cur = cur[p];
|
|
580
|
+
}
|
|
581
|
+
cur[parts[parts.length - 1]] = value;
|
|
582
|
+
}
|
|
583
|
+
function deepClone(v) {
|
|
584
|
+
return structuredClone(v);
|
|
585
|
+
}
|
|
586
|
+
function deepMerge(base, override) {
|
|
587
|
+
if (override === undefined || override === null)
|
|
588
|
+
return deepClone(base);
|
|
589
|
+
if (typeof base !== "object" || base === null)
|
|
590
|
+
return deepClone(override);
|
|
591
|
+
if (typeof override !== "object" || override === null)
|
|
592
|
+
return deepClone(override);
|
|
593
|
+
if (Array.isArray(base) || Array.isArray(override))
|
|
594
|
+
return deepClone(override);
|
|
595
|
+
const out = { ...base };
|
|
596
|
+
for (const [k, v] of Object.entries(override)) {
|
|
597
|
+
if (v === undefined)
|
|
598
|
+
continue;
|
|
599
|
+
const cur = out[k];
|
|
600
|
+
if (typeof cur === "object" &&
|
|
601
|
+
cur !== null &&
|
|
602
|
+
!Array.isArray(cur) &&
|
|
603
|
+
typeof v === "object" &&
|
|
604
|
+
v !== null &&
|
|
605
|
+
!Array.isArray(v)) {
|
|
606
|
+
out[k] = deepMerge(cur, v);
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
out[k] = deepClone(v);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
return out;
|
|
613
|
+
}
|
|
614
|
+
/* ===== Runtime Secret Scanner (20260617) ===== */
|
|
615
|
+
const SECRET_VAR_NAME_REGEXES = [
|
|
616
|
+
/API_KEY$/i,
|
|
617
|
+
/^API_KEY$/i,
|
|
618
|
+
/TOKEN$/i,
|
|
619
|
+
/SECRET$/i,
|
|
620
|
+
/AUTH_TOKEN$/i,
|
|
621
|
+
/ACCESS_KEY$/i,
|
|
622
|
+
/PRIVATE_KEY$/i,
|
|
623
|
+
];
|
|
624
|
+
/**
|
|
625
|
+
* Pure scanner for a single .env file content.
|
|
626
|
+
* Returns only varName + file. NEVER includes or logs the secret value.
|
|
627
|
+
*/
|
|
628
|
+
export function scanDotEnvContent(filePath, content) {
|
|
629
|
+
const hits = [];
|
|
630
|
+
const lines = content.split(/\r?\n/);
|
|
631
|
+
for (const raw of lines) {
|
|
632
|
+
const line = raw.trim();
|
|
633
|
+
if (!line || line.startsWith('#') || line.startsWith(';'))
|
|
634
|
+
continue;
|
|
635
|
+
const eqIdx = line.indexOf('=');
|
|
636
|
+
if (eqIdx <= 0)
|
|
637
|
+
continue;
|
|
638
|
+
const varName = line.slice(0, eqIdx).trim();
|
|
639
|
+
const value = line.slice(eqIdx + 1).trim();
|
|
640
|
+
if (!value)
|
|
641
|
+
continue;
|
|
642
|
+
const looksLikeSecret = SECRET_VAR_NAME_REGEXES.some((re) => re.test(varName));
|
|
643
|
+
if (looksLikeSecret) {
|
|
644
|
+
hits.push({ file: filePath, varName });
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
return hits;
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Scan common runtime locations for plaintext secrets in .env files.
|
|
651
|
+
* Locations: ~/.qling/.env and process.cwd()/.env
|
|
652
|
+
* Only reports hits; never emits values.
|
|
653
|
+
*/
|
|
654
|
+
/** 参与密钥扫描的 env 文件名(相对目录) */
|
|
655
|
+
export const SECRET_ENV_FILENAMES = [
|
|
656
|
+
".env",
|
|
657
|
+
".env.local",
|
|
658
|
+
".env.development",
|
|
659
|
+
".env.production",
|
|
660
|
+
".env.test",
|
|
661
|
+
".env.development.local",
|
|
662
|
+
".env.production.local",
|
|
663
|
+
];
|
|
664
|
+
export function listSecretScanCandidatePaths(cwd = process.cwd(), stateDir) {
|
|
665
|
+
const home = os.homedir();
|
|
666
|
+
const qlingDir = stateDir || path.join(home, ".qling");
|
|
667
|
+
const paths = [path.join(qlingDir, ".env")];
|
|
668
|
+
for (const name of SECRET_ENV_FILENAMES) {
|
|
669
|
+
paths.push(path.join(cwd, name));
|
|
670
|
+
}
|
|
671
|
+
// 去重
|
|
672
|
+
return Array.from(new Set(paths.map((p) => path.resolve(p))));
|
|
673
|
+
}
|
|
674
|
+
export async function scanRuntimeDotEnvSecrets(stateDir) {
|
|
675
|
+
const { readFile } = await import("fs/promises");
|
|
676
|
+
const hits = [];
|
|
677
|
+
const candidates = listSecretScanCandidatePaths(process.cwd(), stateDir);
|
|
678
|
+
for (const p of candidates) {
|
|
679
|
+
try {
|
|
680
|
+
if (existsSync(p)) {
|
|
681
|
+
const content = await readFile(p, "utf8");
|
|
682
|
+
hits.push(...scanDotEnvContent(p, content));
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
catch {
|
|
686
|
+
// best-effort scanner, ignore unreadable files
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
return hits;
|
|
690
|
+
}
|