@ultrst-armada/kloks 1.5.2 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.krusbl-release-attestation.json +3 -3
- package/package.json +1 -1
- package/packages/backend/dist/{chunk-E72GXBXF.js → chunk-6K75XXFD.js} +9 -200
- package/packages/backend/dist/{chunk-GPXV4GBD.js → chunk-6QTNNZSE.js} +7 -5
- package/packages/backend/dist/{chunk-OZDYAEH4.js → chunk-BI5RDDB4.js} +210 -1
- package/packages/backend/dist/{chunk-DBZVGMJ7.js → chunk-KSZ67VZJ.js} +1 -1
- package/packages/backend/dist/{chunk-VDROUXFT.js → chunk-N4Z57FVR.js} +10 -10
- package/packages/backend/dist/{chunk-3Z7EUZWE.js → chunk-SQGBAWZN.js} +238 -6
- package/packages/backend/dist/chunk-VAFCR2MS.js +203 -0
- package/packages/backend/dist/{chunk-GQUNN7SA.js → chunk-Y3X3H2XX.js} +6 -4
- package/packages/backend/dist/development/index.d.ts +100 -1
- package/packages/backend/dist/development/index.js +15 -1
- package/packages/backend/dist/index.d.ts +2 -2
- package/packages/backend/dist/index.js +39 -213
- package/packages/backend/dist/krnl-services.js +5 -4
- package/packages/backend/dist/services/index.js +3 -2
- package/packages/backend/dist/srkl/index.d.ts +48 -1
- package/packages/backend/dist/srkl/index.js +3 -2
- package/packages/backend/dist/workspace/index.js +3 -2
- package/packages/backend/kloks.manifest.json +52 -1
|
@@ -169,6 +169,10 @@ var WebContainerRuntime = class {
|
|
|
169
169
|
release();
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
+
async spawnCommand(command, args = [], cwd, env) {
|
|
173
|
+
const container = await this.boot();
|
|
174
|
+
return container.spawn(command, args, { cwd, env });
|
|
175
|
+
}
|
|
172
176
|
async teardown() {
|
|
173
177
|
const container = this.container;
|
|
174
178
|
this.container = null;
|
|
@@ -239,7 +243,9 @@ var DevelopmentServiceDefinition = createServiceDefinition({
|
|
|
239
243
|
name: "describeProviders",
|
|
240
244
|
handler: async () => ({
|
|
241
245
|
providers: [
|
|
242
|
-
{ id: "webcontainer", capabilities: ["install", "lint", "test", "build", "validate", "check"] },
|
|
246
|
+
{ id: "webcontainer", capabilities: ["install", "lint", "test", "build", "validate", "check", "process-host"] },
|
|
247
|
+
{ id: "typescript-language-server", capabilities: ["lsp", "diagnostics", "completion", "hover", "definition", "references", "rename", "symbols"] },
|
|
248
|
+
{ id: "agent-harness", capabilities: ["deepseek", "openai", "google", "headless", "sdk", "acp"] },
|
|
243
249
|
{ id: "github-actions", capabilities: ["dispatch", "observe", "rerun", "cancel"] }
|
|
244
250
|
]
|
|
245
251
|
})
|
|
@@ -296,8 +302,8 @@ var COMMANDS2 = {
|
|
|
296
302
|
var DEFAULT_LAYERS = ["syntax", "lint", "krnl", "frnl"];
|
|
297
303
|
var commandText = (command, args) => [command, ...args].join(" ");
|
|
298
304
|
var CodeValidationRuntime = class {
|
|
299
|
-
constructor(
|
|
300
|
-
this.runtime =
|
|
305
|
+
constructor(runtime5 = new WebContainerRuntime()) {
|
|
306
|
+
this.runtime = runtime5;
|
|
301
307
|
}
|
|
302
308
|
runtime;
|
|
303
309
|
async validate(input = {}) {
|
|
@@ -351,8 +357,8 @@ var CodeValidationServiceFacade = {
|
|
|
351
357
|
|
|
352
358
|
// src/development/codeDiagnosticsService.ts
|
|
353
359
|
var CodeDiagnosticsService = class {
|
|
354
|
-
constructor(
|
|
355
|
-
this.runtime =
|
|
360
|
+
constructor(runtime5 = new WebContainerRuntime()) {
|
|
361
|
+
this.runtime = runtime5;
|
|
356
362
|
}
|
|
357
363
|
runtime;
|
|
358
364
|
async diagnostics(input = {}) {
|
|
@@ -364,6 +370,225 @@ var CodeDiagnosticsService = class {
|
|
|
364
370
|
};
|
|
365
371
|
var codeDiagnosticsService = new CodeDiagnosticsService();
|
|
366
372
|
|
|
373
|
+
// src/development/typescriptLanguageServerService.ts
|
|
374
|
+
var TYPESCRIPT_LANGUAGE_SERVER_PACKAGE = "typescript-language-server";
|
|
375
|
+
var TYPESCRIPT_LANGUAGE_SERVER_VERSION = "6.0.2";
|
|
376
|
+
var PACKAGE = TYPESCRIPT_LANGUAGE_SERVER_PACKAGE;
|
|
377
|
+
var DEFAULT_VERSION = TYPESCRIPT_LANGUAGE_SERVER_VERSION;
|
|
378
|
+
var TypeScriptLanguageServerRuntime = class {
|
|
379
|
+
constructor(runtime5 = new WebContainerRuntime()) {
|
|
380
|
+
this.runtime = runtime5;
|
|
381
|
+
}
|
|
382
|
+
runtime;
|
|
383
|
+
process = null;
|
|
384
|
+
writer = null;
|
|
385
|
+
pending = /* @__PURE__ */ new Map();
|
|
386
|
+
buffer = "";
|
|
387
|
+
cwd = ".";
|
|
388
|
+
version = DEFAULT_VERSION;
|
|
389
|
+
async start(input = {}) {
|
|
390
|
+
if (this.process) return this.status();
|
|
391
|
+
this.cwd = input.cwd ?? ".";
|
|
392
|
+
this.version = input.version ?? DEFAULT_VERSION;
|
|
393
|
+
if (input.install !== false) {
|
|
394
|
+
await this.runtime.runCommand("pnpm", ["add", "-D", "typescript@7.0.2", PACKAGE + "@" + this.version], this.cwd);
|
|
395
|
+
}
|
|
396
|
+
this.process = await this.runtime.spawnCommand("pnpm", ["exec", PACKAGE, "--stdio"], this.cwd);
|
|
397
|
+
this.writer = this.process.input.getWriter();
|
|
398
|
+
void this.readOutput(this.process.output);
|
|
399
|
+
return this.status();
|
|
400
|
+
}
|
|
401
|
+
async request(input) {
|
|
402
|
+
await this.ensureRunning();
|
|
403
|
+
const promise = new Promise((resolve, reject) => {
|
|
404
|
+
this.pending.set(input.id, { resolve, reject });
|
|
405
|
+
});
|
|
406
|
+
await this.write(input);
|
|
407
|
+
return promise;
|
|
408
|
+
}
|
|
409
|
+
async notify(input) {
|
|
410
|
+
await this.ensureRunning();
|
|
411
|
+
await this.write(input);
|
|
412
|
+
return { sent: true };
|
|
413
|
+
}
|
|
414
|
+
async stop() {
|
|
415
|
+
const process = this.process;
|
|
416
|
+
this.process = null;
|
|
417
|
+
this.writer?.releaseLock();
|
|
418
|
+
this.writer = null;
|
|
419
|
+
for (const pending of this.pending.values()) pending.reject(new Error("Language server stopped"));
|
|
420
|
+
this.pending.clear();
|
|
421
|
+
if (process) await process.kill();
|
|
422
|
+
return { stopped: true };
|
|
423
|
+
}
|
|
424
|
+
status() {
|
|
425
|
+
return { running: Boolean(this.process), cwd: this.cwd, package: PACKAGE, version: this.version };
|
|
426
|
+
}
|
|
427
|
+
async ensureRunning() {
|
|
428
|
+
if (!this.process) await this.start({ cwd: this.cwd, install: false, version: this.version });
|
|
429
|
+
}
|
|
430
|
+
async write(message) {
|
|
431
|
+
if (!this.writer) throw new Error("Language server input is unavailable");
|
|
432
|
+
const body = JSON.stringify({ jsonrpc: "2.0", ...message });
|
|
433
|
+
const frame = "Content-Length: " + new TextEncoder().encode(body).byteLength + "\r\n\r\n" + body;
|
|
434
|
+
await this.writer.write(frame);
|
|
435
|
+
}
|
|
436
|
+
async readOutput(output) {
|
|
437
|
+
const reader = output.getReader();
|
|
438
|
+
try {
|
|
439
|
+
while (true) {
|
|
440
|
+
const next = await reader.read();
|
|
441
|
+
if (next.done) break;
|
|
442
|
+
this.buffer += next.value;
|
|
443
|
+
this.consumeFrames();
|
|
444
|
+
}
|
|
445
|
+
} catch (error) {
|
|
446
|
+
for (const pending of this.pending.values()) pending.reject(error instanceof Error ? error : new Error(String(error)));
|
|
447
|
+
this.pending.clear();
|
|
448
|
+
} finally {
|
|
449
|
+
reader.releaseLock();
|
|
450
|
+
this.process = null;
|
|
451
|
+
this.writer?.releaseLock();
|
|
452
|
+
this.writer = null;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
consumeFrames() {
|
|
456
|
+
while (true) {
|
|
457
|
+
const separator = this.buffer.indexOf("\r\n\r\n");
|
|
458
|
+
if (separator < 0) return;
|
|
459
|
+
const header = this.buffer.slice(0, separator);
|
|
460
|
+
const match = header.match(/Content-Length:\s*(\d+)/i);
|
|
461
|
+
if (!match) {
|
|
462
|
+
this.buffer = this.buffer.slice(separator + 4);
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
const length = Number(match[1]);
|
|
466
|
+
const start = separator + 4;
|
|
467
|
+
if (this.buffer.length - start < length) return;
|
|
468
|
+
const body = this.buffer.slice(start, start + length);
|
|
469
|
+
this.buffer = this.buffer.slice(start + length);
|
|
470
|
+
const response = JSON.parse(body);
|
|
471
|
+
if (response.id !== void 0 && response.id !== null) {
|
|
472
|
+
this.pending.get(response.id)?.resolve(response);
|
|
473
|
+
this.pending.delete(response.id);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
var runtime3 = new TypeScriptLanguageServerRuntime();
|
|
479
|
+
var TypeScriptLanguageServerServiceDefinition = createServiceDefinition({
|
|
480
|
+
id: "kloks.backend.typescriptLanguageServer",
|
|
481
|
+
name: "TypeScriptLanguageServerService",
|
|
482
|
+
version: "1.0.0",
|
|
483
|
+
operations: {
|
|
484
|
+
start: { id: "TypeScriptLanguageServerService.start", name: "start", handler: async (input) => runtime3.start(input) },
|
|
485
|
+
request: { id: "TypeScriptLanguageServerService.request", name: "request", handler: async (input) => runtime3.request(input) },
|
|
486
|
+
notify: { id: "TypeScriptLanguageServerService.notify", name: "notify", handler: async (input) => runtime3.notify(input) },
|
|
487
|
+
stop: { id: "TypeScriptLanguageServerService.stop", name: "stop", handler: async () => runtime3.stop() },
|
|
488
|
+
status: { id: "TypeScriptLanguageServerService.status", name: "status", handler: async () => runtime3.status() }
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
var TypeScriptLanguageServerServiceFacade = {
|
|
492
|
+
id: TypeScriptLanguageServerServiceDefinition.id,
|
|
493
|
+
name: TypeScriptLanguageServerServiceDefinition.name,
|
|
494
|
+
version: TypeScriptLanguageServerServiceDefinition.version,
|
|
495
|
+
runtime: "client",
|
|
496
|
+
deployment: "local",
|
|
497
|
+
definition: TypeScriptLanguageServerServiceDefinition,
|
|
498
|
+
createInstance: () => createService(TypeScriptLanguageServerServiceDefinition),
|
|
499
|
+
execute: async (op, input) => {
|
|
500
|
+
const instance = createService(TypeScriptLanguageServerServiceDefinition);
|
|
501
|
+
await instance.start();
|
|
502
|
+
return instance.call(op, input);
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
// src/development/agentHarnessService.ts
|
|
507
|
+
var PROVIDERS = [
|
|
508
|
+
{
|
|
509
|
+
id: "deepseek",
|
|
510
|
+
name: "DeepSeek Harness",
|
|
511
|
+
package: "@deepseek-ai/dsh",
|
|
512
|
+
capabilities: ["headless", "sdk", "acp", "web"],
|
|
513
|
+
implemented: true
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
id: "openai",
|
|
517
|
+
name: "OpenAI Agents SDK",
|
|
518
|
+
package: "@openai/agents",
|
|
519
|
+
capabilities: ["agents", "tools", "handoffs", "guardrails", "sessions", "tracing"],
|
|
520
|
+
implemented: false
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
id: "google",
|
|
524
|
+
name: "Google ADK",
|
|
525
|
+
package: "@google/adk",
|
|
526
|
+
capabilities: ["agents", "tools", "multi-agent", "evaluation", "deployment"],
|
|
527
|
+
implemented: false
|
|
528
|
+
}
|
|
529
|
+
];
|
|
530
|
+
var AgentHarnessRuntime = class {
|
|
531
|
+
constructor(runtime5 = new WebContainerRuntime()) {
|
|
532
|
+
this.runtime = runtime5;
|
|
533
|
+
}
|
|
534
|
+
runtime;
|
|
535
|
+
providers() {
|
|
536
|
+
return PROVIDERS.map((provider) => ({ ...provider, capabilities: [...provider.capabilities] }));
|
|
537
|
+
}
|
|
538
|
+
async run(input) {
|
|
539
|
+
if (input.provider !== "deepseek") {
|
|
540
|
+
throw new Error(
|
|
541
|
+
`Agent harness provider "${input.provider}" is registered but not yet executable; install and register its adapter before running it.`
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
const started = Date.now();
|
|
545
|
+
const profile = input.profile ?? "headless";
|
|
546
|
+
const command = "pnpm";
|
|
547
|
+
const args = ["exec", "dsh", "--profile", profile, input.prompt];
|
|
548
|
+
const result = await this.runtime.runCommand(command, args, input.cwd ?? ".", input.env);
|
|
549
|
+
return {
|
|
550
|
+
provider: input.provider,
|
|
551
|
+
ok: result.exitCode === 0,
|
|
552
|
+
exitCode: result.exitCode,
|
|
553
|
+
output: result.output,
|
|
554
|
+
durationMs: Date.now() - started,
|
|
555
|
+
command: [command, ...args].join(" ")
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
var runtime4 = new AgentHarnessRuntime();
|
|
560
|
+
var AgentHarnessServiceDefinition = createServiceDefinition({
|
|
561
|
+
id: "kloks.backend.agentHarness",
|
|
562
|
+
name: "AgentHarnessService",
|
|
563
|
+
version: "1.0.0",
|
|
564
|
+
operations: {
|
|
565
|
+
providers: {
|
|
566
|
+
id: "AgentHarnessService.providers",
|
|
567
|
+
name: "providers",
|
|
568
|
+
handler: async () => runtime4.providers()
|
|
569
|
+
},
|
|
570
|
+
run: {
|
|
571
|
+
id: "AgentHarnessService.run",
|
|
572
|
+
name: "run",
|
|
573
|
+
handler: async (input) => runtime4.run(input)
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
var AgentHarnessServiceFacade = {
|
|
578
|
+
id: AgentHarnessServiceDefinition.id,
|
|
579
|
+
name: AgentHarnessServiceDefinition.name,
|
|
580
|
+
version: AgentHarnessServiceDefinition.version,
|
|
581
|
+
runtime: "client",
|
|
582
|
+
deployment: "local",
|
|
583
|
+
definition: AgentHarnessServiceDefinition,
|
|
584
|
+
createInstance: () => createService(AgentHarnessServiceDefinition),
|
|
585
|
+
execute: async (op, input) => {
|
|
586
|
+
const instance = createService(AgentHarnessServiceDefinition);
|
|
587
|
+
await instance.start();
|
|
588
|
+
return instance.call(op, input);
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
|
|
367
592
|
export {
|
|
368
593
|
GitHubActionsClient,
|
|
369
594
|
GitHubActionsServiceDefinition,
|
|
@@ -379,5 +604,12 @@ export {
|
|
|
379
604
|
CodeValidationServiceDefinition,
|
|
380
605
|
CodeValidationServiceFacade,
|
|
381
606
|
CodeDiagnosticsService,
|
|
382
|
-
codeDiagnosticsService
|
|
607
|
+
codeDiagnosticsService,
|
|
608
|
+
TYPESCRIPT_LANGUAGE_SERVER_PACKAGE,
|
|
609
|
+
TYPESCRIPT_LANGUAGE_SERVER_VERSION,
|
|
610
|
+
TypeScriptLanguageServerServiceDefinition,
|
|
611
|
+
TypeScriptLanguageServerServiceFacade,
|
|
612
|
+
AgentHarnessRuntime,
|
|
613
|
+
AgentHarnessServiceDefinition,
|
|
614
|
+
AgentHarnessServiceFacade
|
|
383
615
|
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// src/core/unifiedDb.ts
|
|
2
|
+
var neon;
|
|
3
|
+
function cleanDbUrl(url) {
|
|
4
|
+
if (!url || typeof url !== "string") return "";
|
|
5
|
+
return url.trim().replace(/^["']|["']$/g, "");
|
|
6
|
+
}
|
|
7
|
+
function getUnifiedDbUrl(env) {
|
|
8
|
+
const fromEnv = cleanDbUrl(env?.SYSTEM_DATABASE_URL_1) || cleanDbUrl(env?.DATABASE_URL) || cleanDbUrl(env?.SYSTEM_DATABASE_URL_2);
|
|
9
|
+
if (fromEnv) return fromEnv;
|
|
10
|
+
if (typeof process !== "undefined" && process.env) {
|
|
11
|
+
return cleanDbUrl(process.env.SYSTEM_DATABASE_URL_1) || cleanDbUrl(process.env.DATABASE_URL) || cleanDbUrl(process.env.SYSTEM_DATABASE_URL_2) || cleanDbUrl(process.env.SYSTEM_DATABASE_URL_3) || "";
|
|
12
|
+
}
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
async function queryUnifiedDb(sqlText, params = [], env) {
|
|
16
|
+
const dbUrl = getUnifiedDbUrl(env);
|
|
17
|
+
if (!dbUrl) {
|
|
18
|
+
throw new Error("[UnifiedDB] No database URL configured in environment.");
|
|
19
|
+
}
|
|
20
|
+
if (!neon) {
|
|
21
|
+
const mod = await import("@neondatabase/serverless");
|
|
22
|
+
neon = mod.neon;
|
|
23
|
+
}
|
|
24
|
+
const sql = neon(dbUrl);
|
|
25
|
+
try {
|
|
26
|
+
const rows = await (sql.query ? sql.query(sqlText, params) : sql(sqlText, params));
|
|
27
|
+
return {
|
|
28
|
+
rows: Array.isArray(rows) ? rows : [],
|
|
29
|
+
rowCount: Array.isArray(rows) ? rows.length : 0
|
|
30
|
+
};
|
|
31
|
+
} catch (err) {
|
|
32
|
+
console.error("[UnifiedDB] Query execution error:", err.message);
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/core/b2DirectCore.ts
|
|
38
|
+
var authCache = /* @__PURE__ */ new Map();
|
|
39
|
+
var bucketIdCache = /* @__PURE__ */ new Map();
|
|
40
|
+
async function authorizeB2(keyId, applicationKey) {
|
|
41
|
+
const cacheKey = `${keyId.trim()}:${applicationKey.trim()}`;
|
|
42
|
+
const cached = authCache.get(cacheKey);
|
|
43
|
+
if (cached && Date.now() < cached.expiresAt) return cached.auth;
|
|
44
|
+
const authHeader = typeof Buffer !== "undefined" ? Buffer.from(`${keyId.trim()}:${applicationKey.trim()}`).toString("base64") : btoa(`${keyId.trim()}:${applicationKey.trim()}`);
|
|
45
|
+
let res = await fetch("https://api.backblazeb2.com/b2api/v2/b2_authorize_account", {
|
|
46
|
+
headers: { Authorization: `Basic ${authHeader}` },
|
|
47
|
+
signal: AbortSignal.timeout(1e4)
|
|
48
|
+
});
|
|
49
|
+
if (!res.ok) {
|
|
50
|
+
res = await fetch("https://api.backblazeb2.com/b2api/v4/b2_authorize_account", {
|
|
51
|
+
headers: { Authorization: `Basic ${authHeader}` },
|
|
52
|
+
signal: AbortSignal.timeout(1e4)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (!res.ok) {
|
|
56
|
+
const errText = await res.text();
|
|
57
|
+
throw new Error(`Backblaze B2 authorization failed (${res.status}): ${errText}`);
|
|
58
|
+
}
|
|
59
|
+
const data = await res.json();
|
|
60
|
+
const auth = {
|
|
61
|
+
accountId: data.accountId,
|
|
62
|
+
authorizationToken: data.authorizationToken,
|
|
63
|
+
apiUrl: (data.apiInfo?.storageApi?.apiUrl || data.apiUrl || "https://api.backblazeb2.com").replace(/\/+$/, ""),
|
|
64
|
+
downloadUrl: (data.apiInfo?.storageApi?.downloadUrl || data.downloadUrl || data.apiUrl || "https://f003.backblazeb2.com").replace(/\/+$/, ""),
|
|
65
|
+
s3ApiUrl: data.apiInfo?.storageApi?.s3ApiUrl || data.s3ApiUrl,
|
|
66
|
+
allowed: data.apiInfo?.storageApi?.allowed || data.allowed
|
|
67
|
+
};
|
|
68
|
+
authCache.set(cacheKey, { auth, expiresAt: Date.now() + 20 * 60 * 1e3 });
|
|
69
|
+
return auth;
|
|
70
|
+
}
|
|
71
|
+
async function b2ListBuckets(keyId, applicationKey, bucketId, bucketName) {
|
|
72
|
+
const auth = await authorizeB2(keyId, applicationKey);
|
|
73
|
+
const rBucketId = bucketId || auth.allowed?.bucketId || auth.allowed?.buckets?.[0]?.bucketId;
|
|
74
|
+
const rBucketName = bucketName || auth.allowed?.bucketName || auth.allowed?.buckets?.[0]?.bucketName;
|
|
75
|
+
if (!auth.allowed?.bucketId && !auth.allowed?.bucketName) {
|
|
76
|
+
try {
|
|
77
|
+
const res = await fetch(`${auth.apiUrl}/b2api/v2/b2_list_buckets`, {
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: { Authorization: auth.authorizationToken, "Content-Type": "application/json" },
|
|
80
|
+
body: JSON.stringify({ accountId: auth.accountId }),
|
|
81
|
+
signal: AbortSignal.timeout(8e3)
|
|
82
|
+
});
|
|
83
|
+
if (res.ok) {
|
|
84
|
+
const data = await res.json();
|
|
85
|
+
if (Array.isArray(data.buckets) && data.buckets.length > 0) return data.buckets;
|
|
86
|
+
}
|
|
87
|
+
} catch (err) {
|
|
88
|
+
console.warn("[B2DirectCore] list_buckets query failed:", err.message);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (rBucketId || rBucketName) {
|
|
92
|
+
const body = { accountId: auth.accountId };
|
|
93
|
+
if (rBucketId) body.bucketId = rBucketId;
|
|
94
|
+
else if (rBucketName) body.bucketName = rBucketName;
|
|
95
|
+
try {
|
|
96
|
+
const res = await fetch(`${auth.apiUrl}/b2api/v2/b2_list_buckets`, {
|
|
97
|
+
method: "POST",
|
|
98
|
+
headers: { Authorization: auth.authorizationToken, "Content-Type": "application/json" },
|
|
99
|
+
body: JSON.stringify(body),
|
|
100
|
+
signal: AbortSignal.timeout(8e3)
|
|
101
|
+
});
|
|
102
|
+
if (res.ok) {
|
|
103
|
+
const data = await res.json();
|
|
104
|
+
if (Array.isArray(data.buckets) && data.buckets.length > 0) return data.buckets;
|
|
105
|
+
}
|
|
106
|
+
} catch {
|
|
107
|
+
}
|
|
108
|
+
return [{
|
|
109
|
+
accountId: auth.accountId,
|
|
110
|
+
bucketId: rBucketId || "restricted",
|
|
111
|
+
bucketName: rBucketName || (bucketName || "default-bucket"),
|
|
112
|
+
bucketType: "allPrivate"
|
|
113
|
+
}];
|
|
114
|
+
}
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
async function getB2BucketId(keyId, applicationKey, bucketName) {
|
|
118
|
+
const cacheKey = `${keyId.trim()}:${bucketName.trim()}`;
|
|
119
|
+
if (bucketIdCache.has(cacheKey)) return bucketIdCache.get(cacheKey);
|
|
120
|
+
const buckets = await b2ListBuckets(keyId, applicationKey, void 0, bucketName);
|
|
121
|
+
const match = buckets.find((b) => b.bucketName === bucketName);
|
|
122
|
+
if (!match) throw new Error(`B2 bucket "${bucketName}" not found in account`);
|
|
123
|
+
bucketIdCache.set(cacheKey, match.bucketId);
|
|
124
|
+
return match.bucketId;
|
|
125
|
+
}
|
|
126
|
+
async function b2UploadFile(keyId, applicationKey, bucketName, fileName, buffer, contentType = "b2/x-auto") {
|
|
127
|
+
const auth = await authorizeB2(keyId, applicationKey);
|
|
128
|
+
const bucketId = await getB2BucketId(keyId, applicationKey, bucketName);
|
|
129
|
+
const urlRes = await fetch(`${auth.apiUrl}/b2api/v2/b2_get_upload_url`, {
|
|
130
|
+
method: "POST",
|
|
131
|
+
headers: { Authorization: auth.authorizationToken, "Content-Type": "application/json" },
|
|
132
|
+
body: JSON.stringify({ bucketId })
|
|
133
|
+
});
|
|
134
|
+
if (!urlRes.ok) throw new Error(`B2 get upload url failed (${urlRes.status})`);
|
|
135
|
+
const { uploadUrl, authorizationToken } = await urlRes.json();
|
|
136
|
+
const encodedFileName = encodeURIComponent(fileName).replace(/%2F/g, "/");
|
|
137
|
+
const uploadRes = await fetch(uploadUrl, {
|
|
138
|
+
method: "POST",
|
|
139
|
+
headers: {
|
|
140
|
+
Authorization: authorizationToken,
|
|
141
|
+
"X-Bz-File-Name": encodedFileName,
|
|
142
|
+
"Content-Type": contentType,
|
|
143
|
+
"Content-Length": String(buffer.byteLength),
|
|
144
|
+
"X-Bz-Content-Sha1": "do_not_verify"
|
|
145
|
+
},
|
|
146
|
+
body: buffer
|
|
147
|
+
});
|
|
148
|
+
if (!uploadRes.ok) throw new Error(`B2 upload failed for ${fileName} (${uploadRes.status}): ${await uploadRes.text()}`);
|
|
149
|
+
return uploadRes.json();
|
|
150
|
+
}
|
|
151
|
+
async function b2DownloadFile(keyId, applicationKey, bucketName, fileName) {
|
|
152
|
+
const auth = await authorizeB2(keyId, applicationKey);
|
|
153
|
+
const encodedName = encodeURIComponent(fileName).replace(/%2F/g, "/");
|
|
154
|
+
const res = await fetch(`${auth.downloadUrl}/file/${bucketName}/${encodedName}`, { headers: { Authorization: auth.authorizationToken } });
|
|
155
|
+
if (res.status === 404) return null;
|
|
156
|
+
if (!res.ok) throw new Error(`B2 download failed for ${fileName} (${res.status})`);
|
|
157
|
+
return new Uint8Array(await res.arrayBuffer());
|
|
158
|
+
}
|
|
159
|
+
async function b2ListFileNames(keyId, applicationKey, bucketName, prefix = "") {
|
|
160
|
+
const auth = await authorizeB2(keyId, applicationKey);
|
|
161
|
+
const bucketId = await getB2BucketId(keyId, applicationKey, bucketName);
|
|
162
|
+
const res = await fetch(`${auth.apiUrl}/b2api/v2/b2_list_file_names`, {
|
|
163
|
+
method: "POST",
|
|
164
|
+
headers: { Authorization: auth.authorizationToken, "Content-Type": "application/json" },
|
|
165
|
+
body: JSON.stringify({ bucketId, prefix, maxFileCount: 1e3 })
|
|
166
|
+
});
|
|
167
|
+
if (!res.ok) throw new Error(`B2 list files failed (${res.status})`);
|
|
168
|
+
const data = await res.json();
|
|
169
|
+
return data.files || [];
|
|
170
|
+
}
|
|
171
|
+
async function b2DeleteFileVersion(keyId, applicationKey, fileName, fileId) {
|
|
172
|
+
const auth = await authorizeB2(keyId, applicationKey);
|
|
173
|
+
const res = await fetch(`${auth.apiUrl}/b2api/v2/b2_delete_file_version`, {
|
|
174
|
+
method: "POST",
|
|
175
|
+
headers: { Authorization: auth.authorizationToken, "Content-Type": "application/json" },
|
|
176
|
+
body: JSON.stringify({ fileName, fileId })
|
|
177
|
+
});
|
|
178
|
+
if (!res.ok) throw new Error(`B2 delete file version failed (${res.status})`);
|
|
179
|
+
return res.json();
|
|
180
|
+
}
|
|
181
|
+
async function b2DeleteFolder(keyId, applicationKey, bucketName, folderPrefix) {
|
|
182
|
+
const cleanPrefix = folderPrefix.replace(/\/+$/, "") + "/";
|
|
183
|
+
const files = await b2ListFileNames(keyId, applicationKey, bucketName, cleanPrefix);
|
|
184
|
+
let deletedCount = 0;
|
|
185
|
+
for (const file of files) {
|
|
186
|
+
await b2DeleteFileVersion(keyId, applicationKey, file.fileName, file.fileId);
|
|
187
|
+
deletedCount++;
|
|
188
|
+
}
|
|
189
|
+
return { success: true, deletedCount };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export {
|
|
193
|
+
cleanDbUrl,
|
|
194
|
+
getUnifiedDbUrl,
|
|
195
|
+
queryUnifiedDb,
|
|
196
|
+
b2ListBuckets,
|
|
197
|
+
getB2BucketId,
|
|
198
|
+
b2UploadFile,
|
|
199
|
+
b2DownloadFile,
|
|
200
|
+
b2ListFileNames,
|
|
201
|
+
b2DeleteFileVersion,
|
|
202
|
+
b2DeleteFolder
|
|
203
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
workspaceGraphService
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KSZ67VZJ.js";
|
|
4
4
|
import {
|
|
5
5
|
getSrklAccounts,
|
|
6
6
|
srklListBackblazeBuckets
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-N4Z57FVR.js";
|
|
8
8
|
import {
|
|
9
9
|
StorageAdapterFactory
|
|
10
10
|
} from "./chunk-J2J24JVC.js";
|
|
@@ -20,9 +20,11 @@ import {
|
|
|
20
20
|
deleteWorkspace,
|
|
21
21
|
findUserWorkspace,
|
|
22
22
|
getWorkspaces,
|
|
23
|
-
queryUnifiedDb,
|
|
24
23
|
updateWorkspace
|
|
25
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-6K75XXFD.js";
|
|
25
|
+
import {
|
|
26
|
+
queryUnifiedDb
|
|
27
|
+
} from "./chunk-VAFCR2MS.js";
|
|
26
28
|
import {
|
|
27
29
|
RateLimiter,
|
|
28
30
|
SessionManager,
|
|
@@ -108,6 +108,7 @@ declare class WebContainerRuntime {
|
|
|
108
108
|
exitCode: any;
|
|
109
109
|
output: string;
|
|
110
110
|
}>;
|
|
111
|
+
spawnCommand(command: string, args?: string[], cwd?: string, env?: Record<string, string | number | boolean>): Promise<any>;
|
|
111
112
|
teardown(): Promise<{
|
|
112
113
|
tornDown: boolean;
|
|
113
114
|
}>;
|
|
@@ -199,4 +200,102 @@ declare class CodeDiagnosticsService {
|
|
|
199
200
|
}
|
|
200
201
|
declare const codeDiagnosticsService: CodeDiagnosticsService;
|
|
201
202
|
|
|
202
|
-
|
|
203
|
+
interface TypeScriptLanguageServerStartInput {
|
|
204
|
+
cwd?: string;
|
|
205
|
+
install?: boolean;
|
|
206
|
+
version?: string;
|
|
207
|
+
}
|
|
208
|
+
interface TypeScriptLanguageServerRequestInput {
|
|
209
|
+
id: number | string;
|
|
210
|
+
method: string;
|
|
211
|
+
params?: unknown;
|
|
212
|
+
}
|
|
213
|
+
interface TypeScriptLanguageServerNotificationInput {
|
|
214
|
+
method: string;
|
|
215
|
+
params?: unknown;
|
|
216
|
+
}
|
|
217
|
+
interface TypeScriptLanguageServerResponse {
|
|
218
|
+
jsonrpc: '2.0';
|
|
219
|
+
id?: number | string | null;
|
|
220
|
+
result?: unknown;
|
|
221
|
+
error?: {
|
|
222
|
+
code: number;
|
|
223
|
+
message: string;
|
|
224
|
+
data?: unknown;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
interface TypeScriptLanguageServerStatus {
|
|
228
|
+
running: boolean;
|
|
229
|
+
cwd?: string;
|
|
230
|
+
package: string;
|
|
231
|
+
version: string;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
declare const TYPESCRIPT_LANGUAGE_SERVER_PACKAGE = "typescript-language-server";
|
|
235
|
+
declare const TYPESCRIPT_LANGUAGE_SERVER_VERSION = "6.0.2";
|
|
236
|
+
declare const TypeScriptLanguageServerServiceDefinition: ServiceDefinition;
|
|
237
|
+
declare const TypeScriptLanguageServerServiceFacade: {
|
|
238
|
+
id: string;
|
|
239
|
+
name: string;
|
|
240
|
+
version: string;
|
|
241
|
+
runtime: "client";
|
|
242
|
+
deployment: "local";
|
|
243
|
+
definition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
|
|
244
|
+
createInstance: () => _ultrst_armada_krnl.ServiceInstance<Record<string, unknown>, Record<string, unknown>>;
|
|
245
|
+
execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
type AgentHarnessProvider = 'deepseek' | 'openai' | 'google';
|
|
249
|
+
interface AgentHarnessRunInput {
|
|
250
|
+
provider: AgentHarnessProvider;
|
|
251
|
+
prompt: string;
|
|
252
|
+
cwd?: string;
|
|
253
|
+
profile?: string;
|
|
254
|
+
timeoutMs?: number;
|
|
255
|
+
env?: Record<string, string>;
|
|
256
|
+
}
|
|
257
|
+
interface AgentHarnessResult {
|
|
258
|
+
provider: AgentHarnessProvider;
|
|
259
|
+
ok: boolean;
|
|
260
|
+
exitCode: number;
|
|
261
|
+
output: string;
|
|
262
|
+
durationMs: number;
|
|
263
|
+
command?: string;
|
|
264
|
+
}
|
|
265
|
+
interface AgentHarnessProviderInfo {
|
|
266
|
+
id: AgentHarnessProvider;
|
|
267
|
+
name: string;
|
|
268
|
+
package: string;
|
|
269
|
+
capabilities: string[];
|
|
270
|
+
implemented: boolean;
|
|
271
|
+
}
|
|
272
|
+
interface AgentHarnessServiceContract {
|
|
273
|
+
providers(): AgentHarnessProviderInfo[];
|
|
274
|
+
run(input: AgentHarnessRunInput): Promise<AgentHarnessResult>;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
declare class AgentHarnessRuntime {
|
|
278
|
+
private readonly runtime;
|
|
279
|
+
constructor(runtime?: WebContainerRuntime);
|
|
280
|
+
providers(): {
|
|
281
|
+
capabilities: string[];
|
|
282
|
+
id: AgentHarnessProvider;
|
|
283
|
+
name: string;
|
|
284
|
+
package: string;
|
|
285
|
+
implemented: boolean;
|
|
286
|
+
}[];
|
|
287
|
+
run(input: AgentHarnessRunInput): Promise<AgentHarnessResult>;
|
|
288
|
+
}
|
|
289
|
+
declare const AgentHarnessServiceDefinition: ServiceDefinition;
|
|
290
|
+
declare const AgentHarnessServiceFacade: {
|
|
291
|
+
id: string;
|
|
292
|
+
name: string;
|
|
293
|
+
version: string;
|
|
294
|
+
runtime: "client";
|
|
295
|
+
deployment: "local";
|
|
296
|
+
definition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
|
|
297
|
+
createInstance: () => _ultrst_armada_krnl.ServiceInstance<Record<string, unknown>, Record<string, unknown>>;
|
|
298
|
+
execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
export { type AgentHarnessProvider, type AgentHarnessProviderInfo, type AgentHarnessResult, type AgentHarnessRunInput, AgentHarnessRuntime, type AgentHarnessServiceContract, AgentHarnessServiceDefinition, AgentHarnessServiceFacade, type CodeDiagnosticsInput, type CodeDiagnosticsResult, CodeDiagnosticsService, type CodeValidationInput, type CodeValidationResult, CodeValidationRuntime, CodeValidationServiceDefinition, CodeValidationServiceFacade, type DevelopmentProvider, type DevelopmentRequest, type DevelopmentResult, DevelopmentRuntime, type DevelopmentServiceContract, DevelopmentServiceDefinition, DevelopmentServiceFacade, type DevelopmentTask, GitHubActionsClient, type GitHubActionsConfig, GitHubActionsServiceDefinition, GitHubActionsServiceFacade, TYPESCRIPT_LANGUAGE_SERVER_PACKAGE, TYPESCRIPT_LANGUAGE_SERVER_VERSION, type TypeScriptLanguageServerNotificationInput, type TypeScriptLanguageServerRequestInput, type TypeScriptLanguageServerResponse, TypeScriptLanguageServerServiceDefinition, TypeScriptLanguageServerServiceFacade, type TypeScriptLanguageServerStartInput, type TypeScriptLanguageServerStatus, type ValidationDiagnostic, type ValidationLayer, type WebContainerCommand, type WebContainerRunCommandInput, WebContainerRuntime, WebContainerServiceDefinition, WebContainerServiceFacade, type WorkflowRun, codeDiagnosticsService, resolveDevelopmentCommand };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AgentHarnessRuntime,
|
|
3
|
+
AgentHarnessServiceDefinition,
|
|
4
|
+
AgentHarnessServiceFacade,
|
|
2
5
|
CodeDiagnosticsService,
|
|
3
6
|
CodeValidationRuntime,
|
|
4
7
|
CodeValidationServiceDefinition,
|
|
@@ -9,14 +12,21 @@ import {
|
|
|
9
12
|
GitHubActionsClient,
|
|
10
13
|
GitHubActionsServiceDefinition,
|
|
11
14
|
GitHubActionsServiceFacade,
|
|
15
|
+
TYPESCRIPT_LANGUAGE_SERVER_PACKAGE,
|
|
16
|
+
TYPESCRIPT_LANGUAGE_SERVER_VERSION,
|
|
17
|
+
TypeScriptLanguageServerServiceDefinition,
|
|
18
|
+
TypeScriptLanguageServerServiceFacade,
|
|
12
19
|
WebContainerRuntime,
|
|
13
20
|
WebContainerServiceDefinition,
|
|
14
21
|
WebContainerServiceFacade,
|
|
15
22
|
codeDiagnosticsService,
|
|
16
23
|
resolveDevelopmentCommand
|
|
17
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-SQGBAWZN.js";
|
|
18
25
|
import "../chunk-TY32TUNI.js";
|
|
19
26
|
export {
|
|
27
|
+
AgentHarnessRuntime,
|
|
28
|
+
AgentHarnessServiceDefinition,
|
|
29
|
+
AgentHarnessServiceFacade,
|
|
20
30
|
CodeDiagnosticsService,
|
|
21
31
|
CodeValidationRuntime,
|
|
22
32
|
CodeValidationServiceDefinition,
|
|
@@ -27,6 +37,10 @@ export {
|
|
|
27
37
|
GitHubActionsClient,
|
|
28
38
|
GitHubActionsServiceDefinition,
|
|
29
39
|
GitHubActionsServiceFacade,
|
|
40
|
+
TYPESCRIPT_LANGUAGE_SERVER_PACKAGE,
|
|
41
|
+
TYPESCRIPT_LANGUAGE_SERVER_VERSION,
|
|
42
|
+
TypeScriptLanguageServerServiceDefinition,
|
|
43
|
+
TypeScriptLanguageServerServiceFacade,
|
|
30
44
|
WebContainerRuntime,
|
|
31
45
|
WebContainerServiceDefinition,
|
|
32
46
|
WebContainerServiceFacade,
|