@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,377 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Orchestration tools — delegate tasks, launch apps, navigate browser.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.__resetInflightDelegationForTests = __resetInflightDelegationForTests;
|
|
40
|
+
exports.getOrchestrationTools = getOrchestrationTools;
|
|
41
|
+
const child_process_1 = require("child_process");
|
|
42
|
+
const util_1 = require("util");
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const fs = __importStar(require("fs"));
|
|
45
|
+
const os = __importStar(require("os"));
|
|
46
|
+
const browser_config_1 = require("../llm/browser-config");
|
|
47
|
+
const aliases_1 = require("../core/router/aliases");
|
|
48
|
+
const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
49
|
+
async function commandExists(cmd) {
|
|
50
|
+
try {
|
|
51
|
+
await execFileAsync('which', [cmd], { timeout: 2000 });
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
let inflightDelegation = null;
|
|
59
|
+
/** Test hook — clears the module-level in-flight holder. */
|
|
60
|
+
function __resetInflightDelegationForTests() {
|
|
61
|
+
inflightDelegation = null;
|
|
62
|
+
}
|
|
63
|
+
const SYNC_WAIT_DEFAULT_MS = 45_000; // under common 60s MCP client timeouts
|
|
64
|
+
const SYNC_WAIT_MIN_MS = 1_000;
|
|
65
|
+
const SYNC_WAIT_MAX_MS = 50_000;
|
|
66
|
+
const normTask = (s) => s.replace(/\s+/g, ' ').trim().toLowerCase();
|
|
67
|
+
const sleepMs = (ms) => new Promise(r => setTimeout(r, ms));
|
|
68
|
+
function startDelegation(agent, task) {
|
|
69
|
+
const entry = { task, startedAt: Date.now(), promise: Promise.resolve(), settled: false };
|
|
70
|
+
entry.promise = agent.executeTask(task).then(r => { entry.settled = true; entry.result = r; }, e => { entry.settled = true; entry.error = e; });
|
|
71
|
+
return entry;
|
|
72
|
+
}
|
|
73
|
+
function formatDelegationResult(entry) {
|
|
74
|
+
if (entry.error) {
|
|
75
|
+
const err = entry.error;
|
|
76
|
+
return { text: `delegate_to_agent: ${err?.message ?? String(entry.error)}`, isError: true };
|
|
77
|
+
}
|
|
78
|
+
const result = entry.result;
|
|
79
|
+
return {
|
|
80
|
+
text: JSON.stringify({
|
|
81
|
+
success: result?.success,
|
|
82
|
+
steps: result?.steps?.length ?? 0,
|
|
83
|
+
duration: `${((result?.duration ?? 0) / 1000).toFixed(1)}s`,
|
|
84
|
+
lastAction: result?.steps?.slice(-1)?.[0]?.description ?? '(unknown)',
|
|
85
|
+
}, null, 2),
|
|
86
|
+
isError: !result?.success,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function getOrchestrationTools() {
|
|
90
|
+
return [
|
|
91
|
+
{
|
|
92
|
+
name: 'delegate_to_agent',
|
|
93
|
+
description: "Hand a whole task to clawdcursor's built-in thin agent loop, which drives the toolbox with the model configured via `clawdcursor doctor` (perceive → act → iterate until done). " +
|
|
94
|
+
"For an expensive frontier model this is the delegation lever: hand grunt work to a cheaper configured model that takes the wheel. " +
|
|
95
|
+
"BOUNDED-SYNC: waits up to `timeout` seconds (default 45) for completion. A finished task returns its result directly; a longer task returns a {status:\"running\"} receipt with progress while the loop CONTINUES in the background — re-call with the SAME task text to keep waiting (re-attaches, never restarts), or poll agent_status / abort via abort_task. " +
|
|
96
|
+
"Requires `clawdcursor agent` running WITH a model configured; in tools-only / --no-llm mode there is no model to drive it.",
|
|
97
|
+
parameters: {
|
|
98
|
+
task: { type: 'string', description: 'Natural language task description', required: true },
|
|
99
|
+
timeout: { type: 'number', description: 'Max seconds to WAIT for completion before returning a running receipt (default 45, clamped 1–50; stays under MCP client call-timeouts). The task itself keeps running — this only bounds the wait.', required: false },
|
|
100
|
+
},
|
|
101
|
+
category: 'orchestration',
|
|
102
|
+
compactGroup: 'task',
|
|
103
|
+
safetyTier: 1,
|
|
104
|
+
handler: async ({ task, timeout }, ctx) => {
|
|
105
|
+
// Run the task IN-PROCESS on the daemon's configured-model agent.
|
|
106
|
+
// (This previously self-called the daemon's own /mcp via mcpCall, which
|
|
107
|
+
// the streamable-HTTP transport rejects with "Already connected to a
|
|
108
|
+
// transport" — a re-entrant MCP call. Calling ctx.agent directly avoids
|
|
109
|
+
// the self-call and returns a clean error when no model is configured.)
|
|
110
|
+
if (!ctx?.agent) {
|
|
111
|
+
return { text: 'delegate_to_agent: no model-backed agent attached. This needs `clawdcursor agent` running WITH a model configured (run `clawdcursor doctor`). In tools-only / --no-llm mode there is no model to drive the task — drive the toolbox tools directly instead.', isError: true };
|
|
112
|
+
}
|
|
113
|
+
const text = String(task ?? '').trim();
|
|
114
|
+
if (!text) {
|
|
115
|
+
return { text: 'delegate_to_agent: task must be a non-empty string', isError: true };
|
|
116
|
+
}
|
|
117
|
+
const timeoutSec = Number(timeout);
|
|
118
|
+
const boundMs = Math.min(SYNC_WAIT_MAX_MS, Math.max(SYNC_WAIT_MIN_MS, Number.isFinite(timeoutSec) && timeoutSec > 0 ? timeoutSec * 1000 : SYNC_WAIT_DEFAULT_MS));
|
|
119
|
+
let entry = inflightDelegation;
|
|
120
|
+
if (entry && !entry.settled) {
|
|
121
|
+
// A delegated task is still running. Same text → re-attach and keep
|
|
122
|
+
// waiting; different text → tell the caller the truth instead of
|
|
123
|
+
// queueing or double-running.
|
|
124
|
+
if (normTask(entry.task) !== normTask(text)) {
|
|
125
|
+
const runningFor = ((Date.now() - entry.startedAt) / 1000).toFixed(0);
|
|
126
|
+
return {
|
|
127
|
+
text: `delegate_to_agent: the agent is BUSY with a different task ("${entry.task.slice(0, 100)}", running ${runningFor}s). ` +
|
|
128
|
+
`Poll agent_status (compact: task {action:"status"}), abort it first (abort_task / task {action:"abort"}), ` +
|
|
129
|
+
`or re-call with the SAME task text to keep waiting on it.`,
|
|
130
|
+
isError: true,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else if (entry && entry.settled && normTask(entry.task) === normTask(text)) {
|
|
135
|
+
// Finished while the caller was away — hand over the stored result.
|
|
136
|
+
inflightDelegation = null;
|
|
137
|
+
return formatDelegationResult(entry);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
// Start fresh. Guard against a run started through another route
|
|
141
|
+
// (submit_task / scheduler) that this holder doesn't know about.
|
|
142
|
+
const state = ctx.agent.getState?.();
|
|
143
|
+
if (state?.status && state.status !== 'idle') {
|
|
144
|
+
return {
|
|
145
|
+
text: `delegate_to_agent: agent is busy (status=${state.status}) with a task started elsewhere (submit_task/scheduler). Poll agent_status or call abort_task first.`,
|
|
146
|
+
isError: true,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
entry = startDelegation(ctx.agent, text);
|
|
150
|
+
inflightDelegation = entry;
|
|
151
|
+
}
|
|
152
|
+
await Promise.race([entry.promise, sleepMs(boundMs)]);
|
|
153
|
+
if (entry.settled) {
|
|
154
|
+
if (inflightDelegation === entry)
|
|
155
|
+
inflightDelegation = null;
|
|
156
|
+
return formatDelegationResult(entry);
|
|
157
|
+
}
|
|
158
|
+
// Still running — return a receipt instead of blowing the caller's
|
|
159
|
+
// MCP timeout. NOT an error: the task is alive and progressing.
|
|
160
|
+
const st = ctx.agent.getState?.() ?? {};
|
|
161
|
+
return {
|
|
162
|
+
text: JSON.stringify({
|
|
163
|
+
status: 'running',
|
|
164
|
+
task: entry.task,
|
|
165
|
+
elapsed: `${((Date.now() - entry.startedAt) / 1000).toFixed(0)}s`,
|
|
166
|
+
progress: {
|
|
167
|
+
status: st.status,
|
|
168
|
+
currentStep: st.currentStep,
|
|
169
|
+
stepsCompleted: st.stepsCompleted,
|
|
170
|
+
stepsTotal: st.stepsTotal,
|
|
171
|
+
},
|
|
172
|
+
next: 'Task continues in the background. Re-call this tool with the SAME task text to keep waiting (re-attaches — it will NOT restart the task). Or poll agent_status (compact: task {action:"status"}) / abort with abort_task (task {action:"abort"}).',
|
|
173
|
+
}, null, 2),
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: 'open_app',
|
|
179
|
+
description: 'Open an application by name. Uses the cross-OS app alias table + the PlatformAdapter\'s launchApp (UWP-aware on Windows, `open -a` on macOS, gtk-launch / xdg-open on Linux).',
|
|
180
|
+
parameters: {
|
|
181
|
+
name: { type: 'string', description: 'Application name (e.g. "notepad", "calc", "mspaint", "Outlook", "Chrome")', required: true },
|
|
182
|
+
},
|
|
183
|
+
category: 'orchestration',
|
|
184
|
+
compactGroup: 'window',
|
|
185
|
+
safetyTier: 1,
|
|
186
|
+
handler: async ({ name }, ctx) => {
|
|
187
|
+
await ctx.ensureInitialized();
|
|
188
|
+
const rawName = String(name ?? '');
|
|
189
|
+
if (!rawName) {
|
|
190
|
+
return { text: 'open_app: `name` is required', isError: true };
|
|
191
|
+
}
|
|
192
|
+
// Resolve through the canonical alias table so "Notepad" / "notepad" /
|
|
193
|
+
// "Calculator" / "calc" all map to the right launch hints. The MCP
|
|
194
|
+
// open_app used to call `Start-Process <name>` directly, which fails
|
|
195
|
+
// for UWP apps (Calculator, Win11 Notepad) and is case-sensitive on
|
|
196
|
+
// PowerShell's Start-Process arg. The alias table + platform adapter
|
|
197
|
+
// is the same path the autonomous agent-loop uses.
|
|
198
|
+
const alias = (0, aliases_1.resolveAlias)(rawName);
|
|
199
|
+
// If we have a PlatformAdapter (we always do post-v0.9 init), use it.
|
|
200
|
+
// Falls back to the old execFile path only when the adapter isn't
|
|
201
|
+
// available (shouldn't happen in normal operation).
|
|
202
|
+
if (ctx.platform && typeof ctx.platform.launchApp === 'function') {
|
|
203
|
+
let launchName = rawName;
|
|
204
|
+
if (alias) {
|
|
205
|
+
if (process.platform === 'darwin') {
|
|
206
|
+
launchName = alias.macOSAppName ?? rawName;
|
|
207
|
+
}
|
|
208
|
+
else if (process.platform === 'win32') {
|
|
209
|
+
launchName = alias.executable ?? rawName;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
launchName = alias.executable?.replace(/\.exe$/i, '') ?? rawName;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
const res = await ctx.platform.launchApp(launchName, {
|
|
217
|
+
alwaysNewInstance: alias?.alwaysNewInstance,
|
|
218
|
+
uwpAppId: alias?.uwpAppId,
|
|
219
|
+
searchTerm: alias?.searchTerm
|
|
220
|
+
?? (process.platform === 'darwin' ? alias?.macOSAppName : undefined),
|
|
221
|
+
});
|
|
222
|
+
ctx.a11y.invalidateCache();
|
|
223
|
+
return {
|
|
224
|
+
text: res?.title
|
|
225
|
+
? `Opened "${rawName}" (pid=${res.pid}, window="${res.title}")`
|
|
226
|
+
: `Launched "${rawName}" (no window surfaced yet)`,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
return { text: `Failed to launch "${rawName}": ${err?.message ?? err}`, isError: true };
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Fallback: pre-adapter path (kept for safety, should be unreachable).
|
|
234
|
+
try {
|
|
235
|
+
if (process.platform === 'win32') {
|
|
236
|
+
const exe = alias?.executable ?? rawName;
|
|
237
|
+
const uwpId = alias?.uwpAppId;
|
|
238
|
+
if (uwpId) {
|
|
239
|
+
await execFileAsync('explorer.exe', [`shell:AppsFolder\\${uwpId}`], { timeout: 10000 });
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
// Defense-in-depth: `exe` (a caller-supplied app name) is interpolated
|
|
243
|
+
// into a PowerShell -Command string. Inside a double-quoted PS string,
|
|
244
|
+
// `"`, backtick, and `$(...)` can break out and run arbitrary code.
|
|
245
|
+
// Reject those metacharacters — real executable names/paths never
|
|
246
|
+
// contain them (spaces and parens, e.g. "Program Files (x86)", are fine).
|
|
247
|
+
if (/["`$\r\n]/.test(exe)) {
|
|
248
|
+
return { text: `Refusing to launch "${rawName}": unsafe characters in target name`, isError: true };
|
|
249
|
+
}
|
|
250
|
+
await execFileAsync('powershell.exe', ['-NoProfile', '-Command', `Start-Process "${exe}"`], { timeout: 10000 });
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (process.platform === 'darwin') {
|
|
254
|
+
await execFileAsync('open', ['-a', alias?.macOSAppName ?? rawName], { timeout: 10000 });
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
const linuxName = alias?.executable?.replace(/\.exe$/i, '') ?? rawName;
|
|
258
|
+
if (await commandExists('gtk-launch')) {
|
|
259
|
+
await execFileAsync('gtk-launch', [linuxName], { timeout: 10000 });
|
|
260
|
+
}
|
|
261
|
+
else if (await commandExists('xdg-open')) {
|
|
262
|
+
await execFileAsync('xdg-open', [linuxName], { timeout: 10000 });
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
await execFileAsync(linuxName, [], { timeout: 10000 });
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
await new Promise(r => setTimeout(r, 2000));
|
|
269
|
+
ctx.a11y.invalidateCache();
|
|
270
|
+
return { text: `Launched: ${rawName}` };
|
|
271
|
+
}
|
|
272
|
+
catch (err) {
|
|
273
|
+
return { text: `Failed to launch "${rawName}": ${err.message}`, isError: true };
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
name: 'navigate_browser',
|
|
279
|
+
description: `Open a URL in the browser. Launches with CDP enabled (port ${browser_config_1.DEFAULT_CDP_PORT}) for DOM interaction. Call cdp_connect after. Tier 2 (mutation): triggers network egress to an arbitrary destination + spawns/attaches to a browser process.`,
|
|
280
|
+
parameters: {
|
|
281
|
+
url: { type: 'string', description: 'URL to navigate to', required: true },
|
|
282
|
+
},
|
|
283
|
+
category: 'orchestration',
|
|
284
|
+
compactGroup: 'window',
|
|
285
|
+
safetyTier: 2,
|
|
286
|
+
handler: async ({ url }, ctx) => {
|
|
287
|
+
await ctx.ensureInitialized();
|
|
288
|
+
if (await ctx.cdp.isConnected()) {
|
|
289
|
+
try {
|
|
290
|
+
const page = ctx.cdp.getPage();
|
|
291
|
+
if (page) {
|
|
292
|
+
await page.goto(url, { timeout: 30000, waitUntil: 'domcontentloaded' });
|
|
293
|
+
const title = await page.title().catch(() => '(loading)');
|
|
294
|
+
return { text: `Navigated to: "${title}" at ${url}` };
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
catch { /* fall through */ }
|
|
298
|
+
}
|
|
299
|
+
try {
|
|
300
|
+
const userDataDir = path.join(os.tmpdir(), 'clawdcursor-edge');
|
|
301
|
+
if (process.platform === 'win32') {
|
|
302
|
+
// Direct exec instead of `powershell -Command "Start-Process …"`:
|
|
303
|
+
// the previous form interpolated `url` into a PowerShell string,
|
|
304
|
+
// letting a crafted URL (`")` / `$()` / backtick) escape the
|
|
305
|
+
// quoting and run arbitrary code. execFile with argv is safe.
|
|
306
|
+
// Edge installs in well-known locations; fall back to the one
|
|
307
|
+
// that exists. `where.exe msedge` would also work but adds an
|
|
308
|
+
// extra spawn for the common case.
|
|
309
|
+
const edgeCandidates = [
|
|
310
|
+
path.join(process.env['ProgramFiles(x86)'] || 'C:\\Program Files (x86)', 'Microsoft', 'Edge', 'Application', 'msedge.exe'),
|
|
311
|
+
path.join(process.env['ProgramFiles'] || 'C:\\Program Files', 'Microsoft', 'Edge', 'Application', 'msedge.exe'),
|
|
312
|
+
];
|
|
313
|
+
const edgeExe = edgeCandidates.find(p => { try {
|
|
314
|
+
return fs.existsSync(p);
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
return false;
|
|
318
|
+
} });
|
|
319
|
+
if (!edgeExe) {
|
|
320
|
+
throw new Error('msedge.exe not found in standard install locations');
|
|
321
|
+
}
|
|
322
|
+
await execFileAsync(edgeExe, [
|
|
323
|
+
`--remote-debugging-port=${browser_config_1.DEFAULT_CDP_PORT}`,
|
|
324
|
+
`--user-data-dir=${userDataDir}`,
|
|
325
|
+
'--no-first-run',
|
|
326
|
+
'--disable-default-apps',
|
|
327
|
+
url,
|
|
328
|
+
], { timeout: 10000 });
|
|
329
|
+
}
|
|
330
|
+
else if (process.platform === 'darwin') {
|
|
331
|
+
await execFileAsync('open', ['-a', 'Google Chrome', '--args',
|
|
332
|
+
`--remote-debugging-port=${browser_config_1.DEFAULT_CDP_PORT}`, `--user-data-dir=${userDataDir}`, '--no-first-run', url
|
|
333
|
+
], { timeout: 10000 });
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
// Linux: try common browser binaries in order.
|
|
337
|
+
const browserCandidates = ['google-chrome', 'google-chrome-stable', 'chromium', 'chromium-browser', 'microsoft-edge'];
|
|
338
|
+
let launched = false;
|
|
339
|
+
for (const browserCmd of browserCandidates) {
|
|
340
|
+
if (!(await commandExists(browserCmd)))
|
|
341
|
+
continue;
|
|
342
|
+
await execFileAsync(browserCmd, [
|
|
343
|
+
`--remote-debugging-port=${browser_config_1.DEFAULT_CDP_PORT}`, `--user-data-dir=${userDataDir}`, '--no-first-run', url,
|
|
344
|
+
], { timeout: 10000 });
|
|
345
|
+
launched = true;
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
if (!launched) {
|
|
349
|
+
throw new Error('No supported browser binary found (tried: google-chrome, chromium, microsoft-edge)');
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
353
|
+
ctx.a11y.invalidateCache();
|
|
354
|
+
return { text: `Opened: ${url} (CDP port ${browser_config_1.DEFAULT_CDP_PORT} enabled)` };
|
|
355
|
+
}
|
|
356
|
+
catch (err) {
|
|
357
|
+
return { text: `Navigation failed: ${err.message}`, isError: true };
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
name: 'wait',
|
|
363
|
+
description: 'Wait for a specified duration. Useful after animations or page loads.',
|
|
364
|
+
parameters: {
|
|
365
|
+
seconds: { type: 'number', description: 'Duration to wait (0.1 to 30)', required: true, minimum: 0.1, maximum: 30 },
|
|
366
|
+
},
|
|
367
|
+
category: 'orchestration',
|
|
368
|
+
compactGroup: 'computer',
|
|
369
|
+
safetyTier: 0,
|
|
370
|
+
handler: async ({ seconds }) => {
|
|
371
|
+
await new Promise(r => setTimeout(r, seconds * 1000));
|
|
372
|
+
return { text: `Waited ${seconds}s` };
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
];
|
|
376
|
+
}
|
|
377
|
+
//# sourceMappingURL=orchestration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestration.js","sourceRoot":"","sources":["../../src/tools/orchestration.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CH,8EAEC;AAsCD,sDAqRC;AAzWD,iDAAyC;AACzC,+BAAiC;AACjC,2CAA6B;AAC7B,uCAAyB;AACzB,uCAAyB;AAEzB,0DAAyD;AACzD,oDAAsD;AAEtD,MAAM,aAAa,GAAG,IAAA,gBAAS,EAAC,wBAAQ,CAAC,CAAC;AAE1C,KAAK,UAAU,aAAa,CAAC,GAAW;IACtC,IAAI,CAAC;QACH,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAuBD,IAAI,kBAAkB,GAA8B,IAAI,CAAC;AAEzD,4DAA4D;AAC5D,SAAgB,iCAAiC;IAC/C,kBAAkB,GAAG,IAAI,CAAC;AAC5B,CAAC;AAED,MAAM,oBAAoB,GAAG,MAAM,CAAC,CAAC,uCAAuC;AAC5E,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEhC,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO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CAAC,CAAC;oBAC5C,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;oBAC3B,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,cAAc,iCAAgB,WAAW,EAAE,CAAC;gBAC3E,CAAC;gBAAC,OAAO,GAAQ,EAAE,CAAC;oBAClB,OAAO,EAAE,IAAI,EAAE,sBAAsB,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBACtE,CAAC;YACH,CAAC;SACF;QAED;YACE,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,uEAAuE;YACpF,UAAU,EAAE;gBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8BAA8B,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;aACpH;YACD,QAAQ,EAAE,eAAe;YACzB,YAAY,EAAE,UAAU;YACxB,UAAU,EAAE,CAAC;YACb,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;gBAC7B,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;gBACtD,OAAO,EAAE,IAAI,EAAE,UAAU,OAAO,GAAG,EAAE,CAAC;YACxC,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic field extraction for compose-send tasks.
|
|
3
|
+
*
|
|
4
|
+
* Pulls recipient / subject / body out of natural-language task text
|
|
5
|
+
* like: "send an email to bob@example.com with the subject 'Hi'
|
|
6
|
+
* introducing yourself". Pure (no LLM). Returns whatever it can find;
|
|
7
|
+
* callers decide whether to proceed with missing fields.
|
|
8
|
+
*
|
|
9
|
+
* The match patterns are intentionally conservative: false negatives
|
|
10
|
+
* are fine (caller falls through to the agent ladder), false positives
|
|
11
|
+
* would mean sending mail to the wrong address, which is worse.
|
|
12
|
+
*/
|
|
13
|
+
export interface ComposeFields {
|
|
14
|
+
recipient: string;
|
|
15
|
+
subject: string;
|
|
16
|
+
body: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Extract compose fields from a task string. Always returns an object;
|
|
20
|
+
* any unrecognized field comes back as the empty string.
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractComposeFields(task: string): ComposeFields;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Deterministic field extraction for compose-send tasks.
|
|
4
|
+
*
|
|
5
|
+
* Pulls recipient / subject / body out of natural-language task text
|
|
6
|
+
* like: "send an email to bob@example.com with the subject 'Hi'
|
|
7
|
+
* introducing yourself". Pure (no LLM). Returns whatever it can find;
|
|
8
|
+
* callers decide whether to proceed with missing fields.
|
|
9
|
+
*
|
|
10
|
+
* The match patterns are intentionally conservative: false negatives
|
|
11
|
+
* are fine (caller falls through to the agent ladder), false positives
|
|
12
|
+
* would mean sending mail to the wrong address, which is worse.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.extractComposeFields = extractComposeFields;
|
|
16
|
+
/**
|
|
17
|
+
* Extract compose fields from a task string. Always returns an object;
|
|
18
|
+
* any unrecognized field comes back as the empty string.
|
|
19
|
+
*/
|
|
20
|
+
function extractComposeFields(task) {
|
|
21
|
+
return {
|
|
22
|
+
recipient: extractRecipient(task),
|
|
23
|
+
subject: extractSubject(task),
|
|
24
|
+
body: extractBody(task),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* First well-formed email address in the task. Strict-enough RFC 5322
|
|
29
|
+
* shape (we won't accept "foo @ bar"). If none, return empty string \u2014
|
|
30
|
+
* the caller will refuse to dispatch.
|
|
31
|
+
*/
|
|
32
|
+
function extractRecipient(task) {
|
|
33
|
+
const m = task.match(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/);
|
|
34
|
+
return m ? m[0] : '';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Quoted subject wins. Otherwise look for "with (the )?subject X" or
|
|
38
|
+
* "subject: X" or "subject \"X\"". Stops at the next clause keyword
|
|
39
|
+
* (introducing/saying/about/that/and the body...) so we don't grab the
|
|
40
|
+
* whole rest of the task as the subject.
|
|
41
|
+
*/
|
|
42
|
+
function extractSubject(task) {
|
|
43
|
+
// 1) Quoted: subject 'Hi', subject "Hi", subject \u201cHi\u201d.
|
|
44
|
+
const quoted = task.match(/subject\s*[:=]?\s*(?:["'\u201c\u2018])([^"'\u201d\u2019\n]{1,200})(?:["'\u201d\u2019])/i);
|
|
45
|
+
if (quoted)
|
|
46
|
+
return quoted[1].trim();
|
|
47
|
+
// 2) Unquoted "subject ... " up to a stop word.
|
|
48
|
+
const stopWords = /(?=\s+(?:introducing|saying|about|that|and|with body|with the body|body[:\s]|telling|asking|explaining|describing|requesting|inviting))/i;
|
|
49
|
+
const unquoted = task.match(/subject\s*[:=]?\s+([^\n]+)/i);
|
|
50
|
+
if (unquoted) {
|
|
51
|
+
const tail = unquoted[1];
|
|
52
|
+
const stopMatch = tail.match(stopWords);
|
|
53
|
+
const cut = stopMatch ? tail.slice(0, stopMatch.index).trim() : tail.trim();
|
|
54
|
+
if (cut.length >= 1 && cut.length <= 200)
|
|
55
|
+
return cut.replace(/[.,;]$/, '');
|
|
56
|
+
}
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Body extraction. Patterns we recognize:
|
|
61
|
+
* - "introducing yourself" \u2192 "Hello, I am an AI assistant introducing myself."
|
|
62
|
+
* - "body: <text>" / "body \"<text>\"" \u2192 verbatim
|
|
63
|
+
* - "saying <text>" \u2192 verbatim
|
|
64
|
+
* - "with (the )?message <text>" \u2192 verbatim
|
|
65
|
+
* Anything else: empty (caller can leave the body blank).
|
|
66
|
+
*/
|
|
67
|
+
function extractBody(task) {
|
|
68
|
+
// Quoted body wins.
|
|
69
|
+
const quoted = task.match(/(?:body|message|saying|content)\s*[:=]?\s*(?:["'\u201c\u2018])([^"'\u201d\u2019]{1,2000})(?:["'\u201d\u2019])/i);
|
|
70
|
+
if (quoted)
|
|
71
|
+
return quoted[1].trim();
|
|
72
|
+
// Unquoted "body: X" / "saying X" / "with the message X" \u2014 take the rest.
|
|
73
|
+
const unquoted = task.match(/(?:^|\s)(?:body|saying|message|content)\s*[:=]?\s+([^\n]{1,2000})/i);
|
|
74
|
+
if (unquoted)
|
|
75
|
+
return unquoted[1].trim().replace(/[.,;]$/, '');
|
|
76
|
+
// Semantic shortcuts. "introducing yourself" is the example the user
|
|
77
|
+
// ran into; expand it to a polite one-liner. Keep these intentionally
|
|
78
|
+
// conservative \u2014 if we can't recognize the intent we leave body
|
|
79
|
+
// empty and let the agent type something.
|
|
80
|
+
if (/\bintroduc(?:e|ing)\s+yourself\b/i.test(task)) {
|
|
81
|
+
return 'Hello,\n\nI am an AI assistant reaching out to introduce myself. Please let me know if there is anything I can help with.\n\nBest regards.';
|
|
82
|
+
}
|
|
83
|
+
return '';
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=extract-compose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-compose.js","sourceRoot":"","sources":["../../../src/tools/playbooks/extract-compose.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAYH,oDAMC;AAVD;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,OAAO;QACL,SAAS,EAAE,gBAAgB,CAAC,IAAI,CAAC;QACjC,OAAO,EAAI,cAAc,CAAC,IAAI,CAAC;QAC/B,IAAI,EAAO,WAAW,CAAC,IAAI,CAAC;KAC7B,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,IAAY;IACpC,MAAM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EAA+E;IAC/E,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,oEAAoE,CAAC,CAAC;IAClG,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAE9D,qEAAqE;IACrE,sEAAsE;IACtE,qEAAqE;IACrE,0CAA0C;IAC1C,IAAI,mCAAmC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACnD,OAAO,4IAA4I,CAAC;IACtJ,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find & Replace playbook.
|
|
3
|
+
*
|
|
4
|
+
* Ported from src/deterministic-flows.ts. The choreography:
|
|
5
|
+
* mod+h → type find → Tab → type replace → alt+a (replace all) → Escape.
|
|
6
|
+
*
|
|
7
|
+
* Most text editors (Word, VSCode, Notepad++ on Windows; mac equivalents)
|
|
8
|
+
* expose this same shape. The `mod+h` shortcut is the cross-platform primary.
|
|
9
|
+
*/
|
|
10
|
+
import type { PlaybookArgs, PlaybookResult } from './index';
|
|
11
|
+
export declare function findReplace(args: PlaybookArgs): Promise<PlaybookResult>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Find & Replace playbook.
|
|
4
|
+
*
|
|
5
|
+
* Ported from src/deterministic-flows.ts. The choreography:
|
|
6
|
+
* mod+h → type find → Tab → type replace → alt+a (replace all) → Escape.
|
|
7
|
+
*
|
|
8
|
+
* Most text editors (Word, VSCode, Notepad++ on Windows; mac equivalents)
|
|
9
|
+
* expose this same shape. The `mod+h` shortcut is the cross-platform primary.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.findReplace = findReplace;
|
|
13
|
+
async function findReplace(args) {
|
|
14
|
+
const { adapter, input } = args;
|
|
15
|
+
const findText = input.find ?? input.findText ?? '';
|
|
16
|
+
const replaceText = input.replace ?? input.replaceText ?? '';
|
|
17
|
+
const steps = [];
|
|
18
|
+
if (!findText) {
|
|
19
|
+
return {
|
|
20
|
+
success: false,
|
|
21
|
+
text: 'find-replace: no `find` text provided',
|
|
22
|
+
steps,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// 1) Open the Find & Replace panel.
|
|
26
|
+
await adapter.keyPress('mod+h');
|
|
27
|
+
steps.push({ type: 'key', key: 'mod+h', description: 'open find & replace' });
|
|
28
|
+
await sleep(300);
|
|
29
|
+
// 2) Type the find term (panel focuses its Find field by default).
|
|
30
|
+
await adapter.typeText(findText);
|
|
31
|
+
steps.push({ type: 'type', description: `typed find: ${findText}` });
|
|
32
|
+
// 3) Tab to the Replace field, type replacement.
|
|
33
|
+
await adapter.keyPress('Tab');
|
|
34
|
+
steps.push({ type: 'key', key: 'Tab', description: 'advance to Replace' });
|
|
35
|
+
if (replaceText) {
|
|
36
|
+
await adapter.typeText(replaceText);
|
|
37
|
+
steps.push({ type: 'type', description: `typed replace: ${replaceText}` });
|
|
38
|
+
}
|
|
39
|
+
// 4) Alt+A (Replace All on most editors). Some editors use Enter or a button;
|
|
40
|
+
// the verifier will catch if this missed.
|
|
41
|
+
await adapter.keyPress('alt+a');
|
|
42
|
+
steps.push({ type: 'key', key: 'alt+a', description: 'replace all' });
|
|
43
|
+
await sleep(300);
|
|
44
|
+
// 5) Dismiss the panel.
|
|
45
|
+
await adapter.keyPress('Escape');
|
|
46
|
+
steps.push({ type: 'key', key: 'Escape', description: 'close panel' });
|
|
47
|
+
return {
|
|
48
|
+
success: true,
|
|
49
|
+
text: `find-replace: "${findText}" → "${replaceText}"`,
|
|
50
|
+
steps,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function sleep(ms) {
|
|
54
|
+
return new Promise(r => setTimeout(r, ms));
|
|
55
|
+
}
|
|
56
|
+
//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