feat(mindspace): add page quota grace write and local delivery guardrails.
Memind CI / Test, build, and release guards (pull_request) Failing after 2s
Memind CI / Test, build, and release guards (pull_request) Failing after 2s
Centralize page HTML quota checks with grace-write semantics across page services and workspace tools, keep localhost MindSpace links clickable in chat display, and expand Page Data/static-page skill plus local dev docs for quota, delivery URLs, and native Aider/OpenHands tooling. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import { resolveAssetWorkspaceRelativePath } from './mindspace-workspace-path.mj
|
||||
import { assetInternals } from './mindspace-assets.mjs';
|
||||
import { runBasicFileScan } from './mindspace-scan.mjs';
|
||||
import { buildWorkspaceStorageKey } from './workspace-storage.mjs';
|
||||
import { assertPageWriteQuota } from './mindspace-space-quota.mjs';
|
||||
|
||||
const SKIP_FILENAMES = new Set(['index.html', '.tkmindhints', '.goosehints', '.ls_output']);
|
||||
const SKIP_ZONE_DIR_NAMES = new Set([
|
||||
@@ -186,10 +187,13 @@ export function createWorkspaceAssetSync({
|
||||
if (!space || space.status !== 'active') {
|
||||
throw Object.assign(new Error('用户空间不可用'), { code: 'space_unavailable' });
|
||||
}
|
||||
const available =
|
||||
asNumber(space.quota_bytes) - asNumber(space.used_bytes) - asNumber(space.reserved_bytes);
|
||||
if (available < buffer.length) {
|
||||
throw Object.assign(new Error('剩余空间不足'), { code: 'quota_exceeded' });
|
||||
try {
|
||||
assertPageWriteQuota(space, buffer.length);
|
||||
} catch (error) {
|
||||
throw Object.assign(new Error(error.message), {
|
||||
code: error.code ?? 'quota_exceeded',
|
||||
details: error.details,
|
||||
});
|
||||
}
|
||||
|
||||
const detectedMimeType = assetInternals.detectMimeType(buffer, file.filename);
|
||||
@@ -346,10 +350,15 @@ export function createWorkspaceAssetSync({
|
||||
};
|
||||
}
|
||||
const sizeDelta = buffer.length - asNumber(currentAsset.size_bytes);
|
||||
const available =
|
||||
asNumber(space.quota_bytes) - asNumber(space.used_bytes) - asNumber(space.reserved_bytes);
|
||||
if (sizeDelta > 0 && available < sizeDelta) {
|
||||
throw Object.assign(new Error('剩余空间不足'), { code: 'quota_exceeded' });
|
||||
if (sizeDelta > 0) {
|
||||
try {
|
||||
assertPageWriteQuota(space, sizeDelta);
|
||||
} catch (error) {
|
||||
throw Object.assign(new Error(error.message), {
|
||||
code: error.code ?? 'quota_exceeded',
|
||||
details: error.details,
|
||||
});
|
||||
}
|
||||
}
|
||||
const versionId = currentAsset.current_version_id;
|
||||
if (!versionId) {
|
||||
|
||||
Reference in New Issue
Block a user