@mseep/clawdcursor 1.5.5
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 +2264 -0
- package/LICENSE +21 -0
- package/README.md +385 -0
- package/SECURITY.md +44 -0
- package/SKILL.md +503 -0
- package/dist/core/agent-loop/agent.d.ts +42 -0
- package/dist/core/agent-loop/agent.js +1023 -0
- package/dist/core/agent-loop/agent.js.map +1 -0
- package/dist/core/agent-loop/batch-tool.d.ts +25 -0
- package/dist/core/agent-loop/batch-tool.js +218 -0
- package/dist/core/agent-loop/batch-tool.js.map +1 -0
- package/dist/core/agent-loop/coord-scale.d.ts +72 -0
- package/dist/core/agent-loop/coord-scale.js +89 -0
- package/dist/core/agent-loop/coord-scale.js.map +1 -0
- package/dist/core/agent-loop/focus-guard.d.ts +24 -0
- package/dist/core/agent-loop/focus-guard.js +29 -0
- package/dist/core/agent-loop/focus-guard.js.map +1 -0
- package/dist/core/agent-loop/project-mcp.d.ts +97 -0
- package/dist/core/agent-loop/project-mcp.js +253 -0
- package/dist/core/agent-loop/project-mcp.js.map +1 -0
- package/dist/core/agent-loop/prompt.d.ts +45 -0
- package/dist/core/agent-loop/prompt.js +426 -0
- package/dist/core/agent-loop/prompt.js.map +1 -0
- package/dist/core/agent-loop/tool-meta.d.ts +93 -0
- package/dist/core/agent-loop/tool-meta.js +651 -0
- package/dist/core/agent-loop/tool-meta.js.map +1 -0
- package/dist/core/agent-loop/tools.d.ts +38 -0
- package/dist/core/agent-loop/tools.js +2134 -0
- package/dist/core/agent-loop/tools.js.map +1 -0
- package/dist/core/agent-loop/types.d.ts +170 -0
- package/dist/core/agent-loop/types.js +12 -0
- package/dist/core/agent-loop/types.js.map +1 -0
- package/dist/core/agent.d.ts +51 -0
- package/dist/core/agent.js +245 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/app-categories.d.ts +67 -0
- package/dist/core/app-categories.js +108 -0
- package/dist/core/app-categories.js.map +1 -0
- package/dist/core/banner.d.ts +70 -0
- package/dist/core/banner.js +245 -0
- package/dist/core/banner.js.map +1 -0
- package/dist/core/classify/capability.d.ts +45 -0
- package/dist/core/classify/capability.js +78 -0
- package/dist/core/classify/capability.js.map +1 -0
- package/dist/core/decompose/llm-decomposer.d.ts +35 -0
- package/dist/core/decompose/llm-decomposer.js +156 -0
- package/dist/core/decompose/llm-decomposer.js.map +1 -0
- package/dist/core/decompose/parser.d.ts +27 -0
- package/dist/core/decompose/parser.js +101 -0
- package/dist/core/decompose/parser.js.map +1 -0
- package/dist/core/observability/correlation.d.ts +19 -0
- package/dist/core/observability/correlation.js +36 -0
- package/dist/core/observability/correlation.js.map +1 -0
- package/dist/core/observability/cost-meter.d.ts +51 -0
- package/dist/core/observability/cost-meter.js +134 -0
- package/dist/core/observability/cost-meter.js.map +1 -0
- package/dist/core/observability/logger.d.ts +61 -0
- package/dist/core/observability/logger.js +550 -0
- package/dist/core/observability/logger.js.map +1 -0
- package/dist/core/router/aliases.d.ts +50 -0
- package/dist/core/router/aliases.js +104 -0
- package/dist/core/router/aliases.js.map +1 -0
- package/dist/core/router/normalize.d.ts +41 -0
- package/dist/core/router/normalize.js +80 -0
- package/dist/core/router/normalize.js.map +1 -0
- package/dist/core/safety.d.ts +126 -0
- package/dist/core/safety.js +568 -0
- package/dist/core/safety.js.map +1 -0
- package/dist/core/sense/a11y-resolver.d.ts +73 -0
- package/dist/core/sense/a11y-resolver.js +76 -0
- package/dist/core/sense/a11y-resolver.js.map +1 -0
- package/dist/core/sense/fingerprint.d.ts +41 -0
- package/dist/core/sense/fingerprint.js +123 -0
- package/dist/core/sense/fingerprint.js.map +1 -0
- package/dist/core/sense/rank.d.ts +70 -0
- package/dist/core/sense/rank.js +192 -0
- package/dist/core/sense/rank.js.map +1 -0
- package/dist/core/sense/reactive-check.d.ts +40 -0
- package/dist/core/sense/reactive-check.js +48 -0
- package/dist/core/sense/reactive-check.js.map +1 -0
- package/dist/core/sense/snapshot.d.ts +19 -0
- package/dist/core/sense/snapshot.js +100 -0
- package/dist/core/sense/snapshot.js.map +1 -0
- package/dist/core/sense/types.d.ts +66 -0
- package/dist/core/sense/types.js +9 -0
- package/dist/core/sense/types.js.map +1 -0
- package/dist/core/sense/ui-map-anchors.d.ts +7 -0
- package/dist/core/sense/ui-map-anchors.js +24 -0
- package/dist/core/sense/ui-map-anchors.js.map +1 -0
- package/dist/core/sense/ui-map-elements.d.ts +5 -0
- package/dist/core/sense/ui-map-elements.js +33 -0
- package/dist/core/sense/ui-map-elements.js.map +1 -0
- package/dist/core/sense/ui-map-find.d.ts +56 -0
- package/dist/core/sense/ui-map-find.js +153 -0
- package/dist/core/sense/ui-map-find.js.map +1 -0
- package/dist/core/sense/ui-map-fuse.d.ts +4 -0
- package/dist/core/sense/ui-map-fuse.js +44 -0
- package/dist/core/sense/ui-map-fuse.js.map +1 -0
- package/dist/core/sense/ui-map-geom.d.ts +3 -0
- package/dist/core/sense/ui-map-geom.js +16 -0
- package/dist/core/sense/ui-map-geom.js.map +1 -0
- package/dist/core/sense/ui-map-holder.d.ts +58 -0
- package/dist/core/sense/ui-map-holder.js +87 -0
- package/dist/core/sense/ui-map-holder.js.map +1 -0
- package/dist/core/sense/ui-map-normalize.d.ts +19 -0
- package/dist/core/sense/ui-map-normalize.js +65 -0
- package/dist/core/sense/ui-map-normalize.js.map +1 -0
- package/dist/core/sense/ui-map-render.d.ts +4 -0
- package/dist/core/sense/ui-map-render.js +34 -0
- package/dist/core/sense/ui-map-render.js.map +1 -0
- package/dist/core/sense/ui-map-resolve.d.ts +41 -0
- package/dist/core/sense/ui-map-resolve.js +59 -0
- package/dist/core/sense/ui-map-resolve.js.map +1 -0
- package/dist/core/sense/ui-map-types.d.ts +66 -0
- package/dist/core/sense/ui-map-types.js +11 -0
- package/dist/core/sense/ui-map-types.js.map +1 -0
- package/dist/core/sense/ui-map.d.ts +29 -0
- package/dist/core/sense/ui-map.js +113 -0
- package/dist/core/sense/ui-map.js.map +1 -0
- package/dist/core/verify/assertions.d.ts +132 -0
- package/dist/core/verify/assertions.js +284 -0
- package/dist/core/verify/assertions.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/browser-config.d.ts +36 -0
- package/dist/llm/browser-config.js +83 -0
- package/dist/llm/browser-config.js.map +1 -0
- package/dist/llm/client.d.ts +268 -0
- package/dist/llm/client.js +1094 -0
- package/dist/llm/client.js.map +1 -0
- package/dist/llm/config.d.ts +79 -0
- package/dist/llm/config.js +375 -0
- package/dist/llm/config.js.map +1 -0
- package/dist/llm/credentials.d.ts +35 -0
- package/dist/llm/credentials.js +491 -0
- package/dist/llm/credentials.js.map +1 -0
- package/dist/llm/external-creds.d.ts +42 -0
- package/dist/llm/external-creds.js +169 -0
- package/dist/llm/external-creds.js.map +1 -0
- package/dist/llm/providers.d.ts +123 -0
- package/dist/llm/providers.js +717 -0
- package/dist/llm/providers.js.map +1 -0
- package/dist/paths.d.ts +31 -0
- package/dist/paths.js +147 -0
- package/dist/paths.js.map +1 -0
- package/dist/platform/accessibility.d.ts +139 -0
- package/dist/platform/accessibility.js +670 -0
- package/dist/platform/accessibility.js.map +1 -0
- package/dist/platform/cdp-driver.d.ts +318 -0
- package/dist/platform/cdp-driver.js +1179 -0
- package/dist/platform/cdp-driver.js.map +1 -0
- package/dist/platform/index.d.ts +11 -0
- package/dist/platform/index.js +69 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/keys.d.ts +17 -0
- package/dist/platform/keys.js +129 -0
- package/dist/platform/keys.js.map +1 -0
- package/dist/platform/launch-poll.d.ts +101 -0
- package/dist/platform/launch-poll.js +177 -0
- package/dist/platform/launch-poll.js.map +1 -0
- package/dist/platform/linux.d.ts +173 -0
- package/dist/platform/linux.js +1253 -0
- package/dist/platform/linux.js.map +1 -0
- package/dist/platform/macos.d.ts +136 -0
- package/dist/platform/macos.js +976 -0
- package/dist/platform/macos.js.map +1 -0
- package/dist/platform/native-desktop.d.ts +145 -0
- package/dist/platform/native-desktop.js +936 -0
- package/dist/platform/native-desktop.js.map +1 -0
- package/dist/platform/native-helper.d.ts +130 -0
- package/dist/platform/native-helper.js +592 -0
- package/dist/platform/native-helper.js.map +1 -0
- package/dist/platform/ocr-engine.d.ts +78 -0
- package/dist/platform/ocr-engine.js +363 -0
- package/dist/platform/ocr-engine.js.map +1 -0
- package/dist/platform/ps-runner.d.ts +28 -0
- package/dist/platform/ps-runner.js +228 -0
- package/dist/platform/ps-runner.js.map +1 -0
- package/dist/platform/types.d.ts +397 -0
- package/dist/platform/types.js +15 -0
- package/dist/platform/types.js.map +1 -0
- package/dist/platform/uri-handler.d.ts +75 -0
- package/dist/platform/uri-handler.js +273 -0
- package/dist/platform/uri-handler.js.map +1 -0
- package/dist/platform/wayland-backend.d.ts +53 -0
- package/dist/platform/wayland-backend.js +348 -0
- package/dist/platform/wayland-backend.js.map +1 -0
- package/dist/platform/windows.d.ts +232 -0
- package/dist/platform/windows.js +1210 -0
- package/dist/platform/windows.js.map +1 -0
- package/dist/postbuild.d.ts +10 -0
- package/dist/postbuild.js +98 -0
- package/dist/postbuild.js.map +1 -0
- package/dist/schema/snapshot.d.ts +33 -0
- package/dist/schema/snapshot.js +90 -0
- package/dist/schema/snapshot.js.map +1 -0
- package/dist/shortcuts.d.ts +30 -0
- package/dist/shortcuts.js +261 -0
- package/dist/shortcuts.js.map +1 -0
- package/dist/surface/cli.d.ts +7 -0
- package/dist/surface/cli.js +1556 -0
- package/dist/surface/cli.js.map +1 -0
- package/dist/surface/dashboard.d.ts +8 -0
- package/dist/surface/dashboard.js +1193 -0
- package/dist/surface/dashboard.js.map +1 -0
- package/dist/surface/doctor.d.ts +29 -0
- package/dist/surface/doctor.js +1514 -0
- package/dist/surface/doctor.js.map +1 -0
- package/dist/surface/format.d.ts +10 -0
- package/dist/surface/format.js +37 -0
- package/dist/surface/format.js.map +1 -0
- package/dist/surface/http-utility.d.ts +65 -0
- package/dist/surface/http-utility.js +336 -0
- package/dist/surface/http-utility.js.map +1 -0
- package/dist/surface/mcp-server.d.ts +91 -0
- package/dist/surface/mcp-server.js +280 -0
- package/dist/surface/mcp-server.js.map +1 -0
- package/dist/surface/onboarding.d.ts +15 -0
- package/dist/surface/onboarding.js +184 -0
- package/dist/surface/onboarding.js.map +1 -0
- package/dist/surface/pidfile.d.ts +79 -0
- package/dist/surface/pidfile.js +263 -0
- package/dist/surface/pidfile.js.map +1 -0
- package/dist/surface/readiness.d.ts +45 -0
- package/dist/surface/readiness.js +230 -0
- package/dist/surface/readiness.js.map +1 -0
- package/dist/surface/report.d.ts +68 -0
- package/dist/surface/report.js +341 -0
- package/dist/surface/report.js.map +1 -0
- package/dist/surface/skill-register.d.ts +14 -0
- package/dist/surface/skill-register.js +150 -0
- package/dist/surface/skill-register.js.map +1 -0
- package/dist/surface/version.d.ts +6 -0
- package/dist/surface/version.js +27 -0
- package/dist/surface/version.js.map +1 -0
- package/dist/tools/a11y.d.ts +8 -0
- package/dist/tools/a11y.js +545 -0
- package/dist/tools/a11y.js.map +1 -0
- package/dist/tools/a11y_depth.d.ts +19 -0
- package/dist/tools/a11y_depth.js +455 -0
- package/dist/tools/a11y_depth.js.map +1 -0
- package/dist/tools/agent.d.ts +15 -0
- package/dist/tools/agent.js +248 -0
- package/dist/tools/agent.js.map +1 -0
- package/dist/tools/batch.d.ts +46 -0
- package/dist/tools/batch.js +230 -0
- package/dist/tools/batch.js.map +1 -0
- package/dist/tools/cdp.d.ts +8 -0
- package/dist/tools/cdp.js +233 -0
- package/dist/tools/cdp.js.map +1 -0
- package/dist/tools/compact.d.ts +63 -0
- package/dist/tools/compact.js +418 -0
- package/dist/tools/compact.js.map +1 -0
- package/dist/tools/cost-class.d.ts +38 -0
- package/dist/tools/cost-class.js +117 -0
- package/dist/tools/cost-class.js.map +1 -0
- package/dist/tools/desktop.d.ts +9 -0
- package/dist/tools/desktop.js +346 -0
- package/dist/tools/desktop.js.map +1 -0
- package/dist/tools/electron_bridge.d.ts +41 -0
- package/dist/tools/electron_bridge.js +261 -0
- package/dist/tools/electron_bridge.js.map +1 -0
- package/dist/tools/extras.d.ts +22 -0
- package/dist/tools/extras.js +942 -0
- package/dist/tools/extras.js.map +1 -0
- package/dist/tools/favorites.d.ts +13 -0
- package/dist/tools/favorites.js +137 -0
- package/dist/tools/favorites.js.map +1 -0
- package/dist/tools/introspection.d.ts +13 -0
- package/dist/tools/introspection.js +55 -0
- package/dist/tools/introspection.js.map +1 -0
- package/dist/tools/ocr.d.ts +8 -0
- package/dist/tools/ocr.js +66 -0
- package/dist/tools/ocr.js.map +1 -0
- package/dist/tools/orchestration.d.ts +7 -0
- package/dist/tools/orchestration.js +377 -0
- package/dist/tools/orchestration.js.map +1 -0
- package/dist/tools/playbooks/extract-compose.d.ts +22 -0
- package/dist/tools/playbooks/extract-compose.js +85 -0
- package/dist/tools/playbooks/extract-compose.js.map +1 -0
- package/dist/tools/playbooks/find-replace.d.ts +11 -0
- package/dist/tools/playbooks/find-replace.js +56 -0
- package/dist/tools/playbooks/find-replace.js.map +1 -0
- package/dist/tools/playbooks/index.d.ts +63 -0
- package/dist/tools/playbooks/index.js +70 -0
- package/dist/tools/playbooks/index.js.map +1 -0
- package/dist/tools/playbooks/keys-blocklist.d.ts +24 -0
- package/dist/tools/playbooks/keys-blocklist.js +89 -0
- package/dist/tools/playbooks/keys-blocklist.js.map +1 -0
- package/dist/tools/registry.d.ts +40 -0
- package/dist/tools/registry.js +560 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/safety-gate.d.ts +16 -0
- package/dist/tools/safety-gate.js +70 -0
- package/dist/tools/safety-gate.js.map +1 -0
- package/dist/tools/scheduler.d.ts +76 -0
- package/dist/tools/scheduler.js +413 -0
- package/dist/tools/scheduler.js.map +1 -0
- package/dist/tools/shortcuts.d.ts +13 -0
- package/dist/tools/shortcuts.js +205 -0
- package/dist/tools/shortcuts.js.map +1 -0
- package/dist/tools/smart.d.ts +15 -0
- package/dist/tools/smart.js +785 -0
- package/dist/tools/smart.js.map +1 -0
- package/dist/tools/types.d.ts +174 -0
- package/dist/tools/types.js +67 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/window-text.d.ts +15 -0
- package/dist/tools/window-text.js +39 -0
- package/dist/tools/window-text.js.map +1 -0
- package/dist/types.d.ts +122 -0
- package/dist/types.js +41 -0
- package/dist/types.js.map +1 -0
- package/native/Package.swift +38 -0
- package/native/README.md +113 -0
- package/native/Sources/ClawdCursorHelper/main.swift +602 -0
- package/native/Sources/ClawdCursorHost/main.swift +182 -0
- package/native/Sources/PermissionCheck/main.swift +53 -0
- package/native/Sources/ScreenshotHelper/main.swift +219 -0
- package/native/build.sh +139 -0
- package/native/entitlements.plist +12 -0
- package/package.json +115 -0
- package/scripts/banner.ps1 +112 -0
- package/scripts/coord-accuracy.ps1 +140 -0
- package/scripts/coord-uwp.ps1 +80 -0
- package/scripts/edge-glow.ps1 +180 -0
- package/scripts/find-element.ps1 +198 -0
- package/scripts/get-foreground-window.ps1 +71 -0
- package/scripts/get-screen-context.ps1 +183 -0
- package/scripts/get-windows.ps1 +66 -0
- package/scripts/install-panic-hotkey.ps1 +46 -0
- package/scripts/interact-element.ps1 +431 -0
- package/scripts/invoke-element.ps1 +314 -0
- package/scripts/linux/atspi-bridge.py +356 -0
- package/scripts/linux/ocr-recognize.py +154 -0
- package/scripts/mac/_window-picker.jxa +163 -0
- package/scripts/mac/find-element.jxa +0 -0
- package/scripts/mac/find-element.sh +161 -0
- package/scripts/mac/focus-window.jxa +284 -0
- package/scripts/mac/get-focused-element.jxa +102 -0
- package/scripts/mac/get-foreground-window.jxa +173 -0
- package/scripts/mac/get-screen-context.jxa +197 -0
- package/scripts/mac/get-ui-tree.sh +141 -0
- package/scripts/mac/get-windows.jxa +117 -0
- package/scripts/mac/interact-element.sh +235 -0
- package/scripts/mac/invoke-element.jxa +408 -0
- package/scripts/mac/ocr-recognize.swift +124 -0
- package/scripts/ocr-recognize.ps1 +102 -0
- package/scripts/postinstall-native.js +48 -0
- package/scripts/ps-bridge.ps1 +830 -0
- package/scripts/smoke-mcp.ps1 +119 -0
- package/scripts/sync-version.ts +178 -0
- package/scripts/verify-install.js +81 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agent — thin entry point that drives the desktop using the unified
|
|
4
|
+
* agent loop (runAgent) with the configured model. The pipeline morph
|
|
5
|
+
* machinery has been removed; a capable configured model self-drives
|
|
6
|
+
* the full toolbox.
|
|
7
|
+
*
|
|
8
|
+
* Construction is intentionally minimal — the agent owns the desktop /
|
|
9
|
+
* a11y / OCR primitives and forwards everything else to runAgent.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Agent = void 0;
|
|
13
|
+
const native_desktop_1 = require("../platform/native-desktop");
|
|
14
|
+
const accessibility_1 = require("../platform/accessibility");
|
|
15
|
+
const ocr_engine_1 = require("../platform/ocr-engine");
|
|
16
|
+
const doctor_1 = require("../surface/doctor");
|
|
17
|
+
const agent_1 = require("./agent-loop/agent");
|
|
18
|
+
const platform_1 = require("../platform");
|
|
19
|
+
const banner_1 = require("./banner");
|
|
20
|
+
/**
|
|
21
|
+
* Provider-agnostic Anthropic-endpoint detector. Anthropic native endpoints
|
|
22
|
+
* use the `/messages` API shape; everything else (OpenAI, Groq, Together,
|
|
23
|
+
* Kimi, DeepSeek, Ollama, Gemini-via-OpenAI-compat) uses `/chat/completions`.
|
|
24
|
+
* Local endpoints and Ollama always take the OpenAI-compat path even if their
|
|
25
|
+
* host happens to match an Anthropic-ish substring.
|
|
26
|
+
*/
|
|
27
|
+
function isAnthropicEndpoint(baseUrl) {
|
|
28
|
+
if (!baseUrl)
|
|
29
|
+
return false;
|
|
30
|
+
if (baseUrl.includes('localhost'))
|
|
31
|
+
return false;
|
|
32
|
+
if (baseUrl.includes('11434'))
|
|
33
|
+
return false; // Ollama default port
|
|
34
|
+
return baseUrl.includes('anthropic.com');
|
|
35
|
+
}
|
|
36
|
+
class Agent {
|
|
37
|
+
desktop;
|
|
38
|
+
a11y;
|
|
39
|
+
ocrEngine;
|
|
40
|
+
config;
|
|
41
|
+
resolvedConfig = null;
|
|
42
|
+
hasApiKey;
|
|
43
|
+
state = {
|
|
44
|
+
status: 'idle',
|
|
45
|
+
stepsCompleted: 0,
|
|
46
|
+
stepsTotal: 0,
|
|
47
|
+
};
|
|
48
|
+
aborted = false;
|
|
49
|
+
/** Cancels the in-flight LLM fetch on abort(). Fresh per executeTask(). */
|
|
50
|
+
abortCtl = null;
|
|
51
|
+
/** The in-flight task promise — lets /stop wait for the abort to settle. */
|
|
52
|
+
currentRun = null;
|
|
53
|
+
taskExecutionLocked = false;
|
|
54
|
+
constructor(config, resolvedConfig) {
|
|
55
|
+
this.config = config;
|
|
56
|
+
this.resolvedConfig = resolvedConfig ?? null;
|
|
57
|
+
this.desktop = new native_desktop_1.NativeDesktop(config);
|
|
58
|
+
this.a11y = new accessibility_1.AccessibilityBridge();
|
|
59
|
+
this.ocrEngine = new ocr_engine_1.OcrEngine();
|
|
60
|
+
// hasApiKey gates the offline-mode banner — true if any cloud key is
|
|
61
|
+
// configured. Local LLM (Ollama) is always available via the loop,
|
|
62
|
+
// so absence of cloud keys just means we'll print an offline notice.
|
|
63
|
+
const hasCloudKey = !!(config.ai.apiKey && config.ai.apiKey.length > 0);
|
|
64
|
+
const hasVisionKey = !!(config.ai.visionApiKey && config.ai.visionApiKey.length > 0);
|
|
65
|
+
this.hasApiKey = hasCloudKey || hasVisionKey;
|
|
66
|
+
if (!this.hasApiKey) {
|
|
67
|
+
console.log(`⚡ Running in offline mode (no API key).`);
|
|
68
|
+
console.log(` To unlock AI, set AI_API_KEY (or run: clawdcursor doctor)`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async connect() {
|
|
72
|
+
await this.desktop.connect();
|
|
73
|
+
// Warm up the PSRunner bridge so assembly loading happens in background
|
|
74
|
+
this.a11y.warmup().catch(() => { });
|
|
75
|
+
// Touch the OCR engine so any first-call latency is paid up front.
|
|
76
|
+
void this.ocrEngine;
|
|
77
|
+
}
|
|
78
|
+
/** Safety-net timeout — only fires if task is truly stuck (stagnation + abort didn't catch it) */
|
|
79
|
+
static TASK_TIMEOUT_MS = 12 * 60 * 1000; // 12 minutes
|
|
80
|
+
async executeTask(task) {
|
|
81
|
+
// Atomic concurrency guard — boolean lock prevents TOCTOU race
|
|
82
|
+
// where two simultaneous /task requests both see status === 'idle'
|
|
83
|
+
if (this.taskExecutionLocked || this.state.status !== 'idle') {
|
|
84
|
+
return {
|
|
85
|
+
success: false,
|
|
86
|
+
steps: [{ action: 'error', description: 'Agent is busy', success: false, timestamp: Date.now() }],
|
|
87
|
+
duration: 0,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
this.taskExecutionLocked = true;
|
|
91
|
+
this.aborted = false;
|
|
92
|
+
this.abortCtl = new AbortController();
|
|
93
|
+
const startTime = Date.now();
|
|
94
|
+
// Wrap the entire task with a global wall-clock timeout.
|
|
95
|
+
let timeoutHandle = null;
|
|
96
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
97
|
+
timeoutHandle = setTimeout(() => {
|
|
98
|
+
this.aborted = true;
|
|
99
|
+
console.warn(`\n⏱ Task timed out after ${Agent.TASK_TIMEOUT_MS / 60000} minutes`);
|
|
100
|
+
resolve({
|
|
101
|
+
success: false,
|
|
102
|
+
steps: [{ action: 'error', description: `Task timed out after ${Agent.TASK_TIMEOUT_MS / 60000} minutes`, success: false, timestamp: Date.now() }],
|
|
103
|
+
duration: Date.now() - startTime,
|
|
104
|
+
});
|
|
105
|
+
}, Agent.TASK_TIMEOUT_MS);
|
|
106
|
+
});
|
|
107
|
+
// Transparency: the on-screen banner stays up for the WHOLE task so a
|
|
108
|
+
// human at the machine always knows automation is live (and can
|
|
109
|
+
// double-click it to stop). Pin/unpin — tool-activity touches must not
|
|
110
|
+
// hide it mid-task.
|
|
111
|
+
banner_1.controlBanner.pin();
|
|
112
|
+
try {
|
|
113
|
+
this.currentRun = this._executeTask(task, startTime);
|
|
114
|
+
return await Promise.race([this.currentRun, timeoutPromise]);
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
if (timeoutHandle !== null)
|
|
118
|
+
clearTimeout(timeoutHandle);
|
|
119
|
+
this.taskExecutionLocked = false;
|
|
120
|
+
this.currentRun = null;
|
|
121
|
+
banner_1.controlBanner.unpin();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Wait until the in-flight task settles (or the timeout elapses). Used by
|
|
126
|
+
* the /stop path so an abort can print its "aborted by user"
|
|
127
|
+
* acknowledgment before the process exits — previously stop was a hard
|
|
128
|
+
* kill 500ms after the HTTP response, mid-turn, with zero output.
|
|
129
|
+
*/
|
|
130
|
+
async waitForIdle(timeoutMs) {
|
|
131
|
+
const run = this.currentRun;
|
|
132
|
+
if (!run)
|
|
133
|
+
return;
|
|
134
|
+
await Promise.race([
|
|
135
|
+
run.then(() => undefined, () => undefined),
|
|
136
|
+
new Promise(resolve => setTimeout(resolve, timeoutMs)),
|
|
137
|
+
]);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Thin task executor — runs the unified agent loop with the configured model.
|
|
141
|
+
* No pipeline morph, no mode ladder, no verifier. A capable model self-drives
|
|
142
|
+
* the full toolbox.
|
|
143
|
+
*/
|
|
144
|
+
async _executeTask(task, startTime) {
|
|
145
|
+
// Resolve the LLM configuration from the disk config + CLI overlay.
|
|
146
|
+
const pipelineConfig = (0, doctor_1.loadPipelineConfig)(this.resolvedConfig);
|
|
147
|
+
const hasTextModel = !!(pipelineConfig?.layer2.model && pipelineConfig.layer2.baseUrl);
|
|
148
|
+
const hasVisionModel = !!(pipelineConfig?.layer3?.model && pipelineConfig?.layer3?.baseUrl);
|
|
149
|
+
// Build direct LLM configs for the unified agent. Prefer text; fall back
|
|
150
|
+
// to vision model if text is absent (vision models handle tool_use too).
|
|
151
|
+
const textConfig = hasTextModel && pipelineConfig
|
|
152
|
+
? {
|
|
153
|
+
baseUrl: pipelineConfig.layer2.baseUrl,
|
|
154
|
+
model: pipelineConfig.layer2.model,
|
|
155
|
+
apiKey: pipelineConfig.layer2.apiKey || pipelineConfig.apiKey || '',
|
|
156
|
+
isAnthropic: isAnthropicEndpoint(pipelineConfig.layer2.baseUrl),
|
|
157
|
+
maxTokens: 1024,
|
|
158
|
+
}
|
|
159
|
+
: undefined;
|
|
160
|
+
const visionLayer = pipelineConfig?.layer3;
|
|
161
|
+
const visionConfig = hasVisionModel && visionLayer && pipelineConfig
|
|
162
|
+
? {
|
|
163
|
+
baseUrl: visionLayer.baseUrl,
|
|
164
|
+
model: visionLayer.model,
|
|
165
|
+
apiKey: visionLayer.apiKey || pipelineConfig.apiKey || '',
|
|
166
|
+
isAnthropic: isAnthropicEndpoint(visionLayer.baseUrl),
|
|
167
|
+
maxTokens: 1024,
|
|
168
|
+
}
|
|
169
|
+
: undefined;
|
|
170
|
+
if (!hasTextModel && !hasVisionModel) {
|
|
171
|
+
console.log('⚡ No AI model configured. Run `clawdcursor doctor` to configure a provider.');
|
|
172
|
+
}
|
|
173
|
+
// Clear lastResult at task start so a poller can't read a stale result
|
|
174
|
+
// from a prior run while a new task is in flight.
|
|
175
|
+
this.state = { ...this.state, status: 'thinking', currentTask: task, stepsCompleted: 0, stepsTotal: 0, lastResult: undefined };
|
|
176
|
+
// Get the platform adapter. Lazy-initialised per call (cheap re-call).
|
|
177
|
+
const adapter = await (0, platform_1.getPlatform)();
|
|
178
|
+
// Resolve CDP driver if wired externally.
|
|
179
|
+
const cdp = this.cdpDriver ?? null;
|
|
180
|
+
// Resolve UIMapHolder if wired externally (by cli.ts daemon setup).
|
|
181
|
+
const uiMaps = this.uiMapHolder ?? undefined;
|
|
182
|
+
// Run the thin agent loop with the FULL toolbox.
|
|
183
|
+
// The agent loop prefers a11y-first (cheapest) and only calls screenshot
|
|
184
|
+
// when it genuinely needs pixels.
|
|
185
|
+
const agentResult = await (0, agent_1.runAgent)({
|
|
186
|
+
task,
|
|
187
|
+
isAborted: () => this.aborted,
|
|
188
|
+
abortSignal: this.abortCtl?.signal,
|
|
189
|
+
}, {
|
|
190
|
+
adapter,
|
|
191
|
+
llm: { text: textConfig, vision: visionConfig },
|
|
192
|
+
cdp,
|
|
193
|
+
uiMaps,
|
|
194
|
+
});
|
|
195
|
+
const steps = agentResult.steps.length > 0
|
|
196
|
+
? agentResult.steps.map(s => ({
|
|
197
|
+
action: s.toolName,
|
|
198
|
+
description: s.result.text,
|
|
199
|
+
success: s.result.success,
|
|
200
|
+
timestamp: Date.now(),
|
|
201
|
+
layer: 'unified',
|
|
202
|
+
method: s.toolName,
|
|
203
|
+
latencyMs: s.durationMs,
|
|
204
|
+
}))
|
|
205
|
+
: [{
|
|
206
|
+
action: agentResult.exit,
|
|
207
|
+
description: agentResult.text,
|
|
208
|
+
success: agentResult.success,
|
|
209
|
+
timestamp: Date.now(),
|
|
210
|
+
layer: 'unified',
|
|
211
|
+
}];
|
|
212
|
+
if (agentResult.text) {
|
|
213
|
+
console.log(` ${agentResult.text}`);
|
|
214
|
+
}
|
|
215
|
+
const taskResult = {
|
|
216
|
+
success: agentResult.success,
|
|
217
|
+
steps,
|
|
218
|
+
duration: Date.now() - startTime,
|
|
219
|
+
};
|
|
220
|
+
this.state = { ...this.state, status: 'idle', lastResult: taskResult };
|
|
221
|
+
return taskResult;
|
|
222
|
+
}
|
|
223
|
+
abort() {
|
|
224
|
+
this.aborted = true;
|
|
225
|
+
// Cancel the in-flight LLM fetch too — the cooperative flag alone only
|
|
226
|
+
// takes effect at the next loop checkpoint, i.e. after the current
|
|
227
|
+
// (up to 45s) LLM call returns.
|
|
228
|
+
this.abortCtl?.abort();
|
|
229
|
+
this.state = { status: 'idle', stepsCompleted: 0, stepsTotal: 0 };
|
|
230
|
+
}
|
|
231
|
+
getState() {
|
|
232
|
+
return { ...this.state };
|
|
233
|
+
}
|
|
234
|
+
getDesktop() {
|
|
235
|
+
return this.desktop;
|
|
236
|
+
}
|
|
237
|
+
getA11y() {
|
|
238
|
+
return this.a11y;
|
|
239
|
+
}
|
|
240
|
+
disconnect() {
|
|
241
|
+
this.desktop.disconnect();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.Agent = Agent;
|
|
245
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/core/agent.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,+DAA2D;AAC3D,6DAAgE;AAChE,uDAAmD;AACnD,8CAAuD;AACvD,8CAA8C;AAC9C,0CAA0C;AAC1C,qCAAyC;AAIzC;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,OAA2B;IACtD,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;QAAE,OAAO,KAAK,CAAC;IAChD,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC,CAAC,sBAAsB;IACnE,OAAO,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAC3C,CAAC;AAED,MAAa,KAAK;IACR,OAAO,CAAgB;IACvB,IAAI,CAAsB;IAC1B,SAAS,CAAY;IACrB,MAAM,CAAc;IACpB,cAAc,GAA0B,IAAI,CAAC;IAC7C,SAAS,CAAU;IACnB,KAAK,GAAe;QAC1B,MAAM,EAAE,MAAM;QACd,cAAc,EAAE,CAAC;QACjB,UAAU,EAAE,CAAC;KACd,CAAC;IACM,OAAO,GAAG,KAAK,CAAC;IACxB,2EAA2E;IACnE,QAAQ,GAA2B,IAAI,CAAC;IAChD,4EAA4E;IACpE,UAAU,GAA+B,IAAI,CAAC;IAC9C,mBAAmB,GAAG,KAAK,CAAC;IAEpC,YAAY,MA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AAC;QAEP,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;QACxC,CAAC;QAED,MAAM,UAAU,GAAe;YAC7B,OAAO,EAAE,WAAW,CAAC,OAAO;YAC5B,KAAK;YACL,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;SACjC,CAAC;QACF,IAAI,CAAC,KAAK,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;QACvE,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,uEAAuE;QACvE,mEAAmE;QACnE,gCAAgC;QAChC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;IACpE,CAAC;IAED,QAAQ;QACN,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,UAAU;QACR,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;IAC5B,CAAC;;AA5OH,sBA6OC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App categorization data — the single source of truth for app-pattern
|
|
3
|
+
* matching across clawdcursor.
|
|
4
|
+
*
|
|
5
|
+
* Why this file exists. v0.9's agnostic-audit subagent flagged three
|
|
6
|
+
* places where app-specific patterns were inlined as regexes deep inside
|
|
7
|
+
* other modules:
|
|
8
|
+
* - src/core/router/webview2.ts hardcoded the WebView2 settle list
|
|
9
|
+
* - src/core/safety.ts hardcoded the sensitive-app list
|
|
10
|
+
* - src/tools/electron_bridge.ts had its own KNOWN_APPS array
|
|
11
|
+
*
|
|
12
|
+
* Each of those was small, but together they meant "the list of apps
|
|
13
|
+
* clawdcursor knows about" was scattered across three files in three
|
|
14
|
+
* directories. Adding a new app required changing code in N places and
|
|
15
|
+
* was easy to miss. Worse, the names duplicated (Outlook appeared in
|
|
16
|
+
* both WebView2 and sensitive lists, with slightly different wording).
|
|
17
|
+
*
|
|
18
|
+
* This module consolidates the app-data so:
|
|
19
|
+
* - Categorization decisions live next to one another.
|
|
20
|
+
* - The agent loop / pipeline never imports this file — only the
|
|
21
|
+
* small helper modules that need to make a categorization call do.
|
|
22
|
+
* - Adding a new app means editing one row in one file.
|
|
23
|
+
*
|
|
24
|
+
* Anti-design note. This file is intentionally not exported from any
|
|
25
|
+
* index. Importers reach in explicitly so it's clear at the call-site
|
|
26
|
+
* that they're consulting app-category data, not running app-specific
|
|
27
|
+
* logic. The autonomous pipeline (agent loop, decomposer, verifier,
|
|
28
|
+
* preprocessor) does NOT import from here and never should — those
|
|
29
|
+
* components stay model- and app-agnostic by construction.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Apps that render their UI inside Chromium / Edge WebView2 / Electron.
|
|
33
|
+
* For these the OS-level UI Automation tree is sparse — clawdcursor needs
|
|
34
|
+
* a longer settle window after launch and may need to attach via CDP
|
|
35
|
+
* (`relaunch_with_cdp`) to read the real DOM.
|
|
36
|
+
*
|
|
37
|
+
* Matched against process name OR alias name (case-insensitive substring).
|
|
38
|
+
* Adding a new app here is the only change needed to give it the longer
|
|
39
|
+
* WebView2 settle treatment.
|
|
40
|
+
*/
|
|
41
|
+
export declare const WEBVIEW2_APPS: readonly string[];
|
|
42
|
+
/**
|
|
43
|
+
* Apps where any unlabeled click/keystroke is potentially destructive —
|
|
44
|
+
* email send, banking transfer, password manager autofill, private
|
|
45
|
+
* messaging hit-send. The safety gate elevates click-family tools to
|
|
46
|
+
* `confirm` when active app matches one of these AND no target label
|
|
47
|
+
* was supplied.
|
|
48
|
+
*
|
|
49
|
+
* Matched against active-window process name (case-insensitive substring).
|
|
50
|
+
* This is the canonical sensitive list; the `clawdcursor consent` flow
|
|
51
|
+
* also surfaces these categories to the user at install time.
|
|
52
|
+
*/
|
|
53
|
+
export declare const SENSITIVE_APPS: readonly string[];
|
|
54
|
+
/**
|
|
55
|
+
* Build a case-insensitive regex from a list of substring patterns.
|
|
56
|
+
* Used by callers that need the regex form (e.g. the existing
|
|
57
|
+
* webview2 helper and safety gate both `.test()` a process name).
|
|
58
|
+
*
|
|
59
|
+
* Word-boundary `\b` is used so we don't false-match (`mail` inside
|
|
60
|
+
* `gmail` is fine because both are listed; but `signal` doesn't match
|
|
61
|
+
* `signaling`).
|
|
62
|
+
*/
|
|
63
|
+
export declare function buildAppRegex(patterns: readonly string[]): RegExp;
|
|
64
|
+
/** Convenience: regex form of {@link WEBVIEW2_APPS}. */
|
|
65
|
+
export declare const WEBVIEW2_APPS_PATTERN: RegExp;
|
|
66
|
+
/** Convenience: regex form of {@link SENSITIVE_APPS}. */
|
|
67
|
+
export declare const SENSITIVE_APPS_PATTERN: RegExp;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* App categorization data — the single source of truth for app-pattern
|
|
4
|
+
* matching across clawdcursor.
|
|
5
|
+
*
|
|
6
|
+
* Why this file exists. v0.9's agnostic-audit subagent flagged three
|
|
7
|
+
* places where app-specific patterns were inlined as regexes deep inside
|
|
8
|
+
* other modules:
|
|
9
|
+
* - src/core/router/webview2.ts hardcoded the WebView2 settle list
|
|
10
|
+
* - src/core/safety.ts hardcoded the sensitive-app list
|
|
11
|
+
* - src/tools/electron_bridge.ts had its own KNOWN_APPS array
|
|
12
|
+
*
|
|
13
|
+
* Each of those was small, but together they meant "the list of apps
|
|
14
|
+
* clawdcursor knows about" was scattered across three files in three
|
|
15
|
+
* directories. Adding a new app required changing code in N places and
|
|
16
|
+
* was easy to miss. Worse, the names duplicated (Outlook appeared in
|
|
17
|
+
* both WebView2 and sensitive lists, with slightly different wording).
|
|
18
|
+
*
|
|
19
|
+
* This module consolidates the app-data so:
|
|
20
|
+
* - Categorization decisions live next to one another.
|
|
21
|
+
* - The agent loop / pipeline never imports this file — only the
|
|
22
|
+
* small helper modules that need to make a categorization call do.
|
|
23
|
+
* - Adding a new app means editing one row in one file.
|
|
24
|
+
*
|
|
25
|
+
* Anti-design note. This file is intentionally not exported from any
|
|
26
|
+
* index. Importers reach in explicitly so it's clear at the call-site
|
|
27
|
+
* that they're consulting app-category data, not running app-specific
|
|
28
|
+
* logic. The autonomous pipeline (agent loop, decomposer, verifier,
|
|
29
|
+
* preprocessor) does NOT import from here and never should — those
|
|
30
|
+
* components stay model- and app-agnostic by construction.
|
|
31
|
+
*/
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.SENSITIVE_APPS_PATTERN = exports.WEBVIEW2_APPS_PATTERN = exports.SENSITIVE_APPS = exports.WEBVIEW2_APPS = void 0;
|
|
34
|
+
exports.buildAppRegex = buildAppRegex;
|
|
35
|
+
/**
|
|
36
|
+
* Apps that render their UI inside Chromium / Edge WebView2 / Electron.
|
|
37
|
+
* For these the OS-level UI Automation tree is sparse — clawdcursor needs
|
|
38
|
+
* a longer settle window after launch and may need to attach via CDP
|
|
39
|
+
* (`relaunch_with_cdp`) to read the real DOM.
|
|
40
|
+
*
|
|
41
|
+
* Matched against process name OR alias name (case-insensitive substring).
|
|
42
|
+
* Adding a new app here is the only change needed to give it the longer
|
|
43
|
+
* WebView2 settle treatment.
|
|
44
|
+
*/
|
|
45
|
+
exports.WEBVIEW2_APPS = [
|
|
46
|
+
'olk', // Microsoft New Outlook (Win11)
|
|
47
|
+
'outlook',
|
|
48
|
+
'teams', // Microsoft Teams
|
|
49
|
+
'slack',
|
|
50
|
+
'discord',
|
|
51
|
+
'spotify',
|
|
52
|
+
'vscode', // VS Code
|
|
53
|
+
'code', // VS Code on macOS / Linux
|
|
54
|
+
'obsidian',
|
|
55
|
+
'notion',
|
|
56
|
+
];
|
|
57
|
+
/**
|
|
58
|
+
* Apps where any unlabeled click/keystroke is potentially destructive —
|
|
59
|
+
* email send, banking transfer, password manager autofill, private
|
|
60
|
+
* messaging hit-send. The safety gate elevates click-family tools to
|
|
61
|
+
* `confirm` when active app matches one of these AND no target label
|
|
62
|
+
* was supplied.
|
|
63
|
+
*
|
|
64
|
+
* Matched against active-window process name (case-insensitive substring).
|
|
65
|
+
* This is the canonical sensitive list; the `clawdcursor consent` flow
|
|
66
|
+
* also surfaces these categories to the user at install time.
|
|
67
|
+
*/
|
|
68
|
+
exports.SENSITIVE_APPS = [
|
|
69
|
+
// Email
|
|
70
|
+
'outlook',
|
|
71
|
+
'olk',
|
|
72
|
+
'mail',
|
|
73
|
+
'gmail',
|
|
74
|
+
'thunderbird',
|
|
75
|
+
// Finance
|
|
76
|
+
'banking',
|
|
77
|
+
// Password managers
|
|
78
|
+
'1password',
|
|
79
|
+
'lastpass',
|
|
80
|
+
'bitwarden',
|
|
81
|
+
'keeper',
|
|
82
|
+
'dashlane',
|
|
83
|
+
// Private messaging
|
|
84
|
+
'signal',
|
|
85
|
+
'whatsapp',
|
|
86
|
+
'messages',
|
|
87
|
+
'telegram',
|
|
88
|
+
'imessage',
|
|
89
|
+
'wickr',
|
|
90
|
+
];
|
|
91
|
+
/**
|
|
92
|
+
* Build a case-insensitive regex from a list of substring patterns.
|
|
93
|
+
* Used by callers that need the regex form (e.g. the existing
|
|
94
|
+
* webview2 helper and safety gate both `.test()` a process name).
|
|
95
|
+
*
|
|
96
|
+
* Word-boundary `\b` is used so we don't false-match (`mail` inside
|
|
97
|
+
* `gmail` is fine because both are listed; but `signal` doesn't match
|
|
98
|
+
* `signaling`).
|
|
99
|
+
*/
|
|
100
|
+
function buildAppRegex(patterns) {
|
|
101
|
+
const alt = patterns.map(p => p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|');
|
|
102
|
+
return new RegExp(`\\b(?:${alt})\\b`, 'i');
|
|
103
|
+
}
|
|
104
|
+
/** Convenience: regex form of {@link WEBVIEW2_APPS}. */
|
|
105
|
+
exports.WEBVIEW2_APPS_PATTERN = buildAppRegex(exports.WEBVIEW2_APPS);
|
|
106
|
+
/** Convenience: regex form of {@link SENSITIVE_APPS}. */
|
|
107
|
+
exports.SENSITIVE_APPS_PATTERN = buildAppRegex(exports.SENSITIVE_APPS);
|
|
108
|
+
//# sourceMappingURL=app-categories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-categories.js","sourceRoot":"","sources":["../../src/core/app-categories.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAqEH,sCAGC;AAtED;;;;;;;;;GASG;AACU,QAAA,aAAa,GAAsB;IAC9C,KAAK,EAAQ,gCAAgC;IAC7C,SAAS;IACT,OAAO,EAAM,kBAAkB;IAC/B,OAAO;IACP,SAAS;IACT,SAAS;IACT,QAAQ,EAAK,UAAU;IACvB,MAAM,EAAO,2BAA2B;IACxC,UAAU;IACV,QAAQ;CACT,CAAC;AAEF;;;;;;;;;;GAUG;AACU,QAAA,cAAc,GAAsB;IAC/C,QAAQ;IACR,SAAS;IACT,KAAK;IACL,MAAM;IACN,OAAO;IACP,aAAa;IACb,UAAU;IACV,SAAS;IACT,oBAAoB;IACpB,WAAW;IACX,UAAU;IACV,WAAW;IACX,QAAQ;IACR,UAAU;IACV,oBAAoB;IACpB,QAAQ;IACR,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,OAAO;CACR,CAAC;AAEF;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAAC,QAA2B;IACvD,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClF,OAAO,IAAI,MAAM,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC;AAED,wDAAwD;AAC3C,QAAA,qBAAqB,GAAW,aAAa,CAAC,qBAAa,CAAC,CAAC;AAE1E,yDAAyD;AAC5C,QAAA,sBAAsB,GAAW,aAAa,CAAC,sBAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Control banner — the on-screen "desktop control in progress" indicators:
|
|
3
|
+
* - scripts/banner.ps1: topmost, no-activate pill with a blinking red dot;
|
|
4
|
+
* carries the double-click → stop affordance.
|
|
5
|
+
* - scripts/edge-glow.ps1: a full-screen, click-through amber glow that pulses
|
|
6
|
+
* on all four screen edges. Pure ambient signal; spawned/killed in lockstep
|
|
7
|
+
* with the pill so the two are always in sync. Opt out via CLAWD_NO_GLOW=1.
|
|
8
|
+
*
|
|
9
|
+
* Transparency contract: whenever an agent is actively driving this desktop,
|
|
10
|
+
* a human at the machine sees it — and can kill it (double-click → the parent
|
|
11
|
+
* runs the `clawdcursor stop` flow). Two lifecycles feed it:
|
|
12
|
+
*
|
|
13
|
+
* - pin()/unpin(): the autonomous task loop pins the banner for the whole
|
|
14
|
+
* task (agent.executeTask). A pinned banner ignores idle timers.
|
|
15
|
+
* - touch(): every consequential (safetyTier ≥ 1) MCP tool call pokes the
|
|
16
|
+
* banner; it shows on the first poke and auto-hides after IDLE_HIDE_MS of
|
|
17
|
+
* inactivity. This covers EXTERNAL agents (editor-hosted over stdio or
|
|
18
|
+
* HTTP /mcp) where there is no task boundary to hook.
|
|
19
|
+
*
|
|
20
|
+
* Windows-only today (WinForms via the warm PowerShell host); macOS/Linux are
|
|
21
|
+
* silent no-ops — the API is platform-neutral so adapters can land later.
|
|
22
|
+
* Disable via `--no-banner` or CLAWD_NO_BANNER=1.
|
|
23
|
+
*/
|
|
24
|
+
import { type ChildProcess } from 'child_process';
|
|
25
|
+
type Spawner = () => ChildProcess;
|
|
26
|
+
declare class ControlBanner {
|
|
27
|
+
private child;
|
|
28
|
+
private glowChild;
|
|
29
|
+
private idleTimer;
|
|
30
|
+
private pinned;
|
|
31
|
+
private enabled;
|
|
32
|
+
private glowEnabled;
|
|
33
|
+
private onStopRequested;
|
|
34
|
+
private spawner;
|
|
35
|
+
private glowSpawner;
|
|
36
|
+
/** Wire the double-click → stop callback (the `clawdcursor stop` flow). */
|
|
37
|
+
configure(opts: {
|
|
38
|
+
onStopRequested?: () => void;
|
|
39
|
+
}): void;
|
|
40
|
+
/** Hard enable/disable (CLI --no-banner / config). Disabling hides immediately. */
|
|
41
|
+
setEnabled(v: boolean): void;
|
|
42
|
+
isVisible(): boolean;
|
|
43
|
+
/** Show and keep shown until unpin() — the autonomous-task lifecycle. */
|
|
44
|
+
pin(): void;
|
|
45
|
+
/** Release the task pin; hides unless tool activity re-touches it. */
|
|
46
|
+
unpin(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Activity poke from a consequential tool call: show now, auto-hide after
|
|
49
|
+
* IDLE_HIDE_MS without further pokes. No-op on the timer while pinned.
|
|
50
|
+
*/
|
|
51
|
+
touch(idleMs?: number): void;
|
|
52
|
+
private exitHookInstalled;
|
|
53
|
+
private show;
|
|
54
|
+
/** The "control in progress" pill — also the BANNER_STOP / kill-switch source. */
|
|
55
|
+
private spawnPill;
|
|
56
|
+
/** The ambient screen-edge glow — pure visual, click-through, no stdout. */
|
|
57
|
+
private spawnGlow;
|
|
58
|
+
private installExitHook;
|
|
59
|
+
private killGlow;
|
|
60
|
+
private forceHide;
|
|
61
|
+
private clearIdleTimer;
|
|
62
|
+
__setSpawnerForTests(s: Spawner): void;
|
|
63
|
+
__setGlowSpawnerForTests(s: Spawner): void;
|
|
64
|
+
__setPlatformEnabledForTests(v: boolean): void;
|
|
65
|
+
__setGlowEnabledForTests(v: boolean): void;
|
|
66
|
+
__resetForTests(): void;
|
|
67
|
+
}
|
|
68
|
+
/** Singleton — one banner per process (daemon or stdio MCP server). */
|
|
69
|
+
export declare const controlBanner: ControlBanner;
|
|
70
|
+
export {};
|