weapp-pilot-mcp 0.1.1 → 0.1.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/README.md +5 -2
- package/dist/bin.js +329 -9
- package/dist/bin.js.map +1 -1
- package/dist/index.js +329 -9
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# weapp-pilot-mcp
|
|
2
2
|
|
|
3
|
-
`weapp-pilot-mcp` is a local MCP server for route-aware smoke testing and structured scenario execution against WeChat Mini Programs.
|
|
3
|
+
`weapp-pilot-mcp` is a local MCP server for route-aware smoke testing, async smoke jobs, and structured scenario execution against WeChat Mini Programs.
|
|
4
4
|
|
|
5
5
|
Current public scope:
|
|
6
6
|
|
|
7
7
|
- Taro-first project detection and build orchestration
|
|
8
8
|
- local-machine WeChat DevTools sessions
|
|
9
9
|
- `miniprogram-automator` backed runtime control
|
|
10
|
-
- readiness checks, smoke runs, and structured scenario execution for external Agents
|
|
10
|
+
- readiness checks, sync or async smoke runs, and structured scenario execution for external Agents
|
|
11
11
|
|
|
12
12
|
## Quick Start
|
|
13
13
|
|
|
@@ -43,15 +43,18 @@ env_check
|
|
|
43
43
|
preflight_check
|
|
44
44
|
project_routes / route_search
|
|
45
45
|
smoke_run
|
|
46
|
+
smoke_run_async / run_status / run_result
|
|
46
47
|
scenario_run
|
|
47
48
|
```
|
|
48
49
|
|
|
49
50
|
## Documentation
|
|
50
51
|
|
|
51
52
|
- Repository: https://github.com/Leezgion/weapp-pilot-mcp
|
|
53
|
+
- Client configs: https://github.com/Leezgion/weapp-pilot-mcp/blob/main/docs/client-configs.md
|
|
52
54
|
- Local setup: https://github.com/Leezgion/weapp-pilot-mcp/blob/main/docs/local-setup.md
|
|
53
55
|
- Agent recipes: https://github.com/Leezgion/weapp-pilot-mcp/blob/main/docs/agent-recipes.md
|
|
54
56
|
- Chinese docs: https://github.com/Leezgion/weapp-pilot-mcp/blob/main/docs/zh-CN/README.md
|
|
57
|
+
- Changelog: https://github.com/Leezgion/weapp-pilot-mcp/blob/main/CHANGELOG.md
|
|
55
58
|
|
|
56
59
|
## License
|
|
57
60
|
|
package/dist/bin.js
CHANGED
|
@@ -71,7 +71,9 @@ var require_errors = __commonJS({
|
|
|
71
71
|
"ELEMENT_NOT_FOUND",
|
|
72
72
|
"SCENARIO_STEP_FAILED",
|
|
73
73
|
"ASSERT_TEXT_NOT_FOUND",
|
|
74
|
-
"ASSERT_ROUTE_MISMATCH"
|
|
74
|
+
"ASSERT_ROUTE_MISMATCH",
|
|
75
|
+
"ASYNC_JOB_NOT_FOUND",
|
|
76
|
+
"ASYNC_JOB_NOT_READY"
|
|
75
77
|
]);
|
|
76
78
|
exports2.weappErrorSchema = zod_1.z.object({
|
|
77
79
|
code: exports2.weappErrorCodeSchema,
|
|
@@ -106,8 +108,8 @@ var require_types = __commonJS({
|
|
|
106
108
|
"../shared/dist/types.js"(exports2) {
|
|
107
109
|
"use strict";
|
|
108
110
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
109
|
-
exports2.
|
|
110
|
-
exports2.artifactBundleSchema = exports2.scenarioRunResultSchema = exports2.smokeRunResultSchema = exports2.scenarioRunInputSchema = exports2.scenarioStepResultSchema = exports2.scenarioStepSchema = exports2.smokeRunInputSchema = exports2.restoreWxInputSchema = exports2.mockWxInputSchema = exports2.preflightCheckInputSchema = exports2.envCheckInputSchema = exports2.smokeRunAuthSchema = exports2.smokeRunTargetSchema = exports2.smokeRunLimitsSchema = exports2.smokeRunCleanupSchema = exports2.smokeRunArtifactsSchema = void 0;
|
|
111
|
+
exports2.smokeRunAuthCredentialsSchema = exports2.logBundleSchema = exports2.logEntrySchema = exports2.assertionResultSchema = exports2.screenshotRefSchema = exports2.runtimeEvaluateResultSchema = exports2.runtimeEvaluateInputSchema = exports2.restoreWxResultSchema = exports2.mockWxResultSchema = exports2.wxCallResultSchema = exports2.actionResultSchema = exports2.pageSnapshotSchema = exports2.preflightReportSchema = exports2.preflightResolvedSchema = exports2.environmentReportSchema = exports2.environmentProjectSchema = exports2.environmentMachineSchema = exports2.environmentCheckItemSchema = exports2.routeSearchResultSchema = exports2.routeSearchMatchSchema = exports2.projectRoutesSchema = exports2.projectRouteEntrySchema = exports2.projectRoutesSubpackageSchema = exports2.pageDataSnapshotSchema = exports2.pageStackSchema = exports2.pageReferenceSchema = exports2.runtimeSessionSchema = exports2.buildSessionSchema = exports2.projectContextSchema = exports2.scenarioStepActionSchema = exports2.runtimeEvaluateActionSchema = exports2.smokeRunAuthModeSchema = exports2.scenarioRunStageSchema = exports2.smokeRunStageSchema = exports2.scenarioStepStatusSchema = exports2.asyncJobToolSchema = exports2.asyncJobStatusSchema = exports2.smokeRunStatusSchema = exports2.environmentLoginStatusSchema = exports2.environmentCheckStatusSchema = exports2.environmentOverallStatusSchema = exports2.projectRouteOriginSchema = exports2.projectRoutesSourceSchema = exports2.logLevelSchema = exports2.runResultSchema = exports2.assertionStatusSchema = exports2.runtimeStatusSchema = exports2.buildStatusSchema = exports2.buildModeSchema = exports2.frameworkSchema = void 0;
|
|
112
|
+
exports2.artifactBundleSchema = exports2.scenarioRunResultSchema = exports2.asyncJobCancelResultSchema = exports2.asyncJobResultSchema = exports2.asyncJobReportSchema = exports2.asyncJobAcceptedSchema = exports2.smokeRunResultSchema = exports2.scenarioRunInputSchema = exports2.scenarioStepResultSchema = exports2.scenarioStepSchema = exports2.smokeRunInputSchema = exports2.restoreWxInputSchema = exports2.mockWxInputSchema = exports2.preflightCheckInputSchema = exports2.envCheckInputSchema = exports2.smokeRunAuthSchema = exports2.smokeRunTargetSchema = exports2.smokeRunLimitsSchema = exports2.smokeRunCleanupSchema = exports2.smokeRunArtifactsSchema = exports2.smokeRunSuccessSchema = exports2.smokeRunAuthHintsSchema = void 0;
|
|
111
113
|
var zod_1 = require("zod");
|
|
112
114
|
var errors_1 = require_errors();
|
|
113
115
|
exports2.frameworkSchema = zod_1.z.enum(["taro", "native", "uniapp"]);
|
|
@@ -153,6 +155,16 @@ var require_types = __commonJS({
|
|
|
153
155
|
"needs_auth",
|
|
154
156
|
"blocked"
|
|
155
157
|
]);
|
|
158
|
+
exports2.asyncJobStatusSchema = zod_1.z.enum([
|
|
159
|
+
"queued",
|
|
160
|
+
"running",
|
|
161
|
+
"passed",
|
|
162
|
+
"failed",
|
|
163
|
+
"needs_auth",
|
|
164
|
+
"blocked",
|
|
165
|
+
"canceled"
|
|
166
|
+
]);
|
|
167
|
+
exports2.asyncJobToolSchema = zod_1.z.enum(["smoke_run"]);
|
|
156
168
|
exports2.scenarioStepStatusSchema = zod_1.z.enum(["passed", "failed"]);
|
|
157
169
|
exports2.smokeRunStageSchema = zod_1.z.enum([
|
|
158
170
|
"detect",
|
|
@@ -616,6 +628,31 @@ var require_types = __commonJS({
|
|
|
616
628
|
session: exports2.runtimeSessionSchema.optional(),
|
|
617
629
|
error: errors_1.weappErrorSchema.optional()
|
|
618
630
|
});
|
|
631
|
+
exports2.asyncJobAcceptedSchema = zod_1.z.object({
|
|
632
|
+
jobId: zod_1.z.string().min(1),
|
|
633
|
+
tool: exports2.asyncJobToolSchema,
|
|
634
|
+
status: zod_1.z.enum(["queued", "running"]),
|
|
635
|
+
acceptedAt: zod_1.z.string().datetime()
|
|
636
|
+
});
|
|
637
|
+
exports2.asyncJobReportSchema = zod_1.z.object({
|
|
638
|
+
jobId: zod_1.z.string().min(1),
|
|
639
|
+
tool: exports2.asyncJobToolSchema,
|
|
640
|
+
status: exports2.asyncJobStatusSchema,
|
|
641
|
+
cancelRequested: zod_1.z.boolean(),
|
|
642
|
+
createdAt: zod_1.z.string().datetime(),
|
|
643
|
+
startedAt: zod_1.z.string().datetime().optional(),
|
|
644
|
+
finishedAt: zod_1.z.string().datetime().optional(),
|
|
645
|
+
currentStage: exports2.smokeRunStageSchema.optional(),
|
|
646
|
+
summaryPath: zod_1.z.string().min(1).optional(),
|
|
647
|
+
error: errors_1.weappErrorSchema.optional()
|
|
648
|
+
});
|
|
649
|
+
exports2.asyncJobResultSchema = exports2.asyncJobReportSchema.extend({
|
|
650
|
+
result: exports2.smokeRunResultSchema.optional()
|
|
651
|
+
});
|
|
652
|
+
exports2.asyncJobCancelResultSchema = exports2.asyncJobReportSchema.extend({
|
|
653
|
+
acknowledged: zod_1.z.boolean(),
|
|
654
|
+
message: zod_1.z.string().min(1).optional()
|
|
655
|
+
});
|
|
619
656
|
exports2.scenarioRunResultSchema = zod_1.z.object({
|
|
620
657
|
status: exports2.smokeRunStatusSchema,
|
|
621
658
|
stage: exports2.scenarioRunStageSchema.optional(),
|
|
@@ -771,6 +808,40 @@ var require_tool_schemas = __commonJS({
|
|
|
771
808
|
inputSchema: exports2.emptyInputSchema,
|
|
772
809
|
dataSchema: types_1.actionResultSchema
|
|
773
810
|
}),
|
|
811
|
+
smoke_run_async: createTool({
|
|
812
|
+
name: "smoke_run_async",
|
|
813
|
+
category: "scenario",
|
|
814
|
+
description: "Queue a smoke-test run as an asynchronous job and return immediately with a job id.",
|
|
815
|
+
inputSchema: types_1.smokeRunInputSchema,
|
|
816
|
+
dataSchema: types_1.asyncJobAcceptedSchema
|
|
817
|
+
}),
|
|
818
|
+
run_status: createTool({
|
|
819
|
+
name: "run_status",
|
|
820
|
+
category: "scenario",
|
|
821
|
+
description: "Read the lightweight status of an asynchronous run job.",
|
|
822
|
+
inputSchema: zod_1.z.object({
|
|
823
|
+
jobId: zod_1.z.string().min(1)
|
|
824
|
+
}),
|
|
825
|
+
dataSchema: types_1.asyncJobReportSchema
|
|
826
|
+
}),
|
|
827
|
+
run_result: createTool({
|
|
828
|
+
name: "run_result",
|
|
829
|
+
category: "scenario",
|
|
830
|
+
description: "Read the final result of an asynchronous run job once it is ready.",
|
|
831
|
+
inputSchema: zod_1.z.object({
|
|
832
|
+
jobId: zod_1.z.string().min(1)
|
|
833
|
+
}),
|
|
834
|
+
dataSchema: types_1.asyncJobResultSchema
|
|
835
|
+
}),
|
|
836
|
+
run_cancel: createTool({
|
|
837
|
+
name: "run_cancel",
|
|
838
|
+
category: "scenario",
|
|
839
|
+
description: "Request cancellation for an asynchronous run job.",
|
|
840
|
+
inputSchema: zod_1.z.object({
|
|
841
|
+
jobId: zod_1.z.string().min(1)
|
|
842
|
+
}),
|
|
843
|
+
dataSchema: types_1.asyncJobCancelResultSchema
|
|
844
|
+
}),
|
|
774
845
|
smoke_run: createTool({
|
|
775
846
|
name: "smoke_run",
|
|
776
847
|
category: "scenario",
|
|
@@ -2352,6 +2423,195 @@ var require_inspect = __commonJS({
|
|
|
2352
2423
|
}
|
|
2353
2424
|
});
|
|
2354
2425
|
|
|
2426
|
+
// ../weapp-core/dist/job-manager.js
|
|
2427
|
+
var require_job_manager = __commonJS({
|
|
2428
|
+
"../weapp-core/dist/job-manager.js"(exports2) {
|
|
2429
|
+
"use strict";
|
|
2430
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2431
|
+
exports2.SmokeRunJobManager = void 0;
|
|
2432
|
+
var shared_1 = require_dist();
|
|
2433
|
+
var utils_1 = require_utils();
|
|
2434
|
+
var SmokeRunJobManager = class {
|
|
2435
|
+
jobs = /* @__PURE__ */ new Map();
|
|
2436
|
+
queue = [];
|
|
2437
|
+
activeJobId;
|
|
2438
|
+
submit(input, run) {
|
|
2439
|
+
const jobId = (0, utils_1.createRunId)("smoke-job");
|
|
2440
|
+
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2441
|
+
const job = {
|
|
2442
|
+
jobId,
|
|
2443
|
+
tool: "smoke_run",
|
|
2444
|
+
input,
|
|
2445
|
+
status: this.activeJobId ? "queued" : "running",
|
|
2446
|
+
cancelRequested: false,
|
|
2447
|
+
createdAt,
|
|
2448
|
+
run
|
|
2449
|
+
};
|
|
2450
|
+
this.jobs.set(jobId, job);
|
|
2451
|
+
if (this.activeJobId) {
|
|
2452
|
+
this.queue.push(jobId);
|
|
2453
|
+
} else {
|
|
2454
|
+
this.startJob(jobId);
|
|
2455
|
+
}
|
|
2456
|
+
return {
|
|
2457
|
+
jobId,
|
|
2458
|
+
tool: "smoke_run",
|
|
2459
|
+
status: job.status === "queued" ? "queued" : "running",
|
|
2460
|
+
acceptedAt: createdAt
|
|
2461
|
+
};
|
|
2462
|
+
}
|
|
2463
|
+
getStatus(jobId) {
|
|
2464
|
+
const job = this.requireJob(jobId);
|
|
2465
|
+
return this.toReport(job);
|
|
2466
|
+
}
|
|
2467
|
+
getResult(jobId) {
|
|
2468
|
+
const job = this.requireJob(jobId);
|
|
2469
|
+
if (job.status === "queued" || job.status === "running") {
|
|
2470
|
+
throw (0, shared_1.createWeappError)({
|
|
2471
|
+
code: "ASYNC_JOB_NOT_READY",
|
|
2472
|
+
message: `Async run job ${jobId} is still ${job.status}.`,
|
|
2473
|
+
stage: "unknown",
|
|
2474
|
+
retryable: true,
|
|
2475
|
+
details: {
|
|
2476
|
+
jobId,
|
|
2477
|
+
status: job.status
|
|
2478
|
+
}
|
|
2479
|
+
});
|
|
2480
|
+
}
|
|
2481
|
+
return {
|
|
2482
|
+
...this.toReport(job),
|
|
2483
|
+
...job.result ? { result: job.result } : {}
|
|
2484
|
+
};
|
|
2485
|
+
}
|
|
2486
|
+
cancel(jobId) {
|
|
2487
|
+
const job = this.requireJob(jobId);
|
|
2488
|
+
if (job.status === "queued") {
|
|
2489
|
+
this.removeQueuedJob(jobId);
|
|
2490
|
+
job.status = "canceled";
|
|
2491
|
+
job.finishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2492
|
+
job.currentStage = void 0;
|
|
2493
|
+
return {
|
|
2494
|
+
...this.toReport(job),
|
|
2495
|
+
acknowledged: true,
|
|
2496
|
+
message: `Canceled queued job ${jobId}.`
|
|
2497
|
+
};
|
|
2498
|
+
}
|
|
2499
|
+
if (job.status === "running") {
|
|
2500
|
+
job.cancelRequested = true;
|
|
2501
|
+
return {
|
|
2502
|
+
...this.toReport(job),
|
|
2503
|
+
acknowledged: true,
|
|
2504
|
+
message: "Cancellation was requested. The running smoke job may still complete before the underlying runtime stops."
|
|
2505
|
+
};
|
|
2506
|
+
}
|
|
2507
|
+
return {
|
|
2508
|
+
...this.toReport(job),
|
|
2509
|
+
acknowledged: true,
|
|
2510
|
+
message: `Job ${jobId} is already ${job.status}.`
|
|
2511
|
+
};
|
|
2512
|
+
}
|
|
2513
|
+
requireJob(jobId) {
|
|
2514
|
+
const job = this.jobs.get(jobId);
|
|
2515
|
+
if (!job) {
|
|
2516
|
+
throw (0, shared_1.createWeappError)({
|
|
2517
|
+
code: "ASYNC_JOB_NOT_FOUND",
|
|
2518
|
+
message: `Async run job ${jobId} was not found.`,
|
|
2519
|
+
stage: "unknown",
|
|
2520
|
+
retryable: false,
|
|
2521
|
+
details: {
|
|
2522
|
+
jobId
|
|
2523
|
+
}
|
|
2524
|
+
});
|
|
2525
|
+
}
|
|
2526
|
+
return job;
|
|
2527
|
+
}
|
|
2528
|
+
removeQueuedJob(jobId) {
|
|
2529
|
+
const index = this.queue.indexOf(jobId);
|
|
2530
|
+
if (index >= 0) {
|
|
2531
|
+
this.queue.splice(index, 1);
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
startJob(jobId) {
|
|
2535
|
+
const job = this.jobs.get(jobId);
|
|
2536
|
+
if (!job) {
|
|
2537
|
+
this.startNextJob();
|
|
2538
|
+
return;
|
|
2539
|
+
}
|
|
2540
|
+
if (job.cancelRequested || job.status === "canceled") {
|
|
2541
|
+
job.status = "canceled";
|
|
2542
|
+
job.finishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2543
|
+
job.currentStage = void 0;
|
|
2544
|
+
this.startNextJob();
|
|
2545
|
+
return;
|
|
2546
|
+
}
|
|
2547
|
+
this.activeJobId = jobId;
|
|
2548
|
+
job.status = "running";
|
|
2549
|
+
job.startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2550
|
+
job.currentStage = job.input.build?.skip === true ? "runtime" : "build";
|
|
2551
|
+
void this.execute(job).finally(() => {
|
|
2552
|
+
if (this.activeJobId === jobId) {
|
|
2553
|
+
this.activeJobId = void 0;
|
|
2554
|
+
}
|
|
2555
|
+
this.startNextJob();
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
startNextJob() {
|
|
2559
|
+
const nextJobId = this.queue.shift();
|
|
2560
|
+
if (!nextJobId) {
|
|
2561
|
+
return;
|
|
2562
|
+
}
|
|
2563
|
+
this.startJob(nextJobId);
|
|
2564
|
+
}
|
|
2565
|
+
async execute(job) {
|
|
2566
|
+
try {
|
|
2567
|
+
const output = await job.run();
|
|
2568
|
+
if (output.ok) {
|
|
2569
|
+
job.result = output.data;
|
|
2570
|
+
job.status = output.data.status;
|
|
2571
|
+
job.summaryPath = output.data.summaryPath;
|
|
2572
|
+
job.error = output.data.error;
|
|
2573
|
+
job.currentStage = output.data.stage;
|
|
2574
|
+
} else {
|
|
2575
|
+
job.status = "blocked";
|
|
2576
|
+
job.error = output.error;
|
|
2577
|
+
job.currentStage = output.error.stage === "unknown" ? void 0 : output.error.stage;
|
|
2578
|
+
}
|
|
2579
|
+
} catch (error) {
|
|
2580
|
+
job.status = "blocked";
|
|
2581
|
+
job.error = error && typeof error === "object" && "code" in error ? error : (0, shared_1.createWeappError)({
|
|
2582
|
+
code: "INTERNAL_ERROR",
|
|
2583
|
+
message: error instanceof Error ? error.message : "Unexpected error while executing async smoke job.",
|
|
2584
|
+
stage: "unknown",
|
|
2585
|
+
retryable: false,
|
|
2586
|
+
details: error instanceof Error ? {
|
|
2587
|
+
name: error.name,
|
|
2588
|
+
stack: error.stack
|
|
2589
|
+
} : { value: error }
|
|
2590
|
+
});
|
|
2591
|
+
job.currentStage = job.error.stage === "unknown" ? void 0 : job.error.stage;
|
|
2592
|
+
} finally {
|
|
2593
|
+
job.finishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
toReport(job) {
|
|
2597
|
+
return {
|
|
2598
|
+
jobId: job.jobId,
|
|
2599
|
+
tool: job.tool,
|
|
2600
|
+
status: job.status,
|
|
2601
|
+
cancelRequested: job.cancelRequested,
|
|
2602
|
+
createdAt: job.createdAt,
|
|
2603
|
+
...job.startedAt ? { startedAt: job.startedAt } : {},
|
|
2604
|
+
...job.finishedAt ? { finishedAt: job.finishedAt } : {},
|
|
2605
|
+
...job.currentStage ? { currentStage: job.currentStage } : {},
|
|
2606
|
+
...job.summaryPath ? { summaryPath: job.summaryPath } : {},
|
|
2607
|
+
...job.error ? { error: job.error } : {}
|
|
2608
|
+
};
|
|
2609
|
+
}
|
|
2610
|
+
};
|
|
2611
|
+
exports2.SmokeRunJobManager = SmokeRunJobManager;
|
|
2612
|
+
}
|
|
2613
|
+
});
|
|
2614
|
+
|
|
2355
2615
|
// ../weapp-core/dist/runtime-manager.js
|
|
2356
2616
|
var require_runtime_manager = __commonJS({
|
|
2357
2617
|
"../weapp-core/dist/runtime-manager.js"(exports2) {
|
|
@@ -2902,14 +3162,18 @@ var require_runtime = __commonJS({
|
|
|
2902
3162
|
}
|
|
2903
3163
|
async findPage(route) {
|
|
2904
3164
|
const pages = await this.getMiniProgram().pageStack();
|
|
2905
|
-
const
|
|
3165
|
+
const normalizedRoute = normalizeRuntimePageRoute(route);
|
|
3166
|
+
const page = pages.find((entry) => normalizeRuntimePageRoute(entry.path) === normalizedRoute);
|
|
2906
3167
|
if (!page) {
|
|
2907
3168
|
(0, utils_1.fail)({
|
|
2908
3169
|
code: "PAGE_NOT_FOUND",
|
|
2909
3170
|
message: `Unable to find page ${route} in the current page stack.`,
|
|
2910
3171
|
stage: "runtime",
|
|
2911
3172
|
retryable: true,
|
|
2912
|
-
details: {
|
|
3173
|
+
details: {
|
|
3174
|
+
route,
|
|
3175
|
+
normalizedRoute
|
|
3176
|
+
}
|
|
2913
3177
|
});
|
|
2914
3178
|
}
|
|
2915
3179
|
return page;
|
|
@@ -3492,6 +3756,9 @@ ${bootstrap.stderr}`.toLowerCase();
|
|
|
3492
3756
|
return false;
|
|
3493
3757
|
}
|
|
3494
3758
|
}
|
|
3759
|
+
function normalizeRuntimePageRoute(route) {
|
|
3760
|
+
return route.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
3761
|
+
}
|
|
3495
3762
|
}
|
|
3496
3763
|
});
|
|
3497
3764
|
|
|
@@ -3512,6 +3779,7 @@ var require_core = __commonJS({
|
|
|
3512
3779
|
var diagnostics_1 = require_diagnostics();
|
|
3513
3780
|
var devtools_1 = require_devtools();
|
|
3514
3781
|
var inspect_1 = require_inspect();
|
|
3782
|
+
var job_manager_1 = require_job_manager();
|
|
3515
3783
|
var project_1 = require_project();
|
|
3516
3784
|
var runtime_manager_1 = require_runtime_manager();
|
|
3517
3785
|
var runtime_1 = require_runtime();
|
|
@@ -3526,6 +3794,7 @@ var require_core = __commonJS({
|
|
|
3526
3794
|
detectedProjects = /* @__PURE__ */ new Map();
|
|
3527
3795
|
buildManager = new build_1.BuildManager();
|
|
3528
3796
|
artifactManager = new artifacts_1.ArtifactManager();
|
|
3797
|
+
smokeRunJobManager = new job_manager_1.SmokeRunJobManager();
|
|
3529
3798
|
runtimeAdapter;
|
|
3530
3799
|
runtimeManager;
|
|
3531
3800
|
ideSession;
|
|
@@ -3828,6 +4097,44 @@ var require_core = __commonJS({
|
|
|
3828
4097
|
return (0, utils_1.asToolFailure)(error);
|
|
3829
4098
|
}
|
|
3830
4099
|
}
|
|
4100
|
+
async smoke_run_async(input) {
|
|
4101
|
+
try {
|
|
4102
|
+
const accepted = this.smokeRunJobManager.submit(input, () => this.smoke_run(input));
|
|
4103
|
+
return (0, utils_1.asToolSuccess)(accepted);
|
|
4104
|
+
} catch (error) {
|
|
4105
|
+
return (0, utils_1.asToolFailure)(error);
|
|
4106
|
+
}
|
|
4107
|
+
}
|
|
4108
|
+
async run_status(input) {
|
|
4109
|
+
try {
|
|
4110
|
+
return (0, utils_1.asToolSuccess)(this.smokeRunJobManager.getStatus(input.jobId));
|
|
4111
|
+
} catch (error) {
|
|
4112
|
+
return isWeappError(error) ? {
|
|
4113
|
+
ok: false,
|
|
4114
|
+
error
|
|
4115
|
+
} : (0, utils_1.asToolFailure)(error);
|
|
4116
|
+
}
|
|
4117
|
+
}
|
|
4118
|
+
async run_result(input) {
|
|
4119
|
+
try {
|
|
4120
|
+
return (0, utils_1.asToolSuccess)(this.smokeRunJobManager.getResult(input.jobId));
|
|
4121
|
+
} catch (error) {
|
|
4122
|
+
return isWeappError(error) ? {
|
|
4123
|
+
ok: false,
|
|
4124
|
+
error
|
|
4125
|
+
} : (0, utils_1.asToolFailure)(error);
|
|
4126
|
+
}
|
|
4127
|
+
}
|
|
4128
|
+
async run_cancel(input) {
|
|
4129
|
+
try {
|
|
4130
|
+
return (0, utils_1.asToolSuccess)(this.smokeRunJobManager.cancel(input.jobId));
|
|
4131
|
+
} catch (error) {
|
|
4132
|
+
return isWeappError(error) ? {
|
|
4133
|
+
ok: false,
|
|
4134
|
+
error
|
|
4135
|
+
} : (0, utils_1.asToolFailure)(error);
|
|
4136
|
+
}
|
|
4137
|
+
}
|
|
3831
4138
|
async smoke_run(input) {
|
|
3832
4139
|
const shouldBuild = input.build?.skip !== true;
|
|
3833
4140
|
const shouldCaptureScreenshot = input.artifacts?.screenshot !== false;
|
|
@@ -4129,7 +4436,8 @@ var require_core = __commonJS({
|
|
|
4129
4436
|
}
|
|
4130
4437
|
async navigate(input) {
|
|
4131
4438
|
try {
|
|
4132
|
-
const
|
|
4439
|
+
const normalizedUrl = normalizeNavigationRoute(input.url);
|
|
4440
|
+
const pageReference = await this.withRecoverableRuntimeRead((_runtimeSession) => this.runtimeAdapter.navigate(normalizedUrl));
|
|
4133
4441
|
this.updateCurrentRoute(pageReference.route);
|
|
4134
4442
|
return (0, utils_1.asToolSuccess)(pageReference);
|
|
4135
4443
|
} catch (error) {
|
|
@@ -4138,7 +4446,7 @@ var require_core = __commonJS({
|
|
|
4138
4446
|
}
|
|
4139
4447
|
async current_page(_input) {
|
|
4140
4448
|
try {
|
|
4141
|
-
const pageReference = await this.
|
|
4449
|
+
const pageReference = await this.withRecoverableRuntimeRead((_runtimeSession) => this.runtimeAdapter.currentPage());
|
|
4142
4450
|
this.updateCurrentRoute(pageReference.route);
|
|
4143
4451
|
return (0, utils_1.asToolSuccess)(pageReference);
|
|
4144
4452
|
} catch (error) {
|
|
@@ -4147,7 +4455,7 @@ var require_core = __commonJS({
|
|
|
4147
4455
|
}
|
|
4148
4456
|
async page_stack(_input) {
|
|
4149
4457
|
try {
|
|
4150
|
-
const pageStack = await this.
|
|
4458
|
+
const pageStack = await this.withRecoverableRuntimeRead((_runtimeSession) => this.runtimeAdapter.pageStack());
|
|
4151
4459
|
this.updateCurrentRoute(pageStack.currentRoute);
|
|
4152
4460
|
return (0, utils_1.asToolSuccess)(pageStack);
|
|
4153
4461
|
} catch (error) {
|
|
@@ -4837,6 +5145,10 @@ var require_core = __commonJS({
|
|
|
4837
5145
|
};
|
|
4838
5146
|
exports2.LocalWeappCore = LocalWeappCore;
|
|
4839
5147
|
var UnimplementedWeappCore = class extends LocalWeappCore {
|
|
5148
|
+
smoke_run_async = createUnimplementedHandler("smoke_run_async");
|
|
5149
|
+
run_status = createUnimplementedHandler("run_status");
|
|
5150
|
+
run_result = createUnimplementedHandler("run_result");
|
|
5151
|
+
run_cancel = createUnimplementedHandler("run_cancel");
|
|
4840
5152
|
mock_wx = createUnimplementedHandler("mock_wx");
|
|
4841
5153
|
restore_wx = createUnimplementedHandler("restore_wx");
|
|
4842
5154
|
runtime_evaluate = createUnimplementedHandler("runtime_evaluate");
|
|
@@ -5046,7 +5358,7 @@ var require_core = __commonJS({
|
|
|
5046
5358
|
return hasRecoverableRuntimeMessage(error.message);
|
|
5047
5359
|
}
|
|
5048
5360
|
function hasRecoverableRuntimeMessage(message) {
|
|
5049
|
-
return /(?:socket|websocket|ECONN|closed|disconnect|not connected|target closed)/i.test(message);
|
|
5361
|
+
return /(?:socket|websocket|ECONN|closed|disconnect|not connected|target closed|timeout)/i.test(message);
|
|
5050
5362
|
}
|
|
5051
5363
|
function isWeappError(value) {
|
|
5052
5364
|
return Boolean(value && typeof value === "object" && "code" in value && "message" in value && "stage" in value && "retryable" in value);
|
|
@@ -5098,6 +5410,13 @@ var require_core = __commonJS({
|
|
|
5098
5410
|
}
|
|
5099
5411
|
return route.replace(/^\/+/, "");
|
|
5100
5412
|
}
|
|
5413
|
+
function normalizeNavigationRoute(route) {
|
|
5414
|
+
const normalizedRoute = route.replace(/\\/g, "/");
|
|
5415
|
+
if (normalizedRoute.startsWith("/") || normalizedRoute.startsWith("./") || normalizedRoute.startsWith("../") || normalizedRoute.startsWith("?") || /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(normalizedRoute)) {
|
|
5416
|
+
return normalizedRoute;
|
|
5417
|
+
}
|
|
5418
|
+
return `/${normalizedRoute.replace(/^\/+/, "")}`;
|
|
5419
|
+
}
|
|
5101
5420
|
function derivePreflightOverallStatus(checks, automatorChecked) {
|
|
5102
5421
|
const byName = new Map(checks.map((check) => [check.name, check]));
|
|
5103
5422
|
const projectCheck = byName.get("project_detect");
|
|
@@ -5171,6 +5490,7 @@ var require_dist2 = __commonJS({
|
|
|
5171
5490
|
__exportStar(require_build(), exports2);
|
|
5172
5491
|
__exportStar(require_devtools(), exports2);
|
|
5173
5492
|
__exportStar(require_diagnostics(), exports2);
|
|
5493
|
+
__exportStar(require_job_manager(), exports2);
|
|
5174
5494
|
__exportStar(require_project(), exports2);
|
|
5175
5495
|
__exportStar(require_runtime(), exports2);
|
|
5176
5496
|
__exportStar(require_runtime_manager(), exports2);
|