@ultrst-armada/kloks 1.24.11 → 1.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/packages/audio-midi/dist/index.js +16 -16
- package/packages/backend/dist/chunk-CA5HVC4X.js +155 -0
- package/packages/backend/dist/{chunk-UC25J7E4.js → chunk-COA3ABWL.js} +1 -1
- package/packages/backend/dist/chunk-GKQ42CYW.js +47 -0
- package/packages/backend/dist/{chunk-XHADDA75.js → chunk-RIOYKF3X.js} +18 -10
- package/packages/backend/dist/development/index.d.ts +4 -113
- package/packages/backend/dist/development/index.js +31 -204
- package/packages/backend/dist/development/webContainerRuntime.d.ts +2 -0
- package/packages/backend/dist/development/webContainerRuntime.js +12 -0
- package/packages/backend/dist/development/webContainerService.d.ts +17 -0
- package/packages/backend/dist/development/webContainerService.js +19 -0
- package/packages/backend/dist/index.d.ts +17 -1
- package/packages/backend/dist/index.js +62 -2
- package/packages/backend/dist/krnl-services.js +2 -2
- package/packages/backend/dist/srkl/index.d.ts +0 -5
- package/packages/backend/dist/srkl/index.js +1 -1
- package/packages/backend/dist/webContainerRuntime-BnHB2bNz.d.ts +103 -0
- package/packages/backend/package.json +7 -2
- package/packages/client/dist/auth.d.ts +13 -0
- package/packages/client/dist/index.d.ts +1 -0
- package/packages/client/package.json +1 -1
- package/packages/functions/dist/index.js +16 -16
- package/packages/services/dist/index.d.ts +70 -1
- package/packages/services/dist/index.js +130 -16
- package/packages/services/kloks.manifest.json +28 -0
- package/packages/state-graph/dist/index.js +30 -30
- package/.krusbl-release-attestation.json +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultrst-armada/kloks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -187,12 +187,13 @@
|
|
|
187
187
|
"build": "pnpm -r run build",
|
|
188
188
|
"postbuild": "node -e \"import('fs').then(fs => { for (const pkg of fs.readdirSync('packages')) { const d = 'packages/' + pkg + '/dist'; if (!fs.existsSync(d)) continue; for (const f of fs.readdirSync(d, { recursive: true })) { const p = d + '/' + f; if (fs.statSync(p).isFile() && (p.endsWith('.js') || p.endsWith('.d.ts'))) { const c = fs.readFileSync(p, 'utf8'); const n = c.replaceAll('@kloks/', '@ultrst-armada/kloks/').replaceAll('@ultrst/kloks/', '@ultrst-armada/kloks/').replaceAll('\\\"kloks/', '\\\"@ultrst-armada/kloks/').replaceAll('\\'kloks/', '\\'@ultrst-armada/kloks/'); if (c !== n) fs.writeFileSync(p, n); } } } })\"",
|
|
189
189
|
"prepublishOnly": "npm run postbuild",
|
|
190
|
-
"test": "vitest run",
|
|
190
|
+
"test": "vitest run && pnpm run verify:npm-trusted-publishing",
|
|
191
191
|
"typecheck": "pnpm -r run typecheck",
|
|
192
|
-
"clean": "pnpm -r run clean"
|
|
192
|
+
"clean": "pnpm -r run clean",
|
|
193
|
+
"verify:npm-trusted-publishing": "node scripts/verify-npm-trusted-publishing.mjs"
|
|
193
194
|
},
|
|
194
195
|
"dependencies": {
|
|
195
|
-
"@dinilmusick/gutts": "^1.4.
|
|
196
|
+
"@dinilmusick/gutts": "^1.4.4",
|
|
196
197
|
"@aws-sdk/client-s3": "^3.600.0",
|
|
197
198
|
"@webcontainer/api": "^1.6.4",
|
|
198
199
|
"ws": "^8.18.0",
|
|
@@ -41,7 +41,7 @@ import "./chunk-QGM4M3NI.js";
|
|
|
41
41
|
// ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.9_@types+node@22.20.5/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
|
|
42
42
|
import { randomUUID } from "crypto";
|
|
43
43
|
|
|
44
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
44
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/define-api.js
|
|
45
45
|
function defineApi(definition) {
|
|
46
46
|
const properties = Object.fromEntries(definition.parameters.map((parameter) => [
|
|
47
47
|
parameter.name,
|
|
@@ -62,7 +62,7 @@ function defineApi(definition) {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
65
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/array-apis.js
|
|
66
66
|
var array = { type: "array" };
|
|
67
67
|
var integer = { type: "integer" };
|
|
68
68
|
var arrayApis = [
|
|
@@ -73,7 +73,7 @@ var arrayApis = [
|
|
|
73
73
|
defineApi({ id: "gutts.arrays.last", name: "last", category: "arrays", description: "Returns the final element of an array, or undefined when the array is empty.", parameters: [{ name: "values", description: "The array whose final element should be returned.", required: true, schema: array }], output: { description: "The final array element, or undefined for an empty array." }, semantics: { deterministic: true, pure: true, sideEffects: false } })
|
|
74
74
|
];
|
|
75
75
|
|
|
76
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
76
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/json-apis.js
|
|
77
77
|
var json = { type: "object", description: "A JSON-compatible value." };
|
|
78
78
|
var jsonApis = [
|
|
79
79
|
defineApi({ id: "gutts.json.isJsonValue", name: "isJsonValue", category: "json", description: "Checks whether an unknown value can be represented as a finite JSON value.", parameters: [{ name: "value", description: "The value to validate as JSON-compatible data.", required: true, schema: {} }], output: { type: "boolean", description: "True when the value is a valid JSON value." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
@@ -82,7 +82,7 @@ var jsonApis = [
|
|
|
82
82
|
defineApi({ id: "gutts.json.stringifyJson", name: "stringifyJson", category: "json", description: "Serializes a JSON-compatible value into JSON text, optionally using indentation.", parameters: [{ name: "value", description: "The JSON-compatible value to serialize.", required: true, schema: {} }, { name: "space", description: "Optional number of indentation spaces to use in the serialized output.", required: false, schema: { type: "number" } }], output: { type: "string", description: "The serialized JSON text." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws TypeError when the value cannot be serialized as JSON."] })
|
|
83
83
|
];
|
|
84
84
|
|
|
85
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
85
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/number-apis.js
|
|
86
86
|
var numberApis = [
|
|
87
87
|
defineApi({ id: "gutts.numbers.clamp", name: "clamp", category: "numbers", description: "Restricts a numeric value to an inclusive minimum and maximum range.", parameters: [{ name: "value", description: "The numeric value to constrain.", required: true, schema: { type: "number" } }, { name: "min", description: "The inclusive lower bound.", required: true, schema: { type: "number" } }, { name: "max", description: "The inclusive upper bound.", required: true, schema: { type: "number" } }], output: { type: "number", description: "The value constrained to the inclusive range." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when min exceeds max."] }),
|
|
88
88
|
defineApi({ id: "gutts.numbers.inRange", name: "inRange", category: "numbers", description: "Checks whether a numeric value falls within the configured range.", parameters: [{ name: "value", description: "The numeric value to test.", required: true, schema: { type: "number" } }, { name: "min", description: "The lower range boundary.", required: true, schema: { type: "number" } }, { name: "max", description: "The upper range boundary.", required: true, schema: { type: "number" } }], output: { type: "boolean", description: "Whether the value is inside the range." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when min exceeds max."] }),
|
|
@@ -91,7 +91,7 @@ var numberApis = [
|
|
|
91
91
|
defineApi({ id: "gutts.numbers.sum", name: "sum", category: "numbers", description: "Adds all numbers in an array and returns their total.", parameters: [{ name: "values", description: "The numeric values to add.", required: true, schema: { type: "array", items: { type: "number" } } }], output: { type: "number", description: "The sum of all input numbers." }, semantics: { deterministic: true, pure: true, sideEffects: false } })
|
|
92
92
|
];
|
|
93
93
|
|
|
94
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
94
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/object-apis.js
|
|
95
95
|
var objectApis = [
|
|
96
96
|
defineApi({ id: "gutts.objects.hasOwn", name: "hasOwn", category: "objects", description: "Checks whether an object contains a requested property.", parameters: [{ name: "value", description: "The object to inspect.", required: true, schema: { type: "object" } }, { name: "key", description: "The property key to look for.", required: true, schema: { type: "string" } }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
97
97
|
defineApi({ id: "gutts.objects.pick", name: "pick", category: "objects", description: "Creates an object containing only requested properties.", parameters: [{ name: "value", description: "The source object.", required: true, schema: { type: "object" } }, { name: "keys", description: "The property keys to retain.", required: true, schema: { type: "array", items: { type: "string" } } }], output: { type: "object" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
@@ -99,7 +99,7 @@ var objectApis = [
|
|
|
99
99
|
defineApi({ id: "gutts.objects.isPlainObject", name: "isPlainObject", category: "objects", description: "Checks whether a value is a plain JavaScript object.", parameters: [{ name: "value", description: "The value to classify.", required: true, schema: {} }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } })
|
|
100
100
|
];
|
|
101
101
|
|
|
102
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
102
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/string-apis.js
|
|
103
103
|
var string = { type: "string" };
|
|
104
104
|
var stringApis = [
|
|
105
105
|
defineApi({ id: "gutts.strings.isBlank", name: "isBlank", category: "strings", description: "Checks whether a string contains no non-whitespace characters.", parameters: [{ name: "value", description: "The string to inspect.", required: true, schema: string }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
@@ -115,7 +115,7 @@ var stringApis = [
|
|
|
115
115
|
defineApi({ id: "gutts.strings.truncateWords", name: "truncateWords", category: "strings", description: "Shortens a string to a maximum number of words and appends a suffix when truncation is required.", parameters: [{ name: "value", description: "The string to shorten.", required: true, schema: string }, { name: "maxWords", description: "The non-negative maximum number of words.", required: true, schema: { type: "number" } }, { name: "suffix", description: "The suffix used when truncation occurs.", required: false, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when maxWords is negative."] })
|
|
116
116
|
];
|
|
117
117
|
|
|
118
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
118
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/url-apis.js
|
|
119
119
|
var string2 = { type: "string" };
|
|
120
120
|
var urlApis = [
|
|
121
121
|
defineApi({ id: "gutts.urls.isUrl", name: "isUrl", category: "urls", description: "Checks whether a string can be parsed as a URL by the standard URL constructor.", parameters: [{ name: "value", description: "The string to validate.", required: true, schema: string2 }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
@@ -124,7 +124,7 @@ var urlApis = [
|
|
|
124
124
|
defineApi({ id: "gutts.urls.setQueryParam", name: "setQueryParam", category: "urls", description: "Returns a URL with one query-string parameter set to the supplied value.", parameters: [{ name: "url", description: "The URL to modify.", required: true, schema: string2 }, { name: "key", description: "The query parameter name.", required: true, schema: string2 }, { name: "value", description: "The query parameter value.", required: true, schema: string2 }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws when url cannot be parsed as a URL."] })
|
|
125
125
|
];
|
|
126
126
|
|
|
127
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
127
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/needle3/index.js
|
|
128
128
|
var needle3Metadata = {
|
|
129
129
|
id: "model.cactus-needle3",
|
|
130
130
|
name: "Needle 3",
|
|
@@ -155,12 +155,12 @@ var needle3CompleteApi = defineApi({
|
|
|
155
155
|
semantics: { deterministic: false, pure: false, sideEffects: false }
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
158
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/runtimes/ettin-head.js
|
|
159
159
|
import fs from "fs";
|
|
160
160
|
import path from "path";
|
|
161
161
|
import os from "os";
|
|
162
162
|
|
|
163
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
163
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/smollm2/index.js
|
|
164
164
|
var smolLM2Metadata = {
|
|
165
165
|
id: "model.smollm2-135m-instruct",
|
|
166
166
|
name: "SmolLM2-135M-Instruct",
|
|
@@ -192,7 +192,7 @@ var smolLM2GenerateApi = defineApi({
|
|
|
192
192
|
errors: ["Model load failure", "Inference failure"]
|
|
193
193
|
});
|
|
194
194
|
|
|
195
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
195
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/whistle/index.js
|
|
196
196
|
var whistleMetadata = {
|
|
197
197
|
id: "model.cactus-whistle",
|
|
198
198
|
name: "Whistle",
|
|
@@ -222,7 +222,7 @@ var whistleTranscribeApi = defineApi({
|
|
|
222
222
|
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
223
223
|
});
|
|
224
224
|
|
|
225
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
225
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/ettin/index.js
|
|
226
226
|
var defineEttin = (id2, name, parameters, description) => ({
|
|
227
227
|
id: id2,
|
|
228
228
|
name,
|
|
@@ -257,7 +257,7 @@ var ettinRerankApi = defineApi({
|
|
|
257
257
|
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
258
258
|
});
|
|
259
259
|
|
|
260
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
260
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/minilm/index.js
|
|
261
261
|
var miniLML6Metadata = {
|
|
262
262
|
id: "model.minilm-l6-v2",
|
|
263
263
|
name: "MiniLM-L6-v2",
|
|
@@ -288,7 +288,7 @@ var miniLMSimilarityApi = defineApi({
|
|
|
288
288
|
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
289
289
|
});
|
|
290
290
|
|
|
291
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
291
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/api-registry.js
|
|
292
292
|
var guttsApiDefinitions = Object.freeze([
|
|
293
293
|
...arrayApis,
|
|
294
294
|
...jsonApis,
|
|
@@ -304,7 +304,7 @@ var guttsApiDefinitions = Object.freeze([
|
|
|
304
304
|
]);
|
|
305
305
|
var guttsApiById = Object.freeze(Object.fromEntries(guttsApiDefinitions.map((api) => [api.id, api])));
|
|
306
306
|
|
|
307
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
307
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/fod-node-provider.js
|
|
308
308
|
var schemaType = (schema) => String(schema?.type ?? "any");
|
|
309
309
|
function guttsApiToFodNode(api) {
|
|
310
310
|
return {
|
|
@@ -320,7 +320,7 @@ function guttsApiToFodNode(api) {
|
|
|
320
320
|
}
|
|
321
321
|
var guttsFodNodeDefinitions = Object.freeze(guttsApiDefinitions.map(guttsApiToFodNode));
|
|
322
322
|
|
|
323
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.
|
|
323
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.4.4_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/model-registry.js
|
|
324
324
|
var guttsModelDefinitions = Object.freeze([
|
|
325
325
|
smolLM2Metadata,
|
|
326
326
|
needle3Metadata,
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// src/development/webContainerRuntime.ts
|
|
2
|
+
var COMMANDS = {
|
|
3
|
+
install: { command: "pnpm", args: ["install", "--frozen-lockfile"] },
|
|
4
|
+
lint: { command: "pnpm", args: ["lint"] },
|
|
5
|
+
test: { command: "pnpm", args: ["test"] },
|
|
6
|
+
build: { command: "pnpm", args: ["build"] },
|
|
7
|
+
validate: { command: "pnpm", args: ["validate"] },
|
|
8
|
+
check: { command: "pnpm", args: ["lint"] }
|
|
9
|
+
};
|
|
10
|
+
function resolveWebContainerCommand(task) {
|
|
11
|
+
const command = COMMANDS[task];
|
|
12
|
+
return { command: command.command, args: [...command.args] };
|
|
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
|
+
var runQueue = Promise.resolve();
|
|
64
|
+
var sharedContainer = null;
|
|
65
|
+
var sharedContainerPromise = null;
|
|
66
|
+
var WebContainerRuntime = class {
|
|
67
|
+
async boot() {
|
|
68
|
+
if (typeof window !== "undefined" && !window.crossOriginIsolated) {
|
|
69
|
+
throw new Error("WebContainer requires a cross-origin-isolated page. Ensure COOP=same-origin and COEP=require-corp are served.");
|
|
70
|
+
}
|
|
71
|
+
if (sharedContainer) return sharedContainer;
|
|
72
|
+
if (!sharedContainerPromise) {
|
|
73
|
+
sharedContainerPromise = import("@webcontainer/api").then(async (module) => {
|
|
74
|
+
const container = await module.WebContainer.boot({ coep: "require-corp", workdirName: "kloks-development" });
|
|
75
|
+
sharedContainer = container;
|
|
76
|
+
return container;
|
|
77
|
+
}).catch((error) => {
|
|
78
|
+
sharedContainerPromise = null;
|
|
79
|
+
throw error;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return sharedContainerPromise;
|
|
83
|
+
}
|
|
84
|
+
async mount(files, mountPoint = "/", sourceSha) {
|
|
85
|
+
const container = await this.boot();
|
|
86
|
+
await container.mount(files, mountPoint === "/" ? void 0 : { mountPoint });
|
|
87
|
+
return { mounted: true, mountPoint, sourceSha };
|
|
88
|
+
}
|
|
89
|
+
async runProcess(command, args, cwd, env, sourceSha) {
|
|
90
|
+
const container = await this.boot();
|
|
91
|
+
const process = await container.spawn(command, args, { cwd, env });
|
|
92
|
+
const started = Date.now();
|
|
93
|
+
let output = "";
|
|
94
|
+
const reader = process.output.getReader();
|
|
95
|
+
try {
|
|
96
|
+
while (true) {
|
|
97
|
+
const next = await reader.read();
|
|
98
|
+
if (next.done) break;
|
|
99
|
+
output += next.value;
|
|
100
|
+
}
|
|
101
|
+
} finally {
|
|
102
|
+
reader.releaseLock();
|
|
103
|
+
}
|
|
104
|
+
const exitCode = await process.exit;
|
|
105
|
+
return {
|
|
106
|
+
exitCode,
|
|
107
|
+
output,
|
|
108
|
+
command: [command, ...args].join(" "),
|
|
109
|
+
durationMs: Date.now() - started,
|
|
110
|
+
diagnostics: parseDevelopmentDiagnostics(output, exitCode),
|
|
111
|
+
sourceSha
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async run(task, cwd, env, sourceSha) {
|
|
115
|
+
const spec = resolveWebContainerCommand(task);
|
|
116
|
+
return this.runCommand(spec.command, spec.args, cwd, env, sourceSha);
|
|
117
|
+
}
|
|
118
|
+
async runCommand(command, args = [], cwd, env, sourceSha) {
|
|
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, sourceSha);
|
|
127
|
+
} finally {
|
|
128
|
+
release();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async spawnCommand(command, args = [], cwd, env, sourceSha) {
|
|
132
|
+
const container = await this.boot();
|
|
133
|
+
const process = await container.spawn(command, args, { cwd, env });
|
|
134
|
+
return { processId: globalThis.crypto.randomUUID(), sourceSha, command: [command, ...args].join(" "), startedAt: (/* @__PURE__ */ new Date()).toISOString(), process: captureDevelopmentProcess(process) };
|
|
135
|
+
}
|
|
136
|
+
async teardown(mountPoint) {
|
|
137
|
+
const container = sharedContainer;
|
|
138
|
+
if (!container) return { tornDown: true, mountPoint };
|
|
139
|
+
if (mountPoint && mountPoint !== "/") {
|
|
140
|
+
await container.fs.rm(mountPoint, { recursive: true, force: true });
|
|
141
|
+
return { tornDown: true, mountPoint };
|
|
142
|
+
}
|
|
143
|
+
sharedContainer = null;
|
|
144
|
+
sharedContainerPromise = null;
|
|
145
|
+
await container.teardown();
|
|
146
|
+
return { tornDown: true, mountPoint: "/" };
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
resolveWebContainerCommand,
|
|
152
|
+
parseDevelopmentDiagnostics,
|
|
153
|
+
captureDevelopmentProcess,
|
|
154
|
+
WebContainerRuntime
|
|
155
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WebContainerRuntime,
|
|
3
|
+
resolveWebContainerCommand
|
|
4
|
+
} from "./chunk-CA5HVC4X.js";
|
|
5
|
+
import {
|
|
6
|
+
createService,
|
|
7
|
+
createServiceDefinition
|
|
8
|
+
} from "./chunk-SXDYW3QA.js";
|
|
9
|
+
|
|
10
|
+
// src/development/webContainerService.ts
|
|
11
|
+
var runtime = new WebContainerRuntime();
|
|
12
|
+
var WebContainerServiceDefinition = createServiceDefinition({
|
|
13
|
+
id: "kloks.backend.webContainer",
|
|
14
|
+
name: "WebContainerService",
|
|
15
|
+
version: "1.3.0",
|
|
16
|
+
operations: {
|
|
17
|
+
boot: { id: "WebContainerService.boot", name: "boot", handler: async () => {
|
|
18
|
+
await runtime.boot();
|
|
19
|
+
return { ready: true };
|
|
20
|
+
} },
|
|
21
|
+
mount: { id: "WebContainerService.mount", name: "mount", handler: async (input) => runtime.mount(input.files, input.mountPoint, input.sourceSha) },
|
|
22
|
+
run: { id: "WebContainerService.run", name: "run", handler: async (input) => runtime.run(input.task, input.cwd, input.env, input.sourceSha) },
|
|
23
|
+
runCommand: { id: "WebContainerService.runCommand", name: "runCommand", handler: async (input) => runtime.runCommand(input.command, input.args, input.cwd, input.env, input.sourceSha) },
|
|
24
|
+
spawnCommand: { id: "WebContainerService.spawnCommand", name: "spawnCommand", handler: async (input) => runtime.spawnCommand(input.command, input.args, input.cwd, input.env, input.sourceSha) },
|
|
25
|
+
teardown: { id: "WebContainerService.teardown", name: "teardown", handler: async (input) => runtime.teardown(input?.mountPoint) },
|
|
26
|
+
command: { id: "WebContainerService.command", name: "command", handler: async (input) => ({ task: input.task, command: resolveWebContainerCommand(input.task) }) }
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var WebContainerServiceFacade = {
|
|
30
|
+
id: WebContainerServiceDefinition.id,
|
|
31
|
+
name: WebContainerServiceDefinition.name,
|
|
32
|
+
version: WebContainerServiceDefinition.version,
|
|
33
|
+
runtime: "client",
|
|
34
|
+
deployment: "local",
|
|
35
|
+
definition: WebContainerServiceDefinition,
|
|
36
|
+
createInstance: () => createService(WebContainerServiceDefinition),
|
|
37
|
+
execute: async (op, input) => {
|
|
38
|
+
const instance = createService(WebContainerServiceDefinition);
|
|
39
|
+
await instance.start();
|
|
40
|
+
return instance.call(op, input);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
WebContainerServiceDefinition,
|
|
46
|
+
WebContainerServiceFacade
|
|
47
|
+
};
|
|
@@ -3,27 +3,35 @@ import {
|
|
|
3
3
|
} from "./chunk-4QEMALXF.js";
|
|
4
4
|
|
|
5
5
|
// src/srkl/SrklDiscoveryService.ts
|
|
6
|
-
var
|
|
7
|
-
async function
|
|
8
|
-
if (
|
|
6
|
+
var cachedSrklUrls = null;
|
|
7
|
+
async function getRegisteredSrklDeploymentUrls(queryDb) {
|
|
8
|
+
if (cachedSrklUrls && Date.now() < cachedSrklUrls.expiresAt && cachedSrklUrls.urls.length > 0) {
|
|
9
|
+
return cachedSrklUrls.urls;
|
|
10
|
+
}
|
|
9
11
|
if (queryDb) {
|
|
10
12
|
try {
|
|
11
13
|
const res = await queryDb(
|
|
12
|
-
`SELECT url FROM "ultrst-srkl-deployments" WHERE is_active = true ORDER BY is_primary DESC, priority DESC, created_at ASC
|
|
14
|
+
`SELECT url FROM "ultrst-srkl-deployments" WHERE is_active = true ORDER BY is_primary DESC, priority DESC, created_at ASC`,
|
|
13
15
|
[]
|
|
14
16
|
);
|
|
15
|
-
if (res.rows.length > 0
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
if (res.rows.length > 0) {
|
|
18
|
+
const urls = res.rows.map((r) => String(r.url || "").trim().replace(/\/+$/, "")).filter(Boolean);
|
|
19
|
+
if (urls.length > 0) {
|
|
20
|
+
cachedSrklUrls = { urls, expiresAt: Date.now() + 10 * 60 * 1e3 };
|
|
21
|
+
return urls;
|
|
22
|
+
}
|
|
19
23
|
}
|
|
20
24
|
} catch {
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
|
-
const fallback = "https://srkl-engine.vercel.app";
|
|
24
|
-
|
|
27
|
+
const fallback = ["https://srkl-engine.vercel.app"];
|
|
28
|
+
cachedSrklUrls = { urls: fallback, expiresAt: Date.now() + 10 * 60 * 1e3 };
|
|
25
29
|
return fallback;
|
|
26
30
|
}
|
|
31
|
+
async function getPrimarySrklDeploymentUrl(queryDb) {
|
|
32
|
+
const urls = await getRegisteredSrklDeploymentUrls(queryDb);
|
|
33
|
+
return urls[0] || "https://srkl-engine.vercel.app";
|
|
34
|
+
}
|
|
27
35
|
async function getSrklAccounts(userId, service, queryDb) {
|
|
28
36
|
const srklUrl = await getPrimarySrklDeploymentUrl(queryDb);
|
|
29
37
|
const accounts = [];
|
|
@@ -1,51 +1,11 @@
|
|
|
1
|
+
import { a as WebContainerRuntime, D as DevelopmentRequest, b as DevelopmentResult } from '../webContainerRuntime-BnHB2bNz.js';
|
|
2
|
+
export { d as DevelopmentDiagnostic, e as DevelopmentProvider, f as DevelopmentServiceContract, g as DevelopmentTask, h as WebContainerCommand, W as WebContainerRunCommandInput, c as captureDevelopmentProcess, p as parseDevelopmentDiagnostics, r as resolveWebContainerCommand } from '../webContainerRuntime-BnHB2bNz.js';
|
|
1
3
|
import * as _ultrst_armada_krnl from '@ultrst-armada/krnl';
|
|
2
4
|
import { ServiceDefinition } from '@ultrst-armada/krnl';
|
|
5
|
+
export { WebContainerServiceDefinition, WebContainerServiceFacade } from './webContainerService.js';
|
|
3
6
|
export { InspectionCheck, InspectionCheckResult, InspectionError, InspectionErrorKind, InspectionLog, InspectionViewport, PlaywrightInspectionRequest, PlaywrightInspectionResult } from './playwrightInspectionTypes.js';
|
|
4
7
|
export { PlaywrightInspectionRuntime, PlaywrightInspectionServiceDefinition, PlaywrightInspectionServiceFacade } from './playwrightInspectionService.js';
|
|
5
8
|
|
|
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
|
-
sourceSha?: string;
|
|
18
|
-
}
|
|
19
|
-
interface DevelopmentDiagnostic {
|
|
20
|
-
severity: 'error' | 'warning' | 'info';
|
|
21
|
-
source: 'typescript' | 'eslint' | 'bundler' | 'package-manager' | 'runtime' | 'unknown';
|
|
22
|
-
code?: string;
|
|
23
|
-
file?: string;
|
|
24
|
-
line?: number;
|
|
25
|
-
column?: number;
|
|
26
|
-
message: string;
|
|
27
|
-
}
|
|
28
|
-
interface DevelopmentResult {
|
|
29
|
-
provider: DevelopmentProvider;
|
|
30
|
-
task: DevelopmentTask;
|
|
31
|
-
ok: boolean;
|
|
32
|
-
exitCode?: number;
|
|
33
|
-
output?: string;
|
|
34
|
-
command?: string;
|
|
35
|
-
durationMs?: number;
|
|
36
|
-
diagnostics?: DevelopmentDiagnostic[];
|
|
37
|
-
sourceSha?: string;
|
|
38
|
-
runId?: number;
|
|
39
|
-
url?: string;
|
|
40
|
-
}
|
|
41
|
-
interface WebContainerCommand {
|
|
42
|
-
command: string;
|
|
43
|
-
args: string[];
|
|
44
|
-
}
|
|
45
|
-
interface DevelopmentServiceContract {
|
|
46
|
-
definition: ServiceDefinition;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
9
|
interface GitHubActionsConfig {
|
|
50
10
|
token: string;
|
|
51
11
|
apiBaseUrl?: string;
|
|
@@ -101,75 +61,6 @@ declare const GitHubActionsServiceFacade: {
|
|
|
101
61
|
execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
|
|
102
62
|
};
|
|
103
63
|
|
|
104
|
-
declare function resolveWebContainerCommand(task: DevelopmentTask): WebContainerCommand;
|
|
105
|
-
declare function parseDevelopmentDiagnostics(output: string, exitCode?: number): DevelopmentDiagnostic[];
|
|
106
|
-
declare function captureDevelopmentProcess<T extends {
|
|
107
|
-
output: ReadableStream<string>;
|
|
108
|
-
exit: Promise<number>;
|
|
109
|
-
}>(process: T): T & {
|
|
110
|
-
output: ReadableStream<string>;
|
|
111
|
-
logs: Promise<{
|
|
112
|
-
output: string;
|
|
113
|
-
exitCode: number;
|
|
114
|
-
diagnostics: DevelopmentDiagnostic[];
|
|
115
|
-
}>;
|
|
116
|
-
};
|
|
117
|
-
interface WebContainerRunCommandInput {
|
|
118
|
-
command: string;
|
|
119
|
-
args?: string[];
|
|
120
|
-
cwd?: string;
|
|
121
|
-
env?: Record<string, string | number | boolean>;
|
|
122
|
-
sourceSha?: string;
|
|
123
|
-
}
|
|
124
|
-
declare class WebContainerRuntime {
|
|
125
|
-
boot(): Promise<any>;
|
|
126
|
-
mount(files: Record<string, unknown>, mountPoint?: string, sourceSha?: string): Promise<{
|
|
127
|
-
mounted: boolean;
|
|
128
|
-
mountPoint: string;
|
|
129
|
-
sourceSha: string;
|
|
130
|
-
}>;
|
|
131
|
-
private runProcess;
|
|
132
|
-
run(task: DevelopmentTask, cwd?: string, env?: Record<string, string>, sourceSha?: string): Promise<{
|
|
133
|
-
exitCode: any;
|
|
134
|
-
output: string;
|
|
135
|
-
command: string;
|
|
136
|
-
durationMs: number;
|
|
137
|
-
diagnostics: DevelopmentDiagnostic[];
|
|
138
|
-
sourceSha: string;
|
|
139
|
-
}>;
|
|
140
|
-
runCommand(command: string, args?: string[], cwd?: string, env?: Record<string, string | number | boolean>, sourceSha?: string): Promise<{
|
|
141
|
-
exitCode: any;
|
|
142
|
-
output: string;
|
|
143
|
-
command: string;
|
|
144
|
-
durationMs: number;
|
|
145
|
-
diagnostics: DevelopmentDiagnostic[];
|
|
146
|
-
sourceSha: string;
|
|
147
|
-
}>;
|
|
148
|
-
spawnCommand(command: string, args?: string[], cwd?: string, env?: Record<string, string | number | boolean>, sourceSha?: string): Promise<{
|
|
149
|
-
processId: `${string}-${string}-${string}-${string}-${string}`;
|
|
150
|
-
sourceSha: string;
|
|
151
|
-
command: string;
|
|
152
|
-
startedAt: string;
|
|
153
|
-
process: any;
|
|
154
|
-
}>;
|
|
155
|
-
teardown(mountPoint?: string): Promise<{
|
|
156
|
-
tornDown: boolean;
|
|
157
|
-
mountPoint: string;
|
|
158
|
-
}>;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
declare const WebContainerServiceDefinition: ServiceDefinition;
|
|
162
|
-
declare const WebContainerServiceFacade: {
|
|
163
|
-
id: string;
|
|
164
|
-
name: string;
|
|
165
|
-
version: string;
|
|
166
|
-
runtime: "client";
|
|
167
|
-
deployment: "local";
|
|
168
|
-
definition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
|
|
169
|
-
createInstance: () => _ultrst_armada_krnl.ServiceInstance<Record<string, unknown>, Record<string, unknown>>;
|
|
170
|
-
execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
|
|
171
|
-
};
|
|
172
|
-
|
|
173
64
|
declare function resolveDevelopmentCommand(task: DevelopmentRequest['task']): [string, string[]];
|
|
174
65
|
declare const DevelopmentServiceDefinition: ServiceDefinition;
|
|
175
66
|
declare class DevelopmentRuntime {
|
|
@@ -343,4 +234,4 @@ declare const AgentHarnessServiceFacade: {
|
|
|
343
234
|
execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
|
|
344
235
|
};
|
|
345
236
|
|
|
346
|
-
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,
|
|
237
|
+
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, 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, type ValidationDiagnostic, type ValidationLayer, WebContainerRuntime, type WorkflowRun, codeDiagnosticsService, resolveDevelopmentCommand };
|