@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,172 @@
|
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
import { homedir } from "os";
|
|
3
|
+
import { formatLocalPanel } from "./output-style.js";
|
|
4
|
+
import { SessionRegistry } from "./session/session-registry.js";
|
|
5
|
+
function resolveStateDir(env, agentLoop) {
|
|
6
|
+
return env?.QLING_FILE_STATE_DIR
|
|
7
|
+
|| agentLoop.getRuntimeRootDir?.()
|
|
8
|
+
|| join(homedir(), ".qling");
|
|
9
|
+
}
|
|
10
|
+
function resolveCacheDir(env, stateDir) {
|
|
11
|
+
return env?.QLING_FILE_CACHE_DIR || join(stateDir, "cache");
|
|
12
|
+
}
|
|
13
|
+
function resolveMaxTokens(options, agentLoop) {
|
|
14
|
+
if (typeof options.maxTokens === "number" && options.maxTokens > 0) {
|
|
15
|
+
return options.maxTokens;
|
|
16
|
+
}
|
|
17
|
+
const fromAgent = agentLoop.getTokenBudget?.()?.maxTokens ?? agentLoop.tokenBudget?.maxTokens;
|
|
18
|
+
return typeof fromAgent === "number" && fromAgent > 0 ? fromAgent : null;
|
|
19
|
+
}
|
|
20
|
+
export function formatTokenUsage(tokens, maxTokens) {
|
|
21
|
+
const used = Number(tokens ?? 0);
|
|
22
|
+
if (!maxTokens || maxTokens <= 0) {
|
|
23
|
+
return `${used.toLocaleString()} / unknown`;
|
|
24
|
+
}
|
|
25
|
+
const pct = Math.round((used / maxTokens) * 100);
|
|
26
|
+
return `${used.toLocaleString()} / ${maxTokens.toLocaleString()} (${pct}%)`;
|
|
27
|
+
}
|
|
28
|
+
function classifyContextLevel(percent) {
|
|
29
|
+
if (percent === null)
|
|
30
|
+
return "unknown";
|
|
31
|
+
if (percent >= 90)
|
|
32
|
+
return "critical";
|
|
33
|
+
if (percent >= 70)
|
|
34
|
+
return "watch";
|
|
35
|
+
return "ok";
|
|
36
|
+
}
|
|
37
|
+
function describeContextRecommendation(level) {
|
|
38
|
+
switch (level) {
|
|
39
|
+
case "critical":
|
|
40
|
+
return "立即保存 checkpoint 并执行 /compact,避免后续回复被截断或上下文丢失。";
|
|
41
|
+
case "watch":
|
|
42
|
+
return "建议在继续长任务前保存 checkpoint;如输出变长,提前 /compact。";
|
|
43
|
+
case "ok":
|
|
44
|
+
return "当前上下文占用正常,可继续推进。";
|
|
45
|
+
default:
|
|
46
|
+
return "未配置可用 token 预算,建议设置 max token budget 以获得准确上下文水位。";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function describeTokenSource(source) {
|
|
50
|
+
switch (source) {
|
|
51
|
+
case "provider":
|
|
52
|
+
return "provider reported usage; suitable for accurate accounting when the provider returns usage.";
|
|
53
|
+
case "estimate":
|
|
54
|
+
return "local estimate; useful for context planning but not exact billing.";
|
|
55
|
+
default:
|
|
56
|
+
return "unknown; provider usage and local estimate are unavailable.";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export async function buildContextReport(context, options = {}) {
|
|
60
|
+
const env = options.env ?? process.env;
|
|
61
|
+
const agentLoop = context.agentLoop;
|
|
62
|
+
const stats = typeof agentLoop.getSessionStats === "function"
|
|
63
|
+
? await agentLoop.getSessionStats()
|
|
64
|
+
: {
|
|
65
|
+
sessionId: agentLoop.getSessionId?.() ?? "",
|
|
66
|
+
turnCount: agentLoop.turnCount ?? 0,
|
|
67
|
+
tokens: agentLoop.sessionTokens ?? 0,
|
|
68
|
+
tokenSource: "unknown",
|
|
69
|
+
compactions: agentLoop.compactionCount ?? 0,
|
|
70
|
+
};
|
|
71
|
+
const messages = typeof agentLoop.getMessagesSnapshot === "function"
|
|
72
|
+
? await agentLoop.getMessagesSnapshot()
|
|
73
|
+
: [];
|
|
74
|
+
const savedSessions = context.listSavedSessions ? await context.listSavedSessions() : [];
|
|
75
|
+
const stateDir = resolveStateDir(env, agentLoop);
|
|
76
|
+
const cacheDir = resolveCacheDir(env, stateDir);
|
|
77
|
+
const maxTokens = resolveMaxTokens(options, agentLoop);
|
|
78
|
+
const tokens = Number(stats.tokens ?? 0);
|
|
79
|
+
const tokenUsagePercent = maxTokens ? Math.round((tokens / maxTokens) * 100) : null;
|
|
80
|
+
const tokenSource = normalizeTokenSource(stats.tokenSource);
|
|
81
|
+
const contextLevel = classifyContextLevel(tokenUsagePercent);
|
|
82
|
+
return {
|
|
83
|
+
sessionId: stats.sessionId || agentLoop.getSessionId?.() || "-",
|
|
84
|
+
turnCount: Number(stats.turnCount ?? 0),
|
|
85
|
+
messageCount: Array.isArray(messages) ? messages.length : Number(stats.messageCount ?? 0),
|
|
86
|
+
tokens,
|
|
87
|
+
tokenSource,
|
|
88
|
+
tokenSourceDescription: describeTokenSource(tokenSource),
|
|
89
|
+
maxTokens,
|
|
90
|
+
tokenUsagePercent,
|
|
91
|
+
contextLevel,
|
|
92
|
+
recommendation: describeContextRecommendation(contextLevel),
|
|
93
|
+
compactions: Number(stats.compactions ?? stats.compactionCount ?? 0),
|
|
94
|
+
workspaceDir: context.workspaceDir || agentLoop.getWorkspaceDir?.() || process.cwd(),
|
|
95
|
+
stateDir,
|
|
96
|
+
cacheDir,
|
|
97
|
+
sessionsDir: join(stateDir, "sessions"),
|
|
98
|
+
savedSessionCount: savedSessions.length,
|
|
99
|
+
latestSavedSessionAt: savedSessions[0]?.updatedAt ?? null,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export async function buildLocalContextReport(options) {
|
|
103
|
+
const registry = new SessionRegistry({ stateDir: options.stateDir });
|
|
104
|
+
const savedSessions = await registry.list();
|
|
105
|
+
const maxTokens = typeof options.maxTokens === "number" && options.maxTokens > 0
|
|
106
|
+
? options.maxTokens
|
|
107
|
+
: null;
|
|
108
|
+
const tokenUsagePercent = maxTokens ? 0 : null;
|
|
109
|
+
const tokenSource = "unknown";
|
|
110
|
+
const contextLevel = classifyContextLevel(tokenUsagePercent);
|
|
111
|
+
return {
|
|
112
|
+
sessionId: "-",
|
|
113
|
+
turnCount: 0,
|
|
114
|
+
messageCount: 0,
|
|
115
|
+
tokens: 0,
|
|
116
|
+
tokenSource,
|
|
117
|
+
tokenSourceDescription: describeTokenSource(tokenSource),
|
|
118
|
+
maxTokens,
|
|
119
|
+
tokenUsagePercent,
|
|
120
|
+
contextLevel,
|
|
121
|
+
recommendation: describeContextRecommendation(contextLevel),
|
|
122
|
+
compactions: 0,
|
|
123
|
+
workspaceDir: options.workspaceDir,
|
|
124
|
+
stateDir: options.stateDir,
|
|
125
|
+
cacheDir: options.cacheDir || join(options.stateDir, "cache"),
|
|
126
|
+
sessionsDir: join(options.stateDir, "sessions"),
|
|
127
|
+
savedSessionCount: savedSessions.length,
|
|
128
|
+
latestSavedSessionAt: savedSessions[0]?.updatedAt ?? null,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export function formatContextReport(report) {
|
|
132
|
+
return formatLocalPanel({
|
|
133
|
+
icon: "🧭",
|
|
134
|
+
title: "本地上下文",
|
|
135
|
+
sections: [
|
|
136
|
+
{
|
|
137
|
+
heading: "会话",
|
|
138
|
+
rows: [
|
|
139
|
+
["Session ID", report.sessionId],
|
|
140
|
+
["轮次", report.turnCount],
|
|
141
|
+
["消息数", report.messageCount],
|
|
142
|
+
["压缩次数", report.compactions],
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
heading: "Token 与状态",
|
|
147
|
+
rows: [
|
|
148
|
+
["Token", formatTokenUsage(report.tokens, report.maxTokens)],
|
|
149
|
+
["Token 来源", report.tokenSource],
|
|
150
|
+
["Token 说明", report.tokenSourceDescription],
|
|
151
|
+
["上下文状态", report.contextLevel],
|
|
152
|
+
["建议", report.recommendation],
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
heading: "本地路径",
|
|
157
|
+
rows: [
|
|
158
|
+
["Workspace", report.workspaceDir],
|
|
159
|
+
["State dir", report.stateDir],
|
|
160
|
+
["Cache dir", report.cacheDir],
|
|
161
|
+
["Sessions", report.sessionsDir],
|
|
162
|
+
["已存快照", report.savedSessionCount],
|
|
163
|
+
["最近保存", report.latestSavedSessionAt ?? "-"],
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
boundary: "/context 只展示本地统计与路径,不输出消息正文,不上传上下文。",
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function normalizeTokenSource(value) {
|
|
171
|
+
return value === "provider" || value === "estimate" ? value : "unknown";
|
|
172
|
+
}
|
package/dist/daemon.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon.d.ts","sourceRoot":"","sources":["../src/daemon.ts"],"names":[],"mappings":""}
|
package/dist/daemon.js
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// qlingd - 轻灵后台守护进程 (v0.5 M3)
|
|
3
|
+
// 负责后台任务执行、队列管理与状态持久化
|
|
4
|
+
// ============================================================
|
|
5
|
+
import * as http from "http";
|
|
6
|
+
import { MissionManager } from "./mission/manager.js";
|
|
7
|
+
import { AgentLoop } from "./agent-loop.js";
|
|
8
|
+
import { loadQlingConfig, applyConfigToProcessEnv } from "./config.js";
|
|
9
|
+
import * as path from "path";
|
|
10
|
+
import * as os from "os";
|
|
11
|
+
import * as fs from "fs";
|
|
12
|
+
import dotenv from "dotenv";
|
|
13
|
+
import { SessionScheduler } from "./session/session-scheduler.js";
|
|
14
|
+
import { SessionGoalController } from "./session/goal-controller.js";
|
|
15
|
+
import { SessionGoalManager } from "./session/session-goal-manager.js";
|
|
16
|
+
import { DurableSessionSupervisor } from "./session/durable-session-supervisor.js";
|
|
17
|
+
import { formatDaemonVersion } from "./package-version.js";
|
|
18
|
+
const HOME_DIR = os.homedir();
|
|
19
|
+
const DEFAULT_STATE_DIR = path.join(HOME_DIR, ".qling");
|
|
20
|
+
function loadEnv() {
|
|
21
|
+
// 1. 项目配置
|
|
22
|
+
let dir = process.cwd();
|
|
23
|
+
while (true) {
|
|
24
|
+
const envPath = path.join(dir, ".env");
|
|
25
|
+
if (fs.existsSync(envPath)) {
|
|
26
|
+
dotenv.config({ path: envPath });
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
const parent = path.dirname(dir);
|
|
30
|
+
if (parent === dir)
|
|
31
|
+
break;
|
|
32
|
+
dir = parent;
|
|
33
|
+
}
|
|
34
|
+
// 2. 全局配置
|
|
35
|
+
const globalEnv = path.join(HOME_DIR, ".qling", ".env");
|
|
36
|
+
if (fs.existsSync(globalEnv)) {
|
|
37
|
+
dotenv.config({ path: globalEnv });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function main() {
|
|
41
|
+
loadEnv();
|
|
42
|
+
const stateDir = process.env.QLING_FILE_STATE_DIR || DEFAULT_STATE_DIR;
|
|
43
|
+
const manager = new MissionManager(stateDir);
|
|
44
|
+
await manager.init();
|
|
45
|
+
const startedAt = Date.now();
|
|
46
|
+
const supervisor = new DurableSessionSupervisor({
|
|
47
|
+
stateDir,
|
|
48
|
+
log: (message) => console.log(`[qlingd] ${message}`),
|
|
49
|
+
});
|
|
50
|
+
// 尝试预加载配置并应用到环境变量
|
|
51
|
+
try {
|
|
52
|
+
const { config } = await loadQlingConfig({});
|
|
53
|
+
applyConfigToProcessEnv(config);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
console.error(`[qlingd] Warning: Failed to load config: ${err.message}`);
|
|
57
|
+
}
|
|
58
|
+
const PORT = Number(process.env.QLING_DAEMON_PORT) || 9998;
|
|
59
|
+
supervisor.start();
|
|
60
|
+
const server = http.createServer(async (req, res) => {
|
|
61
|
+
const url = new URL(req.url || "/", `http://localhost:${PORT}`);
|
|
62
|
+
res.setHeader("Content-Type", "application/json");
|
|
63
|
+
try {
|
|
64
|
+
// 1. 获取所有使命
|
|
65
|
+
if (url.pathname === "/missions" && req.method === "GET") {
|
|
66
|
+
const list = manager.listMissions();
|
|
67
|
+
res.end(JSON.stringify(list));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// 2. 提交新使命
|
|
71
|
+
if (url.pathname === "/missions" && req.method === "POST") {
|
|
72
|
+
const data = await readJsonBody(req);
|
|
73
|
+
const mission = await manager.createMission(data.name, data.description, data.sessionId);
|
|
74
|
+
await manager.appendLog(mission.id, "使命已提交到后台队列", { source: "daemon" });
|
|
75
|
+
// 异步启动任务执行 (Detach) - 传入全量数据以支持状态恢复
|
|
76
|
+
executeMissionInBackground(mission.id, manager, stateDir, data);
|
|
77
|
+
res.end(JSON.stringify({ ok: true, missionId: mission.id }));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const missionRoute = matchMissionRoute(url.pathname);
|
|
81
|
+
if (missionRoute) {
|
|
82
|
+
const { id, action } = missionRoute;
|
|
83
|
+
if (!action && req.method === "GET") {
|
|
84
|
+
const mission = manager.getMissionOrThrow(id);
|
|
85
|
+
res.end(JSON.stringify(mission));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (action === "logs" && req.method === "GET") {
|
|
89
|
+
const logs = await manager.getMissionLogs(id);
|
|
90
|
+
res.end(JSON.stringify(logs));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (req.method === "POST") {
|
|
94
|
+
if (action === "pause") {
|
|
95
|
+
const mission = await manager.pauseMission(id, "daemon_api");
|
|
96
|
+
res.end(JSON.stringify({ ok: true, mission }));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (action === "resume") {
|
|
100
|
+
const mission = await manager.resumeMission(id, "daemon_api");
|
|
101
|
+
res.end(JSON.stringify({ ok: true, mission }));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (action === "cancel") {
|
|
105
|
+
const mission = await manager.cancelMission(id, "daemon_api");
|
|
106
|
+
res.end(JSON.stringify({ ok: true, mission }));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (action === "retry") {
|
|
110
|
+
const retried = await manager.retryMission(id);
|
|
111
|
+
await manager.appendLog(retried.id, "使命由 retry 重新排队", {
|
|
112
|
+
source: "daemon",
|
|
113
|
+
sourceMissionId: id,
|
|
114
|
+
});
|
|
115
|
+
executeMissionInBackground(retried.id, manager, stateDir, {
|
|
116
|
+
name: retried.name,
|
|
117
|
+
description: retried.description,
|
|
118
|
+
sessionId: retried.sessionId,
|
|
119
|
+
});
|
|
120
|
+
res.end(JSON.stringify({ ok: true, missionId: retried.id }));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const sessionRoute = matchSessionRoute(url.pathname);
|
|
126
|
+
if (sessionRoute) {
|
|
127
|
+
const { sessionId, resource, itemId, action } = sessionRoute;
|
|
128
|
+
if (resource === "loop-tasks") {
|
|
129
|
+
const scheduler = new SessionScheduler({
|
|
130
|
+
stateDir,
|
|
131
|
+
sessionId,
|
|
132
|
+
runner: "daemon",
|
|
133
|
+
onDue: async () => { },
|
|
134
|
+
});
|
|
135
|
+
await scheduler.init();
|
|
136
|
+
if (!itemId && req.method === "GET") {
|
|
137
|
+
res.end(JSON.stringify(await scheduler.listTasks()));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (!itemId && req.method === "POST") {
|
|
141
|
+
const data = await readJsonBody(req);
|
|
142
|
+
const task = await scheduler.createLoopTask({
|
|
143
|
+
prompt: data.prompt,
|
|
144
|
+
intervalMs: Number(data.intervalMs),
|
|
145
|
+
mode: data.mode === "fixed" ? "fixed" : "default",
|
|
146
|
+
runner: "daemon",
|
|
147
|
+
});
|
|
148
|
+
res.end(JSON.stringify(task));
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (itemId && action === "cancel" && req.method === "POST") {
|
|
152
|
+
const task = await scheduler.cancelTask(itemId);
|
|
153
|
+
res.end(JSON.stringify(task));
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (resource === "goal") {
|
|
158
|
+
const manager = new SessionGoalManager({ stateDir, sessionId });
|
|
159
|
+
const controller = new SessionGoalController({
|
|
160
|
+
manager,
|
|
161
|
+
runner: "daemon",
|
|
162
|
+
});
|
|
163
|
+
await controller.init();
|
|
164
|
+
if (!action && req.method === "GET") {
|
|
165
|
+
res.end(JSON.stringify(await controller.getGoalStatus()));
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (!action && req.method === "POST") {
|
|
169
|
+
const data = await readJsonBody(req);
|
|
170
|
+
const goal = await controller.setGoal(data.condition, {
|
|
171
|
+
turnCount: Number(data.stats?.turnCount ?? 0),
|
|
172
|
+
tokens: Number(data.stats?.tokens ?? 0),
|
|
173
|
+
}, {
|
|
174
|
+
runner: "daemon",
|
|
175
|
+
pending: true,
|
|
176
|
+
});
|
|
177
|
+
res.end(JSON.stringify(goal));
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (action === "clear" && req.method === "POST") {
|
|
181
|
+
const goal = await controller.clearGoal("daemon_api_clear");
|
|
182
|
+
res.end(JSON.stringify(goal));
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// 4. 健康检查
|
|
188
|
+
if (url.pathname === "/health") {
|
|
189
|
+
res.end(JSON.stringify({
|
|
190
|
+
status: "ok",
|
|
191
|
+
version: formatDaemonVersion(),
|
|
192
|
+
pid: process.pid,
|
|
193
|
+
uptimeMs: Date.now() - startedAt,
|
|
194
|
+
missions: manager.listMissions().length,
|
|
195
|
+
durableSupervisor: "running",
|
|
196
|
+
}));
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
res.writeHead(404);
|
|
200
|
+
res.end(JSON.stringify({ error: "Not Found" }));
|
|
201
|
+
}
|
|
202
|
+
catch (err) {
|
|
203
|
+
const error = err;
|
|
204
|
+
res.writeHead(error.statusCode ?? 500);
|
|
205
|
+
res.end(JSON.stringify({ error: error.message, code: error.code ?? "DAEMON_ERROR" }));
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
server.listen(PORT, () => {
|
|
209
|
+
console.log(`[qlingd] 守护进程已启动,监听端口: ${PORT}`);
|
|
210
|
+
});
|
|
211
|
+
const shutdown = () => {
|
|
212
|
+
server.close(() => process.exit(0));
|
|
213
|
+
setTimeout(() => process.exit(0), 2_000).unref();
|
|
214
|
+
};
|
|
215
|
+
process.once("SIGTERM", shutdown);
|
|
216
|
+
process.once("SIGINT", shutdown);
|
|
217
|
+
}
|
|
218
|
+
/** 后台执行使命逻辑 */
|
|
219
|
+
async function executeMissionInBackground(id, manager, stateDir, data) {
|
|
220
|
+
const mission = manager.getMission(id);
|
|
221
|
+
if (!mission)
|
|
222
|
+
return;
|
|
223
|
+
try {
|
|
224
|
+
if (mission.status === "paused" || mission.status === "canceled") {
|
|
225
|
+
await manager.appendLog(id, `使命未启动,当前状态为 ${mission.status}`, { source: "daemon" });
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
await manager.updateStatus(id, "running");
|
|
229
|
+
await manager.appendLog(id, "使命开始执行", { source: "daemon" });
|
|
230
|
+
// 重新加载配置
|
|
231
|
+
const { config: loadedConfig } = await loadQlingConfig({});
|
|
232
|
+
const { buildToolRegistry } = await import("./tools/index.js");
|
|
233
|
+
const staticEnabled = {};
|
|
234
|
+
for (const [name, cfg] of Object.entries(loadedConfig.tools)) {
|
|
235
|
+
staticEnabled[name] = cfg.enabled;
|
|
236
|
+
}
|
|
237
|
+
const tools = buildToolRegistry({ staticEnabled });
|
|
238
|
+
const agentConfig = {
|
|
239
|
+
apiKey: loadedConfig.llm.api_key || process.env.QLING_LLM_API_KEY || "",
|
|
240
|
+
provider: loadedConfig.llm.provider,
|
|
241
|
+
endpoint: loadedConfig.llm.endpoint,
|
|
242
|
+
model: loadedConfig.llm.model,
|
|
243
|
+
maxIterations: loadedConfig.runtime.max_steps,
|
|
244
|
+
tools,
|
|
245
|
+
runtime: {
|
|
246
|
+
workspaceDir: loadedConfig.runtime.workspace_dir || process.cwd(),
|
|
247
|
+
fileCacheDir: loadedConfig.runtime.file_cache_dir,
|
|
248
|
+
fileStateDir: stateDir,
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
const agent = new AgentLoop(agentConfig);
|
|
252
|
+
await agent.waitForInit();
|
|
253
|
+
// v0.5 M3: 状态恢复 (High-fidelity Resume)
|
|
254
|
+
if (data.checkpoint) {
|
|
255
|
+
console.log(`[qlingd] 正在为使命 ${id} 恢复状态机快照...`);
|
|
256
|
+
await manager.appendLog(id, "正在恢复状态机快照", { source: "daemon" });
|
|
257
|
+
agent.syncWorkflowState(data.checkpoint);
|
|
258
|
+
if (data.stats) {
|
|
259
|
+
agent.sessionTokens = data.stats.sessionTokens || 0;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
agent.addUserMessage(mission.description);
|
|
264
|
+
}
|
|
265
|
+
const result = await agent.run();
|
|
266
|
+
await manager.appendLog(id, "使命执行成功", {
|
|
267
|
+
source: "daemon",
|
|
268
|
+
resultPreview: typeof result === "string" ? result.slice(0, 120) : String(result),
|
|
269
|
+
});
|
|
270
|
+
await manager.updateStatus(id, "succeeded");
|
|
271
|
+
console.log(`[qlingd] 使命 ${id} 执行成功。`);
|
|
272
|
+
await agent.shutdown();
|
|
273
|
+
}
|
|
274
|
+
catch (err) {
|
|
275
|
+
await manager.updateStatus(id, "failed", {
|
|
276
|
+
message: err.message,
|
|
277
|
+
code: "DAEMON_EXEC_FAILED"
|
|
278
|
+
});
|
|
279
|
+
await manager.appendLog(id, `使命执行失败: ${err.message}`, { source: "daemon" });
|
|
280
|
+
console.error(`[qlingd] 使命 ${id} 执行失败: ${err.message}`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function matchMissionRoute(pathname) {
|
|
284
|
+
const match = pathname.match(/^\/missions\/([^/]+)(?:\/([^/]+))?$/);
|
|
285
|
+
if (!match)
|
|
286
|
+
return null;
|
|
287
|
+
return {
|
|
288
|
+
id: decodeURIComponent(match[1]),
|
|
289
|
+
action: match[2] ? decodeURIComponent(match[2]) : null,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
function matchSessionRoute(pathname) {
|
|
293
|
+
const match = pathname.match(/^\/sessions\/([^/]+)\/(loop-tasks|goal)(?:\/([^/]+))?(?:\/([^/]+))?$/);
|
|
294
|
+
if (!match)
|
|
295
|
+
return null;
|
|
296
|
+
const resource = match[2];
|
|
297
|
+
let itemId = match[3] ? decodeURIComponent(match[3]) : null;
|
|
298
|
+
let action = match[4] ? decodeURIComponent(match[4]) : null;
|
|
299
|
+
if (resource === "goal" && itemId && !action) {
|
|
300
|
+
action = itemId;
|
|
301
|
+
itemId = null;
|
|
302
|
+
}
|
|
303
|
+
return {
|
|
304
|
+
sessionId: decodeURIComponent(match[1]),
|
|
305
|
+
resource,
|
|
306
|
+
itemId,
|
|
307
|
+
action,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
async function readJsonBody(req) {
|
|
311
|
+
let body = "";
|
|
312
|
+
for await (const chunk of req)
|
|
313
|
+
body += chunk;
|
|
314
|
+
return body ? JSON.parse(body) : {};
|
|
315
|
+
}
|
|
316
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MetricsCollector } from "./metrics/collector.js";
|
|
2
|
+
import { WorkflowRuntime } from "./workflow-runtime.js";
|
|
3
|
+
import { AgentLoop } from "./agent-loop.js";
|
|
4
|
+
export interface DashboardOptions {
|
|
5
|
+
port: number;
|
|
6
|
+
collector: MetricsCollector;
|
|
7
|
+
workflowRuntime: WorkflowRuntime;
|
|
8
|
+
agentLoop: AgentLoop;
|
|
9
|
+
}
|
|
10
|
+
export declare class DashboardServer {
|
|
11
|
+
private server;
|
|
12
|
+
private options;
|
|
13
|
+
listening: boolean;
|
|
14
|
+
constructor(options: DashboardOptions);
|
|
15
|
+
start(): Promise<void>;
|
|
16
|
+
stop(): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=dashboard-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard-server.d.ts","sourceRoot":"","sources":["../src/dashboard-server.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,gBAAgB,CAAC;IAC5B,eAAe,EAAE,eAAe,CAAC;IACjC,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,OAAO,CAAmB;IAC3B,SAAS,UAAS;gBAEb,OAAO,EAAE,gBAAgB;IAIrC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA8TtB,IAAI,IAAI,IAAI;CAIb"}
|