@ultrst-armada/kloks 1.24.11 → 1.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/package.json +5 -4
  2. package/packages/audio-midi/dist/index.js +16 -16
  3. package/packages/backend/dist/chunk-CA5HVC4X.js +155 -0
  4. package/packages/backend/dist/{chunk-UC25J7E4.js → chunk-COA3ABWL.js} +1 -1
  5. package/packages/backend/dist/chunk-GKQ42CYW.js +47 -0
  6. package/packages/backend/dist/{chunk-XHADDA75.js → chunk-RIOYKF3X.js} +18 -10
  7. package/packages/backend/dist/development/index.d.ts +4 -113
  8. package/packages/backend/dist/development/index.js +31 -204
  9. package/packages/backend/dist/development/webContainerRuntime.d.ts +2 -0
  10. package/packages/backend/dist/development/webContainerRuntime.js +12 -0
  11. package/packages/backend/dist/development/webContainerService.d.ts +17 -0
  12. package/packages/backend/dist/development/webContainerService.js +19 -0
  13. package/packages/backend/dist/index.d.ts +17 -1
  14. package/packages/backend/dist/index.js +62 -2
  15. package/packages/backend/dist/krnl-services.js +2 -2
  16. package/packages/backend/dist/srkl/index.d.ts +0 -5
  17. package/packages/backend/dist/srkl/index.js +1 -1
  18. package/packages/backend/dist/webContainerRuntime-BnHB2bNz.d.ts +103 -0
  19. package/packages/backend/package.json +7 -2
  20. package/packages/client/dist/auth.d.ts +13 -0
  21. package/packages/client/dist/index.d.ts +1 -0
  22. package/packages/client/package.json +1 -1
  23. package/packages/functions/dist/index.js +16 -16
  24. package/packages/services/dist/index.d.ts +70 -1
  25. package/packages/services/dist/index.js +130 -16
  26. package/packages/services/kloks.manifest.json +28 -0
  27. package/packages/state-graph/dist/index.js +30 -30
  28. package/.krusbl-release-attestation.json +0 -8
@@ -1,4 +1,14 @@
1
1
  import "../chunk-YEGS4HTA.js";
2
+ import {
3
+ WebContainerServiceDefinition,
4
+ WebContainerServiceFacade
5
+ } from "../chunk-GKQ42CYW.js";
6
+ import {
7
+ WebContainerRuntime,
8
+ captureDevelopmentProcess,
9
+ parseDevelopmentDiagnostics,
10
+ resolveWebContainerCommand
11
+ } from "../chunk-CA5HVC4X.js";
2
12
  import {
3
13
  PlaywrightInspectionRuntime,
4
14
  PlaywrightInspectionServiceDefinition,
@@ -104,189 +114,6 @@ var GitHubActionsServiceFacade = {
104
114
  }
105
115
  };
106
116
 
107
- // src/development/webContainerRuntime.ts
108
- var COMMANDS = {
109
- install: { command: "pnpm", args: ["install", "--frozen-lockfile"] },
110
- lint: { command: "pnpm", args: ["lint"] },
111
- test: { command: "pnpm", args: ["test"] },
112
- build: { command: "pnpm", args: ["build"] },
113
- validate: { command: "pnpm", args: ["validate"] },
114
- check: { command: "pnpm", args: ["lint"] }
115
- };
116
- function resolveWebContainerCommand(task) {
117
- const command = COMMANDS[task];
118
- return { command: command.command, args: [...command.args] };
119
- }
120
- function parseDevelopmentDiagnostics(output, exitCode = 0) {
121
- const diagnostics = [];
122
- const seen = /* @__PURE__ */ new Set();
123
- const add = (diagnostic) => {
124
- const key = [diagnostic.source, diagnostic.code, diagnostic.file, diagnostic.line, diagnostic.message].join("|");
125
- if (!seen.has(key)) {
126
- seen.add(key);
127
- diagnostics.push(diagnostic);
128
- }
129
- };
130
- for (const line of output.split(/\r?\n/)) {
131
- const typescript = line.match(/^(.+?)\((\d+),(\d+)\):\s*(error|warning)\s+(TS\d+):\s*(.+)$/);
132
- if (typescript) {
133
- add({ source: "typescript", severity: typescript[4], file: typescript[1], line: Number(typescript[2]), column: Number(typescript[3]), code: typescript[5], message: typescript[6] });
134
- continue;
135
- }
136
- const eslint = line.match(/^(.+?):(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+([^\s]+)$/);
137
- if (eslint) {
138
- add({ source: "eslint", severity: eslint[4], file: eslint[1], line: Number(eslint[2]), column: Number(eslint[3]), code: eslint[6], message: eslint[5] });
139
- continue;
140
- }
141
- const bundler = line.match(/(?:✘|×|ERROR|error:|Error:)\s*(.+)$/);
142
- if (bundler) add({ source: "bundler", severity: "error", message: bundler[1].trim() });
143
- if (/\bWARN(?:ING)?\b/i.test(line)) add({ source: "package-manager", severity: "warning", message: line.trim() });
144
- }
145
- if (exitCode !== 0 && diagnostics.every((item) => item.severity !== "error")) {
146
- add({ source: "unknown", severity: "error", message: "Command failed with exit code " + exitCode + "; inspect captured output for details." });
147
- }
148
- return diagnostics;
149
- }
150
- function captureDevelopmentProcess(process) {
151
- const [consumerOutput, diagnosticOutput] = process.output.tee();
152
- const logs = (async () => {
153
- const reader = diagnosticOutput.getReader();
154
- let output = "";
155
- try {
156
- while (true) {
157
- const next = await reader.read();
158
- if (next.done) break;
159
- output += next.value;
160
- }
161
- } finally {
162
- reader.releaseLock();
163
- }
164
- const exitCode = await process.exit;
165
- return { output, exitCode, diagnostics: parseDevelopmentDiagnostics(output, exitCode) };
166
- })();
167
- return { ...process, output: consumerOutput, logs };
168
- }
169
- var runQueue = Promise.resolve();
170
- var sharedContainer = null;
171
- var sharedContainerPromise = null;
172
- var WebContainerRuntime = class {
173
- async boot() {
174
- if (typeof window !== "undefined" && !window.crossOriginIsolated) {
175
- throw new Error("WebContainer requires a cross-origin-isolated page. Ensure COOP=same-origin and COEP=require-corp are served.");
176
- }
177
- if (sharedContainer) return sharedContainer;
178
- if (!sharedContainerPromise) {
179
- sharedContainerPromise = import("@webcontainer/api").then(async (module) => {
180
- const container = await module.WebContainer.boot({ coep: "require-corp", workdirName: "kloks-development" });
181
- sharedContainer = container;
182
- return container;
183
- }).catch((error) => {
184
- sharedContainerPromise = null;
185
- throw error;
186
- });
187
- }
188
- return sharedContainerPromise;
189
- }
190
- async mount(files, mountPoint = "/", sourceSha) {
191
- const container = await this.boot();
192
- await container.mount(files, mountPoint === "/" ? void 0 : { mountPoint });
193
- return { mounted: true, mountPoint, sourceSha };
194
- }
195
- async runProcess(command, args, cwd, env, sourceSha) {
196
- const container = await this.boot();
197
- const process = await container.spawn(command, args, { cwd, env });
198
- const started = Date.now();
199
- let output = "";
200
- const reader = process.output.getReader();
201
- try {
202
- while (true) {
203
- const next = await reader.read();
204
- if (next.done) break;
205
- output += next.value;
206
- }
207
- } finally {
208
- reader.releaseLock();
209
- }
210
- const exitCode = await process.exit;
211
- return {
212
- exitCode,
213
- output,
214
- command: [command, ...args].join(" "),
215
- durationMs: Date.now() - started,
216
- diagnostics: parseDevelopmentDiagnostics(output, exitCode),
217
- sourceSha
218
- };
219
- }
220
- async run(task, cwd, env, sourceSha) {
221
- const spec = resolveWebContainerCommand(task);
222
- return this.runCommand(spec.command, spec.args, cwd, env, sourceSha);
223
- }
224
- async runCommand(command, args = [], cwd, env, sourceSha) {
225
- const previous = runQueue;
226
- let release;
227
- runQueue = new Promise((resolve) => {
228
- release = resolve;
229
- });
230
- await previous;
231
- try {
232
- return await this.runProcess(command, args, cwd, env, sourceSha);
233
- } finally {
234
- release();
235
- }
236
- }
237
- async spawnCommand(command, args = [], cwd, env, sourceSha) {
238
- const container = await this.boot();
239
- const process = await container.spawn(command, args, { cwd, env });
240
- return { processId: globalThis.crypto.randomUUID(), sourceSha, command: [command, ...args].join(" "), startedAt: (/* @__PURE__ */ new Date()).toISOString(), process: captureDevelopmentProcess(process) };
241
- }
242
- async teardown(mountPoint) {
243
- const container = sharedContainer;
244
- if (!container) return { tornDown: true, mountPoint };
245
- if (mountPoint && mountPoint !== "/") {
246
- await container.fs.rm(mountPoint, { recursive: true, force: true });
247
- return { tornDown: true, mountPoint };
248
- }
249
- sharedContainer = null;
250
- sharedContainerPromise = null;
251
- await container.teardown();
252
- return { tornDown: true, mountPoint: "/" };
253
- }
254
- };
255
-
256
- // src/development/webContainerService.ts
257
- var runtime = new WebContainerRuntime();
258
- var WebContainerServiceDefinition = createServiceDefinition({
259
- id: "kloks.backend.webContainer",
260
- name: "WebContainerService",
261
- version: "1.3.0",
262
- operations: {
263
- boot: { id: "WebContainerService.boot", name: "boot", handler: async () => {
264
- await runtime.boot();
265
- return { ready: true };
266
- } },
267
- mount: { id: "WebContainerService.mount", name: "mount", handler: async (input) => runtime.mount(input.files, input.mountPoint, input.sourceSha) },
268
- run: { id: "WebContainerService.run", name: "run", handler: async (input) => runtime.run(input.task, input.cwd, input.env, input.sourceSha) },
269
- runCommand: { id: "WebContainerService.runCommand", name: "runCommand", handler: async (input) => runtime.runCommand(input.command, input.args, input.cwd, input.env, input.sourceSha) },
270
- spawnCommand: { id: "WebContainerService.spawnCommand", name: "spawnCommand", handler: async (input) => runtime.spawnCommand(input.command, input.args, input.cwd, input.env, input.sourceSha) },
271
- teardown: { id: "WebContainerService.teardown", name: "teardown", handler: async (input) => runtime.teardown(input?.mountPoint) },
272
- command: { id: "WebContainerService.command", name: "command", handler: async (input) => ({ task: input.task, command: resolveWebContainerCommand(input.task) }) }
273
- }
274
- });
275
- var WebContainerServiceFacade = {
276
- id: WebContainerServiceDefinition.id,
277
- name: WebContainerServiceDefinition.name,
278
- version: WebContainerServiceDefinition.version,
279
- runtime: "client",
280
- deployment: "local",
281
- definition: WebContainerServiceDefinition,
282
- createInstance: () => createService(WebContainerServiceDefinition),
283
- execute: async (op, input) => {
284
- const instance = createService(WebContainerServiceDefinition);
285
- await instance.start();
286
- return instance.call(op, input);
287
- }
288
- };
289
-
290
117
  // src/development/developmentService.ts
291
118
  function resolveDevelopmentCommand(task) {
292
119
  const { command, args } = resolveWebContainerCommand(task);
@@ -357,7 +184,7 @@ var DevelopmentServiceFacade = {
357
184
  };
358
185
 
359
186
  // src/development/codeValidationService.ts
360
- var COMMANDS2 = {
187
+ var COMMANDS = {
361
188
  syntax: { command: "pnpm", args: ["exec", "tsc", "--noEmit"] },
362
189
  lint: { command: "pnpm", args: ["run", "lint", "--if-present"] },
363
190
  test: { command: "pnpm", args: ["run", "test", "--if-present"] },
@@ -369,8 +196,8 @@ var COMMANDS2 = {
369
196
  var DEFAULT_LAYERS = ["lockfile-check", "syntax", "lint", "krnl", "frnl"];
370
197
  var commandText = (command, args) => [command, ...args].join(" ");
371
198
  var CodeValidationRuntime = class {
372
- constructor(runtime5 = new WebContainerRuntime()) {
373
- this.runtime = runtime5;
199
+ constructor(runtime4 = new WebContainerRuntime()) {
200
+ this.runtime = runtime4;
374
201
  }
375
202
  runtime;
376
203
  async validate(input = {}) {
@@ -387,7 +214,7 @@ var CodeValidationRuntime = class {
387
214
  diagnostics.push(await this.validateLawL9(input.cwd, input.maxLines ?? 200));
388
215
  continue;
389
216
  }
390
- const spec = COMMANDS2[layer];
217
+ const spec = COMMANDS[layer];
391
218
  const result = await this.runtime.runCommand(spec.command, spec.args, input.cwd, input.env);
392
219
  diagnostics.push({ layer, ok: result.exitCode === 0, exitCode: result.exitCode, output: result.output, command: commandText(spec.command, spec.args) });
393
220
  if (result.exitCode !== 0) break;
@@ -400,12 +227,12 @@ var CodeValidationRuntime = class {
400
227
  return { layer: "law-l9", ok: result.exitCode === 0, exitCode: result.exitCode, output: result.output, command: script };
401
228
  }
402
229
  };
403
- var runtime2 = new CodeValidationRuntime();
230
+ var runtime = new CodeValidationRuntime();
404
231
  var CodeValidationServiceDefinition = createServiceDefinition({
405
232
  id: "kloks.backend.codeValidation",
406
233
  name: "CodeValidationService",
407
234
  version: "1.1.0",
408
- operations: { validate: { id: "CodeValidationService.validate", name: "validate", handler: async (input) => runtime2.validate(input) } }
235
+ operations: { validate: { id: "CodeValidationService.validate", name: "validate", handler: async (input) => runtime.validate(input) } }
409
236
  });
410
237
  var CodeValidationServiceFacade = {
411
238
  id: CodeValidationServiceDefinition.id,
@@ -424,8 +251,8 @@ var CodeValidationServiceFacade = {
424
251
 
425
252
  // src/development/codeDiagnosticsService.ts
426
253
  var CodeDiagnosticsService = class {
427
- constructor(runtime5 = new WebContainerRuntime()) {
428
- this.runtime = runtime5;
254
+ constructor(runtime4 = new WebContainerRuntime()) {
255
+ this.runtime = runtime4;
429
256
  }
430
257
  runtime;
431
258
  async diagnostics(input = {}) {
@@ -443,8 +270,8 @@ var TYPESCRIPT_LANGUAGE_SERVER_VERSION = "6.0.2";
443
270
  var PACKAGE = TYPESCRIPT_LANGUAGE_SERVER_PACKAGE;
444
271
  var DEFAULT_VERSION = TYPESCRIPT_LANGUAGE_SERVER_VERSION;
445
272
  var TypeScriptLanguageServerRuntime = class {
446
- constructor(runtime5 = new WebContainerRuntime()) {
447
- this.runtime = runtime5;
273
+ constructor(runtime4 = new WebContainerRuntime()) {
274
+ this.runtime = runtime4;
448
275
  }
449
276
  runtime;
450
277
  process = null;
@@ -542,17 +369,17 @@ var TypeScriptLanguageServerRuntime = class {
542
369
  }
543
370
  }
544
371
  };
545
- var runtime3 = new TypeScriptLanguageServerRuntime();
372
+ var runtime2 = new TypeScriptLanguageServerRuntime();
546
373
  var TypeScriptLanguageServerServiceDefinition = createServiceDefinition({
547
374
  id: "kloks.backend.typescriptLanguageServer",
548
375
  name: "TypeScriptLanguageServerService",
549
376
  version: "1.0.0",
550
377
  operations: {
551
- start: { id: "TypeScriptLanguageServerService.start", name: "start", handler: async (input) => runtime3.start(input) },
552
- request: { id: "TypeScriptLanguageServerService.request", name: "request", handler: async (input) => runtime3.request(input) },
553
- notify: { id: "TypeScriptLanguageServerService.notify", name: "notify", handler: async (input) => runtime3.notify(input) },
554
- stop: { id: "TypeScriptLanguageServerService.stop", name: "stop", handler: async () => runtime3.stop() },
555
- status: { id: "TypeScriptLanguageServerService.status", name: "status", handler: async () => runtime3.status() }
378
+ start: { id: "TypeScriptLanguageServerService.start", name: "start", handler: async (input) => runtime2.start(input) },
379
+ request: { id: "TypeScriptLanguageServerService.request", name: "request", handler: async (input) => runtime2.request(input) },
380
+ notify: { id: "TypeScriptLanguageServerService.notify", name: "notify", handler: async (input) => runtime2.notify(input) },
381
+ stop: { id: "TypeScriptLanguageServerService.stop", name: "stop", handler: async () => runtime2.stop() },
382
+ status: { id: "TypeScriptLanguageServerService.status", name: "status", handler: async () => runtime2.status() }
556
383
  }
557
384
  });
558
385
  var TypeScriptLanguageServerServiceFacade = {
@@ -595,8 +422,8 @@ var PROVIDERS = [
595
422
  }
596
423
  ];
597
424
  var AgentHarnessRuntime = class {
598
- constructor(runtime5 = new WebContainerRuntime()) {
599
- this.runtime = runtime5;
425
+ constructor(runtime4 = new WebContainerRuntime()) {
426
+ this.runtime = runtime4;
600
427
  }
601
428
  runtime;
602
429
  providers() {
@@ -623,7 +450,7 @@ var AgentHarnessRuntime = class {
623
450
  };
624
451
  }
625
452
  };
626
- var runtime4 = new AgentHarnessRuntime();
453
+ var runtime3 = new AgentHarnessRuntime();
627
454
  var AgentHarnessServiceDefinition = createServiceDefinition({
628
455
  id: "kloks.backend.agentHarness",
629
456
  name: "AgentHarnessService",
@@ -632,12 +459,12 @@ var AgentHarnessServiceDefinition = createServiceDefinition({
632
459
  providers: {
633
460
  id: "AgentHarnessService.providers",
634
461
  name: "providers",
635
- handler: async () => runtime4.providers()
462
+ handler: async () => runtime3.providers()
636
463
  },
637
464
  run: {
638
465
  id: "AgentHarnessService.run",
639
466
  name: "run",
640
- handler: async (input) => runtime4.run(input)
467
+ handler: async (input) => runtime3.run(input)
641
468
  }
642
469
  }
643
470
  });
@@ -0,0 +1,2 @@
1
+ export { W as WebContainerRunCommandInput, a as WebContainerRuntime, c as captureDevelopmentProcess, p as parseDevelopmentDiagnostics, r as resolveWebContainerCommand } from '../webContainerRuntime-BnHB2bNz.js';
2
+ import '@ultrst-armada/krnl';
@@ -0,0 +1,12 @@
1
+ import {
2
+ WebContainerRuntime,
3
+ captureDevelopmentProcess,
4
+ parseDevelopmentDiagnostics,
5
+ resolveWebContainerCommand
6
+ } from "../chunk-CA5HVC4X.js";
7
+ export {
8
+ WebContainerRuntime,
9
+ captureDevelopmentProcess,
10
+ parseDevelopmentDiagnostics,
11
+ resolveWebContainerCommand
12
+ };
@@ -0,0 +1,17 @@
1
+ import * as _ultrst_armada_krnl from '@ultrst-armada/krnl';
2
+ import { ServiceDefinition } from '@ultrst-armada/krnl';
3
+ export { W as WebContainerRunCommandInput, a as WebContainerRuntime, c as captureDevelopmentProcess, p as parseDevelopmentDiagnostics, r as resolveWebContainerCommand } from '../webContainerRuntime-BnHB2bNz.js';
4
+
5
+ declare const WebContainerServiceDefinition: ServiceDefinition;
6
+ declare const WebContainerServiceFacade: {
7
+ id: string;
8
+ name: string;
9
+ version: string;
10
+ runtime: "client";
11
+ deployment: "local";
12
+ definition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
13
+ createInstance: () => _ultrst_armada_krnl.ServiceInstance<Record<string, unknown>, Record<string, unknown>>;
14
+ execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
15
+ };
16
+
17
+ export { WebContainerServiceDefinition, WebContainerServiceFacade };
@@ -0,0 +1,19 @@
1
+ import {
2
+ WebContainerServiceDefinition,
3
+ WebContainerServiceFacade
4
+ } from "../chunk-GKQ42CYW.js";
5
+ import {
6
+ WebContainerRuntime,
7
+ captureDevelopmentProcess,
8
+ parseDevelopmentDiagnostics,
9
+ resolveWebContainerCommand
10
+ } from "../chunk-CA5HVC4X.js";
11
+ import "../chunk-SXDYW3QA.js";
12
+ export {
13
+ WebContainerRuntime,
14
+ WebContainerServiceDefinition,
15
+ WebContainerServiceFacade,
16
+ captureDevelopmentProcess,
17
+ parseDevelopmentDiagnostics,
18
+ resolveWebContainerCommand
19
+ };
@@ -69,6 +69,22 @@ declare class FunctionalityTable<T extends {
69
69
  count(filters?: QueryFilter[]): Promise<number>;
70
70
  }
71
71
 
72
+ /**
73
+ * @file LuthDiscoveryService.ts
74
+ * @description Universal Luth Auth Service Discovery with multi-deployment fallback and round-robin.
75
+ * Runs identically in Node.js, Vercel Serverless, and Cloudflare Workers (< 200 lines).
76
+ */
77
+ declare function getRegisteredLuthDeploymentUrls(queryDb?: (sql: string, params?: unknown[]) => Promise<{
78
+ rows: any[];
79
+ }>): Promise<string[]>;
80
+ declare function getPrimaryLuthDeploymentUrl(queryDb?: (sql: string, params?: unknown[]) => Promise<{
81
+ rows: any[];
82
+ }>): Promise<string>;
83
+ declare function getNextLuthDeploymentUrl(queryDb?: (sql: string, params?: unknown[]) => Promise<{
84
+ rows: any[];
85
+ }>): Promise<string>;
86
+ declare function clearLuthDiscoveryCache(): void;
87
+
72
88
  /**
73
89
  * @file types.ts
74
90
  * @description Formal TypeScript types and contracts for APP_ARCHITECTURE_SPEC.
@@ -1636,4 +1652,4 @@ declare function resolveSystemDatabaseUrl(env?: Record<string, string | undefine
1636
1652
  */
1637
1653
  declare function tryResolveSystemDatabaseUrl(env?: Record<string, string | undefined>): string | null;
1638
1654
 
1639
- export { type AssetChannelType, type AssetDataType, type AssetFolderInfo, type AssetPoolItem, type AssetPoolScope, type B2AuthData, type BackendFacade, BaseDataProvider, BaseResourceFetcher, type CloudflareObservability, type CloudflarePagesPauseState, type CloudflarePagesPreviewSetting, type CloudflareProjectItem, CloudflareResourceFetcher, type CloudflareUsageMetrics, type CredentialEntry, type CredentialManifest, type Deployment, type DeploymentControlResult, type FunctionSet, FunctionalityTable, GRAPHS_ROOT, type IDataProvider, LEGACY_PROJECTS_ROOT, type OrchestrationFn, PROJECTS_ROOT, type ProjectMetadata, type PublicRouteRecord, type QueryFilter, ResourceFetcherRegistry, type Runtime, SAMPLES_GLOBAL_ROOT, SUPPORTED_AUDIO_EXTS, SUPPORTED_MIDI_EXTS, type ServerAudioSampleItem, type ServiceFacade, type ServiceRegistryRecord, type SortOrder, type SrklB2Account, SrklStorageService, type SyncFileResult, type UnifiedQueryResult, type UnifiedResourceMetricItem, type UnifiedResourceMetrics, VercelResourceFetcher, WORKSPACE_ASSETS_ROOT, WORKSPACE_ROOT, type WorkingWorkspaceConfig, type WorkspaceFolderResolution, type WorkspaceStorageConfig, b2DeleteFileVersion, b2DeleteFolder, buildProjectObservability, buildProjectsList, cleanDbUrl, computeDeploymentFinalWeight, computeUsageWeightScore, configureStarterProjectTemplate, createAssetSubfolder, createCredential, createGraphAssetFolder, createGraphAssetFolder as createGraphAssetSubfolder, createGraphPackage, createWavBuffer, createWorkspace, createWorkspaceGraph, decryptSecretFromBlob, deleteAssetFromGraph, deleteAssetFromPool, deleteCredential, deleteGlobalSample, deleteGraphPackage, deleteProject, deleteProjectSample, deleteRoute, deleteWorkspace, deleteWorkspaceFile, deleteWorkspaceFolder, deleteWorkspaceGraph, encryptSecretToBlob, ensureAssetPoolDirectories, ensureGlobalSamples, ensureGraphAssetDirectories, ensureProjectAssets, ensureProjectsRoot, ensureWorkspaceStructure, exportEncryptedCredentials, fetchCloudflareData, fetchVercelData, findUserWorkspace, findWorkspaceRecord, formatRelativeCreated, getAllRoutes, getAssetPoolLocationPath, getAssetPoolPublicUrl, getB2BucketId, getConnectedDeploymentNode, getConnectedWeightModifiers, getCredential, getDefaultWorkingWorkspaceDir, getExecutions, getGatewayConfig, getGraphPackageById, getPrimarySrklDeploymentUrl as getPrimarySrklCoreDeploymentUrl, getProjectById, getPublicRouteByPath, getPublicRoutes, getSrklAccounts as getSrklCoreAccounts, getSrklStatus, getUnifiedDbUrl, getWeightModifierScore, getWorkingWorkspaceConfig, getWorkingWorkspaceDir, getWorkspaceFolderKey, getWorkspaceFolderPrefix, getWorkspaceGraph, getWorkspaceStorageDetails, getWorkspaces, importEncryptedCredentials, importGraphDependency, initGlobalSamplesDirectory, isB2Workspace, listAllGraphPackages, listAllProjects, listBackblazeBuckets, listCredentials, listGlobalSamples, listProjectSamples, listWorkspaceFiles, listWorkspaceGraphs, loadCredentialManifest, loadWorkspaceData, matchGatewayIngress, matchGatewayIngressAsync, pauseCloudflarePagesProject, pauseVercelProject, queryUnifiedDb, readWorkspaceFile, recordExecution, removeGraphDependency, renameAppInWorkspaceData, resolveDynamicRouteFromDb, resolveSystemDatabaseUrl, resolveWorkspaceConnection, resolveWorkspaceDir, resumeCloudflarePagesProject, resumeVercelProject, saveAssetToGraph, saveAssetToPool, saveCredentialManifest, saveGlobalSample, saveGraphPackage, saveProject, saveProjectSample, saveWorkspaceData, saveWorkspaceGraph, scanAssetPool, scanGraphAssets, seedDefaultAssets, seedStarterGraphAssets, serverPublicRoutes, setServerPublicRoutes, setWorkingWorkspaceConfig, srklListBackblazeBuckets as srklCoreListBackblazeBuckets, syncWorkspace, syncWorkspaceCreateToBucket, syncWorkspaceDataToBucket, syncWorkspaceDeleteToBucket, tryResolveSystemDatabaseUrl, updateCredential, updateWorkspace, upsertRoute, validateServiceDefinition, writeWorkspaceFile };
1655
+ export { type AssetChannelType, type AssetDataType, type AssetFolderInfo, type AssetPoolItem, type AssetPoolScope, type B2AuthData, type BackendFacade, BaseDataProvider, BaseResourceFetcher, type CloudflareObservability, type CloudflarePagesPauseState, type CloudflarePagesPreviewSetting, type CloudflareProjectItem, CloudflareResourceFetcher, type CloudflareUsageMetrics, type CredentialEntry, type CredentialManifest, type Deployment, type DeploymentControlResult, type FunctionSet, FunctionalityTable, GRAPHS_ROOT, type IDataProvider, LEGACY_PROJECTS_ROOT, type OrchestrationFn, PROJECTS_ROOT, type ProjectMetadata, type PublicRouteRecord, type QueryFilter, ResourceFetcherRegistry, type Runtime, SAMPLES_GLOBAL_ROOT, SUPPORTED_AUDIO_EXTS, SUPPORTED_MIDI_EXTS, type ServerAudioSampleItem, type ServiceFacade, type ServiceRegistryRecord, type SortOrder, type SrklB2Account, SrklStorageService, type SyncFileResult, type UnifiedQueryResult, type UnifiedResourceMetricItem, type UnifiedResourceMetrics, VercelResourceFetcher, WORKSPACE_ASSETS_ROOT, WORKSPACE_ROOT, type WorkingWorkspaceConfig, type WorkspaceFolderResolution, type WorkspaceStorageConfig, b2DeleteFileVersion, b2DeleteFolder, buildProjectObservability, buildProjectsList, cleanDbUrl, clearLuthDiscoveryCache, computeDeploymentFinalWeight, computeUsageWeightScore, configureStarterProjectTemplate, createAssetSubfolder, createCredential, createGraphAssetFolder, createGraphAssetFolder as createGraphAssetSubfolder, createGraphPackage, createWavBuffer, createWorkspace, createWorkspaceGraph, decryptSecretFromBlob, deleteAssetFromGraph, deleteAssetFromPool, deleteCredential, deleteGlobalSample, deleteGraphPackage, deleteProject, deleteProjectSample, deleteRoute, deleteWorkspace, deleteWorkspaceFile, deleteWorkspaceFolder, deleteWorkspaceGraph, encryptSecretToBlob, ensureAssetPoolDirectories, ensureGlobalSamples, ensureGraphAssetDirectories, ensureProjectAssets, ensureProjectsRoot, ensureWorkspaceStructure, exportEncryptedCredentials, fetchCloudflareData, fetchVercelData, findUserWorkspace, findWorkspaceRecord, formatRelativeCreated, getAllRoutes, getAssetPoolLocationPath, getAssetPoolPublicUrl, getB2BucketId, getConnectedDeploymentNode, getConnectedWeightModifiers, getCredential, getDefaultWorkingWorkspaceDir, getExecutions, getGatewayConfig, getGraphPackageById, getNextLuthDeploymentUrl, getPrimaryLuthDeploymentUrl, getPrimarySrklDeploymentUrl as getPrimarySrklCoreDeploymentUrl, getProjectById, getPublicRouteByPath, getPublicRoutes, getRegisteredLuthDeploymentUrls, getSrklAccounts as getSrklCoreAccounts, getSrklStatus, getUnifiedDbUrl, getWeightModifierScore, getWorkingWorkspaceConfig, getWorkingWorkspaceDir, getWorkspaceFolderKey, getWorkspaceFolderPrefix, getWorkspaceGraph, getWorkspaceStorageDetails, getWorkspaces, importEncryptedCredentials, importGraphDependency, initGlobalSamplesDirectory, isB2Workspace, listAllGraphPackages, listAllProjects, listBackblazeBuckets, listCredentials, listGlobalSamples, listProjectSamples, listWorkspaceFiles, listWorkspaceGraphs, loadCredentialManifest, loadWorkspaceData, matchGatewayIngress, matchGatewayIngressAsync, pauseCloudflarePagesProject, pauseVercelProject, queryUnifiedDb, readWorkspaceFile, recordExecution, removeGraphDependency, renameAppInWorkspaceData, resolveDynamicRouteFromDb, resolveSystemDatabaseUrl, resolveWorkspaceConnection, resolveWorkspaceDir, resumeCloudflarePagesProject, resumeVercelProject, saveAssetToGraph, saveAssetToPool, saveCredentialManifest, saveGlobalSample, saveGraphPackage, saveProject, saveProjectSample, saveWorkspaceData, saveWorkspaceGraph, scanAssetPool, scanGraphAssets, seedDefaultAssets, seedStarterGraphAssets, serverPublicRoutes, setServerPublicRoutes, setWorkingWorkspaceConfig, srklListBackblazeBuckets as srklCoreListBackblazeBuckets, syncWorkspace, syncWorkspaceCreateToBucket, syncWorkspaceDataToBucket, syncWorkspaceDeleteToBucket, tryResolveSystemDatabaseUrl, updateCredential, updateWorkspace, upsertRoute, validateServiceDefinition, writeWorkspaceFile };
@@ -157,7 +157,7 @@ import {
157
157
  krnlWorkspaceGraphServiceFacade,
158
158
  krnlWorkspaceServiceDefinition,
159
159
  krnlWorkspaceServiceFacade
160
- } from "./chunk-UC25J7E4.js";
160
+ } from "./chunk-COA3ABWL.js";
161
161
  import {
162
162
  workspaceGraphService
163
163
  } from "./chunk-IGZB4RYT.js";
@@ -165,7 +165,7 @@ import {
165
165
  getPrimarySrklDeploymentUrl,
166
166
  getSrklAccounts,
167
167
  srklListBackblazeBuckets
168
- } from "./chunk-XHADDA75.js";
168
+ } from "./chunk-RIOYKF3X.js";
169
169
  import {
170
170
  BackblazeB2Adapter,
171
171
  LocalFSAdapter,
@@ -336,6 +336,62 @@ var FunctionalityTable = class extends BaseDataProvider {
336
336
  }
337
337
  };
338
338
 
339
+ // src/luth/LuthDiscoveryService.ts
340
+ import { DEFAULT_LUTH_URL } from "@dinilmusick/gutts/auth";
341
+ var cachedLuthUrls = null;
342
+ var roundRobinIndex = 0;
343
+ async function getRegisteredLuthDeploymentUrls(queryDb) {
344
+ if (cachedLuthUrls && Date.now() < cachedLuthUrls.expiresAt && cachedLuthUrls.urls.length > 0) {
345
+ return cachedLuthUrls.urls;
346
+ }
347
+ if (queryDb) {
348
+ try {
349
+ const res = await queryDb(
350
+ `SELECT url FROM "ultrst-luth-deployments" WHERE is_active = true ORDER BY is_primary DESC, priority DESC, created_at ASC`,
351
+ []
352
+ );
353
+ if (res.rows.length > 0) {
354
+ const urls = res.rows.map((r) => String(r.url || "").trim().replace(/\/+$/, "")).filter(Boolean);
355
+ if (urls.length > 0) {
356
+ cachedLuthUrls = { urls, expiresAt: Date.now() + 5 * 60 * 1e3 };
357
+ return urls;
358
+ }
359
+ }
360
+ } catch {
361
+ try {
362
+ const res2 = await queryDb(
363
+ `SELECT origin FROM "ultrst-apps" WHERE app_id = 'luth' AND status = 'active' AND origin IS NOT NULL LIMIT 1`,
364
+ []
365
+ );
366
+ if (res2.rows.length > 0 && res2.rows[0].origin) {
367
+ const u = String(res2.rows[0].origin).trim().replace(/\/+$/, "");
368
+ cachedLuthUrls = { urls: [u], expiresAt: Date.now() + 5 * 60 * 1e3 };
369
+ return [u];
370
+ }
371
+ } catch {
372
+ }
373
+ }
374
+ }
375
+ const fallback = [DEFAULT_LUTH_URL];
376
+ cachedLuthUrls = { urls: fallback, expiresAt: Date.now() + 5 * 60 * 1e3 };
377
+ return fallback;
378
+ }
379
+ async function getPrimaryLuthDeploymentUrl(queryDb) {
380
+ const urls = await getRegisteredLuthDeploymentUrls(queryDb);
381
+ return urls[0] || DEFAULT_LUTH_URL;
382
+ }
383
+ async function getNextLuthDeploymentUrl(queryDb) {
384
+ const urls = await getRegisteredLuthDeploymentUrls(queryDb);
385
+ if (urls.length === 0) return DEFAULT_LUTH_URL;
386
+ const next = urls[roundRobinIndex % urls.length];
387
+ roundRobinIndex = (roundRobinIndex + 1) % urls.length;
388
+ return next;
389
+ }
390
+ function clearLuthDiscoveryCache() {
391
+ cachedLuthUrls = null;
392
+ roundRobinIndex = 0;
393
+ }
394
+
339
395
  // src/architecture/types.ts
340
396
  function validateServiceDefinition(def) {
341
397
  if (def.deployment === "remote" && def.runtime !== "server") {
@@ -4425,6 +4481,7 @@ export {
4425
4481
  buildProjectsList,
4426
4482
  classifyAndFormatError,
4427
4483
  cleanDbUrl,
4484
+ clearLuthDiscoveryCache,
4428
4485
  computeDeploymentFinalWeight,
4429
4486
  computeUsageWeightScore,
4430
4487
  configureStarterProjectTemplate,
@@ -4493,12 +4550,15 @@ export {
4493
4550
  getExecutions,
4494
4551
  getGatewayConfig,
4495
4552
  getGraphPackageById,
4553
+ getNextLuthDeploymentUrl,
4554
+ getPrimaryLuthDeploymentUrl,
4496
4555
  getPrimarySrklDeploymentUrl2 as getPrimarySrklCoreDeploymentUrl,
4497
4556
  getPrimarySrklDeploymentUrl,
4498
4557
  getProjectById,
4499
4558
  getProviderMeta,
4500
4559
  getPublicRouteByPath,
4501
4560
  getPublicRoutes,
4561
+ getRegisteredLuthDeploymentUrls,
4502
4562
  getSrklAccounts,
4503
4563
  getSrklAccounts2 as getSrklCoreAccounts,
4504
4564
  getSrklStatus,
@@ -31,9 +31,9 @@ import {
31
31
  krnlWorkspaceGraphServiceFacade,
32
32
  krnlWorkspaceServiceDefinition,
33
33
  krnlWorkspaceServiceFacade
34
- } from "./chunk-UC25J7E4.js";
34
+ } from "./chunk-COA3ABWL.js";
35
35
  import "./chunk-IGZB4RYT.js";
36
- import "./chunk-XHADDA75.js";
36
+ import "./chunk-RIOYKF3X.js";
37
37
  import "./chunk-SHZAQTIT.js";
38
38
  import "./chunk-4QEMALXF.js";
39
39
  import "./chunk-FZKBTF34.js";
@@ -174,11 +174,6 @@ declare class SrklClient {
174
174
  }
175
175
  declare function createSrklClient(options?: SrklClientOptions): SrklClient;
176
176
 
177
- /**
178
- * @file SrklDiscoveryService.ts
179
- * @description Universal SRKL Service Discovery and Backblaze B2 account federation.
180
- * Runs identically in Node.js, Vercel Serverless, and Cloudflare Workers (< 200 lines).
181
- */
182
177
  declare function getPrimarySrklDeploymentUrl(queryDb?: (sql: string, params?: unknown[]) => Promise<{
183
178
  rows: any[];
184
179
  }>): Promise<string>;
@@ -15,7 +15,7 @@ import {
15
15
  getPrimarySrklDeploymentUrl,
16
16
  getSrklAccounts,
17
17
  srklListBackblazeBuckets
18
- } from "../chunk-XHADDA75.js";
18
+ } from "../chunk-RIOYKF3X.js";
19
19
  import "../chunk-4QEMALXF.js";
20
20
  import "../chunk-JCMB7BIM.js";
21
21
  export {
@@ -0,0 +1,103 @@
1
+ import { ServiceDefinition } from '@ultrst-armada/krnl';
2
+
3
+ type DevelopmentProvider = 'webcontainer' | 'github-actions';
4
+ type DevelopmentTask = 'install' | 'lint' | 'test' | 'build' | 'validate' | 'check';
5
+ interface DevelopmentRequest {
6
+ provider: DevelopmentProvider;
7
+ task: DevelopmentTask;
8
+ repository?: string;
9
+ ref?: string;
10
+ workflowId?: string | number;
11
+ workflowInputs?: Record<string, string>;
12
+ cwd?: string;
13
+ env?: Record<string, string>;
14
+ sourceSha?: string;
15
+ }
16
+ interface DevelopmentDiagnostic {
17
+ severity: 'error' | 'warning' | 'info';
18
+ source: 'typescript' | 'eslint' | 'bundler' | 'package-manager' | 'runtime' | 'unknown';
19
+ code?: string;
20
+ file?: string;
21
+ line?: number;
22
+ column?: number;
23
+ message: string;
24
+ }
25
+ interface DevelopmentResult {
26
+ provider: DevelopmentProvider;
27
+ task: DevelopmentTask;
28
+ ok: boolean;
29
+ exitCode?: number;
30
+ output?: string;
31
+ command?: string;
32
+ durationMs?: number;
33
+ diagnostics?: DevelopmentDiagnostic[];
34
+ sourceSha?: string;
35
+ runId?: number;
36
+ url?: string;
37
+ }
38
+ interface WebContainerCommand {
39
+ command: string;
40
+ args: string[];
41
+ }
42
+ interface DevelopmentServiceContract {
43
+ definition: ServiceDefinition;
44
+ }
45
+
46
+ declare function resolveWebContainerCommand(task: DevelopmentTask): WebContainerCommand;
47
+ declare function parseDevelopmentDiagnostics(output: string, exitCode?: number): DevelopmentDiagnostic[];
48
+ declare function captureDevelopmentProcess<T extends {
49
+ output: ReadableStream<string>;
50
+ exit: Promise<number>;
51
+ }>(process: T): T & {
52
+ output: ReadableStream<string>;
53
+ logs: Promise<{
54
+ output: string;
55
+ exitCode: number;
56
+ diagnostics: DevelopmentDiagnostic[];
57
+ }>;
58
+ };
59
+ interface WebContainerRunCommandInput {
60
+ command: string;
61
+ args?: string[];
62
+ cwd?: string;
63
+ env?: Record<string, string | number | boolean>;
64
+ sourceSha?: string;
65
+ }
66
+ declare class WebContainerRuntime {
67
+ boot(): Promise<any>;
68
+ mount(files: Record<string, unknown>, mountPoint?: string, sourceSha?: string): Promise<{
69
+ mounted: boolean;
70
+ mountPoint: string;
71
+ sourceSha: string;
72
+ }>;
73
+ private runProcess;
74
+ run(task: DevelopmentTask, cwd?: string, env?: Record<string, string>, sourceSha?: string): Promise<{
75
+ exitCode: any;
76
+ output: string;
77
+ command: string;
78
+ durationMs: number;
79
+ diagnostics: DevelopmentDiagnostic[];
80
+ sourceSha: string;
81
+ }>;
82
+ runCommand(command: string, args?: string[], cwd?: string, env?: Record<string, string | number | boolean>, sourceSha?: string): Promise<{
83
+ exitCode: any;
84
+ output: string;
85
+ command: string;
86
+ durationMs: number;
87
+ diagnostics: DevelopmentDiagnostic[];
88
+ sourceSha: string;
89
+ }>;
90
+ spawnCommand(command: string, args?: string[], cwd?: string, env?: Record<string, string | number | boolean>, sourceSha?: string): Promise<{
91
+ processId: `${string}-${string}-${string}-${string}-${string}`;
92
+ sourceSha: string;
93
+ command: string;
94
+ startedAt: string;
95
+ process: any;
96
+ }>;
97
+ teardown(mountPoint?: string): Promise<{
98
+ tornDown: boolean;
99
+ mountPoint: string;
100
+ }>;
101
+ }
102
+
103
+ export { type DevelopmentRequest as D, type WebContainerRunCommandInput as W, WebContainerRuntime as a, type DevelopmentResult as b, captureDevelopmentProcess as c, type DevelopmentDiagnostic as d, type DevelopmentProvider as e, type DevelopmentServiceContract as f, type DevelopmentTask as g, type WebContainerCommand as h, parseDevelopmentDiagnostics as p, resolveWebContainerCommand as r };