@galaxy-stack/blackhole-cli 2.1.34 → 2.1.35

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.
@@ -17,7 +17,7 @@ import { blueprintPathFor, readBlueprint, validateBlueprint, writeBlueprint } fr
17
17
  import { registerJourneyHost } from "./journey-host.js";
18
18
  import { advanceRun, cancelRun, createRun, decideRun, listRuns, readRun, runPath, summarizeRun, writeRun } from "./journey-run.js";
19
19
  import { spawn } from "node:child_process";
20
- import { appendFileSync, mkdirSync } from "node:fs";
20
+ import { appendFileSync, existsSync, mkdirSync, readdirSync, writeFileSync } from "node:fs";
21
21
  import { join } from "node:path";
22
22
 
23
23
  /**
@@ -487,6 +487,77 @@ async function removeStoredSession(ctx, home, sessionId, options = {}) {
487
487
  * @param ctx - plugin context, used to reach the Session services lazily per request.
488
488
  * @param connectionCtx - the injected connection scope that owns route registration.
489
489
  */
490
+ /*
491
+ * The optional features a profile can add. Both ship with this DSH but stay out of the composition until the
492
+ * owner asks for them, and the only place DSH records that is `dsh.profile.bundles` in a profile's package.json.
493
+ */
494
+ const FEATURES_PATH = "/api/galaxy/features";
495
+ const GBH_FEATURE_BUNDLES = [
496
+ { id: "agentTeams", name: "@deepseek-ai/dsh-experimental-agent-team-profile" },
497
+ { id: "automationTasks", name: "@deepseek-ai/dsh-experimental-schedule-bundle" },
498
+ ];
499
+
500
+ /** Every profile this home holds. Normally one, the `web` profile this GUI is served from. */
501
+ function profileFiles(home) {
502
+ const root = join(home, "profiles");
503
+ if (!existsSync(root)) return [];
504
+ return readdirSync(root).map(name => join(root, name, "package.json")).filter(existsSync);
505
+ }
506
+
507
+ /** Which optional features the profiles have turned on. Absent means off, which is the shipped default. */
508
+ function readFeatureState(home) {
509
+ const state = {};
510
+ for (const feature of GBH_FEATURE_BUNDLES) state[feature.id] = false;
511
+ for (const file of profileFiles(home)) {
512
+ let parsed;
513
+ try { parsed = JSON.parse(readFileSync(file, "utf8")); } catch { continue; }
514
+ const bundles = parsed?.dsh?.profile?.bundles;
515
+ if (!Array.isArray(bundles)) continue;
516
+ for (const feature of GBH_FEATURE_BUNDLES) if (bundles.includes(feature.name)) state[feature.id] = true;
517
+ }
518
+ return state;
519
+ }
520
+
521
+ /** Turn the requested features on or off, and report how many profiles changed. */
522
+ function writeFeatureState(home, wanted) {
523
+ let touched = 0;
524
+ for (const file of profileFiles(home)) {
525
+ let parsed;
526
+ try { parsed = JSON.parse(readFileSync(file, "utf8")); } catch { continue; }
527
+ const profile = parsed?.dsh?.profile;
528
+ if (profile === undefined || !Array.isArray(profile.bundles)) continue;
529
+ let changed = false;
530
+ for (const feature of GBH_FEATURE_BUNDLES) {
531
+ const want = wanted?.[feature.id];
532
+ if (typeof want !== "boolean" || want === profile.bundles.includes(feature.name)) continue;
533
+ profile.bundles = want
534
+ ? [...profile.bundles, feature.name]
535
+ : profile.bundles.filter(name => name !== feature.name);
536
+ changed = true;
537
+ }
538
+ if (!changed) continue;
539
+ writeFileSync(file, JSON.stringify(parsed, null, 2) + "\n", "utf8");
540
+ touched += 1;
541
+ }
542
+ return touched;
543
+ }
544
+
545
+ function registerFeatureRoutes(ctx, connectionCtx) {
546
+ const home = resolveHome();
547
+ connectionCtx.connection.fetch.register({
548
+ path: FEATURES_PATH,
549
+ methods: ["GET", "POST"],
550
+ requestBody: "buffered",
551
+ fetch: async (request) => {
552
+ if (request.method !== "POST") return jsonResponse({ features: readFeatureState(home) });
553
+ let body = {};
554
+ try { body = JSON.parse(await request.text()); } catch { body = {}; }
555
+ const touched = writeFeatureState(home, body?.features);
556
+ return jsonResponse({ features: readFeatureState(home), profiles: touched });
557
+ },
558
+ });
559
+ }
560
+
490
561
  function registerSessionRoutes(ctx, connectionCtx) {
491
562
  const home = resolveHome();
492
563
  try {
@@ -966,6 +1037,7 @@ function apply(ctx) {
966
1037
  });
967
1038
  ctx.inject(["web"], (webCtx) => webCtx.web.registerSearchProvider(createGalaxySearchProvider()));
968
1039
  ctx.inject(["connection"], (connectionCtx) => registerSessionRoutes(ctx, connectionCtx));
1040
+ ctx.inject(["connection"], (connectionCtx) => registerFeatureRoutes(ctx, connectionCtx));
969
1041
  ctx.inject(["connection"], (connectionCtx) => registerJourneyRoutes(ctx, connectionCtx));
970
1042
  ctx.inject(["connection"], (connectionCtx) => registerUpdateRoutes(ctx, connectionCtx));
971
1043
  ctx.inject(["connection"], (connectionCtx) => {
@@ -858,7 +858,7 @@
858
858
  "message.trigger.explanation": "Thông báo này đã kích hoạt phản hồi.",
859
859
  "message.turnProcess.worked": "Đã làm việc",
860
860
  "message.turnProcess.deepDivingFor": "Đang suy nghĩ trong {duration}",
861
- "message.turnProcess.took": "Mất {duration}",
861
+ "message.turnProcess.took": "Xong sau ",
862
862
  "message.turnProcess.failed": "Thất bại",
863
863
  "view.chat": "Hội thoại",
864
864
  "image.open": "Xem ảnh đầy đủ",