stratagate-dsh 0.3.20 → 0.3.21
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/CHANGELOG.md +7 -0
- package/LICENSE +21 -21
- package/dist/client.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +38 -24
- package/dist/plugin.js.map +1 -1
- package/docs/DSH.md +290 -290
- package/docs/DSH.zh-CN.md +257 -257
- package/docs/benchmarks/issue-128-windows-review.json +104 -104
- package/docs/benchmarks/issue-128-windows.json +103 -103
- package/docs/dreaming-agent.md +69 -69
- package/docs/feedback.md +50 -50
- package/docs/issue-128-lease-cache-review-followup.md +55 -55
- package/docs/issue-128-review-followup.md +58 -58
- package/docs/npm-release.md +52 -52
- package/docs/validation/frontend-feedback-20261021/background-refresh-failed.png +0 -0
- package/docs/validation/frontend-feedback-20261021/browser-results.json +334 -0
- package/docs/validation/frontend-feedback-20261021/first-read-graph.png +0 -0
- package/docs/validation/frontend-feedback-20261021/first-read-profile.png +0 -0
- package/docs/validation/frontend-feedback-20261021/first-read-short.png +0 -0
- package/docs/validation/frontend-feedback-20261021/profile-conflict.png +0 -0
- package/docs/validation/frontend-feedback-20261021/profile-save-regression.json +466 -0
- package/docs/validation/frontend-feedback-20261021/report.json +99 -0
- package/docs/validation/frontend-feedback-20261021/settings-saved-read-failed.png +0 -0
- package/docs/validation/frontend-feedback-20261021/settings-unknown.png +0 -0
- package/docs/validation/frontend-feedback-20261021/unit-results.json +1 -0
- package/docs/validation/issue119.md +41 -0
- package/docs/validation/workspace-cleanup-20261020.md +36 -0
- package/package.json +1 -1
- package/screenshots.json +8 -8
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dsh-host-resolution.ts","../src/bootstrap.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs'\r\nimport { createRequire, registerHooks } from 'node:module'\r\nimport { dirname, isAbsolute, join, relative } from 'node:path'\r\nimport { fileURLToPath, pathToFileURL } from 'node:url'\r\n\r\nconst HOST_PACKAGES = [\r\n '@deepseek-ai/cordis',\r\n '@deepseek-ai/dsh-agent-default-model',\r\n '@deepseek-ai/dsh-client-ui-conversation',\r\n '@deepseek-ai/dsh-llm',\r\n '@deepseek-ai/dsh-native-command',\r\n '@deepseek-ai/dsh-session',\r\n '@deepseek-ai/dsh-session-format',\r\n '@deepseek-ai/dsh-session-format-catalog',\r\n '@deepseek-ai/dsh-session-format-v0-to-v1',\r\n '@deepseek-ai/dsh-settings',\r\n '@deepseek-ai/dsh-system-prompt',\r\n '@deepseek-ai/dsh-tools',\r\n '@deepseek-ai/schemastery',\r\n] as const\r\n\r\nconst installedHooks = Symbol.for('stratagate.dsh-host-resolution.v1')\r\n\r\nfunction isWithin(path: string, root: string): boolean {\r\n const child = relative(root, path)\r\n return child === '' || (!child.startsWith('..') && !isAbsolute(child))\r\n}\r\n\r\nfunction profileDirectory(start: string): string | undefined {\r\n let directory = start\r\n for (;;) {\r\n const manifestPath = join(directory, 'package.json')\r\n if (existsSync(manifestPath)) {\r\n try {\r\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as { dsh?: { profile?: unknown } }\r\n if (manifest.dsh?.profile && typeof manifest.dsh.profile === 'object') return directory\r\n } catch {}\r\n }\r\n const parent = dirname(directory)\r\n if (parent === directory) return undefined\r\n directory = parent\r\n }\r\n}\r\n\r\nfunction hostPackage(specifier: string): boolean {\r\n return HOST_PACKAGES.some((name) => specifier === name || specifier.startsWith(`${name}/`))\r\n}\r\n\r\n/**\r\n * Force only StrataGate's DSH imports through the installation-owned fallback\r\n * created by DSH. The hook neither deletes nor rewrites the profile's package\r\n * tree, and imports belonging to the host or other plugins are untouched.\r\n */\r\nexport function installDshHostResolution(moduleUrl: string): boolean {\r\n const packageDirectory = dirname(dirname(fileURLToPath(moduleUrl)))\r\n const profile = profileDirectory(packageDirectory)\r\n if (!profile) return false\r\n\r\n const globalState = globalThis as typeof globalThis & { [installedHooks]?: Set<string> }\r\n const installed = globalState[installedHooks] ??= new Set<string>()\r\n const key = `${profile}\\u0000${packageDirectory}`\r\n if (installed.has(key)) return true\r\n\r\n const fallbackModules = join(dirname(profile), 'node_modules')\r\n const hostRequire = createRequire(join(fallbackModules, '.stratagate-host-resolution.cjs'))\r\n registerHooks({\r\n resolve(specifier, context, nextResolve) {\r\n const parent = context.parentURL?.startsWith('file:') ? fileURLToPath(context.parentURL) : undefined\r\n if (!hostPackage(specifier) || !parent || !isWithin(parent, packageDirectory)) {\r\n return nextResolve(specifier, context)\r\n }\r\n try {\r\n return { url: pathToFileURL(hostRequire.resolve(specifier)).href, shortCircuit: true }\r\n } catch (cause) {\r\n if (specifier === '@deepseek-ai/dsh-session-format-v0-to-v1'\r\n || specifier === '@deepseek-ai/dsh-session-format-catalog') {\r\n return nextResolve(specifier, context)\r\n }\r\n throw new Error(\r\n `StrataGate cannot resolve host-provided DSH package ${JSON.stringify(specifier)} from ${fallbackModules}. `\r\n + 'Start StrataGate through the DSH profile launcher so the host can prepare its module fallback.',\r\n { cause },\r\n )\r\n }\r\n },\r\n })\r\n installed.add(key)\r\n return true\r\n}\r\n","import { installDshHostResolution } from './dsh-host-resolution.js'\n\n// DSH prepares its installation-owned module fallback before it imports a\n// profile bundle. Install the narrowly-scoped resolver first, then load the\n// implementation so stale profile-local peers cannot win ESM resolution.\ninstallDshHostResolution(import.meta.url)\n\n// This file and src/index.ts are separate tsup entries. The runtime path is\n// intentionally external so the implementation is instantiated only after\n// the resolver above is active.\n// @ts-expect-error dist/plugin.js is emitted from src/index.ts during build.\nconst plugin = await import('./plugin.js') as typeof import('./index.js')\n\nexport const name = plugin.name\nexport const inject = plugin.inject\nexport const STRATAGATE_SETTINGS_NAMESPACE = plugin.STRATAGATE_SETTINGS_NAMESPACE\nexport const Config = plugin.Config\nexport const apply = plugin.apply\nexport type PluginConfig = import('./index.js').PluginConfig\n"],"mappings":";AAAA,SAAS,YAAY,oBAAoB;AACzC,SAA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,IAAI,GAAG,EAAG,QAAO;AAE/B,QAAM,kBAAkB,KAAK,QAAQ,OAAO,GAAG,cAAc;AAC7D,QAAM,cAAc,cAAc,KAAK,iBAAiB,iCAAiC,CAAC;AAC1F,gBAAc;AAAA,IACZ,QAAQ,WAAW,SAAS,aAAa;AACvC,YAAM,SAAS,QAAQ,WAAW,WAAW,OAAO,IAAI,cAAc,QAAQ,SAAS,IAAI;AAC3F,UAAI,CAAC,YAAY,SAAS,KAAK,CAAC,UAAU,CAAC,SAAS,QAAQ,gBAAgB,GAAG;AAC7E,eAAO,YAAY,WAAW,OAAO;AAAA,MACvC;AACA,UAAI;AACF,eAAO,EAAE,KAAK,cAAc,YAAY,QAAQ,SAAS,CAAC,EAAE,MAAM,cAAc,KAAK;AAAA,MACvF,SAAS,OAAO;AACd,YAAI,cAAc,8CACb,cAAc,2CAA2C;AAC5D,iBAAO,YAAY,WAAW,OAAO;AAAA,QACvC;AACA,cAAM,IAAI;AAAA,UACR,uDAAuD,KAAK,UAAU,SAAS,CAAC,SAAS,eAAe;AAAA,UAExG,EAAE,MAAM;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACD,YAAU,IAAI,GAAG;AACjB,SAAO;AACT;;;ACnFA,yBAAyB,YAAY,GAAG;AAMxC,IAAM,SAAS,MAAM,OAAO,aAAa;AAElC,IAAM,OAAO,OAAO;AACpB,IAAM,SAAS,OAAO;AACtB,IAAM,gCAAgC,OAAO;AAC7C,IAAM,SAAS,OAAO;AACtB,IAAM,QAAQ,OAAO;","names":["name"]}
|
|
1
|
+
{"version":3,"sources":["../src/dsh-host-resolution.ts","../src/bootstrap.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs'\r\nimport { createRequire, registerHooks } from 'node:module'\r\nimport { dirname, isAbsolute, join, relative } from 'node:path'\r\nimport { fileURLToPath, pathToFileURL } from 'node:url'\r\n\r\nconst HOST_PACKAGES = [\r\n '@deepseek-ai/cordis',\r\n '@deepseek-ai/dsh-agent-default-model',\r\n '@deepseek-ai/dsh-client-ui-conversation',\r\n '@deepseek-ai/dsh-llm',\r\n '@deepseek-ai/dsh-native-command',\r\n '@deepseek-ai/dsh-session',\r\n '@deepseek-ai/dsh-session-format',\r\n '@deepseek-ai/dsh-session-format-catalog',\r\n '@deepseek-ai/dsh-session-format-v0-to-v1',\r\n '@deepseek-ai/dsh-settings',\r\n '@deepseek-ai/dsh-system-prompt',\r\n '@deepseek-ai/dsh-tools',\r\n '@deepseek-ai/schemastery',\r\n] as const\r\n\r\nconst installedHooks = Symbol.for('stratagate.dsh-host-resolution.v1')\r\n\r\nfunction isWithin(path: string, root: string): boolean {\r\n const child = relative(root, path)\r\n return child === '' || (!child.startsWith('..') && !isAbsolute(child))\r\n}\r\n\r\nfunction profileDirectory(start: string): string | undefined {\r\n let directory = start\r\n for (;;) {\r\n const manifestPath = join(directory, 'package.json')\r\n if (existsSync(manifestPath)) {\r\n try {\r\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as { dsh?: { profile?: unknown } }\r\n if (manifest.dsh?.profile && typeof manifest.dsh.profile === 'object') return directory\r\n } catch {}\r\n }\r\n const parent = dirname(directory)\r\n if (parent === directory) return undefined\r\n directory = parent\r\n }\r\n}\r\n\r\nfunction hostPackage(specifier: string): boolean {\r\n return HOST_PACKAGES.some((name) => specifier === name || specifier.startsWith(`${name}/`))\r\n}\r\n\r\n/**\r\n * Force only StrataGate's DSH imports through the installation-owned fallback\r\n * created by DSH. The hook neither deletes nor rewrites the profile's package\r\n * tree, and imports belonging to the host or other plugins are untouched.\r\n */\r\nexport function installDshHostResolution(moduleUrl: string): boolean {\r\n const packageDirectory = dirname(dirname(fileURLToPath(moduleUrl)))\r\n const profile = profileDirectory(packageDirectory)\r\n if (!profile) return false\r\n\r\n const globalState = globalThis as typeof globalThis & { [installedHooks]?: Set<string> }\r\n const installed = globalState[installedHooks] ??= new Set<string>()\r\n const key = `${profile}\\u0000${packageDirectory}`\r\n if (installed.has(key)) return true\r\n\r\n const fallbackModules = join(dirname(profile), 'node_modules')\r\n const hostRequire = createRequire(join(fallbackModules, '.stratagate-host-resolution.cjs'))\r\n registerHooks({\r\n resolve(specifier, context, nextResolve) {\r\n const parent = context.parentURL?.startsWith('file:') ? fileURLToPath(context.parentURL) : undefined\r\n if (!hostPackage(specifier) || !parent || !isWithin(parent, packageDirectory)) {\r\n return nextResolve(specifier, context)\r\n }\r\n try {\r\n return { url: pathToFileURL(hostRequire.resolve(specifier)).href, shortCircuit: true }\r\n } catch (cause) {\r\n if (specifier === '@deepseek-ai/dsh-session-format-v0-to-v1'\r\n || specifier === '@deepseek-ai/dsh-session-format-catalog') {\r\n return nextResolve(specifier, context)\r\n }\r\n throw new Error(\r\n `StrataGate cannot resolve host-provided DSH package ${JSON.stringify(specifier)} from ${fallbackModules}. `\r\n + 'Start StrataGate through the DSH profile launcher so the host can prepare its module fallback.',\r\n { cause },\r\n )\r\n }\r\n },\r\n })\r\n installed.add(key)\r\n return true\r\n}\r\n","import { installDshHostResolution } from './dsh-host-resolution.js'\r\n\r\n// DSH prepares its installation-owned module fallback before it imports a\r\n// profile bundle. Install the narrowly-scoped resolver first, then load the\r\n// implementation so stale profile-local peers cannot win ESM resolution.\r\ninstallDshHostResolution(import.meta.url)\r\n\r\n// This file and src/index.ts are separate tsup entries. The runtime path is\r\n// intentionally external so the implementation is instantiated only after\r\n// the resolver above is active.\r\n// @ts-expect-error dist/plugin.js is emitted from src/index.ts during build.\r\nconst plugin = await import('./plugin.js') as typeof import('./index.js')\r\n\r\nexport const name = plugin.name\r\nexport const inject = plugin.inject\r\nexport const STRATAGATE_SETTINGS_NAMESPACE = plugin.STRATAGATE_SETTINGS_NAMESPACE\r\nexport const Config = plugin.Config\r\nexport const apply = plugin.apply\r\nexport type PluginConfig = import('./index.js').PluginConfig\r\n"],"mappings":";AAAA,SAAS,YAAY,oBAAoB;AACzC,SAAS,eAAe,qBAAqB;AAC7C,SAAS,SAAS,YAAY,MAAM,gBAA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QAAQ,OAAO,GAAG,cAAc;AAC7D,QAAM,cAAc,cAAc,KAAK,iBAAiB,iCAAiC,CAAC;AAC1F,gBAAc;AAAA,IACZ,QAAQ,WAAW,SAAS,aAAa;AACvC,YAAM,SAAS,QAAQ,WAAW,WAAW,OAAO,IAAI,cAAc,QAAQ,SAAS,IAAI;AAC3F,UAAI,CAAC,YAAY,SAAS,KAAK,CAAC,UAAU,CAAC,SAAS,QAAQ,gBAAgB,GAAG;AAC7E,eAAO,YAAY,WAAW,OAAO;AAAA,MACvC;AACA,UAAI;AACF,eAAO,EAAE,KAAK,cAAc,YAAY,QAAQ,SAAS,CAAC,EAAE,MAAM,cAAc,KAAK;AAAA,MACvF,SAAS,OAAO;AACd,YAAI,cAAc,8CACb,cAAc,2CAA2C;AAC5D,iBAAO,YAAY,WAAW,OAAO;AAAA,QACvC;AACA,cAAM,IAAI;AAAA,UACR,uDAAuD,KAAK,UAAU,SAAS,CAAC,SAAS,eAAe;AAAA,UAExG,EAAE,MAAM;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACD,YAAU,IAAI,GAAG;AACjB,SAAO;AACT;;;ACnFA,yBAAyB,YAAY,GAAG;AAMxC,IAAM,SAAS,MAAM,OAAO,aAAa;AAElC,IAAM,OAAO,OAAO;AACpB,IAAM,SAAS,OAAO;AACtB,IAAM,gCAAgC,OAAO;AAC7C,IAAM,SAAS,OAAO;AACtB,IAAM,QAAQ,OAAO;","names":["name"]}
|
package/dist/plugin.js
CHANGED
|
@@ -13795,6 +13795,10 @@ var StrataGateRuntime = class {
|
|
|
13795
13795
|
database.close();
|
|
13796
13796
|
}
|
|
13797
13797
|
}
|
|
13798
|
+
async adminSettings() {
|
|
13799
|
+
await this.settingsTail;
|
|
13800
|
+
return { blockTurnSize: this.blockTurnSize, blockDecayLambda: this.blockDecayLambda, agentMemoryRetrievalWeight: this.agentMemoryRetrievalWeight };
|
|
13801
|
+
}
|
|
13798
13802
|
async adminSetBlockDecayLambda(value) {
|
|
13799
13803
|
if (!Number.isFinite(value) || value < 0) {
|
|
13800
13804
|
throw new TypeError("blockDecayLambda must be a non-negative finite number");
|
|
@@ -16808,11 +16812,12 @@ async function dashboard(runtime, url, ifNoneMatch) {
|
|
|
16808
16812
|
const requestedNamespace = url.searchParams.get("namespace")?.trim() ?? "";
|
|
16809
16813
|
const selected = entries.find(({ namespace }) => namespace === requestedNamespace) ?? entries[0];
|
|
16810
16814
|
const threadId = url.searchParams.get("threadId")?.trim() ?? "";
|
|
16815
|
+
const region = url.searchParams.get("region") || "";
|
|
16811
16816
|
const revisionKey = entries.map(({ namespace, revision }) => `${namespace}:${revision}`).join("|");
|
|
16812
16817
|
const agentMemoryWeight = runtime.adminAgentMemoryRetrievalWeight?.() ?? 1;
|
|
16813
16818
|
const duplicateKey = JSON.stringify(entries.map(({ namespace }) => runtime.adminDuplicateRepairStatus?.(namespace) ?? null));
|
|
16814
16819
|
const etag = `"${createHash6("sha256").update(`${STRATAGATE_DSH_VERSION}\0${TOPIC_DIRECTORY_VIEW_VERSION}\0${revisionKey}\0${selected?.namespace ?? ""}\0${threadId}\0${agentMemoryWeight}\0${duplicateKey}`).digest("base64url").slice(0, 24)}"`;
|
|
16815
|
-
if (ifNoneMatch.split(",").map((value) => value.trim()).includes(etag)) return { etag, notModified: true };
|
|
16820
|
+
if (!region && ifNoneMatch.split(",").map((value) => value.trim()).includes(etag)) return { etag, notModified: true };
|
|
16816
16821
|
const overviewValue = await overview(runtime, entries);
|
|
16817
16822
|
if (!selected) {
|
|
16818
16823
|
return { etag, notModified: false, body: { namespace: null, overview: overviewValue, data: null, processing: false } };
|
|
@@ -16827,42 +16832,50 @@ async function dashboard(runtime, url, ifNoneMatch) {
|
|
|
16827
16832
|
if (limit) target.searchParams.set("limit", limit);
|
|
16828
16833
|
return target;
|
|
16829
16834
|
};
|
|
16830
|
-
const
|
|
16831
|
-
memories(snapshotRuntime, memoryUrl("events", "40")),
|
|
16832
|
-
memories(snapshotRuntime, memoryUrl("graph")),
|
|
16833
|
-
memories(snapshotRuntime, memoryUrl("blocks", "40")),
|
|
16834
|
-
audit(snapshotRuntime, memoryUrl("audit", "100"))
|
|
16835
|
-
|
|
16835
|
+
const readers = {
|
|
16836
|
+
events: () => memories(snapshotRuntime, memoryUrl("events", "40")),
|
|
16837
|
+
graph: () => memories(snapshotRuntime, memoryUrl("graph")),
|
|
16838
|
+
blocks: () => memories(snapshotRuntime, memoryUrl("blocks", "40")),
|
|
16839
|
+
audit: () => audit(snapshotRuntime, memoryUrl("audit", "100")),
|
|
16840
|
+
topics: () => topicDirectoryProjection(selected.snapshot, agentMemoryWeight).data
|
|
16841
|
+
};
|
|
16842
|
+
if (region && !Object.hasOwn(readers, region)) throw new AdminHttpError(400, "Unknown dashboard region");
|
|
16843
|
+
const keys = region ? [region] : Object.keys(readers);
|
|
16844
|
+
const results = await Promise.allSettled(keys.map((key) => Promise.resolve().then(readers[key])));
|
|
16845
|
+
const values = {}, readErrors = {};
|
|
16846
|
+
results.forEach((result, index) => {
|
|
16847
|
+
if (result.status === "fulfilled") values[keys[index]] = result.value;
|
|
16848
|
+
else readErrors[keys[index]] = "Content could not be read";
|
|
16849
|
+
});
|
|
16850
|
+
const { events: eventResult, graph: graphResult, blocks: blockResult, audit: auditResult, topics: topicDirectoryData } = values;
|
|
16836
16851
|
const selectedOverview = overviewValue.namespaces?.find(({ namespace }) => namespace === selected.namespace);
|
|
16837
|
-
const topicDirectoryData = topicDirectoryProjection(selected.snapshot, agentMemoryWeight).data;
|
|
16838
16852
|
return {
|
|
16839
|
-
|
|
16853
|
+
// Never cache a partial failure as a valid unchanged response.
|
|
16854
|
+
etag: region || Object.keys(readErrors).length ? "" : etag,
|
|
16840
16855
|
notModified: false,
|
|
16841
16856
|
body: {
|
|
16842
16857
|
namespace: selected.namespace,
|
|
16843
16858
|
revision: selected.revision,
|
|
16844
16859
|
overview: overviewValue,
|
|
16845
|
-
|
|
16860
|
+
readErrors,
|
|
16861
|
+
processing: Number(selectedOverview?.processingJobs ?? 0) > 0 || selectedOverview?.duplicateRepair?.status === "pending" || topicDirectoryData?.bootstrap != null && topicDirectoryData.bootstrap.total > 0 && (topicDirectoryData.bootstrap.status === "pending" || topicDirectoryData.bootstrap.status === "running"),
|
|
16846
16862
|
data: {
|
|
16847
|
-
events: eventResult.items ?? [],
|
|
16848
|
-
graph: graphResult,
|
|
16849
|
-
blocks: blockResult.items ?? [],
|
|
16850
|
-
|
|
16851
|
-
|
|
16852
|
-
activeThreadId: blockResult.activeThreadId ?? null,
|
|
16853
|
-
audit: auditResult.items ?? [],
|
|
16854
|
-
topicDirectory: topicDirectoryData,
|
|
16863
|
+
...eventResult ? { events: eventResult.items ?? [] } : {},
|
|
16864
|
+
...graphResult ? { graph: graphResult } : {},
|
|
16865
|
+
...blockResult ? { blocks: blockResult.items ?? [], openBlock: blockResult.openBlock ?? null, conversations: blockResult.conversations ?? [], activeThreadId: blockResult.activeThreadId ?? null } : {},
|
|
16866
|
+
...auditResult ? { audit: auditResult.items ?? [] } : {},
|
|
16867
|
+
...topicDirectoryData ? { topicDirectory: topicDirectoryData } : {},
|
|
16855
16868
|
pagination: {
|
|
16856
|
-
events: { total: eventResult.total ?? 0, offset: eventResult.offset ?? 0, limit: eventResult.limit ?? 40 },
|
|
16857
|
-
blocks: { total: blockResult.total ?? 0, offset: blockResult.offset ?? 0, limit: blockResult.limit ?? 40 },
|
|
16858
|
-
audit: { total: auditResult.total ?? 0, offset: auditResult.offset ?? 0, limit: auditResult.limit ?? 100 }
|
|
16869
|
+
...eventResult ? { events: { total: eventResult.total ?? 0, offset: eventResult.offset ?? 0, limit: eventResult.limit ?? 40 } } : {},
|
|
16870
|
+
...blockResult ? { blocks: { total: blockResult.total ?? 0, offset: blockResult.offset ?? 0, limit: blockResult.limit ?? 40 } } : {},
|
|
16871
|
+
...auditResult ? { audit: { total: auditResult.total ?? 0, offset: auditResult.offset ?? 0, limit: auditResult.limit ?? 100 } } : {}
|
|
16859
16872
|
}
|
|
16860
16873
|
}
|
|
16861
16874
|
}
|
|
16862
16875
|
};
|
|
16863
16876
|
}
|
|
16864
16877
|
function sendDashboard(res, result) {
|
|
16865
|
-
res.setHeader("ETag", result.etag);
|
|
16878
|
+
if (result.etag) res.setHeader("ETag", result.etag);
|
|
16866
16879
|
res.setHeader("Cache-Control", "private, no-cache");
|
|
16867
16880
|
if (result.notModified) {
|
|
16868
16881
|
res.statusCode = 304;
|
|
@@ -16947,8 +16960,9 @@ async function handleAdminRequest(runtime, req, res) {
|
|
|
16947
16960
|
} else if (path === "/api/stratagate/profile") {
|
|
16948
16961
|
sendJson(res, 200, await persistentProfile(runtime, req), true);
|
|
16949
16962
|
} else if (path === "/api/stratagate/settings") {
|
|
16950
|
-
if (req.method
|
|
16951
|
-
sendJson(res, 200, await updateSettings(runtime, url));
|
|
16963
|
+
if (req.method === "GET") sendJson(res, 200, await runtime.adminSettings());
|
|
16964
|
+
else if (req.method === "PATCH") sendJson(res, 200, await updateSettings(runtime, url));
|
|
16965
|
+
else throw new AdminHttpError(405, "StrataGate settings require GET or PATCH");
|
|
16952
16966
|
} else if (path === "/api/stratagate/storage/open-directory") {
|
|
16953
16967
|
if (req.method !== "POST") throw new AdminHttpError(405, "StrataGate data directory open requires POST");
|
|
16954
16968
|
sendJson(res, 200, await runtime.adminOpenDataDirectory(AbortSignal.timeout(15e3)));
|