@ultrst-armada/kloks 1.24.1 → 1.24.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.krusbl-release-attestation.json +3 -3
- package/package.json +11 -1
- package/packages/backend/dist/chunk-2OPIDIIB.js +191 -0
- package/packages/backend/dist/chunk-7K552XGT.js +425 -0
- package/packages/backend/dist/chunk-AGI3VKCZ.js +253 -0
- package/packages/backend/dist/chunk-YEGS4HTA.js +0 -0
- package/packages/backend/dist/development/client.d.ts +142 -0
- package/packages/backend/dist/development/client.js +24 -0
- package/packages/backend/dist/development/index.d.ts +5 -212
- package/packages/backend/dist/development/index.js +14 -9
- package/packages/backend/dist/development/playwrightInspectionService.d.ts +20 -0
- package/packages/backend/dist/development/playwrightInspectionService.js +12 -0
- package/packages/backend/dist/development/playwrightInspectionTypes.d.ts +59 -0
- package/packages/backend/dist/development/playwrightInspectionTypes.js +1 -0
- package/packages/backend/dist/index.d.ts +4 -1
- package/packages/backend/dist/index.js +61 -56
- package/packages/backend/dist/krnl-services.js +5 -5
- package/packages/backend/dist/services/index.js +1 -1
- package/packages/backend/dist/storage/index.js +7 -7
- package/packages/backend/dist/workspace/index.js +2 -2
- package/packages/backend/package.json +1 -1
- package/packages/backend/dist/chunk-6TRVGWXP.js +0 -851
- package/packages/backend/dist/{chunk-VTU6CNZD.js → chunk-AHJ2EWQW.js} +12 -12
- package/packages/backend/dist/{chunk-WQ4XZY4L.js → chunk-SVNL5IVN.js} +3 -3
|
@@ -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.3",
|
|
5
|
+
"sourceCommit": "20945680ee42c1576ccfdc915cb91e59cfee6c77",
|
|
6
6
|
"releaseWorkflow": "npm Release",
|
|
7
|
-
"workflowRunId": "
|
|
7
|
+
"workflowRunId": "41534133554"
|
|
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.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -166,6 +166,16 @@
|
|
|
166
166
|
"types": "./packages/semantic-runtime/dist/index.d.ts",
|
|
167
167
|
"import": "./packages/semantic-runtime/dist/index.js",
|
|
168
168
|
"default": "./packages/semantic-runtime/dist/index.js"
|
|
169
|
+
},
|
|
170
|
+
"./development/webcontainer": {
|
|
171
|
+
"types": "./packages/backend/dist/development/webContainerService.d.ts",
|
|
172
|
+
"import": "./packages/backend/dist/development/webContainerService.js",
|
|
173
|
+
"default": "./packages/backend/dist/development/webContainerService.js"
|
|
174
|
+
},
|
|
175
|
+
"./development/client": {
|
|
176
|
+
"types": "./packages/backend/dist/development/client.d.ts",
|
|
177
|
+
"import": "./packages/backend/dist/development/client.js",
|
|
178
|
+
"default": "./packages/backend/dist/development/client.js"
|
|
169
179
|
}
|
|
170
180
|
},
|
|
171
181
|
"scripts": {
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createService,
|
|
3
|
+
createServiceDefinition
|
|
4
|
+
} from "./chunk-MWSYNRNZ.js";
|
|
5
|
+
|
|
6
|
+
// src/development/playwrightInspectionService.ts
|
|
7
|
+
import { randomUUID } from "crypto";
|
|
8
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
9
|
+
import { dirname, join } from "path";
|
|
10
|
+
|
|
11
|
+
// src/development/playwrightInspectionSupport.ts
|
|
12
|
+
import { createRequire } from "module";
|
|
13
|
+
var require2 = createRequire(import.meta.url);
|
|
14
|
+
function loadPlaywright() {
|
|
15
|
+
try {
|
|
16
|
+
return require2("playwright");
|
|
17
|
+
} catch {
|
|
18
|
+
throw new Error('Playwright is required for browser inspection. Install the optional "playwright" package and Chromium browser.');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function recordInspectionError(errors, kind, message, url, status, method) {
|
|
22
|
+
errors.push({ kind, message, ...url ? { url } : {}, ...status ? { status } : {}, ...method ? { method } : {} });
|
|
23
|
+
}
|
|
24
|
+
async function runInspectionCheck(page, check) {
|
|
25
|
+
try {
|
|
26
|
+
const locator = page.locator(check.selector);
|
|
27
|
+
if (await locator.count() === 0) throw new Error("Selector matched no elements");
|
|
28
|
+
if (check.visible !== void 0 && await locator.isVisible() !== check.visible) throw new Error(`Expected visible=${check.visible}`);
|
|
29
|
+
if (check.text !== void 0 && !(await locator.innerText()).includes(check.text)) throw new Error(`Expected text containing: ${check.text}`);
|
|
30
|
+
if (check.action?.type === "click") await locator.click();
|
|
31
|
+
if (check.action?.type === "fill") await locator.fill(check.action.value ?? "");
|
|
32
|
+
return { selector: check.selector, passed: true };
|
|
33
|
+
} catch (cause) {
|
|
34
|
+
return { selector: check.selector, passed: false, details: cause instanceof Error ? cause.message : String(cause) };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/development/playwrightInspectionService.ts
|
|
39
|
+
var PlaywrightInspectionRuntime = class {
|
|
40
|
+
async inspect(request) {
|
|
41
|
+
const started = Date.now();
|
|
42
|
+
const errors = [];
|
|
43
|
+
const logs = [];
|
|
44
|
+
const checks = [];
|
|
45
|
+
const screenshots = [];
|
|
46
|
+
const screenshotDirectory = request.screenshotDirectory ?? join(process.cwd(), "artifacts/playwright", randomUUID());
|
|
47
|
+
const reportPath = request.reportPath ?? join(screenshotDirectory, "report.json");
|
|
48
|
+
const timeout = request.timeoutMs ?? 15e3;
|
|
49
|
+
let browser;
|
|
50
|
+
try {
|
|
51
|
+
browser = await loadPlaywright().chromium.launch({ headless: true });
|
|
52
|
+
} catch (cause) {
|
|
53
|
+
recordInspectionError(errors, "browser", cause instanceof Error ? cause.message : String(cause), request.url);
|
|
54
|
+
const result2 = {
|
|
55
|
+
ok: false,
|
|
56
|
+
url: request.url,
|
|
57
|
+
durationMs: Date.now() - started,
|
|
58
|
+
errors,
|
|
59
|
+
logs,
|
|
60
|
+
checks,
|
|
61
|
+
screenshots,
|
|
62
|
+
reportPath
|
|
63
|
+
};
|
|
64
|
+
await mkdir(dirname(reportPath), { recursive: true });
|
|
65
|
+
await writeFile(reportPath, JSON.stringify(result2, null, 2), "utf8");
|
|
66
|
+
return result2;
|
|
67
|
+
}
|
|
68
|
+
const context = await browser.newContext({ ignoreHTTPSErrors: false });
|
|
69
|
+
const page = await context.newPage();
|
|
70
|
+
let status;
|
|
71
|
+
let title;
|
|
72
|
+
let domSnapshot;
|
|
73
|
+
page.on("console", (message) => {
|
|
74
|
+
const location = message.location();
|
|
75
|
+
const type = message.type();
|
|
76
|
+
logs.push({ type, message: message.text(), url: page.url(), ...location.lineNumber ? { line: location.lineNumber } : {}, ...location.columnNumber ? { column: location.columnNumber } : {} });
|
|
77
|
+
if (type === "error") recordInspectionError(errors, "console", message.text(), page.url());
|
|
78
|
+
});
|
|
79
|
+
page.on("pageerror", (cause) => recordInspectionError(errors, "pageerror", cause instanceof Error ? cause.stack ?? cause.message : String(cause), page.url()));
|
|
80
|
+
page.on("requestfailed", (requestInfo) => recordInspectionError(errors, "requestfailed", requestInfo.failure()?.errorText ?? "Request failed", requestInfo.url(), void 0, requestInfo.method()));
|
|
81
|
+
page.on("response", (response) => {
|
|
82
|
+
if (response.status() >= 400) recordInspectionError(errors, "http", `HTTP ${response.status()} ${response.statusText()}`, response.url(), response.status(), response.request().method());
|
|
83
|
+
});
|
|
84
|
+
page.on("crash", () => recordInspectionError(errors, "crash", "Browser page crashed", page.url()));
|
|
85
|
+
page.on("dialog", async (dialog) => {
|
|
86
|
+
recordInspectionError(errors, "dialog", `Unexpected ${dialog.type()} dialog: ${dialog.message()}`, page.url());
|
|
87
|
+
await dialog.dismiss();
|
|
88
|
+
});
|
|
89
|
+
try {
|
|
90
|
+
try {
|
|
91
|
+
const response = await page.goto(request.url, { waitUntil: request.waitUntil ?? "networkidle", timeout });
|
|
92
|
+
status = response?.status();
|
|
93
|
+
} catch (cause) {
|
|
94
|
+
recordInspectionError(errors, "navigation", cause instanceof Error ? cause.message : String(cause), request.url);
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
await page.waitForLoadState("domcontentloaded", { timeout });
|
|
98
|
+
} catch {
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
title = await page.title();
|
|
102
|
+
} catch {
|
|
103
|
+
}
|
|
104
|
+
for (const check of request.checks ?? []) checks.push(await runInspectionCheck(page, check));
|
|
105
|
+
for (const viewport of request.viewports ?? [{ width: 1440, height: 900 }, { width: 390, height: 844 }]) {
|
|
106
|
+
try {
|
|
107
|
+
await page.setViewportSize(viewport);
|
|
108
|
+
const layout = await page.evaluate(() => ({
|
|
109
|
+
viewportWidth: window.innerWidth,
|
|
110
|
+
documentWidth: document.documentElement.scrollWidth,
|
|
111
|
+
brokenImages: Array.from(document.images).filter((image) => image.complete && image.naturalWidth === 0).map((image) => image.src)
|
|
112
|
+
}));
|
|
113
|
+
if (layout.documentWidth > layout.viewportWidth + 1) {
|
|
114
|
+
recordInspectionError(errors, "layout", `Horizontal overflow: document width ${layout.documentWidth}px exceeds viewport ${layout.viewportWidth}px`, request.url);
|
|
115
|
+
}
|
|
116
|
+
for (const imageUrl of layout.brokenImages) recordInspectionError(errors, "asset", "Image failed to render", imageUrl);
|
|
117
|
+
{
|
|
118
|
+
await mkdir(screenshotDirectory, { recursive: true });
|
|
119
|
+
const path = join(screenshotDirectory, `inspection-${viewport.width}x${viewport.height}.png`);
|
|
120
|
+
await page.screenshot({ path, fullPage: true });
|
|
121
|
+
screenshots.push(path);
|
|
122
|
+
}
|
|
123
|
+
} catch (cause) {
|
|
124
|
+
recordInspectionError(errors, "screenshot", cause instanceof Error ? cause.message : String(cause), request.url);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (request.captureDom) {
|
|
128
|
+
try {
|
|
129
|
+
const html = await page.content();
|
|
130
|
+
domSnapshot = html.slice(0, request.maxDomCharacters ?? 4e4);
|
|
131
|
+
} catch (cause) {
|
|
132
|
+
recordInspectionError(errors, "dom", cause instanceof Error ? cause.message : String(cause), request.url);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} finally {
|
|
136
|
+
await page.close().catch(() => void 0);
|
|
137
|
+
await context.close().catch(() => void 0);
|
|
138
|
+
await browser.close().catch(() => void 0);
|
|
139
|
+
}
|
|
140
|
+
for (const check of checks) if (!check.passed) recordInspectionError(errors, "assertion", check.details ?? "Inspection assertion failed", request.url);
|
|
141
|
+
const result = {
|
|
142
|
+
ok: errors.length === 0,
|
|
143
|
+
url: request.url,
|
|
144
|
+
...title ? { title } : {},
|
|
145
|
+
...status !== void 0 ? { status } : {},
|
|
146
|
+
durationMs: Date.now() - started,
|
|
147
|
+
errors,
|
|
148
|
+
logs,
|
|
149
|
+
checks,
|
|
150
|
+
screenshots,
|
|
151
|
+
reportPath,
|
|
152
|
+
...domSnapshot ? { domSnapshot } : {}
|
|
153
|
+
};
|
|
154
|
+
await mkdir(dirname(reportPath), { recursive: true });
|
|
155
|
+
await writeFile(reportPath, JSON.stringify(result, null, 2), "utf8");
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var runtime = new PlaywrightInspectionRuntime();
|
|
160
|
+
var PlaywrightInspectionServiceDefinition = createServiceDefinition({
|
|
161
|
+
id: "kloks.backend.playwrightInspection",
|
|
162
|
+
name: "PlaywrightInspectionService",
|
|
163
|
+
version: "1.0.0",
|
|
164
|
+
operations: {
|
|
165
|
+
inspect: {
|
|
166
|
+
id: "PlaywrightInspectionService.inspect",
|
|
167
|
+
name: "inspect",
|
|
168
|
+
handler: async (input) => runtime.inspect(input)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
var PlaywrightInspectionServiceFacade = {
|
|
173
|
+
id: PlaywrightInspectionServiceDefinition.id,
|
|
174
|
+
name: PlaywrightInspectionServiceDefinition.name,
|
|
175
|
+
version: PlaywrightInspectionServiceDefinition.version,
|
|
176
|
+
runtime: "server",
|
|
177
|
+
deployment: "local",
|
|
178
|
+
definition: PlaywrightInspectionServiceDefinition,
|
|
179
|
+
createInstance: () => createService(PlaywrightInspectionServiceDefinition),
|
|
180
|
+
execute: async (op, input) => {
|
|
181
|
+
const instance = createService(PlaywrightInspectionServiceDefinition);
|
|
182
|
+
await instance.start();
|
|
183
|
+
return instance.call(op, input);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export {
|
|
188
|
+
PlaywrightInspectionRuntime,
|
|
189
|
+
PlaywrightInspectionServiceDefinition,
|
|
190
|
+
PlaywrightInspectionServiceFacade
|
|
191
|
+
};
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WebContainerRuntime,
|
|
3
|
+
resolveWebContainerCommand
|
|
4
|
+
} from "./chunk-AGI3VKCZ.js";
|
|
5
|
+
import {
|
|
6
|
+
createService,
|
|
7
|
+
createServiceDefinition
|
|
8
|
+
} from "./chunk-MWSYNRNZ.js";
|
|
9
|
+
|
|
10
|
+
// src/development/githubActionsService.ts
|
|
11
|
+
var GitHubActionsClient = class {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.config = config;
|
|
14
|
+
this.baseUrl = config.apiBaseUrl ?? "https://api.github.com";
|
|
15
|
+
this.fetchImpl = config.fetchImpl ?? fetch;
|
|
16
|
+
}
|
|
17
|
+
config;
|
|
18
|
+
baseUrl;
|
|
19
|
+
fetchImpl;
|
|
20
|
+
async request(path, init = {}) {
|
|
21
|
+
const response = await this.fetchImpl(this.baseUrl + path, {
|
|
22
|
+
...init,
|
|
23
|
+
headers: {
|
|
24
|
+
Accept: "application/vnd.github+json",
|
|
25
|
+
Authorization: `Bearer ${this.config.token}`,
|
|
26
|
+
"X-GitHub-Api-Version": "2022-11-28",
|
|
27
|
+
...init.headers ?? {}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const text = await response.text();
|
|
31
|
+
const data = text ? JSON.parse(text) : void 0;
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
throw new Error(`GitHub Actions request failed (${response.status}): ${data?.message ?? response.statusText}`);
|
|
34
|
+
}
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
listWorkflowRuns(repository, workflowId, branch) {
|
|
38
|
+
const suffix = workflowId ? `/actions/workflows/${workflowId}/runs` : "/actions/runs";
|
|
39
|
+
const query = branch ? `?branch=${encodeURIComponent(branch)}` : "";
|
|
40
|
+
return this.request(`/repos/${repository}${suffix}${query}`);
|
|
41
|
+
}
|
|
42
|
+
getWorkflowRun(repository, runId) {
|
|
43
|
+
return this.request(`/repos/${repository}/actions/runs/${runId}`);
|
|
44
|
+
}
|
|
45
|
+
getWorkflowJobs(repository, runId) {
|
|
46
|
+
return this.request(
|
|
47
|
+
`/repos/${repository}/actions/runs/${runId}/jobs`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
getJobLogs(repository, jobId) {
|
|
51
|
+
return this.request(`/repos/${repository}/actions/jobs/${jobId}/logs`);
|
|
52
|
+
}
|
|
53
|
+
listArtifacts(repository, runId) {
|
|
54
|
+
const path = runId ? `/repos/${repository}/actions/runs/${runId}/artifacts` : `/repos/${repository}/actions/artifacts`;
|
|
55
|
+
return this.request(path);
|
|
56
|
+
}
|
|
57
|
+
dispatchWorkflow(repository, workflowId, ref, inputs = {}) {
|
|
58
|
+
return this.request(`/repos/${repository}/actions/workflows/${workflowId}/dispatches`, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
body: JSON.stringify({ ref, inputs }),
|
|
61
|
+
headers: { "Content-Type": "application/json" }
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
rerunWorkflow(repository, runId) {
|
|
65
|
+
return this.request(`/repos/${repository}/actions/runs/${runId}/rerun`, { method: "POST" });
|
|
66
|
+
}
|
|
67
|
+
rerunFailedJobs(repository, runId) {
|
|
68
|
+
return this.request(`/repos/${repository}/actions/runs/${runId}/rerun-failed-jobs`, { method: "POST" });
|
|
69
|
+
}
|
|
70
|
+
cancelWorkflow(repository, runId) {
|
|
71
|
+
return this.request(`/repos/${repository}/actions/runs/${runId}/cancel`, { method: "POST" });
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var GitHubActionsServiceDefinition = createServiceDefinition({
|
|
75
|
+
id: "kloks.backend.githubActions",
|
|
76
|
+
name: "GitHubActionsService",
|
|
77
|
+
version: "1.0.0",
|
|
78
|
+
operations: {
|
|
79
|
+
listWorkflowRuns: { id: "GitHubActionsService.listWorkflowRuns", name: "listWorkflowRuns", handler: async (i) => new GitHubActionsClient({ token: i.token }).listWorkflowRuns(i.repository, i.workflowId, i.branch) },
|
|
80
|
+
getWorkflowRun: { id: "GitHubActionsService.getWorkflowRun", name: "getWorkflowRun", handler: async (i) => new GitHubActionsClient({ token: i.token }).getWorkflowRun(i.repository, i.runId) },
|
|
81
|
+
getWorkflowJobs: { id: "GitHubActionsService.getWorkflowJobs", name: "getWorkflowJobs", handler: async (i) => new GitHubActionsClient({ token: i.token }).getWorkflowJobs(i.repository, i.runId) },
|
|
82
|
+
getJobLogs: { id: "GitHubActionsService.getJobLogs", name: "getJobLogs", handler: async (i) => new GitHubActionsClient({ token: i.token }).getJobLogs(i.repository, i.jobId) },
|
|
83
|
+
listArtifacts: { id: "GitHubActionsService.listArtifacts", name: "listArtifacts", handler: async (i) => new GitHubActionsClient({ token: i.token }).listArtifacts(i.repository, i.runId) },
|
|
84
|
+
dispatchWorkflow: { id: "GitHubActionsService.dispatchWorkflow", name: "dispatchWorkflow", handler: async (i) => new GitHubActionsClient({ token: i.token }).dispatchWorkflow(i.repository, i.workflowId, i.ref, i.inputs) },
|
|
85
|
+
rerunWorkflow: { id: "GitHubActionsService.rerunWorkflow", name: "rerunWorkflow", handler: async (i) => new GitHubActionsClient({ token: i.token }).rerunWorkflow(i.repository, i.runId) },
|
|
86
|
+
rerunFailedJobs: { id: "GitHubActionsService.rerunFailedJobs", name: "rerunFailedJobs", handler: async (i) => new GitHubActionsClient({ token: i.token }).rerunFailedJobs(i.repository, i.runId) },
|
|
87
|
+
cancelWorkflow: { id: "GitHubActionsService.cancelWorkflow", name: "cancelWorkflow", handler: async (i) => new GitHubActionsClient({ token: i.token }).cancelWorkflow(i.repository, i.runId) }
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
var GitHubActionsServiceFacade = {
|
|
91
|
+
id: GitHubActionsServiceDefinition.id,
|
|
92
|
+
name: GitHubActionsServiceDefinition.name,
|
|
93
|
+
version: GitHubActionsServiceDefinition.version,
|
|
94
|
+
runtime: "server",
|
|
95
|
+
deployment: "remote",
|
|
96
|
+
definition: GitHubActionsServiceDefinition,
|
|
97
|
+
createInstance: () => createService(GitHubActionsServiceDefinition),
|
|
98
|
+
execute: async (op, input) => {
|
|
99
|
+
const instance = createService(GitHubActionsServiceDefinition);
|
|
100
|
+
await instance.start();
|
|
101
|
+
return instance.call(op, input);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/development/developmentService.ts
|
|
106
|
+
function resolveDevelopmentCommand(task) {
|
|
107
|
+
const { command, args } = resolveWebContainerCommand(task);
|
|
108
|
+
return [command, args];
|
|
109
|
+
}
|
|
110
|
+
var DevelopmentServiceDefinition = createServiceDefinition({
|
|
111
|
+
id: "kloks.backend.development",
|
|
112
|
+
name: "DevelopmentService",
|
|
113
|
+
version: "1.1.0",
|
|
114
|
+
operations: {
|
|
115
|
+
plan: {
|
|
116
|
+
id: "DevelopmentService.plan",
|
|
117
|
+
name: "plan",
|
|
118
|
+
handler: async (input) => {
|
|
119
|
+
const [command, args] = resolveDevelopmentCommand(input.task);
|
|
120
|
+
return { task: input.task, command, args };
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
describeProviders: {
|
|
124
|
+
id: "DevelopmentService.describeProviders",
|
|
125
|
+
name: "describeProviders",
|
|
126
|
+
handler: async () => ({
|
|
127
|
+
providers: [
|
|
128
|
+
{ id: "webcontainer", capabilities: ["install", "lint", "test", "build", "validate", "check", "process-host"] },
|
|
129
|
+
{ id: "typescript-language-server", capabilities: ["lsp", "diagnostics", "completion", "hover", "definition", "references", "rename", "symbols"] },
|
|
130
|
+
{ id: "agent-harness", capabilities: ["deepseek", "openai", "google", "headless", "sdk", "acp"] },
|
|
131
|
+
{ id: "github-actions", capabilities: ["dispatch", "observe", "rerun", "cancel"] }
|
|
132
|
+
]
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
var DevelopmentRuntime = class {
|
|
138
|
+
constructor(webContainer = new WebContainerRuntime(), githubActions) {
|
|
139
|
+
this.webContainer = webContainer;
|
|
140
|
+
this.githubActions = githubActions;
|
|
141
|
+
}
|
|
142
|
+
webContainer;
|
|
143
|
+
githubActions;
|
|
144
|
+
async run(request) {
|
|
145
|
+
if (request.provider === "webcontainer") {
|
|
146
|
+
const result = await this.webContainer.run(request.task, request.cwd, request.env);
|
|
147
|
+
return { provider: request.provider, task: request.task, ok: result.exitCode === 0, exitCode: result.exitCode, output: result.output, command: result.command, durationMs: result.durationMs, diagnostics: result.diagnostics };
|
|
148
|
+
}
|
|
149
|
+
if (!this.githubActions || !request.repository || !request.workflowId || !request.ref) {
|
|
150
|
+
throw new Error("GitHub Actions execution requires repository, workflowId, ref, and an authenticated client");
|
|
151
|
+
}
|
|
152
|
+
await this.githubActions.dispatchWorkflow(request.repository, request.workflowId, request.ref, {
|
|
153
|
+
task: request.task,
|
|
154
|
+
...request.workflowInputs ?? {}
|
|
155
|
+
});
|
|
156
|
+
return { provider: request.provider, task: request.task, ok: true, output: "Workflow dispatched; observe its run for final status." };
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var DevelopmentServiceFacade = {
|
|
160
|
+
id: DevelopmentServiceDefinition.id,
|
|
161
|
+
name: DevelopmentServiceDefinition.name,
|
|
162
|
+
version: DevelopmentServiceDefinition.version,
|
|
163
|
+
runtime: "server",
|
|
164
|
+
deployment: "local",
|
|
165
|
+
definition: DevelopmentServiceDefinition,
|
|
166
|
+
createInstance: () => createService(DevelopmentServiceDefinition),
|
|
167
|
+
execute: async (op, input) => {
|
|
168
|
+
const instance = createService(DevelopmentServiceDefinition);
|
|
169
|
+
await instance.start();
|
|
170
|
+
return instance.call(op, input);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// src/development/codeDiagnosticsService.ts
|
|
175
|
+
var CodeDiagnosticsService = class {
|
|
176
|
+
constructor(runtime3 = new WebContainerRuntime()) {
|
|
177
|
+
this.runtime = runtime3;
|
|
178
|
+
}
|
|
179
|
+
runtime;
|
|
180
|
+
async diagnostics(input = {}) {
|
|
181
|
+
const args = ["exec", "tsc", "--noEmit", "--pretty", "false"];
|
|
182
|
+
if (input.file) args.push(input.file);
|
|
183
|
+
const result = await this.runtime.runCommand("pnpm", args, input.cwd);
|
|
184
|
+
return { ok: result.exitCode === 0, output: result.output, command: ["pnpm", ...args].join(" ") };
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
var codeDiagnosticsService = new CodeDiagnosticsService();
|
|
188
|
+
|
|
189
|
+
// src/development/typescriptLanguageServerService.ts
|
|
190
|
+
var TYPESCRIPT_LANGUAGE_SERVER_PACKAGE = "typescript-language-server";
|
|
191
|
+
var TYPESCRIPT_LANGUAGE_SERVER_VERSION = "6.0.2";
|
|
192
|
+
var PACKAGE = TYPESCRIPT_LANGUAGE_SERVER_PACKAGE;
|
|
193
|
+
var DEFAULT_VERSION = TYPESCRIPT_LANGUAGE_SERVER_VERSION;
|
|
194
|
+
var TypeScriptLanguageServerRuntime = class {
|
|
195
|
+
constructor(runtime3 = new WebContainerRuntime()) {
|
|
196
|
+
this.runtime = runtime3;
|
|
197
|
+
}
|
|
198
|
+
runtime;
|
|
199
|
+
process = null;
|
|
200
|
+
writer = null;
|
|
201
|
+
pending = /* @__PURE__ */ new Map();
|
|
202
|
+
buffer = "";
|
|
203
|
+
cwd = ".";
|
|
204
|
+
version = DEFAULT_VERSION;
|
|
205
|
+
async start(input = {}) {
|
|
206
|
+
if (this.process) return this.status();
|
|
207
|
+
this.cwd = input.cwd ?? ".";
|
|
208
|
+
this.version = input.version ?? DEFAULT_VERSION;
|
|
209
|
+
if (input.install !== false) {
|
|
210
|
+
await this.runtime.runCommand("pnpm", ["add", "-D", "typescript@7.0.2", PACKAGE + "@" + this.version], this.cwd);
|
|
211
|
+
}
|
|
212
|
+
this.process = await this.runtime.spawnCommand("pnpm", ["exec", PACKAGE, "--stdio"], this.cwd);
|
|
213
|
+
this.writer = this.process.input.getWriter();
|
|
214
|
+
void this.readOutput(this.process.output);
|
|
215
|
+
return this.status();
|
|
216
|
+
}
|
|
217
|
+
async request(input) {
|
|
218
|
+
await this.ensureRunning();
|
|
219
|
+
const promise = new Promise((resolve, reject) => {
|
|
220
|
+
this.pending.set(input.id, { resolve, reject });
|
|
221
|
+
});
|
|
222
|
+
await this.write(input);
|
|
223
|
+
return promise;
|
|
224
|
+
}
|
|
225
|
+
async notify(input) {
|
|
226
|
+
await this.ensureRunning();
|
|
227
|
+
await this.write(input);
|
|
228
|
+
return { sent: true };
|
|
229
|
+
}
|
|
230
|
+
async stop() {
|
|
231
|
+
const process = this.process;
|
|
232
|
+
this.process = null;
|
|
233
|
+
this.writer?.releaseLock();
|
|
234
|
+
this.writer = null;
|
|
235
|
+
for (const pending of this.pending.values()) pending.reject(new Error("Language server stopped"));
|
|
236
|
+
this.pending.clear();
|
|
237
|
+
if (process) await process.kill();
|
|
238
|
+
return { stopped: true };
|
|
239
|
+
}
|
|
240
|
+
status() {
|
|
241
|
+
return { running: Boolean(this.process), cwd: this.cwd, package: PACKAGE, version: this.version };
|
|
242
|
+
}
|
|
243
|
+
async ensureRunning() {
|
|
244
|
+
if (!this.process) await this.start({ cwd: this.cwd, install: false, version: this.version });
|
|
245
|
+
}
|
|
246
|
+
async write(message) {
|
|
247
|
+
if (!this.writer) throw new Error("Language server input is unavailable");
|
|
248
|
+
const body = JSON.stringify({ jsonrpc: "2.0", ...message });
|
|
249
|
+
const frame = "Content-Length: " + new TextEncoder().encode(body).byteLength + "\r\n\r\n" + body;
|
|
250
|
+
await this.writer.write(frame);
|
|
251
|
+
}
|
|
252
|
+
async readOutput(output) {
|
|
253
|
+
const reader = output.getReader();
|
|
254
|
+
try {
|
|
255
|
+
while (true) {
|
|
256
|
+
const next = await reader.read();
|
|
257
|
+
if (next.done) break;
|
|
258
|
+
this.buffer += next.value;
|
|
259
|
+
this.consumeFrames();
|
|
260
|
+
}
|
|
261
|
+
} catch (error) {
|
|
262
|
+
for (const pending of this.pending.values()) pending.reject(error instanceof Error ? error : new Error(String(error)));
|
|
263
|
+
this.pending.clear();
|
|
264
|
+
} finally {
|
|
265
|
+
reader.releaseLock();
|
|
266
|
+
this.process = null;
|
|
267
|
+
this.writer?.releaseLock();
|
|
268
|
+
this.writer = null;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
consumeFrames() {
|
|
272
|
+
while (true) {
|
|
273
|
+
const separator = this.buffer.indexOf("\r\n\r\n");
|
|
274
|
+
if (separator < 0) return;
|
|
275
|
+
const header = this.buffer.slice(0, separator);
|
|
276
|
+
const match = header.match(/Content-Length:\s*(\d+)/i);
|
|
277
|
+
if (!match) {
|
|
278
|
+
this.buffer = this.buffer.slice(separator + 4);
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
const length = Number(match[1]);
|
|
282
|
+
const start = separator + 4;
|
|
283
|
+
if (this.buffer.length - start < length) return;
|
|
284
|
+
const body = this.buffer.slice(start, start + length);
|
|
285
|
+
this.buffer = this.buffer.slice(start + length);
|
|
286
|
+
const response = JSON.parse(body);
|
|
287
|
+
if (response.id !== void 0 && response.id !== null) {
|
|
288
|
+
this.pending.get(response.id)?.resolve(response);
|
|
289
|
+
this.pending.delete(response.id);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
var runtime = new TypeScriptLanguageServerRuntime();
|
|
295
|
+
var TypeScriptLanguageServerServiceDefinition = createServiceDefinition({
|
|
296
|
+
id: "kloks.backend.typescriptLanguageServer",
|
|
297
|
+
name: "TypeScriptLanguageServerService",
|
|
298
|
+
version: "1.0.0",
|
|
299
|
+
operations: {
|
|
300
|
+
start: { id: "TypeScriptLanguageServerService.start", name: "start", handler: async (input) => runtime.start(input) },
|
|
301
|
+
request: { id: "TypeScriptLanguageServerService.request", name: "request", handler: async (input) => runtime.request(input) },
|
|
302
|
+
notify: { id: "TypeScriptLanguageServerService.notify", name: "notify", handler: async (input) => runtime.notify(input) },
|
|
303
|
+
stop: { id: "TypeScriptLanguageServerService.stop", name: "stop", handler: async () => runtime.stop() },
|
|
304
|
+
status: { id: "TypeScriptLanguageServerService.status", name: "status", handler: async () => runtime.status() }
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
var TypeScriptLanguageServerServiceFacade = {
|
|
308
|
+
id: TypeScriptLanguageServerServiceDefinition.id,
|
|
309
|
+
name: TypeScriptLanguageServerServiceDefinition.name,
|
|
310
|
+
version: TypeScriptLanguageServerServiceDefinition.version,
|
|
311
|
+
runtime: "client",
|
|
312
|
+
deployment: "local",
|
|
313
|
+
definition: TypeScriptLanguageServerServiceDefinition,
|
|
314
|
+
createInstance: () => createService(TypeScriptLanguageServerServiceDefinition),
|
|
315
|
+
execute: async (op, input) => {
|
|
316
|
+
const instance = createService(TypeScriptLanguageServerServiceDefinition);
|
|
317
|
+
await instance.start();
|
|
318
|
+
return instance.call(op, input);
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// src/development/agentHarnessService.ts
|
|
323
|
+
var PROVIDERS = [
|
|
324
|
+
{
|
|
325
|
+
id: "deepseek",
|
|
326
|
+
name: "DeepSeek Harness",
|
|
327
|
+
package: "@deepseek-ai/dsh",
|
|
328
|
+
capabilities: ["headless", "sdk", "acp", "web"],
|
|
329
|
+
implemented: true
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
id: "openai",
|
|
333
|
+
name: "OpenAI Agents SDK",
|
|
334
|
+
package: "@openai/agents",
|
|
335
|
+
capabilities: ["agents", "tools", "handoffs", "guardrails", "sessions", "tracing"],
|
|
336
|
+
implemented: false
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
id: "google",
|
|
340
|
+
name: "Google ADK",
|
|
341
|
+
package: "@google/adk",
|
|
342
|
+
capabilities: ["agents", "tools", "multi-agent", "evaluation", "deployment"],
|
|
343
|
+
implemented: false
|
|
344
|
+
}
|
|
345
|
+
];
|
|
346
|
+
var AgentHarnessRuntime = class {
|
|
347
|
+
constructor(runtime3 = new WebContainerRuntime()) {
|
|
348
|
+
this.runtime = runtime3;
|
|
349
|
+
}
|
|
350
|
+
runtime;
|
|
351
|
+
providers() {
|
|
352
|
+
return PROVIDERS.map((provider) => ({ ...provider, capabilities: [...provider.capabilities] }));
|
|
353
|
+
}
|
|
354
|
+
async run(input) {
|
|
355
|
+
if (input.provider !== "deepseek") {
|
|
356
|
+
throw new Error(
|
|
357
|
+
`Agent harness provider "${input.provider}" is registered but not yet executable; install and register its adapter before running it.`
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
const started = Date.now();
|
|
361
|
+
const profile = input.profile ?? "headless";
|
|
362
|
+
const command = "pnpm";
|
|
363
|
+
const args = ["exec", "dsh", "--profile", profile, input.prompt];
|
|
364
|
+
const result = await this.runtime.runCommand(command, args, input.cwd ?? ".", input.env);
|
|
365
|
+
return {
|
|
366
|
+
provider: input.provider,
|
|
367
|
+
ok: result.exitCode === 0,
|
|
368
|
+
exitCode: result.exitCode,
|
|
369
|
+
output: result.output,
|
|
370
|
+
durationMs: Date.now() - started,
|
|
371
|
+
command: [command, ...args].join(" ")
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
var runtime2 = new AgentHarnessRuntime();
|
|
376
|
+
var AgentHarnessServiceDefinition = createServiceDefinition({
|
|
377
|
+
id: "kloks.backend.agentHarness",
|
|
378
|
+
name: "AgentHarnessService",
|
|
379
|
+
version: "1.0.0",
|
|
380
|
+
operations: {
|
|
381
|
+
providers: {
|
|
382
|
+
id: "AgentHarnessService.providers",
|
|
383
|
+
name: "providers",
|
|
384
|
+
handler: async () => runtime2.providers()
|
|
385
|
+
},
|
|
386
|
+
run: {
|
|
387
|
+
id: "AgentHarnessService.run",
|
|
388
|
+
name: "run",
|
|
389
|
+
handler: async (input) => runtime2.run(input)
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
var AgentHarnessServiceFacade = {
|
|
394
|
+
id: AgentHarnessServiceDefinition.id,
|
|
395
|
+
name: AgentHarnessServiceDefinition.name,
|
|
396
|
+
version: AgentHarnessServiceDefinition.version,
|
|
397
|
+
runtime: "client",
|
|
398
|
+
deployment: "local",
|
|
399
|
+
definition: AgentHarnessServiceDefinition,
|
|
400
|
+
createInstance: () => createService(AgentHarnessServiceDefinition),
|
|
401
|
+
execute: async (op, input) => {
|
|
402
|
+
const instance = createService(AgentHarnessServiceDefinition);
|
|
403
|
+
await instance.start();
|
|
404
|
+
return instance.call(op, input);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
export {
|
|
409
|
+
GitHubActionsClient,
|
|
410
|
+
GitHubActionsServiceDefinition,
|
|
411
|
+
GitHubActionsServiceFacade,
|
|
412
|
+
resolveDevelopmentCommand,
|
|
413
|
+
DevelopmentServiceDefinition,
|
|
414
|
+
DevelopmentRuntime,
|
|
415
|
+
DevelopmentServiceFacade,
|
|
416
|
+
CodeDiagnosticsService,
|
|
417
|
+
codeDiagnosticsService,
|
|
418
|
+
TYPESCRIPT_LANGUAGE_SERVER_PACKAGE,
|
|
419
|
+
TYPESCRIPT_LANGUAGE_SERVER_VERSION,
|
|
420
|
+
TypeScriptLanguageServerServiceDefinition,
|
|
421
|
+
TypeScriptLanguageServerServiceFacade,
|
|
422
|
+
AgentHarnessRuntime,
|
|
423
|
+
AgentHarnessServiceDefinition,
|
|
424
|
+
AgentHarnessServiceFacade
|
|
425
|
+
};
|