@ultrst-armada/kloks 1.24.2 → 1.24.4
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/.krusbl-release-attestation.json +3 -3
- package/package.json +11 -2
- package/packages/backend/dist/chunk-2OPIDIIB.js +191 -0
- package/packages/backend/dist/{chunk-6TRVGWXP.js → chunk-FJ5LZFBV.js} +20 -204
- package/packages/backend/dist/chunk-YEGS4HTA.js +0 -0
- package/packages/backend/dist/development/client.d.ts +142 -0
- package/packages/backend/dist/development/client.js +252 -0
- package/packages/backend/dist/development/index.d.ts +3 -74
- package/packages/backend/dist/development/index.js +7 -4
- package/packages/backend/dist/development/playwrightInspectionService.d.ts +20 -0
- package/packages/backend/dist/development/playwrightInspectionService.js +12 -0
- package/packages/backend/dist/development/playwrightInspectionTypes.d.ts +59 -0
- package/packages/backend/dist/development/playwrightInspectionTypes.js +1 -0
- package/packages/backend/dist/index.d.ts +3 -1
- package/packages/backend/dist/index.js +43 -40
- package/packages/backend/dist/krnl-services.js +4 -4
- package/packages/backend/dist/storage/index.js +7 -7
- package/packages/backend/package.json +1 -1
- package/packages/services/dist/index.js +8 -3
- package/packages/backend/dist/{chunk-VTU6CNZD.js → chunk-AHJ2EWQW.js} +12 -12
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"packageName": "@ultrst-armada/kloks",
|
|
4
|
-
"version": "1.24.
|
|
5
|
-
"sourceCommit": "
|
|
4
|
+
"version": "1.24.4",
|
|
5
|
+
"sourceCommit": "12383c07ed6082051321de083038d23cb82bc1ef",
|
|
6
6
|
"releaseWorkflow": "npm Release",
|
|
7
|
-
"workflowRunId": "
|
|
7
|
+
"workflowRunId": "41538037349"
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultrst-armada/kloks",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -171,6 +171,11 @@
|
|
|
171
171
|
"types": "./packages/backend/dist/development/webContainerService.d.ts",
|
|
172
172
|
"import": "./packages/backend/dist/development/webContainerService.js",
|
|
173
173
|
"default": "./packages/backend/dist/development/webContainerService.js"
|
|
174
|
+
},
|
|
175
|
+
"./development/client": {
|
|
176
|
+
"types": "./packages/backend/dist/development/client.d.ts",
|
|
177
|
+
"import": "./packages/backend/dist/development/client.js",
|
|
178
|
+
"default": "./packages/backend/dist/development/client.js"
|
|
174
179
|
}
|
|
175
180
|
},
|
|
176
181
|
"scripts": {
|
|
@@ -193,7 +198,8 @@
|
|
|
193
198
|
"@neondatabase/serverless": "^0.10.0 || ^1.0.0",
|
|
194
199
|
"@supabase/supabase-js": "^2.45.0",
|
|
195
200
|
"better-sqlite3": "^11.0.0",
|
|
196
|
-
"react": "^18.0.0 || ^19.0.0"
|
|
201
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
202
|
+
"@ultrst-armada/krnl": "^1.0.9"
|
|
197
203
|
},
|
|
198
204
|
"peerDependenciesMeta": {
|
|
199
205
|
"@neondatabase/serverless": {
|
|
@@ -207,6 +213,9 @@
|
|
|
207
213
|
},
|
|
208
214
|
"react": {
|
|
209
215
|
"optional": true
|
|
216
|
+
},
|
|
217
|
+
"@ultrst-armada/krnl": {
|
|
218
|
+
"optional": true
|
|
210
219
|
}
|
|
211
220
|
},
|
|
212
221
|
"devDependencies": {
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createService,
|
|
3
|
+
createServiceDefinition
|
|
4
|
+
} from "./chunk-MWSYNRNZ.js";
|
|
5
|
+
|
|
6
|
+
// src/development/playwrightInspectionService.ts
|
|
7
|
+
import { randomUUID } from "crypto";
|
|
8
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
9
|
+
import { dirname, join } from "path";
|
|
10
|
+
|
|
11
|
+
// src/development/playwrightInspectionSupport.ts
|
|
12
|
+
import { createRequire } from "module";
|
|
13
|
+
var require2 = createRequire(import.meta.url);
|
|
14
|
+
function loadPlaywright() {
|
|
15
|
+
try {
|
|
16
|
+
return require2("playwright");
|
|
17
|
+
} catch {
|
|
18
|
+
throw new Error('Playwright is required for browser inspection. Install the optional "playwright" package and Chromium browser.');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function recordInspectionError(errors, kind, message, url, status, method) {
|
|
22
|
+
errors.push({ kind, message, ...url ? { url } : {}, ...status ? { status } : {}, ...method ? { method } : {} });
|
|
23
|
+
}
|
|
24
|
+
async function runInspectionCheck(page, check) {
|
|
25
|
+
try {
|
|
26
|
+
const locator = page.locator(check.selector);
|
|
27
|
+
if (await locator.count() === 0) throw new Error("Selector matched no elements");
|
|
28
|
+
if (check.visible !== void 0 && await locator.isVisible() !== check.visible) throw new Error(`Expected visible=${check.visible}`);
|
|
29
|
+
if (check.text !== void 0 && !(await locator.innerText()).includes(check.text)) throw new Error(`Expected text containing: ${check.text}`);
|
|
30
|
+
if (check.action?.type === "click") await locator.click();
|
|
31
|
+
if (check.action?.type === "fill") await locator.fill(check.action.value ?? "");
|
|
32
|
+
return { selector: check.selector, passed: true };
|
|
33
|
+
} catch (cause) {
|
|
34
|
+
return { selector: check.selector, passed: false, details: cause instanceof Error ? cause.message : String(cause) };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/development/playwrightInspectionService.ts
|
|
39
|
+
var PlaywrightInspectionRuntime = class {
|
|
40
|
+
async inspect(request) {
|
|
41
|
+
const started = Date.now();
|
|
42
|
+
const errors = [];
|
|
43
|
+
const logs = [];
|
|
44
|
+
const checks = [];
|
|
45
|
+
const screenshots = [];
|
|
46
|
+
const screenshotDirectory = request.screenshotDirectory ?? join(process.cwd(), "artifacts/playwright", randomUUID());
|
|
47
|
+
const reportPath = request.reportPath ?? join(screenshotDirectory, "report.json");
|
|
48
|
+
const timeout = request.timeoutMs ?? 15e3;
|
|
49
|
+
let browser;
|
|
50
|
+
try {
|
|
51
|
+
browser = await loadPlaywright().chromium.launch({ headless: true });
|
|
52
|
+
} catch (cause) {
|
|
53
|
+
recordInspectionError(errors, "browser", cause instanceof Error ? cause.message : String(cause), request.url);
|
|
54
|
+
const result2 = {
|
|
55
|
+
ok: false,
|
|
56
|
+
url: request.url,
|
|
57
|
+
durationMs: Date.now() - started,
|
|
58
|
+
errors,
|
|
59
|
+
logs,
|
|
60
|
+
checks,
|
|
61
|
+
screenshots,
|
|
62
|
+
reportPath
|
|
63
|
+
};
|
|
64
|
+
await mkdir(dirname(reportPath), { recursive: true });
|
|
65
|
+
await writeFile(reportPath, JSON.stringify(result2, null, 2), "utf8");
|
|
66
|
+
return result2;
|
|
67
|
+
}
|
|
68
|
+
const context = await browser.newContext({ ignoreHTTPSErrors: false });
|
|
69
|
+
const page = await context.newPage();
|
|
70
|
+
let status;
|
|
71
|
+
let title;
|
|
72
|
+
let domSnapshot;
|
|
73
|
+
page.on("console", (message) => {
|
|
74
|
+
const location = message.location();
|
|
75
|
+
const type = message.type();
|
|
76
|
+
logs.push({ type, message: message.text(), url: page.url(), ...location.lineNumber ? { line: location.lineNumber } : {}, ...location.columnNumber ? { column: location.columnNumber } : {} });
|
|
77
|
+
if (type === "error") recordInspectionError(errors, "console", message.text(), page.url());
|
|
78
|
+
});
|
|
79
|
+
page.on("pageerror", (cause) => recordInspectionError(errors, "pageerror", cause instanceof Error ? cause.stack ?? cause.message : String(cause), page.url()));
|
|
80
|
+
page.on("requestfailed", (requestInfo) => recordInspectionError(errors, "requestfailed", requestInfo.failure()?.errorText ?? "Request failed", requestInfo.url(), void 0, requestInfo.method()));
|
|
81
|
+
page.on("response", (response) => {
|
|
82
|
+
if (response.status() >= 400) recordInspectionError(errors, "http", `HTTP ${response.status()} ${response.statusText()}`, response.url(), response.status(), response.request().method());
|
|
83
|
+
});
|
|
84
|
+
page.on("crash", () => recordInspectionError(errors, "crash", "Browser page crashed", page.url()));
|
|
85
|
+
page.on("dialog", async (dialog) => {
|
|
86
|
+
recordInspectionError(errors, "dialog", `Unexpected ${dialog.type()} dialog: ${dialog.message()}`, page.url());
|
|
87
|
+
await dialog.dismiss();
|
|
88
|
+
});
|
|
89
|
+
try {
|
|
90
|
+
try {
|
|
91
|
+
const response = await page.goto(request.url, { waitUntil: request.waitUntil ?? "networkidle", timeout });
|
|
92
|
+
status = response?.status();
|
|
93
|
+
} catch (cause) {
|
|
94
|
+
recordInspectionError(errors, "navigation", cause instanceof Error ? cause.message : String(cause), request.url);
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
await page.waitForLoadState("domcontentloaded", { timeout });
|
|
98
|
+
} catch {
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
title = await page.title();
|
|
102
|
+
} catch {
|
|
103
|
+
}
|
|
104
|
+
for (const check of request.checks ?? []) checks.push(await runInspectionCheck(page, check));
|
|
105
|
+
for (const viewport of request.viewports ?? [{ width: 1440, height: 900 }, { width: 390, height: 844 }]) {
|
|
106
|
+
try {
|
|
107
|
+
await page.setViewportSize(viewport);
|
|
108
|
+
const layout = await page.evaluate(() => ({
|
|
109
|
+
viewportWidth: window.innerWidth,
|
|
110
|
+
documentWidth: document.documentElement.scrollWidth,
|
|
111
|
+
brokenImages: Array.from(document.images).filter((image) => image.complete && image.naturalWidth === 0).map((image) => image.src)
|
|
112
|
+
}));
|
|
113
|
+
if (layout.documentWidth > layout.viewportWidth + 1) {
|
|
114
|
+
recordInspectionError(errors, "layout", `Horizontal overflow: document width ${layout.documentWidth}px exceeds viewport ${layout.viewportWidth}px`, request.url);
|
|
115
|
+
}
|
|
116
|
+
for (const imageUrl of layout.brokenImages) recordInspectionError(errors, "asset", "Image failed to render", imageUrl);
|
|
117
|
+
{
|
|
118
|
+
await mkdir(screenshotDirectory, { recursive: true });
|
|
119
|
+
const path = join(screenshotDirectory, `inspection-${viewport.width}x${viewport.height}.png`);
|
|
120
|
+
await page.screenshot({ path, fullPage: true });
|
|
121
|
+
screenshots.push(path);
|
|
122
|
+
}
|
|
123
|
+
} catch (cause) {
|
|
124
|
+
recordInspectionError(errors, "screenshot", cause instanceof Error ? cause.message : String(cause), request.url);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (request.captureDom) {
|
|
128
|
+
try {
|
|
129
|
+
const html = await page.content();
|
|
130
|
+
domSnapshot = html.slice(0, request.maxDomCharacters ?? 4e4);
|
|
131
|
+
} catch (cause) {
|
|
132
|
+
recordInspectionError(errors, "dom", cause instanceof Error ? cause.message : String(cause), request.url);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} finally {
|
|
136
|
+
await page.close().catch(() => void 0);
|
|
137
|
+
await context.close().catch(() => void 0);
|
|
138
|
+
await browser.close().catch(() => void 0);
|
|
139
|
+
}
|
|
140
|
+
for (const check of checks) if (!check.passed) recordInspectionError(errors, "assertion", check.details ?? "Inspection assertion failed", request.url);
|
|
141
|
+
const result = {
|
|
142
|
+
ok: errors.length === 0,
|
|
143
|
+
url: request.url,
|
|
144
|
+
...title ? { title } : {},
|
|
145
|
+
...status !== void 0 ? { status } : {},
|
|
146
|
+
durationMs: Date.now() - started,
|
|
147
|
+
errors,
|
|
148
|
+
logs,
|
|
149
|
+
checks,
|
|
150
|
+
screenshots,
|
|
151
|
+
reportPath,
|
|
152
|
+
...domSnapshot ? { domSnapshot } : {}
|
|
153
|
+
};
|
|
154
|
+
await mkdir(dirname(reportPath), { recursive: true });
|
|
155
|
+
await writeFile(reportPath, JSON.stringify(result, null, 2), "utf8");
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var runtime = new PlaywrightInspectionRuntime();
|
|
160
|
+
var PlaywrightInspectionServiceDefinition = createServiceDefinition({
|
|
161
|
+
id: "kloks.backend.playwrightInspection",
|
|
162
|
+
name: "PlaywrightInspectionService",
|
|
163
|
+
version: "1.0.0",
|
|
164
|
+
operations: {
|
|
165
|
+
inspect: {
|
|
166
|
+
id: "PlaywrightInspectionService.inspect",
|
|
167
|
+
name: "inspect",
|
|
168
|
+
handler: async (input) => runtime.inspect(input)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
var PlaywrightInspectionServiceFacade = {
|
|
173
|
+
id: PlaywrightInspectionServiceDefinition.id,
|
|
174
|
+
name: PlaywrightInspectionServiceDefinition.name,
|
|
175
|
+
version: PlaywrightInspectionServiceDefinition.version,
|
|
176
|
+
runtime: "server",
|
|
177
|
+
deployment: "local",
|
|
178
|
+
definition: PlaywrightInspectionServiceDefinition,
|
|
179
|
+
createInstance: () => createService(PlaywrightInspectionServiceDefinition),
|
|
180
|
+
execute: async (op, input) => {
|
|
181
|
+
const instance = createService(PlaywrightInspectionServiceDefinition);
|
|
182
|
+
await instance.start();
|
|
183
|
+
return instance.call(op, input);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export {
|
|
188
|
+
PlaywrightInspectionRuntime,
|
|
189
|
+
PlaywrightInspectionServiceDefinition,
|
|
190
|
+
PlaywrightInspectionServiceFacade
|
|
191
|
+
};
|
|
@@ -137,8 +137,8 @@ function parseDevelopmentDiagnostics(output, exitCode = 0) {
|
|
|
137
137
|
}
|
|
138
138
|
return diagnostics;
|
|
139
139
|
}
|
|
140
|
-
function captureDevelopmentProcess(
|
|
141
|
-
const [consumerOutput, diagnosticOutput] =
|
|
140
|
+
function captureDevelopmentProcess(process) {
|
|
141
|
+
const [consumerOutput, diagnosticOutput] = process.output.tee();
|
|
142
142
|
const logs = (async () => {
|
|
143
143
|
const reader = diagnosticOutput.getReader();
|
|
144
144
|
let output = "";
|
|
@@ -151,10 +151,10 @@ function captureDevelopmentProcess(process2) {
|
|
|
151
151
|
} finally {
|
|
152
152
|
reader.releaseLock();
|
|
153
153
|
}
|
|
154
|
-
const exitCode = await
|
|
154
|
+
const exitCode = await process.exit;
|
|
155
155
|
return { output, exitCode, diagnostics: parseDevelopmentDiagnostics(output, exitCode) };
|
|
156
156
|
})();
|
|
157
|
-
return { ...
|
|
157
|
+
return { ...process, output: consumerOutput, logs };
|
|
158
158
|
}
|
|
159
159
|
function resolveWebContainerCommand(task) {
|
|
160
160
|
const command = COMMANDS[task];
|
|
@@ -191,10 +191,10 @@ var WebContainerRuntime = class {
|
|
|
191
191
|
}
|
|
192
192
|
async runProcess(command, args, cwd, env) {
|
|
193
193
|
const container = await this.boot();
|
|
194
|
-
const
|
|
194
|
+
const process = await container.spawn(command, args, { cwd, env });
|
|
195
195
|
const started = Date.now();
|
|
196
196
|
let output = "";
|
|
197
|
-
const reader =
|
|
197
|
+
const reader = process.output.getReader();
|
|
198
198
|
try {
|
|
199
199
|
while (true) {
|
|
200
200
|
const next = await reader.read();
|
|
@@ -204,7 +204,7 @@ var WebContainerRuntime = class {
|
|
|
204
204
|
} finally {
|
|
205
205
|
reader.releaseLock();
|
|
206
206
|
}
|
|
207
|
-
const exitCode = await
|
|
207
|
+
const exitCode = await process.exit;
|
|
208
208
|
return { exitCode, output, command: [command, ...args].join(" "), durationMs: Date.now() - started, diagnostics: parseDevelopmentDiagnostics(output, exitCode) };
|
|
209
209
|
}
|
|
210
210
|
async run(task, cwd, env) {
|
|
@@ -226,8 +226,8 @@ var WebContainerRuntime = class {
|
|
|
226
226
|
}
|
|
227
227
|
async spawnCommand(command, args = [], cwd, env) {
|
|
228
228
|
const container = await this.boot();
|
|
229
|
-
const
|
|
230
|
-
return captureDevelopmentProcess(
|
|
229
|
+
const process = await container.spawn(command, args, { cwd, env });
|
|
230
|
+
return captureDevelopmentProcess(process);
|
|
231
231
|
}
|
|
232
232
|
async teardown() {
|
|
233
233
|
const container = sharedContainer;
|
|
@@ -351,8 +351,8 @@ var COMMANDS2 = {
|
|
|
351
351
|
var DEFAULT_LAYERS = ["lockfile-check", "syntax", "lint", "krnl", "frnl"];
|
|
352
352
|
var commandText = (command, args) => [command, ...args].join(" ");
|
|
353
353
|
var CodeValidationRuntime = class {
|
|
354
|
-
constructor(
|
|
355
|
-
this.runtime =
|
|
354
|
+
constructor(runtime5 = new WebContainerRuntime()) {
|
|
355
|
+
this.runtime = runtime5;
|
|
356
356
|
}
|
|
357
357
|
runtime;
|
|
358
358
|
async validate(input = {}) {
|
|
@@ -406,8 +406,8 @@ var CodeValidationServiceFacade = {
|
|
|
406
406
|
|
|
407
407
|
// src/development/codeDiagnosticsService.ts
|
|
408
408
|
var CodeDiagnosticsService = class {
|
|
409
|
-
constructor(
|
|
410
|
-
this.runtime =
|
|
409
|
+
constructor(runtime5 = new WebContainerRuntime()) {
|
|
410
|
+
this.runtime = runtime5;
|
|
411
411
|
}
|
|
412
412
|
runtime;
|
|
413
413
|
async diagnostics(input = {}) {
|
|
@@ -425,8 +425,8 @@ var TYPESCRIPT_LANGUAGE_SERVER_VERSION = "6.0.2";
|
|
|
425
425
|
var PACKAGE = TYPESCRIPT_LANGUAGE_SERVER_PACKAGE;
|
|
426
426
|
var DEFAULT_VERSION = TYPESCRIPT_LANGUAGE_SERVER_VERSION;
|
|
427
427
|
var TypeScriptLanguageServerRuntime = class {
|
|
428
|
-
constructor(
|
|
429
|
-
this.runtime =
|
|
428
|
+
constructor(runtime5 = new WebContainerRuntime()) {
|
|
429
|
+
this.runtime = runtime5;
|
|
430
430
|
}
|
|
431
431
|
runtime;
|
|
432
432
|
process = null;
|
|
@@ -461,13 +461,13 @@ var TypeScriptLanguageServerRuntime = class {
|
|
|
461
461
|
return { sent: true };
|
|
462
462
|
}
|
|
463
463
|
async stop() {
|
|
464
|
-
const
|
|
464
|
+
const process = this.process;
|
|
465
465
|
this.process = null;
|
|
466
466
|
this.writer?.releaseLock();
|
|
467
467
|
this.writer = null;
|
|
468
468
|
for (const pending of this.pending.values()) pending.reject(new Error("Language server stopped"));
|
|
469
469
|
this.pending.clear();
|
|
470
|
-
if (
|
|
470
|
+
if (process) await process.kill();
|
|
471
471
|
return { stopped: true };
|
|
472
472
|
}
|
|
473
473
|
status() {
|
|
@@ -577,8 +577,8 @@ var PROVIDERS = [
|
|
|
577
577
|
}
|
|
578
578
|
];
|
|
579
579
|
var AgentHarnessRuntime = class {
|
|
580
|
-
constructor(
|
|
581
|
-
this.runtime =
|
|
580
|
+
constructor(runtime5 = new WebContainerRuntime()) {
|
|
581
|
+
this.runtime = runtime5;
|
|
582
582
|
}
|
|
583
583
|
runtime;
|
|
584
584
|
providers() {
|
|
@@ -638,187 +638,6 @@ var AgentHarnessServiceFacade = {
|
|
|
638
638
|
}
|
|
639
639
|
};
|
|
640
640
|
|
|
641
|
-
// src/development/playwrightInspectionService.ts
|
|
642
|
-
import { randomUUID } from "crypto";
|
|
643
|
-
import { mkdir, writeFile } from "fs/promises";
|
|
644
|
-
import { dirname, join } from "path";
|
|
645
|
-
|
|
646
|
-
// src/development/playwrightInspectionSupport.ts
|
|
647
|
-
import { createRequire } from "module";
|
|
648
|
-
var require2 = createRequire(import.meta.url);
|
|
649
|
-
function loadPlaywright() {
|
|
650
|
-
try {
|
|
651
|
-
return require2("playwright");
|
|
652
|
-
} catch {
|
|
653
|
-
throw new Error('Playwright is required for browser inspection. Install the optional "playwright" package and Chromium browser.');
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
function recordInspectionError(errors, kind, message, url, status, method) {
|
|
657
|
-
errors.push({ kind, message, ...url ? { url } : {}, ...status ? { status } : {}, ...method ? { method } : {} });
|
|
658
|
-
}
|
|
659
|
-
async function runInspectionCheck(page, check) {
|
|
660
|
-
try {
|
|
661
|
-
const locator = page.locator(check.selector);
|
|
662
|
-
if (await locator.count() === 0) throw new Error("Selector matched no elements");
|
|
663
|
-
if (check.visible !== void 0 && await locator.isVisible() !== check.visible) throw new Error(`Expected visible=${check.visible}`);
|
|
664
|
-
if (check.text !== void 0 && !(await locator.innerText()).includes(check.text)) throw new Error(`Expected text containing: ${check.text}`);
|
|
665
|
-
if (check.action?.type === "click") await locator.click();
|
|
666
|
-
if (check.action?.type === "fill") await locator.fill(check.action.value ?? "");
|
|
667
|
-
return { selector: check.selector, passed: true };
|
|
668
|
-
} catch (cause) {
|
|
669
|
-
return { selector: check.selector, passed: false, details: cause instanceof Error ? cause.message : String(cause) };
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
// src/development/playwrightInspectionService.ts
|
|
674
|
-
var PlaywrightInspectionRuntime = class {
|
|
675
|
-
async inspect(request) {
|
|
676
|
-
const started = Date.now();
|
|
677
|
-
const errors = [];
|
|
678
|
-
const logs = [];
|
|
679
|
-
const checks = [];
|
|
680
|
-
const screenshots = [];
|
|
681
|
-
const screenshotDirectory = request.screenshotDirectory ?? join(process.cwd(), "artifacts/playwright", randomUUID());
|
|
682
|
-
const reportPath = request.reportPath ?? join(screenshotDirectory, "report.json");
|
|
683
|
-
const timeout = request.timeoutMs ?? 15e3;
|
|
684
|
-
let browser;
|
|
685
|
-
try {
|
|
686
|
-
browser = await loadPlaywright().chromium.launch({ headless: true });
|
|
687
|
-
} catch (cause) {
|
|
688
|
-
recordInspectionError(errors, "browser", cause instanceof Error ? cause.message : String(cause), request.url);
|
|
689
|
-
const result2 = {
|
|
690
|
-
ok: false,
|
|
691
|
-
url: request.url,
|
|
692
|
-
durationMs: Date.now() - started,
|
|
693
|
-
errors,
|
|
694
|
-
logs,
|
|
695
|
-
checks,
|
|
696
|
-
screenshots,
|
|
697
|
-
reportPath
|
|
698
|
-
};
|
|
699
|
-
await mkdir(dirname(reportPath), { recursive: true });
|
|
700
|
-
await writeFile(reportPath, JSON.stringify(result2, null, 2), "utf8");
|
|
701
|
-
return result2;
|
|
702
|
-
}
|
|
703
|
-
const context = await browser.newContext({ ignoreHTTPSErrors: false });
|
|
704
|
-
const page = await context.newPage();
|
|
705
|
-
let status;
|
|
706
|
-
let title;
|
|
707
|
-
let domSnapshot;
|
|
708
|
-
page.on("console", (message) => {
|
|
709
|
-
const location = message.location();
|
|
710
|
-
const type = message.type();
|
|
711
|
-
logs.push({ type, message: message.text(), url: page.url(), ...location.lineNumber ? { line: location.lineNumber } : {}, ...location.columnNumber ? { column: location.columnNumber } : {} });
|
|
712
|
-
if (type === "error") recordInspectionError(errors, "console", message.text(), page.url());
|
|
713
|
-
});
|
|
714
|
-
page.on("pageerror", (cause) => recordInspectionError(errors, "pageerror", cause instanceof Error ? cause.stack ?? cause.message : String(cause), page.url()));
|
|
715
|
-
page.on("requestfailed", (requestInfo) => recordInspectionError(errors, "requestfailed", requestInfo.failure()?.errorText ?? "Request failed", requestInfo.url(), void 0, requestInfo.method()));
|
|
716
|
-
page.on("response", (response) => {
|
|
717
|
-
if (response.status() >= 400) recordInspectionError(errors, "http", `HTTP ${response.status()} ${response.statusText()}`, response.url(), response.status(), response.request().method());
|
|
718
|
-
});
|
|
719
|
-
page.on("crash", () => recordInspectionError(errors, "crash", "Browser page crashed", page.url()));
|
|
720
|
-
page.on("dialog", async (dialog) => {
|
|
721
|
-
recordInspectionError(errors, "dialog", `Unexpected ${dialog.type()} dialog: ${dialog.message()}`, page.url());
|
|
722
|
-
await dialog.dismiss();
|
|
723
|
-
});
|
|
724
|
-
try {
|
|
725
|
-
try {
|
|
726
|
-
const response = await page.goto(request.url, { waitUntil: request.waitUntil ?? "networkidle", timeout });
|
|
727
|
-
status = response?.status();
|
|
728
|
-
} catch (cause) {
|
|
729
|
-
recordInspectionError(errors, "navigation", cause instanceof Error ? cause.message : String(cause), request.url);
|
|
730
|
-
}
|
|
731
|
-
try {
|
|
732
|
-
await page.waitForLoadState("domcontentloaded", { timeout });
|
|
733
|
-
} catch {
|
|
734
|
-
}
|
|
735
|
-
try {
|
|
736
|
-
title = await page.title();
|
|
737
|
-
} catch {
|
|
738
|
-
}
|
|
739
|
-
for (const check of request.checks ?? []) checks.push(await runInspectionCheck(page, check));
|
|
740
|
-
for (const viewport of request.viewports ?? [{ width: 1440, height: 900 }, { width: 390, height: 844 }]) {
|
|
741
|
-
try {
|
|
742
|
-
await page.setViewportSize(viewport);
|
|
743
|
-
const layout = await page.evaluate(() => ({
|
|
744
|
-
viewportWidth: window.innerWidth,
|
|
745
|
-
documentWidth: document.documentElement.scrollWidth,
|
|
746
|
-
brokenImages: Array.from(document.images).filter((image) => image.complete && image.naturalWidth === 0).map((image) => image.src)
|
|
747
|
-
}));
|
|
748
|
-
if (layout.documentWidth > layout.viewportWidth + 1) {
|
|
749
|
-
recordInspectionError(errors, "layout", `Horizontal overflow: document width ${layout.documentWidth}px exceeds viewport ${layout.viewportWidth}px`, request.url);
|
|
750
|
-
}
|
|
751
|
-
for (const imageUrl of layout.brokenImages) recordInspectionError(errors, "asset", "Image failed to render", imageUrl);
|
|
752
|
-
{
|
|
753
|
-
await mkdir(screenshotDirectory, { recursive: true });
|
|
754
|
-
const path = join(screenshotDirectory, `inspection-${viewport.width}x${viewport.height}.png`);
|
|
755
|
-
await page.screenshot({ path, fullPage: true });
|
|
756
|
-
screenshots.push(path);
|
|
757
|
-
}
|
|
758
|
-
} catch (cause) {
|
|
759
|
-
recordInspectionError(errors, "screenshot", cause instanceof Error ? cause.message : String(cause), request.url);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
if (request.captureDom) {
|
|
763
|
-
try {
|
|
764
|
-
const html = await page.content();
|
|
765
|
-
domSnapshot = html.slice(0, request.maxDomCharacters ?? 4e4);
|
|
766
|
-
} catch (cause) {
|
|
767
|
-
recordInspectionError(errors, "dom", cause instanceof Error ? cause.message : String(cause), request.url);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
} finally {
|
|
771
|
-
await page.close().catch(() => void 0);
|
|
772
|
-
await context.close().catch(() => void 0);
|
|
773
|
-
await browser.close().catch(() => void 0);
|
|
774
|
-
}
|
|
775
|
-
for (const check of checks) if (!check.passed) recordInspectionError(errors, "assertion", check.details ?? "Inspection assertion failed", request.url);
|
|
776
|
-
const result = {
|
|
777
|
-
ok: errors.length === 0,
|
|
778
|
-
url: request.url,
|
|
779
|
-
...title ? { title } : {},
|
|
780
|
-
...status !== void 0 ? { status } : {},
|
|
781
|
-
durationMs: Date.now() - started,
|
|
782
|
-
errors,
|
|
783
|
-
logs,
|
|
784
|
-
checks,
|
|
785
|
-
screenshots,
|
|
786
|
-
reportPath,
|
|
787
|
-
...domSnapshot ? { domSnapshot } : {}
|
|
788
|
-
};
|
|
789
|
-
await mkdir(dirname(reportPath), { recursive: true });
|
|
790
|
-
await writeFile(reportPath, JSON.stringify(result, null, 2), "utf8");
|
|
791
|
-
return result;
|
|
792
|
-
}
|
|
793
|
-
};
|
|
794
|
-
var runtime5 = new PlaywrightInspectionRuntime();
|
|
795
|
-
var PlaywrightInspectionServiceDefinition = createServiceDefinition({
|
|
796
|
-
id: "kloks.backend.playwrightInspection",
|
|
797
|
-
name: "PlaywrightInspectionService",
|
|
798
|
-
version: "1.0.0",
|
|
799
|
-
operations: {
|
|
800
|
-
inspect: {
|
|
801
|
-
id: "PlaywrightInspectionService.inspect",
|
|
802
|
-
name: "inspect",
|
|
803
|
-
handler: async (input) => runtime5.inspect(input)
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
});
|
|
807
|
-
var PlaywrightInspectionServiceFacade = {
|
|
808
|
-
id: PlaywrightInspectionServiceDefinition.id,
|
|
809
|
-
name: PlaywrightInspectionServiceDefinition.name,
|
|
810
|
-
version: PlaywrightInspectionServiceDefinition.version,
|
|
811
|
-
runtime: "server",
|
|
812
|
-
deployment: "local",
|
|
813
|
-
definition: PlaywrightInspectionServiceDefinition,
|
|
814
|
-
createInstance: () => createService(PlaywrightInspectionServiceDefinition),
|
|
815
|
-
execute: async (op, input) => {
|
|
816
|
-
const instance = createService(PlaywrightInspectionServiceDefinition);
|
|
817
|
-
await instance.start();
|
|
818
|
-
return instance.call(op, input);
|
|
819
|
-
}
|
|
820
|
-
};
|
|
821
|
-
|
|
822
641
|
export {
|
|
823
642
|
GitHubActionsClient,
|
|
824
643
|
GitHubActionsServiceDefinition,
|
|
@@ -844,8 +663,5 @@ export {
|
|
|
844
663
|
TypeScriptLanguageServerServiceFacade,
|
|
845
664
|
AgentHarnessRuntime,
|
|
846
665
|
AgentHarnessServiceDefinition,
|
|
847
|
-
AgentHarnessServiceFacade
|
|
848
|
-
PlaywrightInspectionRuntime,
|
|
849
|
-
PlaywrightInspectionServiceDefinition,
|
|
850
|
-
PlaywrightInspectionServiceFacade
|
|
666
|
+
AgentHarnessServiceFacade
|
|
851
667
|
};
|
|
File without changes
|