stratagate-dsh 0.2.66 → 0.2.68

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/dist/plugin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
2
  import { mkdir as mkdir2 } from "node:fs/promises";
3
- import { dirname as dirname2 } from "node:path";
3
+ import { dirname as dirname3 } from "node:path";
4
4
  import { createUserMessage as createUserMessage3 } from "@deepseek-ai/dsh-llm";
5
5
 
6
6
  // src/config.ts
@@ -5414,8 +5414,9 @@ function isOffRejection(error) {
5414
5414
  // src/runtime.ts
5415
5415
  import { createHash } from "node:crypto";
5416
5416
  import { existsSync } from "node:fs";
5417
- import { resolve } from "node:path";
5417
+ import { dirname, resolve } from "node:path";
5418
5418
  import { createUserMessage as createUserMessage2 } from "@deepseek-ai/dsh-llm";
5419
+ import { openNativePath } from "@deepseek-ai/dsh-native-command";
5419
5420
 
5420
5421
  // src/fold.ts
5421
5422
  function renderBlocks(blocks) {
@@ -5758,12 +5759,13 @@ function feedbackDraftUrl(namespace, origin) {
5758
5759
  var StrataGateRuntime = class {
5759
5760
  constructor(config, models, onIngestError = () => {
5760
5761
  }, flushNativeSession = async () => {
5761
- }, feedbackOrigin = () => void 0) {
5762
+ }, feedbackOrigin = () => void 0, openPath = openNativePath) {
5762
5763
  this.config = config;
5763
5764
  this.models = models;
5764
5765
  this.onIngestError = onIngestError;
5765
5766
  this.flushNativeSession = flushNativeSession;
5766
5767
  this.feedbackOrigin = feedbackOrigin;
5768
+ this.openPath = openPath;
5767
5769
  this.blockTurnSize = config.blockTurnSize;
5768
5770
  this.blockDecayLambda = config.blockDecayLambda;
5769
5771
  this.scheduleBackgroundWorker(BACKGROUND_WORKER_INITIAL_DELAY_MS);
@@ -5773,6 +5775,7 @@ var StrataGateRuntime = class {
5773
5775
  onIngestError;
5774
5776
  flushNativeSession;
5775
5777
  feedbackOrigin;
5778
+ openPath;
5776
5779
  folder = new TurnFolder();
5777
5780
  spaces = /* @__PURE__ */ new Map();
5778
5781
  batches = /* @__PURE__ */ new Map();
@@ -6838,6 +6841,16 @@ var StrataGateRuntime = class {
6838
6841
  await update;
6839
6842
  return value;
6840
6843
  }
6844
+ adminDataDirectory() {
6845
+ if (this.config.database === ":memory:") return null;
6846
+ return dirname(resolve(this.config.database));
6847
+ }
6848
+ async adminOpenDataDirectory(signal) {
6849
+ const path = this.adminDataDirectory();
6850
+ if (!path) throw new Error("StrataGate is using in-memory storage, so no data directory is available");
6851
+ await this.openPath(path, signal);
6852
+ return { opened: true, path };
6853
+ }
6841
6854
  async adminExpandBlock(namespace, id, target) {
6842
6855
  const key = namespace.trim();
6843
6856
  if (!key) throw new TypeError("StrataGate admin namespace must not be empty");
@@ -8071,6 +8084,7 @@ async function overview(runtime, cachedEntries) {
8071
8084
  return {
8072
8085
  readonly: true,
8073
8086
  settingsWritable: true,
8087
+ dataDirectory: runtime.adminDataDirectory?.() ?? null,
8074
8088
  pluginVersion: STRATAGATE_DSH_VERSION,
8075
8089
  harnessVersion: installedPackageVersion(["@deepseek-ai/dsh", "@deepseek-ai/dsh-session"]),
8076
8090
  namespaces: rows
@@ -8711,6 +8725,9 @@ async function handleAdminRequest(runtime, req, res) {
8711
8725
  } else if (path === "/api/stratagate/settings") {
8712
8726
  if (req.method !== "PATCH") throw new AdminHttpError(405, "StrataGate settings require PATCH");
8713
8727
  sendJson(res, 200, await updateSettings(runtime, url));
8728
+ } else if (path === "/api/stratagate/storage/open-directory") {
8729
+ if (req.method !== "POST") throw new AdminHttpError(405, "StrataGate data directory open requires POST");
8730
+ sendJson(res, 200, await runtime.adminOpenDataDirectory(AbortSignal.timeout(15e3)));
8714
8731
  } else if (path === "/api/stratagate/blocks/expand") {
8715
8732
  if (req.method !== "PATCH") throw new AdminHttpError(405, "StrataGate Block expansion requires PATCH");
8716
8733
  sendJson(res, 200, await expandBlock(runtime, url));
@@ -8770,7 +8787,7 @@ import {
8770
8787
  unlink,
8771
8788
  writeFile
8772
8789
  } from "node:fs/promises";
8773
- import { basename, dirname, join } from "node:path";
8790
+ import { basename, dirname as dirname2, join } from "node:path";
8774
8791
  import { createHash as createHash3, randomUUID } from "node:crypto";
8775
8792
  import { encodeSeqRanges } from "@deepseek-ai/dsh-session";
8776
8793
  var LEGACY_EVENT_TYPE = "stratagate/memory-citations";
@@ -8982,8 +8999,8 @@ async function exists(path) {
8982
8999
  }
8983
9000
  }
8984
9001
  async function publishExclusive(path, bytes) {
8985
- await mkdir(dirname(path), { recursive: true });
8986
- const temporary = join(dirname(path), `.${basename(path)}.stratagate-${randomUUID()}.tmp`);
9002
+ await mkdir(dirname2(path), { recursive: true });
9003
+ const temporary = join(dirname2(path), `.${basename(path)}.stratagate-${randomUUID()}.tmp`);
8987
9004
  const handle = await open(temporary, "wx", 384);
8988
9005
  try {
8989
9006
  await handle.writeFile(bytes);
@@ -9109,7 +9126,7 @@ async function apply(ctx, config) {
9109
9126
  if (legacyMigration.migrated > 0) {
9110
9127
  ctx.logger.info(`stratagate-memory prepared ${legacyMigration.migrated} legacy Session generation(s) for DSH 0.1.5`);
9111
9128
  }
9112
- await mkdir2(dirname2(resolved.database), { recursive: true });
9129
+ await mkdir2(dirname3(resolved.database), { recursive: true });
9113
9130
  const models = new DshModelBridge(ctx, resolved);
9114
9131
  const runtime = new StrataGateRuntime(resolved, models, (error) => {
9115
9132
  ctx.logger.error(`stratagate-memory ingestion failed: ${renderError(error)}`);