@ultrst-armada/kloks 1.24.3 → 1.24.5

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.
@@ -13,10 +13,6 @@ export { AdaptedStorageConnection, AppAccountManifest, AppServiceDeclaration, CA
13
13
  export { CompositeBackend, EndpointGenerator, GeneratedEndpointSummary, LOCAL_STORAGE_GRAPHS_PREFIX, LocalService, NodeGraphPersistenceService, NodeGraphValidationResult, RemoteServiceProxy, SaveGraphOptions, UniversalAppEntity, UniversalGraphEdge, UniversalGraphNode, UniversalNodeGraphDocument, UniversalStorageConnection, WorkspaceGraphDocument, WorkspaceGraphSummary, createBackend, createCompositeService, createLocalService, createRemoteService, exportGraphAsJsonFile, nodeGraphPersistence, parseGraphJsonFile, validateGraphDocument, workspaceGraphService } from './services/index.js';
14
14
  import { AssetDataType as AssetDataType$1, AssetChannelType as AssetChannelType$1, GraphFolderInfo as GraphFolderInfo$1, GraphAssetItem as GraphAssetItem$1, SpaceNode, NodeConnection, DawProject } from '@ultrst-armada/kloks/state-graph';
15
15
  export { AuthServiceDefinition, AuthServiceFacade, ControlPlaneServiceDefinition, ControlPlaneServiceFacade, DatabaseServiceDefinition, DatabaseServiceFacade, GeminiServiceDefinition, GeminiServiceFacade, SrklServiceDefinition, SrklServiceFacade, StorageServiceDefinition, StorageServiceFacade, WorkspaceGraphServiceDefinition, WorkspaceGraphServiceFacade, WorkspaceServiceDefinition, WorkspaceServiceFacade, krnlAuthServiceDefinition, krnlAuthServiceFacade, krnlControlPlaneServiceDefinition, krnlControlPlaneServiceFacade, krnlDatabaseServiceDefinition, krnlDatabaseServiceFacade, krnlGeminiServiceDefinition, krnlGeminiServiceFacade, krnlSrklServiceDefinition, krnlSrklServiceFacade, krnlStorageServiceDefinition, krnlStorageServiceFacade, krnlWorkspaceGraphServiceDefinition, krnlWorkspaceGraphServiceFacade, krnlWorkspaceServiceDefinition, krnlWorkspaceServiceFacade } from './krnl-services.js';
16
- export { CodeValidationInput, CodeValidationResult, CodeValidationRuntime, CodeValidationServiceDefinition, CodeValidationServiceFacade, DevelopmentDiagnostic, DevelopmentProvider, DevelopmentRequest, DevelopmentResult, DevelopmentServiceContract, DevelopmentTask, ValidationDiagnostic, ValidationLayer, WebContainerCommand, WebContainerRunCommandInput, WebContainerRuntime, WebContainerServiceDefinition, WebContainerServiceFacade, captureDevelopmentProcess, parseDevelopmentDiagnostics, resolveWebContainerCommand } from './development/client.js';
17
- export { AgentHarnessProvider, AgentHarnessProviderInfo, AgentHarnessResult, AgentHarnessRunInput, AgentHarnessRuntime, AgentHarnessServiceContract, AgentHarnessServiceDefinition, AgentHarnessServiceFacade, CodeDiagnosticsInput, CodeDiagnosticsResult, CodeDiagnosticsService, DevelopmentRuntime, DevelopmentServiceDefinition, DevelopmentServiceFacade, GitHubActionsClient, GitHubActionsConfig, GitHubActionsServiceDefinition, GitHubActionsServiceFacade, TYPESCRIPT_LANGUAGE_SERVER_PACKAGE, TYPESCRIPT_LANGUAGE_SERVER_VERSION, TypeScriptLanguageServerNotificationInput, TypeScriptLanguageServerRequestInput, TypeScriptLanguageServerResponse, TypeScriptLanguageServerServiceDefinition, TypeScriptLanguageServerServiceFacade, TypeScriptLanguageServerStartInput, TypeScriptLanguageServerStatus, WorkflowRun, codeDiagnosticsService, resolveDevelopmentCommand } from './development/index.js';
18
- export { InspectionCheck, InspectionCheckResult, InspectionError, InspectionErrorKind, InspectionLog, InspectionViewport, PlaywrightInspectionRequest, PlaywrightInspectionResult } from './development/playwrightInspectionTypes.js';
19
- export { PlaywrightInspectionRuntime, PlaywrightInspectionServiceDefinition, PlaywrightInspectionServiceFacade } from './development/playwrightInspectionService.js';
20
16
  export { A as AIProviderStatus, a as ProviderCapabilities, P as ProviderId, b as ProviderMeta } from './types-Di4ZAQYA.js';
21
17
  export { AIProviderService, PROVIDERS_META, PROVIDER_COLORS, aiProviderService, getProviderMeta, listProviders } from './ai-provider/index.js';
22
18
  export { A as AIHttpRequest, a as AIHttpResponse, b as AITransportClient } from './AITransportClient-dToGr8nj.js';
@@ -101,41 +101,6 @@ import {
101
101
  getSystemDatabaseUrls,
102
102
  resolveSystemDatabaseClusterNodes
103
103
  } from "./chunk-RCCQ7IRM.js";
104
- import {
105
- AgentHarnessRuntime,
106
- AgentHarnessServiceDefinition,
107
- AgentHarnessServiceFacade,
108
- CodeDiagnosticsService,
109
- DevelopmentRuntime,
110
- DevelopmentServiceDefinition,
111
- DevelopmentServiceFacade,
112
- GitHubActionsClient,
113
- GitHubActionsServiceDefinition,
114
- GitHubActionsServiceFacade,
115
- TYPESCRIPT_LANGUAGE_SERVER_PACKAGE,
116
- TYPESCRIPT_LANGUAGE_SERVER_VERSION,
117
- TypeScriptLanguageServerServiceDefinition,
118
- TypeScriptLanguageServerServiceFacade,
119
- codeDiagnosticsService,
120
- resolveDevelopmentCommand
121
- } from "./chunk-7K552XGT.js";
122
- import {
123
- PlaywrightInspectionRuntime,
124
- PlaywrightInspectionServiceDefinition,
125
- PlaywrightInspectionServiceFacade
126
- } from "./chunk-2OPIDIIB.js";
127
- import "./chunk-YEGS4HTA.js";
128
- import {
129
- CodeValidationRuntime,
130
- CodeValidationServiceDefinition,
131
- CodeValidationServiceFacade,
132
- WebContainerRuntime,
133
- WebContainerServiceDefinition,
134
- WebContainerServiceFacade,
135
- captureDevelopmentProcess,
136
- parseDevelopmentDiagnostics,
137
- resolveWebContainerCommand
138
- } from "./chunk-AGI3VKCZ.js";
139
104
  import {
140
105
  AIInferenceServiceDefinition,
141
106
  AIInferenceServiceFacade,
@@ -4437,9 +4402,6 @@ export {
4437
4402
  AIToolServiceFacade,
4438
4403
  AITransportClient,
4439
4404
  AdminGuard,
4440
- AgentHarnessRuntime,
4441
- AgentHarnessServiceDefinition,
4442
- AgentHarnessServiceFacade,
4443
4405
  AuditLogger,
4444
4406
  AuthServiceDefinition,
4445
4407
  AuthServiceFacade,
@@ -4457,10 +4419,6 @@ export {
4457
4419
  CallbackRegistry,
4458
4420
  CanonicalAuthClient,
4459
4421
  CloudflareResourceFetcher,
4460
- CodeDiagnosticsService,
4461
- CodeValidationRuntime,
4462
- CodeValidationServiceDefinition,
4463
- CodeValidationServiceFacade,
4464
4422
  CompositeBackend,
4465
4423
  ConcurrencyConflictError,
4466
4424
  ConcurrencyManager,
@@ -4471,9 +4429,6 @@ export {
4471
4429
  DatabaseServiceDefinition,
4472
4430
  DatabaseServiceFacade,
4473
4431
  DeterministicEndpointExecutor,
4474
- DevelopmentRuntime,
4475
- DevelopmentServiceDefinition,
4476
- DevelopmentServiceFacade,
4477
4432
  EndpointGenerator,
4478
4433
  EndpointRefresher,
4479
4434
  EventBus,
@@ -4483,9 +4438,6 @@ export {
4483
4438
  GRAPHS_ROOT,
4484
4439
  GeminiServiceDefinition,
4485
4440
  GeminiServiceFacade,
4486
- GitHubActionsClient,
4487
- GitHubActionsServiceDefinition,
4488
- GitHubActionsServiceFacade,
4489
4441
  GoogleDriveAdapter,
4490
4442
  HTTPTransport,
4491
4443
  HealthCheckService,
@@ -4511,9 +4463,6 @@ export {
4511
4463
  PROVIDERS_META,
4512
4464
  PROVIDER_COLORS,
4513
4465
  PasswordHasher,
4514
- PlaywrightInspectionRuntime,
4515
- PlaywrightInspectionServiceDefinition,
4516
- PlaywrightInspectionServiceFacade,
4517
4466
  RateLimiter,
4518
4467
  RemoteExecutor,
4519
4468
  RemoteWorkspaceService,
@@ -4536,17 +4485,10 @@ export {
4536
4485
  StorageServiceFacade,
4537
4486
  SupabaseStorageAdapter,
4538
4487
  SyncEngine,
4539
- TYPESCRIPT_LANGUAGE_SERVER_PACKAGE,
4540
- TYPESCRIPT_LANGUAGE_SERVER_VERSION,
4541
4488
  ToolManagerService,
4542
- TypeScriptLanguageServerServiceDefinition,
4543
- TypeScriptLanguageServerServiceFacade,
4544
4489
  VercelResourceFetcher,
4545
4490
  WORKSPACE_ASSETS_ROOT,
4546
4491
  WORKSPACE_ROOT,
4547
- WebContainerRuntime,
4548
- WebContainerServiceDefinition,
4549
- WebContainerServiceFacade,
4550
4492
  WebSocketTransport,
4551
4493
  WorkingWorkspaceService,
4552
4494
  WorkspaceCloneSyncEngine,
@@ -4565,10 +4507,8 @@ export {
4565
4507
  b2UploadFile,
4566
4508
  buildProjectObservability,
4567
4509
  buildProjectsList,
4568
- captureDevelopmentProcess,
4569
4510
  classifyAndFormatError,
4570
4511
  cleanDbUrl,
4571
- codeDiagnosticsService,
4572
4512
  computeDeploymentFinalWeight,
4573
4513
  computeUsageWeightScore,
4574
4514
  configureStarterProjectTemplate,
@@ -4704,7 +4644,6 @@ export {
4704
4644
  modelHealthService,
4705
4645
  nodeGraphPersistence,
4706
4646
  normalizeBackblazeCredentials,
4707
- parseDevelopmentDiagnostics,
4708
4647
  parseErrorJson,
4709
4648
  parseGraphJsonFile,
4710
4649
  pauseCloudflarePagesProject,
@@ -4721,12 +4660,10 @@ export {
4721
4660
  renameAppInWorkspaceData,
4722
4661
  renameS3Folder,
4723
4662
  resolveBackblazeEndpoint,
4724
- resolveDevelopmentCommand,
4725
4663
  resolveDynamicRouteFromDb,
4726
4664
  resolveSystemDatabaseClusterNodes,
4727
4665
  resolveSystemDatabaseUrl,
4728
4666
  resolveUserFromToken,
4729
- resolveWebContainerCommand,
4730
4667
  resolveWorkspaceConnection,
4731
4668
  resolveWorkspaceDir,
4732
4669
  resumeCloudflarePagesProject,
@@ -110,7 +110,7 @@
110
110
  }
111
111
  },
112
112
  "scripts": {
113
- "build": "tsup src/index.ts src/krnl-services.ts src/krnl-ai-services.ts src/services/index.ts src/auth/index.ts src/storage/index.ts src/workspace/index.ts src/control-plane/index.ts src/api/index.ts src/connectivity/index.ts src/client/index.ts src/srkl/index.ts src/development/index.ts src/development/playwrightInspectionService.ts src/development/playwrightInspectionTypes.ts src/development/client.ts src/ai-provider/index.ts src/ai-inference/index.ts src/ai-models/index.ts src/ai-routing/index.ts src/ai-keys/index.ts src/ai-tools/index.ts --format esm --dts --clean --external @kloks/functions --external react --external @kloks/state-graph --external @neondatabase/serverless --external @supabase/supabase-js --external @aws-sdk/client-s3 --external @aws-sdk/lib-storage --external bcryptjs --external better-sqlite3 --external zod --external ws --external @webcontainer/api --external playwright",
113
+ "build": "tsup src/index.ts src/krnl-services.ts src/krnl-ai-services.ts src/services/index.ts src/auth/index.ts src/storage/index.ts src/workspace/index.ts src/control-plane/index.ts src/api/index.ts src/connectivity/index.ts src/client/index.ts src/srkl/index.ts src/development/index.ts src/development/playwrightInspectionService.ts src/development/playwrightInspectionTypes.ts src/ai-provider/index.ts src/ai-inference/index.ts src/ai-models/index.ts src/ai-routing/index.ts src/ai-keys/index.ts src/ai-tools/index.ts --format esm --dts --clean --external @kloks/functions --external react --external @kloks/state-graph --external @neondatabase/serverless --external @supabase/supabase-js --external @aws-sdk/client-s3 --external @aws-sdk/lib-storage --external bcryptjs --external better-sqlite3 --external zod --external ws --external @webcontainer/api --external playwright && tsup src/development/client.ts --format esm --dts --out-dir dist/development --splitting false --platform browser --external @ultrst-armada/krnl",
114
114
  "typecheck": "tsc --noEmit",
115
115
  "clean": "rm -rf dist"
116
116
  },
@@ -1696,7 +1696,6 @@ var SystemDbService = class {
1696
1696
  };
1697
1697
  listeners = /* @__PURE__ */ new Set();
1698
1698
  constructor() {
1699
- this.refreshStatus();
1700
1699
  }
1701
1700
  async refreshStatus() {
1702
1701
  try {
@@ -2755,12 +2754,18 @@ var SystemDbClientServiceDefinition = createServiceDefinition({
2755
2754
  getEnvStatus: {
2756
2755
  id: "SystemDbClientService.getEnvStatus",
2757
2756
  name: "getEnvStatus",
2758
- handler: async () => systemDbService.getEnvStatus()
2757
+ handler: async () => {
2758
+ await systemDbService.refreshStatus();
2759
+ return systemDbService.getEnvStatus();
2760
+ }
2759
2761
  },
2760
2762
  getTelemetry: {
2761
2763
  id: "SystemDbClientService.getTelemetry",
2762
2764
  name: "getTelemetry",
2763
- handler: async () => systemDbService.getTelemetry()
2765
+ handler: async () => {
2766
+ await systemDbService.refreshStatus();
2767
+ return systemDbService.getTelemetry();
2768
+ }
2764
2769
  }
2765
2770
  }
2766
2771
  });
@@ -1,425 +0,0 @@
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
- };