@ultrst-armada/kloks 1.24.3 → 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 +6 -2
- package/packages/backend/dist/{chunk-7K552XGT.js → chunk-FJ5LZFBV.js} +261 -19
- package/packages/backend/dist/development/client.js +240 -12
- package/packages/backend/dist/development/index.d.ts +139 -3
- package/packages/backend/dist/development/index.js +12 -14
- package/packages/backend/dist/index.d.ts +1 -2
- package/packages/backend/dist/index.js +12 -14
- package/packages/backend/package.json +1 -1
- package/packages/services/dist/index.js +8 -3
- package/packages/state-graph/dist/index.js +14 -14
- package/packages/backend/dist/chunk-AGI3VKCZ.js +0 -253
|
@@ -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",
|
|
@@ -198,7 +198,8 @@
|
|
|
198
198
|
"@neondatabase/serverless": "^0.10.0 || ^1.0.0",
|
|
199
199
|
"@supabase/supabase-js": "^2.45.0",
|
|
200
200
|
"better-sqlite3": "^11.0.0",
|
|
201
|
-
"react": "^18.0.0 || ^19.0.0"
|
|
201
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
202
|
+
"@ultrst-armada/krnl": "^1.0.9"
|
|
202
203
|
},
|
|
203
204
|
"peerDependenciesMeta": {
|
|
204
205
|
"@neondatabase/serverless": {
|
|
@@ -212,6 +213,9 @@
|
|
|
212
213
|
},
|
|
213
214
|
"react": {
|
|
214
215
|
"optional": true
|
|
216
|
+
},
|
|
217
|
+
"@ultrst-armada/krnl": {
|
|
218
|
+
"optional": true
|
|
215
219
|
}
|
|
216
220
|
},
|
|
217
221
|
"devDependencies": {
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WebContainerRuntime,
|
|
3
|
-
resolveWebContainerCommand
|
|
4
|
-
} from "./chunk-AGI3VKCZ.js";
|
|
5
1
|
import {
|
|
6
2
|
createService,
|
|
7
3
|
createServiceDefinition
|
|
@@ -102,6 +98,177 @@ var GitHubActionsServiceFacade = {
|
|
|
102
98
|
}
|
|
103
99
|
};
|
|
104
100
|
|
|
101
|
+
// src/development/webContainerService.ts
|
|
102
|
+
var COMMANDS = {
|
|
103
|
+
install: { command: "pnpm", args: ["install", "--no-frozen-lockfile"] },
|
|
104
|
+
lint: { command: "pnpm", args: ["lint"] },
|
|
105
|
+
test: { command: "pnpm", args: ["test"] },
|
|
106
|
+
build: { command: "pnpm", args: ["build"] },
|
|
107
|
+
validate: { command: "pnpm", args: ["validate"] },
|
|
108
|
+
check: { command: "pnpm", args: ["lint"] }
|
|
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(process) {
|
|
141
|
+
const [consumerOutput, diagnosticOutput] = process.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 process.exit;
|
|
155
|
+
return { output, exitCode, diagnostics: parseDevelopmentDiagnostics(output, exitCode) };
|
|
156
|
+
})();
|
|
157
|
+
return { ...process, output: consumerOutput, logs };
|
|
158
|
+
}
|
|
159
|
+
function resolveWebContainerCommand(task) {
|
|
160
|
+
const command = COMMANDS[task];
|
|
161
|
+
return { command: command.command, args: [...command.args] };
|
|
162
|
+
}
|
|
163
|
+
var runQueue = Promise.resolve();
|
|
164
|
+
var sharedContainer = null;
|
|
165
|
+
var sharedContainerPromise = null;
|
|
166
|
+
var WebContainerRuntime = class {
|
|
167
|
+
async boot() {
|
|
168
|
+
if (typeof window !== "undefined" && !window.crossOriginIsolated) {
|
|
169
|
+
throw new Error("WebContainer requires a cross-origin-isolated page. Ensure COOP=same-origin and COEP=require-corp are served.");
|
|
170
|
+
}
|
|
171
|
+
if (sharedContainer) return sharedContainer;
|
|
172
|
+
if (!sharedContainerPromise) {
|
|
173
|
+
sharedContainerPromise = import("@webcontainer/api").then(async (module) => {
|
|
174
|
+
const container = await module.WebContainer.boot({
|
|
175
|
+
coep: "require-corp",
|
|
176
|
+
workdirName: "kloks-development"
|
|
177
|
+
});
|
|
178
|
+
sharedContainer = container;
|
|
179
|
+
return container;
|
|
180
|
+
}).catch((error) => {
|
|
181
|
+
sharedContainerPromise = null;
|
|
182
|
+
throw error;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return sharedContainerPromise;
|
|
186
|
+
}
|
|
187
|
+
async mount(files, mountPoint) {
|
|
188
|
+
const container = await this.boot();
|
|
189
|
+
await container.mount(files, mountPoint ? { mountPoint } : void 0);
|
|
190
|
+
return { mounted: true, mountPoint: mountPoint ?? "/" };
|
|
191
|
+
}
|
|
192
|
+
async runProcess(command, args, cwd, env) {
|
|
193
|
+
const container = await this.boot();
|
|
194
|
+
const process = await container.spawn(command, args, { cwd, env });
|
|
195
|
+
const started = Date.now();
|
|
196
|
+
let output = "";
|
|
197
|
+
const reader = process.output.getReader();
|
|
198
|
+
try {
|
|
199
|
+
while (true) {
|
|
200
|
+
const next = await reader.read();
|
|
201
|
+
if (next.done) break;
|
|
202
|
+
output += next.value;
|
|
203
|
+
}
|
|
204
|
+
} finally {
|
|
205
|
+
reader.releaseLock();
|
|
206
|
+
}
|
|
207
|
+
const exitCode = await process.exit;
|
|
208
|
+
return { exitCode, output, command: [command, ...args].join(" "), durationMs: Date.now() - started, diagnostics: parseDevelopmentDiagnostics(output, exitCode) };
|
|
209
|
+
}
|
|
210
|
+
async run(task, cwd, env) {
|
|
211
|
+
const spec = resolveWebContainerCommand(task);
|
|
212
|
+
return this.runCommand(spec.command, spec.args, cwd, env);
|
|
213
|
+
}
|
|
214
|
+
async runCommand(command, args = [], cwd, env) {
|
|
215
|
+
const previous = runQueue;
|
|
216
|
+
let release;
|
|
217
|
+
runQueue = new Promise((resolve) => {
|
|
218
|
+
release = resolve;
|
|
219
|
+
});
|
|
220
|
+
await previous;
|
|
221
|
+
try {
|
|
222
|
+
return await this.runProcess(command, args, cwd, env);
|
|
223
|
+
} finally {
|
|
224
|
+
release();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
async spawnCommand(command, args = [], cwd, env) {
|
|
228
|
+
const container = await this.boot();
|
|
229
|
+
const process = await container.spawn(command, args, { cwd, env });
|
|
230
|
+
return captureDevelopmentProcess(process);
|
|
231
|
+
}
|
|
232
|
+
async teardown() {
|
|
233
|
+
const container = sharedContainer;
|
|
234
|
+
sharedContainer = null;
|
|
235
|
+
sharedContainerPromise = null;
|
|
236
|
+
await container?.teardown();
|
|
237
|
+
return { tornDown: true };
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
var runtime = new WebContainerRuntime();
|
|
241
|
+
var WebContainerServiceDefinition = createServiceDefinition({
|
|
242
|
+
id: "kloks.backend.webContainer",
|
|
243
|
+
name: "WebContainerService",
|
|
244
|
+
version: "1.2.0",
|
|
245
|
+
operations: {
|
|
246
|
+
boot: { id: "WebContainerService.boot", name: "boot", handler: async () => {
|
|
247
|
+
await runtime.boot();
|
|
248
|
+
return { ready: true };
|
|
249
|
+
} },
|
|
250
|
+
mount: { id: "WebContainerService.mount", name: "mount", handler: async (input) => runtime.mount(input.files, input.mountPoint) },
|
|
251
|
+
run: { id: "WebContainerService.run", name: "run", handler: async (input) => runtime.run(input.task, input.cwd, input.env) },
|
|
252
|
+
runCommand: { id: "WebContainerService.runCommand", name: "runCommand", handler: async (input) => runtime.runCommand(input.command, input.args, input.cwd, input.env) },
|
|
253
|
+
teardown: { id: "WebContainerService.teardown", name: "teardown", handler: async () => runtime.teardown() },
|
|
254
|
+
command: { id: "WebContainerService.command", name: "command", handler: async (input) => ({ task: input.task, command: resolveWebContainerCommand(input.task) }) }
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
var WebContainerServiceFacade = {
|
|
258
|
+
id: WebContainerServiceDefinition.id,
|
|
259
|
+
name: WebContainerServiceDefinition.name,
|
|
260
|
+
version: WebContainerServiceDefinition.version,
|
|
261
|
+
runtime: "client",
|
|
262
|
+
deployment: "local",
|
|
263
|
+
definition: WebContainerServiceDefinition,
|
|
264
|
+
createInstance: () => createService(WebContainerServiceDefinition),
|
|
265
|
+
execute: async (op, input) => {
|
|
266
|
+
const instance = createService(WebContainerServiceDefinition);
|
|
267
|
+
await instance.start();
|
|
268
|
+
return instance.call(op, input);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
105
272
|
// src/development/developmentService.ts
|
|
106
273
|
function resolveDevelopmentCommand(task) {
|
|
107
274
|
const { command, args } = resolveWebContainerCommand(task);
|
|
@@ -171,10 +338,76 @@ var DevelopmentServiceFacade = {
|
|
|
171
338
|
}
|
|
172
339
|
};
|
|
173
340
|
|
|
341
|
+
// src/development/codeValidationService.ts
|
|
342
|
+
var COMMANDS2 = {
|
|
343
|
+
syntax: { command: "pnpm", args: ["exec", "tsc", "--noEmit"] },
|
|
344
|
+
lint: { command: "pnpm", args: ["run", "lint", "--if-present"] },
|
|
345
|
+
test: { command: "pnpm", args: ["run", "test", "--if-present"] },
|
|
346
|
+
build: { command: "pnpm", args: ["run", "build", "--if-present"] },
|
|
347
|
+
krnl: { command: "pnpm", args: ["exec", "krnl", "validate"] },
|
|
348
|
+
frnl: { command: "pnpm", args: ["exec", "frnl", "validate"] },
|
|
349
|
+
"lockfile-check": { command: "pnpm", args: ["install", "--frozen-lockfile", "--ignore-scripts"] }
|
|
350
|
+
};
|
|
351
|
+
var DEFAULT_LAYERS = ["lockfile-check", "syntax", "lint", "krnl", "frnl"];
|
|
352
|
+
var commandText = (command, args) => [command, ...args].join(" ");
|
|
353
|
+
var CodeValidationRuntime = class {
|
|
354
|
+
constructor(runtime5 = new WebContainerRuntime()) {
|
|
355
|
+
this.runtime = runtime5;
|
|
356
|
+
}
|
|
357
|
+
runtime;
|
|
358
|
+
async validate(input = {}) {
|
|
359
|
+
if (input.files) await this.runtime.mount(input.files);
|
|
360
|
+
const diagnostics = [];
|
|
361
|
+
if (input.install) {
|
|
362
|
+
const installed = await this.runtime.runCommand("pnpm", ["install", "--frozen-lockfile", "--ignore-scripts"], input.cwd, input.env);
|
|
363
|
+
diagnostics.push({ layer: "lockfile-check", ok: installed.exitCode === 0, exitCode: installed.exitCode, output: installed.output, command: "pnpm install --frozen-lockfile --ignore-scripts" });
|
|
364
|
+
if (installed.exitCode !== 0) return { ok: false, diagnostics, failedLayers: ["lockfile-check"] };
|
|
365
|
+
}
|
|
366
|
+
const layers = input.layers?.length ? input.layers : DEFAULT_LAYERS;
|
|
367
|
+
for (const layer of layers) {
|
|
368
|
+
if (layer === "law-l9") {
|
|
369
|
+
diagnostics.push(await this.validateLawL9(input.cwd, input.maxLines ?? 200));
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
const spec = COMMANDS2[layer];
|
|
373
|
+
const result = await this.runtime.runCommand(spec.command, spec.args, input.cwd, input.env);
|
|
374
|
+
diagnostics.push({ layer, ok: result.exitCode === 0, exitCode: result.exitCode, output: result.output, command: commandText(spec.command, spec.args) });
|
|
375
|
+
if (result.exitCode !== 0) break;
|
|
376
|
+
}
|
|
377
|
+
return { ok: diagnostics.every((item) => item.ok), diagnostics, failedLayers: diagnostics.filter((item) => !item.ok).map((item) => item.layer) };
|
|
378
|
+
}
|
|
379
|
+
async validateLawL9(cwd = ".", maxLines = 200) {
|
|
380
|
+
const script = `python3 -c 'import os,sys; bad=[]; root="src"; [bad.append(os.path.join(r,f)+": "+str(len(open(os.path.join(r,f),encoding="utf-8",errors="ignore").readlines()))+" lines") for r,_,fs in os.walk(root) for f in fs if f.endswith((".ts",".tsx",".js",".jsx")) and not f.endswith(".d.ts") and len(open(os.path.join(r,f),encoding="utf-8",errors="ignore").readlines())>200]; print("\\n".join(bad)); sys.exit(1 if bad else 0)'`;
|
|
381
|
+
const result = await this.runtime.runCommand("sh", ["-lc", script], cwd);
|
|
382
|
+
return { layer: "law-l9", ok: result.exitCode === 0, exitCode: result.exitCode, output: result.output, command: script };
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
var runtime2 = new CodeValidationRuntime();
|
|
386
|
+
var CodeValidationServiceDefinition = createServiceDefinition({
|
|
387
|
+
id: "kloks.backend.codeValidation",
|
|
388
|
+
name: "CodeValidationService",
|
|
389
|
+
version: "1.1.0",
|
|
390
|
+
operations: { validate: { id: "CodeValidationService.validate", name: "validate", handler: async (input) => runtime2.validate(input) } }
|
|
391
|
+
});
|
|
392
|
+
var CodeValidationServiceFacade = {
|
|
393
|
+
id: CodeValidationServiceDefinition.id,
|
|
394
|
+
name: CodeValidationServiceDefinition.name,
|
|
395
|
+
version: CodeValidationServiceDefinition.version,
|
|
396
|
+
runtime: "client",
|
|
397
|
+
deployment: "local",
|
|
398
|
+
definition: CodeValidationServiceDefinition,
|
|
399
|
+
createInstance: () => createService(CodeValidationServiceDefinition),
|
|
400
|
+
execute: async (op, input) => {
|
|
401
|
+
const instance = createService(CodeValidationServiceDefinition);
|
|
402
|
+
await instance.start();
|
|
403
|
+
return instance.call(op, input);
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
|
|
174
407
|
// src/development/codeDiagnosticsService.ts
|
|
175
408
|
var CodeDiagnosticsService = class {
|
|
176
|
-
constructor(
|
|
177
|
-
this.runtime =
|
|
409
|
+
constructor(runtime5 = new WebContainerRuntime()) {
|
|
410
|
+
this.runtime = runtime5;
|
|
178
411
|
}
|
|
179
412
|
runtime;
|
|
180
413
|
async diagnostics(input = {}) {
|
|
@@ -192,8 +425,8 @@ var TYPESCRIPT_LANGUAGE_SERVER_VERSION = "6.0.2";
|
|
|
192
425
|
var PACKAGE = TYPESCRIPT_LANGUAGE_SERVER_PACKAGE;
|
|
193
426
|
var DEFAULT_VERSION = TYPESCRIPT_LANGUAGE_SERVER_VERSION;
|
|
194
427
|
var TypeScriptLanguageServerRuntime = class {
|
|
195
|
-
constructor(
|
|
196
|
-
this.runtime =
|
|
428
|
+
constructor(runtime5 = new WebContainerRuntime()) {
|
|
429
|
+
this.runtime = runtime5;
|
|
197
430
|
}
|
|
198
431
|
runtime;
|
|
199
432
|
process = null;
|
|
@@ -291,17 +524,17 @@ var TypeScriptLanguageServerRuntime = class {
|
|
|
291
524
|
}
|
|
292
525
|
}
|
|
293
526
|
};
|
|
294
|
-
var
|
|
527
|
+
var runtime3 = new TypeScriptLanguageServerRuntime();
|
|
295
528
|
var TypeScriptLanguageServerServiceDefinition = createServiceDefinition({
|
|
296
529
|
id: "kloks.backend.typescriptLanguageServer",
|
|
297
530
|
name: "TypeScriptLanguageServerService",
|
|
298
531
|
version: "1.0.0",
|
|
299
532
|
operations: {
|
|
300
|
-
start: { id: "TypeScriptLanguageServerService.start", name: "start", handler: async (input) =>
|
|
301
|
-
request: { id: "TypeScriptLanguageServerService.request", name: "request", handler: async (input) =>
|
|
302
|
-
notify: { id: "TypeScriptLanguageServerService.notify", name: "notify", handler: async (input) =>
|
|
303
|
-
stop: { id: "TypeScriptLanguageServerService.stop", name: "stop", handler: async () =>
|
|
304
|
-
status: { id: "TypeScriptLanguageServerService.status", name: "status", handler: async () =>
|
|
533
|
+
start: { id: "TypeScriptLanguageServerService.start", name: "start", handler: async (input) => runtime3.start(input) },
|
|
534
|
+
request: { id: "TypeScriptLanguageServerService.request", name: "request", handler: async (input) => runtime3.request(input) },
|
|
535
|
+
notify: { id: "TypeScriptLanguageServerService.notify", name: "notify", handler: async (input) => runtime3.notify(input) },
|
|
536
|
+
stop: { id: "TypeScriptLanguageServerService.stop", name: "stop", handler: async () => runtime3.stop() },
|
|
537
|
+
status: { id: "TypeScriptLanguageServerService.status", name: "status", handler: async () => runtime3.status() }
|
|
305
538
|
}
|
|
306
539
|
});
|
|
307
540
|
var TypeScriptLanguageServerServiceFacade = {
|
|
@@ -344,8 +577,8 @@ var PROVIDERS = [
|
|
|
344
577
|
}
|
|
345
578
|
];
|
|
346
579
|
var AgentHarnessRuntime = class {
|
|
347
|
-
constructor(
|
|
348
|
-
this.runtime =
|
|
580
|
+
constructor(runtime5 = new WebContainerRuntime()) {
|
|
581
|
+
this.runtime = runtime5;
|
|
349
582
|
}
|
|
350
583
|
runtime;
|
|
351
584
|
providers() {
|
|
@@ -372,7 +605,7 @@ var AgentHarnessRuntime = class {
|
|
|
372
605
|
};
|
|
373
606
|
}
|
|
374
607
|
};
|
|
375
|
-
var
|
|
608
|
+
var runtime4 = new AgentHarnessRuntime();
|
|
376
609
|
var AgentHarnessServiceDefinition = createServiceDefinition({
|
|
377
610
|
id: "kloks.backend.agentHarness",
|
|
378
611
|
name: "AgentHarnessService",
|
|
@@ -381,12 +614,12 @@ var AgentHarnessServiceDefinition = createServiceDefinition({
|
|
|
381
614
|
providers: {
|
|
382
615
|
id: "AgentHarnessService.providers",
|
|
383
616
|
name: "providers",
|
|
384
|
-
handler: async () =>
|
|
617
|
+
handler: async () => runtime4.providers()
|
|
385
618
|
},
|
|
386
619
|
run: {
|
|
387
620
|
id: "AgentHarnessService.run",
|
|
388
621
|
name: "run",
|
|
389
|
-
handler: async (input) =>
|
|
622
|
+
handler: async (input) => runtime4.run(input)
|
|
390
623
|
}
|
|
391
624
|
}
|
|
392
625
|
});
|
|
@@ -409,10 +642,19 @@ export {
|
|
|
409
642
|
GitHubActionsClient,
|
|
410
643
|
GitHubActionsServiceDefinition,
|
|
411
644
|
GitHubActionsServiceFacade,
|
|
645
|
+
parseDevelopmentDiagnostics,
|
|
646
|
+
captureDevelopmentProcess,
|
|
647
|
+
resolveWebContainerCommand,
|
|
648
|
+
WebContainerRuntime,
|
|
649
|
+
WebContainerServiceDefinition,
|
|
650
|
+
WebContainerServiceFacade,
|
|
412
651
|
resolveDevelopmentCommand,
|
|
413
652
|
DevelopmentServiceDefinition,
|
|
414
653
|
DevelopmentRuntime,
|
|
415
654
|
DevelopmentServiceFacade,
|
|
655
|
+
CodeValidationRuntime,
|
|
656
|
+
CodeValidationServiceDefinition,
|
|
657
|
+
CodeValidationServiceFacade,
|
|
416
658
|
CodeDiagnosticsService,
|
|
417
659
|
codeDiagnosticsService,
|
|
418
660
|
TYPESCRIPT_LANGUAGE_SERVER_PACKAGE,
|
|
@@ -1,16 +1,244 @@
|
|
|
1
|
+
// src/development/webContainerService.ts
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
createService,
|
|
4
|
+
createServiceDefinition
|
|
5
|
+
} from "@ultrst-armada/krnl";
|
|
6
|
+
var COMMANDS = {
|
|
7
|
+
install: { command: "pnpm", args: ["install", "--no-frozen-lockfile"] },
|
|
8
|
+
lint: { command: "pnpm", args: ["lint"] },
|
|
9
|
+
test: { command: "pnpm", args: ["test"] },
|
|
10
|
+
build: { command: "pnpm", args: ["build"] },
|
|
11
|
+
validate: { command: "pnpm", args: ["validate"] },
|
|
12
|
+
check: { command: "pnpm", args: ["lint"] }
|
|
13
|
+
};
|
|
14
|
+
function parseDevelopmentDiagnostics(output, exitCode = 0) {
|
|
15
|
+
const diagnostics = [];
|
|
16
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17
|
+
const add = (diagnostic) => {
|
|
18
|
+
const key = [diagnostic.source, diagnostic.code, diagnostic.file, diagnostic.line, diagnostic.message].join("|");
|
|
19
|
+
if (!seen.has(key)) {
|
|
20
|
+
seen.add(key);
|
|
21
|
+
diagnostics.push(diagnostic);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
for (const line of output.split(/\r?\n/)) {
|
|
25
|
+
const typescript = line.match(/^(.+?)\((\d+),(\d+)\):\s*(error|warning)\s+(TS\d+):\s*(.+)$/);
|
|
26
|
+
if (typescript) {
|
|
27
|
+
add({ source: "typescript", severity: typescript[4], file: typescript[1], line: Number(typescript[2]), column: Number(typescript[3]), code: typescript[5], message: typescript[6] });
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const eslint = line.match(/^(.+?):(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+([^\s]+)$/);
|
|
31
|
+
if (eslint) {
|
|
32
|
+
add({ source: "eslint", severity: eslint[4], file: eslint[1], line: Number(eslint[2]), column: Number(eslint[3]), code: eslint[6], message: eslint[5] });
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const bundler = line.match(/(?:✘|×|ERROR|error:|Error:)\s*(.+)$/);
|
|
36
|
+
if (bundler) add({ source: "bundler", severity: "error", message: bundler[1].trim() });
|
|
37
|
+
if (/\bWARN(?:ING)?\b/i.test(line)) add({ source: "package-manager", severity: "warning", message: line.trim() });
|
|
38
|
+
}
|
|
39
|
+
if (exitCode !== 0 && diagnostics.every((item) => item.severity !== "error")) {
|
|
40
|
+
add({ source: "unknown", severity: "error", message: "Command failed with exit code " + exitCode + "; inspect captured output for details." });
|
|
41
|
+
}
|
|
42
|
+
return diagnostics;
|
|
43
|
+
}
|
|
44
|
+
function captureDevelopmentProcess(process) {
|
|
45
|
+
const [consumerOutput, diagnosticOutput] = process.output.tee();
|
|
46
|
+
const logs = (async () => {
|
|
47
|
+
const reader = diagnosticOutput.getReader();
|
|
48
|
+
let output = "";
|
|
49
|
+
try {
|
|
50
|
+
while (true) {
|
|
51
|
+
const next = await reader.read();
|
|
52
|
+
if (next.done) break;
|
|
53
|
+
output += next.value;
|
|
54
|
+
}
|
|
55
|
+
} finally {
|
|
56
|
+
reader.releaseLock();
|
|
57
|
+
}
|
|
58
|
+
const exitCode = await process.exit;
|
|
59
|
+
return { output, exitCode, diagnostics: parseDevelopmentDiagnostics(output, exitCode) };
|
|
60
|
+
})();
|
|
61
|
+
return { ...process, output: consumerOutput, logs };
|
|
62
|
+
}
|
|
63
|
+
function resolveWebContainerCommand(task) {
|
|
64
|
+
const command = COMMANDS[task];
|
|
65
|
+
return { command: command.command, args: [...command.args] };
|
|
66
|
+
}
|
|
67
|
+
var runQueue = Promise.resolve();
|
|
68
|
+
var sharedContainer = null;
|
|
69
|
+
var sharedContainerPromise = null;
|
|
70
|
+
var WebContainerRuntime = class {
|
|
71
|
+
async boot() {
|
|
72
|
+
if (typeof window !== "undefined" && !window.crossOriginIsolated) {
|
|
73
|
+
throw new Error("WebContainer requires a cross-origin-isolated page. Ensure COOP=same-origin and COEP=require-corp are served.");
|
|
74
|
+
}
|
|
75
|
+
if (sharedContainer) return sharedContainer;
|
|
76
|
+
if (!sharedContainerPromise) {
|
|
77
|
+
sharedContainerPromise = import("@webcontainer/api").then(async (module) => {
|
|
78
|
+
const container = await module.WebContainer.boot({
|
|
79
|
+
coep: "require-corp",
|
|
80
|
+
workdirName: "kloks-development"
|
|
81
|
+
});
|
|
82
|
+
sharedContainer = container;
|
|
83
|
+
return container;
|
|
84
|
+
}).catch((error) => {
|
|
85
|
+
sharedContainerPromise = null;
|
|
86
|
+
throw error;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return sharedContainerPromise;
|
|
90
|
+
}
|
|
91
|
+
async mount(files, mountPoint) {
|
|
92
|
+
const container = await this.boot();
|
|
93
|
+
await container.mount(files, mountPoint ? { mountPoint } : void 0);
|
|
94
|
+
return { mounted: true, mountPoint: mountPoint ?? "/" };
|
|
95
|
+
}
|
|
96
|
+
async runProcess(command, args, cwd, env) {
|
|
97
|
+
const container = await this.boot();
|
|
98
|
+
const process = await container.spawn(command, args, { cwd, env });
|
|
99
|
+
const started = Date.now();
|
|
100
|
+
let output = "";
|
|
101
|
+
const reader = process.output.getReader();
|
|
102
|
+
try {
|
|
103
|
+
while (true) {
|
|
104
|
+
const next = await reader.read();
|
|
105
|
+
if (next.done) break;
|
|
106
|
+
output += next.value;
|
|
107
|
+
}
|
|
108
|
+
} finally {
|
|
109
|
+
reader.releaseLock();
|
|
110
|
+
}
|
|
111
|
+
const exitCode = await process.exit;
|
|
112
|
+
return { exitCode, output, command: [command, ...args].join(" "), durationMs: Date.now() - started, diagnostics: parseDevelopmentDiagnostics(output, exitCode) };
|
|
113
|
+
}
|
|
114
|
+
async run(task, cwd, env) {
|
|
115
|
+
const spec = resolveWebContainerCommand(task);
|
|
116
|
+
return this.runCommand(spec.command, spec.args, cwd, env);
|
|
117
|
+
}
|
|
118
|
+
async runCommand(command, args = [], cwd, env) {
|
|
119
|
+
const previous = runQueue;
|
|
120
|
+
let release;
|
|
121
|
+
runQueue = new Promise((resolve) => {
|
|
122
|
+
release = resolve;
|
|
123
|
+
});
|
|
124
|
+
await previous;
|
|
125
|
+
try {
|
|
126
|
+
return await this.runProcess(command, args, cwd, env);
|
|
127
|
+
} finally {
|
|
128
|
+
release();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async spawnCommand(command, args = [], cwd, env) {
|
|
132
|
+
const container = await this.boot();
|
|
133
|
+
const process = await container.spawn(command, args, { cwd, env });
|
|
134
|
+
return captureDevelopmentProcess(process);
|
|
135
|
+
}
|
|
136
|
+
async teardown() {
|
|
137
|
+
const container = sharedContainer;
|
|
138
|
+
sharedContainer = null;
|
|
139
|
+
sharedContainerPromise = null;
|
|
140
|
+
await container?.teardown();
|
|
141
|
+
return { tornDown: true };
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
var runtime = new WebContainerRuntime();
|
|
145
|
+
var WebContainerServiceDefinition = createServiceDefinition({
|
|
146
|
+
id: "kloks.backend.webContainer",
|
|
147
|
+
name: "WebContainerService",
|
|
148
|
+
version: "1.2.0",
|
|
149
|
+
operations: {
|
|
150
|
+
boot: { id: "WebContainerService.boot", name: "boot", handler: async () => {
|
|
151
|
+
await runtime.boot();
|
|
152
|
+
return { ready: true };
|
|
153
|
+
} },
|
|
154
|
+
mount: { id: "WebContainerService.mount", name: "mount", handler: async (input) => runtime.mount(input.files, input.mountPoint) },
|
|
155
|
+
run: { id: "WebContainerService.run", name: "run", handler: async (input) => runtime.run(input.task, input.cwd, input.env) },
|
|
156
|
+
runCommand: { id: "WebContainerService.runCommand", name: "runCommand", handler: async (input) => runtime.runCommand(input.command, input.args, input.cwd, input.env) },
|
|
157
|
+
teardown: { id: "WebContainerService.teardown", name: "teardown", handler: async () => runtime.teardown() },
|
|
158
|
+
command: { id: "WebContainerService.command", name: "command", handler: async (input) => ({ task: input.task, command: resolveWebContainerCommand(input.task) }) }
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
var WebContainerServiceFacade = {
|
|
162
|
+
id: WebContainerServiceDefinition.id,
|
|
163
|
+
name: WebContainerServiceDefinition.name,
|
|
164
|
+
version: WebContainerServiceDefinition.version,
|
|
165
|
+
runtime: "client",
|
|
166
|
+
deployment: "local",
|
|
167
|
+
definition: WebContainerServiceDefinition,
|
|
168
|
+
createInstance: () => createService(WebContainerServiceDefinition),
|
|
169
|
+
execute: async (op, input) => {
|
|
170
|
+
const instance = createService(WebContainerServiceDefinition);
|
|
171
|
+
await instance.start();
|
|
172
|
+
return instance.call(op, input);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// src/development/codeValidationService.ts
|
|
177
|
+
import { createService as createService2, createServiceDefinition as createServiceDefinition2 } from "@ultrst-armada/krnl";
|
|
178
|
+
var COMMANDS2 = {
|
|
179
|
+
syntax: { command: "pnpm", args: ["exec", "tsc", "--noEmit"] },
|
|
180
|
+
lint: { command: "pnpm", args: ["run", "lint", "--if-present"] },
|
|
181
|
+
test: { command: "pnpm", args: ["run", "test", "--if-present"] },
|
|
182
|
+
build: { command: "pnpm", args: ["run", "build", "--if-present"] },
|
|
183
|
+
krnl: { command: "pnpm", args: ["exec", "krnl", "validate"] },
|
|
184
|
+
frnl: { command: "pnpm", args: ["exec", "frnl", "validate"] },
|
|
185
|
+
"lockfile-check": { command: "pnpm", args: ["install", "--frozen-lockfile", "--ignore-scripts"] }
|
|
186
|
+
};
|
|
187
|
+
var DEFAULT_LAYERS = ["lockfile-check", "syntax", "lint", "krnl", "frnl"];
|
|
188
|
+
var commandText = (command, args) => [command, ...args].join(" ");
|
|
189
|
+
var CodeValidationRuntime = class {
|
|
190
|
+
constructor(runtime3 = new WebContainerRuntime()) {
|
|
191
|
+
this.runtime = runtime3;
|
|
192
|
+
}
|
|
193
|
+
runtime;
|
|
194
|
+
async validate(input = {}) {
|
|
195
|
+
if (input.files) await this.runtime.mount(input.files);
|
|
196
|
+
const diagnostics = [];
|
|
197
|
+
if (input.install) {
|
|
198
|
+
const installed = await this.runtime.runCommand("pnpm", ["install", "--frozen-lockfile", "--ignore-scripts"], input.cwd, input.env);
|
|
199
|
+
diagnostics.push({ layer: "lockfile-check", ok: installed.exitCode === 0, exitCode: installed.exitCode, output: installed.output, command: "pnpm install --frozen-lockfile --ignore-scripts" });
|
|
200
|
+
if (installed.exitCode !== 0) return { ok: false, diagnostics, failedLayers: ["lockfile-check"] };
|
|
201
|
+
}
|
|
202
|
+
const layers = input.layers?.length ? input.layers : DEFAULT_LAYERS;
|
|
203
|
+
for (const layer of layers) {
|
|
204
|
+
if (layer === "law-l9") {
|
|
205
|
+
diagnostics.push(await this.validateLawL9(input.cwd, input.maxLines ?? 200));
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
const spec = COMMANDS2[layer];
|
|
209
|
+
const result = await this.runtime.runCommand(spec.command, spec.args, input.cwd, input.env);
|
|
210
|
+
diagnostics.push({ layer, ok: result.exitCode === 0, exitCode: result.exitCode, output: result.output, command: commandText(spec.command, spec.args) });
|
|
211
|
+
if (result.exitCode !== 0) break;
|
|
212
|
+
}
|
|
213
|
+
return { ok: diagnostics.every((item) => item.ok), diagnostics, failedLayers: diagnostics.filter((item) => !item.ok).map((item) => item.layer) };
|
|
214
|
+
}
|
|
215
|
+
async validateLawL9(cwd = ".", maxLines = 200) {
|
|
216
|
+
const script = `python3 -c 'import os,sys; bad=[]; root="src"; [bad.append(os.path.join(r,f)+": "+str(len(open(os.path.join(r,f),encoding="utf-8",errors="ignore").readlines()))+" lines") for r,_,fs in os.walk(root) for f in fs if f.endswith((".ts",".tsx",".js",".jsx")) and not f.endswith(".d.ts") and len(open(os.path.join(r,f),encoding="utf-8",errors="ignore").readlines())>200]; print("\\n".join(bad)); sys.exit(1 if bad else 0)'`;
|
|
217
|
+
const result = await this.runtime.runCommand("sh", ["-lc", script], cwd);
|
|
218
|
+
return { layer: "law-l9", ok: result.exitCode === 0, exitCode: result.exitCode, output: result.output, command: script };
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
var runtime2 = new CodeValidationRuntime();
|
|
222
|
+
var CodeValidationServiceDefinition = createServiceDefinition2({
|
|
223
|
+
id: "kloks.backend.codeValidation",
|
|
224
|
+
name: "CodeValidationService",
|
|
225
|
+
version: "1.1.0",
|
|
226
|
+
operations: { validate: { id: "CodeValidationService.validate", name: "validate", handler: async (input) => runtime2.validate(input) } }
|
|
227
|
+
});
|
|
228
|
+
var CodeValidationServiceFacade = {
|
|
229
|
+
id: CodeValidationServiceDefinition.id,
|
|
230
|
+
name: CodeValidationServiceDefinition.name,
|
|
231
|
+
version: CodeValidationServiceDefinition.version,
|
|
232
|
+
runtime: "client",
|
|
233
|
+
deployment: "local",
|
|
234
|
+
definition: CodeValidationServiceDefinition,
|
|
235
|
+
createInstance: () => createService2(CodeValidationServiceDefinition),
|
|
236
|
+
execute: async (op, input) => {
|
|
237
|
+
const instance = createService2(CodeValidationServiceDefinition);
|
|
238
|
+
await instance.start();
|
|
239
|
+
return instance.call(op, input);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
14
242
|
export {
|
|
15
243
|
CodeValidationRuntime,
|
|
16
244
|
CodeValidationServiceDefinition,
|
|
@@ -1,10 +1,49 @@
|
|
|
1
|
-
import { WebContainerRuntime, DevelopmentRequest, DevelopmentResult } from './client.js';
|
|
2
|
-
export { CodeValidationInput, CodeValidationResult, CodeValidationRuntime, CodeValidationServiceDefinition, CodeValidationServiceFacade, DevelopmentDiagnostic, DevelopmentProvider, DevelopmentServiceContract, DevelopmentTask, ValidationDiagnostic, ValidationLayer, WebContainerCommand, WebContainerRunCommandInput, WebContainerServiceDefinition, WebContainerServiceFacade, captureDevelopmentProcess, parseDevelopmentDiagnostics, resolveWebContainerCommand } from './client.js';
|
|
3
1
|
import * as _ultrst_armada_krnl from '@ultrst-armada/krnl';
|
|
4
2
|
import { ServiceDefinition } from '@ultrst-armada/krnl';
|
|
5
3
|
export { InspectionCheck, InspectionCheckResult, InspectionError, InspectionErrorKind, InspectionLog, InspectionViewport, PlaywrightInspectionRequest, PlaywrightInspectionResult } from './playwrightInspectionTypes.js';
|
|
6
4
|
export { PlaywrightInspectionRuntime, PlaywrightInspectionServiceDefinition, PlaywrightInspectionServiceFacade } from './playwrightInspectionService.js';
|
|
7
5
|
|
|
6
|
+
type DevelopmentProvider = 'webcontainer' | 'github-actions';
|
|
7
|
+
type DevelopmentTask = 'install' | 'lint' | 'test' | 'build' | 'validate' | 'check';
|
|
8
|
+
interface DevelopmentRequest {
|
|
9
|
+
provider: DevelopmentProvider;
|
|
10
|
+
task: DevelopmentTask;
|
|
11
|
+
repository?: string;
|
|
12
|
+
ref?: string;
|
|
13
|
+
workflowId?: string | number;
|
|
14
|
+
workflowInputs?: Record<string, string>;
|
|
15
|
+
cwd?: string;
|
|
16
|
+
env?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
interface DevelopmentDiagnostic {
|
|
19
|
+
severity: 'error' | 'warning' | 'info';
|
|
20
|
+
source: 'typescript' | 'eslint' | 'bundler' | 'package-manager' | 'runtime' | 'unknown';
|
|
21
|
+
code?: string;
|
|
22
|
+
file?: string;
|
|
23
|
+
line?: number;
|
|
24
|
+
column?: number;
|
|
25
|
+
message: string;
|
|
26
|
+
}
|
|
27
|
+
interface DevelopmentResult {
|
|
28
|
+
provider: DevelopmentProvider;
|
|
29
|
+
task: DevelopmentTask;
|
|
30
|
+
ok: boolean;
|
|
31
|
+
exitCode?: number;
|
|
32
|
+
output?: string;
|
|
33
|
+
command?: string;
|
|
34
|
+
durationMs?: number;
|
|
35
|
+
diagnostics?: DevelopmentDiagnostic[];
|
|
36
|
+
runId?: number;
|
|
37
|
+
url?: string;
|
|
38
|
+
}
|
|
39
|
+
interface WebContainerCommand {
|
|
40
|
+
command: string;
|
|
41
|
+
args: string[];
|
|
42
|
+
}
|
|
43
|
+
interface DevelopmentServiceContract {
|
|
44
|
+
definition: ServiceDefinition;
|
|
45
|
+
}
|
|
46
|
+
|
|
8
47
|
interface GitHubActionsConfig {
|
|
9
48
|
token: string;
|
|
10
49
|
apiBaseUrl?: string;
|
|
@@ -60,6 +99,63 @@ declare const GitHubActionsServiceFacade: {
|
|
|
60
99
|
execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
|
|
61
100
|
};
|
|
62
101
|
|
|
102
|
+
declare function parseDevelopmentDiagnostics(output: string, exitCode?: number): DevelopmentDiagnostic[];
|
|
103
|
+
declare function captureDevelopmentProcess<T extends {
|
|
104
|
+
output: ReadableStream<string>;
|
|
105
|
+
exit: Promise<number>;
|
|
106
|
+
}>(process: T): T & {
|
|
107
|
+
output: ReadableStream<string>;
|
|
108
|
+
logs: Promise<{
|
|
109
|
+
output: string;
|
|
110
|
+
exitCode: number;
|
|
111
|
+
diagnostics: DevelopmentDiagnostic[];
|
|
112
|
+
}>;
|
|
113
|
+
};
|
|
114
|
+
declare function resolveWebContainerCommand(task: DevelopmentTask): WebContainerCommand;
|
|
115
|
+
interface WebContainerRunCommandInput {
|
|
116
|
+
command: string;
|
|
117
|
+
args?: string[];
|
|
118
|
+
cwd?: string;
|
|
119
|
+
env?: Record<string, string | number | boolean>;
|
|
120
|
+
}
|
|
121
|
+
declare class WebContainerRuntime {
|
|
122
|
+
boot(): Promise<any>;
|
|
123
|
+
mount(files: Record<string, unknown>, mountPoint?: string): Promise<{
|
|
124
|
+
mounted: boolean;
|
|
125
|
+
mountPoint: string;
|
|
126
|
+
}>;
|
|
127
|
+
private runProcess;
|
|
128
|
+
run(task: DevelopmentTask, cwd?: string, env?: Record<string, string>): Promise<{
|
|
129
|
+
exitCode: any;
|
|
130
|
+
output: string;
|
|
131
|
+
command: string;
|
|
132
|
+
durationMs: number;
|
|
133
|
+
diagnostics: DevelopmentDiagnostic[];
|
|
134
|
+
}>;
|
|
135
|
+
runCommand(command: string, args?: string[], cwd?: string, env?: Record<string, string | number | boolean>): Promise<{
|
|
136
|
+
exitCode: any;
|
|
137
|
+
output: string;
|
|
138
|
+
command: string;
|
|
139
|
+
durationMs: number;
|
|
140
|
+
diagnostics: DevelopmentDiagnostic[];
|
|
141
|
+
}>;
|
|
142
|
+
spawnCommand(command: string, args?: string[], cwd?: string, env?: Record<string, string | number | boolean>): Promise<any>;
|
|
143
|
+
teardown(): Promise<{
|
|
144
|
+
tornDown: boolean;
|
|
145
|
+
}>;
|
|
146
|
+
}
|
|
147
|
+
declare const WebContainerServiceDefinition: ServiceDefinition;
|
|
148
|
+
declare const WebContainerServiceFacade: {
|
|
149
|
+
id: string;
|
|
150
|
+
name: string;
|
|
151
|
+
version: string;
|
|
152
|
+
runtime: "client";
|
|
153
|
+
deployment: "local";
|
|
154
|
+
definition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
|
|
155
|
+
createInstance: () => _ultrst_armada_krnl.ServiceInstance<Record<string, unknown>, Record<string, unknown>>;
|
|
156
|
+
execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
|
|
157
|
+
};
|
|
158
|
+
|
|
63
159
|
declare function resolveDevelopmentCommand(task: DevelopmentRequest['task']): [string, string[]];
|
|
64
160
|
declare const DevelopmentServiceDefinition: ServiceDefinition;
|
|
65
161
|
declare class DevelopmentRuntime {
|
|
@@ -79,6 +175,46 @@ declare const DevelopmentServiceFacade: {
|
|
|
79
175
|
execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
|
|
80
176
|
};
|
|
81
177
|
|
|
178
|
+
type ValidationLayer = 'syntax' | 'lint' | 'test' | 'build' | 'krnl' | 'frnl' | 'lockfile-check' | 'law-l9';
|
|
179
|
+
interface CodeValidationInput {
|
|
180
|
+
layers?: ValidationLayer[];
|
|
181
|
+
cwd?: string;
|
|
182
|
+
env?: Record<string, string>;
|
|
183
|
+
maxLines?: number;
|
|
184
|
+
files?: Record<string, unknown>;
|
|
185
|
+
install?: boolean;
|
|
186
|
+
}
|
|
187
|
+
interface ValidationDiagnostic {
|
|
188
|
+
layer: ValidationLayer;
|
|
189
|
+
ok: boolean;
|
|
190
|
+
exitCode: number;
|
|
191
|
+
output: string;
|
|
192
|
+
command: string;
|
|
193
|
+
}
|
|
194
|
+
interface CodeValidationResult {
|
|
195
|
+
ok: boolean;
|
|
196
|
+
diagnostics: ValidationDiagnostic[];
|
|
197
|
+
failedLayers: ValidationLayer[];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
declare class CodeValidationRuntime {
|
|
201
|
+
private readonly runtime;
|
|
202
|
+
constructor(runtime?: WebContainerRuntime);
|
|
203
|
+
validate(input?: CodeValidationInput): Promise<CodeValidationResult>;
|
|
204
|
+
private validateLawL9;
|
|
205
|
+
}
|
|
206
|
+
declare const CodeValidationServiceDefinition: ServiceDefinition;
|
|
207
|
+
declare const CodeValidationServiceFacade: {
|
|
208
|
+
id: string;
|
|
209
|
+
name: string;
|
|
210
|
+
version: string;
|
|
211
|
+
runtime: "client";
|
|
212
|
+
deployment: "local";
|
|
213
|
+
definition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
|
|
214
|
+
createInstance: () => _ultrst_armada_krnl.ServiceInstance<Record<string, unknown>, Record<string, unknown>>;
|
|
215
|
+
execute: <TIn = CodeValidationInput, TOut = CodeValidationResult>(op: string, input?: TIn) => Promise<TOut>;
|
|
216
|
+
};
|
|
217
|
+
|
|
82
218
|
interface CodeDiagnosticsInput {
|
|
83
219
|
cwd?: string;
|
|
84
220
|
file?: string;
|
|
@@ -193,4 +329,4 @@ declare const AgentHarnessServiceFacade: {
|
|
|
193
329
|
execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
|
|
194
330
|
};
|
|
195
331
|
|
|
196
|
-
export { type AgentHarnessProvider, type AgentHarnessProviderInfo, type AgentHarnessResult, type AgentHarnessRunInput, AgentHarnessRuntime, type AgentHarnessServiceContract, AgentHarnessServiceDefinition, AgentHarnessServiceFacade, type CodeDiagnosticsInput, type CodeDiagnosticsResult, CodeDiagnosticsService, DevelopmentRequest, DevelopmentResult, DevelopmentRuntime, DevelopmentServiceDefinition, DevelopmentServiceFacade, GitHubActionsClient, type GitHubActionsConfig, GitHubActionsServiceDefinition, GitHubActionsServiceFacade, TYPESCRIPT_LANGUAGE_SERVER_PACKAGE, TYPESCRIPT_LANGUAGE_SERVER_VERSION, type TypeScriptLanguageServerNotificationInput, type TypeScriptLanguageServerRequestInput, type TypeScriptLanguageServerResponse, TypeScriptLanguageServerServiceDefinition, TypeScriptLanguageServerServiceFacade, type TypeScriptLanguageServerStartInput, type TypeScriptLanguageServerStatus, WebContainerRuntime, type WorkflowRun, codeDiagnosticsService, resolveDevelopmentCommand };
|
|
332
|
+
export { type AgentHarnessProvider, type AgentHarnessProviderInfo, type AgentHarnessResult, type AgentHarnessRunInput, AgentHarnessRuntime, type AgentHarnessServiceContract, AgentHarnessServiceDefinition, AgentHarnessServiceFacade, type CodeDiagnosticsInput, type CodeDiagnosticsResult, CodeDiagnosticsService, type CodeValidationInput, type CodeValidationResult, CodeValidationRuntime, CodeValidationServiceDefinition, CodeValidationServiceFacade, type DevelopmentDiagnostic, type DevelopmentProvider, type DevelopmentRequest, type DevelopmentResult, DevelopmentRuntime, type DevelopmentServiceContract, DevelopmentServiceDefinition, DevelopmentServiceFacade, type DevelopmentTask, GitHubActionsClient, type GitHubActionsConfig, GitHubActionsServiceDefinition, GitHubActionsServiceFacade, TYPESCRIPT_LANGUAGE_SERVER_PACKAGE, TYPESCRIPT_LANGUAGE_SERVER_VERSION, type TypeScriptLanguageServerNotificationInput, type TypeScriptLanguageServerRequestInput, type TypeScriptLanguageServerResponse, TypeScriptLanguageServerServiceDefinition, TypeScriptLanguageServerServiceFacade, type TypeScriptLanguageServerStartInput, type TypeScriptLanguageServerStatus, type ValidationDiagnostic, type ValidationLayer, type WebContainerCommand, type WebContainerRunCommandInput, WebContainerRuntime, WebContainerServiceDefinition, WebContainerServiceFacade, type WorkflowRun, captureDevelopmentProcess, codeDiagnosticsService, parseDevelopmentDiagnostics, resolveDevelopmentCommand, resolveWebContainerCommand };
|
|
@@ -3,6 +3,9 @@ import {
|
|
|
3
3
|
AgentHarnessServiceDefinition,
|
|
4
4
|
AgentHarnessServiceFacade,
|
|
5
5
|
CodeDiagnosticsService,
|
|
6
|
+
CodeValidationRuntime,
|
|
7
|
+
CodeValidationServiceDefinition,
|
|
8
|
+
CodeValidationServiceFacade,
|
|
6
9
|
DevelopmentRuntime,
|
|
7
10
|
DevelopmentServiceDefinition,
|
|
8
11
|
DevelopmentServiceFacade,
|
|
@@ -13,26 +16,21 @@ import {
|
|
|
13
16
|
TYPESCRIPT_LANGUAGE_SERVER_VERSION,
|
|
14
17
|
TypeScriptLanguageServerServiceDefinition,
|
|
15
18
|
TypeScriptLanguageServerServiceFacade,
|
|
16
|
-
codeDiagnosticsService,
|
|
17
|
-
resolveDevelopmentCommand
|
|
18
|
-
} from "../chunk-7K552XGT.js";
|
|
19
|
-
import {
|
|
20
|
-
PlaywrightInspectionRuntime,
|
|
21
|
-
PlaywrightInspectionServiceDefinition,
|
|
22
|
-
PlaywrightInspectionServiceFacade
|
|
23
|
-
} from "../chunk-2OPIDIIB.js";
|
|
24
|
-
import "../chunk-YEGS4HTA.js";
|
|
25
|
-
import {
|
|
26
|
-
CodeValidationRuntime,
|
|
27
|
-
CodeValidationServiceDefinition,
|
|
28
|
-
CodeValidationServiceFacade,
|
|
29
19
|
WebContainerRuntime,
|
|
30
20
|
WebContainerServiceDefinition,
|
|
31
21
|
WebContainerServiceFacade,
|
|
32
22
|
captureDevelopmentProcess,
|
|
23
|
+
codeDiagnosticsService,
|
|
33
24
|
parseDevelopmentDiagnostics,
|
|
25
|
+
resolveDevelopmentCommand,
|
|
34
26
|
resolveWebContainerCommand
|
|
35
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-FJ5LZFBV.js";
|
|
28
|
+
import "../chunk-YEGS4HTA.js";
|
|
29
|
+
import {
|
|
30
|
+
PlaywrightInspectionRuntime,
|
|
31
|
+
PlaywrightInspectionServiceDefinition,
|
|
32
|
+
PlaywrightInspectionServiceFacade
|
|
33
|
+
} from "../chunk-2OPIDIIB.js";
|
|
36
34
|
import "../chunk-MWSYNRNZ.js";
|
|
37
35
|
import "../chunk-QGM4M3NI.js";
|
|
38
36
|
export {
|
|
@@ -13,8 +13,7 @@ export { AdaptedStorageConnection, AppAccountManifest, AppServiceDeclaration, CA
|
|
|
13
13
|
export { CompositeBackend, EndpointGenerator, GeneratedEndpointSummary, LOCAL_STORAGE_GRAPHS_PREFIX, LocalService, NodeGraphPersistenceService, NodeGraphValidationResult, RemoteServiceProxy, SaveGraphOptions, UniversalAppEntity, UniversalGraphEdge, UniversalGraphNode, UniversalNodeGraphDocument, UniversalStorageConnection, WorkspaceGraphDocument, WorkspaceGraphSummary, createBackend, createCompositeService, createLocalService, createRemoteService, exportGraphAsJsonFile, nodeGraphPersistence, parseGraphJsonFile, validateGraphDocument, workspaceGraphService } from './services/index.js';
|
|
14
14
|
import { AssetDataType as AssetDataType$1, AssetChannelType as AssetChannelType$1, GraphFolderInfo as GraphFolderInfo$1, GraphAssetItem as GraphAssetItem$1, SpaceNode, NodeConnection, DawProject } from '@ultrst-armada/kloks/state-graph';
|
|
15
15
|
export { AuthServiceDefinition, AuthServiceFacade, ControlPlaneServiceDefinition, ControlPlaneServiceFacade, DatabaseServiceDefinition, DatabaseServiceFacade, GeminiServiceDefinition, GeminiServiceFacade, SrklServiceDefinition, SrklServiceFacade, StorageServiceDefinition, StorageServiceFacade, WorkspaceGraphServiceDefinition, WorkspaceGraphServiceFacade, WorkspaceServiceDefinition, WorkspaceServiceFacade, krnlAuthServiceDefinition, krnlAuthServiceFacade, krnlControlPlaneServiceDefinition, krnlControlPlaneServiceFacade, krnlDatabaseServiceDefinition, krnlDatabaseServiceFacade, krnlGeminiServiceDefinition, krnlGeminiServiceFacade, krnlSrklServiceDefinition, krnlSrklServiceFacade, krnlStorageServiceDefinition, krnlStorageServiceFacade, krnlWorkspaceGraphServiceDefinition, krnlWorkspaceGraphServiceFacade, krnlWorkspaceServiceDefinition, krnlWorkspaceServiceFacade } from './krnl-services.js';
|
|
16
|
-
export { CodeValidationInput, CodeValidationResult, CodeValidationRuntime, CodeValidationServiceDefinition, CodeValidationServiceFacade, DevelopmentDiagnostic, DevelopmentProvider, DevelopmentRequest, DevelopmentResult, DevelopmentServiceContract, DevelopmentTask, ValidationDiagnostic, ValidationLayer, WebContainerCommand, WebContainerRunCommandInput, WebContainerRuntime, WebContainerServiceDefinition, WebContainerServiceFacade, captureDevelopmentProcess, parseDevelopmentDiagnostics, resolveWebContainerCommand } from './development/
|
|
17
|
-
export { AgentHarnessProvider, AgentHarnessProviderInfo, AgentHarnessResult, AgentHarnessRunInput, AgentHarnessRuntime, AgentHarnessServiceContract, AgentHarnessServiceDefinition, AgentHarnessServiceFacade, CodeDiagnosticsInput, CodeDiagnosticsResult, CodeDiagnosticsService, DevelopmentRuntime, DevelopmentServiceDefinition, DevelopmentServiceFacade, GitHubActionsClient, GitHubActionsConfig, GitHubActionsServiceDefinition, GitHubActionsServiceFacade, TYPESCRIPT_LANGUAGE_SERVER_PACKAGE, TYPESCRIPT_LANGUAGE_SERVER_VERSION, TypeScriptLanguageServerNotificationInput, TypeScriptLanguageServerRequestInput, TypeScriptLanguageServerResponse, TypeScriptLanguageServerServiceDefinition, TypeScriptLanguageServerServiceFacade, TypeScriptLanguageServerStartInput, TypeScriptLanguageServerStatus, WorkflowRun, codeDiagnosticsService, resolveDevelopmentCommand } from './development/index.js';
|
|
16
|
+
export { AgentHarnessProvider, AgentHarnessProviderInfo, AgentHarnessResult, AgentHarnessRunInput, AgentHarnessRuntime, AgentHarnessServiceContract, AgentHarnessServiceDefinition, AgentHarnessServiceFacade, CodeDiagnosticsInput, CodeDiagnosticsResult, CodeDiagnosticsService, CodeValidationInput, CodeValidationResult, CodeValidationRuntime, CodeValidationServiceDefinition, CodeValidationServiceFacade, DevelopmentDiagnostic, DevelopmentProvider, DevelopmentRequest, DevelopmentResult, DevelopmentRuntime, DevelopmentServiceContract, DevelopmentServiceDefinition, DevelopmentServiceFacade, DevelopmentTask, GitHubActionsClient, GitHubActionsConfig, GitHubActionsServiceDefinition, GitHubActionsServiceFacade, TYPESCRIPT_LANGUAGE_SERVER_PACKAGE, TYPESCRIPT_LANGUAGE_SERVER_VERSION, TypeScriptLanguageServerNotificationInput, TypeScriptLanguageServerRequestInput, TypeScriptLanguageServerResponse, TypeScriptLanguageServerServiceDefinition, TypeScriptLanguageServerServiceFacade, TypeScriptLanguageServerStartInput, TypeScriptLanguageServerStatus, ValidationDiagnostic, ValidationLayer, WebContainerCommand, WebContainerRunCommandInput, WebContainerRuntime, WebContainerServiceDefinition, WebContainerServiceFacade, WorkflowRun, captureDevelopmentProcess, codeDiagnosticsService, parseDevelopmentDiagnostics, resolveDevelopmentCommand, resolveWebContainerCommand } from './development/index.js';
|
|
18
17
|
export { InspectionCheck, InspectionCheckResult, InspectionError, InspectionErrorKind, InspectionLog, InspectionViewport, PlaywrightInspectionRequest, PlaywrightInspectionResult } from './development/playwrightInspectionTypes.js';
|
|
19
18
|
export { PlaywrightInspectionRuntime, PlaywrightInspectionServiceDefinition, PlaywrightInspectionServiceFacade } from './development/playwrightInspectionService.js';
|
|
20
19
|
export { A as AIProviderStatus, a as ProviderCapabilities, P as ProviderId, b as ProviderMeta } from './types-Di4ZAQYA.js';
|
|
@@ -106,6 +106,9 @@ import {
|
|
|
106
106
|
AgentHarnessServiceDefinition,
|
|
107
107
|
AgentHarnessServiceFacade,
|
|
108
108
|
CodeDiagnosticsService,
|
|
109
|
+
CodeValidationRuntime,
|
|
110
|
+
CodeValidationServiceDefinition,
|
|
111
|
+
CodeValidationServiceFacade,
|
|
109
112
|
DevelopmentRuntime,
|
|
110
113
|
DevelopmentServiceDefinition,
|
|
111
114
|
DevelopmentServiceFacade,
|
|
@@ -116,26 +119,21 @@ import {
|
|
|
116
119
|
TYPESCRIPT_LANGUAGE_SERVER_VERSION,
|
|
117
120
|
TypeScriptLanguageServerServiceDefinition,
|
|
118
121
|
TypeScriptLanguageServerServiceFacade,
|
|
119
|
-
codeDiagnosticsService,
|
|
120
|
-
resolveDevelopmentCommand
|
|
121
|
-
} from "./chunk-7K552XGT.js";
|
|
122
|
-
import {
|
|
123
|
-
PlaywrightInspectionRuntime,
|
|
124
|
-
PlaywrightInspectionServiceDefinition,
|
|
125
|
-
PlaywrightInspectionServiceFacade
|
|
126
|
-
} from "./chunk-2OPIDIIB.js";
|
|
127
|
-
import "./chunk-YEGS4HTA.js";
|
|
128
|
-
import {
|
|
129
|
-
CodeValidationRuntime,
|
|
130
|
-
CodeValidationServiceDefinition,
|
|
131
|
-
CodeValidationServiceFacade,
|
|
132
122
|
WebContainerRuntime,
|
|
133
123
|
WebContainerServiceDefinition,
|
|
134
124
|
WebContainerServiceFacade,
|
|
135
125
|
captureDevelopmentProcess,
|
|
126
|
+
codeDiagnosticsService,
|
|
136
127
|
parseDevelopmentDiagnostics,
|
|
128
|
+
resolveDevelopmentCommand,
|
|
137
129
|
resolveWebContainerCommand
|
|
138
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-FJ5LZFBV.js";
|
|
131
|
+
import "./chunk-YEGS4HTA.js";
|
|
132
|
+
import {
|
|
133
|
+
PlaywrightInspectionRuntime,
|
|
134
|
+
PlaywrightInspectionServiceDefinition,
|
|
135
|
+
PlaywrightInspectionServiceFacade
|
|
136
|
+
} from "./chunk-2OPIDIIB.js";
|
|
139
137
|
import {
|
|
140
138
|
AIInferenceServiceDefinition,
|
|
141
139
|
AIInferenceServiceFacade,
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
112
|
"scripts": {
|
|
113
|
-
"build": "tsup src/index.ts src/krnl-services.ts src/krnl-ai-services.ts src/services/index.ts src/auth/index.ts src/storage/index.ts src/workspace/index.ts src/control-plane/index.ts src/api/index.ts src/connectivity/index.ts src/client/index.ts src/srkl/index.ts src/development/index.ts src/development/playwrightInspectionService.ts src/development/playwrightInspectionTypes.ts src/
|
|
113
|
+
"build": "tsup src/index.ts src/krnl-services.ts src/krnl-ai-services.ts src/services/index.ts src/auth/index.ts src/storage/index.ts src/workspace/index.ts src/control-plane/index.ts src/api/index.ts src/connectivity/index.ts src/client/index.ts src/srkl/index.ts src/development/index.ts src/development/playwrightInspectionService.ts src/development/playwrightInspectionTypes.ts src/ai-provider/index.ts src/ai-inference/index.ts src/ai-models/index.ts src/ai-routing/index.ts src/ai-keys/index.ts src/ai-tools/index.ts --format esm --dts --clean --external @kloks/functions --external react --external @kloks/state-graph --external @neondatabase/serverless --external @supabase/supabase-js --external @aws-sdk/client-s3 --external @aws-sdk/lib-storage --external bcryptjs --external better-sqlite3 --external zod --external ws --external @webcontainer/api --external playwright && tsup src/development/client.ts --format esm --dts --out-dir dist/development --splitting false --platform browser --external @ultrst-armada/krnl",
|
|
114
114
|
"typecheck": "tsc --noEmit",
|
|
115
115
|
"clean": "rm -rf dist"
|
|
116
116
|
},
|
|
@@ -1696,7 +1696,6 @@ var SystemDbService = class {
|
|
|
1696
1696
|
};
|
|
1697
1697
|
listeners = /* @__PURE__ */ new Set();
|
|
1698
1698
|
constructor() {
|
|
1699
|
-
this.refreshStatus();
|
|
1700
1699
|
}
|
|
1701
1700
|
async refreshStatus() {
|
|
1702
1701
|
try {
|
|
@@ -2755,12 +2754,18 @@ var SystemDbClientServiceDefinition = createServiceDefinition({
|
|
|
2755
2754
|
getEnvStatus: {
|
|
2756
2755
|
id: "SystemDbClientService.getEnvStatus",
|
|
2757
2756
|
name: "getEnvStatus",
|
|
2758
|
-
handler: async () =>
|
|
2757
|
+
handler: async () => {
|
|
2758
|
+
await systemDbService.refreshStatus();
|
|
2759
|
+
return systemDbService.getEnvStatus();
|
|
2760
|
+
}
|
|
2759
2761
|
},
|
|
2760
2762
|
getTelemetry: {
|
|
2761
2763
|
id: "SystemDbClientService.getTelemetry",
|
|
2762
2764
|
name: "getTelemetry",
|
|
2763
|
-
handler: async () =>
|
|
2765
|
+
handler: async () => {
|
|
2766
|
+
await systemDbService.refreshStatus();
|
|
2767
|
+
return systemDbService.getTelemetry();
|
|
2768
|
+
}
|
|
2764
2769
|
}
|
|
2765
2770
|
}
|
|
2766
2771
|
});
|
|
@@ -16,20 +16,6 @@ import {
|
|
|
16
16
|
useSkipoBind,
|
|
17
17
|
useSkipoState
|
|
18
18
|
} from "./chunk-EW4ACSZB.js";
|
|
19
|
-
import {
|
|
20
|
-
CommandApi,
|
|
21
|
-
GhostStore,
|
|
22
|
-
GraphStore
|
|
23
|
-
} from "./chunk-4UVGXFEM.js";
|
|
24
|
-
import {
|
|
25
|
-
BaseGraph,
|
|
26
|
-
BaseNode,
|
|
27
|
-
BaseViewWindow,
|
|
28
|
-
CustomGraph,
|
|
29
|
-
CustomNode,
|
|
30
|
-
CustomViewWindow,
|
|
31
|
-
DEFAULT_GRAPH_SETTINGS
|
|
32
|
-
} from "./chunk-KG6QYS26.js";
|
|
33
19
|
import {
|
|
34
20
|
AttractionEngine,
|
|
35
21
|
GhostInferenceEngine,
|
|
@@ -45,6 +31,20 @@ import {
|
|
|
45
31
|
WireTypeRegistry,
|
|
46
32
|
initializeDefaultGraphRules
|
|
47
33
|
} from "./chunk-TZOL3RN7.js";
|
|
34
|
+
import {
|
|
35
|
+
CommandApi,
|
|
36
|
+
GhostStore,
|
|
37
|
+
GraphStore
|
|
38
|
+
} from "./chunk-4UVGXFEM.js";
|
|
39
|
+
import {
|
|
40
|
+
BaseGraph,
|
|
41
|
+
BaseNode,
|
|
42
|
+
BaseViewWindow,
|
|
43
|
+
CustomGraph,
|
|
44
|
+
CustomNode,
|
|
45
|
+
CustomViewWindow,
|
|
46
|
+
DEFAULT_GRAPH_SETTINGS
|
|
47
|
+
} from "./chunk-KG6QYS26.js";
|
|
48
48
|
import {
|
|
49
49
|
AutoSolidify,
|
|
50
50
|
SpatialEngine,
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createService,
|
|
3
|
-
createServiceDefinition
|
|
4
|
-
} from "./chunk-MWSYNRNZ.js";
|
|
5
|
-
|
|
6
|
-
// src/development/webContainerService.ts
|
|
7
|
-
var COMMANDS = {
|
|
8
|
-
install: { command: "pnpm", args: ["install", "--no-frozen-lockfile"] },
|
|
9
|
-
lint: { command: "pnpm", args: ["lint"] },
|
|
10
|
-
test: { command: "pnpm", args: ["test"] },
|
|
11
|
-
build: { command: "pnpm", args: ["build"] },
|
|
12
|
-
validate: { command: "pnpm", args: ["validate"] },
|
|
13
|
-
check: { command: "pnpm", args: ["lint"] }
|
|
14
|
-
};
|
|
15
|
-
function parseDevelopmentDiagnostics(output, exitCode = 0) {
|
|
16
|
-
const diagnostics = [];
|
|
17
|
-
const seen = /* @__PURE__ */ new Set();
|
|
18
|
-
const add = (diagnostic) => {
|
|
19
|
-
const key = [diagnostic.source, diagnostic.code, diagnostic.file, diagnostic.line, diagnostic.message].join("|");
|
|
20
|
-
if (!seen.has(key)) {
|
|
21
|
-
seen.add(key);
|
|
22
|
-
diagnostics.push(diagnostic);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
for (const line of output.split(/\r?\n/)) {
|
|
26
|
-
const typescript = line.match(/^(.+?)\((\d+),(\d+)\):\s*(error|warning)\s+(TS\d+):\s*(.+)$/);
|
|
27
|
-
if (typescript) {
|
|
28
|
-
add({ source: "typescript", severity: typescript[4], file: typescript[1], line: Number(typescript[2]), column: Number(typescript[3]), code: typescript[5], message: typescript[6] });
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
const eslint = line.match(/^(.+?):(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+([^\s]+)$/);
|
|
32
|
-
if (eslint) {
|
|
33
|
-
add({ source: "eslint", severity: eslint[4], file: eslint[1], line: Number(eslint[2]), column: Number(eslint[3]), code: eslint[6], message: eslint[5] });
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
const bundler = line.match(/(?:✘|×|ERROR|error:|Error:)\s*(.+)$/);
|
|
37
|
-
if (bundler) add({ source: "bundler", severity: "error", message: bundler[1].trim() });
|
|
38
|
-
if (/\bWARN(?:ING)?\b/i.test(line)) add({ source: "package-manager", severity: "warning", message: line.trim() });
|
|
39
|
-
}
|
|
40
|
-
if (exitCode !== 0 && diagnostics.every((item) => item.severity !== "error")) {
|
|
41
|
-
add({ source: "unknown", severity: "error", message: "Command failed with exit code " + exitCode + "; inspect captured output for details." });
|
|
42
|
-
}
|
|
43
|
-
return diagnostics;
|
|
44
|
-
}
|
|
45
|
-
function captureDevelopmentProcess(process) {
|
|
46
|
-
const [consumerOutput, diagnosticOutput] = process.output.tee();
|
|
47
|
-
const logs = (async () => {
|
|
48
|
-
const reader = diagnosticOutput.getReader();
|
|
49
|
-
let output = "";
|
|
50
|
-
try {
|
|
51
|
-
while (true) {
|
|
52
|
-
const next = await reader.read();
|
|
53
|
-
if (next.done) break;
|
|
54
|
-
output += next.value;
|
|
55
|
-
}
|
|
56
|
-
} finally {
|
|
57
|
-
reader.releaseLock();
|
|
58
|
-
}
|
|
59
|
-
const exitCode = await process.exit;
|
|
60
|
-
return { output, exitCode, diagnostics: parseDevelopmentDiagnostics(output, exitCode) };
|
|
61
|
-
})();
|
|
62
|
-
return { ...process, output: consumerOutput, logs };
|
|
63
|
-
}
|
|
64
|
-
function resolveWebContainerCommand(task) {
|
|
65
|
-
const command = COMMANDS[task];
|
|
66
|
-
return { command: command.command, args: [...command.args] };
|
|
67
|
-
}
|
|
68
|
-
var runQueue = Promise.resolve();
|
|
69
|
-
var sharedContainer = null;
|
|
70
|
-
var sharedContainerPromise = null;
|
|
71
|
-
var WebContainerRuntime = class {
|
|
72
|
-
async boot() {
|
|
73
|
-
if (typeof window !== "undefined" && !window.crossOriginIsolated) {
|
|
74
|
-
throw new Error("WebContainer requires a cross-origin-isolated page. Ensure COOP=same-origin and COEP=require-corp are served.");
|
|
75
|
-
}
|
|
76
|
-
if (sharedContainer) return sharedContainer;
|
|
77
|
-
if (!sharedContainerPromise) {
|
|
78
|
-
sharedContainerPromise = import("@webcontainer/api").then(async (module) => {
|
|
79
|
-
const container = await module.WebContainer.boot({
|
|
80
|
-
coep: "require-corp",
|
|
81
|
-
workdirName: "kloks-development"
|
|
82
|
-
});
|
|
83
|
-
sharedContainer = container;
|
|
84
|
-
return container;
|
|
85
|
-
}).catch((error) => {
|
|
86
|
-
sharedContainerPromise = null;
|
|
87
|
-
throw error;
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
return sharedContainerPromise;
|
|
91
|
-
}
|
|
92
|
-
async mount(files, mountPoint) {
|
|
93
|
-
const container = await this.boot();
|
|
94
|
-
await container.mount(files, mountPoint ? { mountPoint } : void 0);
|
|
95
|
-
return { mounted: true, mountPoint: mountPoint ?? "/" };
|
|
96
|
-
}
|
|
97
|
-
async runProcess(command, args, cwd, env) {
|
|
98
|
-
const container = await this.boot();
|
|
99
|
-
const process = await container.spawn(command, args, { cwd, env });
|
|
100
|
-
const started = Date.now();
|
|
101
|
-
let output = "";
|
|
102
|
-
const reader = process.output.getReader();
|
|
103
|
-
try {
|
|
104
|
-
while (true) {
|
|
105
|
-
const next = await reader.read();
|
|
106
|
-
if (next.done) break;
|
|
107
|
-
output += next.value;
|
|
108
|
-
}
|
|
109
|
-
} finally {
|
|
110
|
-
reader.releaseLock();
|
|
111
|
-
}
|
|
112
|
-
const exitCode = await process.exit;
|
|
113
|
-
return { exitCode, output, command: [command, ...args].join(" "), durationMs: Date.now() - started, diagnostics: parseDevelopmentDiagnostics(output, exitCode) };
|
|
114
|
-
}
|
|
115
|
-
async run(task, cwd, env) {
|
|
116
|
-
const spec = resolveWebContainerCommand(task);
|
|
117
|
-
return this.runCommand(spec.command, spec.args, cwd, env);
|
|
118
|
-
}
|
|
119
|
-
async runCommand(command, args = [], cwd, env) {
|
|
120
|
-
const previous = runQueue;
|
|
121
|
-
let release;
|
|
122
|
-
runQueue = new Promise((resolve) => {
|
|
123
|
-
release = resolve;
|
|
124
|
-
});
|
|
125
|
-
await previous;
|
|
126
|
-
try {
|
|
127
|
-
return await this.runProcess(command, args, cwd, env);
|
|
128
|
-
} finally {
|
|
129
|
-
release();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
async spawnCommand(command, args = [], cwd, env) {
|
|
133
|
-
const container = await this.boot();
|
|
134
|
-
const process = await container.spawn(command, args, { cwd, env });
|
|
135
|
-
return captureDevelopmentProcess(process);
|
|
136
|
-
}
|
|
137
|
-
async teardown() {
|
|
138
|
-
const container = sharedContainer;
|
|
139
|
-
sharedContainer = null;
|
|
140
|
-
sharedContainerPromise = null;
|
|
141
|
-
await container?.teardown();
|
|
142
|
-
return { tornDown: true };
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
var runtime = new WebContainerRuntime();
|
|
146
|
-
var WebContainerServiceDefinition = createServiceDefinition({
|
|
147
|
-
id: "kloks.backend.webContainer",
|
|
148
|
-
name: "WebContainerService",
|
|
149
|
-
version: "1.2.0",
|
|
150
|
-
operations: {
|
|
151
|
-
boot: { id: "WebContainerService.boot", name: "boot", handler: async () => {
|
|
152
|
-
await runtime.boot();
|
|
153
|
-
return { ready: true };
|
|
154
|
-
} },
|
|
155
|
-
mount: { id: "WebContainerService.mount", name: "mount", handler: async (input) => runtime.mount(input.files, input.mountPoint) },
|
|
156
|
-
run: { id: "WebContainerService.run", name: "run", handler: async (input) => runtime.run(input.task, input.cwd, input.env) },
|
|
157
|
-
runCommand: { id: "WebContainerService.runCommand", name: "runCommand", handler: async (input) => runtime.runCommand(input.command, input.args, input.cwd, input.env) },
|
|
158
|
-
teardown: { id: "WebContainerService.teardown", name: "teardown", handler: async () => runtime.teardown() },
|
|
159
|
-
command: { id: "WebContainerService.command", name: "command", handler: async (input) => ({ task: input.task, command: resolveWebContainerCommand(input.task) }) }
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
var WebContainerServiceFacade = {
|
|
163
|
-
id: WebContainerServiceDefinition.id,
|
|
164
|
-
name: WebContainerServiceDefinition.name,
|
|
165
|
-
version: WebContainerServiceDefinition.version,
|
|
166
|
-
runtime: "client",
|
|
167
|
-
deployment: "local",
|
|
168
|
-
definition: WebContainerServiceDefinition,
|
|
169
|
-
createInstance: () => createService(WebContainerServiceDefinition),
|
|
170
|
-
execute: async (op, input) => {
|
|
171
|
-
const instance = createService(WebContainerServiceDefinition);
|
|
172
|
-
await instance.start();
|
|
173
|
-
return instance.call(op, input);
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
// src/development/codeValidationService.ts
|
|
178
|
-
var COMMANDS2 = {
|
|
179
|
-
syntax: { command: "pnpm", args: ["exec", "tsc", "--noEmit"] },
|
|
180
|
-
lint: { command: "pnpm", args: ["run", "lint", "--if-present"] },
|
|
181
|
-
test: { command: "pnpm", args: ["run", "test", "--if-present"] },
|
|
182
|
-
build: { command: "pnpm", args: ["run", "build", "--if-present"] },
|
|
183
|
-
krnl: { command: "pnpm", args: ["exec", "krnl", "validate"] },
|
|
184
|
-
frnl: { command: "pnpm", args: ["exec", "frnl", "validate"] },
|
|
185
|
-
"lockfile-check": { command: "pnpm", args: ["install", "--frozen-lockfile", "--ignore-scripts"] }
|
|
186
|
-
};
|
|
187
|
-
var DEFAULT_LAYERS = ["lockfile-check", "syntax", "lint", "krnl", "frnl"];
|
|
188
|
-
var commandText = (command, args) => [command, ...args].join(" ");
|
|
189
|
-
var CodeValidationRuntime = class {
|
|
190
|
-
constructor(runtime3 = new WebContainerRuntime()) {
|
|
191
|
-
this.runtime = runtime3;
|
|
192
|
-
}
|
|
193
|
-
runtime;
|
|
194
|
-
async validate(input = {}) {
|
|
195
|
-
if (input.files) await this.runtime.mount(input.files);
|
|
196
|
-
const diagnostics = [];
|
|
197
|
-
if (input.install) {
|
|
198
|
-
const installed = await this.runtime.runCommand("pnpm", ["install", "--frozen-lockfile", "--ignore-scripts"], input.cwd, input.env);
|
|
199
|
-
diagnostics.push({ layer: "lockfile-check", ok: installed.exitCode === 0, exitCode: installed.exitCode, output: installed.output, command: "pnpm install --frozen-lockfile --ignore-scripts" });
|
|
200
|
-
if (installed.exitCode !== 0) return { ok: false, diagnostics, failedLayers: ["lockfile-check"] };
|
|
201
|
-
}
|
|
202
|
-
const layers = input.layers?.length ? input.layers : DEFAULT_LAYERS;
|
|
203
|
-
for (const layer of layers) {
|
|
204
|
-
if (layer === "law-l9") {
|
|
205
|
-
diagnostics.push(await this.validateLawL9(input.cwd, input.maxLines ?? 200));
|
|
206
|
-
continue;
|
|
207
|
-
}
|
|
208
|
-
const spec = COMMANDS2[layer];
|
|
209
|
-
const result = await this.runtime.runCommand(spec.command, spec.args, input.cwd, input.env);
|
|
210
|
-
diagnostics.push({ layer, ok: result.exitCode === 0, exitCode: result.exitCode, output: result.output, command: commandText(spec.command, spec.args) });
|
|
211
|
-
if (result.exitCode !== 0) break;
|
|
212
|
-
}
|
|
213
|
-
return { ok: diagnostics.every((item) => item.ok), diagnostics, failedLayers: diagnostics.filter((item) => !item.ok).map((item) => item.layer) };
|
|
214
|
-
}
|
|
215
|
-
async validateLawL9(cwd = ".", maxLines = 200) {
|
|
216
|
-
const script = `python3 -c 'import os,sys; bad=[]; root="src"; [bad.append(os.path.join(r,f)+": "+str(len(open(os.path.join(r,f),encoding="utf-8",errors="ignore").readlines()))+" lines") for r,_,fs in os.walk(root) for f in fs if f.endswith((".ts",".tsx",".js",".jsx")) and not f.endswith(".d.ts") and len(open(os.path.join(r,f),encoding="utf-8",errors="ignore").readlines())>200]; print("\\n".join(bad)); sys.exit(1 if bad else 0)'`;
|
|
217
|
-
const result = await this.runtime.runCommand("sh", ["-lc", script], cwd);
|
|
218
|
-
return { layer: "law-l9", ok: result.exitCode === 0, exitCode: result.exitCode, output: result.output, command: script };
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
var runtime2 = new CodeValidationRuntime();
|
|
222
|
-
var CodeValidationServiceDefinition = createServiceDefinition({
|
|
223
|
-
id: "kloks.backend.codeValidation",
|
|
224
|
-
name: "CodeValidationService",
|
|
225
|
-
version: "1.1.0",
|
|
226
|
-
operations: { validate: { id: "CodeValidationService.validate", name: "validate", handler: async (input) => runtime2.validate(input) } }
|
|
227
|
-
});
|
|
228
|
-
var CodeValidationServiceFacade = {
|
|
229
|
-
id: CodeValidationServiceDefinition.id,
|
|
230
|
-
name: CodeValidationServiceDefinition.name,
|
|
231
|
-
version: CodeValidationServiceDefinition.version,
|
|
232
|
-
runtime: "client",
|
|
233
|
-
deployment: "local",
|
|
234
|
-
definition: CodeValidationServiceDefinition,
|
|
235
|
-
createInstance: () => createService(CodeValidationServiceDefinition),
|
|
236
|
-
execute: async (op, input) => {
|
|
237
|
-
const instance = createService(CodeValidationServiceDefinition);
|
|
238
|
-
await instance.start();
|
|
239
|
-
return instance.call(op, input);
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
export {
|
|
244
|
-
parseDevelopmentDiagnostics,
|
|
245
|
-
captureDevelopmentProcess,
|
|
246
|
-
resolveWebContainerCommand,
|
|
247
|
-
WebContainerRuntime,
|
|
248
|
-
WebContainerServiceDefinition,
|
|
249
|
-
WebContainerServiceFacade,
|
|
250
|
-
CodeValidationRuntime,
|
|
251
|
-
CodeValidationServiceDefinition,
|
|
252
|
-
CodeValidationServiceFacade
|
|
253
|
-
};
|