preflite 1.0.1
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 +201 -0
- package/README.md +144 -0
- package/dist/adapter-spi/artifact/index.js +1 -0
- package/dist/adapter-spi/command/index.js +1 -0
- package/dist/adapter-spi/install/index.js +1 -0
- package/dist/adapter-spi/lifecycle/index.js +1 -0
- package/dist/adapter-spi/resource/index.js +1 -0
- package/dist/adapter-spi/snapshot/index.js +1 -0
- package/dist/application/agent/AgentCommandPollLoop.js +48 -0
- package/dist/application/agent/AgentRuntimeService.js +27 -0
- package/dist/application/app-package/AppPackageApplicationService.js +97 -0
- package/dist/application/artifact/ArtifactApplicationService.js +13 -0
- package/dist/application/debug/DebugApplicationService.js +117 -0
- package/dist/application/health/HealthMetricsService.js +47 -0
- package/dist/application/lease/LeaseApplicationService.js +79 -0
- package/dist/application/query/ObservationQueryService.js +48 -0
- package/dist/application/reporter/ReporterApplicationService.js +41 -0
- package/dist/application/resource/ResourceOccupationReleaseService.js +49 -0
- package/dist/application/resource/ResourceRegistryService.js +113 -0
- package/dist/application/session/SessionApplicationService.js +39 -0
- package/dist/application/task/TaskApplicationService.js +378 -0
- package/dist/client/agentAppPackageClient.js +91 -0
- package/dist/domain/agent/AgentNode.js +12 -0
- package/dist/domain/agent/AgentRuntime.js +6 -0
- package/dist/domain/artifact/ArtifactPipeline.js +6 -0
- package/dist/domain/artifact/ArtifactRef.js +12 -0
- package/dist/domain/event/AgentEvent.js +10 -0
- package/dist/domain/event/Reporter.js +6 -0
- package/dist/domain/health/HealthMetrics.js +8 -0
- package/dist/domain/lease/Lease.js +28 -0
- package/dist/domain/lease/LeaseManager.js +6 -0
- package/dist/domain/repositories/index.js +1 -0
- package/dist/domain/resource/DeviceDetails.js +23 -0
- package/dist/domain/resource/DeviceResource.js +16 -0
- package/dist/domain/resource/ResourceRegistry.js +6 -0
- package/dist/domain/runtime/interfaces.js +1 -0
- package/dist/domain/session/BaseSession.js +16 -0
- package/dist/domain/session/DebugSession.js +3 -0
- package/dist/domain/session/ExecutionSession.js +3 -0
- package/dist/domain/session/SessionManager.js +8 -0
- package/dist/domain/task/TaskRecord.js +14 -0
- package/dist/domain/task/TaskSpec.js +12 -0
- package/dist/infrastructure/adapters/AdapterRegistry.js +10 -0
- package/dist/infrastructure/adapters/BridgeAdapters.js +6 -0
- package/dist/infrastructure/adapters/android/AndroidResourceAdapter.js +51 -0
- package/dist/infrastructure/adapters/deviceDetailsProbe.js +229 -0
- package/dist/infrastructure/adapters/harmony/HarmonyResourceAdapter.js +40 -0
- package/dist/infrastructure/adapters/ios/IOSResourceAdapter.js +182 -0
- package/dist/infrastructure/adapters/real/ShellCommandAndSnapshot.js +41 -0
- package/dist/infrastructure/airtest/AirtestRuntime.js +168 -0
- package/dist/infrastructure/app-package/AppPackageUrlCache.js +191 -0
- package/dist/infrastructure/app-package/appPackageDownloadDir.js +13 -0
- package/dist/infrastructure/bootstrap/BuildRuntimeContext.js +88 -0
- package/dist/infrastructure/cache/DirCapacityWatchdog.js +150 -0
- package/dist/infrastructure/config/agentConfigFile.js +96 -0
- package/dist/infrastructure/device/DeviceAppPackageOps.js +146 -0
- package/dist/infrastructure/ios/IOSWdaWatchdog.js +207 -0
- package/dist/infrastructure/live-debug/LiveDebugSessionManager.js +74 -0
- package/dist/infrastructure/live-debug/RuntimeLiveDebugAdapters.js +19 -0
- package/dist/infrastructure/midscene/DebugRuntimeImpl.js +533 -0
- package/dist/infrastructure/midscene/MidsceneRuntimeMock.js +22 -0
- package/dist/infrastructure/midscene/MidsceneRuntimeReal.js +552 -0
- package/dist/infrastructure/midscene/executionDumpWatcher.js +219 -0
- package/dist/infrastructure/midscene/videoRecorder.js +365 -0
- package/dist/infrastructure/midscene/zipReportDir.js +36 -0
- package/dist/infrastructure/persistence/InMemoryRepositories.js +94 -0
- package/dist/infrastructure/resilience/DeliveryIdDeduper.js +26 -0
- package/dist/infrastructure/system/CommandRunner.js +128 -0
- package/dist/infrastructure/transport/http/AgentEventHttpIngestClient.js +52 -0
- package/dist/infrastructure/transport/http/CallbackOutboxStore.js +106 -0
- package/dist/infrastructure/transport/http/PlatformCallbackClient.js +113 -0
- package/dist/infrastructure/transport/http/PlatformCommandPollClient.js +89 -0
- package/dist/infrastructure/transport/http/ResilientPlatformCallbackClient.js +117 -0
- package/dist/infrastructure/transport/midscenePaths.js +28 -0
- package/dist/infrastructure/transport/ws/ResilientWsOrHttpEventPublisher.js +29 -0
- package/dist/infrastructure/transport/ws/WsClient.js +182 -0
- package/dist/infrastructure/transport/ws/WsEventPublisher.js +36 -0
- package/dist/interfaces/http/HttpServer.js +227 -0
- package/dist/interfaces/websocket/AgentWsGateway.js +227 -0
- package/dist/main.js +368 -0
- package/dist/mcp/agentHttpClient.js +82 -0
- package/dist/mcp/agentRuntime.js +184 -0
- package/dist/mcp/cli.js +36 -0
- package/dist/mcp/doctor.js +124 -0
- package/dist/mcp/evidence.js +57 -0
- package/dist/mcp/exploration/index.js +129 -0
- package/dist/mcp/exploration/sessionManager.js +122 -0
- package/dist/mcp/exploration/tools-atomic.js +34 -0
- package/dist/mcp/exploration/tools-intelligent.js +33 -0
- package/dist/mcp/exploration/tools-session.js +276 -0
- package/dist/mcp/exploration/types.js +1 -0
- package/dist/mcp/flowStepEvents.js +114 -0
- package/dist/mcp/liveViewer.js +156 -0
- package/dist/mcp/reportReader.js +157 -0
- package/dist/mcp/runManager.js +161 -0
- package/dist/mcp/runSummary.js +72 -0
- package/dist/mcp/runtimeInstall.js +44 -0
- package/dist/mcp/server.js +260 -0
- package/dist/mcp/setup.js +185 -0
- package/dist/mcp/types.js +1 -0
- package/dist/mcp/userConfig.js +45 -0
- package/dist/mcp/visual-flow/codegen.js +576 -0
- package/dist/mcp/visual-flow/index.js +14 -0
- package/dist/mcp/visual-flow/types.js +5 -0
- package/dist/mcp/visual-flow/validate.js +617 -0
- package/dist/protocol-contracts/commands/envelope.js +24 -0
- package/dist/protocol-contracts/commands/index.js +1 -0
- package/dist/protocol-contracts/dto/index.js +1 -0
- package/dist/protocol-contracts/events/index.js +1 -0
- package/dist/protocol-contracts/queries/index.js +1 -0
- package/dist/shared-kernel/enums/index.js +70 -0
- package/dist/shared-kernel/errors/index.js +21 -0
- package/dist/shared-kernel/ids/index.js +18 -0
- package/dist/shared-kernel/time/index.js +3 -0
- package/dist/shared-kernel/value-objects/index.js +1 -0
- package/dist/utils/appPackageLocalPath.js +75 -0
- package/dist/utils/deviceResourceRouting.js +24 -0
- package/dist/utils/harmonyAgentDebugDevice.js +60 -0
- package/dist/utils/harmonyHdcDeviceId.js +134 -0
- package/dist/utils/iosAgentDebugDevice.js +72 -0
- package/dist/utils/iosMjpegCapture.js +90 -0
- package/dist/utils/liveDebugForegroundParse.js +71 -0
- package/dist/utils/midscene-device-session.js +353 -0
- package/dist/utils/midscene-task-cache-env.js +15 -0
- package/dist/utils/midsceneReportConstants.js +49 -0
- package/dist/utils/seedMidsceneTaskCache.js +61 -0
- package/dist/utils/task-runners/context/androidTaskRunnerContext.js +1 -0
- package/dist/utils/task-runners/context/harmonyTaskRunnerContext.js +1 -0
- package/dist/utils/task-runners/context/iosTaskRunnerContext.js +1 -0
- package/dist/utils/task-runners/runAndroidNativeAppTask.js +29 -0
- package/dist/utils/task-runners/runHarmonyNativeAppTask.js +36 -0
- package/dist/utils/task-runners/runIosNativeAppTask.js +30 -0
- package/dist/utils/task-runners/taskAppPackage.js +20 -0
- package/dist/utils/wrapper/resolveTaskRunnerImport.js +11 -0
- package/dist/utils/wrapper/wrapAndroidTaskScript.js +38 -0
- package/dist/utils/wrapper/wrapHarmonyTaskScript.js +42 -0
- package/dist/utils/wrapper/wrapIosTaskScript.js +30 -0
- package/package.json +46 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { resolveTaskRunnerImportUrl } from './resolveTaskRunnerImport.js';
|
|
2
|
+
function targetToRunnerArgs(target) {
|
|
3
|
+
return {
|
|
4
|
+
deviceId: target.deviceId,
|
|
5
|
+
hdcTconnHost: target.hdcTconnHost,
|
|
6
|
+
hdcTconnPort: target.hdcTconnPort,
|
|
7
|
+
hdcPath: target.hdcPath,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 鸿蒙任务执行:生成薄层脚本,实际模版见 {@link runHarmonyNativeAppTask}。
|
|
12
|
+
*/
|
|
13
|
+
export function wrapHarmonyTaskScript(userScript, target) {
|
|
14
|
+
const body = userScript.trim();
|
|
15
|
+
const indented = body
|
|
16
|
+
? body.split(/\r?\n/).map((line) => ` ${line}`).join('\n')
|
|
17
|
+
: ' // (用例脚本为空)';
|
|
18
|
+
const t = targetToRunnerArgs(target);
|
|
19
|
+
const deviceIdLiteral = JSON.stringify(t.deviceId);
|
|
20
|
+
const hostLiteral = typeof t.hdcTconnHost === 'string' && t.hdcTconnHost.trim()
|
|
21
|
+
? JSON.stringify(t.hdcTconnHost.trim())
|
|
22
|
+
: 'undefined';
|
|
23
|
+
const portLiteral = Number.isFinite(t.hdcTconnPort) && (t.hdcTconnPort ?? 0) > 0
|
|
24
|
+
? JSON.stringify(Math.floor(t.hdcTconnPort))
|
|
25
|
+
: 'undefined';
|
|
26
|
+
const hdcPathLiteral = typeof t.hdcPath === 'string' && t.hdcPath.trim() ? JSON.stringify(t.hdcPath.trim()) : 'undefined';
|
|
27
|
+
const runnerImportUrlLiteral = JSON.stringify(resolveTaskRunnerImportUrl('runHarmonyNativeAppTask'));
|
|
28
|
+
return `import { runHarmonyNativeAppTask } from ${runnerImportUrlLiteral};
|
|
29
|
+
|
|
30
|
+
Promise.resolve(
|
|
31
|
+
runHarmonyNativeAppTask(
|
|
32
|
+
{ deviceId: ${deviceIdLiteral}, hdcTconnHost: ${hostLiteral}, hdcTconnPort: ${portLiteral}, hdcPath: ${hdcPathLiteral} },
|
|
33
|
+
async ({ agent, page, sleep, installApp, uninstallApp }) => {
|
|
34
|
+
${indented}
|
|
35
|
+
},
|
|
36
|
+
),
|
|
37
|
+
).catch((e) => {
|
|
38
|
+
console.error(e);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
});
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { resolveTaskRunnerImportUrl } from './resolveTaskRunnerImport.js';
|
|
2
|
+
/**
|
|
3
|
+
* iOS 任务执行:生成薄层脚本,实际模版见 {@link runIosNativeAppTask}(可维护的真实 TS)。
|
|
4
|
+
*/
|
|
5
|
+
export function wrapIosTaskScript(userScript, target) {
|
|
6
|
+
const body = userScript.trim();
|
|
7
|
+
const indented = body
|
|
8
|
+
? body.split(/\r?\n/).map((line) => ` ${line}`).join('\n')
|
|
9
|
+
: ' // (用例脚本为空)';
|
|
10
|
+
const wdaHostLiteral = JSON.stringify(target.wdaHost);
|
|
11
|
+
const wdaPortLiteral = JSON.stringify(target.wdaPort);
|
|
12
|
+
const deviceIdLiteral = typeof target.deviceId === 'string' && target.deviceId.trim()
|
|
13
|
+
? JSON.stringify(target.deviceId.trim())
|
|
14
|
+
: 'undefined';
|
|
15
|
+
const runnerImportUrlLiteral = JSON.stringify(resolveTaskRunnerImportUrl('runIosNativeAppTask'));
|
|
16
|
+
return `import { runIosNativeAppTask } from ${runnerImportUrlLiteral};
|
|
17
|
+
|
|
18
|
+
Promise.resolve(
|
|
19
|
+
runIosNativeAppTask(
|
|
20
|
+
{ wdaHost: ${wdaHostLiteral}, wdaPort: ${wdaPortLiteral}, deviceId: ${deviceIdLiteral} },
|
|
21
|
+
async ({ agent, page, sleep, installApp, uninstallApp }) => {
|
|
22
|
+
${indented}
|
|
23
|
+
},
|
|
24
|
+
),
|
|
25
|
+
).catch((e) => {
|
|
26
|
+
console.error(e);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
});
|
|
29
|
+
`;
|
|
30
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "preflite",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Preflight — Local mobile AI testing via MCP. AI-assisted testing on real Android/iOS/Harmony devices.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"preflite": "dist/mcp/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20.11.0"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"mcp": "tsx src/mcp/cli.ts",
|
|
20
|
+
"mcp:setup": "tsx src/mcp/cli.ts setup",
|
|
21
|
+
"build": "tsc -p tsconfig.build.json",
|
|
22
|
+
"check": "tsc -p tsconfig.json --noEmit",
|
|
23
|
+
"test": "tsx --test src/tests/**/*.test.ts",
|
|
24
|
+
"start": "node dist/main.js"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@midscene/android": "^1.7.5",
|
|
28
|
+
"@midscene/harmony": "^1.7.5",
|
|
29
|
+
"@midscene/ios": "^1.7.5",
|
|
30
|
+
"@modelcontextprotocol/sdk": "^1.17.5",
|
|
31
|
+
"koa": "^2.15.4",
|
|
32
|
+
"lodash": "^4.17.21",
|
|
33
|
+
"sharp": "^0.33.5",
|
|
34
|
+
"tsx": "^4.20.6",
|
|
35
|
+
"ws": "^8.18.3",
|
|
36
|
+
"yaml": "^2.8.1",
|
|
37
|
+
"zod": "^3.25.76"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/koa": "^3.0.2",
|
|
41
|
+
"@types/lodash": "^4.17.24",
|
|
42
|
+
"@types/node": "^20.17.57",
|
|
43
|
+
"@types/ws": "^8.18.1",
|
|
44
|
+
"typescript": "^5.9.3"
|
|
45
|
+
}
|
|
46
|
+
}
|