@schlenkr/ragents 0.1.8 → 0.1.9
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/apps/server/src/config-definition.ts +24 -2
- package/apps/server/src/config.ts +0 -6
- package/apps/server/src/host-api.json +3 -10
- package/apps/server/src/host-api.ts +6 -7
- package/apps/server/src/plugin-build/build.ts +28 -5
- package/apps/server/src/plugin-build/plugin-description.ts +1 -1
- package/apps/server/src/plugin-build/typecheck.ts +2 -2
- package/apps/server/src/plugin-support/language-server/plugin.ts +8 -7
- package/apps/server/src/plugin-support/language-server/tools.ts +7 -6
- package/apps/server/src/plugin-support/model-aliases.ts +55 -25
- package/apps/server/src/plugin-support/product-relay.ts +10 -2
- package/apps/server/src/plugin-support/workspace-sandbox-host.ts +18 -9
- package/apps/server/src/profile/bundle-manifest.ts +7 -3
- package/apps/server/src/profile/compose.ts +6 -0
- package/apps/server/src/profile/plugin-discovery.ts +6 -1
- package/apps/server/src/profile/provisioning.ts +6 -5
- package/apps/server/src/ragents/engine.ts +0 -1
- package/apps/server/src/ragents/host-services.ts +4 -0
- package/apps/server/src/ragents/session.ts +1 -1
- package/apps/server/src/server.ts +1 -0
- package/apps/server/tsconfig.json +2 -0
- package/apps/web/dist/help/guide-clients.html +14 -6
- package/apps/web/dist/help/guide-clients.md +14 -6
- package/apps/web/dist/help/guide-distributed.html +12 -4
- package/apps/web/dist/help/guide-distributed.md +12 -4
- package/apps/web/dist/help/guide-getting-started.html +12 -8
- package/apps/web/dist/help/guide-getting-started.md +12 -8
- package/apps/web/dist/help/guide-plugins.html +6 -2
- package/apps/web/dist/help/guide-plugins.md +6 -2
- package/apps/web/dist/help/guide-runtime.html +2 -1
- package/apps/web/dist/help/guide-runtime.md +2 -1
- package/apps/web/dist/help/index.html +3328 -1135
- package/apps/web/dist/host-web.json +3 -3
- package/bundles/ragents.activity/ragents-bundle.json +3 -3
- package/bundles/ragents.actor-programs/ragents-bundle.json +3 -3
- package/bundles/ragents.ask/ragents-bundle.json +4 -4
- package/bundles/ragents.ask/server/index.js +42 -11
- package/bundles/ragents.ask/server/index.js.map +3 -3
- package/bundles/ragents.ask/web/chunks/chunk-WFN4374U.js +2 -0
- package/bundles/ragents.ask/web/chunks/chunk-WFN4374U.js.map +7 -0
- package/bundles/ragents.ask/web/classes.json +1 -1
- package/bundles/ragents.ask/web/exports/ask-payload.js +1 -1
- package/bundles/ragents.ask/web/index.js +1 -1
- package/bundles/ragents.ask/web/index.js.map +3 -3
- package/bundles/ragents.browser/executor/index.mjs +357 -0
- package/bundles/ragents.browser/executor/index.mjs.map +7 -0
- package/bundles/ragents.browser/ragents-bundle.json +5 -8
- package/bundles/ragents.browser/server/chunks/{chunk-2GKLLCBE.js → chunk-CWLX4VA5.js} +1 -1
- package/bundles/ragents.browser/server/chunks/chunk-CWLX4VA5.js.map +7 -0
- package/bundles/ragents.browser/server/exports/server/contract.js +1 -1
- package/bundles/ragents.browser/server/index.js +20 -9
- package/bundles/ragents.browser/server/index.js.map +4 -4
- package/bundles/ragents.documents/ragents-bundle.json +3 -3
- package/bundles/ragents.lsp-fsharp/executor/index.mjs +68 -0
- package/bundles/ragents.lsp-fsharp/executor/index.mjs.map +7 -0
- package/bundles/ragents.lsp-fsharp/ragents-bundle.json +5 -9
- package/bundles/ragents.lsp-fsharp/server/index.js +21 -6
- package/bundles/ragents.lsp-fsharp/server/index.js.map +4 -4
- package/bundles/ragents.lsp-roslyn/executor/index.mjs +68 -0
- package/bundles/ragents.lsp-roslyn/executor/index.mjs.map +7 -0
- package/bundles/ragents.lsp-roslyn/ragents-bundle.json +6 -8
- package/bundles/ragents.lsp-roslyn/server/index.js +54 -15
- package/bundles/ragents.lsp-roslyn/server/index.js.map +4 -4
- package/bundles/ragents.lsp-typescript/executor/index.mjs +49 -0
- package/bundles/ragents.lsp-typescript/executor/index.mjs.map +7 -0
- package/bundles/ragents.lsp-typescript/ragents-bundle.json +5 -7
- package/bundles/ragents.lsp-typescript/server/index.js +22 -2
- package/bundles/ragents.lsp-typescript/server/index.js.map +3 -3
- package/bundles/ragents.model-relay/ragents-bundle.json +4 -4
- package/bundles/ragents.model-relay/server/index.js +3 -2
- package/bundles/ragents.model-relay/server/index.js.map +2 -2
- package/bundles/ragents.orchestration/ragents-bundle.json +3 -3
- package/bundles/ragents.overseer/ragents-bundle.json +3 -3
- package/bundles/ragents.processes/ragents-bundle.json +3 -3
- package/bundles/ragents.product/ragents-bundle.json +3 -3
- package/bundles/ragents.profile-distribution/ragents-bundle.json +4 -4
- package/bundles/ragents.profile-distribution/server/index.js +1 -1
- package/bundles/ragents.profile-distribution/server/index.js.map +2 -2
- package/bundles/ragents.reference/ragents-bundle.json +3 -3
- package/bundles/ragents.todo/ragents-bundle.json +3 -3
- package/bundles/ragents.transcript/ragents-bundle.json +3 -3
- package/bundles/ragents.watch/ragents-bundle.json +3 -3
- package/bundles/ragents.workspace/ragents-bundle.json +11 -5
- package/bundles/ragents.workspace/server/index.js +101 -28
- package/bundles/ragents.workspace/server/index.js.map +3 -3
- package/bundles/ragents.workspace/web/classes.json +1 -1
- package/bundles/ragents.workspace/web/index.js +1 -1
- package/bundles/ragents.workspace/web/index.js.map +3 -3
- package/package.json +2 -2
- package/packages/agent/dist/core/agent-settings.d.ts +1 -7
- package/packages/agent/dist/core/compaction/compaction.d.ts +17 -13
- package/packages/agent/dist/core/model-runtime.d.ts +5 -4
- package/packages/agent/dist/core/provider-composer.d.ts +2 -1
- package/packages/agent/dist/core/tools/bash.d.ts +9 -3
- package/packages/agent/dist/index.d.ts +1 -1
- package/packages/agent/src/core/agent-settings.ts +1 -4
- package/packages/agent/src/core/compaction/compaction.ts +68 -30
- package/packages/agent/src/core/model-runtime.ts +12 -5
- package/packages/agent/src/core/provider-composer.ts +5 -0
- package/packages/agent/src/core/tools/bash.ts +36 -30
- package/packages/agent/src/index.ts +3 -0
- package/packages/ai/dist/types.d.ts +11 -0
- package/packages/ai/src/types.ts +12 -0
- package/packages/ragents/src/domain/event-semantics.ts +3 -0
- package/packages/ragents/src/domain/event-validation.ts +15 -2
- package/packages/ragents/src/domain/events.ts +3 -0
- package/packages/ragents/src/domain/model.ts +2 -0
- package/packages/ragents/src/domain/projection.ts +1 -0
- package/packages/ragents/src/drivers/agent-runtime.ts +1 -1
- package/packages/ragents/src/drivers/agent-turn.ts +8 -6
- package/packages/ragents/src/runtime/decisions/inputs.ts +6 -2
- package/packages/ragents/src/runtime/journal-storage.ts +5 -4
- package/packages/workspace-executor/package.json +0 -1
- package/packages/workspace-executor/src/bash-launch.ts +56 -10
- package/packages/workspace-executor/src/context.ts +4 -0
- package/packages/workspace-executor/src/contributions.ts +150 -0
- package/packages/workspace-executor/src/executor.ts +1 -1
- package/packages/workspace-executor/src/index.ts +16 -19
- package/packages/workspace-executor/src/language-server/host.ts +3 -0
- package/packages/workspace-executor/src/language-server/module.ts +12 -2
- package/packages/workspace-executor/src/language-server/roots.ts +0 -5
- package/packages/workspace-executor/src/modules.ts +7 -6
- package/packages/workspace-executor/src/sandbox-tools.ts +3 -9
- package/packages/workspace-executor/src/shell-platform.ts +14 -3
- package/packages/workspace-executor/src/tools.ts +0 -3
- package/plugins/ragents.ask/ask-payload.ts +9 -0
- package/plugins/ragents.ask/server/ask-service.ts +53 -13
- package/plugins/ragents.ask/web/AskActionView.tsx +3 -2
- package/plugins/ragents.browser/executor/index.ts +5 -0
- package/{packages/workspace-executor/src/browser → plugins/ragents.browser/executor}/module.ts +25 -31
- package/{packages/workspace-executor/src/browser → plugins/ragents.browser/executor}/playwright.ts +9 -23
- package/plugins/ragents.browser/provision.ts +1 -1
- package/plugins/ragents.browser/server/browser.ts +3 -3
- package/plugins/ragents.browser/server/contract.ts +2 -2
- package/plugins/ragents.browser/server/index.ts +1 -1
- package/plugins/ragents.lsp-fsharp/executor.ts +80 -0
- package/plugins/ragents.lsp-fsharp/provision.ts +1 -1
- package/plugins/ragents.lsp-fsharp/server/index.ts +2 -2
- package/plugins/ragents.lsp-roslyn/executor.ts +64 -0
- package/plugins/ragents.lsp-roslyn/provision.ts +1 -1
- package/plugins/ragents.lsp-roslyn/server/index.ts +28 -5
- package/plugins/ragents.lsp-roslyn/server/solution-on-start.ts +18 -6
- package/plugins/ragents.lsp-typescript/executor.ts +50 -0
- package/plugins/ragents.lsp-typescript/server/index.ts +2 -2
- package/plugins/ragents.model-relay/server/config.ts +1 -1
- package/plugins/ragents.model-relay/server/relay.ts +4 -2
- package/plugins/ragents.profile-distribution/server/archive.ts +2 -1
- package/plugins/ragents.workspace/client/workspace-client.ts +111 -28
- package/plugins/ragents.workspace/contract.ts +33 -2
- package/plugins/ragents.workspace/server/binding.ts +10 -4
- package/plugins/ragents.workspace/server/clients.ts +56 -9
- package/plugins/ragents.workspace/server/config.ts +9 -0
- package/plugins/ragents.workspace/server/index.ts +13 -4
- package/plugins/ragents.workspace/server/runtime.ts +10 -0
- package/plugins/ragents.workspace/server/shell-platform.ts +6 -5
- package/plugins/ragents.workspace/web/WorkspaceBinding.tsx +1 -1
- package/ragents.config.core.ts +4 -1
- package/ragents.config.showcase.ts +4 -1
- package/scripts/agent/journal.ts +3 -1
- package/scripts/package/build-package.ts +3 -1
- package/scripts/provision/run-provision.ts +2 -2
- package/scripts/workspace-client/run-workspace-client.ts +7 -4
- package/apps/web/dist/help/screenshots/release-checklist-vscode.png +0 -0
- package/apps/web/dist/help/screenshots/release-checklist-web.png +0 -0
- package/bundles/ragents.ask/web/chunks/chunk-HGFDGTNC.js +0 -2
- package/bundles/ragents.ask/web/chunks/chunk-HGFDGTNC.js.map +0 -7
- package/bundles/ragents.browser/server/chunks/chunk-2GKLLCBE.js.map +0 -7
- package/packages/workspace-executor/src/language-server/adapters/fsharp.ts +0 -60
- package/packages/workspace-executor/src/language-server/adapters/index.ts +0 -7
- package/packages/workspace-executor/src/language-server/adapters/roslyn.ts +0 -56
- package/packages/workspace-executor/src/language-server/adapters/typescript.ts +0 -74
- package/packages/workspace-executor/src/language-server/solution.ts +0 -13
- /package/{packages/workspace-executor/src/browser → plugins/ragents.browser/executor}/contract.ts +0 -0
- /package/{packages/workspace-executor/src/browser → plugins/ragents.browser/executor}/pages.ts +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import type { LanguageServerDescription, WorkspaceExecutorContribution } from "@ragents/workspace-executor";
|
|
5
|
+
|
|
6
|
+
export const ROSLYN_SERVER_VARIABLE = "ROSLYN_LANGUAGE_SERVER";
|
|
7
|
+
export const ROSLYN_SERVER_FILE = "roslyn/Microsoft.CodeAnalysis.LanguageServer.dll";
|
|
8
|
+
|
|
9
|
+
const languages = { ".cs": "csharp" } as const;
|
|
10
|
+
|
|
11
|
+
export const roslynLanguageServer: LanguageServerDescription = {
|
|
12
|
+
id: "roslyn",
|
|
13
|
+
label: "Roslyn",
|
|
14
|
+
languages,
|
|
15
|
+
rootDescription: "the .sln file (or a single .csproj)",
|
|
16
|
+
solutionExtensions: [".sln", ".slnx"],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const dotnetCommand = (server: string, args: readonly string[]): { command: string; args: string[] } =>
|
|
20
|
+
server.toLowerCase().endsWith(".dll")
|
|
21
|
+
? { command: "dotnet", args: [server, ...args] }
|
|
22
|
+
: { command: server, args: [...args] };
|
|
23
|
+
|
|
24
|
+
const serverPath = (toolsDirectory: string): string => {
|
|
25
|
+
const configured = process.env[ROSLYN_SERVER_VARIABLE];
|
|
26
|
+
if (configured) return configured;
|
|
27
|
+
const provisioned = path.join(toolsDirectory, ...ROSLYN_SERVER_FILE.split("/"));
|
|
28
|
+
if (existsSync(provisioned)) return provisioned;
|
|
29
|
+
throw new Error("Microsoft.CodeAnalysis.LanguageServer gibt es auf diesem Rechner nicht: weder "
|
|
30
|
+
+ `${ROSLYN_SERVER_VARIABLE} gesetzt noch ${provisioned} vorhanden. Ein Arbeitsplatz holt ihn mit `
|
|
31
|
+
+ `pnpm provision --workspace, ein Server über pnpm provision <profil>; ${ROSLYN_SERVER_VARIABLE} übersteuert beides`);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const executor: WorkspaceExecutorContribution = (machine) => ({
|
|
35
|
+
languageServers: [{
|
|
36
|
+
...roslynLanguageServer,
|
|
37
|
+
resolveRoot: (workspaceRoot, root) => machine.resolveRootFile(workspaceRoot, root, [".sln", ".slnx", ".csproj"]),
|
|
38
|
+
rootDirectory: (root) => path.dirname(root),
|
|
39
|
+
launch: async (context, root) => ({
|
|
40
|
+
label: "Roslyn",
|
|
41
|
+
...dotnetCommand(serverPath(machine.toolsDirectory), [
|
|
42
|
+
"--stdio",
|
|
43
|
+
"--logLevel", "Warning",
|
|
44
|
+
"--extensionLogDirectory", path.join(context.logDirectory, "roslyn-logs"),
|
|
45
|
+
]),
|
|
46
|
+
cwd: path.dirname(root),
|
|
47
|
+
env: context.env,
|
|
48
|
+
uid: context.uid,
|
|
49
|
+
gid: context.gid,
|
|
50
|
+
rootUri: pathToFileURL(path.dirname(root)).href,
|
|
51
|
+
languages,
|
|
52
|
+
newFileSettleMs: 2_000,
|
|
53
|
+
}),
|
|
54
|
+
open: async (session, root, timeoutMs) => {
|
|
55
|
+
const uri = pathToFileURL(root).href;
|
|
56
|
+
const loaded = session.waitForNotification(timeoutMs, "Projekte geladen",
|
|
57
|
+
(method) => method === "workspace/projectInitializationComplete");
|
|
58
|
+
if (root.toLowerCase().endsWith(".csproj")) session.notify("project/open", { projects: [uri] });
|
|
59
|
+
else session.notify("solution/open", { solution: uri });
|
|
60
|
+
await loaded;
|
|
61
|
+
return `${path.basename(root)} geladen`;
|
|
62
|
+
},
|
|
63
|
+
}],
|
|
64
|
+
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { stat } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { ROSLYN_SERVER_FILE } from "@ragents/workspace-executor";
|
|
4
3
|
import {
|
|
5
4
|
DOTNET_INSTRUCTION,
|
|
6
5
|
downloadArchive,
|
|
@@ -14,6 +13,7 @@ import {
|
|
|
14
13
|
type PluginProvision,
|
|
15
14
|
type ProvisionState,
|
|
16
15
|
} from "@ragents/host/plugin-support/provision.js";
|
|
16
|
+
import { ROSLYN_SERVER_FILE } from "./executor.js";
|
|
17
17
|
|
|
18
18
|
export const ROSLYN_VERSION = "5.4.0-2.26179.14";
|
|
19
19
|
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from "node:path";
|
|
2
2
|
import { declaredEnvironment } from "@ragents/host/plugin-support/plugin-config.js";
|
|
3
3
|
import { createLanguageServerPlugin } from "@ragents/host/plugin-support/language-server/plugin.js";
|
|
4
4
|
import type { PluginModule } from "@ragents/host/plugin-support/plugin-module.js";
|
|
5
5
|
import { sandboxServicesToken } from "@ragents/host/plugin-support/workspace-sandbox-host.js";
|
|
6
6
|
import { runtimeProviderToken } from "@ragents/host/ragents/host-services.js";
|
|
7
7
|
import { askServiceToken } from "@ragents/plugins/ragents.ask/server/contract.js";
|
|
8
|
-
import {
|
|
8
|
+
import { roslynLanguageServer, ROSLYN_SERVER_VARIABLE } from "../executor.js";
|
|
9
|
+
import {
|
|
10
|
+
createSolutionOnStart,
|
|
11
|
+
SOLUTION_ON_START_VARIABLE,
|
|
12
|
+
SOLUTION_PREFERRED_VARIABLE,
|
|
13
|
+
type SolutionOnStart,
|
|
14
|
+
} from "./solution-on-start.js";
|
|
9
15
|
|
|
10
16
|
export const roslynConfigDescriptors = [
|
|
11
17
|
{ key: ROSLYN_SERVER_VARIABLE, source: "environment" },
|
|
12
18
|
{ key: SOLUTION_ON_START_VARIABLE, source: "environment" },
|
|
19
|
+
{ key: SOLUTION_PREFERRED_VARIABLE, source: "environment" },
|
|
13
20
|
] as const;
|
|
14
21
|
|
|
15
22
|
const PLUGIN_ID = "ragents.lsp-roslyn";
|
|
@@ -25,13 +32,26 @@ export const solutionOnStart = (): boolean => {
|
|
|
25
32
|
return mode === "on";
|
|
26
33
|
};
|
|
27
34
|
|
|
35
|
+
/** Ein Pfad relativ zur Wurzel des Arbeitsbereichs, wie ihn `roslyn_solutions` nennt; ohne Laden beim Start hätte er keine Wirkung. */
|
|
36
|
+
export const preferredSolution = (loadOnStart: boolean): string | undefined => {
|
|
37
|
+
const preferred = env.optional(SOLUTION_PREFERRED_VARIABLE);
|
|
38
|
+
if (preferred === undefined) return undefined;
|
|
39
|
+
if (!loadOnStart) {
|
|
40
|
+
throw new Error(`${SOLUTION_PREFERRED_VARIABLE} in der Sektion ragents.lsp-roslyn verlangt ${SOLUTION_ON_START_VARIABLE}: "on"`);
|
|
41
|
+
}
|
|
42
|
+
if (preferred === "" || preferred.includes("\\") || path.win32.isAbsolute(preferred)) {
|
|
43
|
+
throw new Error(`${SOLUTION_PREFERRED_VARIABLE} in der Sektion ragents.lsp-roslyn ist ein Pfad relativ zum Arbeitsbereich mit Schrägstrichen, nicht "${preferred}"`);
|
|
44
|
+
}
|
|
45
|
+
return preferred;
|
|
46
|
+
};
|
|
47
|
+
|
|
28
48
|
export const plugin: PluginModule = {
|
|
29
49
|
requires: ["ragents.ask"],
|
|
30
50
|
create: () => {
|
|
31
51
|
let startup: SolutionOnStart | undefined;
|
|
32
52
|
const languageServer = createLanguageServerPlugin({
|
|
33
53
|
id: PLUGIN_ID,
|
|
34
|
-
|
|
54
|
+
languageServer: roslynLanguageServer,
|
|
35
55
|
configDescriptors: roslynConfigDescriptors,
|
|
36
56
|
onOpened: (runId) => startup?.opened(runId),
|
|
37
57
|
});
|
|
@@ -39,10 +59,13 @@ export const plugin: PluginModule = {
|
|
|
39
59
|
manifest: languageServer.manifest,
|
|
40
60
|
register: (host) => {
|
|
41
61
|
languageServer.register(host);
|
|
42
|
-
|
|
62
|
+
const loadOnStart = solutionOnStart();
|
|
63
|
+
const preferred = preferredSolution(loadOnStart);
|
|
64
|
+
if (!loadOnStart) return;
|
|
43
65
|
startup = createSolutionOnStart({
|
|
44
66
|
pluginId: PLUGIN_ID,
|
|
45
|
-
adapterId:
|
|
67
|
+
adapterId: roslynLanguageServer.id,
|
|
68
|
+
preferred,
|
|
46
69
|
sandbox: () => host.service(sandboxServicesToken),
|
|
47
70
|
runtime: () => host.service(runtimeProviderToken)(),
|
|
48
71
|
ask: () => host.service(askServiceToken),
|
|
@@ -8,6 +8,7 @@ import type { SandboxServices } from "@ragents/host/plugin-support/workspace-san
|
|
|
8
8
|
import { DISMISSED_ANSWER, type AskService } from "@ragents/plugins/ragents.ask/server/contract.js";
|
|
9
9
|
|
|
10
10
|
export const SOLUTION_ON_START_VARIABLE = "ROSLYN_SOLUTION_ON_START";
|
|
11
|
+
export const SOLUTION_PREFERRED_VARIABLE = "ROSLYN_SOLUTION_PREFERRED";
|
|
11
12
|
export const NO_SOLUTION = "Keine laden";
|
|
12
13
|
export const SOLUTION_QUESTION = "Welche Solution soll Roslyn für die Diagnostik laden?";
|
|
13
14
|
|
|
@@ -21,11 +22,21 @@ export type SolutionAnswer =
|
|
|
21
22
|
| { kind: "open"; path: string }
|
|
22
23
|
| { kind: "forward" };
|
|
23
24
|
|
|
24
|
-
/**
|
|
25
|
-
|
|
25
|
+
/** Die Vorgabe passt auch in einem Unterordner, etwa wenn der Arbeitsbereich der Ordner über dem Checkout ist. */
|
|
26
|
+
const matchesPreferred = (solution: string, preferred: string): boolean => {
|
|
27
|
+
const path = solution.toLowerCase();
|
|
28
|
+
const expected = preferred.toLowerCase();
|
|
29
|
+
return path === expected || path.endsWith(`/${expected}`);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** Was jemand schon geöffnet hat oder gerade öffnet, bleibt ohne Frage und ohne zweites Laden; passt die Vorgabe, zählen nur die passenden Solutions. */
|
|
33
|
+
export const solutionStartStep = (listing: LanguageServerSolutions, preferred?: string): SolutionStartStep => {
|
|
26
34
|
if (listing.opened || listing.solutions.length === 0) return { kind: "none" };
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
const paths = listing.solutions.map((solution) => solution.path);
|
|
36
|
+
const matching = preferred === undefined ? [] : paths.filter((path) => matchesPreferred(path, preferred));
|
|
37
|
+
const candidates = matching.length > 0 ? matching : paths;
|
|
38
|
+
if (candidates.length === 1) return { kind: "open", path: candidates[0] };
|
|
39
|
+
return { kind: "ask", options: [...candidates, NO_SOLUTION] };
|
|
29
40
|
};
|
|
30
41
|
|
|
31
42
|
/** Eine frei formulierte Antwort bekommt der Koordinator, damit sie nicht verloren geht. */
|
|
@@ -38,6 +49,7 @@ export const solutionAnswer = (options: readonly string[], answer: string): Solu
|
|
|
38
49
|
export interface SolutionOnStartOptions {
|
|
39
50
|
pluginId: string;
|
|
40
51
|
adapterId: string;
|
|
52
|
+
preferred?: string;
|
|
41
53
|
sandbox: () => SandboxServices;
|
|
42
54
|
runtime: () => Orchestration;
|
|
43
55
|
ask: () => AskService;
|
|
@@ -45,7 +57,7 @@ export interface SolutionOnStartOptions {
|
|
|
45
57
|
|
|
46
58
|
const messageOf = (error: unknown): string => error instanceof Error ? error.message : String(error);
|
|
47
59
|
|
|
48
|
-
/** Lädt beim Start ohne Run-Script die einzige Solution oder fragt bei mehreren; der Merker im Journal lässt das je Run höchstens einmal zu. */
|
|
60
|
+
/** Lädt beim Start ohne Run-Script die Vorgabe oder die einzige Solution oder fragt bei mehreren; der Merker im Journal lässt das je Run höchstens einmal zu. */
|
|
49
61
|
export interface SolutionOnStart {
|
|
50
62
|
lifecycle: SessionLifecycleContribution;
|
|
51
63
|
/** Jemand hat eine Instanz geöffnet; eine noch offene Startfrage erledigt sich damit ohne Laden und ohne Input. */
|
|
@@ -78,7 +90,7 @@ export const createSolutionOnStart = (options: SolutionOnStartOptions): Solution
|
|
|
78
90
|
|
|
79
91
|
const begin = async (runId: string, ownerId: string, coordinatorId: string, signal: AbortSignal): Promise<{ rest: Promise<void> }> => {
|
|
80
92
|
const listing = await options.sandbox().execute(runId, languageServerSolutionsOperation(options.adapterId), null, { signal }) as LanguageServerSolutions;
|
|
81
|
-
const step = solutionStartStep(listing);
|
|
93
|
+
const step = solutionStartStep(listing, options.preferred);
|
|
82
94
|
if (step.kind === "none") return { rest: Promise.resolve() };
|
|
83
95
|
if (step.kind === "open") return { rest: load(runId, step.path, true, signal) };
|
|
84
96
|
const answer = options.ask().ask(
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { stat } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import type { LanguageServerDescription, WorkspaceExecutorContribution } from "@ragents/workspace-executor";
|
|
5
|
+
|
|
6
|
+
const languages = {
|
|
7
|
+
".ts": "typescript",
|
|
8
|
+
".tsx": "typescriptreact",
|
|
9
|
+
".mts": "typescript",
|
|
10
|
+
".cts": "typescript",
|
|
11
|
+
".js": "javascript",
|
|
12
|
+
".jsx": "javascriptreact",
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
export const typescriptLanguageServer: LanguageServerDescription = {
|
|
16
|
+
id: "typescript",
|
|
17
|
+
label: "TypeScript",
|
|
18
|
+
languages,
|
|
19
|
+
rootDescription: "the directory whose tsconfig.json projects should be served (e.g. src)",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const hasWorkspaceTypeScript = (root: string): Promise<boolean> =>
|
|
23
|
+
stat(path.join(root, "node_modules", "typescript", "lib", "tsserver.js")).then((info) => info.isFile(), () => false);
|
|
24
|
+
|
|
25
|
+
/** Sprachserver und Compiler liegen in den node_modules des Hosts dieser Maschine; ohne Host gibt es sie hier nicht. */
|
|
26
|
+
export const executor: WorkspaceExecutorContribution = (machine) => ({
|
|
27
|
+
languageServers: [{
|
|
28
|
+
...typescriptLanguageServer,
|
|
29
|
+
resolveRoot: machine.resolveRootDirectory,
|
|
30
|
+
rootDirectory: (root) => root,
|
|
31
|
+
launch: async (context, root) => ({
|
|
32
|
+
label: "TypeScript",
|
|
33
|
+
command: process.execPath,
|
|
34
|
+
args: [machine.hostPackageFile(context.hostRoot, "typescript-language-server/lib/cli.mjs"), "--stdio"],
|
|
35
|
+
cwd: root,
|
|
36
|
+
// Im Extension-Host ist process.execPath Electron; ohne diese Variable startet es die Anwendung statt des Skripts.
|
|
37
|
+
env: { ...context.env, ELECTRON_RUN_AS_NODE: "1" },
|
|
38
|
+
uid: context.uid,
|
|
39
|
+
gid: context.gid,
|
|
40
|
+
rootUri: pathToFileURL(root).href,
|
|
41
|
+
initializationOptions: await hasWorkspaceTypeScript(root)
|
|
42
|
+
? {}
|
|
43
|
+
: { tsserver: { path: path.dirname(machine.hostPackageFile(context.hostRoot, "typescript")) } },
|
|
44
|
+
languages,
|
|
45
|
+
publishesOnlyChangedDiagnostics: true,
|
|
46
|
+
}),
|
|
47
|
+
open: async (_session, root) =>
|
|
48
|
+
`TypeScript-Server auf ${path.basename(root)} bereit; Projekte werden je Datei aus der nächsten tsconfig.json geladen`,
|
|
49
|
+
}],
|
|
50
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { typescriptAdapter } from "@ragents/workspace-executor";
|
|
2
1
|
import { createLanguageServerPlugin } from "@ragents/host/plugin-support/language-server/plugin.js";
|
|
3
2
|
import type { PluginModule } from "@ragents/host/plugin-support/plugin-module.js";
|
|
3
|
+
import { typescriptLanguageServer } from "../executor.js";
|
|
4
4
|
|
|
5
5
|
export const plugin: PluginModule = {
|
|
6
|
-
create: () => createLanguageServerPlugin({ id: "ragents.lsp-typescript",
|
|
6
|
+
create: () => createLanguageServerPlugin({ id: "ragents.lsp-typescript", languageServer: typescriptLanguageServer }),
|
|
7
7
|
};
|
|
@@ -2,7 +2,7 @@ import { configuredModelAliases, type ModelAlias } from "@ragents/host/plugin-su
|
|
|
2
2
|
|
|
3
3
|
/** Das Relay bietet die Aliasse des Profils an (MODEL_ALIASES im Abschnitt host), dieselben wie für die eigenen Runs. */
|
|
4
4
|
export const relayAliases = (aliases: readonly ModelAlias[]): readonly ModelAlias[] => {
|
|
5
|
-
if (aliases.length === 0) throw new Error("ragents.model-relay
|
|
5
|
+
if (aliases.length === 0) throw new Error("ragents.model-relay needs MODEL_ALIASES in the host section, a list of { alias, model, thinking?, compaction }");
|
|
6
6
|
return aliases;
|
|
7
7
|
};
|
|
8
8
|
|
|
@@ -18,6 +18,7 @@ export interface ResolvedAlias {
|
|
|
18
18
|
readonly alias: string;
|
|
19
19
|
readonly upstream: ModelUpstream;
|
|
20
20
|
readonly model: ModelUpstream["models"][number];
|
|
21
|
+
readonly compaction: ModelAlias["compaction"];
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/** Jeder Alias muss auf einen konfigurierten Anbieter und ein Modell aus dessen Katalog zeigen. */
|
|
@@ -30,10 +31,10 @@ export const resolveAliases = (aliases: readonly ModelAlias[], upstreams: readon
|
|
|
30
31
|
}
|
|
31
32
|
const model = upstream.models.find((candidate) => candidate.id === entry.model);
|
|
32
33
|
if (!model) throw new Error(`MODEL_ALIASES: das Modell ${entry.model} hinter ${entry.alias} fehlt im Katalog von ${entry.upstream}`);
|
|
33
|
-
return { alias: entry.alias, upstream, model };
|
|
34
|
+
return { alias: entry.alias, upstream, model, compaction: entry.compaction };
|
|
34
35
|
});
|
|
35
36
|
|
|
36
|
-
/** Der Katalogeintrag nennt nur, was der Verbraucher für
|
|
37
|
+
/** Der Katalogeintrag nennt nur, was der Verbraucher für Draht und Kompaktierung braucht; Name, Anbieter und Kosten bleiben beim Server. */
|
|
37
38
|
export const catalogEntryOf = (resolved: ResolvedAlias) => ({
|
|
38
39
|
id: resolved.alias,
|
|
39
40
|
object: "model" as const,
|
|
@@ -44,6 +45,7 @@ export const catalogEntryOf = (resolved: ResolvedAlias) => ({
|
|
|
44
45
|
input: [...resolved.model.input],
|
|
45
46
|
contextWindow: resolved.model.contextWindow,
|
|
46
47
|
maxTokens: resolved.model.maxTokens,
|
|
48
|
+
compaction: resolved.compaction,
|
|
47
49
|
...(resolved.model.compat ? { compat: resolved.model.compat } : {}),
|
|
48
50
|
},
|
|
49
51
|
});
|
|
@@ -55,7 +55,8 @@ const checkSections = (source: string, raw: Record<string, unknown>, pluginIds:
|
|
|
55
55
|
if (isEnvironmentReference(entry) || isProvisionedReference(entry)) continue;
|
|
56
56
|
if (SECRET_KEY_PATTERN.test(key)) throw new Error(`${source}: ${section}.${key} ist ein Secret und muss als env("...") stehen`);
|
|
57
57
|
const valid = typeof entry === "string" || typeof entry === "number" || typeof entry === "boolean"
|
|
58
|
-
|| (Array.isArray(entry) && entry.every((item) => typeof item === "string"))
|
|
58
|
+
|| (Array.isArray(entry) && entry.every((item) => typeof item === "string"))
|
|
59
|
+
|| (Array.isArray(entry) && entry.every((item) => !!item && typeof item === "object" && !Array.isArray(item)));
|
|
59
60
|
if (!valid) throw new Error(`${source}: ${section}.${key} hat keinen gültigen Wert`);
|
|
60
61
|
if (typeof entry === "string" && /^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/.test(entry)) throw new Error(`${source}: ${section}.${key} verweist als Text auf die Umgebung; env("...") verwenden`);
|
|
61
62
|
}
|
|
@@ -2,20 +2,30 @@ import { realpath } from "node:fs/promises";
|
|
|
2
2
|
import { homedir, tmpdir } from "node:os";
|
|
3
3
|
import { basename, dirname, join, resolve } from "node:path";
|
|
4
4
|
import {
|
|
5
|
+
EXECUTOR_CONTRIBUTION_FILE,
|
|
5
6
|
WORKSPACE_EXECUTOR_VERSION,
|
|
6
7
|
containsWorkspacePath,
|
|
8
|
+
hostDataDirectory,
|
|
9
|
+
loadExecutorContribution,
|
|
10
|
+
pluginToolsDirectory,
|
|
11
|
+
prepareExecutorContribution,
|
|
12
|
+
ripgrepAvailable,
|
|
7
13
|
WorkspaceOperationError,
|
|
8
14
|
WorkspaceOperationExecutor,
|
|
9
15
|
workspaceDataDirectory,
|
|
10
16
|
workspaceExecutorModules,
|
|
11
17
|
workspaceProcessContext,
|
|
18
|
+
type ExecutorContributionStand,
|
|
19
|
+
type PreparedExecutorContribution,
|
|
12
20
|
type WorkspaceProcessContext,
|
|
13
21
|
} from "@ragents/workspace-executor";
|
|
14
22
|
import type { RpcClient } from "../../../apps/web/src/rpc/client";
|
|
15
23
|
import type { OperationInput } from "../../../packages/ragents/src/rpc/contract";
|
|
16
24
|
import type { RpcHandlerContext } from "../../../packages/ragents/src/rpc/peer";
|
|
25
|
+
import { RPC_ERROR_CODES, RpcError } from "../../../packages/ragents/src/rpc/protocol";
|
|
17
26
|
import { DomainError } from "../../../packages/ragents/src/runtime/domain-error";
|
|
18
27
|
import {
|
|
28
|
+
PLUGIN_ID_PATTERN,
|
|
19
29
|
WORKSPACE_CLIENT_STOP_OPERATION,
|
|
20
30
|
workspaceClientContracts,
|
|
21
31
|
workspaceContracts,
|
|
@@ -28,7 +38,8 @@ export type WorkspaceClientStatus =
|
|
|
28
38
|
| { kind: "registered" }
|
|
29
39
|
| { kind: "failed"; message: string };
|
|
30
40
|
|
|
31
|
-
|
|
41
|
+
/** Was der Arbeitsplatz über sich sagt; ob seine Bash rg findet, ermittelt er selbst bei jeder Anmeldung. */
|
|
42
|
+
export interface WorkspaceClientIdentity extends Omit<WorkspaceClientDescription, "ripgrep"> {
|
|
32
43
|
id: string;
|
|
33
44
|
}
|
|
34
45
|
|
|
@@ -41,10 +52,12 @@ export interface WorkspaceClientExecution {
|
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
export interface WorkspaceClientOptions {
|
|
44
|
-
/** Die Host-Wurzel dieses Rechners, aus der
|
|
55
|
+
/** Die Host-Wurzel dieses Rechners mit den Bundles, aus denen der Executor seine Beiträge lädt; sie kann erst später entstehen. */
|
|
45
56
|
hostRoot: () => string | undefined;
|
|
46
57
|
/** Die Bash dieses Rechners für das Werkzeug bash; unter Windows die mitgebrachte und Pflicht, sonst ohne Angabe die des Systems. */
|
|
47
58
|
bash?: string | undefined;
|
|
59
|
+
/** Das mitgebrachte rg, dessen Ordner die Bash vorn im PATH hat; ohne Angabe gilt eines im PATH dieses Rechners. */
|
|
60
|
+
rg?: string | undefined;
|
|
48
61
|
onExecuted?: (execution: WorkspaceClientExecution) => void;
|
|
49
62
|
}
|
|
50
63
|
|
|
@@ -93,9 +106,44 @@ const contextOf = (runs: ReadonlyMap<string, WorkspaceProcessContext>, runId: st
|
|
|
93
106
|
return Promise.resolve(context);
|
|
94
107
|
};
|
|
95
108
|
|
|
109
|
+
const sameContributions = (left: readonly ExecutorContributionStand[], right: readonly ExecutorContributionStand[]): boolean =>
|
|
110
|
+
left.length === right.length && left.every((entry) => right.some((other) => other.plugin === entry.plugin && other.stand === entry.stand));
|
|
111
|
+
|
|
112
|
+
/** Die Bundles eines Arbeitsplatzes sind die eingebauten seines Hosts; ein Plugin, das dort fehlt, kann er nicht ausführen. */
|
|
113
|
+
const contributionFileOf = (hostRoot: string, plugin: string): string => join(hostRoot, "bundles", plugin, EXECUTOR_CONTRIBUTION_FILE);
|
|
114
|
+
|
|
115
|
+
/** Lädt die Beiträge, die der Server verlangt, aus den Bundles des Hosts dieser Maschine; ein fehlendes Bundle oder ein anderer Stand ist ein Fehler mit Ursache. */
|
|
116
|
+
const loadedContributions = async (
|
|
117
|
+
hostRoot: string | undefined,
|
|
118
|
+
wanted: readonly ExecutorContributionStand[],
|
|
119
|
+
): Promise<readonly PreparedExecutorContribution[]> => {
|
|
120
|
+
if (wanted.length === 0) return [];
|
|
121
|
+
if (!hostRoot) {
|
|
122
|
+
throw new Error(`Der Server verlangt die Executor-Beiträge von ${wanted.map(({ plugin }) => plugin).join(", ")}; dieser Arbeitsplatz `
|
|
123
|
+
+ "kennt keinen Host, aus dessen Bundles er sie laden könnte. Er bekommt ihn mit der ersten Verbindung zu einem verteilenden "
|
|
124
|
+
+ "Server oder über die Einstellung ragents.hostPath");
|
|
125
|
+
}
|
|
126
|
+
return Promise.all(wanted.map(async ({ plugin, stand }) => {
|
|
127
|
+
if (!PLUGIN_ID_PATTERN.test(plugin)) throw new Error(`Der Server nennt ${plugin} als Plugin; das ist keine Kennung eines Plugins`);
|
|
128
|
+
const loaded = await loadExecutorContribution(plugin, contributionFileOf(hostRoot, plugin), stand).catch((cause: unknown) => {
|
|
129
|
+
throw new Error(`${messageOf(cause)}. Der Host dieses Arbeitsplatzes (${hostRoot}) muss dieselben Bundles tragen wie der Server: `
|
|
130
|
+
+ "die RAgents-Erweiterung beziehungsweise das Paket @schlenkr/ragents in der Fassung des Servers, im Checkout pnpm build:plugins");
|
|
131
|
+
});
|
|
132
|
+
return prepareExecutorContribution(loaded, pluginToolsDirectory(hostDataDirectory(), plugin));
|
|
133
|
+
}));
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/** Ein Executor aus den Beiträgen, die der Server bei der Anmeldung verlangt hat. */
|
|
137
|
+
interface BuiltExecutor {
|
|
138
|
+
readonly executor: WorkspaceOperationExecutor;
|
|
139
|
+
readonly contributions: readonly ExecutorContributionStand[];
|
|
140
|
+
}
|
|
141
|
+
|
|
96
142
|
/** Was eine Anmeldung auf diesem Rechner hält: ihren eigenen Executor, die Aufträge ihrer Runs und ihre Handler an der Nachrichtenschicht. */
|
|
97
143
|
interface Attachment {
|
|
98
|
-
|
|
144
|
+
/** Entsteht mit der Antwort des Servers, welche Beiträge er verlangt; verlangt er nach einer Neuverbindung andere, ersetzt ein neuer ihn. */
|
|
145
|
+
built: BuiltExecutor | undefined;
|
|
146
|
+
readonly runsDirectory: string;
|
|
99
147
|
readonly runs: Map<string, WorkspaceProcessContext>;
|
|
100
148
|
readonly release: () => void;
|
|
101
149
|
}
|
|
@@ -172,7 +220,7 @@ export class WorkspaceClient {
|
|
|
172
220
|
this.#set({ kind: "idle" });
|
|
173
221
|
const signingOff = Promise.allSettled([this.#signingOff, this.#announcing]).then(() => this.#signOff());
|
|
174
222
|
this.#signingOff = signingOff;
|
|
175
|
-
await Promise.all([signingOff, attachment?.executor.shutdown()]);
|
|
223
|
+
await Promise.all([signingOff, attachment?.built?.executor.shutdown()]);
|
|
176
224
|
}
|
|
177
225
|
|
|
178
226
|
/** Der Arbeitsplatz bindet immer sich selbst; wo der Server läuft, ändert daran nichts. */
|
|
@@ -183,19 +231,44 @@ export class WorkspaceClient {
|
|
|
183
231
|
/** Jede Anmeldung baut ihren eigenen Executor; einer, den eine Abmeldung beendet hat, wird nie wieder benutzt. */
|
|
184
232
|
#attach(): Attachment {
|
|
185
233
|
if (this.#attachment) return this.#attachment;
|
|
186
|
-
const runs = new Map<string, WorkspaceProcessContext>();
|
|
187
|
-
const runsDirectory = this.#identity.runsDirectory;
|
|
188
|
-
const executor = new WorkspaceOperationExecutor({
|
|
189
|
-
contextFor: (runId) => contextOf(runs, runId),
|
|
190
|
-
modules: workspaceExecutorModules({ runFolder: (runId) => runFolderOf(runsDirectory, runId) }),
|
|
191
|
-
});
|
|
192
234
|
const rpc = this.transport.rpc;
|
|
193
|
-
const releases = [
|
|
194
|
-
|
|
235
|
+
const releases: Array<() => void> = [];
|
|
236
|
+
const attachment: Attachment = {
|
|
237
|
+
built: undefined,
|
|
238
|
+
runsDirectory: this.#identity.runsDirectory,
|
|
239
|
+
runs: new Map(),
|
|
240
|
+
release: () => { for (const release of releases) release(); },
|
|
241
|
+
};
|
|
242
|
+
releases.push(
|
|
243
|
+
rpc.handle(workspaceClientContracts.execute, (input, context) => this.#execute(attachment, input, context)),
|
|
195
244
|
rpc.onConnected(() => void this.#announce()),
|
|
196
|
-
|
|
197
|
-
this.#attachment =
|
|
198
|
-
return
|
|
245
|
+
);
|
|
246
|
+
this.#attachment = attachment;
|
|
247
|
+
return attachment;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Behält den Executor, solange der Server dieselben Beiträge verlangt; sonst baut es einen neuen aus den Bundles dieses Rechners und beendet den alten. */
|
|
251
|
+
async #built(attachment: Attachment, wanted: readonly ExecutorContributionStand[]): Promise<BuiltExecutor> {
|
|
252
|
+
const current = attachment.built;
|
|
253
|
+
if (current && sameContributions(current.contributions, wanted)) return current;
|
|
254
|
+
const contributions = await loadedContributions(this.options.hostRoot(), wanted);
|
|
255
|
+
const built: BuiltExecutor = {
|
|
256
|
+
executor: new WorkspaceOperationExecutor({
|
|
257
|
+
contextFor: (runId) => contextOf(attachment.runs, runId),
|
|
258
|
+
modules: workspaceExecutorModules({
|
|
259
|
+
runFolder: (runId) => runFolderOf(attachment.runsDirectory, runId),
|
|
260
|
+
contributions: contributions.map((contribution) => contribution.parts),
|
|
261
|
+
}),
|
|
262
|
+
}),
|
|
263
|
+
contributions: contributions.map(({ plugin, stand }) => ({ plugin, stand })),
|
|
264
|
+
};
|
|
265
|
+
if (attachment !== this.#attachment) {
|
|
266
|
+
await built.executor.shutdown();
|
|
267
|
+
throw new Error("Der Arbeitsplatz hat sich inzwischen abgemeldet");
|
|
268
|
+
}
|
|
269
|
+
attachment.built = built;
|
|
270
|
+
await current?.executor.shutdown();
|
|
271
|
+
return built;
|
|
199
272
|
}
|
|
200
273
|
|
|
201
274
|
/** Wartet auf den Ereignisstrom; ohne ihn nimmt der Server die Anmeldung nicht an. */
|
|
@@ -219,10 +292,20 @@ export class WorkspaceClient {
|
|
|
219
292
|
return this.#announcing;
|
|
220
293
|
}
|
|
221
294
|
|
|
222
|
-
/**
|
|
295
|
+
/** Erst die Beiträge, die der Server verlangt, dann die Anmeldung mit dem Executor daraus; eine Antwort nach einer Abmeldung ändert den Zustand nicht mehr. */
|
|
223
296
|
async #send(): Promise<void> {
|
|
224
297
|
const attachment = this.#attachment;
|
|
298
|
+
if (!attachment) return;
|
|
225
299
|
try {
|
|
300
|
+
const wanted = await this.transport.rpc.call(workspaceContracts.clients.contributions, {
|
|
301
|
+
label: this.#identity.label,
|
|
302
|
+
executor: WORKSPACE_EXECUTOR_VERSION,
|
|
303
|
+
}, { timeoutMs: REGISTER_TIMEOUT_MS }).catch((cause: unknown) => {
|
|
304
|
+
if (!(cause instanceof RpcError) || cause.code !== RPC_ERROR_CODES.methodNotFound) throw cause;
|
|
305
|
+
throw new Error(`Der Server kennt ${workspaceContracts.clients.contributions.id} nicht; er ist älter als dieser Arbeitsplatz `
|
|
306
|
+
+ `mit dem Executor ${WORKSPACE_EXECUTOR_VERSION}. Den Server auf die Fassung des Arbeitsplatzes aktualisieren.`);
|
|
307
|
+
});
|
|
308
|
+
const { contributions } = await this.#built(attachment, wanted);
|
|
226
309
|
await this.transport.rpc.call(workspaceContracts.clients.register, {
|
|
227
310
|
id: this.#identity.id,
|
|
228
311
|
label: this.#identity.label,
|
|
@@ -230,7 +313,9 @@ export class WorkspaceClient {
|
|
|
230
313
|
platform: this.#identity.platform,
|
|
231
314
|
folders: [...this.#identity.folders],
|
|
232
315
|
runsDirectory: this.#identity.runsDirectory,
|
|
316
|
+
ripgrep: ripgrepAvailable(this.options.rg, process.env),
|
|
233
317
|
executor: WORKSPACE_EXECUTOR_VERSION,
|
|
318
|
+
contributions: contributions.map((contribution) => ({ ...contribution })),
|
|
234
319
|
}, { timeoutMs: REGISTER_TIMEOUT_MS });
|
|
235
320
|
if (attachment === this.#attachment) this.#set({ kind: "registered" });
|
|
236
321
|
} catch (cause) {
|
|
@@ -247,17 +332,14 @@ export class WorkspaceClient {
|
|
|
247
332
|
}
|
|
248
333
|
|
|
249
334
|
/** Der Entwickler arbeitet auf seinem Arbeitsplatz mit seinen eigenen Zugangsdaten und seiner ganzen Umgebung; HOME bleibt sein Home. */
|
|
250
|
-
async #execute(
|
|
251
|
-
|
|
252
|
-
runs: Map<string, WorkspaceProcessContext>,
|
|
253
|
-
input: ExecuteInput,
|
|
254
|
-
context: RpcHandlerContext,
|
|
255
|
-
): Promise<{ value: unknown }> {
|
|
256
|
-
if (input.operation === WORKSPACE_CLIENT_STOP_OPERATION) return this.#stop(executor, runs, input.runId);
|
|
335
|
+
async #execute(attachment: Attachment, input: ExecuteInput, context: RpcHandlerContext): Promise<{ value: unknown }> {
|
|
336
|
+
if (input.operation === WORKSPACE_CLIENT_STOP_OPERATION) return this.#stop(attachment, input.runId);
|
|
257
337
|
const cwd = await this.#inside(input.cwd, input.runId);
|
|
258
338
|
const root = await realPathOf(cwd);
|
|
259
|
-
if (
|
|
260
|
-
|
|
339
|
+
if (attachment !== this.#attachment) throw new Error("Der Arbeitsplatz hat sich inzwischen abgemeldet");
|
|
340
|
+
const executor = attachment.built?.executor;
|
|
341
|
+
if (!executor) throw new Error("Der Arbeitsplatz ist beim Server noch nicht angemeldet");
|
|
342
|
+
attachment.runs.set(input.runId, workspaceProcessContext({
|
|
261
343
|
runId: input.runId,
|
|
262
344
|
cwd,
|
|
263
345
|
root,
|
|
@@ -267,6 +349,7 @@ export class WorkspaceClient {
|
|
|
267
349
|
additions: input.env,
|
|
268
350
|
baseEnvironment: "inherited",
|
|
269
351
|
...(this.options.bash === undefined ? {} : { bash: this.options.bash }),
|
|
352
|
+
...(this.options.rg === undefined ? {} : { rg: this.options.rg }),
|
|
270
353
|
}));
|
|
271
354
|
const startedAt = Date.now();
|
|
272
355
|
let failure: string | undefined;
|
|
@@ -293,11 +376,11 @@ export class WorkspaceClient {
|
|
|
293
376
|
}
|
|
294
377
|
|
|
295
378
|
/** Der Stopp braucht keinen Ordner: er gibt frei, was der Run hält, auch wenn sein Ordner nicht mehr angeboten wird. */
|
|
296
|
-
async #stop(
|
|
379
|
+
async #stop(attachment: Attachment, runId: string): Promise<{ value: null }> {
|
|
297
380
|
try {
|
|
298
|
-
await executor.stopRun(runId);
|
|
381
|
+
await attachment.built?.executor.stopRun(runId);
|
|
299
382
|
} finally {
|
|
300
|
-
runs.delete(runId);
|
|
383
|
+
attachment.runs.delete(runId);
|
|
301
384
|
}
|
|
302
385
|
return { value: null };
|
|
303
386
|
}
|
|
@@ -66,6 +66,8 @@ export interface WorkspaceClientDescription {
|
|
|
66
66
|
folders: string[];
|
|
67
67
|
/** Wo der Arbeitsplatz die neuen Ordner je Run anlegt, je Run ein Unterordner mit dessen Kennung. */
|
|
68
68
|
runsDirectory: string;
|
|
69
|
+
/** Ob die Bash des Arbeitsplatzes rg findet; der Prompt richtet die Suche danach. */
|
|
70
|
+
ripgrep: boolean;
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
export interface WorkspaceClientInfo extends WorkspaceClientDescription {
|
|
@@ -95,12 +97,21 @@ const clientId = Type.String({ pattern: "^[A-Za-z0-9_-]{8,64}$", description: "S
|
|
|
95
97
|
|
|
96
98
|
const executorVersion = Type.String({ minLength: 1, maxLength: 64, description: "Stand des Executors, den der Arbeitsplatz mitbringt" });
|
|
97
99
|
|
|
100
|
+
/** Die Kennung eines Plugins; ein Arbeitsplatz sucht dessen Bundle unter genau diesem Namen, ein Pfad kann darin nicht stecken. */
|
|
101
|
+
export const PLUGIN_ID_PATTERN = /^[a-z0-9]+(?:[.-][a-z0-9]+)*$/;
|
|
102
|
+
|
|
103
|
+
const executorContributions = Type.Array(Type.Object({
|
|
104
|
+
plugin: Type.String({ pattern: PLUGIN_ID_PATTERN.source, maxLength: 128, description: "Kennung des Plugins" }),
|
|
105
|
+
stand: Type.String({ pattern: "^[0-9a-f]{64}$", description: "SHA-256 der Datei des Beitrags" }),
|
|
106
|
+
}, { additionalProperties: false }), { maxItems: 64, description: "Die Beiträge der Plugins zum Executor, in der Reihenfolge der Pluginliste des Servers" });
|
|
107
|
+
|
|
98
108
|
const clientDescription = {
|
|
99
109
|
label: Type.String({ minLength: 1, maxLength: 120 }),
|
|
100
110
|
hostname: Type.String({ minLength: 1 }),
|
|
101
111
|
platform: Type.String({ minLength: 1 }),
|
|
102
112
|
folders: Type.Array(Type.String({ minLength: 1 }), { maxItems: 32 }),
|
|
103
113
|
runsDirectory: Type.String({ minLength: 1, description: "Absoluter Ordner, unter dem der Arbeitsplatz die neuen Ordner je Run anlegt" }),
|
|
114
|
+
ripgrep: Type.Boolean({ description: "Ob die Bash des Arbeitsplatzes rg findet" }),
|
|
104
115
|
};
|
|
105
116
|
|
|
106
117
|
export const clientInfoSchema = Type.Object({
|
|
@@ -108,6 +119,19 @@ export const clientInfoSchema = Type.Object({
|
|
|
108
119
|
...clientDescription,
|
|
109
120
|
}, { additionalProperties: false });
|
|
110
121
|
|
|
122
|
+
/** Die Anmeldung, wie ein Arbeitsplatz mit dem Executor des Servers sie sendet. */
|
|
123
|
+
export const clientRegistrationSchema = Type.Object({
|
|
124
|
+
id: clientId,
|
|
125
|
+
...clientDescription,
|
|
126
|
+
executor: executorVersion,
|
|
127
|
+
contributions: executorContributions,
|
|
128
|
+
}, { additionalProperties: false });
|
|
129
|
+
|
|
130
|
+
/** Ein Arbeitsplatz mit einem anderen Executor kennt die Form dieses Stands nicht; der Server lehnt ihn an seinem Stand ab, nicht an der Form. */
|
|
131
|
+
const otherExecutorRegistration = Type.Object({ label: clientDescription.label, executor: executorVersion }, {
|
|
132
|
+
description: "Anmeldung mit einem anderen Executor-Stand in beliebiger Form; der Server lehnt sie mit workspace-executor-version ab",
|
|
133
|
+
});
|
|
134
|
+
|
|
111
135
|
const absolutePath = Type.String({ minLength: 1, description: "Absoluter Pfad im gebundenen Ordner" });
|
|
112
136
|
|
|
113
137
|
/** Keine Operation eines Moduls: gibt frei, was der Executor des Arbeitsplatzes für den Run hält. */
|
|
@@ -172,11 +196,18 @@ export const workspaceContracts = {
|
|
|
172
196
|
input: Type.Object({}, { additionalProperties: false }),
|
|
173
197
|
result: Type.Array(clientInfoSchema),
|
|
174
198
|
}),
|
|
199
|
+
contributions: defineOperation({
|
|
200
|
+
id: "ragents.workspace.clients.contributions",
|
|
201
|
+
description: "Die Beiträge der Plugins zum Executor, die ein Arbeitsplatz vor der Anmeldung lädt und mit ihr zurückmeldet. Ein Arbeitsplatz mit anderem Executor-Stand scheitert an seinem Stand; weitere Felder zählen nicht.",
|
|
202
|
+
rights: ["runs.write"],
|
|
203
|
+
input: Type.Object({ label: clientDescription.label, executor: executorVersion }),
|
|
204
|
+
result: executorContributions,
|
|
205
|
+
}),
|
|
175
206
|
register: defineOperation({
|
|
176
207
|
id: "ragents.workspace.clients.register",
|
|
177
|
-
description: "Einen Arbeitsplatz anmelden oder seine Ordner erneuern; die Verbindung dieser Anfrage wird sein Rückweg und braucht einen Ereignisstrom.",
|
|
208
|
+
description: "Einen Arbeitsplatz anmelden oder seine Ordner erneuern; die Verbindung dieser Anfrage wird sein Rückweg und braucht einen Ereignisstrom. Ein Arbeitsplatz mit anderem Executor-Stand scheitert an seinem Stand, bevor die übrige Form zählt.",
|
|
178
209
|
rights: ["runs.write"],
|
|
179
|
-
input: Type.
|
|
210
|
+
input: Type.Union([clientRegistrationSchema, otherExecutorRegistration]),
|
|
180
211
|
result: clientInfoSchema,
|
|
181
212
|
}),
|
|
182
213
|
unregister: defineOperation({
|