@ultrst-armada/kloks 1.23.0 → 1.24.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.
Files changed (26) hide show
  1. package/.krusbl-release-attestation.json +3 -3
  2. package/package.json +6 -1
  3. package/packages/backend/dist/auth/index.d.ts +2 -0
  4. package/packages/backend/dist/auth/index.js +2 -2
  5. package/packages/backend/dist/{chunk-WTBAG4AV.js → chunk-2HCQ2SIR.js} +9 -3
  6. package/packages/backend/dist/{chunk-IJ5QNZCY.js → chunk-6TRVGWXP.js} +282 -47
  7. package/packages/backend/dist/{chunk-W6JNJD3Q.js → chunk-A3BE6ROS.js} +1 -1
  8. package/packages/backend/dist/{chunk-3IUA66RS.js → chunk-HF5SGQ5V.js} +1 -1
  9. package/packages/backend/dist/{chunk-47IVAXPJ.js → chunk-IGZB4RYT.js} +1 -1
  10. package/packages/backend/dist/{chunk-VAFCR2MS.js → chunk-JCMB7BIM.js} +11 -3
  11. package/packages/backend/dist/{chunk-VN2YMZJO.js → chunk-JGUWYVOL.js} +1 -1
  12. package/packages/backend/dist/{chunk-NB2X3HEX.js → chunk-VTU6CNZD.js} +4 -4
  13. package/packages/backend/dist/{chunk-6DNGLKAV.js → chunk-WQ4XZY4L.js} +5 -5
  14. package/packages/backend/dist/development/index.d.ts +108 -6
  15. package/packages/backend/dist/development/index.js +15 -3
  16. package/packages/backend/dist/index.d.ts +1 -1
  17. package/packages/backend/dist/index.js +32 -20
  18. package/packages/backend/dist/krnl-services.js +5 -5
  19. package/packages/backend/dist/services/index.js +3 -3
  20. package/packages/backend/dist/srkl/index.js +2 -2
  21. package/packages/backend/dist/workspace/index.js +3 -3
  22. package/packages/backend/package.json +1 -1
  23. package/packages/semantic-runtime/dist/index.d.ts +132 -2
  24. package/packages/semantic-runtime/dist/index.js +300 -8
  25. package/packages/services/dist/index.d.ts +71 -1
  26. package/packages/services/dist/index.js +125 -0
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "packageName": "@ultrst-armada/kloks",
4
- "version": "1.23.0",
5
- "sourceCommit": "dd84756182c810b22853ab5f91c6a9cbf1fa103e",
4
+ "version": "1.24.1",
5
+ "sourceCommit": "55f07544f89f1924b7374305941b6444e6257095",
6
6
  "releaseWorkflow": "npm Release",
7
- "workflowRunId": "41207095076"
7
+ "workflowRunId": "41517983084"
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultrst-armada/kloks",
3
- "version": "1.23.0",
3
+ "version": "1.24.1",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -112,6 +112,11 @@
112
112
  "import": "./packages/backend/dist/development/index.js",
113
113
  "default": "./packages/backend/dist/development/index.js"
114
114
  },
115
+ "./browser-inspection": {
116
+ "types": "./packages/backend/dist/development/playwrightInspectionTypes.d.ts",
117
+ "import": "./packages/backend/dist/development/playwrightInspectionService.js",
118
+ "default": "./packages/backend/dist/development/playwrightInspectionService.js"
119
+ },
115
120
  "./ai-provider": {
116
121
  "types": "./packages/backend/dist/ai-provider/index.d.ts",
117
122
  "import": "./packages/backend/dist/ai-provider/index.js",
@@ -52,6 +52,7 @@ interface AuthResult {
52
52
  session?: Record<string, unknown>;
53
53
  error?: string;
54
54
  redirectUrl?: string;
55
+ token?: string;
55
56
  }
56
57
  declare class CanonicalAuthClient {
57
58
  private readonly baseUrl;
@@ -64,6 +65,7 @@ declare class CanonicalAuthClient {
64
65
  signInGoogle(callbackURL: string): Promise<AuthResult>;
65
66
  requestGoogleDriveAccess(callbackURL?: string): Promise<AuthResult>;
66
67
  getSession(cookie?: string): Promise<CanonicalAuthSession | null>;
68
+ getSessionWithToken(token: string): Promise<CanonicalAuthSession | null>;
67
69
  signOut(): Promise<boolean>;
68
70
  }
69
71
  declare function createCanonicalAuthClient(baseUrl: string, fetcher?: typeof fetch): CanonicalAuthClient;
@@ -3,7 +3,7 @@ import {
3
3
  BaseAccountProvider,
4
4
  LocalAccountProvider,
5
5
  PasswordHasher
6
- } from "../chunk-W6JNJD3Q.js";
6
+ } from "../chunk-A3BE6ROS.js";
7
7
  import {
8
8
  CanonicalAuthClient,
9
9
  RateLimiter,
@@ -11,7 +11,7 @@ import {
11
11
  createCanonicalAuthClient,
12
12
  loginSystemUser,
13
13
  resolveUserFromToken
14
- } from "../chunk-WTBAG4AV.js";
14
+ } from "../chunk-2HCQ2SIR.js";
15
15
  import "../chunk-QGM4M3NI.js";
16
16
  export {
17
17
  AdminGuard,
@@ -74,7 +74,7 @@ var CanonicalAuthClient = class {
74
74
  } catch {
75
75
  data = { message: text };
76
76
  }
77
- return { status: response.status, data };
77
+ return { status: response.status, data, token: response.headers.get("set-auth-token") ?? void 0 };
78
78
  }
79
79
  async signInEmail(email, password) {
80
80
  const result = await this.request("/sign-in/email", {
@@ -84,7 +84,7 @@ var CanonicalAuthClient = class {
84
84
  if (result.status >= 400 || result.data?.error) {
85
85
  return { success: false, status: result.status, error: result.data?.error?.message ?? result.data?.message ?? "Authentication failed." };
86
86
  }
87
- return { success: true, status: result.status, user: result.data?.user, session: result.data?.session };
87
+ return { success: true, status: result.status, user: result.data?.user, session: result.data?.session, token: result.token };
88
88
  }
89
89
  async signUpEmail(email, password, name) {
90
90
  const result = await this.request("/sign-up/email", {
@@ -94,7 +94,7 @@ var CanonicalAuthClient = class {
94
94
  if (result.status >= 400 || result.data?.error) {
95
95
  return { success: false, status: result.status, error: result.data?.error?.message ?? result.data?.message ?? "Registration failed." };
96
96
  }
97
- return { success: true, status: result.status, user: result.data?.user, session: result.data?.session };
97
+ return { success: true, status: result.status, user: result.data?.user, session: result.data?.session, token: result.data?.token ?? result.data?.session?.token };
98
98
  }
99
99
  async signInGoogle(callbackURL) {
100
100
  const result = await this.request("/sign-in/social", {
@@ -133,6 +133,12 @@ var CanonicalAuthClient = class {
133
133
  if (result.status >= 400 || !result.data?.user) return null;
134
134
  return result.data;
135
135
  }
136
+ async getSessionWithToken(token) {
137
+ if (!token?.trim()) return null;
138
+ const result = await this.request("/get-session", { headers: { Authorization: `Bearer ${token}` } });
139
+ if (result.status >= 400 || !result.data?.user) return null;
140
+ return result.data;
141
+ }
136
142
  async signOut() {
137
143
  const result = await this.request("/sign-out", { method: "POST", body: "{}" });
138
144
  return result.status < 400 && !result.data?.error;
@@ -104,43 +104,97 @@ var COMMANDS = {
104
104
  lint: { command: "pnpm", args: ["lint"] },
105
105
  test: { command: "pnpm", args: ["test"] },
106
106
  build: { command: "pnpm", args: ["build"] },
107
- validate: { command: "pnpm", args: ["lint"] },
107
+ validate: { command: "pnpm", args: ["validate"] },
108
108
  check: { command: "pnpm", args: ["lint"] }
109
109
  };
110
+ function parseDevelopmentDiagnostics(output, exitCode = 0) {
111
+ const diagnostics = [];
112
+ const seen = /* @__PURE__ */ new Set();
113
+ const add = (diagnostic) => {
114
+ const key = [diagnostic.source, diagnostic.code, diagnostic.file, diagnostic.line, diagnostic.message].join("|");
115
+ if (!seen.has(key)) {
116
+ seen.add(key);
117
+ diagnostics.push(diagnostic);
118
+ }
119
+ };
120
+ for (const line of output.split(/\r?\n/)) {
121
+ const typescript = line.match(/^(.+?)\((\d+),(\d+)\):\s*(error|warning)\s+(TS\d+):\s*(.+)$/);
122
+ if (typescript) {
123
+ add({ source: "typescript", severity: typescript[4], file: typescript[1], line: Number(typescript[2]), column: Number(typescript[3]), code: typescript[5], message: typescript[6] });
124
+ continue;
125
+ }
126
+ const eslint = line.match(/^(.+?):(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+([^\s]+)$/);
127
+ if (eslint) {
128
+ add({ source: "eslint", severity: eslint[4], file: eslint[1], line: Number(eslint[2]), column: Number(eslint[3]), code: eslint[6], message: eslint[5] });
129
+ continue;
130
+ }
131
+ const bundler = line.match(/(?:✘|×|ERROR|error:|Error:)\s*(.+)$/);
132
+ if (bundler) add({ source: "bundler", severity: "error", message: bundler[1].trim() });
133
+ if (/\bWARN(?:ING)?\b/i.test(line)) add({ source: "package-manager", severity: "warning", message: line.trim() });
134
+ }
135
+ if (exitCode !== 0 && diagnostics.every((item) => item.severity !== "error")) {
136
+ add({ source: "unknown", severity: "error", message: "Command failed with exit code " + exitCode + "; inspect captured output for details." });
137
+ }
138
+ return diagnostics;
139
+ }
140
+ function captureDevelopmentProcess(process2) {
141
+ const [consumerOutput, diagnosticOutput] = process2.output.tee();
142
+ const logs = (async () => {
143
+ const reader = diagnosticOutput.getReader();
144
+ let output = "";
145
+ try {
146
+ while (true) {
147
+ const next = await reader.read();
148
+ if (next.done) break;
149
+ output += next.value;
150
+ }
151
+ } finally {
152
+ reader.releaseLock();
153
+ }
154
+ const exitCode = await process2.exit;
155
+ return { output, exitCode, diagnostics: parseDevelopmentDiagnostics(output, exitCode) };
156
+ })();
157
+ return { ...process2, output: consumerOutput, logs };
158
+ }
159
+ function resolveWebContainerCommand(task) {
160
+ const command = COMMANDS[task];
161
+ return { command: command.command, args: [...command.args] };
162
+ }
110
163
  var runQueue = Promise.resolve();
164
+ var sharedContainer = null;
165
+ var sharedContainerPromise = null;
111
166
  var WebContainerRuntime = class {
112
- container = null;
113
- instancePromise = null;
114
167
  async boot() {
115
168
  if (typeof window !== "undefined" && !window.crossOriginIsolated) {
116
169
  throw new Error("WebContainer requires a cross-origin-isolated page. Ensure COOP=same-origin and COEP=require-corp are served.");
117
170
  }
118
- if (this.container) return this.container;
119
- if (!this.instancePromise) {
120
- this.instancePromise = import("@webcontainer/api").then(async (module) => {
171
+ if (sharedContainer) return sharedContainer;
172
+ if (!sharedContainerPromise) {
173
+ sharedContainerPromise = import("@webcontainer/api").then(async (module) => {
121
174
  const container = await module.WebContainer.boot({
122
175
  coep: "require-corp",
123
176
  workdirName: "kloks-development"
124
177
  });
125
- this.container = container;
178
+ sharedContainer = container;
126
179
  return container;
127
180
  }).catch((error) => {
128
- this.instancePromise = null;
181
+ sharedContainerPromise = null;
129
182
  throw error;
130
183
  });
131
184
  }
132
- return this.instancePromise;
185
+ return sharedContainerPromise;
133
186
  }
134
- async mount(files) {
187
+ async mount(files, mountPoint) {
135
188
  const container = await this.boot();
136
- await container.mount(files);
137
- return { mounted: true };
189
+ await container.mount(files, mountPoint ? { mountPoint } : void 0);
190
+ return { mounted: true, mountPoint: mountPoint ?? "/" };
138
191
  }
139
192
  async runProcess(command, args, cwd, env) {
140
193
  const container = await this.boot();
141
- const process = await container.spawn(command, args, { cwd, env });
194
+ const process2 = await container.spawn(command, args, { cwd, env });
195
+ const started = Date.now();
142
196
  let output = "";
143
- const reader = process.output.getReader();
197
+ const reader = process2.output.getReader();
144
198
  try {
145
199
  while (true) {
146
200
  const next = await reader.read();
@@ -150,10 +204,11 @@ var WebContainerRuntime = class {
150
204
  } finally {
151
205
  reader.releaseLock();
152
206
  }
153
- return { exitCode: await process.exit, output };
207
+ const exitCode = await process2.exit;
208
+ return { exitCode, output, command: [command, ...args].join(" "), durationMs: Date.now() - started, diagnostics: parseDevelopmentDiagnostics(output, exitCode) };
154
209
  }
155
210
  async run(task, cwd, env) {
156
- const spec = COMMANDS[task];
211
+ const spec = resolveWebContainerCommand(task);
157
212
  return this.runCommand(spec.command, spec.args, cwd, env);
158
213
  }
159
214
  async runCommand(command, args = [], cwd, env) {
@@ -171,13 +226,14 @@ var WebContainerRuntime = class {
171
226
  }
172
227
  async spawnCommand(command, args = [], cwd, env) {
173
228
  const container = await this.boot();
174
- return container.spawn(command, args, { cwd, env });
229
+ const process2 = await container.spawn(command, args, { cwd, env });
230
+ return captureDevelopmentProcess(process2);
175
231
  }
176
232
  async teardown() {
177
- const container = this.container;
178
- this.container = null;
179
- this.instancePromise = null;
180
- container?.teardown();
233
+ const container = sharedContainer;
234
+ sharedContainer = null;
235
+ sharedContainerPromise = null;
236
+ await container?.teardown();
181
237
  return { tornDown: true };
182
238
  }
183
239
  };
@@ -185,17 +241,17 @@ var runtime = new WebContainerRuntime();
185
241
  var WebContainerServiceDefinition = createServiceDefinition({
186
242
  id: "kloks.backend.webContainer",
187
243
  name: "WebContainerService",
188
- version: "1.1.0",
244
+ version: "1.2.0",
189
245
  operations: {
190
246
  boot: { id: "WebContainerService.boot", name: "boot", handler: async () => {
191
247
  await runtime.boot();
192
248
  return { ready: true };
193
249
  } },
194
- mount: { id: "WebContainerService.mount", name: "mount", handler: async (input) => runtime.mount(input.files) },
250
+ mount: { id: "WebContainerService.mount", name: "mount", handler: async (input) => runtime.mount(input.files, input.mountPoint) },
195
251
  run: { id: "WebContainerService.run", name: "run", handler: async (input) => runtime.run(input.task, input.cwd, input.env) },
196
252
  runCommand: { id: "WebContainerService.runCommand", name: "runCommand", handler: async (input) => runtime.runCommand(input.command, input.args, input.cwd, input.env) },
197
253
  teardown: { id: "WebContainerService.teardown", name: "teardown", handler: async () => runtime.teardown() },
198
- command: { id: "WebContainerService.command", name: "command", handler: async (input) => ({ task: input.task, command: COMMANDS[input.task] }) }
254
+ command: { id: "WebContainerService.command", name: "command", handler: async (input) => ({ task: input.task, command: resolveWebContainerCommand(input.task) }) }
199
255
  }
200
256
  });
201
257
  var WebContainerServiceFacade = {
@@ -215,20 +271,13 @@ var WebContainerServiceFacade = {
215
271
 
216
272
  // src/development/developmentService.ts
217
273
  function resolveDevelopmentCommand(task) {
218
- const commands = {
219
- install: ["pnpm", ["install", "--no-frozen-lockfile"]],
220
- lint: ["pnpm", ["lint"]],
221
- test: ["pnpm", ["test"]],
222
- build: ["pnpm", ["build"]],
223
- validate: ["pnpm", ["validate"]],
224
- check: ["pnpm", ["lint"]]
225
- };
226
- return commands[task];
274
+ const { command, args } = resolveWebContainerCommand(task);
275
+ return [command, args];
227
276
  }
228
277
  var DevelopmentServiceDefinition = createServiceDefinition({
229
278
  id: "kloks.backend.development",
230
279
  name: "DevelopmentService",
231
- version: "1.0.0",
280
+ version: "1.1.0",
232
281
  operations: {
233
282
  plan: {
234
283
  id: "DevelopmentService.plan",
@@ -261,9 +310,8 @@ var DevelopmentRuntime = class {
261
310
  githubActions;
262
311
  async run(request) {
263
312
  if (request.provider === "webcontainer") {
264
- const [command, args] = resolveDevelopmentCommand(request.task);
265
313
  const result = await this.webContainer.run(request.task, request.cwd, request.env);
266
- return { provider: request.provider, task: request.task, ok: result.exitCode === 0, exitCode: result.exitCode, output: result.output };
314
+ return { provider: request.provider, task: request.task, ok: result.exitCode === 0, exitCode: result.exitCode, output: result.output, command: result.command, durationMs: result.durationMs, diagnostics: result.diagnostics };
267
315
  }
268
316
  if (!this.githubActions || !request.repository || !request.workflowId || !request.ref) {
269
317
  throw new Error("GitHub Actions execution requires repository, workflowId, ref, and an authenticated client");
@@ -303,8 +351,8 @@ var COMMANDS2 = {
303
351
  var DEFAULT_LAYERS = ["lockfile-check", "syntax", "lint", "krnl", "frnl"];
304
352
  var commandText = (command, args) => [command, ...args].join(" ");
305
353
  var CodeValidationRuntime = class {
306
- constructor(runtime5 = new WebContainerRuntime()) {
307
- this.runtime = runtime5;
354
+ constructor(runtime6 = new WebContainerRuntime()) {
355
+ this.runtime = runtime6;
308
356
  }
309
357
  runtime;
310
358
  async validate(input = {}) {
@@ -358,8 +406,8 @@ var CodeValidationServiceFacade = {
358
406
 
359
407
  // src/development/codeDiagnosticsService.ts
360
408
  var CodeDiagnosticsService = class {
361
- constructor(runtime5 = new WebContainerRuntime()) {
362
- this.runtime = runtime5;
409
+ constructor(runtime6 = new WebContainerRuntime()) {
410
+ this.runtime = runtime6;
363
411
  }
364
412
  runtime;
365
413
  async diagnostics(input = {}) {
@@ -377,8 +425,8 @@ var TYPESCRIPT_LANGUAGE_SERVER_VERSION = "6.0.2";
377
425
  var PACKAGE = TYPESCRIPT_LANGUAGE_SERVER_PACKAGE;
378
426
  var DEFAULT_VERSION = TYPESCRIPT_LANGUAGE_SERVER_VERSION;
379
427
  var TypeScriptLanguageServerRuntime = class {
380
- constructor(runtime5 = new WebContainerRuntime()) {
381
- this.runtime = runtime5;
428
+ constructor(runtime6 = new WebContainerRuntime()) {
429
+ this.runtime = runtime6;
382
430
  }
383
431
  runtime;
384
432
  process = null;
@@ -413,13 +461,13 @@ var TypeScriptLanguageServerRuntime = class {
413
461
  return { sent: true };
414
462
  }
415
463
  async stop() {
416
- const process = this.process;
464
+ const process2 = this.process;
417
465
  this.process = null;
418
466
  this.writer?.releaseLock();
419
467
  this.writer = null;
420
468
  for (const pending of this.pending.values()) pending.reject(new Error("Language server stopped"));
421
469
  this.pending.clear();
422
- if (process) await process.kill();
470
+ if (process2) await process2.kill();
423
471
  return { stopped: true };
424
472
  }
425
473
  status() {
@@ -529,8 +577,8 @@ var PROVIDERS = [
529
577
  }
530
578
  ];
531
579
  var AgentHarnessRuntime = class {
532
- constructor(runtime5 = new WebContainerRuntime()) {
533
- this.runtime = runtime5;
580
+ constructor(runtime6 = new WebContainerRuntime()) {
581
+ this.runtime = runtime6;
534
582
  }
535
583
  runtime;
536
584
  providers() {
@@ -590,10 +638,194 @@ var AgentHarnessServiceFacade = {
590
638
  }
591
639
  };
592
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
+
593
822
  export {
594
823
  GitHubActionsClient,
595
824
  GitHubActionsServiceDefinition,
596
825
  GitHubActionsServiceFacade,
826
+ parseDevelopmentDiagnostics,
827
+ captureDevelopmentProcess,
828
+ resolveWebContainerCommand,
597
829
  WebContainerRuntime,
598
830
  WebContainerServiceDefinition,
599
831
  WebContainerServiceFacade,
@@ -612,5 +844,8 @@ export {
612
844
  TypeScriptLanguageServerServiceFacade,
613
845
  AgentHarnessRuntime,
614
846
  AgentHarnessServiceDefinition,
615
- AgentHarnessServiceFacade
847
+ AgentHarnessServiceFacade,
848
+ PlaywrightInspectionRuntime,
849
+ PlaywrightInspectionServiceDefinition,
850
+ PlaywrightInspectionServiceFacade
616
851
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  RateLimiter,
3
3
  SessionManager
4
- } from "./chunk-WTBAG4AV.js";
4
+ } from "./chunk-2HCQ2SIR.js";
5
5
 
6
6
  // src/auth/PasswordHasher.ts
7
7
  var bcrypt = null;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  b2ListBuckets,
3
3
  queryUnifiedDb
4
- } from "./chunk-VAFCR2MS.js";
4
+ } from "./chunk-JCMB7BIM.js";
5
5
 
6
6
  // src/srkl/SrklClient.ts
7
7
  var CANONICAL_SRKL_URL = "https://srkl-engine.vercel.app";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-SHZAQTIT.js";
4
4
  import {
5
5
  findUserWorkspace
6
- } from "./chunk-VN2YMZJO.js";
6
+ } from "./chunk-JGUWYVOL.js";
7
7
 
8
8
  // src/services/workspaceGraphService.ts
9
9
  function slugify(name) {
@@ -5,10 +5,18 @@ function cleanDbUrl(url) {
5
5
  return url.trim().replace(/^["']|["']$/g, "");
6
6
  }
7
7
  function getUnifiedDbUrl(env) {
8
- const fromEnv = cleanDbUrl(env?.SYSTEM_DATABASE_URL_1) || cleanDbUrl(env?.DATABASE_URL) || cleanDbUrl(env?.SYSTEM_DATABASE_URL_2);
9
- if (fromEnv) return fromEnv;
8
+ const fromBindings = [
9
+ env?.SYSTEM_DATABASE_URL_1,
10
+ env?.SYSTEM_DATABASE_URL_2,
11
+ env?.SYSTEM_DATABASE_URL_3
12
+ ].map(cleanDbUrl).find(Boolean);
13
+ if (fromBindings) return fromBindings;
10
14
  if (typeof process !== "undefined" && process.env) {
11
- return cleanDbUrl(process.env.SYSTEM_DATABASE_URL_1) || cleanDbUrl(process.env.DATABASE_URL) || cleanDbUrl(process.env.SYSTEM_DATABASE_URL_2) || cleanDbUrl(process.env.SYSTEM_DATABASE_URL_3) || "";
15
+ return [
16
+ process.env.SYSTEM_DATABASE_URL_1,
17
+ process.env.SYSTEM_DATABASE_URL_2,
18
+ process.env.SYSTEM_DATABASE_URL_3
19
+ ].map(cleanDbUrl).find(Boolean) || "";
12
20
  }
13
21
  return "";
14
22
  }
@@ -6,7 +6,7 @@ import {
6
6
  b2ListFileNames,
7
7
  b2UploadFile,
8
8
  queryUnifiedDb
9
- } from "./chunk-VAFCR2MS.js";
9
+ } from "./chunk-JCMB7BIM.js";
10
10
 
11
11
  // src/core/workspaceFileCore.ts
12
12
  async function getFs() {
@@ -14,10 +14,10 @@ import {
14
14
  SessionManager,
15
15
  loginSystemUser,
16
16
  resolveUserFromToken
17
- } from "./chunk-WTBAG4AV.js";
17
+ } from "./chunk-2HCQ2SIR.js";
18
18
  import {
19
19
  workspaceGraphService
20
- } from "./chunk-47IVAXPJ.js";
20
+ } from "./chunk-IGZB4RYT.js";
21
21
  import {
22
22
  StorageAdapterFactory
23
23
  } from "./chunk-SHZAQTIT.js";
@@ -27,10 +27,10 @@ import {
27
27
  findUserWorkspace,
28
28
  getWorkspaces,
29
29
  updateWorkspace
30
- } from "./chunk-VN2YMZJO.js";
30
+ } from "./chunk-JGUWYVOL.js";
31
31
  import {
32
32
  queryUnifiedDb
33
- } from "./chunk-VAFCR2MS.js";
33
+ } from "./chunk-JCMB7BIM.js";
34
34
  import {
35
35
  createService,
36
36
  createServiceDefinition