@minicor/mcp-server 2.0.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -2
- package/dist/__tests__/state.test.d.ts +2 -0
- package/dist/__tests__/state.test.d.ts.map +1 -0
- package/dist/__tests__/state.test.js +90 -0
- package/dist/__tests__/state.test.js.map +1 -0
- package/dist/__tests__/vm-service-client.test.d.ts +2 -0
- package/dist/__tests__/vm-service-client.test.d.ts.map +1 -0
- package/dist/__tests__/vm-service-client.test.js +80 -0
- package/dist/__tests__/vm-service-client.test.js.map +1 -0
- package/dist/agent-service-client.d.ts +34 -0
- package/dist/agent-service-client.d.ts.map +1 -0
- package/dist/agent-service-client.js +64 -0
- package/dist/agent-service-client.js.map +1 -0
- package/dist/helpers.d.ts +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +1 -1
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/lib.d.ts +2 -0
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +8 -0
- package/dist/lib.js.map +1 -1
- package/dist/prompts/build-rpa.d.ts.map +1 -1
- package/dist/prompts/build-rpa.js +39 -5
- package/dist/prompts/build-rpa.js.map +1 -1
- package/dist/state.d.ts +10 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +9 -0
- package/dist/state.js.map +1 -1
- package/dist/tools/{stats.d.ts → agents.d.ts} +1 -1
- package/dist/tools/agents.d.ts.map +1 -0
- package/dist/tools/agents.js +78 -0
- package/dist/tools/agents.js.map +1 -0
- package/dist/tools/issues.d.ts.map +1 -1
- package/dist/tools/issues.js +12 -9
- package/dist/tools/issues.js.map +1 -1
- package/dist/tools/vm.d.ts.map +1 -1
- package/dist/tools/vm.js +81 -12
- package/dist/tools/vm.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/vm-service-client.d.ts +24 -0
- package/dist/vm-service-client.d.ts.map +1 -0
- package/dist/vm-service-client.js +23 -0
- package/dist/vm-service-client.js.map +1 -0
- package/package.json +2 -2
- package/dist/browser-client.d.ts +0 -42
- package/dist/browser-client.d.ts.map +0 -1
- package/dist/browser-client.js +0 -66
- package/dist/browser-client.js.map +0 -1
- package/dist/prompts/build-browser-rpa.d.ts +0 -3
- package/dist/prompts/build-browser-rpa.d.ts.map +0 -1
- package/dist/prompts/build-browser-rpa.js +0 -90
- package/dist/prompts/build-browser-rpa.js.map +0 -1
- package/dist/prompts/build-nerve-rpa.d.ts +0 -3
- package/dist/prompts/build-nerve-rpa.d.ts.map +0 -1
- package/dist/prompts/build-nerve-rpa.js +0 -148
- package/dist/prompts/build-nerve-rpa.js.map +0 -1
- package/dist/services.d.ts +0 -61
- package/dist/services.d.ts.map +0 -1
- package/dist/services.js +0 -249
- package/dist/services.js.map +0 -1
- package/dist/tools/browser.d.ts +0 -3
- package/dist/tools/browser.d.ts.map +0 -1
- package/dist/tools/browser.js +0 -254
- package/dist/tools/browser.js.map +0 -1
- package/dist/tools/cron.d.ts +0 -3
- package/dist/tools/cron.d.ts.map +0 -1
- package/dist/tools/cron.js +0 -168
- package/dist/tools/cron.js.map +0 -1
- package/dist/tools/elasticsearch.d.ts +0 -3
- package/dist/tools/elasticsearch.d.ts.map +0 -1
- package/dist/tools/elasticsearch.js +0 -248
- package/dist/tools/elasticsearch.js.map +0 -1
- package/dist/tools/stats.d.ts.map +0 -1
- package/dist/tools/stats.js +0 -18
- package/dist/tools/stats.js.map +0 -1
package/dist/browser-client.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stateless HTTP client for Browser RPA sessions.
|
|
3
|
-
*
|
|
4
|
-
* Matches the session-based API pattern from Sully QA workspace:
|
|
5
|
-
* POST /sessions → create session
|
|
6
|
-
* POST /sessions/:id/act → send action
|
|
7
|
-
* POST /sessions/:id/extract → extract data
|
|
8
|
-
* GET /sessions/:id/screenshot → screenshot
|
|
9
|
-
* DELETE /sessions/:id → close session
|
|
10
|
-
*/
|
|
11
|
-
function normalizeUrl(base) {
|
|
12
|
-
return base.replace(/\/+$/, "");
|
|
13
|
-
}
|
|
14
|
-
function authHeaders(auth) {
|
|
15
|
-
return {
|
|
16
|
-
"Authorization": `Bearer ${auth.bearerToken}`,
|
|
17
|
-
"Content-Type": "application/json",
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
async function request(url, init) {
|
|
21
|
-
const res = await fetch(url, init);
|
|
22
|
-
if (!res.ok) {
|
|
23
|
-
const body = await res.text().catch(() => "");
|
|
24
|
-
throw new Error(`Browser RPA ${init?.method ?? "GET"} ${url} returned ${res.status}: ${body}`);
|
|
25
|
-
}
|
|
26
|
-
return res.json();
|
|
27
|
-
}
|
|
28
|
-
export async function createSession(baseUrl, auth, opts) {
|
|
29
|
-
const url = `${normalizeUrl(baseUrl)}/sessions`;
|
|
30
|
-
return request(url, {
|
|
31
|
-
method: "POST",
|
|
32
|
-
headers: authHeaders(auth),
|
|
33
|
-
body: JSON.stringify(opts?.slackChannelId ? { slackChannelId: opts.slackChannelId } : {}),
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
export async function act(baseUrl, sessionId, message, auth) {
|
|
37
|
-
const url = `${normalizeUrl(baseUrl)}/sessions/${sessionId}/act`;
|
|
38
|
-
return request(url, {
|
|
39
|
-
method: "POST",
|
|
40
|
-
headers: authHeaders(auth),
|
|
41
|
-
body: JSON.stringify({ message }),
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
export async function extract(baseUrl, sessionId, instructions, auth) {
|
|
45
|
-
const url = `${normalizeUrl(baseUrl)}/sessions/${sessionId}/extract`;
|
|
46
|
-
return request(url, {
|
|
47
|
-
method: "POST",
|
|
48
|
-
headers: authHeaders(auth),
|
|
49
|
-
body: JSON.stringify({ instructions }),
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
export async function screenshot(baseUrl, sessionId, auth) {
|
|
53
|
-
const url = `${normalizeUrl(baseUrl)}/sessions/${sessionId}/screenshot`;
|
|
54
|
-
return request(url, {
|
|
55
|
-
headers: { "Authorization": `Bearer ${auth.bearerToken}` },
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
export async function closeSession(baseUrl, sessionId, auth) {
|
|
59
|
-
const url = `${normalizeUrl(baseUrl)}/sessions/${sessionId}`;
|
|
60
|
-
await request(url, {
|
|
61
|
-
method: "DELETE",
|
|
62
|
-
headers: { "Authorization": `Bearer ${auth.bearerToken}` },
|
|
63
|
-
});
|
|
64
|
-
return { closed: true };
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=browser-client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser-client.js","sourceRoot":"","sources":["../src/browser-client.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-browser-rpa.d.ts","sourceRoot":"","sources":["../../src/prompts/build-browser-rpa.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,QAAQ,QA8F5C"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export function register({ server }) {
|
|
3
|
-
server.prompt("build-browser-rpa-workflow", "Iteratively build a browser-based RPA workflow using the Laminar Browser RPA service. Guides you through creating a browser session, performing actions, extracting data, and saving each step as a Laminar workflow flow.", {
|
|
4
|
-
workspaceId: z.string().describe("Laminar workspace ID"),
|
|
5
|
-
task: z
|
|
6
|
-
.string()
|
|
7
|
-
.describe("Description of what to automate (e.g. 'Log into athenaHealth, navigate to patient chart, extract insurance info')"),
|
|
8
|
-
targetUrl: z
|
|
9
|
-
.string()
|
|
10
|
-
.describe("Starting URL for the web application"),
|
|
11
|
-
workflowId: z
|
|
12
|
-
.string()
|
|
13
|
-
.optional()
|
|
14
|
-
.describe("Existing workflow ID to add steps to (omit to create a new workflow)"),
|
|
15
|
-
}, async ({ workspaceId, task, targetUrl, workflowId }) => ({
|
|
16
|
-
messages: [
|
|
17
|
-
{
|
|
18
|
-
role: "user",
|
|
19
|
-
content: {
|
|
20
|
-
type: "text",
|
|
21
|
-
text: `You are building a browser-based RPA workflow on the Laminar platform. Your goal is to automate web application interactions using the Browser RPA session API.
|
|
22
|
-
|
|
23
|
-
## Task
|
|
24
|
-
${task}
|
|
25
|
-
|
|
26
|
-
## Target URL
|
|
27
|
-
${targetUrl}
|
|
28
|
-
|
|
29
|
-
## Workspace
|
|
30
|
-
ID: ${workspaceId}${workflowId ? `\nExisting workflow ID: ${workflowId} (add steps to this workflow)` : "\nCreate a new workflow for this automation."}
|
|
31
|
-
|
|
32
|
-
## How Browser RPA Works
|
|
33
|
-
|
|
34
|
-
The Browser RPA service provides a session-based API:
|
|
35
|
-
1. **Create Session** — starts a browser instance, returns a sessionId
|
|
36
|
-
2. **Act** — sends natural-language actions (e.g. "click the login button", "type hello@example.com in the email field")
|
|
37
|
-
3. **Extract** — extracts data from the current page via natural-language instructions
|
|
38
|
-
4. **Screenshot** — captures the current browser state
|
|
39
|
-
5. **Close Session** — cleans up
|
|
40
|
-
|
|
41
|
-
## Procedure
|
|
42
|
-
|
|
43
|
-
### 1. Connect to Browser RPA Service
|
|
44
|
-
Call \`browser_connect\` with the service base URL and bearer token. Ask the user if not known.
|
|
45
|
-
|
|
46
|
-
### 2. Create a Browser Session
|
|
47
|
-
Call \`browser_create_session\` to get a sessionId.
|
|
48
|
-
|
|
49
|
-
### 3. Iterative Build Loop — For EACH step:
|
|
50
|
-
|
|
51
|
-
**a. ACT — Perform the browser action**
|
|
52
|
-
- Call \`browser_act\` with a natural-language description of what to do
|
|
53
|
-
- Be specific: "navigate to ${targetUrl}", "click the Submit button", "type 'john@example.com' into the email input field"
|
|
54
|
-
|
|
55
|
-
**b. VERIFY — Confirm the action worked**
|
|
56
|
-
- Call \`browser_screenshot\` to see the current state
|
|
57
|
-
- If the action didn't produce the expected result, retry with a more specific instruction
|
|
58
|
-
|
|
59
|
-
**c. EXTRACT — Get data if needed**
|
|
60
|
-
- Call \`browser_extract\` with instructions like "extract the patient name and date of birth"
|
|
61
|
-
- This returns structured data from the page
|
|
62
|
-
|
|
63
|
-
**d. SAVE — Persist as a workflow step**
|
|
64
|
-
- Call \`create_browser_rpa_flow\` with the action type and payload
|
|
65
|
-
- For the first step, use actionType "create_session"
|
|
66
|
-
- For navigation/interaction steps, use actionType "act"
|
|
67
|
-
- For data extraction steps, use actionType "extract"
|
|
68
|
-
- For cleanup, use actionType "close_session"
|
|
69
|
-
|
|
70
|
-
### 4. End-to-End Validation
|
|
71
|
-
- Run the full workflow via \`execute_workflow\`
|
|
72
|
-
- Verify the final state
|
|
73
|
-
|
|
74
|
-
### 5. Iterate with the User
|
|
75
|
-
- Present the completed workflow
|
|
76
|
-
- Make adjustments as needed
|
|
77
|
-
|
|
78
|
-
## Important Rules
|
|
79
|
-
- **Always verify actions with screenshots** before saving
|
|
80
|
-
- **Use \`create_browser_rpa_flow\`** to save steps — it generates the correct \`lam.httpRequest\` wrapper
|
|
81
|
-
- **Use \`{{config.variables}}\`** for credentials (bearerToken, baseUrl, etc.)
|
|
82
|
-
- **Be specific in actions** — natural language should be unambiguous
|
|
83
|
-
- **Handle 2FA/MFA** — if login requires verification codes, use waitForInput patterns
|
|
84
|
-
- **One action per step** — keep steps focused and debuggable`,
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=build-browser-rpa.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-browser-rpa.js","sourceRoot":"","sources":["../../src/prompts/build-browser-rpa.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,UAAU,QAAQ,CAAC,EAAE,MAAM,EAAY;IAC3C,MAAM,CAAC,MAAM,CACX,4BAA4B,EAC5B,4NAA4N,EAC5N;QACE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QACxD,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,QAAQ,CACP,mHAAmH,CACpH;QACH,SAAS,EAAE,CAAC;aACT,MAAM,EAAE;aACR,QAAQ,CAAC,sCAAsC,CAAC;QACnD,UAAU,EAAE,CAAC;aACV,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,sEAAsE,CAAC;KACpF,EACD,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;QACvD,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAe;gBACrB,OAAO,EAAE;oBACP,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE;;;EAGhB,IAAI;;;EAGJ,SAAS;;;MAGL,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC,2BAA2B,UAAU,+BAA+B,CAAC,CAAC,CAAC,8CAA8C;;;;;;;;;;;;;;;;;;;;;;;8BAuBxH,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8DA+BuB;iBACnD;aACF;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-nerve-rpa.d.ts","sourceRoot":"","sources":["../../src/prompts/build-nerve-rpa.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,QAAQ,QAsJ5C"}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export function register({ server }) {
|
|
3
|
-
server.prompt("build-nerve-rpa-workflow", "Build an RPA workflow using NERVE's atomic operations: annotated screenshots, element clicking/typing, CDP browser control, OCR, and self-healing. Optimized for NERVE (not legacy LDS).", {
|
|
4
|
-
workspaceId: z.string().describe("Laminar workspace ID"),
|
|
5
|
-
task: z.string().describe("What to automate"),
|
|
6
|
-
appName: z.string().describe("Target application name"),
|
|
7
|
-
workflowId: z.string().optional().describe("Existing workflow ID to add steps to"),
|
|
8
|
-
}, async ({ workspaceId, task, appName, workflowId }) => ({
|
|
9
|
-
messages: [
|
|
10
|
-
{
|
|
11
|
-
role: "user",
|
|
12
|
-
content: {
|
|
13
|
-
type: "text",
|
|
14
|
-
text: `You are building an RPA workflow using NERVE on the Laminar platform. NERVE gives you direct atomic control over the Windows desktop — you do NOT need to write Python scripts for simple interactions.
|
|
15
|
-
|
|
16
|
-
## Task
|
|
17
|
-
${task}
|
|
18
|
-
|
|
19
|
-
## Target Application
|
|
20
|
-
${appName}
|
|
21
|
-
|
|
22
|
-
## Workspace
|
|
23
|
-
ID: ${workspaceId}${workflowId ? `\nExisting workflow ID: ${workflowId}` : "\nCreate a new workflow for this automation."}
|
|
24
|
-
|
|
25
|
-
## How NERVE Works
|
|
26
|
-
|
|
27
|
-
NERVE runs on the VM and exposes the full OS via HTTP APIs. When you call \`vm_connect\`, check the \`capabilities\` array in the response to see what's available.
|
|
28
|
-
|
|
29
|
-
Key capabilities:
|
|
30
|
-
- \`annotated_screenshots\` — X-Ray Vision: screenshot with numbered element overlays
|
|
31
|
-
- \`ui_tree_cache\` — Persistent accessibility tree
|
|
32
|
-
- \`atomic_input\` — Click/type/invoke by element ID
|
|
33
|
-
- \`script_execution\` — Run Python scripts
|
|
34
|
-
- \`cdp\` — Chrome DevTools Protocol for browser control
|
|
35
|
-
- \`ocr\` / \`template_matching\` — For Citrix/pixel-based apps
|
|
36
|
-
- \`self_healing\` — Pause on error + intervention
|
|
37
|
-
|
|
38
|
-
## Step 1: Connect and Survey
|
|
39
|
-
|
|
40
|
-
1. \`vm_connect\` — connect to the VM
|
|
41
|
-
2. Check \`capabilities\` in the response
|
|
42
|
-
3. \`vm_annotated_screenshot\` — see the desktop with numbered elements
|
|
43
|
-
4. \`vm_system_info\` — get OS, RAM, CPU info
|
|
44
|
-
5. \`vm_processes\` — see what's running
|
|
45
|
-
|
|
46
|
-
## Step 2: Understand the UI
|
|
47
|
-
|
|
48
|
-
Use the annotated screenshot to understand the screen. Each interactive element has a number:
|
|
49
|
-
\`\`\`
|
|
50
|
-
[1] Username field (Edit)
|
|
51
|
-
[2] Password field (Edit)
|
|
52
|
-
[3] OK button (Button)
|
|
53
|
-
[4] Cancel button (Button)
|
|
54
|
-
\`\`\`
|
|
55
|
-
|
|
56
|
-
For deeper inspection:
|
|
57
|
-
- \`vm_inspect_ui\` mode \`element_tree\` — full accessibility tree
|
|
58
|
-
- \`vm_inspect_ui\` mode \`element_at_point\` — inspect specific coordinates
|
|
59
|
-
|
|
60
|
-
## Step 3: Interact with Atomic Operations
|
|
61
|
-
|
|
62
|
-
**DO NOT write Python scripts for simple click/type operations.** Use atomic tools:
|
|
63
|
-
|
|
64
|
-
- \`vm_click_element\` {element_id: 3} — click element #3 from annotated screenshot
|
|
65
|
-
- \`vm_type_into_element\` {element_id: 1, text: "admin"} — type into element #1
|
|
66
|
-
- \`vm_set_value\` {element_id: 2, value: "password"} — set value directly
|
|
67
|
-
- \`vm_invoke_element\` {element_id: 3} — invoke button via accessibility pattern
|
|
68
|
-
- \`vm_shell\` {command: "Start-Process notepad"} — run commands
|
|
69
|
-
|
|
70
|
-
After each action, take another \`vm_annotated_screenshot\` to verify it worked.
|
|
71
|
-
|
|
72
|
-
## Step 4: For Web Apps — Use CDP
|
|
73
|
-
|
|
74
|
-
If the target is a browser or Electron app:
|
|
75
|
-
|
|
76
|
-
1. \`cdp_connect\` — connect to Chrome/Edge DevTools
|
|
77
|
-
2. \`cdp_dom\` — get the full DOM tree
|
|
78
|
-
3. \`cdp_query\` {selector: "#username"} — find elements by CSS
|
|
79
|
-
4. \`cdp_click\` {selector: "#login-btn"} — click via DOM
|
|
80
|
-
5. \`cdp_type\` {selector: "#email", text: "user@example.com"} — type via DOM
|
|
81
|
-
6. \`cdp_js\` — execute arbitrary JavaScript
|
|
82
|
-
7. \`cdp_network\` — see API calls the app makes
|
|
83
|
-
|
|
84
|
-
CDP is MORE RELIABLE than screen-based automation for web apps.
|
|
85
|
-
|
|
86
|
-
## Step 5: For Citrix / Legacy Apps — Use OCR + Template Matching
|
|
87
|
-
|
|
88
|
-
When there's no accessibility tree (Citrix, RDP, custom-rendered apps):
|
|
89
|
-
|
|
90
|
-
1. \`vm_ocr\` {x, y, width, height} — read text from a screen region
|
|
91
|
-
2. \`vm_template_match\` {template_b64: "..."} — find a visual element
|
|
92
|
-
3. \`vm_wait_for_text\` {text: "Login", region: {...}} — wait for text to appear
|
|
93
|
-
4. \`vm_wait_for_change\` {region: {...}} — wait for visual change (replaces sleep)
|
|
94
|
-
5. \`vm_region_ocr\` {regions: [...]} — batch OCR multiple fields
|
|
95
|
-
6. Click by coordinates from template match results
|
|
96
|
-
|
|
97
|
-
## Step 6: Build Production Scripts
|
|
98
|
-
|
|
99
|
-
Once you understand the UI and have tested atomic operations, consolidate into Python scripts for production:
|
|
100
|
-
|
|
101
|
-
1. Write a Python script that performs the full sequence
|
|
102
|
-
2. Test with \`debug_rpa_step\` — returns before/after screenshots + timeline
|
|
103
|
-
3. Save with \`create_rpa_flow\` — wraps Python in Laminar workflow format
|
|
104
|
-
|
|
105
|
-
## Step 7: Self-Healing Pattern
|
|
106
|
-
|
|
107
|
-
For robust automations, enable self-healing:
|
|
108
|
-
|
|
109
|
-
1. Execute with \`on_error: "pause"\` — script pauses at failure instead of crashing
|
|
110
|
-
2. \`vm_failure_context\` — get screenshot, UI tree, error details at failure point
|
|
111
|
-
3. \`vm_annotated_screenshot\` — see current screen state
|
|
112
|
-
4. Fix with atomic operations (\`vm_click_element\`, etc.)
|
|
113
|
-
5. Resume execution
|
|
114
|
-
|
|
115
|
-
## Step 8: End-to-End Validation
|
|
116
|
-
|
|
117
|
-
1. \`execute_workflow\` to run the full sequence
|
|
118
|
-
2. \`vm_annotated_screenshot\` to verify final state
|
|
119
|
-
3. \`vm_execution_timeline\` to review frame-by-frame what happened
|
|
120
|
-
4. \`diagnose_execution\` if anything fails
|
|
121
|
-
|
|
122
|
-
## Data Extraction Priority
|
|
123
|
-
|
|
124
|
-
When you need to READ data from the screen:
|
|
125
|
-
|
|
126
|
-
1. **Accessibility tree** — \`vm_inspect_ui\` with \`element_tree\` (most reliable)
|
|
127
|
-
2. **Focused element** — Tab through fields, read via \`vm_inspect_ui\` \`focused_element\`
|
|
128
|
-
3. **Clipboard** — Click field, Ctrl+A, Ctrl+C, then \`vm_read_clipboard\`
|
|
129
|
-
4. **OCR** — \`vm_ocr\` on a specific region
|
|
130
|
-
5. **CDP extraction** — \`cdp_js\` to read DOM values (for web apps)
|
|
131
|
-
6. **Region screenshot** — \`vm_screenshot\` of a specific area (last resort)
|
|
132
|
-
|
|
133
|
-
## Key Rules
|
|
134
|
-
|
|
135
|
-
- **Annotated screenshots FIRST** — always start by seeing the screen with element IDs
|
|
136
|
-
- **Atomic ops for exploration** — use click/type tools to test, scripts for production
|
|
137
|
-
- **Verify after every action** — take another annotated screenshot
|
|
138
|
-
- **Never hardcode coordinates** — use element IDs or accessibility patterns
|
|
139
|
-
- **Use wait_for_text/wait_for_change** — never use time.sleep() for synchronization
|
|
140
|
-
- **Use \`create_rpa_flow\`** to save steps — never construct JS wrappers manually
|
|
141
|
-
- **Use \`{{config.variables}}\`** for secrets — never hardcode credentials
|
|
142
|
-
`,
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
}));
|
|
147
|
-
}
|
|
148
|
-
//# sourceMappingURL=build-nerve-rpa.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-nerve-rpa.js","sourceRoot":"","sources":["../../src/prompts/build-nerve-rpa.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,UAAU,QAAQ,CAAC,EAAE,MAAM,EAAY;IAC3C,MAAM,CAAC,MAAM,CACX,0BAA0B,EAC1B,0LAA0L,EAC1L;QACE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QACxD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QAC7C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;QACvD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,sCAAsC,CAAC;KACnF,EACD,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;QACrD,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAe;gBACrB,OAAO,EAAE;oBACP,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE;;;EAGhB,IAAI;;;EAGJ,OAAO;;;MAGH,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC,2BAA2B,UAAU,EAAE,CAAC,CAAC,CAAC,8CAA8C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuHxH;iBACU;aACF;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/dist/services.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Optional service clients: Elasticsearch + CRON.
|
|
3
|
-
* Only instantiated when configured — otherwise tools degrade gracefully.
|
|
4
|
-
*/
|
|
5
|
-
import type { ElasticsearchConfig, CronConfig } from "./config.js";
|
|
6
|
-
export interface ESSearchParams {
|
|
7
|
-
workspaceId: string;
|
|
8
|
-
workflowId?: string;
|
|
9
|
-
workflowIds?: string[];
|
|
10
|
-
query?: string;
|
|
11
|
-
startDate?: string;
|
|
12
|
-
endDate?: string;
|
|
13
|
-
status?: string;
|
|
14
|
-
includeGlobalObject?: boolean;
|
|
15
|
-
rawQuery?: string;
|
|
16
|
-
fuzzy?: boolean;
|
|
17
|
-
size?: number;
|
|
18
|
-
from?: number;
|
|
19
|
-
}
|
|
20
|
-
export declare class ElasticsearchService {
|
|
21
|
-
private endpoint;
|
|
22
|
-
private apiKey;
|
|
23
|
-
private indexName;
|
|
24
|
-
constructor(config: ElasticsearchConfig);
|
|
25
|
-
private esRequest;
|
|
26
|
-
search(params: ESSearchParams): Promise<{
|
|
27
|
-
warning?: string | undefined;
|
|
28
|
-
hits: any;
|
|
29
|
-
total: any;
|
|
30
|
-
took: any;
|
|
31
|
-
}>;
|
|
32
|
-
private formatResults;
|
|
33
|
-
}
|
|
34
|
-
export declare class CronService {
|
|
35
|
-
private apiBase;
|
|
36
|
-
private apiKey;
|
|
37
|
-
constructor(config: CronConfig);
|
|
38
|
-
private request;
|
|
39
|
-
listJobs(workflowId?: string): Promise<any[]>;
|
|
40
|
-
getJob(jobId: string): Promise<any>;
|
|
41
|
-
createJob(job: {
|
|
42
|
-
name: string;
|
|
43
|
-
schedule: string;
|
|
44
|
-
url: string;
|
|
45
|
-
body?: Record<string, any>;
|
|
46
|
-
enabled?: boolean;
|
|
47
|
-
max_runs?: number | null;
|
|
48
|
-
is_temporary?: boolean;
|
|
49
|
-
}): Promise<any>;
|
|
50
|
-
updateJob(jobId: string, updates: {
|
|
51
|
-
name?: string;
|
|
52
|
-
schedule?: string;
|
|
53
|
-
url?: string;
|
|
54
|
-
body?: Record<string, any>;
|
|
55
|
-
enabled?: boolean;
|
|
56
|
-
}): Promise<any>;
|
|
57
|
-
toggleJob(jobId: string): Promise<any>;
|
|
58
|
-
deleteJob(jobId: string): Promise<void>;
|
|
59
|
-
triggerJob(jobId: string): Promise<void>;
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=services.d.ts.map
|
package/dist/services.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../src/services.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOnE,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,mBAAmB;YAMzB,SAAS;IAmBjB,MAAM,CAAC,MAAM,EAAE,cAAc;;;;;;IAmJnC,OAAO,CAAC,aAAa;CAyBtB;AAID,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,UAAU;YAKhB,OAAO;IA+Bf,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM;IAY5B,MAAM,CAAC,KAAK,EAAE,MAAM;IAKpB,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB;IASK,SAAS,CACb,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB;IAUG,SAAS,CAAC,KAAK,EAAE,MAAM;IAKvB,SAAS,CAAC,KAAK,EAAE,MAAM;IAIvB,UAAU,CAAC,KAAK,EAAE,MAAM;CAG/B"}
|
package/dist/services.js
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Optional service clients: Elasticsearch + CRON.
|
|
3
|
-
* Only instantiated when configured — otherwise tools degrade gracefully.
|
|
4
|
-
*/
|
|
5
|
-
const DEFAULT_ES_INDEX = "search-workflow-executions";
|
|
6
|
-
const DEFAULT_CRON_BASE = "https://cron.laminar.run";
|
|
7
|
-
export class ElasticsearchService {
|
|
8
|
-
endpoint;
|
|
9
|
-
apiKey;
|
|
10
|
-
indexName;
|
|
11
|
-
constructor(config) {
|
|
12
|
-
this.endpoint = config.endpoint.replace(/\/$/, "");
|
|
13
|
-
this.apiKey = config.apiKey;
|
|
14
|
-
this.indexName = config.indexName || DEFAULT_ES_INDEX;
|
|
15
|
-
}
|
|
16
|
-
async esRequest(body) {
|
|
17
|
-
const res = await fetch(`${this.endpoint}/${this.indexName}/_search`, {
|
|
18
|
-
method: "POST",
|
|
19
|
-
headers: {
|
|
20
|
-
"Content-Type": "application/json",
|
|
21
|
-
Authorization: `ApiKey ${this.apiKey}`,
|
|
22
|
-
},
|
|
23
|
-
body: JSON.stringify(body),
|
|
24
|
-
});
|
|
25
|
-
if (!res.ok) {
|
|
26
|
-
const err = await res.text().catch(() => "");
|
|
27
|
-
throw new Error(`Elasticsearch (${res.status}): ${err}`);
|
|
28
|
-
}
|
|
29
|
-
return res.json();
|
|
30
|
-
}
|
|
31
|
-
async search(params) {
|
|
32
|
-
const { workspaceId, workflowId, workflowIds, query, startDate, endDate, status, includeGlobalObject = false, rawQuery, fuzzy = false, size = 20, from = 0, } = params;
|
|
33
|
-
let searchBody;
|
|
34
|
-
if (rawQuery) {
|
|
35
|
-
const parsed = JSON.parse(rawQuery);
|
|
36
|
-
if (!parsed.query)
|
|
37
|
-
parsed.query = { bool: { must: [] } };
|
|
38
|
-
if (!parsed.query.bool)
|
|
39
|
-
parsed.query = { bool: { must: [parsed.query] } };
|
|
40
|
-
if (!parsed.query.bool.must)
|
|
41
|
-
parsed.query.bool.must = [];
|
|
42
|
-
if (!JSON.stringify(parsed).includes(`"workspaceId":"${workspaceId}"`)) {
|
|
43
|
-
parsed.query.bool.must.push({ term: { workspaceId } });
|
|
44
|
-
}
|
|
45
|
-
searchBody = { ...parsed, size, from };
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
const esQuery = {
|
|
49
|
-
bool: { must: [{ term: { workspaceId } }], filter: [] },
|
|
50
|
-
};
|
|
51
|
-
if (workflowId) {
|
|
52
|
-
esQuery.bool.must.push({ term: { workflowId } });
|
|
53
|
-
}
|
|
54
|
-
else if (workflowIds?.length) {
|
|
55
|
-
esQuery.bool.must.push({ terms: { workflowId: workflowIds } });
|
|
56
|
-
}
|
|
57
|
-
if (status)
|
|
58
|
-
esQuery.bool.must.push({ term: { status } });
|
|
59
|
-
if (startDate || endDate) {
|
|
60
|
-
const range = {};
|
|
61
|
-
if (startDate)
|
|
62
|
-
range.gte = startDate;
|
|
63
|
-
if (endDate)
|
|
64
|
-
range.lte = endDate;
|
|
65
|
-
esQuery.bool.filter.push({ range: { startedAt: range } });
|
|
66
|
-
}
|
|
67
|
-
if (query?.trim()) {
|
|
68
|
-
const q = query.trim();
|
|
69
|
-
const nested = {
|
|
70
|
-
nested: {
|
|
71
|
-
path: "flows",
|
|
72
|
-
query: {
|
|
73
|
-
multi_match: {
|
|
74
|
-
query: q,
|
|
75
|
-
fields: [
|
|
76
|
-
"flows.log^4",
|
|
77
|
-
"flows.response^3",
|
|
78
|
-
"flows.program^2",
|
|
79
|
-
"flows.transformation^2",
|
|
80
|
-
"flows.flowName^3",
|
|
81
|
-
],
|
|
82
|
-
type: "best_fields",
|
|
83
|
-
operator: fuzzy ? "OR" : "AND",
|
|
84
|
-
...(fuzzy ? { fuzziness: "AUTO" } : {}),
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
inner_hits: {
|
|
88
|
-
size: 10,
|
|
89
|
-
highlight: {
|
|
90
|
-
fields: {
|
|
91
|
-
"flows.log": { fragment_size: 300, number_of_fragments: 3 },
|
|
92
|
-
"flows.response": {
|
|
93
|
-
fragment_size: 200,
|
|
94
|
-
number_of_fragments: 2,
|
|
95
|
-
},
|
|
96
|
-
"flows.program": {
|
|
97
|
-
fragment_size: 150,
|
|
98
|
-
number_of_fragments: 1,
|
|
99
|
-
},
|
|
100
|
-
"flows.transformation": {
|
|
101
|
-
fragment_size: 150,
|
|
102
|
-
number_of_fragments: 1,
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
pre_tags: [">>"],
|
|
106
|
-
post_tags: ["<<"],
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
if (includeGlobalObject) {
|
|
112
|
-
esQuery.bool.must.push({
|
|
113
|
-
bool: {
|
|
114
|
-
should: [
|
|
115
|
-
nested,
|
|
116
|
-
{
|
|
117
|
-
match: {
|
|
118
|
-
globalJson: {
|
|
119
|
-
query: q,
|
|
120
|
-
operator: fuzzy ? "OR" : "AND",
|
|
121
|
-
...(fuzzy ? { fuzziness: "AUTO" } : {}),
|
|
122
|
-
boost: 1,
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
minimum_should_match: 1,
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
esQuery.bool.must.push(nested);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
searchBody = {
|
|
136
|
-
query: esQuery,
|
|
137
|
-
sort: ["_score", { startedAt: { order: "desc" } }],
|
|
138
|
-
size,
|
|
139
|
-
from,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
const data = await this.esRequest(searchBody);
|
|
143
|
-
// Retry without highlighting on shard failures
|
|
144
|
-
if (data._shards?.failed > 0 &&
|
|
145
|
-
!data.hits?.hits?.length &&
|
|
146
|
-
(data.hits?.total?.value || 0) > 0) {
|
|
147
|
-
try {
|
|
148
|
-
const retry = await this.esRequest({
|
|
149
|
-
...searchBody,
|
|
150
|
-
highlight: undefined,
|
|
151
|
-
});
|
|
152
|
-
if (retry.hits?.hits?.length) {
|
|
153
|
-
return this.formatResults(retry, true);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
catch { }
|
|
157
|
-
}
|
|
158
|
-
return this.formatResults(data, false);
|
|
159
|
-
}
|
|
160
|
-
formatResults(data, noHighlight) {
|
|
161
|
-
return {
|
|
162
|
-
hits: (data.hits?.hits || []).map((hit) => ({
|
|
163
|
-
id: hit._id,
|
|
164
|
-
score: hit._score,
|
|
165
|
-
workflowId: hit._source?.workflowId,
|
|
166
|
-
workflowName: hit._source?.workflowName,
|
|
167
|
-
executionId: hit._source?.executionId,
|
|
168
|
-
status: hit._source?.status,
|
|
169
|
-
startedAt: hit._source?.startedAt,
|
|
170
|
-
endedAt: hit._source?.endedAt,
|
|
171
|
-
highlight: hit.highlight || {},
|
|
172
|
-
inner_hits: hit.inner_hits || {},
|
|
173
|
-
})),
|
|
174
|
-
total: data.hits?.total?.value || data.hits?.total || 0,
|
|
175
|
-
took: data.took,
|
|
176
|
-
...(noHighlight && {
|
|
177
|
-
warning: "Results loaded without highlighting due to large fields",
|
|
178
|
-
}),
|
|
179
|
-
...(data._shards?.failed > 0 &&
|
|
180
|
-
!noHighlight && {
|
|
181
|
-
warning: "Some results may be missing due to large field values",
|
|
182
|
-
}),
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
// ── CRON ──────────────────────────────────────────────────────
|
|
187
|
-
export class CronService {
|
|
188
|
-
apiBase;
|
|
189
|
-
apiKey;
|
|
190
|
-
constructor(config) {
|
|
191
|
-
this.apiBase = (config.apiBase || DEFAULT_CRON_BASE).replace(/\/$/, "");
|
|
192
|
-
this.apiKey = config.apiKey;
|
|
193
|
-
}
|
|
194
|
-
async request(method, endpoint, data) {
|
|
195
|
-
const res = await fetch(`${this.apiBase}/${endpoint}`, {
|
|
196
|
-
method,
|
|
197
|
-
headers: {
|
|
198
|
-
"Content-Type": "application/json",
|
|
199
|
-
"X-API-Key": this.apiKey,
|
|
200
|
-
},
|
|
201
|
-
body: data ? JSON.stringify(data) : undefined,
|
|
202
|
-
});
|
|
203
|
-
if (!res.ok) {
|
|
204
|
-
const errText = await res.text().catch(() => "");
|
|
205
|
-
let msg;
|
|
206
|
-
try {
|
|
207
|
-
msg = JSON.parse(errText).error || errText;
|
|
208
|
-
}
|
|
209
|
-
catch {
|
|
210
|
-
msg = errText;
|
|
211
|
-
}
|
|
212
|
-
throw new Error(msg || `CRON API ${method} ${endpoint} failed (${res.status})`);
|
|
213
|
-
}
|
|
214
|
-
if (method === "DELETE")
|
|
215
|
-
return true;
|
|
216
|
-
return res.json();
|
|
217
|
-
}
|
|
218
|
-
async listJobs(workflowId) {
|
|
219
|
-
if (workflowId) {
|
|
220
|
-
const d = await this.request("GET", `api/workflows/${workflowId}/jobs`);
|
|
221
|
-
return d.jobs || [];
|
|
222
|
-
}
|
|
223
|
-
const d = await this.request("GET", "api/jobs");
|
|
224
|
-
return d.jobs || [];
|
|
225
|
-
}
|
|
226
|
-
async getJob(jobId) {
|
|
227
|
-
const d = await this.request("GET", `api/jobs/${jobId}`);
|
|
228
|
-
return d.job;
|
|
229
|
-
}
|
|
230
|
-
async createJob(job) {
|
|
231
|
-
const d = await this.request("POST", "api/jobs", job);
|
|
232
|
-
return this.getJob(d.job_id);
|
|
233
|
-
}
|
|
234
|
-
async updateJob(jobId, updates) {
|
|
235
|
-
const d = await this.request("PUT", `api/jobs/${jobId}`, updates);
|
|
236
|
-
return d.job;
|
|
237
|
-
}
|
|
238
|
-
async toggleJob(jobId) {
|
|
239
|
-
const cur = await this.getJob(jobId);
|
|
240
|
-
return this.updateJob(jobId, { enabled: !cur.enabled });
|
|
241
|
-
}
|
|
242
|
-
async deleteJob(jobId) {
|
|
243
|
-
await this.request("DELETE", `api/jobs/${jobId}`);
|
|
244
|
-
}
|
|
245
|
-
async triggerJob(jobId) {
|
|
246
|
-
await this.request("POST", `api/jobs/${jobId}/trigger`);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
//# sourceMappingURL=services.js.map
|