@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,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* project-mcp.ts — Project System B (agent-loop) UnifiedTools onto the
|
|
3
|
+
* System A (MCP/REST) ToolDefinition surface.
|
|
4
|
+
*
|
|
5
|
+
* PURELY ADDITIVE. This module is not yet imported by any production path.
|
|
6
|
+
* Wire-in happens in a later step (Step 3).
|
|
7
|
+
*
|
|
8
|
+
* The three public exports:
|
|
9
|
+
*
|
|
10
|
+
* jsonSchemaToParamDefs(inputSchema)
|
|
11
|
+
* Convert a UnifiedTool.inputSchema (raw JSON Schema object) into the
|
|
12
|
+
* Record<string, ParameterDef> shape ToolDefinition expects.
|
|
13
|
+
*
|
|
14
|
+
* toolContextToAgent(ctx)
|
|
15
|
+
* Build a synthetic AgentToolContext from a ToolContext so a projected
|
|
16
|
+
* handler can call the System B execute() function.
|
|
17
|
+
*
|
|
18
|
+
* unifiedToToolResult(r)
|
|
19
|
+
* Map a UnifiedToolResult back to the ToolResult shape the MCP surface
|
|
20
|
+
* expects, including base64-encoding any screenshot.
|
|
21
|
+
*
|
|
22
|
+
* projectToToolDefinition(t)
|
|
23
|
+
* Assemble a complete ToolDefinition from a UnifiedTool + TOOL_META.
|
|
24
|
+
* The handler bridges ToolContext → AgentToolContext → UnifiedToolResult →
|
|
25
|
+
* ToolResult in a single async call.
|
|
26
|
+
*/
|
|
27
|
+
import type { UnifiedTool, UnifiedToolResult, AgentToolContext } from './types';
|
|
28
|
+
import type { ToolDefinition, ToolContext, ToolResult, ParameterDef } from '../../tools/types';
|
|
29
|
+
/**
|
|
30
|
+
* Convert a UnifiedTool JSON-Schema inputSchema into the
|
|
31
|
+
* Record<string, ParameterDef> shape that ToolDefinition.parameters expects.
|
|
32
|
+
*
|
|
33
|
+
* Supported JSON Schema property types: "string" | "number" | "boolean" | "array".
|
|
34
|
+
* Properties missing a supported type default to "string" with a note.
|
|
35
|
+
* The `required` array in the schema is used to set ParameterDef.required.
|
|
36
|
+
* `enum` is preserved when all values are strings.
|
|
37
|
+
*
|
|
38
|
+
* Description resolution order (per parameter):
|
|
39
|
+
* 1. System B inputSchema property's own description (if non-empty).
|
|
40
|
+
* 2. `paramDescriptions[key]` harvested from the corresponding System A
|
|
41
|
+
* ToolDefinition (passed as the optional second argument).
|
|
42
|
+
* 3. Empty string fallback.
|
|
43
|
+
*
|
|
44
|
+
* @param inputSchema - The raw JSON Schema object from UnifiedTool.inputSchema.
|
|
45
|
+
* @param paramDescriptions - Optional per-parameter fallback descriptions
|
|
46
|
+
* harvested from the System A ToolDefinition (TOOL_META[name].paramDescriptions).
|
|
47
|
+
* @returns A Record mapping parameter names to ParameterDef instances.
|
|
48
|
+
*/
|
|
49
|
+
export declare function jsonSchemaToParamDefs(inputSchema: UnifiedTool['inputSchema'], paramDescriptions?: Record<string, string>): Record<string, ParameterDef>;
|
|
50
|
+
/**
|
|
51
|
+
* Build a synthetic AgentToolContext from a ToolContext.
|
|
52
|
+
*
|
|
53
|
+
* Called once per projected handler invocation. Awaits
|
|
54
|
+
* ctx.ensureInitialized() first to guarantee subsystems are ready
|
|
55
|
+
* before the System B tool execute() accesses ctx.platform.*.
|
|
56
|
+
*
|
|
57
|
+
* Fields that are absent from ToolContext (task, mode, screenshotsCaptured)
|
|
58
|
+
* are given safe neutral defaults so the System B tools don't crash.
|
|
59
|
+
*
|
|
60
|
+
* @param ctx - The ToolContext injected by the MCP server / REST handler.
|
|
61
|
+
* @returns A fully populated AgentToolContext ready for System B tool execute().
|
|
62
|
+
*/
|
|
63
|
+
export declare function toolContextToAgent(ctx: ToolContext): Promise<AgentToolContext>;
|
|
64
|
+
/**
|
|
65
|
+
* Convert a UnifiedToolResult to the ToolResult shape the MCP surface expects.
|
|
66
|
+
*
|
|
67
|
+
* - success=false maps to isError=true.
|
|
68
|
+
* - screenshot (ScreenshotResult with a Buffer) is base64-encoded and returned
|
|
69
|
+
* as { data, mimeType } in the image field — mirroring how the agent loop
|
|
70
|
+
* and the existing MCP server serialize images.
|
|
71
|
+
* - All other UnifiedToolResult fields (stop, terminalExit, targetLabel) are
|
|
72
|
+
* consumed internally and not forwarded — they are agent-loop concerns.
|
|
73
|
+
*
|
|
74
|
+
* @param r - The UnifiedToolResult from a System B tool execute() call.
|
|
75
|
+
* @returns A ToolResult ready for the MCP / REST transport.
|
|
76
|
+
*/
|
|
77
|
+
export declare function unifiedToToolResult(r: UnifiedToolResult): ToolResult;
|
|
78
|
+
/**
|
|
79
|
+
* Project a System B UnifiedTool into a System A ToolDefinition.
|
|
80
|
+
*
|
|
81
|
+
* Assembles:
|
|
82
|
+
* - name: TOOL_META[t.name].mcpName ?? t.name
|
|
83
|
+
* - description: t.description (System B already has good descriptions)
|
|
84
|
+
* - parameters: via jsonSchemaToParamDefs(t.inputSchema)
|
|
85
|
+
* - category, compactGroup, safetyTier, costClass, cheaperAlternatives: from TOOL_META
|
|
86
|
+
* - handler: bridges ToolContext → AgentToolContext → t.execute() → ToolResult
|
|
87
|
+
*
|
|
88
|
+
* Terminal actions (done, give_up, cannot_read) and vision compound tools
|
|
89
|
+
* (mouse, keyboard, window) should NOT be passed to this function — they have
|
|
90
|
+
* no counterpart on the MCP surface or have their own projection path.
|
|
91
|
+
*
|
|
92
|
+
* Throws if t.name has no TOOL_META entry (enforced by the coverage test).
|
|
93
|
+
*
|
|
94
|
+
* @param t - A UnifiedTool from buildUnifiedTools().
|
|
95
|
+
* @returns A fully populated ToolDefinition ready for getTools() or direct MCP use.
|
|
96
|
+
*/
|
|
97
|
+
export declare function projectToToolDefinition(t: UnifiedTool): ToolDefinition;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* project-mcp.ts — Project System B (agent-loop) UnifiedTools onto the
|
|
4
|
+
* System A (MCP/REST) ToolDefinition surface.
|
|
5
|
+
*
|
|
6
|
+
* PURELY ADDITIVE. This module is not yet imported by any production path.
|
|
7
|
+
* Wire-in happens in a later step (Step 3).
|
|
8
|
+
*
|
|
9
|
+
* The three public exports:
|
|
10
|
+
*
|
|
11
|
+
* jsonSchemaToParamDefs(inputSchema)
|
|
12
|
+
* Convert a UnifiedTool.inputSchema (raw JSON Schema object) into the
|
|
13
|
+
* Record<string, ParameterDef> shape ToolDefinition expects.
|
|
14
|
+
*
|
|
15
|
+
* toolContextToAgent(ctx)
|
|
16
|
+
* Build a synthetic AgentToolContext from a ToolContext so a projected
|
|
17
|
+
* handler can call the System B execute() function.
|
|
18
|
+
*
|
|
19
|
+
* unifiedToToolResult(r)
|
|
20
|
+
* Map a UnifiedToolResult back to the ToolResult shape the MCP surface
|
|
21
|
+
* expects, including base64-encoding any screenshot.
|
|
22
|
+
*
|
|
23
|
+
* projectToToolDefinition(t)
|
|
24
|
+
* Assemble a complete ToolDefinition from a UnifiedTool + TOOL_META.
|
|
25
|
+
* The handler bridges ToolContext → AgentToolContext → UnifiedToolResult →
|
|
26
|
+
* ToolResult in a single async call.
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.jsonSchemaToParamDefs = jsonSchemaToParamDefs;
|
|
30
|
+
exports.toolContextToAgent = toolContextToAgent;
|
|
31
|
+
exports.unifiedToToolResult = unifiedToToolResult;
|
|
32
|
+
exports.projectToToolDefinition = projectToToolDefinition;
|
|
33
|
+
const tool_meta_1 = require("./tool-meta");
|
|
34
|
+
const reactive_check_1 = require("../sense/reactive-check");
|
|
35
|
+
const ocr_engine_1 = require("../../platform/ocr-engine");
|
|
36
|
+
// Lazy OCR singleton for ocr_contains assertions in MCP-route expect checks.
|
|
37
|
+
let _mcpOcr = null;
|
|
38
|
+
function mcpOcr() { return (_mcpOcr ??= new ocr_engine_1.OcrEngine()); }
|
|
39
|
+
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
40
|
+
/**
|
|
41
|
+
* Convert a UnifiedTool JSON-Schema inputSchema into the
|
|
42
|
+
* Record<string, ParameterDef> shape that ToolDefinition.parameters expects.
|
|
43
|
+
*
|
|
44
|
+
* Supported JSON Schema property types: "string" | "number" | "boolean" | "array".
|
|
45
|
+
* Properties missing a supported type default to "string" with a note.
|
|
46
|
+
* The `required` array in the schema is used to set ParameterDef.required.
|
|
47
|
+
* `enum` is preserved when all values are strings.
|
|
48
|
+
*
|
|
49
|
+
* Description resolution order (per parameter):
|
|
50
|
+
* 1. System B inputSchema property's own description (if non-empty).
|
|
51
|
+
* 2. `paramDescriptions[key]` harvested from the corresponding System A
|
|
52
|
+
* ToolDefinition (passed as the optional second argument).
|
|
53
|
+
* 3. Empty string fallback.
|
|
54
|
+
*
|
|
55
|
+
* @param inputSchema - The raw JSON Schema object from UnifiedTool.inputSchema.
|
|
56
|
+
* @param paramDescriptions - Optional per-parameter fallback descriptions
|
|
57
|
+
* harvested from the System A ToolDefinition (TOOL_META[name].paramDescriptions).
|
|
58
|
+
* @returns A Record mapping parameter names to ParameterDef instances.
|
|
59
|
+
*/
|
|
60
|
+
function jsonSchemaToParamDefs(inputSchema, paramDescriptions) {
|
|
61
|
+
const result = {};
|
|
62
|
+
const props = inputSchema.properties ?? {};
|
|
63
|
+
const required = new Set(inputSchema.required ?? []);
|
|
64
|
+
for (const [key, raw] of Object.entries(props)) {
|
|
65
|
+
const prop = raw;
|
|
66
|
+
const rawType = typeof prop.type === 'string' ? prop.type : 'string';
|
|
67
|
+
// Narrow to ParameterDef's allowed types; fall back to 'string'.
|
|
68
|
+
const type = rawType === 'number' || rawType === 'boolean' || rawType === 'array' ? rawType : 'string';
|
|
69
|
+
// Prefer System B's own description; fall back to harvested System A description.
|
|
70
|
+
const ownDescription = typeof prop.description === 'string' ? prop.description : '';
|
|
71
|
+
const description = ownDescription || paramDescriptions?.[key] || '';
|
|
72
|
+
const def = {
|
|
73
|
+
type,
|
|
74
|
+
description,
|
|
75
|
+
required: required.has(key),
|
|
76
|
+
};
|
|
77
|
+
// Preserve the element schema for array params (ParameterDef.items),
|
|
78
|
+
// e.g. verify's `assertions: {type:'array', items:{type:'object'}}`.
|
|
79
|
+
if (type === 'array' && prop.items && typeof prop.items === 'object') {
|
|
80
|
+
def.items = prop.items;
|
|
81
|
+
}
|
|
82
|
+
// Preserve enum when all values are strings (ParameterDef only supports string enum).
|
|
83
|
+
if (Array.isArray(prop.enum)) {
|
|
84
|
+
const strEnum = prop.enum.filter(v => typeof v === 'string');
|
|
85
|
+
if (strEnum.length > 0)
|
|
86
|
+
def.enum = strEnum;
|
|
87
|
+
}
|
|
88
|
+
// Preserve numeric constraints.
|
|
89
|
+
if (typeof prop.minimum === 'number')
|
|
90
|
+
def.minimum = prop.minimum;
|
|
91
|
+
if (typeof prop.maximum === 'number')
|
|
92
|
+
def.maximum = prop.maximum;
|
|
93
|
+
result[key] = def;
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Build a synthetic AgentToolContext from a ToolContext.
|
|
99
|
+
*
|
|
100
|
+
* Called once per projected handler invocation. Awaits
|
|
101
|
+
* ctx.ensureInitialized() first to guarantee subsystems are ready
|
|
102
|
+
* before the System B tool execute() accesses ctx.platform.*.
|
|
103
|
+
*
|
|
104
|
+
* Fields that are absent from ToolContext (task, mode, screenshotsCaptured)
|
|
105
|
+
* are given safe neutral defaults so the System B tools don't crash.
|
|
106
|
+
*
|
|
107
|
+
* @param ctx - The ToolContext injected by the MCP server / REST handler.
|
|
108
|
+
* @returns A fully populated AgentToolContext ready for System B tool execute().
|
|
109
|
+
*/
|
|
110
|
+
async function toolContextToAgent(ctx) {
|
|
111
|
+
// Guarantee all subsystems are initialized (lazy init gate).
|
|
112
|
+
await ctx.ensureInitialized();
|
|
113
|
+
// Derive the platform adapter. The `platform` field was added in Tranche 1A
|
|
114
|
+
// and is present on every modern ToolContext. Guard defensively for tests.
|
|
115
|
+
const platform = ctx.platform;
|
|
116
|
+
if (!platform) {
|
|
117
|
+
throw new Error('toolContextToAgent: ctx.platform is not initialized. ' +
|
|
118
|
+
'Ensure clawdcursor is running with a supported OS adapter.');
|
|
119
|
+
}
|
|
120
|
+
// Derive screen dimensions. System B tools use ctx.screen for coordinate math.
|
|
121
|
+
// ToolContext exposes getScreenSize() on ctx.desktop (NativeDesktop).
|
|
122
|
+
let screen;
|
|
123
|
+
try {
|
|
124
|
+
const size = ctx.desktop.getScreenSize();
|
|
125
|
+
const msf = ctx.getMouseScaleFactor(); // image → logical (mouse) scale
|
|
126
|
+
const ssf = ctx.getScreenshotScaleFactor(); // image → physical pixel scale
|
|
127
|
+
// msf ≈ physicalWidth / imageWidth (typically 1 on standard, 2 on HiDPI).
|
|
128
|
+
// We reconstruct logical and physical from physical size + ratio.
|
|
129
|
+
const physicalWidth = size.width;
|
|
130
|
+
const physicalHeight = size.height;
|
|
131
|
+
// Logical = physical / DPI ratio. DPI ratio = physical / logical = ssf / msf.
|
|
132
|
+
// For the typical case both scale factors are 1, leaving logical == physical.
|
|
133
|
+
const dpiRatio = ssf > 0 ? ssf / msf : 1;
|
|
134
|
+
const logicalWidth = dpiRatio > 0 ? Math.round(physicalWidth / dpiRatio) : physicalWidth;
|
|
135
|
+
const logicalHeight = dpiRatio > 0 ? Math.round(physicalHeight / dpiRatio) : physicalHeight;
|
|
136
|
+
screen = { logicalWidth, logicalHeight, physicalWidth, physicalHeight, dpiRatio };
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// Fallback to a sane default if getScreenSize throws (e.g. in tests).
|
|
140
|
+
screen = { logicalWidth: 1920, logicalHeight: 1080, physicalWidth: 1920, physicalHeight: 1080, dpiRatio: 1 };
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
platform,
|
|
144
|
+
task: '', // No task context available in the MCP surface layer.
|
|
145
|
+
screen,
|
|
146
|
+
screenshotsCaptured: { n: 0 },
|
|
147
|
+
cdp: ctx.cdp ?? null,
|
|
148
|
+
targetWindow: undefined,
|
|
149
|
+
activeApp: undefined,
|
|
150
|
+
uiMaps: ctx.uiMaps,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Convert a UnifiedToolResult to the ToolResult shape the MCP surface expects.
|
|
155
|
+
*
|
|
156
|
+
* - success=false maps to isError=true.
|
|
157
|
+
* - screenshot (ScreenshotResult with a Buffer) is base64-encoded and returned
|
|
158
|
+
* as { data, mimeType } in the image field — mirroring how the agent loop
|
|
159
|
+
* and the existing MCP server serialize images.
|
|
160
|
+
* - All other UnifiedToolResult fields (stop, terminalExit, targetLabel) are
|
|
161
|
+
* consumed internally and not forwarded — they are agent-loop concerns.
|
|
162
|
+
*
|
|
163
|
+
* @param r - The UnifiedToolResult from a System B tool execute() call.
|
|
164
|
+
* @returns A ToolResult ready for the MCP / REST transport.
|
|
165
|
+
*/
|
|
166
|
+
function unifiedToToolResult(r) {
|
|
167
|
+
const result = {
|
|
168
|
+
text: r.text,
|
|
169
|
+
isError: !r.success,
|
|
170
|
+
};
|
|
171
|
+
if (r.screenshot) {
|
|
172
|
+
// ScreenshotResult.buffer is a Buffer containing raw image bytes (PNG per
|
|
173
|
+
// the platform/types.ts interface; the agent loop captures via screenshot()
|
|
174
|
+
// which returns PNG). The MCP image field expects base64-encoded string data.
|
|
175
|
+
result.image = {
|
|
176
|
+
data: r.screenshot.buffer.toString('base64'),
|
|
177
|
+
mimeType: 'image/png',
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Project a System B UnifiedTool into a System A ToolDefinition.
|
|
184
|
+
*
|
|
185
|
+
* Assembles:
|
|
186
|
+
* - name: TOOL_META[t.name].mcpName ?? t.name
|
|
187
|
+
* - description: t.description (System B already has good descriptions)
|
|
188
|
+
* - parameters: via jsonSchemaToParamDefs(t.inputSchema)
|
|
189
|
+
* - category, compactGroup, safetyTier, costClass, cheaperAlternatives: from TOOL_META
|
|
190
|
+
* - handler: bridges ToolContext → AgentToolContext → t.execute() → ToolResult
|
|
191
|
+
*
|
|
192
|
+
* Terminal actions (done, give_up, cannot_read) and vision compound tools
|
|
193
|
+
* (mouse, keyboard, window) should NOT be passed to this function — they have
|
|
194
|
+
* no counterpart on the MCP surface or have their own projection path.
|
|
195
|
+
*
|
|
196
|
+
* Throws if t.name has no TOOL_META entry (enforced by the coverage test).
|
|
197
|
+
*
|
|
198
|
+
* @param t - A UnifiedTool from buildUnifiedTools().
|
|
199
|
+
* @returns A fully populated ToolDefinition ready for getTools() or direct MCP use.
|
|
200
|
+
*/
|
|
201
|
+
function projectToToolDefinition(t) {
|
|
202
|
+
const meta = tool_meta_1.TOOL_META[t.name];
|
|
203
|
+
if (!meta) {
|
|
204
|
+
throw new Error(`projectToToolDefinition: no TOOL_META entry for System B tool "${t.name}". ` +
|
|
205
|
+
'Add an entry to src/core/agent-loop/tool-meta.ts.');
|
|
206
|
+
}
|
|
207
|
+
const name = meta.mcpName ?? t.name;
|
|
208
|
+
const parameters = jsonSchemaToParamDefs(t.inputSchema, meta.paramDescriptions);
|
|
209
|
+
const handler = async (params, ctx) => {
|
|
210
|
+
const agentCtx = await toolContextToAgent(ctx);
|
|
211
|
+
let result = await t.execute(params, agentCtx);
|
|
212
|
+
const executed = result.success;
|
|
213
|
+
// Honor a caller-supplied `expect` assertion array. The projected schemas
|
|
214
|
+
// advertise it (same as the agent loop), so an external agent passing
|
|
215
|
+
// post-conditions over MCP must get them VERIFIED — they were silently
|
|
216
|
+
// dropped before (audit 2026-06-10, finding E). Hard check only: the
|
|
217
|
+
// loop-side soft "no observable change" net needs per-turn fingerprints
|
|
218
|
+
// the MCP route doesn't track.
|
|
219
|
+
if (params.expect !== undefined && params.expect !== null) {
|
|
220
|
+
const reactive = await (0, reactive_check_1.reactiveCheck)({
|
|
221
|
+
expect: params.expect,
|
|
222
|
+
toolText: result.text,
|
|
223
|
+
toolSuccess: result.success,
|
|
224
|
+
changesScreen: false,
|
|
225
|
+
observedChange: true,
|
|
226
|
+
adapter: agentCtx.platform,
|
|
227
|
+
ocrText: async () => (await mcpOcr().recognizeScreen()).fullText ?? '',
|
|
228
|
+
}).catch(() => null);
|
|
229
|
+
if (reactive)
|
|
230
|
+
result = { ...result, success: reactive.success, text: reactive.text };
|
|
231
|
+
}
|
|
232
|
+
// Invalidate the shared UIMap holder only when the screen-changing action
|
|
233
|
+
// actually TOOK (pre-expect outcome — a DEVIATION still means the input
|
|
234
|
+
// was dispatched). A rejected el_NN ref / failed dispatch changed nothing
|
|
235
|
+
// and must not stale a still-valid map (parity with the agent loop's
|
|
236
|
+
// outcome-gated invalidation; audit finding E/A1).
|
|
237
|
+
if (t.changesScreen && executed)
|
|
238
|
+
ctx.uiMaps?.invalidate();
|
|
239
|
+
return unifiedToToolResult(result);
|
|
240
|
+
};
|
|
241
|
+
return {
|
|
242
|
+
name,
|
|
243
|
+
description: t.description,
|
|
244
|
+
parameters,
|
|
245
|
+
category: meta.category,
|
|
246
|
+
compactGroup: meta.compactGroup,
|
|
247
|
+
safetyTier: meta.safetyTier,
|
|
248
|
+
costClass: meta.costClass,
|
|
249
|
+
cheaperAlternatives: meta.cheaperAlternatives,
|
|
250
|
+
handler,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=project-mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-mcp.js","sourceRoot":"","sources":["../../../src/core/agent-loop/project-mcp.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;AAkCH,sDAwCC;AAeD,gDA8CC;AAeD,kDAiBC;AAqBD,0DAyDC;AAjPD,2CAAwC;AACxC,4DAAwD;AACxD,0DAAsD;AAEtD,6EAA6E;AAC7E,IAAI,OAAO,GAAqB,IAAI,CAAC;AACrC,SAAS,MAAM,KAAgB,OAAO,CAAC,OAAO,KAAK,IAAI,s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
|
+
/**
|
|
2
|
+
* Unified-agent system prompt + perception renderer.
|
|
3
|
+
*
|
|
4
|
+
* A single compact prompt (~70 lines) for the thin agent loop: accessibility-
|
|
5
|
+
* first, screenshot only on demand. No per-mode variation, no app-specific
|
|
6
|
+
* rules, no model names — the autonomous pipeline and its blind/hybrid/vision
|
|
7
|
+
* rungs were removed in v1.0.0 (a capable model is its own pipeline).
|
|
8
|
+
*
|
|
9
|
+
* Prompt-injection defense: screen content is wrapped in
|
|
10
|
+
* `<untrusted-screen-content>` delimiters and the prompt explicitly tells
|
|
11
|
+
* the model to treat anything inside as data, never as instructions.
|
|
12
|
+
*/
|
|
13
|
+
import type { AgentStep } from './types';
|
|
14
|
+
import type { Snapshot } from '../sense/types';
|
|
15
|
+
/**
|
|
16
|
+
* Wrap screen content in explicit delimiters to make prompt-injection defense
|
|
17
|
+
* auditable. Callers feed this into the user message, not the system prompt.
|
|
18
|
+
*/
|
|
19
|
+
export declare function wrapUntrustedScreenContent(text: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Build the system prompt. Compact; kept under budget so the token budget
|
|
22
|
+
* goes to snapshots + tool results, not rules.
|
|
23
|
+
*
|
|
24
|
+
* The thin agent loop is accessibility-first: screenshot only on demand.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildSystemPrompt(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Render a Snapshot as compact text for the user message. Ranks by
|
|
29
|
+
* role-priority (rank.ts) so the most actionable elements survive
|
|
30
|
+
* truncation. Respects the secure-field redaction in the Snapshot type.
|
|
31
|
+
*
|
|
32
|
+
* Zero app-specific rules. A new LOB app follows the same a11y contract
|
|
33
|
+
* and renders cleanly.
|
|
34
|
+
*/
|
|
35
|
+
export declare function renderSnapshot(snapshot: Snapshot, opts?: {
|
|
36
|
+
elementCap?: number;
|
|
37
|
+
screenWidth?: number;
|
|
38
|
+
screenHeight?: number;
|
|
39
|
+
focusProcessId?: number;
|
|
40
|
+
}): string;
|
|
41
|
+
/**
|
|
42
|
+
* Build a compact recent-history line block for the user message.
|
|
43
|
+
* Keeps only the last `keep` turns to stay under the token budget.
|
|
44
|
+
*/
|
|
45
|
+
export declare function renderHistory(steps: AgentStep[], keep?: number): string;
|