mulmoclaude 2.9.0 → 2.11.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/README.md +11 -0
- package/bin/mulmoclaude.js +32 -17
- package/client/assets/{JsonEditor-E3FJ7oRf.js → JsonEditor-DnC5hozl.js} +1 -1
- package/client/assets/{marp-C3oyTBz_.js → marp-DvbfD9EO.js} +1 -1
- package/client/assets/material-symbols-outlined-DzTrJqFk.woff2 +0 -0
- package/client/assets/{feat-3497-qPLQlhNs.js → mulmoclaude3-BUmaA-ZX.js} +606 -600
- package/client/assets/mulmoclaude3-D93Ihflz.css +2 -0
- package/client/assets/vue-i18n-BVPWXOdL.js +3 -0
- package/client/index.html +3 -3
- package/package.json +20 -20
- package/server/agent/backend/claude-code.ts +50 -5
- package/server/agent/config.ts +3 -1
- package/server/agent/sandboxEnv.ts +148 -0
- package/server/agent/sandboxEnvPlan.ts +188 -0
- package/server/api/auth/bearerAuth.ts +19 -10
- package/server/api/auth/clientTokenAccess.ts +57 -0
- package/server/api/auth/clientTokenCli.ts +13 -0
- package/server/api/auth/clientTokenCommands.ts +90 -0
- package/server/api/auth/clientTokenRule.ts +115 -0
- package/server/api/auth/clientTokenStore.ts +178 -0
- package/server/api/auth/principal.ts +33 -0
- package/server/api/routes/collections.ts +73 -35
- package/server/api/routes/files.ts +230 -89
- package/server/api/routes/pdf.ts +68 -62
- package/server/api/routes/runtime-plugin.ts +33 -32
- package/server/build/mcp-server.mjs +618 -609
- package/server/events/pub-sub/handshakeAuth.ts +3 -5
- package/server/events/pub-sub/index.ts +22 -4
- package/server/index.ts +30 -95
- package/server/plugins/confined-file-ops.ts +5 -3
- package/server/system/config.ts +1 -1
- package/server/system/env.ts +4 -0
- package/server/system/logs/aaa +737 -0
- package/server/system/logs/bb +446 -0
- package/server/utils/exif.ts +4 -7
- package/server/utils/files/artifactMount.ts +89 -0
- package/server/utils/files/attachment-store.ts +17 -29
- package/server/utils/files/image-store.ts +7 -13
- package/server/utils/files/plugins-io.ts +13 -5
- package/server/utils/files/safe.ts +0 -8
- package/server/utils/files/sendFileHandle.ts +115 -0
- package/server/utils/files/store-files.ts +86 -0
- package/server/utils/files/storePaths.ts +23 -0
- package/server/utils/files/thumbnail-store.ts +25 -23
- package/server/utils/files/upload-io.ts +9 -8
- package/server/utils/html/htmlArtifactSplicer.ts +19 -14
- package/server/utils/share/packHtml.ts +23 -34
- package/server/workspace/photo-locations/index.ts +26 -27
- package/server/workspace/photo-locations/list.ts +17 -29
- package/server/workspace/photo-locations/store.ts +4 -0
- package/server/workspace/wiki-pages/io.ts +9 -8
- package/src/components/SessionHistoryRow.vue +11 -1
- package/src/utils/html/customViewSrcdoc.ts +5 -0
- package/client/assets/feat-3497-CVVJjM2K.css +0 -2
- package/client/assets/material-symbols-outlined-Bn5lkljl.woff2 +0 -0
- package/client/assets/vue-i18n-BHWgmfE3.js +0 -3
- package/server/utils/files/store-resolvers.ts +0 -58
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { readFile } from "fs/promises";
|
|
2
|
-
import { realpathSync } from "fs";
|
|
3
1
|
import path from "path";
|
|
4
2
|
import JSZip from "jszip";
|
|
3
|
+
import type { VerifiedScope } from "@mulmoclaude/core/files";
|
|
5
4
|
import { resolveWorkspacePath } from "../files/workspace-io.js";
|
|
6
|
-
import {
|
|
5
|
+
import { artifactScope, lexicallyInside, openArtifactFile, readArtifactFile } from "../files/artifactMount.js";
|
|
7
6
|
import { rewriteHtmlAssets } from "./rewriteAssets.js";
|
|
8
7
|
import { log } from "../../system/logger/index.js";
|
|
9
8
|
|
|
@@ -22,32 +21,29 @@ export interface PackedBundle {
|
|
|
22
21
|
files: PackedFile[];
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
// `resolveWithinRoot` requires an already-realpath'd root. Resolved
|
|
26
|
-
// lazily (not at import) so loading this module never depends on the
|
|
27
|
-
// workspace dir existing yet; the location doesn't change during a run.
|
|
28
|
-
let workspaceRealCache: string | null = null;
|
|
29
|
-
function workspaceReal(): string {
|
|
30
|
-
if (workspaceRealCache === null) workspaceRealCache = realpathSync(resolveWorkspacePath("."));
|
|
31
|
-
return workspaceRealCache;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
24
|
function stripQueryHash(ref: string): string {
|
|
35
25
|
const cut = ref.search(/[?#]/);
|
|
36
26
|
return cut === -1 ? ref : ref.slice(0, cut);
|
|
37
27
|
}
|
|
38
28
|
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
29
|
+
// Reads go through the verified handle (#3573). The lexical check is the form CodeQL's js/path-injection recognises.
|
|
30
|
+
async function workspaceTarget(relFromRoot: string): Promise<{ scope: VerifiedScope; inside: string } | null> {
|
|
31
|
+
const root = resolveWorkspacePath(".");
|
|
32
|
+
const inside = lexicallyInside(root, relFromRoot);
|
|
33
|
+
const scope = inside === null ? null : await artifactScope(root, "");
|
|
34
|
+
return scope === null || inside === null ? null : { scope, inside };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// The page's own read errors (EACCES …) propagate; only missing, outside or not a regular file is "not found".
|
|
38
|
+
async function readPage(htmlRelPath: string): Promise<string> {
|
|
39
|
+
const target = await workspaceTarget(htmlRelPath);
|
|
40
|
+
const handle = target === null ? null : await openArtifactFile(target.scope, target.inside);
|
|
41
|
+
if (handle === null) throw new Error(`HTML not found or outside workspace: ${htmlRelPath}`);
|
|
42
|
+
try {
|
|
43
|
+
return await handle.readFile("utf-8");
|
|
44
|
+
} finally {
|
|
45
|
+
await handle.close();
|
|
46
|
+
}
|
|
51
47
|
}
|
|
52
48
|
|
|
53
49
|
// Resolve a ref (relative to the HTML file's dir) to workspace bytes.
|
|
@@ -55,19 +51,12 @@ function safeWorkspaceAbs(relFromRoot: string): string | null {
|
|
|
55
51
|
// missing — the caller warns and leaves the (now dangling) link.
|
|
56
52
|
async function readAsset(htmlDir: string, originalRef: string): Promise<Buffer | null> {
|
|
57
53
|
const relFromRoot = path.posix.normalize(path.posix.join(htmlDir, stripQueryHash(originalRef)));
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
try {
|
|
61
|
-
return await readFile(abs);
|
|
62
|
-
} catch {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
54
|
+
const target = await workspaceTarget(relFromRoot).catch(() => null);
|
|
55
|
+
return target === null ? null : readArtifactFile(target.scope, target.inside);
|
|
65
56
|
}
|
|
66
57
|
|
|
67
58
|
export async function packHtmlBundle(htmlRelPath: string): Promise<PackedBundle> {
|
|
68
|
-
const
|
|
69
|
-
if (!abs) throw new Error(`HTML not found or outside workspace: ${htmlRelPath}`);
|
|
70
|
-
const html = await readFile(abs, "utf-8");
|
|
59
|
+
const html = await readPage(htmlRelPath);
|
|
71
60
|
|
|
72
61
|
const { html: rewritten, assets } = rewriteHtmlAssets(html);
|
|
73
62
|
const htmlDir = path.posix.dirname(htmlRelPath);
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
// auto-capture is enabled in `AppSettings.photoExif`.
|
|
15
15
|
|
|
16
16
|
import path from "node:path";
|
|
17
|
-
import { mkdir } from "node:fs/promises";
|
|
18
|
-
import { writeFileAtomic } from "../../utils/files/atomic.js";
|
|
19
17
|
import { WORKSPACE_PATHS, WORKSPACE_DIRS } from "../paths.js";
|
|
20
18
|
import { isPhotoExifAutoCaptureEnabled, loadSettings } from "../../system/config.js";
|
|
21
|
-
import { isExifSupportedMime,
|
|
19
|
+
import { isExifSupportedMime, parsePhotoExif, type ExifParser, type PhotoExif } from "../../utils/exif.js";
|
|
20
|
+
import { loadAttachmentBytes } from "../../utils/files/attachment-store.js";
|
|
21
|
+
import { locationsStore } from "./store.js";
|
|
22
22
|
import { log } from "../../system/logger/index.js";
|
|
23
23
|
import { publishPhotoLocationsChanged } from "../../events/photo-locations-change.js";
|
|
24
24
|
|
|
@@ -65,12 +65,16 @@ function partitionForAttachment(attachmentRelativePath: string): string {
|
|
|
65
65
|
return path.posix.join(year, month);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
/** The sidecar's path inside the locations store (`YYYY/MM/<id>.json`). */
|
|
69
|
+
function sidecarStorePath(attachmentRelativePath: string): string | null {
|
|
70
|
+
const partition = partitionForAttachment(attachmentRelativePath);
|
|
71
|
+
return partition === "" ? null : path.posix.join(partition, `${sidecarIdForAttachment(attachmentRelativePath)}.json`);
|
|
72
|
+
}
|
|
73
|
+
|
|
68
74
|
/** Compute the absolute sidecar path for a saved attachment. */
|
|
69
75
|
export function sidecarPathForAttachment(attachmentRelativePath: string): string | null {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const sidecarId = sidecarIdForAttachment(attachmentRelativePath);
|
|
73
|
-
return path.join(WORKSPACE_PATHS.locations, partition, `${sidecarId}.json`);
|
|
76
|
+
const storePath = sidecarStorePath(attachmentRelativePath);
|
|
77
|
+
return storePath === null ? null : path.join(WORKSPACE_PATHS.locations, storePath);
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
/** Hook the attachment-store calls after every saved attachment.
|
|
@@ -81,8 +85,8 @@ export function sidecarPathForAttachment(attachmentRelativePath: string): string
|
|
|
81
85
|
*
|
|
82
86
|
* Errors are swallowed and logged at warn — we never want a failed
|
|
83
87
|
* EXIF probe to fail the upload. */
|
|
84
|
-
export function capturePhotoLocation(
|
|
85
|
-
return capturePhotoLocationWithParser(
|
|
88
|
+
export function capturePhotoLocation(attachmentRelativePath: string, mimeType: string): Promise<void> {
|
|
89
|
+
return capturePhotoLocationWithParser(attachmentRelativePath, mimeType);
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
/** Gate check: should we even try to read EXIF for this MIME, given
|
|
@@ -92,13 +96,14 @@ function shouldCapture(mimeType: string): boolean {
|
|
|
92
96
|
return isPhotoExifAutoCaptureEnabled(loadSettings());
|
|
93
97
|
}
|
|
94
98
|
|
|
95
|
-
/** Read EXIF, swallowing
|
|
96
|
-
* fails the upload —
|
|
97
|
-
|
|
99
|
+
/** Read EXIF from the stored photo, swallowing errors as `null`. The
|
|
100
|
+
* hook never fails the upload — an unreadable photo or a thrown
|
|
101
|
+
* parser is just "skip the sidecar". */
|
|
102
|
+
async function readExifSafe(attachmentRelativePath: string, parser: ExifParser | undefined): Promise<PhotoExif | null> {
|
|
98
103
|
try {
|
|
99
|
-
return await
|
|
104
|
+
return await parsePhotoExif(await loadAttachmentBytes(attachmentRelativePath), parser);
|
|
100
105
|
} catch (err) {
|
|
101
|
-
log.warn("photo-locations", "exif
|
|
106
|
+
log.warn("photo-locations", "exif read failed — skipping sidecar", { path: attachmentRelativePath, error: String(err) });
|
|
102
107
|
return null;
|
|
103
108
|
}
|
|
104
109
|
}
|
|
@@ -106,10 +111,9 @@ async function readExifSafe(absPhotoPath: string, attachmentRelativePath: string
|
|
|
106
111
|
/** Write the sidecar JSON, creating parent dirs as needed. Failures
|
|
107
112
|
* are logged but never thrown — the photo upload already succeeded
|
|
108
113
|
* by the time this runs. */
|
|
109
|
-
async function writeSidecarSafe(
|
|
114
|
+
async function writeSidecarSafe(storePath: string, payload: PhotoLocationSidecar): Promise<void> {
|
|
110
115
|
try {
|
|
111
|
-
await
|
|
112
|
-
await writeFileAtomic(sidecarPath, `${JSON.stringify(payload, null, 2)}\n`, { mode: SIDECAR_FILE_MODE });
|
|
116
|
+
await locationsStore.write(storePath, Buffer.from(`${JSON.stringify(payload, null, 2)}\n`), { mode: SIDECAR_FILE_MODE });
|
|
113
117
|
log.info("photo-locations", "sidecar written", {
|
|
114
118
|
attachment: payload.photo.relativePath,
|
|
115
119
|
hasGps: payload.exif.lat !== undefined && payload.exif.lng !== undefined,
|
|
@@ -124,17 +128,12 @@ async function writeSidecarSafe(sidecarPath: string, payload: PhotoLocationSidec
|
|
|
124
128
|
/** Parser-injectable variant. Production code uses
|
|
125
129
|
* `capturePhotoLocation`; tests reach for this overload to swap
|
|
126
130
|
* exifr for a stub so they don't need a JPEG fixture. */
|
|
127
|
-
export async function capturePhotoLocationWithParser(
|
|
128
|
-
absPhotoPath: string,
|
|
129
|
-
attachmentRelativePath: string,
|
|
130
|
-
mimeType: string,
|
|
131
|
-
parser?: ExifParser,
|
|
132
|
-
): Promise<void> {
|
|
131
|
+
export async function capturePhotoLocationWithParser(attachmentRelativePath: string, mimeType: string, parser?: ExifParser): Promise<void> {
|
|
133
132
|
if (!shouldCapture(mimeType)) return;
|
|
134
|
-
const exif = await readExifSafe(
|
|
133
|
+
const exif = await readExifSafe(attachmentRelativePath, parser);
|
|
135
134
|
if (!exif) return;
|
|
136
|
-
const
|
|
137
|
-
if (!
|
|
135
|
+
const storePath = sidecarStorePath(attachmentRelativePath);
|
|
136
|
+
if (!storePath) {
|
|
138
137
|
log.warn("photo-locations", "could not derive sidecar path — skipping", { attachmentRelativePath });
|
|
139
138
|
return;
|
|
140
139
|
}
|
|
@@ -144,7 +143,7 @@ export async function capturePhotoLocationWithParser(
|
|
|
144
143
|
exif,
|
|
145
144
|
capturedAt: new Date().toISOString(),
|
|
146
145
|
};
|
|
147
|
-
await writeSidecarSafe(
|
|
146
|
+
await writeSidecarSafe(storePath, payload);
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
// `WORKSPACE_DIRS.locations` is referenced for typing-side
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
// "list all my photo locations" or "render every captured pin on
|
|
9
9
|
// a map view".
|
|
10
10
|
|
|
11
|
-
import { readdir, readFile } from "node:fs/promises";
|
|
12
11
|
import path from "node:path";
|
|
13
|
-
import { WORKSPACE_DIRS
|
|
12
|
+
import { WORKSPACE_DIRS } from "../paths.js";
|
|
14
13
|
import { log } from "../../system/logger/index.js";
|
|
15
14
|
import { isRecord } from "../../utils/types.js";
|
|
16
15
|
import type { PhotoExif } from "../../utils/exif.js";
|
|
17
16
|
import type { PhotoLocationSidecar } from "./index.js";
|
|
17
|
+
import { locationsStore } from "./store.js";
|
|
18
18
|
|
|
19
19
|
/** A sidecar paired with the id used in the filename. The id is the
|
|
20
20
|
* attachment's stable identifier; consumers (UI, LLM) use it to
|
|
@@ -33,15 +33,12 @@ const SIDECAR_EXT = ".json";
|
|
|
33
33
|
* the path so an operator can investigate without the listing
|
|
34
34
|
* crashing. */
|
|
35
35
|
export async function listAllSidecars(): Promise<ListedSidecar[]> {
|
|
36
|
-
const
|
|
37
|
-
const yearDirs = await readSubdirsSafe(root);
|
|
36
|
+
const yearDirs = await readSubdirs("");
|
|
38
37
|
const all: ListedSidecar[] = [];
|
|
39
38
|
for (const year of yearDirs) {
|
|
40
|
-
const
|
|
41
|
-
const monthDirs = await readSubdirsSafe(yearAbs);
|
|
39
|
+
const monthDirs = await readSubdirs(year);
|
|
42
40
|
for (const month of monthDirs) {
|
|
43
|
-
const
|
|
44
|
-
const sidecars = await readSidecarsInDir(monthAbs, year, month);
|
|
41
|
+
const sidecars = await readSidecarsInDir(year, month);
|
|
45
42
|
all.push(...sidecars);
|
|
46
43
|
}
|
|
47
44
|
}
|
|
@@ -146,39 +143,30 @@ function validateSidecarShape(value: unknown): PhotoLocationSidecar | null {
|
|
|
146
143
|
return { version: 1, capturedAt, photo: { relativePath, mimeType }, exif: readSidecarExif(exif) };
|
|
147
144
|
}
|
|
148
145
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
} catch {
|
|
154
|
-
// ENOENT on a fresh workspace — locations dir doesn't exist
|
|
155
|
-
// yet, treat as empty.
|
|
156
|
-
return [];
|
|
157
|
-
}
|
|
146
|
+
// A fresh workspace has no locations folder yet; the store lists that as empty.
|
|
147
|
+
async function readSubdirs(storeDir: string): Promise<string[]> {
|
|
148
|
+
const entries = await locationsStore.listDir(storeDir);
|
|
149
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
158
150
|
}
|
|
159
151
|
|
|
160
|
-
async function readSidecarsInDir(
|
|
161
|
-
const entries = await
|
|
152
|
+
async function readSidecarsInDir(year: string, month: string): Promise<ListedSidecar[]> {
|
|
153
|
+
const entries = await locationsStore.listDir(path.posix.join(year, month));
|
|
162
154
|
const out: ListedSidecar[] = [];
|
|
163
|
-
for (const entry of entries) {
|
|
155
|
+
for (const { name: entry } of entries) {
|
|
164
156
|
if (!entry.endsWith(SIDECAR_EXT)) continue;
|
|
165
157
|
const sidecarId = entry.slice(0, -SIDECAR_EXT.length);
|
|
166
|
-
const
|
|
158
|
+
const relativePath = path.posix.join(WORKSPACE_DIRS.locations, year, month, entry);
|
|
167
159
|
try {
|
|
168
|
-
const raw = await
|
|
160
|
+
const raw = (await locationsStore.read(relativePath)).toString("utf8");
|
|
169
161
|
const parsed: unknown = JSON.parse(raw);
|
|
170
162
|
const sidecar = validateSidecarShape(parsed);
|
|
171
163
|
if (!sidecar) {
|
|
172
|
-
log.warn("photo-locations", "skipping sidecar with invalid shape", { path:
|
|
164
|
+
log.warn("photo-locations", "skipping sidecar with invalid shape", { path: relativePath });
|
|
173
165
|
continue;
|
|
174
166
|
}
|
|
175
|
-
out.push({
|
|
176
|
-
id: sidecarId,
|
|
177
|
-
relativePath: path.posix.join(WORKSPACE_DIRS.locations, year, month, entry),
|
|
178
|
-
sidecar,
|
|
179
|
-
});
|
|
167
|
+
out.push({ id: sidecarId, relativePath, sidecar });
|
|
180
168
|
} catch (err) {
|
|
181
|
-
log.warn("photo-locations", "skipping malformed sidecar", { path:
|
|
169
|
+
log.warn("photo-locations", "skipping malformed sidecar", { path: relativePath, error: String(err) });
|
|
182
170
|
}
|
|
183
171
|
}
|
|
184
172
|
return out;
|
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
// site wired up means PR 2 is purely an internal change.
|
|
20
20
|
|
|
21
21
|
import path from "node:path";
|
|
22
|
-
import {
|
|
22
|
+
import { realpath } from "node:fs/promises";
|
|
23
23
|
import { readTextSafe } from "../../utils/files/safe.js";
|
|
24
24
|
import { writeFileAtomic } from "../../utils/files/atomic.js";
|
|
25
|
+
import { writeNewFileExclusive } from "../../utils/files/upload-io.js";
|
|
25
26
|
import { mergeFrontmatter, parseFrontmatter, serializeWithFrontmatter } from "@mulmoclaude/markdown-utils/markdown/frontmatter";
|
|
26
27
|
import { isSafeSlug } from "@mulmoclaude/core/wiki";
|
|
27
28
|
import { wikiSlugFromAbsPath } from "@mulmoclaude/core/wiki/paths";
|
|
@@ -56,7 +57,7 @@ export interface WikiPageWriteOptions {
|
|
|
56
57
|
* injection. Tests pass a fixed `Date` so the round-trip is
|
|
57
58
|
* deterministic; production uses the wall clock. */
|
|
58
59
|
now?: (() => Date) | undefined;
|
|
59
|
-
/** Create-only mode: write via `O_EXCL`
|
|
60
|
+
/** Create-only mode: write via `O_EXCL` so the
|
|
60
61
|
* call atomically refuses to overwrite an existing page. The
|
|
61
62
|
* thrown error has `code: "EEXIST"` — used by the
|
|
62
63
|
* `POST /api/files/create` route (#1598) to map to a 409 and
|
|
@@ -107,7 +108,7 @@ export async function writeWikiPage(slug: string, content: string, meta: WikiWri
|
|
|
107
108
|
const finalContent = stampFrontmatter(oldContent, content, meta, opts);
|
|
108
109
|
if (opts.exclusive) {
|
|
109
110
|
// Re-anchor the absolute path against the workspace root before
|
|
110
|
-
// handing it to
|
|
111
|
+
// handing it to the create. `wikiPagePath` already
|
|
111
112
|
// enforces containment via `isSafeSlug` + `path.join`, but
|
|
112
113
|
// CodeQL's `js/path-injection` analysis doesn't trace through
|
|
113
114
|
// those — the explicit `relative` + `startsWith` containment
|
|
@@ -120,11 +121,11 @@ export async function writeWikiPage(slug: string, content: string, meta: WikiWri
|
|
|
120
121
|
throw new Error(`wiki-pages: refusing to write outside workspace root: ${JSON.stringify(absPath)}`);
|
|
121
122
|
}
|
|
122
123
|
const safeAbsPath = path.join(root, relFromRoot);
|
|
123
|
-
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
await
|
|
124
|
+
// `O_EXCL`: atomic create-or-fail. On a concurrent create race
|
|
125
|
+
// only one call wins; the other throws `EEXIST`, which the route
|
|
126
|
+
// handler maps to HTTP 409. The new file is also proven to sit
|
|
127
|
+
// inside the workspace before any byte is written (#3573).
|
|
128
|
+
await writeNewFileExclusive(await realpath(root), safeAbsPath, finalContent);
|
|
128
129
|
} else {
|
|
129
130
|
await writeFileAtomic(absPath, finalContent, { uniqueTmp: true });
|
|
130
131
|
}
|
|
@@ -67,7 +67,15 @@
|
|
|
67
67
|
first-message fallback stays on a single line via `truncate`
|
|
68
68
|
so short prompts don't disturb row heights. -->
|
|
69
69
|
<div class="flex items-start gap-1.5">
|
|
70
|
-
|
|
70
|
+
<!-- Mouse-only on purpose: a <button> would nest inside the role="button" row; keyboard users have the menu item. -->
|
|
71
|
+
<span
|
|
72
|
+
class="flex-shrink-0 mt-0.5 cursor-pointer"
|
|
73
|
+
:title="bookmarkLabel"
|
|
74
|
+
:data-testid="`session-row-icon-bookmark-${session.id}`"
|
|
75
|
+
@click.stop="emit('toggleBookmark', session)"
|
|
76
|
+
>
|
|
77
|
+
<SessionRoleIcon :session="session" :roles="roles" size="sm" />
|
|
78
|
+
</span>
|
|
71
79
|
<p class="flex-1 min-w-0" :class="[previewClasses, hasVisibleSummary ? 'line-clamp-2' : 'truncate']">
|
|
72
80
|
{{ primaryText }}
|
|
73
81
|
</p>
|
|
@@ -123,6 +131,8 @@ const primaryText = computed(() => resolveSessionPrimaryText(props.session) ?? t
|
|
|
123
131
|
|
|
124
132
|
const rowAria = computed(() => t("sessionHistoryPanel.openRowAria", { preview: primaryText.value }));
|
|
125
133
|
|
|
134
|
+
const bookmarkLabel = computed(() => (props.session.isBookmarked ? t("sessionHistoryPanel.unbookmark") : t("sessionHistoryPanel.bookmark")));
|
|
135
|
+
|
|
126
136
|
const formattedDate = computed(() => formatDate(props.session.updatedAt));
|
|
127
137
|
|
|
128
138
|
const hasVisibleSummary = computed(() => sessionHasVisibleSummary(props.session));
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
// helper that asks the host to open a new chat seeded with `prompt`, and
|
|
16
16
|
// the host search box's live text (see below).
|
|
17
17
|
|
|
18
|
+
import type { CustomViewFields } from "@mulmoclaude/core/collection";
|
|
18
19
|
import { buildCustomViewCsp, type CspExtraHosts } from "./previewCsp";
|
|
19
20
|
|
|
20
21
|
/** Debounce (ms) for the in-iframe live-refresh helper — collapses a burst of
|
|
@@ -119,6 +120,9 @@ export interface CustomViewBootstrap {
|
|
|
119
120
|
* iframe sees ONLY this locale's strings (never the full multi-locale
|
|
120
121
|
* JSON). Optional / may be `{}` — the `t()` helper falls back to the key. */
|
|
121
122
|
dict?: Record<string, string>;
|
|
123
|
+
/** Schema-derived enum metadata, keyed by field name (#2169). Optional — the
|
|
124
|
+
* bootstrap always exposes `__MC_VIEW.fields`, `{}` when omitted. */
|
|
125
|
+
fields?: CustomViewFields;
|
|
122
126
|
}
|
|
123
127
|
|
|
124
128
|
function absoluteDataUrl(dataUrl: string, origin: string): string {
|
|
@@ -143,6 +147,7 @@ export function buildCustomViewSrcdoc(html: string, boot: CustomViewBootstrap, c
|
|
|
143
147
|
cspNonce, // echoed in mc-csp-violation so the host can trust the sender (#1989)
|
|
144
148
|
locale: boot.locale ?? "",
|
|
145
149
|
dict: boot.dict ?? {},
|
|
150
|
+
fields: boot.fields ?? {},
|
|
146
151
|
}).replace(/</g, "\\u003c");
|
|
147
152
|
const injection = `${cspMeta}<script>window.__MC_VIEW=${json};${viewBridgeBootstrap()}</script>`;
|
|
148
153
|
if (/<head\b[^>]*>/i.test(html)) {
|