digital-ai-testing-mcp 1.2.2
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/LICENSE +197 -0
- package/README.md +984 -0
- package/dist/api/agents.d.ts +5 -0
- package/dist/api/agents.d.ts.map +1 -0
- package/dist/api/agents.js +33 -0
- package/dist/api/agents.js.map +1 -0
- package/dist/api/applications.d.ts +35 -0
- package/dist/api/applications.d.ts.map +1 -0
- package/dist/api/applications.js +162 -0
- package/dist/api/applications.js.map +1 -0
- package/dist/api/backup.d.ts +4 -0
- package/dist/api/backup.d.ts.map +1 -0
- package/dist/api/backup.js +13 -0
- package/dist/api/backup.js.map +1 -0
- package/dist/api/browser-inspection.d.ts +33 -0
- package/dist/api/browser-inspection.d.ts.map +1 -0
- package/dist/api/browser-inspection.js +273 -0
- package/dist/api/browser-inspection.js.map +1 -0
- package/dist/api/browsers.d.ts +20 -0
- package/dist/api/browsers.d.ts.map +1 -0
- package/dist/api/browsers.js +31 -0
- package/dist/api/browsers.js.map +1 -0
- package/dist/api/client.d.ts +33 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +200 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/device-groups.d.ts +15 -0
- package/dist/api/device-groups.d.ts.map +1 -0
- package/dist/api/device-groups.js +106 -0
- package/dist/api/device-groups.js.map +1 -0
- package/dist/api/devices.d.ts +32 -0
- package/dist/api/devices.d.ts.map +1 -0
- package/dist/api/devices.js +192 -0
- package/dist/api/devices.js.map +1 -0
- package/dist/api/license.d.ts +3 -0
- package/dist/api/license.d.ts.map +1 -0
- package/dist/api/license.js +11 -0
- package/dist/api/license.js.map +1 -0
- package/dist/api/nv-servers.d.ts +4 -0
- package/dist/api/nv-servers.d.ts.map +1 -0
- package/dist/api/nv-servers.js +20 -0
- package/dist/api/nv-servers.js.map +1 -0
- package/dist/api/projects.d.ts +36 -0
- package/dist/api/projects.d.ts.map +1 -0
- package/dist/api/projects.js +246 -0
- package/dist/api/projects.js.map +1 -0
- package/dist/api/provisioning-profiles.d.ts +7 -0
- package/dist/api/provisioning-profiles.d.ts.map +1 -0
- package/dist/api/provisioning-profiles.js +54 -0
- package/dist/api/provisioning-profiles.js.map +1 -0
- package/dist/api/regions.d.ts +4 -0
- package/dist/api/regions.d.ts.map +1 -0
- package/dist/api/regions.js +20 -0
- package/dist/api/regions.js.map +1 -0
- package/dist/api/reporter-projects.d.ts +3 -0
- package/dist/api/reporter-projects.d.ts.map +1 -0
- package/dist/api/reporter-projects.js +13 -0
- package/dist/api/reporter-projects.js.map +1 -0
- package/dist/api/reporting.d.ts +28 -0
- package/dist/api/reporting.d.ts.map +1 -0
- package/dist/api/reporting.js +340 -0
- package/dist/api/reporting.js.map +1 -0
- package/dist/api/repository.d.ts +17 -0
- package/dist/api/repository.d.ts.map +1 -0
- package/dist/api/repository.js +81 -0
- package/dist/api/repository.js.map +1 -0
- package/dist/api/reservations.d.ts +9 -0
- package/dist/api/reservations.d.ts.map +1 -0
- package/dist/api/reservations.js +72 -0
- package/dist/api/reservations.js.map +1 -0
- package/dist/api/sessions.d.ts +3 -0
- package/dist/api/sessions.d.ts.map +1 -0
- package/dist/api/sessions.js +12 -0
- package/dist/api/sessions.js.map +1 -0
- package/dist/api/test-views.d.ts +9 -0
- package/dist/api/test-views.d.ts.map +1 -0
- package/dist/api/test-views.js +77 -0
- package/dist/api/test-views.js.map +1 -0
- package/dist/api/transactions.d.ts +4 -0
- package/dist/api/transactions.d.ts.map +1 -0
- package/dist/api/transactions.js +28 -0
- package/dist/api/transactions.js.map +1 -0
- package/dist/api/usage-reports.d.ts +24 -0
- package/dist/api/usage-reports.d.ts.map +1 -0
- package/dist/api/usage-reports.js +47 -0
- package/dist/api/usage-reports.js.map +1 -0
- package/dist/api/users.d.ts +14 -0
- package/dist/api/users.d.ts.map +1 -0
- package/dist/api/users.js +77 -0
- package/dist/api/users.js.map +1 -0
- package/dist/api/webdriver.d.ts +97 -0
- package/dist/api/webdriver.d.ts.map +1 -0
- package/dist/api/webdriver.js +1183 -0
- package/dist/api/webdriver.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +130 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/agent-tools.d.ts +3 -0
- package/dist/tools/agent-tools.d.ts.map +1 -0
- package/dist/tools/agent-tools.js +74 -0
- package/dist/tools/agent-tools.js.map +1 -0
- package/dist/tools/application-tools.d.ts +3 -0
- package/dist/tools/application-tools.d.ts.map +1 -0
- package/dist/tools/application-tools.js +816 -0
- package/dist/tools/application-tools.js.map +1 -0
- package/dist/tools/backup-tools.d.ts +3 -0
- package/dist/tools/backup-tools.d.ts.map +1 -0
- package/dist/tools/backup-tools.js +33 -0
- package/dist/tools/backup-tools.js.map +1 -0
- package/dist/tools/boilerplate-tools.d.ts +9 -0
- package/dist/tools/boilerplate-tools.d.ts.map +1 -0
- package/dist/tools/boilerplate-tools.js +1365 -0
- package/dist/tools/boilerplate-tools.js.map +1 -0
- package/dist/tools/browser-tools.d.ts +3 -0
- package/dist/tools/browser-tools.d.ts.map +1 -0
- package/dist/tools/browser-tools.js +108 -0
- package/dist/tools/browser-tools.js.map +1 -0
- package/dist/tools/coverage-tools.d.ts +3 -0
- package/dist/tools/coverage-tools.d.ts.map +1 -0
- package/dist/tools/coverage-tools.js +148 -0
- package/dist/tools/coverage-tools.js.map +1 -0
- package/dist/tools/debug-tools.d.ts +3 -0
- package/dist/tools/debug-tools.d.ts.map +1 -0
- package/dist/tools/debug-tools.js +315 -0
- package/dist/tools/debug-tools.js.map +1 -0
- package/dist/tools/device-group-tools.d.ts +3 -0
- package/dist/tools/device-group-tools.d.ts.map +1 -0
- package/dist/tools/device-group-tools.js +284 -0
- package/dist/tools/device-group-tools.js.map +1 -0
- package/dist/tools/device-tools.d.ts +3 -0
- package/dist/tools/device-tools.d.ts.map +1 -0
- package/dist/tools/device-tools.js +757 -0
- package/dist/tools/device-tools.js.map +1 -0
- package/dist/tools/health-tools.d.ts +3 -0
- package/dist/tools/health-tools.d.ts.map +1 -0
- package/dist/tools/health-tools.js +368 -0
- package/dist/tools/health-tools.js.map +1 -0
- package/dist/tools/inspection-tools.d.ts +3 -0
- package/dist/tools/inspection-tools.d.ts.map +1 -0
- package/dist/tools/inspection-tools.js +1170 -0
- package/dist/tools/inspection-tools.js.map +1 -0
- package/dist/tools/meta-tools.d.ts +4 -0
- package/dist/tools/meta-tools.d.ts.map +1 -0
- package/dist/tools/meta-tools.js +412 -0
- package/dist/tools/meta-tools.js.map +1 -0
- package/dist/tools/nv-server-tools.d.ts +3 -0
- package/dist/tools/nv-server-tools.d.ts.map +1 -0
- package/dist/tools/nv-server-tools.js +67 -0
- package/dist/tools/nv-server-tools.js.map +1 -0
- package/dist/tools/performance-tools.d.ts +3 -0
- package/dist/tools/performance-tools.d.ts.map +1 -0
- package/dist/tools/performance-tools.js +295 -0
- package/dist/tools/performance-tools.js.map +1 -0
- package/dist/tools/project-tools.d.ts +3 -0
- package/dist/tools/project-tools.d.ts.map +1 -0
- package/dist/tools/project-tools.js +577 -0
- package/dist/tools/project-tools.js.map +1 -0
- package/dist/tools/prompt-tools.d.ts +3 -0
- package/dist/tools/prompt-tools.d.ts.map +1 -0
- package/dist/tools/prompt-tools.js +570 -0
- package/dist/tools/prompt-tools.js.map +1 -0
- package/dist/tools/provisioning-profile-tools.d.ts +3 -0
- package/dist/tools/provisioning-profile-tools.d.ts.map +1 -0
- package/dist/tools/provisioning-profile-tools.js +169 -0
- package/dist/tools/provisioning-profile-tools.js.map +1 -0
- package/dist/tools/region-tools.d.ts +3 -0
- package/dist/tools/region-tools.d.ts.map +1 -0
- package/dist/tools/region-tools.js +46 -0
- package/dist/tools/region-tools.js.map +1 -0
- package/dist/tools/reporting-tools.d.ts +3 -0
- package/dist/tools/reporting-tools.d.ts.map +1 -0
- package/dist/tools/reporting-tools.js +1105 -0
- package/dist/tools/reporting-tools.js.map +1 -0
- package/dist/tools/repository-tools.d.ts +3 -0
- package/dist/tools/repository-tools.d.ts.map +1 -0
- package/dist/tools/repository-tools.js +208 -0
- package/dist/tools/repository-tools.js.map +1 -0
- package/dist/tools/reservation-tools.d.ts +3 -0
- package/dist/tools/reservation-tools.d.ts.map +1 -0
- package/dist/tools/reservation-tools.js +199 -0
- package/dist/tools/reservation-tools.js.map +1 -0
- package/dist/tools/resources.d.ts +3 -0
- package/dist/tools/resources.d.ts.map +1 -0
- package/dist/tools/resources.js +91 -0
- package/dist/tools/resources.js.map +1 -0
- package/dist/tools/test-view-tools.d.ts +3 -0
- package/dist/tools/test-view-tools.d.ts.map +1 -0
- package/dist/tools/test-view-tools.js +242 -0
- package/dist/tools/test-view-tools.js.map +1 -0
- package/dist/tools/transaction-tools.d.ts +3 -0
- package/dist/tools/transaction-tools.d.ts.map +1 -0
- package/dist/tools/transaction-tools.js +391 -0
- package/dist/tools/transaction-tools.js.map +1 -0
- package/dist/tools/usage-report-tools.d.ts +3 -0
- package/dist/tools/usage-report-tools.d.ts.map +1 -0
- package/dist/tools/usage-report-tools.js +160 -0
- package/dist/tools/usage-report-tools.js.map +1 -0
- package/dist/tools/user-tools.d.ts +3 -0
- package/dist/tools/user-tools.d.ts.map +1 -0
- package/dist/tools/user-tools.js +279 -0
- package/dist/tools/user-tools.js.map +1 -0
- package/dist/tools/web-inspection-tools.d.ts +3 -0
- package/dist/tools/web-inspection-tools.d.ts.map +1 -0
- package/dist/tools/web-inspection-tools.js +416 -0
- package/dist/tools/web-inspection-tools.js.map +1 -0
- package/dist/tools/workflow-tools.d.ts +3 -0
- package/dist/tools/workflow-tools.d.ts.map +1 -0
- package/dist/tools/workflow-tools.js +1136 -0
- package/dist/tools/workflow-tools.js.map +1 -0
- package/dist/types/digital-ai.d.ts +691 -0
- package/dist/types/digital-ai.d.ts.map +1 -0
- package/dist/types/digital-ai.js +3 -0
- package/dist/types/digital-ai.js.map +1 -0
- package/dist/utils/csv.d.ts +6 -0
- package/dist/utils/csv.d.ts.map +1 -0
- package/dist/utils/csv.js +77 -0
- package/dist/utils/csv.js.map +1 -0
- package/dist/utils/destructive-guard.d.ts +2 -0
- package/dist/utils/destructive-guard.d.ts.map +1 -0
- package/dist/utils/destructive-guard.js +13 -0
- package/dist/utils/destructive-guard.js.map +1 -0
- package/dist/utils/device-resolver.d.ts +22 -0
- package/dist/utils/device-resolver.d.ts.map +1 -0
- package/dist/utils/device-resolver.js +69 -0
- package/dist/utils/device-resolver.js.map +1 -0
- package/dist/utils/download-command.d.ts +18 -0
- package/dist/utils/download-command.d.ts.map +1 -0
- package/dist/utils/download-command.js +54 -0
- package/dist/utils/download-command.js.map +1 -0
- package/dist/utils/locality.d.ts +9 -0
- package/dist/utils/locality.d.ts.map +1 -0
- package/dist/utils/locality.js +22 -0
- package/dist/utils/locality.js.map +1 -0
- package/dist/utils/output-format.d.ts +13 -0
- package/dist/utils/output-format.d.ts.map +1 -0
- package/dist/utils/output-format.js +13 -0
- package/dist/utils/output-format.js.map +1 -0
- package/dist/utils/pagination.d.ts +12 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/pagination.js +24 -0
- package/dist/utils/pagination.js.map +1 -0
- package/dist/utils/path-guard.d.ts +17 -0
- package/dist/utils/path-guard.d.ts.map +1 -0
- package/dist/utils/path-guard.js +41 -0
- package/dist/utils/path-guard.js.map +1 -0
- package/dist/utils/performance-comparison.d.ts +53 -0
- package/dist/utils/performance-comparison.d.ts.map +1 -0
- package/dist/utils/performance-comparison.js +286 -0
- package/dist/utils/performance-comparison.js.map +1 -0
- package/dist/utils/performance-stats.d.ts +72 -0
- package/dist/utils/performance-stats.d.ts.map +1 -0
- package/dist/utils/performance-stats.js +124 -0
- package/dist/utils/performance-stats.js.map +1 -0
- package/dist/utils/profile-loader.d.ts +37 -0
- package/dist/utils/profile-loader.d.ts.map +1 -0
- package/dist/utils/profile-loader.js +80 -0
- package/dist/utils/profile-loader.js.map +1 -0
- package/dist/utils/response-formatter.d.ts +27 -0
- package/dist/utils/response-formatter.d.ts.map +1 -0
- package/dist/utils/response-formatter.js +493 -0
- package/dist/utils/response-formatter.js.map +1 -0
- package/dist/utils/timestamp.d.ts +12 -0
- package/dist/utils/timestamp.d.ts.map +1 -0
- package/dist/utils/timestamp.js +22 -0
- package/dist/utils/timestamp.js.map +1 -0
- package/dist/utils/tool-registry.d.ts +21 -0
- package/dist/utils/tool-registry.d.ts.map +1 -0
- package/dist/utils/tool-registry.js +137 -0
- package/dist/utils/tool-registry.js.map +1 -0
- package/dist/utils/upload-command.d.ts +20 -0
- package/dist/utils/upload-command.d.ts.map +1 -0
- package/dist/utils/upload-command.js +64 -0
- package/dist/utils/upload-command.js.map +1 -0
- package/dist/utils/usage-report-guard.d.ts +48 -0
- package/dist/utils/usage-report-guard.d.ts.map +1 -0
- package/dist/utils/usage-report-guard.js +88 -0
- package/dist/utils/usage-report-guard.js.map +1 -0
- package/dist/utils/usage-report-summary.d.ts +20 -0
- package/dist/utils/usage-report-summary.d.ts.map +1 -0
- package/dist/utils/usage-report-summary.js +48 -0
- package/dist/utils/usage-report-summary.js.map +1 -0
- package/dist/utils/version.d.ts +2 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +24 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +73 -0
- package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative-oss.java +58 -0
- package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative.java +67 -0
- package/resources/boilerplate/Android-Native/Java JUnit5/gradle +10 -0
- package/resources/boilerplate/Android-Native/Java JUnit5/gradle-oss +10 -0
- package/resources/boilerplate/Android-Native/Java JUnit5/maven +42 -0
- package/resources/boilerplate/Android-Native/Java JUnit5/maven-oss +42 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/AndroidNative.js +30 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/Shell +19 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/Shell-oss +19 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/package-oss.json +12 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/package.json +12 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/wdio-oss.conf.js +40 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/wdio.conf.js +44 -0
- package/resources/boilerplate/Android-Native/Python/AndroidNative-oss.py +49 -0
- package/resources/boilerplate/Android-Native/Python/AndroidNative.py +69 -0
- package/resources/boilerplate/Android-Native/Python/pip +2 -0
- package/resources/boilerplate/Android-Native/Python/pip-oss +1 -0
- package/resources/boilerplate/Android-Native/java TestNG/AndroidNative-oss.java +58 -0
- package/resources/boilerplate/Android-Native/java TestNG/AndroidNative.java +67 -0
- package/resources/boilerplate/Android-Native/java TestNG/gradle +13 -0
- package/resources/boilerplate/Android-Native/java TestNG/gradle-oss +13 -0
- package/resources/boilerplate/Android-Native/java TestNG/maven +42 -0
- package/resources/boilerplate/Android-Native/java TestNG/maven-oss +42 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/Shell-oss.txt +19 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/Shell.txt +19 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/iOSNative.js +30 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/package-oss.json +12 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/package.json +12 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/wdio-oss.conf.js +35 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/wdio.conf.js +39 -0
- package/resources/boilerplate/iOS-Native/Python/iOSNative-oss.py +44 -0
- package/resources/boilerplate/iOS-Native/Python/iOSNative.py +62 -0
- package/resources/boilerplate/iOS-Native/Python/pip-oss.txt +1 -0
- package/resources/boilerplate/iOS-Native/Python/pip.txt +2 -0
- package/resources/boilerplate/iOS-Native/java-JUnit5/gradle +10 -0
- package/resources/boilerplate/iOS-Native/java-JUnit5/gradle-oss +10 -0
- package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative-oss.java +52 -0
- package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative.java +59 -0
- package/resources/boilerplate/iOS-Native/java-JUnit5/maven +42 -0
- package/resources/boilerplate/iOS-Native/java-JUnit5/maven-oss +42 -0
- package/resources/boilerplate/iOS-Native/java-TestNG/gradle +13 -0
- package/resources/boilerplate/iOS-Native/java-TestNG/gradle-oss +13 -0
- package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative-oss.java +52 -0
- package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative.java +59 -0
- package/resources/boilerplate/iOS-Native/java-TestNG/maven +42 -0
- package/resources/boilerplate/iOS-Native/java-TestNG/maven-oss +42 -0
|
@@ -0,0 +1,1136 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { computeWorkflowReadiness } from '../utils/tool-registry.js';
|
|
3
|
+
/** Normalise an end-date string to YYYY-MM-DD.
|
|
4
|
+
* Accepts ISO dates, relative offsets (+14d, +2w, "in 2 weeks"), or
|
|
5
|
+
* any string that JavaScript's Date constructor can parse.
|
|
6
|
+
* Falls back to the raw string if it cannot be parsed so no input is lost.
|
|
7
|
+
*/
|
|
8
|
+
function normalizeEndDate(raw) {
|
|
9
|
+
const trimmed = raw.trim();
|
|
10
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(trimmed))
|
|
11
|
+
return trimmed;
|
|
12
|
+
const daysMatch = trimmed.match(/^\+?(\d+)\s*d(?:ays?)?$/i);
|
|
13
|
+
if (daysMatch) {
|
|
14
|
+
const d = new Date();
|
|
15
|
+
d.setDate(d.getDate() + parseInt(daysMatch[1], 10));
|
|
16
|
+
return d.toISOString().slice(0, 10);
|
|
17
|
+
}
|
|
18
|
+
const weeksMatch = trimmed.match(/^\+?(\d+)\s*w(?:eeks?)?$/i);
|
|
19
|
+
if (weeksMatch) {
|
|
20
|
+
const d = new Date();
|
|
21
|
+
d.setDate(d.getDate() + parseInt(weeksMatch[1], 10) * 7);
|
|
22
|
+
return d.toISOString().slice(0, 10);
|
|
23
|
+
}
|
|
24
|
+
const inMatch = trimmed.match(/^in\s+(\d+)\s*(weeks?|days?|months?)/i);
|
|
25
|
+
if (inMatch) {
|
|
26
|
+
const n = parseInt(inMatch[1], 10);
|
|
27
|
+
const unit = inMatch[2].toLowerCase();
|
|
28
|
+
const d = new Date();
|
|
29
|
+
if (unit.startsWith('week'))
|
|
30
|
+
d.setDate(d.getDate() + n * 7);
|
|
31
|
+
else if (unit.startsWith('day'))
|
|
32
|
+
d.setDate(d.getDate() + n);
|
|
33
|
+
else if (unit.startsWith('month'))
|
|
34
|
+
d.setMonth(d.getMonth() + n);
|
|
35
|
+
return d.toISOString().slice(0, 10);
|
|
36
|
+
}
|
|
37
|
+
const parsed = new Date(trimmed);
|
|
38
|
+
if (!isNaN(parsed.getTime()))
|
|
39
|
+
return parsed.toISOString().slice(0, 10);
|
|
40
|
+
return trimmed;
|
|
41
|
+
}
|
|
42
|
+
export function registerWorkflowTools(server) {
|
|
43
|
+
/** Returns a hard-error response if any dependency of `workflow` is not registered,
|
|
44
|
+
* or null if the workflow is ready to run. */
|
|
45
|
+
function preflightCheck(workflow) {
|
|
46
|
+
const readiness = computeWorkflowReadiness(server, workflow);
|
|
47
|
+
const status = readiness[workflow];
|
|
48
|
+
if (!status || status.ready)
|
|
49
|
+
return null;
|
|
50
|
+
const missing = [...status.missingRead, ...status.missingWrite];
|
|
51
|
+
return {
|
|
52
|
+
content: [{
|
|
53
|
+
type: 'text',
|
|
54
|
+
text: [
|
|
55
|
+
`❌ ${workflow} cannot execute — ${missing.length} required tool(s) are not registered in this runtime:`,
|
|
56
|
+
...missing.map(t => ` • ${t}`),
|
|
57
|
+
'',
|
|
58
|
+
'This indicates the deployed Docker image is incomplete or a module failed to load at startup.',
|
|
59
|
+
'Call check_workflow_readiness for the full dependency report.',
|
|
60
|
+
'To fix: docker build -t digital-ai-testing-mcp:latest . then restart the container.',
|
|
61
|
+
].join('\n'),
|
|
62
|
+
}],
|
|
63
|
+
isError: true,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
// ─── create_poc ────────────────────────────────────────────────────────────
|
|
67
|
+
server.tool('create_poc', 'Guided 10-step workflow to set up a complete POC environment: device group, device selection and tagging, project creation, user provisioning, and app assignment. Call this tool with all required parameters — it returns step-by-step instructions that you will then execute using the individual MCP tools.', {
|
|
68
|
+
customerName: z
|
|
69
|
+
.string()
|
|
70
|
+
.describe('Customer name, e.g. "Acme Corp". POC display name will be "<name> POC"; device tag will be the lowercase alphanumeric form (e.g. "acmecorppoc").'),
|
|
71
|
+
region: z
|
|
72
|
+
.string()
|
|
73
|
+
.describe('Region code where the customer will test, e.g. "US2", "EU", "SG". Used to select geographically close devices from the Default device group.'),
|
|
74
|
+
deviceCount: z
|
|
75
|
+
.number()
|
|
76
|
+
.int()
|
|
77
|
+
.min(1)
|
|
78
|
+
.max(50)
|
|
79
|
+
.optional()
|
|
80
|
+
.describe('Total number of phones to allocate (default: 6). Tablets are never selected.'),
|
|
81
|
+
iosCount: z
|
|
82
|
+
.number()
|
|
83
|
+
.int()
|
|
84
|
+
.min(0)
|
|
85
|
+
.optional()
|
|
86
|
+
.describe('Number of iOS phones. Defaults to ceil(deviceCount / 2).'),
|
|
87
|
+
androidCount: z
|
|
88
|
+
.number()
|
|
89
|
+
.int()
|
|
90
|
+
.min(0)
|
|
91
|
+
.optional()
|
|
92
|
+
.describe('Number of Android phones. Defaults to floor(deviceCount / 2).'),
|
|
93
|
+
automationType: z
|
|
94
|
+
.enum(['appium-server', 'appium-grid'])
|
|
95
|
+
.optional()
|
|
96
|
+
.describe('"appium-server" (default, recommended) or "appium-grid".'),
|
|
97
|
+
salesforceUrl: z
|
|
98
|
+
.string()
|
|
99
|
+
.describe('Salesforce Opportunity URL — recorded in project notes.'),
|
|
100
|
+
endDate: z
|
|
101
|
+
.string()
|
|
102
|
+
.describe('POC end date. Accepts ISO format ("2026-08-31"), relative offsets ("+14d", "+2w"), or natural language ("in 2 weeks"). Stored in project notes.'),
|
|
103
|
+
users: z
|
|
104
|
+
.array(z.object({
|
|
105
|
+
email: z.string().describe('Email address, also used as the login username.'),
|
|
106
|
+
firstName: z.string().describe('First name.'),
|
|
107
|
+
lastName: z.string().describe('Last name.'),
|
|
108
|
+
role: z
|
|
109
|
+
.enum(['User', 'ProjectAdmin'])
|
|
110
|
+
.describe('"User" for standard access, "ProjectAdmin" for project management access. Cloud Admin is never permitted for POC users.'),
|
|
111
|
+
}))
|
|
112
|
+
.min(1)
|
|
113
|
+
.describe('Users to create. Each user gets the email as username, is assigned to the POC project, and is removed from the Default project.'),
|
|
114
|
+
appName: z
|
|
115
|
+
.string()
|
|
116
|
+
.optional()
|
|
117
|
+
.describe('Display name of the demo app used in notes and summaries (default: "ExperiBank").'),
|
|
118
|
+
androidPackageName: z
|
|
119
|
+
.string()
|
|
120
|
+
.optional()
|
|
121
|
+
.describe('Android package name used to locate the APK in the repository (default: "com.experitest.ExperiBank"). Searched via the packageName filter — more reliable than display name.'),
|
|
122
|
+
iosBundleId: z
|
|
123
|
+
.string()
|
|
124
|
+
.optional()
|
|
125
|
+
.describe('iOS bundle identifier used to locate the IPA in the repository (default: "com.experitest.ExperiBank"). Searched via the bundleIdentifier filter — more reliable than display name.'),
|
|
126
|
+
}, ({ customerName, region, deviceCount, iosCount, androidCount, automationType, salesforceUrl, endDate, users, appName, androidPackageName, iosBundleId }) => {
|
|
127
|
+
const guard = preflightCheck('create_poc');
|
|
128
|
+
if (guard)
|
|
129
|
+
return guard;
|
|
130
|
+
const pocName = `${customerName.trim()} POC`;
|
|
131
|
+
const pocTag = customerName.toLowerCase().replace(/[^a-z0-9]/g, '') + 'poc';
|
|
132
|
+
const appiumOSS = (automationType ?? 'appium-server') !== 'appium-grid';
|
|
133
|
+
const automationLabel = appiumOSS ? 'Appium Server (appiumOSS: true)' : 'Appium Grid (appiumOSS: false)';
|
|
134
|
+
const total = deviceCount ?? 6;
|
|
135
|
+
const ios = iosCount ?? Math.ceil(total / 2);
|
|
136
|
+
const android = androidCount ?? Math.floor(total / 2);
|
|
137
|
+
const deviceDesc = `${total} phones total — ${ios} iOS + ${android} Android`;
|
|
138
|
+
const targetAppName = appName ?? 'ExperiBank';
|
|
139
|
+
const targetAndroidPkg = androidPackageName ?? 'com.experitest.ExperiBank';
|
|
140
|
+
const targetIosBundleId = iosBundleId ?? 'com.experitest.ExperiBank';
|
|
141
|
+
const resolvedEndDate = normalizeEndDate(endDate);
|
|
142
|
+
const userLines = users.map((u, i) => ` User ${i + 1}: ${u.firstName} ${u.lastName} <${u.email}> — role: ${u.role}`).join('\n');
|
|
143
|
+
const instructions = [
|
|
144
|
+
`You are executing a guided POC setup workflow. Work through each numbered step in order.`,
|
|
145
|
+
`Do not skip steps or reorder them — later steps depend on IDs returned by earlier ones.`,
|
|
146
|
+
`This workflow is idempotent: if a group or project named "${pocName}" already exists,`,
|
|
147
|
+
`reuse it rather than creating a duplicate. See individual steps for details.`,
|
|
148
|
+
``,
|
|
149
|
+
`═══════════════════════════════════════════════`,
|
|
150
|
+
`CONFIRMED PARAMETERS`,
|
|
151
|
+
`═══════════════════════════════════════════════`,
|
|
152
|
+
`POC Display Name : ${pocName}`,
|
|
153
|
+
`POC Device Tag : ${pocTag} (lowercase alphanumeric — spaces and special chars stripped)`,
|
|
154
|
+
`Target Region : ${region}`,
|
|
155
|
+
`Device Mix : ${deviceDesc}`,
|
|
156
|
+
`Automation Type : ${automationLabel}`,
|
|
157
|
+
`Salesforce URL : ${salesforceUrl}`,
|
|
158
|
+
`POC End Date : ${resolvedEndDate}`,
|
|
159
|
+
`Users to create :`,
|
|
160
|
+
userLines,
|
|
161
|
+
``,
|
|
162
|
+
`─── STEP 0 — App pre-flight check + Operator confirmation ──────────────`,
|
|
163
|
+
`Before presenting parameters to the operator, verify app availability:`,
|
|
164
|
+
``,
|
|
165
|
+
...(android > 0 ? [
|
|
166
|
+
`Android check — call: list_applications`,
|
|
167
|
+
` packageName: "${targetAndroidPkg}"`,
|
|
168
|
+
` outputFormat: "json"`,
|
|
169
|
+
`Set ANDROID_APP_FOUND = true if any result is returned, and note the app ID of the`,
|
|
170
|
+
`most recently uploaded entry as ANDROID_APP_ID.`,
|
|
171
|
+
``,
|
|
172
|
+
] : []),
|
|
173
|
+
...(ios > 0 ? [
|
|
174
|
+
`iOS check — call: list_applications`,
|
|
175
|
+
` bundleIdentifier: "${targetIosBundleId}"`,
|
|
176
|
+
` outputFormat: "json"`,
|
|
177
|
+
`Set iOS_APP_FOUND = true if any result is returned, and note the app ID of the`,
|
|
178
|
+
`most recently uploaded entry as IOS_APP_ID.`,
|
|
179
|
+
``,
|
|
180
|
+
] : []),
|
|
181
|
+
...(ios > 0 ? [
|
|
182
|
+
`⚠️ iOS devices requested (${ios}) — if iOS_APP_FOUND is false:`,
|
|
183
|
+
` Include in the summary: "WARNING: No iOS binary for bundle ID '${targetIosBundleId}' found in repository."`,
|
|
184
|
+
` Ask the operator to proceed without it or upload an IPA first.`,
|
|
185
|
+
] : []),
|
|
186
|
+
...(android > 0 ? [
|
|
187
|
+
`⚠️ Android devices requested (${android}) — if ANDROID_APP_FOUND is false:`,
|
|
188
|
+
` Include in the summary: "WARNING: No Android binary for package '${targetAndroidPkg}' found in repository."`,
|
|
189
|
+
` Ask the operator to proceed without it or upload an APK first.`,
|
|
190
|
+
] : []),
|
|
191
|
+
``,
|
|
192
|
+
`Then present the full parameters above in a clean summary table, include any`,
|
|
193
|
+
`app warnings, and ask for explicit operator confirmation before executing any steps.`,
|
|
194
|
+
`If the operator wants to change anything, stop and collect corrections.`,
|
|
195
|
+
`Only proceed past this step when the operator confirms.`,
|
|
196
|
+
``,
|
|
197
|
+
`─── STEP 1 — Create or reuse the POC device group ───────────────────────`,
|
|
198
|
+
`First call: list_device_groups`,
|
|
199
|
+
` outputFormat: "json"`,
|
|
200
|
+
`Check if a group named exactly "${pocName}" already exists in deviceGroups[].`,
|
|
201
|
+
``,
|
|
202
|
+
` IF IT EXISTS:`,
|
|
203
|
+
` • Note its id as POC_GROUP_ID and skip the create_device_group call.`,
|
|
204
|
+
` • Report "Device group reused (not created)" in the completion summary.`,
|
|
205
|
+
``,
|
|
206
|
+
` IF IT DOES NOT EXIST:`,
|
|
207
|
+
` Call: create_device_group`,
|
|
208
|
+
` name: "${pocName}"`,
|
|
209
|
+
` acceptNewDevices: false`,
|
|
210
|
+
` SAVE the returned device group ID as POC_GROUP_ID.`,
|
|
211
|
+
``,
|
|
212
|
+
`─── STEP 2 — Locate the Default device group ────────────────────────────`,
|
|
213
|
+
`Call: list_device_groups (you may already have this from Step 1)`,
|
|
214
|
+
` outputFormat: "json"`,
|
|
215
|
+
`Find the entry whose name is exactly "Default" and note its id as DEFAULT_GROUP_ID.`,
|
|
216
|
+
``,
|
|
217
|
+
`─── STEP 3 — Select devices for the POC ─────────────────────────────────`,
|
|
218
|
+
`Call: get_devices_in_group`,
|
|
219
|
+
` groupId: DEFAULT_GROUP_ID`,
|
|
220
|
+
` category: "PHONE"`,
|
|
221
|
+
` status: "Available"`,
|
|
222
|
+
` excludeTags: ["DoNotTake", "DONTTAKE", "DONOTUSE", "Worksoft", "Worksoft_Temp"]`,
|
|
223
|
+
` outputFormat: "json"`,
|
|
224
|
+
``,
|
|
225
|
+
`The server pre-filters to Available phones and strips all known restriction-tagged devices.`,
|
|
226
|
+
`From the returned list apply these additional rules:`,
|
|
227
|
+
``,
|
|
228
|
+
` INCLUDE only devices where:`,
|
|
229
|
+
` • region contains "${region}" (case-insensitive partial match)`,
|
|
230
|
+
``,
|
|
231
|
+
` EXCLUDE any remaining device whose tags array:`,
|
|
232
|
+
` • contains "POC" (case-insensitive) — already in another active POC`,
|
|
233
|
+
` • otherwise clearly indicates restriction (e.g. "INUSE", "reserved") not already filtered`,
|
|
234
|
+
``,
|
|
235
|
+
` TARGET MIX: ${deviceDesc}`,
|
|
236
|
+
` • Prefer modern models (last 2–3 device generations)`,
|
|
237
|
+
` • Aim for ${ios} iOS and ${android} Android phones`,
|
|
238
|
+
` • If the split cannot be met exactly, fill the shortfall from the other OS`,
|
|
239
|
+
` • If fewer than ${total} devices pass all filters, select all that qualify and report the gap`,
|
|
240
|
+
``,
|
|
241
|
+
`Present the proposed device selection as a table to the operator:`,
|
|
242
|
+
` Device Name | OS | Model | Region | Tags`,
|
|
243
|
+
`Ask for confirmation before continuing. Save confirmed device IDs as SELECTED_DEVICE_IDS.`,
|
|
244
|
+
``,
|
|
245
|
+
`─── STEP 4 — Add selected devices to the POC device group ───────────────`,
|
|
246
|
+
`Call: add_devices_to_group`,
|
|
247
|
+
` groupId: POC_GROUP_ID`,
|
|
248
|
+
` deviceIds: SELECTED_DEVICE_IDS`,
|
|
249
|
+
``,
|
|
250
|
+
`─── STEP 5 — Tag all selected devices with the POC tag ──────────────────`,
|
|
251
|
+
`For each device in SELECTED_DEVICE_IDS:`,
|
|
252
|
+
` • Check the device's existing tags (visible in the Step 3 response).`,
|
|
253
|
+
` • If the device already has the tag "${pocTag}", skip it — no action needed.`,
|
|
254
|
+
` • Otherwise call: add_device_tag`,
|
|
255
|
+
` deviceId: <device ID>`,
|
|
256
|
+
` tag: "${pocTag}"`,
|
|
257
|
+
``,
|
|
258
|
+
`Call this for every untagged device individually. If a tag call fails on one device,`,
|
|
259
|
+
`report it and continue with the remaining devices — do not abort.`,
|
|
260
|
+
``,
|
|
261
|
+
`─── STEP 6 — Create or reuse the POC project ────────────────────────────`,
|
|
262
|
+
`(Project creation comes BEFORE removing devices from Default — if it fails,`,
|
|
263
|
+
`the devices are still in the Default group and nothing needs to be unwound.)`,
|
|
264
|
+
``,
|
|
265
|
+
`First call: list_projects`,
|
|
266
|
+
` outputFormat: "json"`,
|
|
267
|
+
`Check if a project named exactly "${pocName}" already exists in projects[].`,
|
|
268
|
+
``,
|
|
269
|
+
` IF IT EXISTS:`,
|
|
270
|
+
` • Note its ID as POC_PROJECT_ID and skip the create_project call.`,
|
|
271
|
+
` • Report "Project reused (not created)" in the completion summary.`,
|
|
272
|
+
``,
|
|
273
|
+
` IF IT DOES NOT EXIST:`,
|
|
274
|
+
` Call: create_project`,
|
|
275
|
+
` name: "${pocName}"`,
|
|
276
|
+
` deviceGroupName: "${pocName}"`,
|
|
277
|
+
` appiumOSS: ${appiumOSS}`,
|
|
278
|
+
` SAVE the returned project ID as POC_PROJECT_ID.`,
|
|
279
|
+
``,
|
|
280
|
+
`In both cases (reuse or create), call: set_project_notes`,
|
|
281
|
+
` projectId: POC_PROJECT_ID`,
|
|
282
|
+
` notes: "Salesforce Opportunity: ${salesforceUrl}\\nPOC End Date: ${resolvedEndDate}"`,
|
|
283
|
+
``,
|
|
284
|
+
`─── STEP 7 — Remove selected devices from the Default device group ───────`,
|
|
285
|
+
`Do this ONLY after Step 6 succeeded — the project must exist before devices`,
|
|
286
|
+
`leave the Default pool, or a failure would strand them in a project-less group.`,
|
|
287
|
+
``,
|
|
288
|
+
`Call: remove_devices_from_group`,
|
|
289
|
+
` groupId: DEFAULT_GROUP_ID`,
|
|
290
|
+
` deviceIds: SELECTED_DEVICE_IDS`,
|
|
291
|
+
` confirmDeletion: true`,
|
|
292
|
+
``,
|
|
293
|
+
`confirmDeletion:true is correct here — this removal is an intentional,`,
|
|
294
|
+
`pre-authorised step in this scripted workflow.`,
|
|
295
|
+
``,
|
|
296
|
+
`─── STEP 8 — Locate the Default project ID ──────────────────────────────`,
|
|
297
|
+
`Call: list_projects (you may already have this from Step 6)`,
|
|
298
|
+
` outputFormat: "json"`,
|
|
299
|
+
`Find the project named exactly "Default" and note its id as DEFAULT_PROJECT_ID.`,
|
|
300
|
+
`You will need this in Step 9 to remove users from the Default project.`,
|
|
301
|
+
``,
|
|
302
|
+
`─── STEP 9 — Create users and assign them to the POC project ────────────`,
|
|
303
|
+
``,
|
|
304
|
+
`CRITICAL RULES — enforce without exception:`,
|
|
305
|
+
` • Never grant Cloud Admin access to any user`,
|
|
306
|
+
` • Every user must be removed from the Default project after creation`,
|
|
307
|
+
` • role must be "User" or "ProjectAdmin" only`,
|
|
308
|
+
``,
|
|
309
|
+
`For each user listed below, execute sub-steps a → b → c → d in order:`,
|
|
310
|
+
``,
|
|
311
|
+
userLines,
|
|
312
|
+
``,
|
|
313
|
+
` a. Call: create_user`,
|
|
314
|
+
` username: <email>`,
|
|
315
|
+
` firstName: <firstName>`,
|
|
316
|
+
` lastName: <lastName>`,
|
|
317
|
+
` email: <email>`,
|
|
318
|
+
` role: <role> ("User" or "ProjectAdmin" — never "Admin")`,
|
|
319
|
+
` authenticationType: "BASIC"`,
|
|
320
|
+
` SAVE the returned user ID as USER_ID.`,
|
|
321
|
+
``,
|
|
322
|
+
` b. Call: assign_user_to_project`,
|
|
323
|
+
` projectId: POC_PROJECT_ID`,
|
|
324
|
+
` userId: USER_ID`,
|
|
325
|
+
` role: <role>`,
|
|
326
|
+
``,
|
|
327
|
+
` c. Call: remove_user_from_project`,
|
|
328
|
+
` projectId: DEFAULT_PROJECT_ID`,
|
|
329
|
+
` userId: USER_ID`,
|
|
330
|
+
` confirmDeletion: true`,
|
|
331
|
+
` confirmDeletion:true is correct — removing POC users from Default`,
|
|
332
|
+
` is an intentional, pre-authorised step in this workflow.`,
|
|
333
|
+
``,
|
|
334
|
+
` d. Call: set_user_tags`,
|
|
335
|
+
` userId: USER_ID`,
|
|
336
|
+
` tags: ["${pocTag}"]`,
|
|
337
|
+
` ⚠️ REQUIRED — do not skip. This tag is how close_poc and delete_poc identify`,
|
|
338
|
+
` POC-created users. Without it, those workflows cannot auto-identify this user`,
|
|
339
|
+
` and the operator will have to find and remove them manually.`,
|
|
340
|
+
` If this call fails, record it explicitly in the completion summary as a WARNING`,
|
|
341
|
+
` (not just a note) — the account works, but manual tracking is now required.`,
|
|
342
|
+
``,
|
|
343
|
+
`Failure handling (isolate — do not abort the whole workflow):`,
|
|
344
|
+
` • If 9a (create_user) fails: record the failure, skip 9b, 9c, and 9d for this user,`,
|
|
345
|
+
` continue with the next user. The operator will need to create this account manually.`,
|
|
346
|
+
` • If 9b (assign_user_to_project) fails: record it and attempt 9c and 9d anyway, then`,
|
|
347
|
+
` continue. The account exists but needs manual project assignment.`,
|
|
348
|
+
` • If 9c (remove_user_from_project) fails: record it and continue.`,
|
|
349
|
+
` The account exists and is assigned to the POC project; Default project removal`,
|
|
350
|
+
` will need to be done manually.`,
|
|
351
|
+
` • If 9d (set_user_tags) fails: record it as a WARNING in the completion summary.`,
|
|
352
|
+
` The account works but will not be found by close_poc/delete_poc tag filter.`,
|
|
353
|
+
``,
|
|
354
|
+
`─── STEP 10 — Assign ${targetAppName} apps to the POC project ──────────────────────`,
|
|
355
|
+
`Use the app IDs already resolved during the Step 0 pre-flight check.`,
|
|
356
|
+
``,
|
|
357
|
+
...(android > 0 ? [
|
|
358
|
+
`Android assignment:`,
|
|
359
|
+
` If ANDROID_APP_FOUND is true (ANDROID_APP_ID is known from Step 0):`,
|
|
360
|
+
` Call: assign_app_to_project`,
|
|
361
|
+
` projectId: POC_PROJECT_ID`,
|
|
362
|
+
` applicationId: ANDROID_APP_ID`,
|
|
363
|
+
` If ANDROID_APP_FOUND is false:`,
|
|
364
|
+
` Report in summary: "Android binary for '${targetAndroidPkg}' not found — manual upload required."`,
|
|
365
|
+
` Do not abort — mark Android app assignment as incomplete.`,
|
|
366
|
+
``,
|
|
367
|
+
] : []),
|
|
368
|
+
...(ios > 0 ? [
|
|
369
|
+
`iOS assignment:`,
|
|
370
|
+
` If iOS_APP_FOUND is true (IOS_APP_ID is known from Step 0):`,
|
|
371
|
+
` Call: assign_app_to_project`,
|
|
372
|
+
` projectId: POC_PROJECT_ID`,
|
|
373
|
+
` applicationId: IOS_APP_ID`,
|
|
374
|
+
` If iOS_APP_FOUND is false:`,
|
|
375
|
+
` Report in summary: "iOS binary for '${targetIosBundleId}' not found — manual upload required."`,
|
|
376
|
+
` Do not abort — mark iOS app assignment as incomplete.`,
|
|
377
|
+
``,
|
|
378
|
+
] : []),
|
|
379
|
+
`NOTE: assign_app_to_project grants the POC project access to the shared binary.`,
|
|
380
|
+
`It is not an independent copy — both projects reference the same record.`,
|
|
381
|
+
``,
|
|
382
|
+
`═══════════════════════════════════════════════`,
|
|
383
|
+
`IF ANY STEP FAILS`,
|
|
384
|
+
`═══════════════════════════════════════════════`,
|
|
385
|
+
`Stop at the failed step — do not improvise later steps out of order.`,
|
|
386
|
+
`Report exactly which steps completed and include every resource ID created so far`,
|
|
387
|
+
`(POC_GROUP_ID, POC_PROJECT_ID, SELECTED_DEVICE_IDS, user IDs) so the operator can:`,
|
|
388
|
+
` • Resume: re-invoke create_poc with the same parameters — Steps 1 and 6 detect`,
|
|
389
|
+
` and reuse the existing group/project instead of creating duplicates. Re-verify`,
|
|
390
|
+
` the Step 3 device selection (previously selected devices may already carry the`,
|
|
391
|
+
` POC tag or sit in the POC group — verify with get_devices_in_group before adding).`,
|
|
392
|
+
` • Unwind: run delete_poc, which returns devices to Default and removes the`,
|
|
393
|
+
` group, project, and users created so far.`,
|
|
394
|
+
``,
|
|
395
|
+
`═══════════════════════════════════════════════`,
|
|
396
|
+
`COMPLETION SUMMARY`,
|
|
397
|
+
`═══════════════════════════════════════════════`,
|
|
398
|
+
`After all steps complete, present a final summary:`,
|
|
399
|
+
``,
|
|
400
|
+
` ✅ POC Name : ${pocName}`,
|
|
401
|
+
` ✅ Device Group : <POC_GROUP_ID> (created or reused)`,
|
|
402
|
+
` ✅ Devices allocated: <count> (<iOS> iOS, <Android> Android)`,
|
|
403
|
+
` ✅ POC Tag applied : ${pocTag}`,
|
|
404
|
+
` ✅ Project : <POC_PROJECT_ID> (created or reused)`,
|
|
405
|
+
` ✅ Project Notes : Salesforce URL + End Date recorded`,
|
|
406
|
+
` ✅ Users created : <count> — for each user list: name, role, and tag status`,
|
|
407
|
+
` e.g. "Jane Doe (ProjectAdmin) — tagged ✅" or "tagged ⚠️ FAILED"`,
|
|
408
|
+
` ✅ ${targetAppName}: Android and/or iOS assigned to project (or ⚠️ not found — see above)`,
|
|
409
|
+
` ⚠️ Any warnings, shortfalls, skipped steps, or individual step failures`,
|
|
410
|
+
` ⚠️ If any user tag failed: explicitly name each untagged user — they must be tracked manually`,
|
|
411
|
+
].join('\n');
|
|
412
|
+
return {
|
|
413
|
+
content: [{ type: 'text', text: instructions }],
|
|
414
|
+
};
|
|
415
|
+
});
|
|
416
|
+
// ─── close_poc ─────────────────────────────────────────────────────────────
|
|
417
|
+
server.tool('close_poc', 'Guided workflow to cleanly close an active POC: removes the POC tag from devices, moves devices back to the Default group, and permanently deletes the user accounts that were created for the POC (identified by their POC tag, with per-user operator confirmation). Does not delete the project or device group — use delete_poc for full teardown.', {
|
|
418
|
+
customerName: z
|
|
419
|
+
.string()
|
|
420
|
+
.describe('Customer name exactly as used when the POC was created (e.g. "Acme Corp"). Used to derive the POC project name and device tag.'),
|
|
421
|
+
}, ({ customerName }) => {
|
|
422
|
+
const guard = preflightCheck('close_poc');
|
|
423
|
+
if (guard)
|
|
424
|
+
return guard;
|
|
425
|
+
const pocName = `${customerName.trim()} POC`;
|
|
426
|
+
const pocTag = customerName.toLowerCase().replace(/[^a-z0-9]/g, '') + 'poc';
|
|
427
|
+
const instructions = [
|
|
428
|
+
`You are executing a guided POC close-down workflow. Work through each step in order.`,
|
|
429
|
+
``,
|
|
430
|
+
`═══════════════════════════════════════════════`,
|
|
431
|
+
`CONFIRMED PARAMETERS`,
|
|
432
|
+
`═══════════════════════════════════════════════`,
|
|
433
|
+
`POC Name : ${pocName}`,
|
|
434
|
+
`POC Tag : ${pocTag}`,
|
|
435
|
+
``,
|
|
436
|
+
`─── STEP 0 — Operator confirmation ──────────────────────────────────────`,
|
|
437
|
+
`Present the parameters above and ask the operator to confirm before proceeding.`,
|
|
438
|
+
``,
|
|
439
|
+
`─── STEP 1 — Locate the POC project and device group ────────────────────`,
|
|
440
|
+
`Call: list_projects`,
|
|
441
|
+
` outputFormat: "json"`,
|
|
442
|
+
`Find the project named exactly "${pocName}" and note its id as POC_PROJECT_ID.`,
|
|
443
|
+
`If no POC project exists, stop and report: "POC project not found — nothing to close."`,
|
|
444
|
+
``,
|
|
445
|
+
`Call: list_device_groups`,
|
|
446
|
+
` outputFormat: "json"`,
|
|
447
|
+
`Find the group named exactly "${pocName}" and note its id as POC_GROUP_ID.`,
|
|
448
|
+
`Also find the group named exactly "Default" and note its id as DEFAULT_GROUP_ID.`,
|
|
449
|
+
`If POC_GROUP_ID is not found, note this — Steps 2–4 will be skipped.`,
|
|
450
|
+
``,
|
|
451
|
+
`─── STEP 2 — Get devices in the POC device group ─────────────────────────`,
|
|
452
|
+
`If POC_GROUP_ID was found:`,
|
|
453
|
+
` Call: get_devices_in_group`,
|
|
454
|
+
` groupId: POC_GROUP_ID`,
|
|
455
|
+
` outputFormat: "json"`,
|
|
456
|
+
` Save all returned device IDs as POC_DEVICE_IDS.`,
|
|
457
|
+
` Present the device list to the operator (Device Name | OS | Tags) before continuing.`,
|
|
458
|
+
``,
|
|
459
|
+
`If POC_GROUP_ID was not found, skip Steps 3 and 4.`,
|
|
460
|
+
``,
|
|
461
|
+
`─── STEP 3 — Remove the POC tag from each device ────────────────────────`,
|
|
462
|
+
`For each device in POC_DEVICE_IDS, call: remove_device_tag`,
|
|
463
|
+
` deviceId: <device ID>`,
|
|
464
|
+
` tag: "${pocTag}"`,
|
|
465
|
+
``,
|
|
466
|
+
`Only remove the "${pocTag}" tag — leave all other tags on the device untouched.`,
|
|
467
|
+
`If a remove_device_tag call fails (e.g. tag was already absent), record it and continue.`,
|
|
468
|
+
``,
|
|
469
|
+
`─── STEP 4 — Move devices from POC group to Default group ───────────────`,
|
|
470
|
+
`Call: remove_devices_from_group`,
|
|
471
|
+
` groupId: POC_GROUP_ID`,
|
|
472
|
+
` deviceIds: POC_DEVICE_IDS`,
|
|
473
|
+
` confirmDeletion: true`,
|
|
474
|
+
`confirmDeletion:true is correct — this removal is an intentional step in this workflow.`,
|
|
475
|
+
``,
|
|
476
|
+
`Call: add_devices_to_group`,
|
|
477
|
+
` groupId: DEFAULT_GROUP_ID`,
|
|
478
|
+
` deviceIds: POC_DEVICE_IDS`,
|
|
479
|
+
``,
|
|
480
|
+
`─── STEP 5 — Identify and process POC user accounts ────────────────────`,
|
|
481
|
+
`Call: list_users`,
|
|
482
|
+
` tag: "${pocTag}"`,
|
|
483
|
+
` outputFormat: "json"`,
|
|
484
|
+
``,
|
|
485
|
+
`This returns only users who were tagged with "${pocTag}" during create_poc.`,
|
|
486
|
+
`Users added to the project after POC creation will not have this tag and are not affected.`,
|
|
487
|
+
``,
|
|
488
|
+
`For each returned user, inspect their "roles" field (a map of role → [project names]).`,
|
|
489
|
+
`The exact shape is: {"<roleName>": ["<projectName>", ...], ...} — for example:`,
|
|
490
|
+
` "roles": { "ProjectAdmin": ["${pocName}"], "User": ["QA Team", "Staging"] }`,
|
|
491
|
+
`Flatten all project names across all role keys (here: ["${pocName}", "QA Team", "Staging"])`,
|
|
492
|
+
`and remove "${pocName}" from the list.`,
|
|
493
|
+
`If a user's roles field is missing or not in this shape, STOP and show the raw record`,
|
|
494
|
+
`to the operator — do not guess a classification that leads to account deletion.`,
|
|
495
|
+
``,
|
|
496
|
+
` • If the remaining project list is EMPTY → user belongs only to this POC → ELIGIBLE FOR DELETION`,
|
|
497
|
+
` • If the remaining project list is NON-EMPTY → user belongs to other projects → DO NOT DELETE`,
|
|
498
|
+
` Instead, only remove them from the POC project.`,
|
|
499
|
+
``,
|
|
500
|
+
`Present the full list to the operator as a summary table with the recommended action:`,
|
|
501
|
+
` Name | Email | Other Projects | Action`,
|
|
502
|
+
` e.g. "Jane Doe | jane@co.com | (none) | Delete account"`,
|
|
503
|
+
` e.g. "Bob Smith | bob@co.com | QA Team, Staging | Remove from POC only"`,
|
|
504
|
+
``,
|
|
505
|
+
`⚠️ IMPORTANT — Per-user confirmation is REQUIRED before acting on each account.`,
|
|
506
|
+
`Although the tag filter is reliable, an admin may have temporarily added themselves`,
|
|
507
|
+
`to the POC project (e.g. to impersonate a user), which could cause them to be`,
|
|
508
|
+
`inadvertently caught in the tag filter if they were also tagged. Review each user`,
|
|
509
|
+
`individually before proceeding.`,
|
|
510
|
+
``,
|
|
511
|
+
`For EACH user in the list, in sequence:`,
|
|
512
|
+
``,
|
|
513
|
+
` 1. Display the user record and recommended action:`,
|
|
514
|
+
` Name : <firstName> <lastName>`,
|
|
515
|
+
` Email : <email>`,
|
|
516
|
+
` Other projects: <list, or "(none)" if POC-only>`,
|
|
517
|
+
` Recommended : <"Delete account" or "Remove from POC only">`,
|
|
518
|
+
``,
|
|
519
|
+
` 2. Ask the operator: "<recommended action>? (yes / skip)"`,
|
|
520
|
+
` — Wait for an explicit answer before proceeding.`,
|
|
521
|
+
` — If the operator says SKIP: record the user as skipped and move on.`,
|
|
522
|
+
``,
|
|
523
|
+
` 3a. If user is POC-only AND operator confirms YES:`,
|
|
524
|
+
` Call: delete_user`,
|
|
525
|
+
` userId: <user ID>`,
|
|
526
|
+
` confirmDeletion: true`,
|
|
527
|
+
` This cannot be undone. If this call fails, record it and continue.`,
|
|
528
|
+
``,
|
|
529
|
+
` 3b. If user has other projects AND operator confirms YES:`,
|
|
530
|
+
` Call: remove_user_from_project`,
|
|
531
|
+
` projectId: POC_PROJECT_ID`,
|
|
532
|
+
` userId: <user ID>`,
|
|
533
|
+
` confirmDeletion: true`,
|
|
534
|
+
` This only removes their access to the POC project — their account and`,
|
|
535
|
+
` membership in all other projects is preserved.`,
|
|
536
|
+
` If this call fails, record it and continue.`,
|
|
537
|
+
``,
|
|
538
|
+
`Record each user's outcome (deleted / removed from POC / skipped / failed) in the completion summary.`,
|
|
539
|
+
``,
|
|
540
|
+
`═══════════════════════════════════════════════`,
|
|
541
|
+
`COMPLETION SUMMARY`,
|
|
542
|
+
`═══════════════════════════════════════════════`,
|
|
543
|
+
` ✅ POC Name : ${pocName}`,
|
|
544
|
+
` ✅ Devices moved : <count> moved from "${pocName}" group back to Default`,
|
|
545
|
+
` ✅ POC tag removed : "${pocTag}" removed from <count> devices`,
|
|
546
|
+
` ✅ Users — for each user list outcome:`,
|
|
547
|
+
` Deleted : <count> (POC-only accounts permanently removed)`,
|
|
548
|
+
` Removed from POC : <count> (multi-project accounts — access revoked, account preserved)`,
|
|
549
|
+
` Skipped : <count> (operator chose to skip)`,
|
|
550
|
+
` ⚠️ Project and device group "${pocName}" still exist — run delete_poc to remove them.`,
|
|
551
|
+
` ⚠️ Any warnings or individual step failures`,
|
|
552
|
+
].join('\n');
|
|
553
|
+
return { content: [{ type: 'text', text: instructions }] };
|
|
554
|
+
});
|
|
555
|
+
// ─── delete_poc ────────────────────────────────────────────────────────────
|
|
556
|
+
server.tool('delete_poc', 'Guided workflow for full POC teardown: untags devices, moves them back to the Default group, permanently deletes all POC-tagged user accounts, then deletes the POC device group and project. Requires confirmDeletion: true. Presents a full pre-deletion inventory before any destructive action occurs.', {
|
|
557
|
+
customerName: z
|
|
558
|
+
.string()
|
|
559
|
+
.describe('Customer name exactly as used when the POC was created (e.g. "Acme Corp"). Used to derive the POC project name and device tag.'),
|
|
560
|
+
confirmDeletion: z
|
|
561
|
+
.boolean()
|
|
562
|
+
.describe('Must be true to receive the workflow instructions. Without this, no changes are made. The workflow will still present a pre-deletion inventory and require operator confirmation before any delete call.'),
|
|
563
|
+
}, ({ customerName, confirmDeletion }) => {
|
|
564
|
+
const guard = preflightCheck('delete_poc');
|
|
565
|
+
if (guard)
|
|
566
|
+
return guard;
|
|
567
|
+
const pocName = `${customerName.trim()} POC`;
|
|
568
|
+
const pocTag = customerName.toLowerCase().replace(/[^a-z0-9]/g, '') + 'poc';
|
|
569
|
+
if (confirmDeletion !== true) {
|
|
570
|
+
return {
|
|
571
|
+
content: [{
|
|
572
|
+
type: 'text',
|
|
573
|
+
text: [
|
|
574
|
+
`⚠️ Safety guard triggered.`,
|
|
575
|
+
``,
|
|
576
|
+
`"Delete POC \\"${pocName}\\"" permanently removes the device group and project and cannot be undone.`,
|
|
577
|
+
``,
|
|
578
|
+
`To proceed with full deletion, call delete_poc again with confirmDeletion: true.`,
|
|
579
|
+
``,
|
|
580
|
+
`💡 Best practice: Consider running close_poc first instead.`,
|
|
581
|
+
` close_poc safely winds down the POC — it returns devices to the Default group,`,
|
|
582
|
+
` removes the POC device tag, and revokes user access — without permanently deleting`,
|
|
583
|
+
` the project or device group. The data is preserved and the teardown is fully reversible.`,
|
|
584
|
+
` You can always run delete_poc later once you are confident nothing needs to be recovered.`,
|
|
585
|
+
``,
|
|
586
|
+
`No changes were made.`,
|
|
587
|
+
].join('\n'),
|
|
588
|
+
}],
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
const instructions = [
|
|
592
|
+
`You are executing a guided POC deletion workflow. Work through each step in order.`,
|
|
593
|
+
`This workflow permanently deletes the POC device group and project. It cannot be undone.`,
|
|
594
|
+
``,
|
|
595
|
+
`═══════════════════════════════════════════════`,
|
|
596
|
+
`CONFIRMED PARAMETERS`,
|
|
597
|
+
`═══════════════════════════════════════════════`,
|
|
598
|
+
`POC Name : ${pocName}`,
|
|
599
|
+
`POC Tag : ${pocTag}`,
|
|
600
|
+
``,
|
|
601
|
+
`─── STEP 0 — Gather inventory and confirm with operator ──────────────────`,
|
|
602
|
+
`Before executing anything, collect the full picture of what will be affected:`,
|
|
603
|
+
``,
|
|
604
|
+
` a. Call: list_projects`,
|
|
605
|
+
` outputFormat: "json"`,
|
|
606
|
+
` Find "${pocName}", note POC_PROJECT_ID.`,
|
|
607
|
+
` If not found, stop and report: "POC project not found — nothing to delete."`,
|
|
608
|
+
``,
|
|
609
|
+
` b. Call: list_device_groups`,
|
|
610
|
+
` outputFormat: "json"`,
|
|
611
|
+
` Find "${pocName}", note POC_GROUP_ID.`,
|
|
612
|
+
` Also find "Default" and note DEFAULT_GROUP_ID.`,
|
|
613
|
+
` If POC_GROUP_ID is not found, note this — Steps 1 and 2 will be skipped.`,
|
|
614
|
+
``,
|
|
615
|
+
` c. Call: get_devices_in_group`,
|
|
616
|
+
` groupId: POC_GROUP_ID`,
|
|
617
|
+
` outputFormat: "json"`,
|
|
618
|
+
` Record device count and names as POC_DEVICE_IDS.`,
|
|
619
|
+
``,
|
|
620
|
+
` d. Call: list_users`,
|
|
621
|
+
` tag: "${pocTag}"`,
|
|
622
|
+
` outputFormat: "json"`,
|
|
623
|
+
` These are POC_USERS — accounts tagged during create_poc.`,
|
|
624
|
+
` Any users added to the project after POC creation will not have this tag`,
|
|
625
|
+
` and are treated as OTHER_USERS (not affected by this workflow).`,
|
|
626
|
+
``,
|
|
627
|
+
` For each POC_USER, inspect their "roles" field and flatten all project names.`,
|
|
628
|
+
` The shape is {"<roleName>": ["<projectName>", ...]} — e.g.`,
|
|
629
|
+
` "roles": { "ProjectAdmin": ["${pocName}"], "User": ["QA Team"] } → ["${pocName}", "QA Team"]`,
|
|
630
|
+
` Remove "${pocName}" from the list.`,
|
|
631
|
+
` • If the remaining list is EMPTY → user is POC-only → classify as DELETE_USERS`,
|
|
632
|
+
` • If the remaining list is NON-EMPTY → user has other projects → classify as REVOKE_USERS`,
|
|
633
|
+
` If a user's roles field is missing or not in this shape, classify them as REVOKE_USERS`,
|
|
634
|
+
` (the safe action) and flag the raw record to the operator in the Step 0 inventory.`,
|
|
635
|
+
``,
|
|
636
|
+
`Present this pre-deletion inventory to the operator and require explicit confirmation`,
|
|
637
|
+
`before proceeding. Do not continue until the operator confirms:`,
|
|
638
|
+
``,
|
|
639
|
+
` WILL BE PERMANENTLY DELETED:`,
|
|
640
|
+
` • Device group : "${pocName}" (ID: <POC_GROUP_ID>)`,
|
|
641
|
+
` • Project : "${pocName}" (ID: <POC_PROJECT_ID>)`,
|
|
642
|
+
` • <count> user accounts (POC-only, no other projects): <list names>`,
|
|
643
|
+
``,
|
|
644
|
+
` WILL HAVE POC ACCESS REVOKED (account preserved):`,
|
|
645
|
+
` • <count> user accounts with other project memberships: <list names + their other projects>`,
|
|
646
|
+
``,
|
|
647
|
+
` WILL BE MODIFIED (reversible):`,
|
|
648
|
+
` • <count> devices — POC tag removed, moved back to Default group`,
|
|
649
|
+
``,
|
|
650
|
+
` NOT AFFECTED:`,
|
|
651
|
+
` • Users in the POC project without the "${pocTag}" tag (added after POC creation)`,
|
|
652
|
+
``,
|
|
653
|
+
`Only proceed past Step 0 when the operator gives explicit confirmation.`,
|
|
654
|
+
``,
|
|
655
|
+
`─── STEP 1 — Remove the POC tag from each device ────────────────────────`,
|
|
656
|
+
`For each device in POC_DEVICE_IDS, call: remove_device_tag`,
|
|
657
|
+
` deviceId: <device ID>`,
|
|
658
|
+
` tag: "${pocTag}"`,
|
|
659
|
+
`Only remove the "${pocTag}" tag — leave all other tags untouched.`,
|
|
660
|
+
`If a call fails, record it and continue — do not abort.`,
|
|
661
|
+
``,
|
|
662
|
+
`─── STEP 2 — Move devices from POC group to Default group ───────────────`,
|
|
663
|
+
`Call: remove_devices_from_group`,
|
|
664
|
+
` groupId: POC_GROUP_ID`,
|
|
665
|
+
` deviceIds: POC_DEVICE_IDS`,
|
|
666
|
+
` confirmDeletion: true`,
|
|
667
|
+
``,
|
|
668
|
+
`Call: add_devices_to_group`,
|
|
669
|
+
` groupId: DEFAULT_GROUP_ID`,
|
|
670
|
+
` deviceIds: POC_DEVICE_IDS`,
|
|
671
|
+
``,
|
|
672
|
+
`─── STEP 3 — Process POC user accounts ─────────────────────────────────`,
|
|
673
|
+
`POC_USERS were classified in Step 0d into DELETE_USERS and REVOKE_USERS.`,
|
|
674
|
+
`The operator confirmed the full inventory in Step 0 — do NOT ask for per-user`,
|
|
675
|
+
`confirmation here. Process all users in sequence without pausing.`,
|
|
676
|
+
``,
|
|
677
|
+
`For each user in DELETE_USERS (POC-only, no other projects):`,
|
|
678
|
+
` Call: delete_user`,
|
|
679
|
+
` userId: <user ID>`,
|
|
680
|
+
` confirmDeletion: true`,
|
|
681
|
+
` The Step 0 inventory confirmation covers this batch.`,
|
|
682
|
+
` If a call fails, record it and continue — do not abort.`,
|
|
683
|
+
``,
|
|
684
|
+
`For each user in REVOKE_USERS (has other project memberships):`,
|
|
685
|
+
` Call: remove_user_from_project`,
|
|
686
|
+
` projectId: POC_PROJECT_ID`,
|
|
687
|
+
` userId: <user ID>`,
|
|
688
|
+
` confirmDeletion: true`,
|
|
689
|
+
` This removes their access to the POC project only — their account and`,
|
|
690
|
+
` memberships in all other projects are fully preserved.`,
|
|
691
|
+
` If a call fails, record it and continue — do not abort.`,
|
|
692
|
+
``,
|
|
693
|
+
`Do not touch OTHER_USERS — they were added to the project after the POC was created.`,
|
|
694
|
+
``,
|
|
695
|
+
`─── STEP 4 — Delete the POC device group ────────────────────────────────`,
|
|
696
|
+
`PRECONDITION: only proceed if the Step 2 add_devices_to_group call succeeded.`,
|
|
697
|
+
`If it failed or you are unsure, call get_devices_in_group on DEFAULT_GROUP_ID and`,
|
|
698
|
+
`verify every device in POC_DEVICE_IDS is present — deleting the group while`,
|
|
699
|
+
`devices never made it back to Default orphans them with no group membership.`,
|
|
700
|
+
``,
|
|
701
|
+
`Call: delete_device_group`,
|
|
702
|
+
` groupId: POC_GROUP_ID`,
|
|
703
|
+
` confirmDeletion: true`,
|
|
704
|
+
``,
|
|
705
|
+
`─── STEP 5 — Delete the POC project ─────────────────────────────────────`,
|
|
706
|
+
`Call: delete_project`,
|
|
707
|
+
` projectId: POC_PROJECT_ID`,
|
|
708
|
+
` deleteUsers: false`,
|
|
709
|
+
` confirmDeletion: true`,
|
|
710
|
+
`deleteUsers:false — POC user accounts were already permanently deleted in Step 3.`,
|
|
711
|
+
``,
|
|
712
|
+
`═══════════════════════════════════════════════`,
|
|
713
|
+
`COMPLETION SUMMARY`,
|
|
714
|
+
`═══════════════════════════════════════════════`,
|
|
715
|
+
` ✅ POC tag removed : "${pocTag}" removed from <count> devices`,
|
|
716
|
+
` ✅ Devices moved : <count> moved to Default group`,
|
|
717
|
+
` ✅ Users deleted : <count> permanently deleted (POC-only accounts, list names)`,
|
|
718
|
+
` ✅ Users POC access revoked: <count> removed from POC project only (multi-project, list names)`,
|
|
719
|
+
` ✅ Device group : "${pocName}" permanently deleted`,
|
|
720
|
+
` ✅ Project : "${pocName}" permanently deleted`,
|
|
721
|
+
` ⚠️ Any warnings or individual step failures`,
|
|
722
|
+
].join('\n');
|
|
723
|
+
return { content: [{ type: 'text', text: instructions }] };
|
|
724
|
+
});
|
|
725
|
+
// ─── setup_project ─────────────────────────────────────────────────────────
|
|
726
|
+
server.tool('setup_project', 'Guided workflow to set up a project environment. Starts by asking whether the user wants a simple project record or a fully provisioned environment (device group, device allocation, user provisioning, app assignment). The full path mirrors the POC workflow but is generalized for any project type, with an optional memo in place of a Salesforce URL and a choice of whether to isolate devices exclusively for this project.', {
|
|
727
|
+
projectName: z
|
|
728
|
+
.string()
|
|
729
|
+
.describe('Name of the project to create.'),
|
|
730
|
+
region: z
|
|
731
|
+
.string()
|
|
732
|
+
.optional()
|
|
733
|
+
.describe('Region code for device selection, e.g. "US2", "SG1". Required for the full setup path.'),
|
|
734
|
+
deviceCount: z
|
|
735
|
+
.number().int().min(1).max(50)
|
|
736
|
+
.optional()
|
|
737
|
+
.describe('Total number of phones to allocate (full path only, default: 6).'),
|
|
738
|
+
iosCount: z.number().int().min(0).optional().describe('Number of iOS phones (default: ceil(deviceCount/2)).'),
|
|
739
|
+
androidCount: z.number().int().min(0).optional().describe('Number of Android phones (default: floor(deviceCount/2)).'),
|
|
740
|
+
automationType: z
|
|
741
|
+
.enum(['appium-server', 'appium-grid'])
|
|
742
|
+
.optional()
|
|
743
|
+
.describe('"appium-server" (default) or "appium-grid".'),
|
|
744
|
+
projectMemo: z
|
|
745
|
+
.string()
|
|
746
|
+
.optional()
|
|
747
|
+
.describe('Optional free-text memo recorded in the project notes (replaces the Salesforce URL used in POC workflows).'),
|
|
748
|
+
isolateDevices: z
|
|
749
|
+
.boolean()
|
|
750
|
+
.optional()
|
|
751
|
+
.describe('If true, allocated devices will be removed from ALL other device groups (not just Default) to ensure exclusive availability. Default: false — only removes from the Default group, same as the POC workflow.'),
|
|
752
|
+
users: z
|
|
753
|
+
.array(z.object({
|
|
754
|
+
email: z.string(),
|
|
755
|
+
firstName: z.string(),
|
|
756
|
+
lastName: z.string(),
|
|
757
|
+
role: z.enum(['User', 'ProjectAdmin']),
|
|
758
|
+
}))
|
|
759
|
+
.optional()
|
|
760
|
+
.describe('Users to create or add (full path only). Each user is tagged and assigned exclusively to this project.'),
|
|
761
|
+
appName: z.string().optional().describe('Display name of the app to assign (full path only, default: "ExperiBank").'),
|
|
762
|
+
androidPackageName: z.string().optional().describe('Android package name for app lookup (default: "com.experitest.ExperiBank").'),
|
|
763
|
+
iosBundleId: z.string().optional().describe('iOS bundle ID for app lookup (default: "com.experitest.ExperiBank").'),
|
|
764
|
+
}, ({ projectName, region, deviceCount, iosCount, androidCount, automationType, projectMemo, isolateDevices, users, appName, androidPackageName, iosBundleId }) => {
|
|
765
|
+
const guard = preflightCheck('setup_project');
|
|
766
|
+
if (guard)
|
|
767
|
+
return guard;
|
|
768
|
+
const projTag = projectName.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
769
|
+
const appiumOSS = (automationType ?? 'appium-server') !== 'appium-grid';
|
|
770
|
+
const total = deviceCount ?? 6;
|
|
771
|
+
const ios = iosCount ?? Math.ceil(total / 2);
|
|
772
|
+
const android = androidCount ?? Math.floor(total / 2);
|
|
773
|
+
const targetAppName = appName ?? 'ExperiBank';
|
|
774
|
+
const targetAndroidPkg = androidPackageName ?? 'com.experitest.ExperiBank';
|
|
775
|
+
const targetIosBundleId = iosBundleId ?? 'com.experitest.ExperiBank';
|
|
776
|
+
const isFullSetup = !!(region || deviceCount || users?.length);
|
|
777
|
+
const instructions = [
|
|
778
|
+
`You are executing a guided project setup workflow.`,
|
|
779
|
+
``,
|
|
780
|
+
`═══════════════════════════════════════════════`,
|
|
781
|
+
`CONFIRMED PARAMETERS`,
|
|
782
|
+
`═══════════════════════════════════════════════`,
|
|
783
|
+
`Project Name : ${projectName}`,
|
|
784
|
+
`Project Tag : ${projTag} (used to identify devices and users belonging to this project)`,
|
|
785
|
+
`Memo : ${projectMemo ?? '(none)'}`,
|
|
786
|
+
``,
|
|
787
|
+
`─── STEP 0 — Confirm setup scope ────────────────────────────────────────`,
|
|
788
|
+
isFullSetup
|
|
789
|
+
? [
|
|
790
|
+
`Full setup parameters were provided. Confirm the following with the operator before proceeding:`,
|
|
791
|
+
``,
|
|
792
|
+
` Project Name : ${projectName}`,
|
|
793
|
+
` Project Tag : ${projTag}`,
|
|
794
|
+
` Region : ${region ?? '(not specified — device selection will not filter by region)'}`,
|
|
795
|
+
` Device Mix : ${total} phones (${ios} iOS + ${android} Android)`,
|
|
796
|
+
` Automation Type : ${appiumOSS ? 'Appium Server (appiumOSS: true)' : 'Appium Grid (appiumOSS: false)'}`,
|
|
797
|
+
` Device Isolation: ${isolateDevices ? 'YES — devices removed from ALL other groups' : 'NO — only removed from Default group'}`,
|
|
798
|
+
` Memo : ${projectMemo ?? '(none)'}`,
|
|
799
|
+
` Users : ${users?.length ?? 0}`,
|
|
800
|
+
...(users ?? []).map((u, i) => ` User ${i + 1}: ${u.firstName} ${u.lastName} <${u.email}> — ${u.role}`),
|
|
801
|
+
``,
|
|
802
|
+
`If the operator wants to change anything, stop and collect corrections.`,
|
|
803
|
+
`Only proceed when the operator confirms.`,
|
|
804
|
+
].join('\n')
|
|
805
|
+
: [
|
|
806
|
+
`No device or user parameters were provided. Ask the operator:`,
|
|
807
|
+
``,
|
|
808
|
+
` "Would you like to:`,
|
|
809
|
+
` A) Create a simple project record only (no device group, no users, no app assignment)`,
|
|
810
|
+
` B) Fully provision the project environment (device group, devices, users, app assignment)"`,
|
|
811
|
+
``,
|
|
812
|
+
` If A: proceed only to Step 1 (create project + memo), then stop.`,
|
|
813
|
+
` If B: ask the operator to provide:`,
|
|
814
|
+
` • Region code (e.g. "US2", "SG1")`,
|
|
815
|
+
` • Device count and iOS/Android split`,
|
|
816
|
+
` • Device isolation preference (remove from Default only, or from ALL other groups)`,
|
|
817
|
+
` • User list (email, firstName, lastName, role)`,
|
|
818
|
+
` • App name / package name (or use ExperiBank default)`,
|
|
819
|
+
` Then re-invoke setup_project with the collected parameters.`,
|
|
820
|
+
].join('\n'),
|
|
821
|
+
``,
|
|
822
|
+
`─── STEP 1 — Create or reuse the project ────────────────────────────────`,
|
|
823
|
+
`Call: list_projects`,
|
|
824
|
+
` outputFormat: "json"`,
|
|
825
|
+
`If a project named exactly "${projectName}" already exists, note its ID as PROJECT_ID and skip creation.`,
|
|
826
|
+
``,
|
|
827
|
+
`Otherwise call: create_project`,
|
|
828
|
+
` name: "${projectName}"`,
|
|
829
|
+
` appiumOSS: ${appiumOSS}`,
|
|
830
|
+
`SAVE the returned project ID as PROJECT_ID.`,
|
|
831
|
+
``,
|
|
832
|
+
`In both cases call: set_project_notes`,
|
|
833
|
+
` projectId: PROJECT_ID`,
|
|
834
|
+
` notes: "${projectMemo ?? ''}"`,
|
|
835
|
+
``,
|
|
836
|
+
`If the operator chose simple setup (Step 0 option A), stop here and report:`,
|
|
837
|
+
` ✅ Project "${projectName}" created (ID: PROJECT_ID)${projectMemo ? ` — memo recorded` : ''}.`,
|
|
838
|
+
` No device group, devices, or users were provisioned.`,
|
|
839
|
+
``,
|
|
840
|
+
`Otherwise continue with Steps 2–9 for full provisioning.`,
|
|
841
|
+
``,
|
|
842
|
+
`─── STEP 2 — Create or reuse a device group and link it to the project ──`,
|
|
843
|
+
`Call: list_device_groups outputFormat: "json"`,
|
|
844
|
+
`If a group named exactly "${projectName}" exists, note its ID as PROJECT_GROUP_ID.`,
|
|
845
|
+
`Otherwise call: create_device_group name: "${projectName}" acceptNewDevices: false`,
|
|
846
|
+
`SAVE the ID as PROJECT_GROUP_ID.`,
|
|
847
|
+
``,
|
|
848
|
+
`Then link the group to the project — REQUIRED. Without this, devices added to`,
|
|
849
|
+
`the group are not accessible to the project:`,
|
|
850
|
+
`Call: assign_group_to_project projectId: PROJECT_ID deviceGroupId: PROJECT_GROUP_ID`,
|
|
851
|
+
``,
|
|
852
|
+
`Also find the group named "Default" and note its ID as DEFAULT_GROUP_ID.`,
|
|
853
|
+
``,
|
|
854
|
+
`─── STEP 3 — App pre-flight check ───────────────────────────────────────`,
|
|
855
|
+
android > 0 ? `Android: call list_applications packageName: "${targetAndroidPkg}" — note ANDROID_APP_ID if found.` : '',
|
|
856
|
+
ios > 0 ? `iOS: call list_applications bundleIdentifier: "${targetIosBundleId}" — note IOS_APP_ID if found.` : '',
|
|
857
|
+
``,
|
|
858
|
+
`─── STEP 4 — Select devices ─────────────────────────────────────────────`,
|
|
859
|
+
`Call: get_devices_in_group`,
|
|
860
|
+
` groupId: DEFAULT_GROUP_ID`,
|
|
861
|
+
` category: "PHONE"`,
|
|
862
|
+
` status: "Available"`,
|
|
863
|
+
` excludeTags: ["DoNotTake", "DONTTAKE", "DONOTUSE"]`,
|
|
864
|
+
` outputFormat: "json"`,
|
|
865
|
+
``,
|
|
866
|
+
region ? `Apply additional client-side filter: region contains "${region}" (case-insensitive).` : `No region filter specified — select from all available phones.`,
|
|
867
|
+
`Also exclude devices whose tags contain "${projTag}" (already in this project) or "poc" (in an active POC).`,
|
|
868
|
+
``,
|
|
869
|
+
`Target mix: ${total} phones (${ios} iOS + ${android} Android). Prefer recent models.`,
|
|
870
|
+
`Present proposed selection as a table and wait for operator confirmation.`,
|
|
871
|
+
`Save confirmed IDs as SELECTED_DEVICE_IDS.`,
|
|
872
|
+
``,
|
|
873
|
+
`─── STEP 5 — Add devices to the project group ───────────────────────────`,
|
|
874
|
+
`Call: add_devices_to_group groupId: PROJECT_GROUP_ID deviceIds: SELECTED_DEVICE_IDS`,
|
|
875
|
+
``,
|
|
876
|
+
`─── STEP 6 — Tag devices ────────────────────────────────────────────────`,
|
|
877
|
+
`For each device in SELECTED_DEVICE_IDS that does not already have the tag "${projTag}":`,
|
|
878
|
+
` Call: add_device_tag deviceId: <id> tag: "${projTag}"`,
|
|
879
|
+
``,
|
|
880
|
+
`─── STEP 7 — Remove devices from other groups ───────────────────────────`,
|
|
881
|
+
isolateDevices
|
|
882
|
+
? [
|
|
883
|
+
`Device isolation is ENABLED — remove devices from ALL other groups.`,
|
|
884
|
+
`For each device in SELECTED_DEVICE_IDS:`,
|
|
885
|
+
` Call: get_device_detail deviceId: <id> outputFormat: "json"`,
|
|
886
|
+
` This returns a deviceGroups object (groupId → groupName).`,
|
|
887
|
+
` For each group ID in deviceGroups OTHER THAN PROJECT_GROUP_ID:`,
|
|
888
|
+
` Call: remove_devices_from_group groupId: <other group ID> deviceIds: [<device id>] confirmDeletion: true`,
|
|
889
|
+
`This ensures the device is exclusively available in the "${projectName}" group.`,
|
|
890
|
+
].join('\n')
|
|
891
|
+
: `Device isolation is DISABLED — existing group memberships (including Default) are left untouched.`,
|
|
892
|
+
``,
|
|
893
|
+
`─── STEP 8 — Create and assign users ────────────────────────────────────`,
|
|
894
|
+
`For each user, execute sub-steps a → b → c → d in order:`,
|
|
895
|
+
``,
|
|
896
|
+
...(users ?? []).map((u, i) => ` User ${i + 1}: ${u.firstName} ${u.lastName} <${u.email}> — ${u.role}`),
|
|
897
|
+
users?.length ? `` : ` (No users specified — skip this step.)`,
|
|
898
|
+
``,
|
|
899
|
+
` a. Call: create_user username: <email> firstName/lastName/email: as above`,
|
|
900
|
+
` role: <role> authenticationType: "BASIC" → SAVE as USER_ID`,
|
|
901
|
+
` b. Call: assign_user_to_project projectId: PROJECT_ID userId: USER_ID role: <role>`,
|
|
902
|
+
` c. Call: remove_user_from_project projectId: DEFAULT_PROJECT_ID userId: USER_ID confirmDeletion: true`,
|
|
903
|
+
` (Call list_projects first if DEFAULT_PROJECT_ID is not yet known.)`,
|
|
904
|
+
` d. Call: set_user_tags userId: USER_ID tags: ["${projTag}"]`,
|
|
905
|
+
` ⚠️ Required — without this tag, close_project_resources and teardown_project`,
|
|
906
|
+
` cannot auto-identify this user for cleanup.`,
|
|
907
|
+
``,
|
|
908
|
+
`─── STEP 9 — Assign app to project ──────────────────────────────────────`,
|
|
909
|
+
android > 0 ? `If ANDROID_APP_ID known: call assign_app_to_project projectId: PROJECT_ID applicationId: ANDROID_APP_ID` : '',
|
|
910
|
+
ios > 0 ? `If IOS_APP_ID known: call assign_app_to_project projectId: PROJECT_ID applicationId: IOS_APP_ID` : '',
|
|
911
|
+
``,
|
|
912
|
+
`IF ANY STEP FAILS: stop, report which steps completed with all created resource IDs`,
|
|
913
|
+
`(PROJECT_ID, PROJECT_GROUP_ID, SELECTED_DEVICE_IDS, user IDs). Re-invoking`,
|
|
914
|
+
`setup_project with the same parameters resumes safely — Steps 1 and 2 reuse the`,
|
|
915
|
+
`existing project/group. To unwind instead, run teardown_project.`,
|
|
916
|
+
``,
|
|
917
|
+
`═══════════════════════════════════════════════`,
|
|
918
|
+
`COMPLETION SUMMARY`,
|
|
919
|
+
`═══════════════════════════════════════════════`,
|
|
920
|
+
` ✅ Project : "${projectName}" (ID: PROJECT_ID)`,
|
|
921
|
+
` ✅ Memo : ${projectMemo ? 'recorded' : '(none)'}`,
|
|
922
|
+
` ✅ Device Group : PROJECT_GROUP_ID`,
|
|
923
|
+
` ✅ Devices : <count> allocated — isolation: ${isolateDevices ? 'full (removed from all other groups)' : 'none (existing group links preserved)'}`,
|
|
924
|
+
` ✅ Tag applied : "${projTag}"`,
|
|
925
|
+
` ✅ Users : <count> — list names and tag status`,
|
|
926
|
+
` ✅ App : ${targetAppName} assigned (or ⚠️ not found)`,
|
|
927
|
+
` ⚠️ Any warnings or failures`,
|
|
928
|
+
].filter(s => s != null).join('\n');
|
|
929
|
+
return { content: [{ type: 'text', text: instructions }] };
|
|
930
|
+
});
|
|
931
|
+
// ─── close_project_resources ───────────────────────────────────────────────
|
|
932
|
+
server.tool('close_project_resources', 'Guided workflow to wind down a project environment: removes the project tag from devices, returns devices to the Default group, and removes user access (deleting accounts with no other project memberships; revoking only POC access for multi-project users). Does not delete the project or device group — use teardown_project for full removal.', {
|
|
933
|
+
projectName: z
|
|
934
|
+
.string()
|
|
935
|
+
.describe('Exact project name as used when the project was created.'),
|
|
936
|
+
}, ({ projectName }) => {
|
|
937
|
+
const guard = preflightCheck('close_project_resources');
|
|
938
|
+
if (guard)
|
|
939
|
+
return guard;
|
|
940
|
+
const projTag = projectName.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
941
|
+
const instructions = [
|
|
942
|
+
`You are executing a guided project close-down workflow.`,
|
|
943
|
+
`This returns devices to the Default group and removes user access.`,
|
|
944
|
+
`The project and device group are preserved — run teardown_project to delete them.`,
|
|
945
|
+
``,
|
|
946
|
+
`═══════════════════════════════════════════════`,
|
|
947
|
+
`CONFIRMED PARAMETERS`,
|
|
948
|
+
`═══════════════════════════════════════════════`,
|
|
949
|
+
`Project Name : ${projectName}`,
|
|
950
|
+
`Project Tag : ${projTag}`,
|
|
951
|
+
``,
|
|
952
|
+
`─── STEP 0 — Operator confirmation ──────────────────────────────────────`,
|
|
953
|
+
`Present parameters and wait for explicit confirmation before proceeding.`,
|
|
954
|
+
``,
|
|
955
|
+
`─── STEP 1 — Locate project, device group, and Default group ────────────`,
|
|
956
|
+
`Call: list_projects outputFormat: "json"`,
|
|
957
|
+
`Find "${projectName}" → PROJECT_ID. If not found, stop: "Project not found."`,
|
|
958
|
+
``,
|
|
959
|
+
`Call: list_device_groups outputFormat: "json"`,
|
|
960
|
+
`Find "${projectName}" → PROJECT_GROUP_ID (may not exist — Steps 2–4 skipped if absent).`,
|
|
961
|
+
`Find "Default" → DEFAULT_GROUP_ID.`,
|
|
962
|
+
``,
|
|
963
|
+
`─── STEP 2 — Get devices in the project group ───────────────────────────`,
|
|
964
|
+
`If PROJECT_GROUP_ID was found:`,
|
|
965
|
+
` Call: get_devices_in_group groupId: PROJECT_GROUP_ID outputFormat: "json"`,
|
|
966
|
+
` Save all device IDs as PROJECT_DEVICE_IDS.`,
|
|
967
|
+
` Show the device list to the operator before continuing.`,
|
|
968
|
+
``,
|
|
969
|
+
`─── STEP 3 — Remove the project tag from each device ────────────────────`,
|
|
970
|
+
`For each device in PROJECT_DEVICE_IDS:`,
|
|
971
|
+
` Call: remove_device_tag deviceId: <id> tag: "${projTag}"`,
|
|
972
|
+
`Only remove "${projTag}" — all other tags are left untouched.`,
|
|
973
|
+
``,
|
|
974
|
+
`─── STEP 4 — Move devices back to Default group ─────────────────────────`,
|
|
975
|
+
`Call: remove_devices_from_group groupId: PROJECT_GROUP_ID deviceIds: PROJECT_DEVICE_IDS confirmDeletion: true`,
|
|
976
|
+
`Call: add_devices_to_group groupId: DEFAULT_GROUP_ID deviceIds: PROJECT_DEVICE_IDS`,
|
|
977
|
+
``,
|
|
978
|
+
`─── STEP 5 — Identify and process project user accounts ─────────────────`,
|
|
979
|
+
`Call: list_users tag: "${projTag}" outputFormat: "json"`,
|
|
980
|
+
``,
|
|
981
|
+
`For each returned user, inspect their "roles" field. The shape is`,
|
|
982
|
+
`{"<roleName>": ["<projectName>", ...]} — e.g.`,
|
|
983
|
+
` "roles": { "ProjectAdmin": ["${projectName}"], "User": ["QA Team"] } → ["${projectName}", "QA Team"]`,
|
|
984
|
+
`Flatten all project names across all role keys and remove "${projectName}" from the list.`,
|
|
985
|
+
`If a user's roles field is missing or not in this shape, STOP and show the raw record`,
|
|
986
|
+
`to the operator — do not guess a classification that leads to account deletion.`,
|
|
987
|
+
` • Remaining list EMPTY → user belongs only to this project → ELIGIBLE FOR DELETION`,
|
|
988
|
+
` • Remaining list NON-EMPTY → user belongs to other projects → REMOVE FROM PROJECT ONLY`,
|
|
989
|
+
``,
|
|
990
|
+
`Present the list with recommended action:`,
|
|
991
|
+
` Name | Email | Other Projects | Action`,
|
|
992
|
+
``,
|
|
993
|
+
`For EACH user, ask the operator to confirm the recommended action (yes / skip).`,
|
|
994
|
+
``,
|
|
995
|
+
` If project-only AND confirmed: call delete_user userId: <id> confirmDeletion: true`,
|
|
996
|
+
` If multi-project AND confirmed: call remove_user_from_project projectId: PROJECT_ID userId: <id> confirmDeletion: true`,
|
|
997
|
+
` If skipped: record and move on.`,
|
|
998
|
+
``,
|
|
999
|
+
`═══════════════════════════════════════════════`,
|
|
1000
|
+
`COMPLETION SUMMARY`,
|
|
1001
|
+
`═══════════════════════════════════════════════`,
|
|
1002
|
+
` ✅ Project tag removed : "${projTag}" removed from <count> devices`,
|
|
1003
|
+
` ✅ Devices moved : <count> returned to Default group`,
|
|
1004
|
+
` ✅ Users deleted : <count> (project-only accounts)`,
|
|
1005
|
+
` ✅ Users removed from project: <count> (multi-project — accounts preserved)`,
|
|
1006
|
+
` ✅ Users skipped : <count>`,
|
|
1007
|
+
` ⚠️ Project and device group "${projectName}" still exist — run teardown_project to remove them.`,
|
|
1008
|
+
` ⚠️ Any failures`,
|
|
1009
|
+
].join('\n');
|
|
1010
|
+
return { content: [{ type: 'text', text: instructions }] };
|
|
1011
|
+
});
|
|
1012
|
+
// ─── teardown_project ──────────────────────────────────────────────────────
|
|
1013
|
+
server.tool('teardown_project', 'Guided workflow for full project removal: untags devices, returns them to Default, handles user accounts (deleting project-only users, revoking access for multi-project users), then permanently deletes the device group and project. Requires confirmDeletion: true. Presents a full pre-deletion inventory before any destructive action.', {
|
|
1014
|
+
projectName: z
|
|
1015
|
+
.string()
|
|
1016
|
+
.describe('Exact project name as used when the project was created.'),
|
|
1017
|
+
confirmDeletion: z
|
|
1018
|
+
.boolean()
|
|
1019
|
+
.describe('Must be true to proceed. Without this, a safety summary is shown and no changes are made.'),
|
|
1020
|
+
}, ({ projectName, confirmDeletion }) => {
|
|
1021
|
+
const guard = preflightCheck('teardown_project');
|
|
1022
|
+
if (guard)
|
|
1023
|
+
return guard;
|
|
1024
|
+
const projTag = projectName.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
1025
|
+
if (confirmDeletion !== true) {
|
|
1026
|
+
return {
|
|
1027
|
+
content: [{
|
|
1028
|
+
type: 'text',
|
|
1029
|
+
text: [
|
|
1030
|
+
`⚠️ Safety guard triggered.`,
|
|
1031
|
+
``,
|
|
1032
|
+
`"Tear down project \\"${projectName}\\"" permanently deletes the device group and project.`,
|
|
1033
|
+
``,
|
|
1034
|
+
`To proceed, call teardown_project again with confirmDeletion: true.`,
|
|
1035
|
+
``,
|
|
1036
|
+
`💡 Consider running close_project_resources first — it safely revokes access and`,
|
|
1037
|
+
` returns devices without permanently deleting the project or group.`,
|
|
1038
|
+
``,
|
|
1039
|
+
`No changes were made.`,
|
|
1040
|
+
].join('\n'),
|
|
1041
|
+
}],
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
const instructions = [
|
|
1045
|
+
`You are executing a guided project teardown workflow.`,
|
|
1046
|
+
`This permanently deletes the project and device group. It cannot be undone.`,
|
|
1047
|
+
``,
|
|
1048
|
+
`═══════════════════════════════════════════════`,
|
|
1049
|
+
`CONFIRMED PARAMETERS`,
|
|
1050
|
+
`═══════════════════════════════════════════════`,
|
|
1051
|
+
`Project Name : ${projectName}`,
|
|
1052
|
+
`Project Tag : ${projTag}`,
|
|
1053
|
+
``,
|
|
1054
|
+
`─── STEP 0 — Gather inventory and confirm with operator ──────────────────`,
|
|
1055
|
+
` a. Call: list_projects outputFormat: "json"`,
|
|
1056
|
+
` Find "${projectName}" → PROJECT_ID. If not found, stop: "Project not found."`,
|
|
1057
|
+
``,
|
|
1058
|
+
` b. Call: list_device_groups outputFormat: "json"`,
|
|
1059
|
+
` Find "${projectName}" → PROJECT_GROUP_ID.`,
|
|
1060
|
+
` Find "Default" → DEFAULT_GROUP_ID.`,
|
|
1061
|
+
``,
|
|
1062
|
+
` c. Call: get_devices_in_group groupId: PROJECT_GROUP_ID outputFormat: "json"`,
|
|
1063
|
+
` Record as PROJECT_DEVICE_IDS.`,
|
|
1064
|
+
``,
|
|
1065
|
+
` d. Call: list_users tag: "${projTag}" outputFormat: "json"`,
|
|
1066
|
+
` For each user, inspect their "roles" field — shape {"<roleName>": ["<projectName>", ...]},`,
|
|
1067
|
+
` e.g. "roles": { "User": ["${projectName}", "QA Team"] }. Flatten all project names,`,
|
|
1068
|
+
` remove "${projectName}" from the list.`,
|
|
1069
|
+
` • Remaining EMPTY → classify as DELETE_USERS`,
|
|
1070
|
+
` • Remaining NON-EMPTY → classify as REVOKE_USERS`,
|
|
1071
|
+
` If a roles field is missing or malformed, classify as REVOKE_USERS (the safe`,
|
|
1072
|
+
` action) and flag the raw record in the Step 0 inventory.`,
|
|
1073
|
+
``,
|
|
1074
|
+
`Present the pre-deletion inventory and require explicit operator confirmation:`,
|
|
1075
|
+
``,
|
|
1076
|
+
` WILL BE PERMANENTLY DELETED:`,
|
|
1077
|
+
` • Device group : "${projectName}" (ID: PROJECT_GROUP_ID)`,
|
|
1078
|
+
` • Project : "${projectName}" (ID: PROJECT_ID)`,
|
|
1079
|
+
` • <count> user accounts (project-only): <names>`,
|
|
1080
|
+
``,
|
|
1081
|
+
` WILL HAVE PROJECT ACCESS REVOKED (account preserved):`,
|
|
1082
|
+
` • <count> users with other project memberships: <names + their other projects>`,
|
|
1083
|
+
``,
|
|
1084
|
+
` WILL BE MODIFIED (reversible):`,
|
|
1085
|
+
` • <count> devices — tag removed, returned to Default group`,
|
|
1086
|
+
``,
|
|
1087
|
+
` NOT AFFECTED:`,
|
|
1088
|
+
` • Users in the project without the "${projTag}" tag`,
|
|
1089
|
+
``,
|
|
1090
|
+
`Only proceed past Step 0 when the operator explicitly confirms.`,
|
|
1091
|
+
``,
|
|
1092
|
+
`─── STEP 1 — Remove project tag from each device ────────────────────────`,
|
|
1093
|
+
`For each device in PROJECT_DEVICE_IDS:`,
|
|
1094
|
+
` Call: remove_device_tag deviceId: <id> tag: "${projTag}"`,
|
|
1095
|
+
``,
|
|
1096
|
+
`─── STEP 2 — Move devices to Default group ──────────────────────────────`,
|
|
1097
|
+
`Call: remove_devices_from_group groupId: PROJECT_GROUP_ID deviceIds: PROJECT_DEVICE_IDS confirmDeletion: true`,
|
|
1098
|
+
`Call: add_devices_to_group groupId: DEFAULT_GROUP_ID deviceIds: PROJECT_DEVICE_IDS`,
|
|
1099
|
+
``,
|
|
1100
|
+
`─── STEP 3 — Process user accounts ──────────────────────────────────────`,
|
|
1101
|
+
`The Step 0 confirmation covers this batch — no per-user pause.`,
|
|
1102
|
+
``,
|
|
1103
|
+
`For each user in DELETE_USERS:`,
|
|
1104
|
+
` Call: delete_user userId: <id> confirmDeletion: true`,
|
|
1105
|
+
``,
|
|
1106
|
+
`For each user in REVOKE_USERS:`,
|
|
1107
|
+
` Call: remove_user_from_project projectId: PROJECT_ID userId: <id> confirmDeletion: true`,
|
|
1108
|
+
` Account and all other project memberships are fully preserved.`,
|
|
1109
|
+
``,
|
|
1110
|
+
`─── STEP 4 — Delete the device group ────────────────────────────────────`,
|
|
1111
|
+
`PRECONDITION: only proceed if the Step 2 add_devices_to_group call succeeded.`,
|
|
1112
|
+
`If it failed or you are unsure, verify with get_devices_in_group on DEFAULT_GROUP_ID`,
|
|
1113
|
+
`that every device in PROJECT_DEVICE_IDS is present — deleting the group while devices`,
|
|
1114
|
+
`never made it back to Default orphans them with no group membership.`,
|
|
1115
|
+
``,
|
|
1116
|
+
`Call: delete_device_group groupId: PROJECT_GROUP_ID confirmDeletion: true`,
|
|
1117
|
+
``,
|
|
1118
|
+
`─── STEP 5 — Delete the project ─────────────────────────────────────────`,
|
|
1119
|
+
`Call: delete_project projectId: PROJECT_ID deleteUsers: false confirmDeletion: true`,
|
|
1120
|
+
`deleteUsers:false — accounts were already handled in Step 3.`,
|
|
1121
|
+
``,
|
|
1122
|
+
`═══════════════════════════════════════════════`,
|
|
1123
|
+
`COMPLETION SUMMARY`,
|
|
1124
|
+
`═══════════════════════════════════════════════`,
|
|
1125
|
+
` ✅ Project tag removed : "${projTag}" removed from <count> devices`,
|
|
1126
|
+
` ✅ Devices returned to Default: <count>`,
|
|
1127
|
+
` ✅ Users deleted : <count> (project-only accounts)`,
|
|
1128
|
+
` ✅ Users — access revoked : <count> (multi-project — accounts preserved)`,
|
|
1129
|
+
` ✅ Device group deleted : "${projectName}"`,
|
|
1130
|
+
` ✅ Project deleted : "${projectName}"`,
|
|
1131
|
+
` ⚠️ Any warnings or failures`,
|
|
1132
|
+
].join('\n');
|
|
1133
|
+
return { content: [{ type: 'text', text: instructions }] };
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
//# sourceMappingURL=workflow-tools.js.map
|