patchwarden 0.6.0 → 0.6.4
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/PatchWarden-Control-Tray.cmd +11 -0
- package/PatchWarden-Control.cmd +6 -0
- package/PatchWarden-Desktop.cmd +5 -0
- package/PatchWarden.cmd +1 -1
- package/README.en.md +106 -18
- package/README.md +30 -19
- package/Restart-PatchWarden-Control.cmd +6 -0
- package/Stop-PatchWarden.cmd +11 -0
- package/dist/controlCenter.d.ts +14 -0
- package/dist/controlCenter.js +2002 -0
- package/dist/doctor.js +4 -4
- package/dist/logging.d.ts +52 -0
- package/dist/logging.js +123 -0
- package/dist/runner/changeCapture.d.ts +41 -0
- package/dist/runner/changeCapture.js +171 -1
- package/dist/runner/runTask.js +204 -24
- package/dist/smoke-test.js +8 -8
- package/dist/test/unit/android-doctor.test.d.ts +1 -0
- package/dist/test/unit/android-doctor.test.js +118 -0
- package/dist/test/unit/chinese-path.test.d.ts +1 -0
- package/dist/test/unit/chinese-path.test.js +91 -0
- package/dist/test/unit/command-guard.test.d.ts +1 -0
- package/dist/test/unit/command-guard.test.js +160 -0
- package/dist/test/unit/direct-guards.test.d.ts +1 -0
- package/dist/test/unit/direct-guards.test.js +213 -0
- package/dist/test/unit/logging.test.d.ts +1 -0
- package/dist/test/unit/logging.test.js +275 -0
- package/dist/test/unit/path-guard.test.d.ts +1 -0
- package/dist/test/unit/path-guard.test.js +109 -0
- package/dist/test/unit/safe-status.test.d.ts +1 -0
- package/dist/test/unit/safe-status.test.js +165 -0
- package/dist/test/unit/sensitive-guard.test.d.ts +1 -0
- package/dist/test/unit/sensitive-guard.test.js +104 -0
- package/dist/test/unit/sync-file.test.d.ts +1 -0
- package/dist/test/unit/sync-file.test.js +154 -0
- package/dist/test/unit/watcher-status.test.d.ts +1 -0
- package/dist/test/unit/watcher-status.test.js +169 -0
- package/dist/tools/androidDoctor.d.ts +38 -0
- package/dist/tools/androidDoctor.js +391 -0
- package/dist/tools/auditTask.js +11 -5
- package/dist/tools/getTaskSummary.d.ts +3 -0
- package/dist/tools/getTaskSummary.js +15 -1
- package/dist/tools/healthCheck.d.ts +5 -0
- package/dist/tools/healthCheck.js +21 -0
- package/dist/tools/registry.js +53 -0
- package/dist/tools/safeStatus.d.ts +19 -0
- package/dist/tools/safeStatus.js +72 -0
- package/dist/tools/syncFile.d.ts +18 -0
- package/dist/tools/syncFile.js +65 -0
- package/dist/tools/taskOutputs.d.ts +2 -2
- package/dist/tools/toolCatalog.d.ts +2 -2
- package/dist/tools/toolCatalog.js +2 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/dist/watcherStatus.d.ts +1 -0
- package/dist/watcherStatus.js +96 -4
- package/docs/control-center/README.md +33 -0
- package/docs/control-center/control-center-daily-driver.md +211 -0
- package/docs/control-center/control-center-mvp.md +205 -0
- package/docs/control-center/control-center-phase2.md +159 -0
- package/docs/demo.md +3 -0
- package/docs/performance-notes.md +55 -0
- package/docs/release-v0.6.1.md +75 -0
- package/docs/release-v0.6.4.md +45 -0
- package/examples/openai-tunnel/README.md +5 -5
- package/examples/openai-tunnel/tunnel-client.example.yaml +3 -3
- package/package.json +23 -14
- package/scripts/README.md +47 -0
- package/scripts/{brand-check.js → checks/brand-check.js} +2 -2
- package/scripts/checks/control-center-smoke.js +1098 -0
- package/scripts/{control-smoke.js → checks/control-smoke.js} +17 -3
- package/scripts/{doctor-smoke.js → checks/doctor-smoke.js} +1 -1
- package/scripts/{http-mcp-smoke.js → checks/http-mcp-smoke.js} +12 -4
- package/scripts/{lifecycle-smoke.js → checks/lifecycle-smoke.js} +347 -13
- package/scripts/{mcp-manifest-check.js → checks/mcp-manifest-check.js} +32 -9
- package/scripts/{mcp-smoke.js → checks/mcp-smoke.js} +14 -9
- package/scripts/{package-manifest-check.js → checks/package-manifest-check.js} +2 -1
- package/scripts/{tunnel-supervisor-smoke.js → checks/tunnel-supervisor-smoke.js} +2 -2
- package/scripts/checks/unit-tests.js +36 -0
- package/scripts/{watcher-supervisor-smoke.js → checks/watcher-supervisor-smoke.js} +11 -5
- package/scripts/control/control-center-tray.ps1 +281 -0
- package/scripts/{get-patchwarden-health.ps1 → control/get-patchwarden-health.ps1} +3 -3
- package/scripts/{manage-patchwarden.ps1 → control/manage-patchwarden.ps1} +30 -4
- package/scripts/control/restart-control-center.ps1 +173 -0
- package/scripts/{restart-patchwarden.ps1 → control/restart-patchwarden.ps1} +1 -1
- package/scripts/control/start-control-center.ps1 +263 -0
- package/scripts/{start-patchwarden-tunnel.ps1 → control/start-patchwarden-tunnel.ps1} +48 -6
- package/scripts/control/stop-patchwarden.ps1 +114 -0
- package/scripts/launchers/Check-PatchWarden-Health.cmd +1 -1
- package/scripts/launchers/Reset-PatchWarden-Tunnel-Key.cmd +1 -1
- package/scripts/launchers/Restart-PatchWarden.cmd +1 -1
- package/scripts/launchers/Start-PatchWarden-Direct-Tunnel.cmd +1 -1
- package/scripts/launchers/Start-PatchWarden-Tunnel.cmd +1 -1
- package/scripts/{patchwarden-mcp-direct.cmd → mcp/patchwarden-mcp-direct.cmd} +1 -1
- package/scripts/{patchwarden-mcp-stdio.cmd → mcp/patchwarden-mcp-stdio.cmd} +1 -1
- package/scripts/release/pack-clean.js +305 -0
- package/src/controlCenter.ts +2152 -0
- package/src/doctor.ts +5 -5
- package/src/logging.ts +152 -0
- package/src/runner/changeCapture.ts +212 -1
- package/src/runner/runTask.ts +220 -22
- package/src/smoke-test.ts +5 -5
- package/src/test/unit/android-doctor.test.ts +158 -0
- package/src/test/unit/chinese-path.test.ts +106 -0
- package/src/test/unit/command-guard.test.ts +221 -0
- package/src/test/unit/direct-guards.test.ts +297 -0
- package/src/test/unit/logging.test.ts +325 -0
- package/src/test/unit/path-guard.test.ts +150 -0
- package/src/test/unit/safe-status.test.ts +187 -0
- package/src/test/unit/sensitive-guard.test.ts +124 -0
- package/src/test/unit/sync-file.test.ts +231 -0
- package/src/test/unit/watcher-status.test.ts +190 -0
- package/src/tools/androidDoctor.ts +424 -0
- package/src/tools/auditTask.ts +11 -5
- package/src/tools/getTaskSummary.ts +22 -1
- package/src/tools/healthCheck.ts +22 -0
- package/src/tools/registry.ts +63 -0
- package/src/tools/safeStatus.ts +96 -0
- package/src/tools/syncFile.ts +122 -0
- package/src/tools/toolCatalog.ts +2 -0
- package/src/version.ts +2 -2
- package/src/watcherStatus.ts +101 -4
- package/ui/colors_and_type.css +141 -0
- package/ui/pages/audit.html +743 -0
- package/ui/pages/dashboard.html +1154 -0
- package/ui/pages/direct-sessions.html +652 -0
- package/ui/pages/logs.html +502 -0
- package/ui/pages/task-detail.html +1229 -0
- package/ui/pages/tasks.html +702 -0
- package/ui/pages/workspace.html +947 -0
- package/ui/partials/project-shell.html +362 -0
- package/ui/vendor/lucide.js +12 -0
- package/ui/vendor/tailwindcss-browser.js +947 -0
- package/scripts/pack-clean.js +0 -141
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
2
|
+
import { resolve, join } from "node:path";
|
|
3
|
+
import { getTasksDir, getConfig } from "../config.js";
|
|
4
|
+
import { guardReadPath } from "../security/pathGuard.js";
|
|
5
|
+
import { guardSensitivePath } from "../security/sensitiveGuard.js";
|
|
6
|
+
import { readTaskRuntime } from "../taskRuntime.js";
|
|
7
|
+
import { readWatcherStatus } from "../watcherStatus.js";
|
|
8
|
+
export function safeStatus(taskId, config) {
|
|
9
|
+
const cfg = config || getConfig();
|
|
10
|
+
const tasksDir = getTasksDir(cfg);
|
|
11
|
+
const taskDir = resolve(tasksDir, taskId);
|
|
12
|
+
const statusFile = join(taskDir, "status.json");
|
|
13
|
+
// Check existence BEFORE guardReadPath so that a non-existent task
|
|
14
|
+
// returns a structured not_found response instead of throwing.
|
|
15
|
+
if (!existsSync(statusFile)) {
|
|
16
|
+
return {
|
|
17
|
+
task_id: taskId,
|
|
18
|
+
status: "not_found",
|
|
19
|
+
phase: null,
|
|
20
|
+
created_at: null,
|
|
21
|
+
started_at: null,
|
|
22
|
+
updated_at: null,
|
|
23
|
+
finished_at: null,
|
|
24
|
+
last_heartbeat_at: null,
|
|
25
|
+
current_command: null,
|
|
26
|
+
verify_status: null,
|
|
27
|
+
artifact_status: null,
|
|
28
|
+
watcher_state: null,
|
|
29
|
+
error_code: null,
|
|
30
|
+
error_summary: null,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
guardReadPath(statusFile, cfg.workspaceRoot, cfg.tasksDir);
|
|
34
|
+
guardSensitivePath(statusFile);
|
|
35
|
+
const raw = readFileSync(statusFile, "utf-8");
|
|
36
|
+
const status = JSON.parse(raw);
|
|
37
|
+
const runtime = readTaskRuntime(taskDir);
|
|
38
|
+
const phase = (runtime.phase || status.phase || "queued");
|
|
39
|
+
const watcher = readWatcherStatus(cfg);
|
|
40
|
+
// Extract short error summary — never the full error text
|
|
41
|
+
let errorCode = null;
|
|
42
|
+
let errorSummary = null;
|
|
43
|
+
if (status.error && typeof status.error === "string") {
|
|
44
|
+
const errorStr = status.error;
|
|
45
|
+
// Keep only the first 200 chars as summary
|
|
46
|
+
errorSummary = errorStr.length > 200 ? errorStr.slice(0, 200) + "..." : errorStr;
|
|
47
|
+
// Try to extract an error code from the status
|
|
48
|
+
if (typeof status.status === "string" && status.status.startsWith("failed")) {
|
|
49
|
+
errorCode = status.status;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (typeof status.status === "string" && status.status.startsWith("failed")) {
|
|
53
|
+
errorCode = status.status;
|
|
54
|
+
errorSummary = `Task ended with status: ${status.status}`;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
task_id: taskId,
|
|
58
|
+
status: status.status || "not_found",
|
|
59
|
+
phase,
|
|
60
|
+
created_at: typeof status.created_at === "string" ? status.created_at : null,
|
|
61
|
+
started_at: typeof status.started_at === "string" ? status.started_at : null,
|
|
62
|
+
updated_at: typeof status.updated_at === "string" ? status.updated_at : null,
|
|
63
|
+
finished_at: typeof status.finished_at === "string" ? status.finished_at : null,
|
|
64
|
+
last_heartbeat_at: runtime.last_heartbeat_at || (typeof status.last_heartbeat_at === "string" ? status.last_heartbeat_at : null),
|
|
65
|
+
current_command: runtime.current_command ?? (typeof status.current_command === "string" ? status.current_command : null) ?? null,
|
|
66
|
+
verify_status: typeof status.verify_status === "string" ? status.verify_status : null,
|
|
67
|
+
artifact_status: typeof status.artifact_status === "string" ? status.artifact_status : null,
|
|
68
|
+
watcher_state: watcher.status,
|
|
69
|
+
error_code: errorCode,
|
|
70
|
+
error_summary: errorSummary,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type PatchWardenConfig } from "../config.js";
|
|
2
|
+
export interface SyncFileResult {
|
|
3
|
+
source_path: string;
|
|
4
|
+
target_path: string;
|
|
5
|
+
before_target_sha256: string | null;
|
|
6
|
+
after_target_sha256: string;
|
|
7
|
+
source_sha256: string;
|
|
8
|
+
copied_bytes: number;
|
|
9
|
+
changed: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Copy a file from source to target within the same session repo.
|
|
13
|
+
* Both source and target must be inside the session's repo_path.
|
|
14
|
+
*/
|
|
15
|
+
export declare function syncFile(sessionId: string, sourcePath: string, targetPath: string, options?: {
|
|
16
|
+
expected_source_sha256?: string;
|
|
17
|
+
expected_target_sha256?: string;
|
|
18
|
+
}, config?: PatchWardenConfig): SyncFileResult;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { PatchWardenError } from "../errors.js";
|
|
4
|
+
import { getConfig } from "../config.js";
|
|
5
|
+
import { guardDirectPath, guardDirectWritePath } from "../direct/directGuards.js";
|
|
6
|
+
import { guardSensitivePath } from "../security/sensitiveGuard.js";
|
|
7
|
+
import { computeFileSha256 } from "../direct/directPatch.js";
|
|
8
|
+
/**
|
|
9
|
+
* Copy a file from source to target within the same session repo.
|
|
10
|
+
* Both source and target must be inside the session's repo_path.
|
|
11
|
+
*/
|
|
12
|
+
export function syncFile(sessionId, sourcePath, targetPath, options, config) {
|
|
13
|
+
const cfg = config || getConfig();
|
|
14
|
+
const sessionsDir = resolve(cfg.workspaceRoot, cfg.directSessionsDir);
|
|
15
|
+
// Load session to get repo_path
|
|
16
|
+
const sessionFile = resolve(sessionsDir, sessionId, "session.json");
|
|
17
|
+
if (!existsSync(sessionFile)) {
|
|
18
|
+
throw new PatchWardenError("direct_session_not_found", `Direct session "${sessionId}" not found.`, "Create a direct session first using direct_start_session.", true, { session_id: sessionId });
|
|
19
|
+
}
|
|
20
|
+
const session = JSON.parse(readFileSync(sessionFile, "utf-8"));
|
|
21
|
+
const repoPath = resolve(session.repo_path);
|
|
22
|
+
const workspaceRoot = cfg.workspaceRoot;
|
|
23
|
+
// Guard source path — must be inside repo
|
|
24
|
+
const resolvedSource = guardDirectPath(sourcePath, repoPath, workspaceRoot);
|
|
25
|
+
guardSensitivePath(resolvedSource);
|
|
26
|
+
if (!existsSync(resolvedSource)) {
|
|
27
|
+
throw new PatchWardenError("source_file_not_found", `Source file does not exist: "${sourcePath}".`, "Ensure the source path is correct.", true, { source_path: sourcePath });
|
|
28
|
+
}
|
|
29
|
+
// Guard target path — must be inside repo, not in blocked dirs
|
|
30
|
+
const resolvedTarget = guardDirectWritePath(targetPath, repoPath, workspaceRoot);
|
|
31
|
+
guardSensitivePath(resolvedTarget);
|
|
32
|
+
// Verify source sha256 if provided
|
|
33
|
+
const sourceSha256 = computeFileSha256(resolvedSource);
|
|
34
|
+
if (options?.expected_source_sha256 && options.expected_source_sha256 !== sourceSha256) {
|
|
35
|
+
throw new PatchWardenError("source_hash_mismatch", `Source file hash mismatch. Expected "${options.expected_source_sha256}" but got "${sourceSha256}".`, "Re-read the source file to get the current sha256.", true, { expected_sha256: options.expected_source_sha256, actual_sha256: sourceSha256 });
|
|
36
|
+
}
|
|
37
|
+
// Get target sha256 before copy
|
|
38
|
+
let beforeTargetSha256 = null;
|
|
39
|
+
if (existsSync(resolvedTarget)) {
|
|
40
|
+
beforeTargetSha256 = computeFileSha256(resolvedTarget);
|
|
41
|
+
// Verify target sha256 if provided
|
|
42
|
+
if (options?.expected_target_sha256 && options.expected_target_sha256 !== beforeTargetSha256) {
|
|
43
|
+
throw new PatchWardenError("target_hash_mismatch", `Target file hash mismatch. Expected "${options.expected_target_sha256}" but got "${beforeTargetSha256}".`, "Re-read the target file to get the current sha256.", true, { expected_sha256: options.expected_target_sha256, actual_sha256: beforeTargetSha256 });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Read source content
|
|
47
|
+
const sourceContent = readFileSync(resolvedSource);
|
|
48
|
+
const copiedBytes = sourceContent.length;
|
|
49
|
+
// Create target directory if needed
|
|
50
|
+
mkdirSync(dirname(resolvedTarget), { recursive: true });
|
|
51
|
+
// Write to target
|
|
52
|
+
writeFileSync(resolvedTarget, sourceContent, "utf-8");
|
|
53
|
+
// Compute after hash
|
|
54
|
+
const afterTargetSha256 = computeFileSha256(resolvedTarget);
|
|
55
|
+
const changed = beforeTargetSha256 !== afterTargetSha256;
|
|
56
|
+
return {
|
|
57
|
+
source_path: sourcePath,
|
|
58
|
+
target_path: targetPath,
|
|
59
|
+
before_target_sha256: beforeTargetSha256,
|
|
60
|
+
after_target_sha256: afterTargetSha256,
|
|
61
|
+
source_sha256: sourceSha256,
|
|
62
|
+
copied_bytes: copiedBytes,
|
|
63
|
+
changed,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -14,7 +14,7 @@ export declare function getTaskLogTail(taskId: string, file: "stdout" | "stderr"
|
|
|
14
14
|
lines?: number;
|
|
15
15
|
redact?: boolean;
|
|
16
16
|
}): {
|
|
17
|
-
file: "
|
|
17
|
+
file: "test" | "stdout" | "stderr" | "verify";
|
|
18
18
|
lines: number;
|
|
19
19
|
total_bytes: number;
|
|
20
20
|
task_id: string;
|
|
@@ -37,7 +37,7 @@ export declare function getTaskLogTail(taskId: string, file: "stdout" | "stderr"
|
|
|
37
37
|
truncated?: undefined;
|
|
38
38
|
} | {
|
|
39
39
|
task_id: string;
|
|
40
|
-
file: "
|
|
40
|
+
file: "test" | "stdout" | "stderr" | "verify";
|
|
41
41
|
filename: string;
|
|
42
42
|
content: string;
|
|
43
43
|
available: boolean;
|
|
@@ -12,8 +12,8 @@ export interface ToolCatalogSnapshot {
|
|
|
12
12
|
tool_names: string[];
|
|
13
13
|
tool_manifest_sha256: string;
|
|
14
14
|
}
|
|
15
|
-
export declare const CHATGPT_CORE_TOOL_NAMES: readonly ["health_check", "list_agents", "list_workspace", "read_workspace_file", "save_plan", "create_task", "wait_for_task", "get_task_summary", "get_diff", "get_result", "get_result_json", "get_test_log", "get_task_status", "list_tasks", "cancel_task", "audit_task"];
|
|
16
|
-
export declare const CHATGPT_DIRECT_TOOL_NAMES: readonly ["health_check", "list_workspace", "create_direct_session", "search_workspace", "read_workspace_file", "apply_patch", "run_verification", "finalize_direct_session", "audit_session"];
|
|
15
|
+
export declare const CHATGPT_CORE_TOOL_NAMES: readonly ["health_check", "list_agents", "list_workspace", "read_workspace_file", "save_plan", "create_task", "wait_for_task", "get_task_summary", "get_diff", "get_result", "get_result_json", "get_test_log", "get_task_status", "list_tasks", "cancel_task", "audit_task", "safe_status"];
|
|
16
|
+
export declare const CHATGPT_DIRECT_TOOL_NAMES: readonly ["health_check", "list_workspace", "create_direct_session", "search_workspace", "read_workspace_file", "apply_patch", "run_verification", "finalize_direct_session", "audit_session", "sync_file"];
|
|
17
17
|
export declare function resolveToolProfile(configProfile?: string): ToolProfile;
|
|
18
18
|
export declare function selectToolsForProfile<T extends CatalogTool>(tools: T[], profile: ToolProfile, enableDirectProfile?: boolean): T[];
|
|
19
19
|
export declare function buildToolCatalogSnapshot(tools: CatalogTool[], profile: ToolProfile): ToolCatalogSnapshot;
|
|
@@ -17,6 +17,7 @@ export const CHATGPT_CORE_TOOL_NAMES = [
|
|
|
17
17
|
"list_tasks",
|
|
18
18
|
"cancel_task",
|
|
19
19
|
"audit_task",
|
|
20
|
+
"safe_status",
|
|
20
21
|
];
|
|
21
22
|
export const CHATGPT_DIRECT_TOOL_NAMES = [
|
|
22
23
|
"health_check",
|
|
@@ -28,6 +29,7 @@ export const CHATGPT_DIRECT_TOOL_NAMES = [
|
|
|
28
29
|
"run_verification",
|
|
29
30
|
"finalize_direct_session",
|
|
30
31
|
"audit_session",
|
|
32
|
+
"sync_file",
|
|
31
33
|
];
|
|
32
34
|
let lastSnapshot = null;
|
|
33
35
|
export function resolveToolProfile(configProfile) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PATCHWARDEN_VERSION = "0.6.
|
|
2
|
-
export declare const TOOL_SCHEMA_EPOCH = "2026-06-
|
|
1
|
+
export declare const PATCHWARDEN_VERSION = "0.6.4";
|
|
2
|
+
export declare const TOOL_SCHEMA_EPOCH = "2026-06-24-v7";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const PATCHWARDEN_VERSION = "0.6.
|
|
2
|
-
export const TOOL_SCHEMA_EPOCH = "2026-06-
|
|
1
|
+
export const PATCHWARDEN_VERSION = "0.6.4";
|
|
2
|
+
export const TOOL_SCHEMA_EPOCH = "2026-06-24-v7";
|
package/dist/watcherStatus.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface WatcherStatusSnapshot {
|
|
|
11
11
|
instance_id: string | null;
|
|
12
12
|
launcher_pid: number | null;
|
|
13
13
|
reason: string | null;
|
|
14
|
+
activity: string | null;
|
|
14
15
|
}
|
|
15
16
|
export declare function getWatcherHeartbeatPath(config?: PatchWardenConfig): string;
|
|
16
17
|
export declare function readWatcherStatus(config?: PatchWardenConfig, nowMs?: number): WatcherStatusSnapshot;
|
package/dist/watcherStatus.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
1
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { getConfig, getTasksDir } from "./config.js";
|
|
4
4
|
export function getWatcherHeartbeatPath(config = getConfig()) {
|
|
@@ -8,6 +8,22 @@ export function readWatcherStatus(config = getConfig(), nowMs = Date.now()) {
|
|
|
8
8
|
const staleAfterSeconds = config.watcherStaleSeconds;
|
|
9
9
|
const heartbeatPath = getWatcherHeartbeatPath(config);
|
|
10
10
|
if (!existsSync(heartbeatPath)) {
|
|
11
|
+
// Even if watcher heartbeat is missing, check if a task is actively running
|
|
12
|
+
const taskFallback = checkRunningTaskHeartbeat(config, nowMs, staleAfterSeconds);
|
|
13
|
+
if (taskFallback) {
|
|
14
|
+
return {
|
|
15
|
+
status: "healthy",
|
|
16
|
+
available: true,
|
|
17
|
+
stale_after_seconds: staleAfterSeconds,
|
|
18
|
+
last_heartbeat_at: taskFallback.heartbeat_at,
|
|
19
|
+
heartbeat_age_seconds: taskFallback.age_seconds,
|
|
20
|
+
heartbeat_pid: null,
|
|
21
|
+
instance_id: null,
|
|
22
|
+
launcher_pid: null,
|
|
23
|
+
reason: null,
|
|
24
|
+
activity: taskFallback.activity,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
11
27
|
return {
|
|
12
28
|
status: "missing",
|
|
13
29
|
available: false,
|
|
@@ -18,6 +34,7 @@ export function readWatcherStatus(config = getConfig(), nowMs = Date.now()) {
|
|
|
18
34
|
instance_id: null,
|
|
19
35
|
launcher_pid: null,
|
|
20
36
|
reason: "Watcher heartbeat has not been observed. Start or restart the PatchWarden watcher.",
|
|
37
|
+
activity: null,
|
|
21
38
|
};
|
|
22
39
|
}
|
|
23
40
|
try {
|
|
@@ -29,16 +46,47 @@ export function readWatcherStatus(config = getConfig(), nowMs = Date.now()) {
|
|
|
29
46
|
const ageMs = Math.max(0, nowMs - heartbeatMs);
|
|
30
47
|
const ageSeconds = Math.round(ageMs / 1000);
|
|
31
48
|
const healthy = ageMs < staleAfterSeconds * 1000;
|
|
49
|
+
if (healthy) {
|
|
50
|
+
return {
|
|
51
|
+
status: "healthy",
|
|
52
|
+
available: true,
|
|
53
|
+
stale_after_seconds: staleAfterSeconds,
|
|
54
|
+
last_heartbeat_at: String(data.last_heartbeat_at),
|
|
55
|
+
heartbeat_age_seconds: ageSeconds,
|
|
56
|
+
heartbeat_pid: Number.isInteger(Number(data.pid)) ? Number(data.pid) : null,
|
|
57
|
+
instance_id: typeof data.instance_id === "string" ? data.instance_id : null,
|
|
58
|
+
launcher_pid: Number.isInteger(Number(data.launcher_pid)) ? Number(data.launcher_pid) : null,
|
|
59
|
+
reason: null,
|
|
60
|
+
activity: null,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Watcher heartbeat is stale — check if a task is actively running
|
|
64
|
+
const taskFallback = checkRunningTaskHeartbeat(config, nowMs, staleAfterSeconds);
|
|
65
|
+
if (taskFallback) {
|
|
66
|
+
return {
|
|
67
|
+
status: "healthy",
|
|
68
|
+
available: true,
|
|
69
|
+
stale_after_seconds: staleAfterSeconds,
|
|
70
|
+
last_heartbeat_at: taskFallback.heartbeat_at,
|
|
71
|
+
heartbeat_age_seconds: taskFallback.age_seconds,
|
|
72
|
+
heartbeat_pid: Number.isInteger(Number(data.pid)) ? Number(data.pid) : null,
|
|
73
|
+
instance_id: typeof data.instance_id === "string" ? data.instance_id : null,
|
|
74
|
+
launcher_pid: Number.isInteger(Number(data.launcher_pid)) ? Number(data.launcher_pid) : null,
|
|
75
|
+
reason: null,
|
|
76
|
+
activity: taskFallback.activity,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
32
79
|
return {
|
|
33
|
-
status:
|
|
34
|
-
available:
|
|
80
|
+
status: "stale",
|
|
81
|
+
available: false,
|
|
35
82
|
stale_after_seconds: staleAfterSeconds,
|
|
36
83
|
last_heartbeat_at: String(data.last_heartbeat_at),
|
|
37
84
|
heartbeat_age_seconds: ageSeconds,
|
|
38
85
|
heartbeat_pid: Number.isInteger(Number(data.pid)) ? Number(data.pid) : null,
|
|
39
86
|
instance_id: typeof data.instance_id === "string" ? data.instance_id : null,
|
|
40
87
|
launcher_pid: Number.isInteger(Number(data.launcher_pid)) ? Number(data.launcher_pid) : null,
|
|
41
|
-
reason:
|
|
88
|
+
reason: "Watcher heartbeat is stale. Restart the PatchWarden watcher.",
|
|
89
|
+
activity: null,
|
|
42
90
|
};
|
|
43
91
|
}
|
|
44
92
|
catch {
|
|
@@ -52,9 +100,53 @@ export function readWatcherStatus(config = getConfig(), nowMs = Date.now()) {
|
|
|
52
100
|
instance_id: null,
|
|
53
101
|
launcher_pid: null,
|
|
54
102
|
reason: "Watcher heartbeat file is unreadable.",
|
|
103
|
+
activity: null,
|
|
55
104
|
};
|
|
56
105
|
}
|
|
57
106
|
}
|
|
107
|
+
function checkRunningTaskHeartbeat(config, nowMs, staleAfterSeconds) {
|
|
108
|
+
const tasksDir = getTasksDir(config);
|
|
109
|
+
if (!existsSync(tasksDir))
|
|
110
|
+
return null;
|
|
111
|
+
let entries;
|
|
112
|
+
try {
|
|
113
|
+
entries = readdirSync(tasksDir, { withFileTypes: true });
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
for (const entry of entries) {
|
|
119
|
+
if (!entry.isDirectory())
|
|
120
|
+
continue;
|
|
121
|
+
const taskDir = join(tasksDir, entry.name);
|
|
122
|
+
const statusFile = join(taskDir, "status.json");
|
|
123
|
+
const runtimeFile = join(taskDir, "runtime.json");
|
|
124
|
+
if (!existsSync(statusFile) || !existsSync(runtimeFile))
|
|
125
|
+
continue;
|
|
126
|
+
try {
|
|
127
|
+
const status = JSON.parse(readFileSync(statusFile, "utf-8"));
|
|
128
|
+
if (status.status !== "running")
|
|
129
|
+
continue;
|
|
130
|
+
const runtime = JSON.parse(readFileSync(runtimeFile, "utf-8"));
|
|
131
|
+
const heartbeatAt = String(runtime.last_heartbeat_at || "");
|
|
132
|
+
const heartbeatMs = Date.parse(heartbeatAt);
|
|
133
|
+
if (!Number.isFinite(heartbeatMs))
|
|
134
|
+
continue;
|
|
135
|
+
const ageMs = Math.max(0, nowMs - heartbeatMs);
|
|
136
|
+
if (ageMs < staleAfterSeconds * 1000) {
|
|
137
|
+
return {
|
|
138
|
+
heartbeat_at: heartbeatAt,
|
|
139
|
+
age_seconds: Math.round(ageMs / 1000),
|
|
140
|
+
activity: `watcher busy executing task ${entry.name}`,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
58
150
|
export function derivePendingReason(task, watcher) {
|
|
59
151
|
if (task.status === "pending") {
|
|
60
152
|
if (watcher.status === "stale")
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# PatchWarden Control Center
|
|
2
|
+
|
|
3
|
+
PatchWarden has three control layers:
|
|
4
|
+
|
|
5
|
+
1. Web dashboard: the daily management surface for status, setup checks, tasks,
|
|
6
|
+
stale-task actions, Direct sessions, audit logs, and long logs.
|
|
7
|
+
2. Tray entry: a lightweight quick-control surface for opening the dashboard,
|
|
8
|
+
checking compact status, Start/Stop/Restart, opening logs, and quitting the
|
|
9
|
+
tray.
|
|
10
|
+
3. CLI/scripts: the lower-level fallback for automation, smoke tests, package
|
|
11
|
+
checks, and troubleshooting.
|
|
12
|
+
|
|
13
|
+
## User Entrypoints
|
|
14
|
+
|
|
15
|
+
From the repository root:
|
|
16
|
+
|
|
17
|
+
```powershell
|
|
18
|
+
.\PatchWarden-Desktop.cmd
|
|
19
|
+
.\PatchWarden-Control.cmd
|
|
20
|
+
.\PatchWarden-Control-Tray.cmd --foreground
|
|
21
|
+
.\PatchWarden.cmd status all
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Use `PatchWarden-Control.cmd` for normal desktop use. Use the tray when you only
|
|
25
|
+
need quick controls. Use `PatchWarden.cmd` when you need explicit CLI output or
|
|
26
|
+
automation-friendly commands.
|
|
27
|
+
|
|
28
|
+
## Design Notes
|
|
29
|
+
|
|
30
|
+
- `control-center-mvp.md`: first Web dashboard scope.
|
|
31
|
+
- `control-center-phase2.md`: follow-up management and diagnostics scope.
|
|
32
|
+
- `control-center-daily-driver.md`: current daily-use contract.
|
|
33
|
+
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# PatchWarden Control Center Daily Driver
|
|
2
|
+
|
|
3
|
+
> v0.6.4 在 v0.6.2 MVP 与 v0.6.3 Phase 2 基础上,把 Control Center 从「启动页面脚本」
|
|
4
|
+
> 升级为日常入口:单实例启动、后台运行、托盘入口、健康修复建议、页面通知和活动时间线。
|
|
5
|
+
> 不重构架构,不合并 Core/Direct MCP,不改现有 MCP 工具注册逻辑。
|
|
6
|
+
> 不发布 npm,不打 git tag。
|
|
7
|
+
|
|
8
|
+
## 概述
|
|
9
|
+
|
|
10
|
+
Daily Driver 完全在 Control Center HTTP 层与启动脚本层增强,未触动 MCP 工具注册、
|
|
11
|
+
watcher 核心循环或 Direct session 写入逻辑。新增的 API 沿用既有 token 校验、路径围栏
|
|
12
|
+
和脱敏机制;托盘与后台模式仅调用现有 Control Center API,不引入新的进程管理路径。
|
|
13
|
+
|
|
14
|
+
- **单实例启动**:status 文件 + 端口探测,重复运行只开浏览器,不启第二个服务
|
|
15
|
+
- **后台运行**:`-Background`(默认)/ `-Foreground` / `-NoBrowser`,日志写入
|
|
16
|
+
`%LOCALAPPDATA%\patchwarden\control-center\control-center.{stdout,stderr}.log`
|
|
17
|
+
- **托盘入口**:基于 .NET NotifyIcon 的轻量 PowerShell 托盘,无需 Electron
|
|
18
|
+
- **健康修复建议**:`/api/status` 新增 `suggestions` 字段,dashboard 显示建议卡片
|
|
19
|
+
- **页面通知**:dashboard 轮询状态变化时弹出 toast,同一事件只提示一次
|
|
20
|
+
- **Activity Timeline**:`runtime/control-center-events.jsonl` 记录关键事件,
|
|
21
|
+
`GET /api/events` 返回最近事件,dashboard 显示时间线区块
|
|
22
|
+
|
|
23
|
+
## 启动方式
|
|
24
|
+
|
|
25
|
+
### 1. 日常入口(推荐)
|
|
26
|
+
|
|
27
|
+
```powershell
|
|
28
|
+
.\PatchWarden-Control.cmd
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
默认后台启动 Control Center 并打开浏览器。再次运行时:
|
|
32
|
+
|
|
33
|
+
- 如果 127.0.0.1:8090 已经是当前 Control Center —— 直接打开浏览器页面,不重复启动
|
|
34
|
+
- 如果端口被其他程序占用 —— 给出明确错误提示并退出
|
|
35
|
+
- 如果 status 文件指向已死的 PID —— 清理孤儿进程后启动新实例
|
|
36
|
+
|
|
37
|
+
### 2. 启动参数
|
|
38
|
+
|
|
39
|
+
```powershell
|
|
40
|
+
.\PatchWarden-Control.cmd -NoBrowser # 启动但不打开浏览器
|
|
41
|
+
.\PatchWarden-Control.cmd -Foreground # 前台运行,日志直接输出到控制台
|
|
42
|
+
.\PatchWarden-Control.cmd -Background # 后台运行(默认),脚本启动后即退出
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`-Foreground` 与 `-Background` 互斥;都不传时默认 `-Background`。
|
|
46
|
+
|
|
47
|
+
### 3. 托盘入口
|
|
48
|
+
|
|
49
|
+
```powershell
|
|
50
|
+
.\PatchWarden-Control-Tray.cmd
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
启动 Windows 系统托盘图标(基于 .NET NotifyIcon,无需额外依赖)。如果 Control Center
|
|
54
|
+
未运行,托盘脚本会先在后台启动它。托盘菜单:
|
|
55
|
+
|
|
56
|
+
| 菜单项 | 行为 |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| Open Control Center | 在默认浏览器打开 dashboard |
|
|
59
|
+
| Start All | `POST /api/start-all`(带 token) |
|
|
60
|
+
| Stop All | `POST /api/stop-all`(带 token) |
|
|
61
|
+
| Restart All | `POST /api/restart-all`(带 token) |
|
|
62
|
+
| Open Workspace | 通过 `GET /api/workspace` 获取 workspaceRoot 后用 explorer 打开 |
|
|
63
|
+
| Open Logs Folder | `POST /api/open-logs-folder`(带 token) |
|
|
64
|
+
| Exit | 关闭托盘(不停止 Control Center 后台进程) |
|
|
65
|
+
|
|
66
|
+
双击托盘图标打开 dashboard。所有 API 调用通过 `/control-token.json` 获取 token 后
|
|
67
|
+
带 `X-PatchWarden-Control-Token` 头发起请求。
|
|
68
|
+
|
|
69
|
+
## 改动文件
|
|
70
|
+
|
|
71
|
+
| 文件 | 改动 |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| `src/version.ts` | `PATCHWARDEN_VERSION` 0.6.3 → 0.6.4 |
|
|
74
|
+
| `package.json` | `version` 0.6.3 → 0.6.4 |
|
|
75
|
+
| `src/controlCenter.ts` | 新增 status 文件、events JSONL、suggestions 引擎、`/api/events`、`/api/control-center-status`;`getControlCenterLogDir` 支持 `PATCHWARDEN_CONTROL_LOG_DIR` 覆盖 |
|
|
76
|
+
| `scripts/control/start-control-center.ps1` | 重写:单实例检测、`-NoBrowser`/`-Foreground`/`-Background`、孤儿清理、端口冲突检测 |
|
|
77
|
+
| `scripts/control/control-center-tray.ps1` | 新文件:.NET NotifyIcon 托盘,菜单驱动 Control Center API |
|
|
78
|
+
| `PatchWarden-Control-Tray.cmd` | 新文件:托盘启动入口 |
|
|
79
|
+
| `ui/pages/dashboard.html` | 新增 Health Suggestions 卡片、toast 通知、Activity Timeline 区块 |
|
|
80
|
+
| `scripts/checks/control-center-smoke.js` | 新增 Test 16–20 覆盖 Daily Driver API;`PATCHWARDEN_CONTROL_LOG_DIR` 重定向到项目内临时目录 |
|
|
81
|
+
| `scripts/release/pack-clean.js` | forbidden 列表新增 `.tmp/` |
|
|
82
|
+
| `.gitignore` | 新增 `.tmp/` |
|
|
83
|
+
| `docs/control-center/control-center-daily-driver.md` | 本文档 |
|
|
84
|
+
|
|
85
|
+
## 新增 API
|
|
86
|
+
|
|
87
|
+
### GET 接口(免 token)
|
|
88
|
+
|
|
89
|
+
| 路径 | 说明 |
|
|
90
|
+
| --- | --- |
|
|
91
|
+
| `GET /api/events?limit=<N>` | 返回最近 N 条活动事件(最大 1000),结构 `{events, total, limit}` |
|
|
92
|
+
| `GET /api/control-center-status` | 读取 status 文件,返回 `{running, pid, port, started_at, url, version}` 或 `{running: false}` |
|
|
93
|
+
|
|
94
|
+
### /api/status 增强字段
|
|
95
|
+
|
|
96
|
+
`GET /api/status` 响应新增 `suggestions` 数组,每条建议包含:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"code": "core_stopped",
|
|
101
|
+
"severity": "warning",
|
|
102
|
+
"message": "Core 未运行,建议启动 Core profile",
|
|
103
|
+
"action": "/api/core/start",
|
|
104
|
+
"link": null
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
| code | severity | 触发条件 | action |
|
|
109
|
+
| --- | --- | --- | --- |
|
|
110
|
+
| `core_stopped` | warning | Core 探测不可用 | `/api/core/start` |
|
|
111
|
+
| `direct_stopped` | warning | Direct 探测不可用 | `/api/direct/start` |
|
|
112
|
+
| `watcher_stale` | error | watcher 状态为 stale/unreadable | `/api/restart-all` |
|
|
113
|
+
| `stale_task` | warning | 存在 stale 任务 | 无 action,`link` 指向 tasks 页面 |
|
|
114
|
+
| `tunnel_not_ready` | warning | Core 或 Direct tunnel 未就绪 | `/api/restart-all` |
|
|
115
|
+
| `agent_missing` | info | 配置的 agent 不可用 | 无 action,提示检查路径 |
|
|
116
|
+
|
|
117
|
+
## 活动事件
|
|
118
|
+
|
|
119
|
+
事件写入 `%LOCALAPPDATA%\patchwarden\control-center\control-center-events.jsonl`,
|
|
120
|
+
每行一个 JSON 对象 `{timestamp, type, payload?}`。文件超过 512KB 时惰性裁剪到
|
|
121
|
+
2000 行。
|
|
122
|
+
|
|
123
|
+
### 事件类型
|
|
124
|
+
|
|
125
|
+
| type | 触发时机 |
|
|
126
|
+
| --- | --- |
|
|
127
|
+
| `control_center.started` | 服务 listen 成功 |
|
|
128
|
+
| `control_center.stopped` | 服务收到 SIGTERM/SIGINT 关闭 |
|
|
129
|
+
| `manage.start.all` / `manage.stop.all` / `manage.restart.all` | 用户请求 start/stop/restart all |
|
|
130
|
+
| `manage.<mode>.<action>.failed` | manage-patchwarden.ps1 执行失败 |
|
|
131
|
+
| `core.status_changed` | Core 可用性发生变化(diff 自上次 /api/status 轮询) |
|
|
132
|
+
| `direct.status_changed` | Direct 可用性发生变化 |
|
|
133
|
+
| `watcher.status_changed` | watcher 状态发生变化 |
|
|
134
|
+
| `task.status_changed` | 任务状态从 running → done/failed 等 |
|
|
135
|
+
| `task.reconciled` | 用户对 stale 任务执行 reconcile |
|
|
136
|
+
| `task.audited` | 用户对任务执行 audit |
|
|
137
|
+
|
|
138
|
+
> Control Center 是无状态、拉取驱动的服务。`core/direct/watcher/task.status_changed`
|
|
139
|
+
> 事件在 `/api/status` 轮询时通过 digest diff 检测,因此事件时间戳反映的是「被观察到」
|
|
140
|
+
> 的时间,不保证是状态变化的精确时刻。
|
|
141
|
+
|
|
142
|
+
## 页面通知(toast)
|
|
143
|
+
|
|
144
|
+
dashboard.html 轮询 `/api/status`(30s)和 `/api/audit`(90s)时检测以下状态变化并
|
|
145
|
+
弹出 toast 通知:
|
|
146
|
+
|
|
147
|
+
- core/direct: available → unavailable(error)/ unavailable → available(success)
|
|
148
|
+
- watcher: healthy → stale/unreadable(error)/ stale → healthy(success)
|
|
149
|
+
- task: running → done(success)/ running → failed*(error)
|
|
150
|
+
- audit: 新出现的 pass(success)/ warn(warning)/ fail(error)
|
|
151
|
+
|
|
152
|
+
同一事件通过 dedup key 只提示一次;toast 8 秒后自动消失,也可手动关闭。首次加载时
|
|
153
|
+
audit 列表会 seed 到 `seenAuditKeys`,不会对已有审计记录弹通知。
|
|
154
|
+
|
|
155
|
+
## 运行时文件
|
|
156
|
+
|
|
157
|
+
| 文件 | 路径 | 说明 |
|
|
158
|
+
| --- | --- | --- |
|
|
159
|
+
| status 文件 | `%LOCALAPPDATA%\patchwarden\control-center\control-center-status.json` | pid/port/started_at/url/version,服务启动时写入,关闭时删除 |
|
|
160
|
+
| events 文件 | `%LOCALAPPDATA%\patchwarden\control-center\control-center-events.jsonl` | 活动事件 JSONL |
|
|
161
|
+
| stdout 日志 | `%LOCALAPPDATA%\patchwarden\control-center\control-center.stdout.log` | 后台模式 stdout |
|
|
162
|
+
| stderr 日志 | `%LOCALAPPDATA%\patchwarden\control-center\control-center.stderr.log` | 后台模式 stderr |
|
|
163
|
+
|
|
164
|
+
> `PATCHWARDEN_CONTROL_LOG_DIR` 环境变量可覆盖上述目录(必须为绝对路径),
|
|
165
|
+
> 主要用于 smoke test 将其重定向到项目内临时目录。
|
|
166
|
+
|
|
167
|
+
## 测试
|
|
168
|
+
|
|
169
|
+
```powershell
|
|
170
|
+
npm.cmd test
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### control-center-smoke.js(21 项)
|
|
174
|
+
|
|
175
|
+
| # | 测试 | 覆盖 |
|
|
176
|
+
| --- | --- | --- |
|
|
177
|
+
| 1–1b | 静态文件 + 页面路由 | 基础服务 |
|
|
178
|
+
| 2 | `/api/status` JSON + 容错 | 结构校验 |
|
|
179
|
+
| 3–4 | tasks JSON + control-token | token 机制 |
|
|
180
|
+
| 5–7 | POST 无 token / 错 token → 403 | 安全门 |
|
|
181
|
+
| 8–9 | token 不污染 git + 无 CDN | 发布卫生 |
|
|
182
|
+
| 10 | 其他 GET API 可达 | workspace/audit/logs/tunnel |
|
|
183
|
+
| 11–15 | Phase 2 API | stale/reconcile/workspace/direct-sessions/logs |
|
|
184
|
+
| **16** | `/api/status` 包含 `suggestions` 数组 | Daily Driver |
|
|
185
|
+
| **17** | `/api/events` 返回 JSON | Daily Driver |
|
|
186
|
+
| **18** | `/api/logs/control-center` 返回 JSON | Daily Driver |
|
|
187
|
+
| **19** | POST `/api/restart-all` 无 token → 403 | Daily Driver |
|
|
188
|
+
| **20** | `/api/control-center-status` 报告 running 实例 | Daily Driver(单实例检测) |
|
|
189
|
+
|
|
190
|
+
### 全量测试结果
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
security tests: 139 passed, 0 failed
|
|
194
|
+
unit tests: 136 passed, 0 failed (1 skipped: Windows symlink)
|
|
195
|
+
lifecycle tests: 22 passed, 0 failed
|
|
196
|
+
control-center: 21 passed, 0 failed
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## 已知限制
|
|
200
|
+
|
|
201
|
+
1. **托盘为 PowerShell 实现**:基于 .NET NotifyIcon,不提供跨平台支持;在非 Windows
|
|
202
|
+
环境下不可用。如需跨平台托盘,需引入 Electron 或类似框架(本阶段刻意避免)。
|
|
203
|
+
2. **事件时间为观测时间**:Control Center 无状态,`status_changed` 事件在轮询时通过
|
|
204
|
+
diff 检测,时间戳是「被观察到」的时间,不保证是状态变化的精确时刻。
|
|
205
|
+
3. **status 文件依赖可写目录**:如果 `%LOCALAPPDATA%` 不可写(如沙箱环境),
|
|
206
|
+
status 文件不会生成,单实例检测会退化为端口探测模式。可通过
|
|
207
|
+
`PATCHWARDEN_CONTROL_LOG_DIR` 覆盖到可写目录。
|
|
208
|
+
4. **toast 为页面内通知**:不要求系统级通知;仅当 dashboard 页面打开时才会弹出。
|
|
209
|
+
5. **托盘 Exit 不停止后台进程**:Exit 仅关闭托盘,Control Center 后台 node 进程继续
|
|
210
|
+
运行。需通过 Stop All 或 `Stop-Process -Id <pid>` 停止。
|
|
211
|
+
6. **事件文件不轮转**:超过 512KB 时惰性裁剪到 2000 行,不按日期轮转。
|