@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,138 @@
|
|
|
1
|
+
import { DEFAULT_LOOP_INTERVAL_MS, resolveLoopPrompt } from "../session/loop-prompt.js";
|
|
2
|
+
import { evaluateIsolationPolicy } from "../agents/isolation-policy.js";
|
|
3
|
+
function parseIntervalToken(token) {
|
|
4
|
+
if (!token)
|
|
5
|
+
return null;
|
|
6
|
+
const match = token.trim().match(/^(\d+)(s|m|h|d)$/i);
|
|
7
|
+
if (!match)
|
|
8
|
+
return null;
|
|
9
|
+
const value = Number(match[1]);
|
|
10
|
+
const unit = match[2].toLowerCase();
|
|
11
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
12
|
+
return null;
|
|
13
|
+
switch (unit) {
|
|
14
|
+
case "s":
|
|
15
|
+
return value * 1000;
|
|
16
|
+
case "m":
|
|
17
|
+
return value * 60 * 1000;
|
|
18
|
+
case "h":
|
|
19
|
+
return value * 60 * 60 * 1000;
|
|
20
|
+
case "d":
|
|
21
|
+
return value * 24 * 60 * 60 * 1000;
|
|
22
|
+
default:
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function formatInterval(ms) {
|
|
27
|
+
if (ms % (24 * 60 * 60 * 1000) === 0)
|
|
28
|
+
return `${ms / (24 * 60 * 60 * 1000)}d`;
|
|
29
|
+
if (ms % (60 * 60 * 1000) === 0)
|
|
30
|
+
return `${ms / (60 * 60 * 1000)}h`;
|
|
31
|
+
if (ms % (60 * 1000) === 0)
|
|
32
|
+
return `${ms / (60 * 1000)}m`;
|
|
33
|
+
if (ms % 1000 === 0)
|
|
34
|
+
return `${ms / 1000}s`;
|
|
35
|
+
return `${ms}ms`;
|
|
36
|
+
}
|
|
37
|
+
export const loopCommand = {
|
|
38
|
+
name: "/loop",
|
|
39
|
+
aliases: ["/循环"],
|
|
40
|
+
description: "在当前 session 中周期性重跑 prompt",
|
|
41
|
+
usage: "/loop [interval] [prompt]",
|
|
42
|
+
execute: async (args, context) => {
|
|
43
|
+
const scheduler = context.scheduler;
|
|
44
|
+
if (!scheduler || typeof scheduler.createLoopTask !== "function") {
|
|
45
|
+
context.writeError("❌ 当前会话未启用 loop 调度器。");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const sub = args[0]?.toLowerCase();
|
|
49
|
+
const daemonMode = sub === "daemon" || sub === "durable" || sub === "bg";
|
|
50
|
+
if (sub === "stop" || sub === "cancel") {
|
|
51
|
+
const taskId = args[1];
|
|
52
|
+
if (!taskId) {
|
|
53
|
+
context.writeError("❌ 用法: /loop stop <id>");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const canceled = await scheduler.cancelTask(taskId);
|
|
57
|
+
context.writeLine("");
|
|
58
|
+
context.writeLine(`🛑 已停止 loop 任务 ${canceled.id}`);
|
|
59
|
+
context.writeLine("");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const loopArgs = daemonMode ? args.slice(1) : args;
|
|
63
|
+
const leadingInterval = parseIntervalToken(loopArgs[0]);
|
|
64
|
+
const promptArgs = leadingInterval === null ? loopArgs : loopArgs.slice(1);
|
|
65
|
+
const inlinePrompt = promptArgs.join(" ").trim();
|
|
66
|
+
const resolved = await resolveLoopPrompt({
|
|
67
|
+
workspaceDir: context.workspaceDir ??
|
|
68
|
+
(typeof context.agentLoop.getWorkspaceDir === "function"
|
|
69
|
+
? context.agentLoop.getWorkspaceDir()
|
|
70
|
+
: process.cwd()),
|
|
71
|
+
homeDir: context.homeDir,
|
|
72
|
+
inlinePrompt: inlinePrompt || undefined,
|
|
73
|
+
});
|
|
74
|
+
const intervalMs = leadingInterval ?? DEFAULT_LOOP_INTERVAL_MS;
|
|
75
|
+
const mode = leadingInterval === null ? "default" : "fixed";
|
|
76
|
+
if (daemonMode) {
|
|
77
|
+
const workspaceDir = context.workspaceDir ??
|
|
78
|
+
(typeof context.agentLoop.getWorkspaceDir === "function"
|
|
79
|
+
? context.agentLoop.getWorkspaceDir()
|
|
80
|
+
: process.cwd());
|
|
81
|
+
const isolation = await evaluateIsolationPolicy({
|
|
82
|
+
workspaceDir,
|
|
83
|
+
mode: process.env.QLING_AGENTS_ISOLATION_MODE === "off" ? "off" : "worktree",
|
|
84
|
+
requireGit: process.env.QLING_AGENTS_ISOLATION_REQUIRE_GIT !== "false",
|
|
85
|
+
nonGitPolicy: process.env.QLING_AGENTS_ISOLATION_NON_GIT_POLICY === "deny"
|
|
86
|
+
? "deny"
|
|
87
|
+
: process.env.QLING_AGENTS_ISOLATION_NON_GIT_POLICY === "off"
|
|
88
|
+
? "off"
|
|
89
|
+
: "warn",
|
|
90
|
+
});
|
|
91
|
+
if (isolation.level === "deny") {
|
|
92
|
+
context.writeError(`❌ ${isolation.message ?? "当前 workspace 不允许 daemon 隔离执行。"}`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (isolation.level === "warn") {
|
|
96
|
+
context.writeLine(`⚠️ ${isolation.message ?? "当前 workspace 不是 Git 仓库,已降级执行。"}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const task = daemonMode
|
|
100
|
+
? await createDaemonLoopTask(context, {
|
|
101
|
+
prompt: resolved.prompt,
|
|
102
|
+
intervalMs,
|
|
103
|
+
mode,
|
|
104
|
+
})
|
|
105
|
+
: await scheduler.createLoopTask({
|
|
106
|
+
prompt: resolved.prompt,
|
|
107
|
+
intervalMs,
|
|
108
|
+
mode,
|
|
109
|
+
runner: "session",
|
|
110
|
+
});
|
|
111
|
+
context.writeLine("");
|
|
112
|
+
context.writeLine(`🔁 【已创建 ${daemonMode ? "Daemon" : "Loop"} 任务】`);
|
|
113
|
+
context.writeLine("-----------------------------------------");
|
|
114
|
+
context.writeLine(`任务 ID : ${task.id}`);
|
|
115
|
+
context.writeLine(`执行间隔 : ${formatInterval(intervalMs)}`);
|
|
116
|
+
context.writeLine(`模式 : ${mode}`);
|
|
117
|
+
context.writeLine(`Runner : ${task.runner ?? (daemonMode ? "daemon" : "session")}`);
|
|
118
|
+
context.writeLine(`Prompt 来源: ${resolved.source}${resolved.path ? ` (${resolved.path})` : ""}`);
|
|
119
|
+
context.writeLine(`Prompt 摘要: ${resolved.prompt.slice(0, 80)}`);
|
|
120
|
+
if (leadingInterval === null && inlinePrompt) {
|
|
121
|
+
context.writeLine("说明 : 当前版本对“只给 prompt”的 /loop 采用固定 10m 轮询。");
|
|
122
|
+
}
|
|
123
|
+
context.writeLine("-----------------------------------------");
|
|
124
|
+
context.writeLine("");
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
async function createDaemonLoopTask(context, payload) {
|
|
128
|
+
if (!context.daemonSessionApi?.createLoopTask) {
|
|
129
|
+
throw new Error("当前会话未启用 daemon session API。请先启动 `qling daemon start`。");
|
|
130
|
+
}
|
|
131
|
+
if (typeof context.agentLoop?.checkpointSession === "function") {
|
|
132
|
+
await context.agentLoop.checkpointSession();
|
|
133
|
+
}
|
|
134
|
+
return context.daemonSessionApi.createLoopTask(context.agentLoop.getSessionId(), {
|
|
135
|
+
...payload,
|
|
136
|
+
runner: "daemon",
|
|
137
|
+
});
|
|
138
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAO1C,eAAO,MAAM,UAAU,EAAE,YAuDxB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { buildLocalMcpReport, formatLocalMcpReport } from "../mcp-report.js";
|
|
2
|
+
import { formatMcpPresetTable } from "../mcp/presets.js";
|
|
3
|
+
import { defaultMcpStorePath, loadMcpStore } from "../mcp/store.js";
|
|
4
|
+
function parseTimeoutEnv(name) {
|
|
5
|
+
const value = Number(process.env[name]);
|
|
6
|
+
return Number.isFinite(value) && value >= 0 ? value : 0;
|
|
7
|
+
}
|
|
8
|
+
export const mcpCommand = {
|
|
9
|
+
name: "/mcp",
|
|
10
|
+
aliases: ["/外部工具"],
|
|
11
|
+
description: "查看本地 MCP 配置;提示 presets / add",
|
|
12
|
+
usage: "/mcp [status|presets|list]",
|
|
13
|
+
argumentHint: "[status|presets|list]",
|
|
14
|
+
execute: async (args, context) => {
|
|
15
|
+
const sub = (args[0] ?? "status").toLowerCase();
|
|
16
|
+
if (sub === "presets" || sub === "preset") {
|
|
17
|
+
context.writeLine("");
|
|
18
|
+
context.writeLine("可用 MCP 预设:");
|
|
19
|
+
context.writeLine("-----------------------------------------");
|
|
20
|
+
for (const line of formatMcpPresetTable()) {
|
|
21
|
+
context.writeLine(line);
|
|
22
|
+
}
|
|
23
|
+
context.writeLine("-----------------------------------------");
|
|
24
|
+
context.writeLine("添加: qling mcp add <preset>");
|
|
25
|
+
context.writeLine("");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (sub === "list" || sub === "ls") {
|
|
29
|
+
const store = await loadMcpStore(defaultMcpStorePath());
|
|
30
|
+
const names = Object.keys(store.servers).sort();
|
|
31
|
+
context.writeLine("");
|
|
32
|
+
context.writeLine("本机 MCP store:");
|
|
33
|
+
context.writeLine("-----------------------------------------");
|
|
34
|
+
if (names.length === 0) {
|
|
35
|
+
context.writeLine("(空) — qling mcp add filesystem");
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
for (const name of names) {
|
|
39
|
+
const s = store.servers[name];
|
|
40
|
+
context.writeLine(`- ${name}: ${s.command} ${(s.args ?? []).join(" ")}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
context.writeLine("-----------------------------------------");
|
|
44
|
+
context.writeLine("");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const report = buildLocalMcpReport({
|
|
48
|
+
servers: {},
|
|
49
|
+
connection_timeout_ms: parseTimeoutEnv("QLING_MCP_CONNECTION_TIMEOUT_MS"),
|
|
50
|
+
call_timeout_ms: parseTimeoutEnv("QLING_MCP_CALL_TIMEOUT_MS"),
|
|
51
|
+
}, process.env);
|
|
52
|
+
for (const line of formatLocalMcpReport(report)) {
|
|
53
|
+
context.writeLine(line);
|
|
54
|
+
}
|
|
55
|
+
context.writeLine("提示: /mcp presets · qling mcp add <preset> · qling mcp list");
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/commands/memory.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA8C1C,eAAO,MAAM,aAAa,EAAE,YAgL3B,CAAC"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { homedir } from "os";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { buildLocalMemoryReport, buildLocalMemorySourcesReport, findLocalMemoryEntry, formatLocalMemoryEntry, formatLocalMemoryGraphReport, formatLocalMemoryPracticesReport, formatLocalMemoryReport, formatLocalMemorySearchReport, formatLocalMemorySourcesReport, listLocalMemoryGraph, listLocalMemoryPractices, parseMemoryReportCount, parseMemorySearchArgs, searchLocalMemoryEntries, } from "../memory-report.js";
|
|
4
|
+
function resolveStateDir(context) {
|
|
5
|
+
const agentLoop = context.agentLoop;
|
|
6
|
+
return agentLoop.getRuntimeRootDir?.()
|
|
7
|
+
|| process.env.QLING_FILE_STATE_DIR
|
|
8
|
+
|| join(context.homeDir ?? homedir(), ".qling");
|
|
9
|
+
}
|
|
10
|
+
function normalizeSubcommand(value) {
|
|
11
|
+
const normalized = (value ?? "").toLowerCase();
|
|
12
|
+
const aliases = {
|
|
13
|
+
"": "list",
|
|
14
|
+
"status": "list",
|
|
15
|
+
"状态": "list",
|
|
16
|
+
"list": "list",
|
|
17
|
+
"列表": "list",
|
|
18
|
+
"practice": "practices",
|
|
19
|
+
"practices": "practices",
|
|
20
|
+
"实践": "practices",
|
|
21
|
+
"经验": "practices",
|
|
22
|
+
"graph": "graph",
|
|
23
|
+
"图谱": "graph",
|
|
24
|
+
"知识图谱": "graph",
|
|
25
|
+
"search": "search",
|
|
26
|
+
"搜索": "search",
|
|
27
|
+
"source": "sources",
|
|
28
|
+
"sources": "sources",
|
|
29
|
+
"来源": "sources",
|
|
30
|
+
"来源图": "sources",
|
|
31
|
+
"show": "show",
|
|
32
|
+
"查看": "show",
|
|
33
|
+
"详情": "show",
|
|
34
|
+
"add": "add",
|
|
35
|
+
"添加": "add",
|
|
36
|
+
"delete": "delete",
|
|
37
|
+
"remove": "delete",
|
|
38
|
+
"删除": "delete",
|
|
39
|
+
"edit": "edit",
|
|
40
|
+
"update": "edit",
|
|
41
|
+
"修改": "edit",
|
|
42
|
+
"更新": "edit",
|
|
43
|
+
};
|
|
44
|
+
return aliases[normalized] ?? normalized;
|
|
45
|
+
}
|
|
46
|
+
export const memoryCommand = {
|
|
47
|
+
name: "/memory",
|
|
48
|
+
aliases: ["/记忆"],
|
|
49
|
+
description: "查看本地持久化记忆索引",
|
|
50
|
+
usage: "/memory [list] [global|workspace] [count] | /memory add <fact> [--global] | /memory delete <id> | /memory edit <id> <new_content>",
|
|
51
|
+
execute: async (args, context) => {
|
|
52
|
+
const stateDir = resolveStateDir(context);
|
|
53
|
+
const [rawSub, ...rest] = args;
|
|
54
|
+
const sub = normalizeSubcommand(rawSub);
|
|
55
|
+
const agentLoop = context.agentLoop;
|
|
56
|
+
const memoryStore = agentLoop.getMemoryStore?.();
|
|
57
|
+
const workspaceMemoryDir = memoryStore ? memoryStore.getWorkspaceMemoryDir() : join(stateDir, "memory");
|
|
58
|
+
const globalMemoryDir = memoryStore ? memoryStore.getGlobalMemoryDir() : join(stateDir, "memory/global");
|
|
59
|
+
if (sub === "add") {
|
|
60
|
+
const isGlobal = args.includes("--global");
|
|
61
|
+
const factParts = rest.filter(x => x !== "--global");
|
|
62
|
+
const fact = factParts.join(" ").trim();
|
|
63
|
+
if (!fact) {
|
|
64
|
+
context.writeError("用法: /memory add <fact> [--global]");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (memoryStore) {
|
|
68
|
+
memoryStore.add(fact, "manual", 0.8, isGlobal ? "global" : "workspace");
|
|
69
|
+
await memoryStore.saveToDisk();
|
|
70
|
+
context.writeLine(`成功添加记忆到 ${isGlobal ? "全局" : "工作区"}。`);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
context.writeError("当前会话不支持内存存储。");
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (sub === "delete" || sub === "remove") {
|
|
78
|
+
const id = rest[0];
|
|
79
|
+
if (!id) {
|
|
80
|
+
context.writeError("用法: /memory delete <id>");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (memoryStore) {
|
|
84
|
+
const removedWs = memoryStore.remove(id, "workspace");
|
|
85
|
+
const removedGlobal = memoryStore.remove(id, "global");
|
|
86
|
+
if (removedWs || removedGlobal) {
|
|
87
|
+
await memoryStore.saveToDisk();
|
|
88
|
+
context.writeLine(`成功删除记忆 ID: ${id}`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
context.writeError(`未找到记忆 ID: ${id}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
context.writeError("当前会话不支持内存存储。");
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (sub === "edit" || sub === "update") {
|
|
100
|
+
const id = rest[0];
|
|
101
|
+
const newContent = rest.slice(1).join(" ").trim();
|
|
102
|
+
if (!id || !newContent) {
|
|
103
|
+
context.writeError("用法: /memory edit <id> <new_content>");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (memoryStore) {
|
|
107
|
+
const updatedWs = memoryStore.update(id, { content: newContent }, "workspace");
|
|
108
|
+
const updatedGlobal = memoryStore.update(id, { content: newContent }, "global");
|
|
109
|
+
if (updatedWs || updatedGlobal) {
|
|
110
|
+
await memoryStore.saveToDisk();
|
|
111
|
+
context.writeLine(`成功更新记忆 ID: ${id}`);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
context.writeError(`未找到记忆 ID: ${id}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
context.writeError("当前会话不支持内存存储。");
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (sub === "show") {
|
|
123
|
+
const id = rest[0];
|
|
124
|
+
if (!id) {
|
|
125
|
+
context.writeError("用法: /memory show <id>");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const entry = (await findLocalMemoryEntry(workspaceMemoryDir, id)) || (await findLocalMemoryEntry(globalMemoryDir, id));
|
|
129
|
+
if (entry) {
|
|
130
|
+
for (const line of formatLocalMemoryEntry(entry)) {
|
|
131
|
+
context.writeLine(line);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
context.writeError(`未找到记忆 ID: ${id}`);
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (sub === "search") {
|
|
140
|
+
const request = parseMemorySearchArgs(rest);
|
|
141
|
+
if (!request.query) {
|
|
142
|
+
context.writeError("用法: /memory search <query> [count]");
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const wsReport = await searchLocalMemoryEntries(workspaceMemoryDir, request);
|
|
146
|
+
const globalReport = await searchLocalMemoryEntries(globalMemoryDir, request);
|
|
147
|
+
const mergedEntries = [
|
|
148
|
+
...wsReport.entries.map(e => ({ ...e, preview: "[工作区] " + e.preview })),
|
|
149
|
+
...globalReport.entries.map(e => ({ ...e, preview: "[全局] " + e.preview }))
|
|
150
|
+
];
|
|
151
|
+
mergedEntries.sort((a, b) => b.score - a.score);
|
|
152
|
+
const report = {
|
|
153
|
+
stateDir: workspaceMemoryDir,
|
|
154
|
+
memoryDir: workspaceMemoryDir,
|
|
155
|
+
memoryFile: join(workspaceMemoryDir, "memory.json"),
|
|
156
|
+
query: request.query,
|
|
157
|
+
entries: mergedEntries.slice(0, request.count),
|
|
158
|
+
totalEntries: wsReport.totalEntries + globalReport.totalEntries,
|
|
159
|
+
totalMatches: wsReport.totalMatches + globalReport.totalMatches,
|
|
160
|
+
requestedCount: request.count,
|
|
161
|
+
truncated: mergedEntries.length > request.count,
|
|
162
|
+
warnings: [...wsReport.warnings, ...globalReport.warnings],
|
|
163
|
+
};
|
|
164
|
+
for (const line of formatLocalMemorySearchReport(report)) {
|
|
165
|
+
context.writeLine(line);
|
|
166
|
+
}
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (sub === "practices") {
|
|
170
|
+
const report = await listLocalMemoryPractices(workspaceMemoryDir, {
|
|
171
|
+
count: parseMemoryReportCount(rest[0]),
|
|
172
|
+
});
|
|
173
|
+
for (const line of formatLocalMemoryPracticesReport(report)) {
|
|
174
|
+
context.writeLine(line);
|
|
175
|
+
}
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (sub === "sources") {
|
|
179
|
+
const report = await buildLocalMemorySourcesReport(workspaceMemoryDir);
|
|
180
|
+
for (const line of formatLocalMemorySourcesReport(report)) {
|
|
181
|
+
context.writeLine(line);
|
|
182
|
+
}
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (sub === "graph") {
|
|
186
|
+
const report = await listLocalMemoryGraph(workspaceMemoryDir, {
|
|
187
|
+
count: parseMemoryReportCount(rest[0]),
|
|
188
|
+
});
|
|
189
|
+
for (const line of formatLocalMemoryGraphReport(report)) {
|
|
190
|
+
context.writeLine(line);
|
|
191
|
+
}
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
// List operation
|
|
195
|
+
let targetDir = workspaceMemoryDir;
|
|
196
|
+
let countVal = undefined;
|
|
197
|
+
if (rawSub === "global" || rawSub === "全局") {
|
|
198
|
+
targetDir = globalMemoryDir;
|
|
199
|
+
countVal = rest[0];
|
|
200
|
+
}
|
|
201
|
+
else if (rawSub === "workspace" || rawSub === "工作区") {
|
|
202
|
+
targetDir = workspaceMemoryDir;
|
|
203
|
+
countVal = rest[0];
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
countVal = rawSub === "list" ? rest[0] : rawSub;
|
|
207
|
+
}
|
|
208
|
+
const report = await buildLocalMemoryReport(targetDir, {
|
|
209
|
+
count: parseMemoryReportCount(countVal),
|
|
210
|
+
});
|
|
211
|
+
for (const line of formatLocalMemoryReport(report)) {
|
|
212
|
+
context.writeLine(line);
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mission.d.ts","sourceRoot":"","sources":["../../src/commands/mission.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA0E1C,eAAO,MAAM,cAAc,EAAE,YAgE5B,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { homedir } from "os";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { renderAgentsView, renderMissionEvents } from "../cli/mission-views.js";
|
|
4
|
+
import { MissionManager } from "../mission/manager.js";
|
|
5
|
+
const SUBCOMMAND_ALIASES = {
|
|
6
|
+
"": "list",
|
|
7
|
+
"列表": "list",
|
|
8
|
+
"查看": "show",
|
|
9
|
+
detail: "show",
|
|
10
|
+
"详情": "show",
|
|
11
|
+
"日志": "logs",
|
|
12
|
+
log: "logs",
|
|
13
|
+
"暂停": "pause",
|
|
14
|
+
"恢复": "resume",
|
|
15
|
+
"取消": "cancel",
|
|
16
|
+
"停止": "cancel",
|
|
17
|
+
"终止": "cancel",
|
|
18
|
+
stop: "cancel",
|
|
19
|
+
terminate: "cancel",
|
|
20
|
+
"重试": "retry",
|
|
21
|
+
respawn: "retry",
|
|
22
|
+
};
|
|
23
|
+
function resolveStateDir(context) {
|
|
24
|
+
const loop = context.agentLoop;
|
|
25
|
+
const runtimeRoot = typeof loop.getRuntimeRootDir === "function" ? loop.getRuntimeRootDir() : undefined;
|
|
26
|
+
return runtimeRoot || process.env.QLING_FILE_STATE_DIR || join(context.homeDir ?? homedir(), ".qling");
|
|
27
|
+
}
|
|
28
|
+
function normalizeSubcommand(value) {
|
|
29
|
+
const key = (value ?? "").toLowerCase();
|
|
30
|
+
return SUBCOMMAND_ALIASES[key] ?? key;
|
|
31
|
+
}
|
|
32
|
+
function formatTimestamp(value) {
|
|
33
|
+
return value ? new Date(value).toLocaleString() : "-";
|
|
34
|
+
}
|
|
35
|
+
function formatMissionDetail(mission) {
|
|
36
|
+
const lines = [
|
|
37
|
+
"",
|
|
38
|
+
"🧭 【使命详情】",
|
|
39
|
+
"-----------------------------------------",
|
|
40
|
+
`ID : ${mission.id}`,
|
|
41
|
+
`名称 : ${mission.name}`,
|
|
42
|
+
`状态 : ${mission.status}`,
|
|
43
|
+
`会话 : ${mission.sessionId}`,
|
|
44
|
+
`创建 : ${formatTimestamp(mission.createdAt)}`,
|
|
45
|
+
`更新 : ${formatTimestamp(mission.updatedAt)}`,
|
|
46
|
+
];
|
|
47
|
+
if (mission.sourceMissionId) {
|
|
48
|
+
lines.push(`来源使命 : ${mission.sourceMissionId}`);
|
|
49
|
+
}
|
|
50
|
+
if (mission.error) {
|
|
51
|
+
lines.push(`错误 : [${mission.error.code}] ${mission.error.message}`);
|
|
52
|
+
}
|
|
53
|
+
lines.push(`任务 : ${mission.description}`);
|
|
54
|
+
lines.push("-----------------------------------------", "");
|
|
55
|
+
return lines;
|
|
56
|
+
}
|
|
57
|
+
async function createManager(context) {
|
|
58
|
+
const manager = new MissionManager(resolveStateDir(context));
|
|
59
|
+
await manager.init();
|
|
60
|
+
return manager;
|
|
61
|
+
}
|
|
62
|
+
function requireMissionId(id, usage, context) {
|
|
63
|
+
if (id)
|
|
64
|
+
return id;
|
|
65
|
+
context.writeError(`❌ 用法: ${usage}`);
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
export const missionCommand = {
|
|
69
|
+
name: "/mission",
|
|
70
|
+
aliases: ["/使命"],
|
|
71
|
+
description: "查看或控制本地 mission",
|
|
72
|
+
usage: "/mission list|show|logs|pause|resume|cancel|terminate|retry <id>",
|
|
73
|
+
execute: async (args, context) => {
|
|
74
|
+
const sub = normalizeSubcommand(args[0]);
|
|
75
|
+
const id = args[1];
|
|
76
|
+
try {
|
|
77
|
+
const manager = await createManager(context);
|
|
78
|
+
if (sub === "list") {
|
|
79
|
+
context.writeLine(renderAgentsView(manager.listMissions()));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (sub === "show") {
|
|
83
|
+
const missionId = requireMissionId(id, "/mission show <id>", context);
|
|
84
|
+
if (!missionId)
|
|
85
|
+
return;
|
|
86
|
+
for (const line of formatMissionDetail(manager.getMissionOrThrow(missionId))) {
|
|
87
|
+
context.writeLine(line);
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (sub === "logs") {
|
|
92
|
+
const missionId = requireMissionId(id, "/mission logs <id>", context);
|
|
93
|
+
if (!missionId)
|
|
94
|
+
return;
|
|
95
|
+
context.writeLine(renderMissionEvents(await manager.getMissionLogs(missionId)));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (sub === "pause" || sub === "resume" || sub === "cancel") {
|
|
99
|
+
const missionId = requireMissionId(id, `/mission ${sub} <id>`, context);
|
|
100
|
+
if (!missionId)
|
|
101
|
+
return;
|
|
102
|
+
const mission = sub === "pause"
|
|
103
|
+
? await manager.pauseMission(missionId, "slash_local")
|
|
104
|
+
: sub === "resume"
|
|
105
|
+
? await manager.resumeMission(missionId, "slash_local")
|
|
106
|
+
: await manager.cancelMission(missionId, "slash_local");
|
|
107
|
+
for (const line of formatMissionDetail(mission)) {
|
|
108
|
+
context.writeLine(line);
|
|
109
|
+
}
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (sub === "retry") {
|
|
113
|
+
const missionId = requireMissionId(id, "/mission retry <id>", context);
|
|
114
|
+
if (!missionId)
|
|
115
|
+
return;
|
|
116
|
+
const mission = await manager.retryMission(missionId);
|
|
117
|
+
context.writeLine(`🔄 已创建本地重试使命: ${mission.id}`);
|
|
118
|
+
for (const line of formatMissionDetail(mission)) {
|
|
119
|
+
context.writeLine(line);
|
|
120
|
+
}
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
context.writeError("❌ 用法: /mission list|show|logs|pause|resume|cancel|terminate|retry <id>");
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
context.writeError(`❌ mission 操作失败: ${err instanceof Error ? err.message : String(err)}`);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/commands/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA4C1C,eAAO,MAAM,kBAAkB,EAAE,YAsDhC,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { formatPermissionMode } from "../statusline.js";
|
|
2
|
+
import { explainLocalPermissionDecision, formatPermissionExplanationReport, } from "../permissions-report.js";
|
|
3
|
+
const MODES = ["allow", "deny", "ask"];
|
|
4
|
+
function isMode(value) {
|
|
5
|
+
return MODES.includes(value);
|
|
6
|
+
}
|
|
7
|
+
function resolveCurrentMode(context) {
|
|
8
|
+
const fromLoop = context.agentLoop?.getPermissionMode?.();
|
|
9
|
+
if (typeof fromLoop === "string" && isMode(fromLoop.toLowerCase())) {
|
|
10
|
+
return fromLoop.toLowerCase();
|
|
11
|
+
}
|
|
12
|
+
const fromEnv = String(process.env.QLING_GUARD_PERMISSIONS_DEFAULT ?? "allow").toLowerCase();
|
|
13
|
+
if (isMode(fromEnv)) {
|
|
14
|
+
return fromEnv;
|
|
15
|
+
}
|
|
16
|
+
return "allow";
|
|
17
|
+
}
|
|
18
|
+
function parseEnvPermissionRules(env) {
|
|
19
|
+
const raw = env.QLING_GUARD_PERMISSIONS_RULES;
|
|
20
|
+
if (!raw)
|
|
21
|
+
return [];
|
|
22
|
+
try {
|
|
23
|
+
const parsed = JSON.parse(raw);
|
|
24
|
+
if (!Array.isArray(parsed))
|
|
25
|
+
return [];
|
|
26
|
+
return parsed.filter((entry) => Boolean(entry && typeof entry === "object"));
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const permissionsCommand = {
|
|
33
|
+
name: "/permissions",
|
|
34
|
+
aliases: ["/权限", "/allowed-tools"],
|
|
35
|
+
description: "查看或切换工具权限默认策略",
|
|
36
|
+
usage: "/permissions [status|allow|deny|ask|explain <tool>]",
|
|
37
|
+
execute: async (args, context) => {
|
|
38
|
+
const first = (args[0] ?? "status").toLowerCase();
|
|
39
|
+
if (first === "explain" || first === "解释") {
|
|
40
|
+
const toolName = args[1];
|
|
41
|
+
if (!toolName) {
|
|
42
|
+
context.writeError("❌ 用法: /permissions explain <tool>");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const report = explainLocalPermissionDecision({
|
|
46
|
+
defaultMode: resolveCurrentMode(context),
|
|
47
|
+
rules: parseEnvPermissionRules(process.env),
|
|
48
|
+
env: process.env,
|
|
49
|
+
}, toolName);
|
|
50
|
+
for (const line of formatPermissionExplanationReport(report)) {
|
|
51
|
+
context.writeLine(line);
|
|
52
|
+
}
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (first === "status") {
|
|
56
|
+
const mode = resolveCurrentMode(context);
|
|
57
|
+
context.writeLine("");
|
|
58
|
+
context.writeLine("🔐 【权限模式】");
|
|
59
|
+
context.writeLine("-----------------------------------------");
|
|
60
|
+
context.writeLine(`Default : ${formatPermissionMode(mode)}`);
|
|
61
|
+
context.writeLine("说明 : allow=自动放行, ask=询问确认, deny=默认拒绝");
|
|
62
|
+
context.writeLine("-----------------------------------------");
|
|
63
|
+
context.writeLine("");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!isMode(first)) {
|
|
67
|
+
context.writeError("❌ 用法: /permissions [status|allow|deny|ask|explain <tool>]");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const setMode = context.agentLoop?.setPermissionMode;
|
|
71
|
+
if (typeof setMode === "function") {
|
|
72
|
+
await setMode.call(context.agentLoop, first);
|
|
73
|
+
}
|
|
74
|
+
process.env.QLING_GUARD_PERMISSIONS_DEFAULT = first;
|
|
75
|
+
process.env.QLING_PERMISSIONS_MODE = first;
|
|
76
|
+
const mode = resolveCurrentMode(context);
|
|
77
|
+
context.writeLine("");
|
|
78
|
+
context.writeLine(`🔐 权限默认策略已切换为: ${formatPermissionMode(mode)}`);
|
|
79
|
+
context.writeLine("说明: 后续工具调用将按新策略执行。");
|
|
80
|
+
context.writeLine("");
|
|
81
|
+
},
|
|
82
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacy.d.ts","sourceRoot":"","sources":["../../src/commands/privacy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,eAAO,MAAM,cAAc,EAAE,YAW5B,CAAC"}
|