@openchamber/web 1.18.2 → 1.18.4
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/bin/lib/commands-models.js +1 -1
- package/dist/assets/{CodeMirrorCommentWidgets-CxcJ5x9h.js → CodeMirrorCommentWidgets-4qZbrEXU.js} +1 -1
- package/dist/assets/{CommitSection-C9sBBYAJ.js → CommitSection-MJmntVPJ.js} +1 -1
- package/dist/assets/{DiagramEditor-C7nUw7p3.js → DiagramEditor-jnG3Hbxg.js} +1 -1
- package/dist/assets/{DiagramView-cYxZP-HS.js → DiagramView-CFXxgg_a.js} +1 -1
- package/dist/assets/{DiffView-1zd0slLu.js → DiffView-DZIoOnV7.js} +2 -2
- package/dist/assets/FilesView-BKL6YlKG.js +14 -0
- package/dist/assets/{GitView-OSVIn5V1.js → GitView-DBFrDDBv.js} +1 -1
- package/dist/assets/{JsonTreeView-Kgepz4pR.js → JsonTreeView-DLW2Wy1g.js} +1 -1
- package/dist/assets/MarkdownImageGallery-DKIylIK7.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CLv8hxvv.js +12 -0
- package/dist/assets/OnboardingScreen-D2Y6djMw.js +1 -0
- package/dist/assets/{PatchDiff-Cddz02Ya.js → PatchDiff-BuLPx7AN.js} +1 -1
- package/dist/assets/{PierreDiffViewer-B5k0KvPW.js → PierreDiffViewer-BHm4Yr0X.js} +2 -2
- package/dist/assets/{PlanView-BYgHBHDt.js → PlanView-ZYEJn8A_.js} +3 -3
- package/dist/assets/{SessionSwitcherDropdown-ig2OT22Z.js → SessionSwitcherDropdown-rro-SsaO.js} +1 -1
- package/dist/assets/SettingsView-5RmswFZe.js +28 -0
- package/dist/assets/{SettingsWindow-CNHM8ifT.js → SettingsWindow-BZhAYFdS.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DrGeYq2p.js → ToolOutputDialog-Za6V4VMJ.js} +7 -7
- package/dist/assets/{ToolPartDiffPreview-BRmPpe94.js → ToolPartDiffPreview-BL-9ixyC.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-Dcu8Q-5P.js → VirtualizedFileDiff-CwGocYQd.js} +1 -1
- package/dist/assets/{WalkthroughView-HStEYdD2.js → WalkthroughView-5DyvN03T.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-DQE7R9IY.js → computeVirtualFileMetrics-Da00Jg7M.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-B-bSg3P5.js +1 -0
- package/dist/assets/de-u7gSnqWs.js +9 -0
- package/dist/assets/es-T9O7aAOr.js +15 -0
- package/dist/assets/fr-Oor7ewbE.js +13 -0
- package/dist/assets/index-BzIpNlNE.css +1 -0
- package/dist/assets/{index-BgQEgA2a.js → index-C0yNhuZw.js} +1 -1
- package/dist/assets/index-DRpChWux.js +7 -0
- package/dist/assets/{isDiffPlainText-XyBCe4eD.js → isDiffPlainText-D9YpoLrV.js} +1 -1
- package/dist/assets/{isFilePlainText-JbqDfa3n.js → isFilePlainText-gTibdNIe.js} +1 -1
- package/dist/assets/ja-DHpqbVmr.js +15 -0
- package/dist/assets/ko-CwLkS3nx.js +15 -0
- package/dist/assets/{main-LfcbGv7C.js → main-D7UcL3VQ.js} +2 -2
- package/dist/assets/main-DPMd2iKS.js +915 -0
- package/dist/assets/markdownCore-DDrHVneM.js +2 -0
- package/dist/assets/{miniChat-CUp_elRz.js → miniChat-O_GVoEbc.js} +2 -2
- package/dist/assets/{mobile-CBSN7BsH.js → mobile-Br4TtAqc.js} +2 -2
- package/dist/assets/{patchFileDiff-DCIXUHRJ.js → patchFileDiff-KNkxM1C1.js} +2 -2
- package/dist/assets/{pl-tHTP6XQx.js → pl-CcZILN8q.js} +4 -4
- package/dist/assets/pt-BR-DYHhVK6o.js +15 -0
- package/dist/assets/{renderElectronMiniChatApp-eZl-5STF.js → renderElectronMiniChatApp-CJpdxTT1.js} +2 -2
- package/dist/assets/renderMobileApp-toj9cXoh.js +25 -0
- package/dist/assets/runtimeEndpointReset-BVmispdD.js +13 -0
- package/dist/assets/scheduledTasksApi-ByKya3Un.js +1 -0
- package/dist/assets/{shikiHighlight-eU8abJ3T.js → shikiHighlight-C7LTbwFx.js} +1 -1
- package/dist/assets/uk-BA2kZR38.js +15 -0
- package/dist/assets/{useAppFontEffects-Bbpz77To.js → useAppFontEffects-BikB6enL.js} +138 -138
- package/dist/assets/useInlineCommentController-CYPvYJDt.js +2 -0
- package/dist/assets/{vendor-codemirror-language-data-Dzt9rWZZ.js → vendor-codemirror-language-data-CLHw8NWn.js} +2 -2
- package/dist/assets/{vendor-marked-i_gIkIP3.js → vendor-marked-CX41MkDF.js} +1 -1
- package/dist/assets/{web-components-DGvnI0zx.js → web-components-GMc3oR3i.js} +1 -1
- package/dist/assets/zh-CN-dlOQK6v9.js +15 -0
- package/dist/assets/zh-TW-BnqQ-WL5.js +15 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +2 -2
- package/server/index.js +65 -19
- package/server/lib/agent-tool/DOCUMENTATION.md +21 -6
- package/server/lib/agent-tool/runtime.js +90 -16
- package/server/lib/agent-tool/runtime.test.js +86 -0
- package/server/lib/browser-control/DOCUMENTATION.md +50 -0
- package/server/lib/browser-control/broker.js +154 -0
- package/server/lib/browser-control/broker.test.js +191 -0
- package/server/lib/browser-control/routes.js +48 -0
- package/server/lib/browser-control/routes.test.js +108 -0
- package/server/lib/dev-servers/parse.js +203 -0
- package/server/lib/dev-servers/parse.test.js +174 -0
- package/server/lib/dev-servers/routes.js +135 -0
- package/server/lib/dev-tunnel/DOCUMENTATION.md +57 -0
- package/server/lib/dev-tunnel/client.js +193 -0
- package/server/lib/dev-tunnel/runtime.js +189 -0
- package/server/lib/dev-tunnel/tunnel.test.js +291 -0
- package/server/lib/git/credentials.js +0 -33
- package/server/lib/github/DOCUMENTATION.md +1 -1
- package/server/lib/markdown-image-grants/DOCUMENTATION.md +36 -0
- package/server/lib/markdown-image-grants/routes.js +340 -0
- package/server/lib/markdown-image-grants/routes.test.js +221 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +9 -0
- package/server/lib/openchamber-control/actions.js +33 -1
- package/server/lib/openchamber-control/screenshots.js +83 -0
- package/server/lib/openchamber-control/screenshots.test.js +84 -0
- package/server/lib/openchamber-control/service.js +141 -2
- package/server/lib/openchamber-control/service.test.js +55 -0
- package/server/lib/opencode/core-routes.js +31 -52
- package/server/lib/opencode/core-routes.test.js +37 -9
- package/server/lib/opencode/feature-routes-runtime.js +15 -0
- package/server/lib/opencode/server-startup-runtime.js +22 -1
- package/server/lib/opencode/server-startup-runtime.test.js +44 -0
- package/server/lib/opencode/settings-helpers.js +3 -9
- package/server/lib/projects/project-config.js +181 -2
- package/server/lib/projects/project-config.test.js +295 -0
- package/server/lib/quota/DOCUMENTATION.md +4 -2
- package/server/lib/quota/credentials/providers.js +0 -7
- package/server/lib/quota/credentials/store.js +11 -1
- package/server/lib/quota/credentials/store.test.js +9 -1
- package/server/lib/quota/providers/opencode-go.js +35 -35
- package/server/lib/quota/providers/opencode-go.test.js +52 -7
- package/server/lib/quota/routes.js +0 -2
- package/server/lib/relay/DOCUMENTATION.md +2 -0
- package/server/lib/relay/tunnel-host.js +157 -33
- package/server/lib/relay/tunnel-host.test.js +147 -0
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +49 -0
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +488 -0
- package/server/lib/scheduled-tasks/routes.js +6 -0
- package/server/lib/scheduled-tasks/runtime.js +369 -108
- package/server/lib/scheduled-tasks/service.js +7 -1
- package/server/lib/scheduled-tasks/service.test.js +20 -0
- package/server/lib/walkthrough/index.js +0 -2
- package/server/sse-routes.test.js +3 -0
- package/dist/assets/FilesView-WkxsWHBE.js +0 -14
- package/dist/assets/MarkdownRendererImpl-CKAsRfIk.js +0 -12
- package/dist/assets/OnboardingScreen-BCgYA7J5.js +0 -1
- package/dist/assets/SettingsView-e7Fmxnz8.js +0 -28
- package/dist/assets/contextPanelEmbeddedChat-5VGWIT_J.js +0 -1
- package/dist/assets/de-B6t6T54h.js +0 -9
- package/dist/assets/es-DH9NUKge.js +0 -15
- package/dist/assets/fr-Do4t2KmA.js +0 -13
- package/dist/assets/index-B45s9aAX.css +0 -1
- package/dist/assets/index-CNrN5qDs.js +0 -7
- package/dist/assets/ja-DJT9EM80.js +0 -15
- package/dist/assets/ko-CfWRq2p4.js +0 -15
- package/dist/assets/main-B4oBRI9u.js +0 -193
- package/dist/assets/markdownCore-A3_L34oS.js +0 -2
- package/dist/assets/pt-BR-BDEzzltP.js +0 -15
- package/dist/assets/renderMobileApp-DA7wpIBi.js +0 -23
- package/dist/assets/runtimeEndpointReset-D5izT-u5.js +0 -13
- package/dist/assets/scheduledTasksApi-CTJdfSWc.js +0 -1
- package/dist/assets/uk-B6Q32nyk.js +0 -15
- package/dist/assets/useInlineCommentController-D7zs7-BQ.js +0 -2
- package/dist/assets/vendor-zumer-snapdom-Btyu_Xi2.js +0 -8
- package/dist/assets/zh-CN-7MGcwGaC.js +0 -15
- package/dist/assets/zh-TW-CFPfqxlL.js +0 -15
- package/server/lib/preview/proxy-runtime.js +0 -1604
- package/server/lib/preview/proxy-runtime.test.js +0 -528
- package/server/lib/quota/opencode-go-credentials.js +0 -11
- package/server/lib/quota/opencode-go-credentials.test.js +0 -32
- package/server/lib/quota/routes.test.js +0 -40
|
@@ -39,36 +39,3 @@ export function discoverGitCredentials() {
|
|
|
39
39
|
|
|
40
40
|
return credentials;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
export function getCredentialForHost(host) {
|
|
44
|
-
if (!fs.existsSync(GIT_CREDENTIALS_PATH)) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
const content = fs.readFileSync(GIT_CREDENTIALS_PATH, 'utf8');
|
|
50
|
-
const lines = content.split('\n').filter(line => line.trim());
|
|
51
|
-
|
|
52
|
-
for (const line of lines) {
|
|
53
|
-
try {
|
|
54
|
-
const url = new URL(line.trim());
|
|
55
|
-
const hostname = url.hostname;
|
|
56
|
-
const pathname = url.pathname && url.pathname !== '/' ? url.pathname : '';
|
|
57
|
-
const credHost = hostname + pathname;
|
|
58
|
-
|
|
59
|
-
if (credHost === host) {
|
|
60
|
-
return {
|
|
61
|
-
username: url.username || '',
|
|
62
|
-
token: url.password || ''
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
} catch {
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
} catch (error) {
|
|
70
|
-
console.error('Failed to read .git-credentials for host lookup:', error);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
## Entrypoints and structure
|
|
9
9
|
|
|
10
|
-
- `packages/web/server/lib/github/index.js`: public server entrypoint.
|
|
10
|
+
- `packages/web/server/lib/github/index.js`: public server entrypoint. `routes.js` loads it lazily with `await import('./index.js')` and destructures the handler it needs, so a re-export removed from here breaks a route at request time rather than at build time. Static "unused export" reports do not see these consumers.
|
|
11
11
|
- `packages/web/server/lib/github/routes.js`: Express route registration for `/api/github/*` endpoints.
|
|
12
12
|
- `packages/web/server/lib/github/auth.js`: auth storage, multi-account support, client id, scope config.
|
|
13
13
|
- `packages/web/server/lib/github/device-flow.js`: OAuth device flow.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Markdown Image Grants
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This module lets the Markdown image gallery display images that an assistant
|
|
6
|
+
explicitly referenced from OpenCode's temporary directory when the UI is on a
|
|
7
|
+
different machine.
|
|
8
|
+
|
|
9
|
+
## Contract
|
|
10
|
+
|
|
11
|
+
- Chat Markdown rendering is independent: assistant image syntax renders as an
|
|
12
|
+
icon and filename, while the gallery only reads finalized Markdown to collect
|
|
13
|
+
image candidates.
|
|
14
|
+
- `POST /api/openchamber/sessions/:sessionId/markdown-image-grants` prepares up to 12
|
|
15
|
+
local images in one message-level request. The server fetches the assistant
|
|
16
|
+
message once and verifies every exact image source before reading files.
|
|
17
|
+
- Authorization recognizes the same common inline and reference-style image
|
|
18
|
+
destinations collected by the UI, including balanced parentheses, while
|
|
19
|
+
excluding fenced and inline code.
|
|
20
|
+
- Relative and workspace-contained absolute paths resolve against the active
|
|
21
|
+
directory. Other absolute paths are accepted only inside
|
|
22
|
+
`os.tmpdir()/opencode` after `realpath` resolution.
|
|
23
|
+
- PNG, JPEG, GIF, and WebP files are signature-checked and limited to 10 MiB.
|
|
24
|
+
- Prepare requests inspect only file metadata and signatures. Workspace images
|
|
25
|
+
reuse the existing authenticated `/api/fs/raw` asset route directly. Images
|
|
26
|
+
under `os.tmpdir()/opencode` receive the existing path-bound `raw`
|
|
27
|
+
`outsideFileGrant`; this module does not add another asset lifetime, copy, or
|
|
28
|
+
storage layer. Missing files return per-source results so the gallery can
|
|
29
|
+
remove only those items.
|
|
30
|
+
|
|
31
|
+
The routes are OpenChamber-owned and must be registered before the generic
|
|
32
|
+
OpenCode proxy. Web, Electron, hosted mobile, and Capacitor use the shared
|
|
33
|
+
server implementation. VS Code does not call this route for workspace images;
|
|
34
|
+
those use its local filesystem bridge. If called, the grant route returns an
|
|
35
|
+
explicit unsupported response because OpenCode temporary images are not
|
|
36
|
+
supported there.
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { constants as fsConstants } from 'node:fs';
|
|
3
|
+
import { mintOutsideFileGrant } from '../fs/routes.js';
|
|
4
|
+
|
|
5
|
+
const MAX_IMAGE_BYTES = 10 * 1024 * 1024;
|
|
6
|
+
const MAX_IMAGE_SOURCES = 12;
|
|
7
|
+
|
|
8
|
+
const asString = (value) => typeof value === 'string' ? value.trim() : '';
|
|
9
|
+
|
|
10
|
+
const isWithin = (target, root, path) => {
|
|
11
|
+
const relative = path.relative(root, target);
|
|
12
|
+
return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const parseFileSource = (source) => {
|
|
16
|
+
if (/^file:\/\//i.test(source)) {
|
|
17
|
+
try {
|
|
18
|
+
const url = new URL(source);
|
|
19
|
+
if (url.protocol !== 'file:' || (url.host && url.host !== 'localhost')) return '';
|
|
20
|
+
const pathname = decodeURIComponent(url.pathname);
|
|
21
|
+
return /^\/[A-Za-z]:\//.test(pathname) ? pathname.slice(1) : pathname;
|
|
22
|
+
} catch {
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const pathname = source.split(/[?#]/, 1)[0] || '';
|
|
27
|
+
try {
|
|
28
|
+
return decodeURIComponent(pathname);
|
|
29
|
+
} catch {
|
|
30
|
+
return pathname;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const hasImageSignature = (bytes) => {
|
|
35
|
+
if (bytes.length >= 8
|
|
36
|
+
&& bytes[0] === 0x89 && bytes.subarray(1, 4).toString('ascii') === 'PNG'
|
|
37
|
+
&& bytes[4] === 0x0d && bytes[5] === 0x0a && bytes[6] === 0x1a && bytes[7] === 0x0a) return true;
|
|
38
|
+
if (bytes.length >= 3 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff) return true;
|
|
39
|
+
const header = bytes.subarray(0, 12).toString('ascii');
|
|
40
|
+
return header.startsWith('GIF87a')
|
|
41
|
+
|| header.startsWith('GIF89a')
|
|
42
|
+
|| (header.startsWith('RIFF') && header.slice(8, 12) === 'WEBP');
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const normalizeReferenceLabel = (value) => value.trim().replace(/\s+/g, ' ').toLowerCase();
|
|
46
|
+
|
|
47
|
+
const unescapeMarkdownDestination = (value) => value.replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\])/g, '$1');
|
|
48
|
+
|
|
49
|
+
const isEscapedAt = (value, index) => {
|
|
50
|
+
let slashes = 0;
|
|
51
|
+
for (let cursor = index - 1; cursor >= 0 && value[cursor] === '\\'; cursor -= 1) slashes += 1;
|
|
52
|
+
return slashes % 2 === 1;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const findClosingBracket = (value, start) => {
|
|
56
|
+
for (let cursor = start; cursor < value.length; cursor += 1) {
|
|
57
|
+
if (value[cursor] === ']' && !isEscapedAt(value, cursor)) return cursor;
|
|
58
|
+
}
|
|
59
|
+
return -1;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const findInlineImageEnd = (value, start) => {
|
|
63
|
+
let cursor = start;
|
|
64
|
+
while (/\s/.test(value[cursor] || '')) cursor += 1;
|
|
65
|
+
if (value[cursor] === ')') return cursor;
|
|
66
|
+
|
|
67
|
+
const opener = value[cursor];
|
|
68
|
+
const closer = opener === '"' ? '"' : opener === "'" ? "'" : opener === '(' ? ')' : '';
|
|
69
|
+
if (!closer) return -1;
|
|
70
|
+
cursor += 1;
|
|
71
|
+
for (; cursor < value.length; cursor += 1) {
|
|
72
|
+
if (value[cursor] !== closer || isEscapedAt(value, cursor)) continue;
|
|
73
|
+
cursor += 1;
|
|
74
|
+
while (/\s/.test(value[cursor] || '')) cursor += 1;
|
|
75
|
+
return value[cursor] === ')' ? cursor : -1;
|
|
76
|
+
}
|
|
77
|
+
return -1;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const parseInlineDestination = (value, start) => {
|
|
81
|
+
let cursor = start;
|
|
82
|
+
while (/\s/.test(value[cursor] || '')) cursor += 1;
|
|
83
|
+
if (value[cursor] === '<') {
|
|
84
|
+
const end = value.indexOf('>', cursor + 1);
|
|
85
|
+
if (end < 0) return null;
|
|
86
|
+
const imageEnd = findInlineImageEnd(value, end + 1);
|
|
87
|
+
return imageEnd < 0
|
|
88
|
+
? null
|
|
89
|
+
: { source: unescapeMarkdownDestination(value.slice(cursor + 1, end)), end: imageEnd };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let source = '';
|
|
93
|
+
let depth = 0;
|
|
94
|
+
for (; cursor < value.length; cursor += 1) {
|
|
95
|
+
const char = value[cursor];
|
|
96
|
+
if (char === '\\' && cursor + 1 < value.length) {
|
|
97
|
+
source += char + value[cursor + 1];
|
|
98
|
+
cursor += 1;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (char === '(') {
|
|
102
|
+
depth += 1;
|
|
103
|
+
source += char;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (char === ')') {
|
|
107
|
+
if (depth === 0) return { source: unescapeMarkdownDestination(source), end: cursor };
|
|
108
|
+
depth -= 1;
|
|
109
|
+
source += char;
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (/\s/.test(char) && depth === 0) {
|
|
113
|
+
const imageEnd = findInlineImageEnd(value, cursor);
|
|
114
|
+
return imageEnd < 0 ? null : { source: unescapeMarkdownDestination(source), end: imageEnd };
|
|
115
|
+
}
|
|
116
|
+
source += char;
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const parseDefinitionDestination = (value) => {
|
|
122
|
+
const trimmed = value.trimStart();
|
|
123
|
+
if (trimmed.startsWith('<')) {
|
|
124
|
+
const end = trimmed.indexOf('>', 1);
|
|
125
|
+
return end < 0 ? '' : unescapeMarkdownDestination(trimmed.slice(1, end));
|
|
126
|
+
}
|
|
127
|
+
const match = /^(?:\\.|\S)+/.exec(trimmed);
|
|
128
|
+
return match ? unescapeMarkdownDestination(match[0]) : '';
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const collectMarkdownLinesOutsideCode = (message) => {
|
|
132
|
+
const lines = [];
|
|
133
|
+
for (const part of Array.isArray(message?.parts) ? message.parts : []) {
|
|
134
|
+
if (part?.type !== 'text' || typeof part.text !== 'string') continue;
|
|
135
|
+
let fence = null;
|
|
136
|
+
for (const line of part.text.split('\n')) {
|
|
137
|
+
const fenceMatch = /^\s{0,3}(`{3,}|~{3,})/.exec(line);
|
|
138
|
+
if (fenceMatch) {
|
|
139
|
+
const marker = fenceMatch[1];
|
|
140
|
+
if (!fence) {
|
|
141
|
+
fence = { char: marker[0], size: marker.length };
|
|
142
|
+
} else if (marker[0] === fence.char && marker.length >= fence.size) {
|
|
143
|
+
fence = null;
|
|
144
|
+
}
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (fence) continue;
|
|
148
|
+
lines.push(line.replace(/`+[^`]*`+/g, ''));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return lines;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const markdownImageSources = (message) => {
|
|
155
|
+
const sources = new Set();
|
|
156
|
+
const markdownLines = collectMarkdownLinesOutsideCode(message);
|
|
157
|
+
const definitions = new Map();
|
|
158
|
+
for (const line of markdownLines) {
|
|
159
|
+
const match = /^\s{0,3}\[([^\]]+)]\s*:\s*(.*)$/.exec(line);
|
|
160
|
+
if (!match) continue;
|
|
161
|
+
const source = parseDefinitionDestination(match[2]);
|
|
162
|
+
if (source) definitions.set(normalizeReferenceLabel(match[1]), source);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
for (const line of markdownLines) {
|
|
166
|
+
for (let cursor = 0; cursor < line.length; cursor += 1) {
|
|
167
|
+
if (line[cursor] !== '!' || line[cursor + 1] !== '[' || isEscapedAt(line, cursor)) continue;
|
|
168
|
+
const altEnd = findClosingBracket(line, cursor + 2);
|
|
169
|
+
if (altEnd < 0) continue;
|
|
170
|
+
const alt = line.slice(cursor + 2, altEnd);
|
|
171
|
+
const next = line[altEnd + 1];
|
|
172
|
+
if (next === '(') {
|
|
173
|
+
const parsed = parseInlineDestination(line, altEnd + 2);
|
|
174
|
+
if (parsed?.source) sources.add(parsed.source);
|
|
175
|
+
cursor = parsed?.end ?? altEnd;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
let label = alt;
|
|
179
|
+
if (next === '[') {
|
|
180
|
+
const labelEnd = findClosingBracket(line, altEnd + 2);
|
|
181
|
+
if (labelEnd < 0) continue;
|
|
182
|
+
label = line.slice(altEnd + 2, labelEnd) || alt;
|
|
183
|
+
cursor = labelEnd;
|
|
184
|
+
} else {
|
|
185
|
+
cursor = altEnd;
|
|
186
|
+
}
|
|
187
|
+
const source = definitions.get(normalizeReferenceLabel(label));
|
|
188
|
+
if (source) sources.add(source);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return sources;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const fetchMessage = async ({ sessionId, messageId, directory, buildOpenCodeUrl, getOpenCodeAuthHeaders }) => {
|
|
195
|
+
const url = new URL(buildOpenCodeUrl(
|
|
196
|
+
`/session/${encodeURIComponent(sessionId)}/message/${encodeURIComponent(messageId)}`,
|
|
197
|
+
'',
|
|
198
|
+
));
|
|
199
|
+
url.searchParams.set('directory', directory);
|
|
200
|
+
const response = await fetch(url, {
|
|
201
|
+
headers: {
|
|
202
|
+
accept: 'application/json',
|
|
203
|
+
'x-opencode-directory': directory,
|
|
204
|
+
...getOpenCodeAuthHeaders(),
|
|
205
|
+
},
|
|
206
|
+
signal: AbortSignal.timeout(10_000),
|
|
207
|
+
});
|
|
208
|
+
if (response.status === 404) return null;
|
|
209
|
+
if (!response.ok) throw new Error(`OpenCode returned ${response.status}`);
|
|
210
|
+
const message = await response.json().catch(() => null);
|
|
211
|
+
return message?.info && Array.isArray(message.parts) ? message : null;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const inspectImage = async ({ source, directory, approvedTempRoot, fsPromises, path }) => {
|
|
215
|
+
const parsed = parseFileSource(source);
|
|
216
|
+
if (!parsed) return { status: 'error' };
|
|
217
|
+
const sourcePath = path.isAbsolute(parsed) ? parsed : path.resolve(directory, parsed);
|
|
218
|
+
const workspaceRoot = path.resolve(directory);
|
|
219
|
+
const outsideWorkspace = !isWithin(path.resolve(sourcePath), workspaceRoot, path);
|
|
220
|
+
const root = outsideWorkspace ? approvedTempRoot : workspaceRoot;
|
|
221
|
+
|
|
222
|
+
try {
|
|
223
|
+
// Resolve symlinks before comparing roots; lexical prefixes are not an authorization boundary.
|
|
224
|
+
const [canonicalRoot, canonicalPath] = await Promise.all([
|
|
225
|
+
fsPromises.realpath(root),
|
|
226
|
+
fsPromises.realpath(sourcePath),
|
|
227
|
+
]);
|
|
228
|
+
if (!isWithin(canonicalPath, canonicalRoot, path)) return { status: 'error' };
|
|
229
|
+
const handle = await fsPromises.open(canonicalPath, fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW);
|
|
230
|
+
try {
|
|
231
|
+
const stats = await handle.stat();
|
|
232
|
+
if (!stats.isFile() || stats.size > MAX_IMAGE_BYTES) return { status: 'error' };
|
|
233
|
+
const header = Buffer.alloc(12);
|
|
234
|
+
const { bytesRead } = await handle.read(header, 0, header.length, 0);
|
|
235
|
+
if (!hasImageSignature(header.subarray(0, bytesRead))) return { status: 'error' };
|
|
236
|
+
return {
|
|
237
|
+
status: 'ready',
|
|
238
|
+
path: outsideWorkspace ? canonicalPath : path.resolve(sourcePath),
|
|
239
|
+
outsideWorkspace,
|
|
240
|
+
};
|
|
241
|
+
} finally {
|
|
242
|
+
await handle.close();
|
|
243
|
+
}
|
|
244
|
+
} catch (error) {
|
|
245
|
+
if (error?.code === 'ENOENT') return { status: 'missing' };
|
|
246
|
+
if (error?.code === 'EACCES' || error?.code === 'EPERM' || error?.code === 'ELOOP') {
|
|
247
|
+
return { status: 'error' };
|
|
248
|
+
}
|
|
249
|
+
throw error;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export const registerMarkdownImageGrantRoutes = (app, dependencies) => {
|
|
254
|
+
const {
|
|
255
|
+
fsPromises,
|
|
256
|
+
path,
|
|
257
|
+
os,
|
|
258
|
+
crypto,
|
|
259
|
+
validateDirectoryPath,
|
|
260
|
+
buildOpenCodeUrl,
|
|
261
|
+
getOpenCodeAuthHeaders,
|
|
262
|
+
approvedTempRoot = path.join(os.tmpdir(), 'opencode'),
|
|
263
|
+
} = dependencies;
|
|
264
|
+
|
|
265
|
+
app.post(
|
|
266
|
+
'/api/openchamber/sessions/:sessionId/markdown-image-grants',
|
|
267
|
+
express.json({ limit: '32kb' }),
|
|
268
|
+
async (req, res) => {
|
|
269
|
+
const sessionId = asString(req.params.sessionId);
|
|
270
|
+
const messageId = asString(req.body?.messageId);
|
|
271
|
+
const sources = Array.isArray(req.body?.sources)
|
|
272
|
+
? [...new Set(req.body.sources.map(asString).filter(Boolean))]
|
|
273
|
+
: [];
|
|
274
|
+
if (!sessionId || !messageId || sources.length === 0 || sources.length > MAX_IMAGE_SOURCES) {
|
|
275
|
+
return res.status(400).json({ error: 'sessionId, messageId, and 1-12 sources are required' });
|
|
276
|
+
}
|
|
277
|
+
const validatedDirectory = await validateDirectoryPath(asString(req.body?.directory));
|
|
278
|
+
if (!validatedDirectory.ok) {
|
|
279
|
+
return res.status(400).json({ error: validatedDirectory.error || 'Invalid directory' });
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
try {
|
|
283
|
+
const message = await fetchMessage({
|
|
284
|
+
sessionId,
|
|
285
|
+
messageId,
|
|
286
|
+
directory: validatedDirectory.directory,
|
|
287
|
+
buildOpenCodeUrl,
|
|
288
|
+
getOpenCodeAuthHeaders,
|
|
289
|
+
});
|
|
290
|
+
if (!message || message.info?.id !== messageId || message.info?.role !== 'assistant') {
|
|
291
|
+
return res.status(404).json({ error: 'Assistant message not found' });
|
|
292
|
+
}
|
|
293
|
+
// Assistant text is authoritative: a remote client cannot mint grants for unreferenced paths.
|
|
294
|
+
const referenced = markdownImageSources(message);
|
|
295
|
+
const results = [];
|
|
296
|
+
for (const source of sources) {
|
|
297
|
+
if (!referenced.has(source)) {
|
|
298
|
+
results.push({ source, status: 'error' });
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
try {
|
|
302
|
+
const inspected = await inspectImage({
|
|
303
|
+
source,
|
|
304
|
+
directory: validatedDirectory.directory,
|
|
305
|
+
approvedTempRoot,
|
|
306
|
+
fsPromises,
|
|
307
|
+
path,
|
|
308
|
+
});
|
|
309
|
+
if (inspected.status !== 'ready') {
|
|
310
|
+
results.push({ source, status: inspected.status });
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
// Reuse the existing path-bound raw-file grant instead of creating another asset lifecycle.
|
|
314
|
+
const grant = inspected.outsideWorkspace
|
|
315
|
+
? await mintOutsideFileGrant(inspected.path, {
|
|
316
|
+
scopes: ['raw'],
|
|
317
|
+
fsPromises,
|
|
318
|
+
path,
|
|
319
|
+
crypto,
|
|
320
|
+
})
|
|
321
|
+
: null;
|
|
322
|
+
results.push({
|
|
323
|
+
source,
|
|
324
|
+
status: 'ready',
|
|
325
|
+
path: inspected.path,
|
|
326
|
+
outsideFileGrant: grant?.outsideFileGrant,
|
|
327
|
+
expiresAt: grant?.expiresAt,
|
|
328
|
+
});
|
|
329
|
+
} catch {
|
|
330
|
+
results.push({ source, status: 'error' });
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return res.json({ results });
|
|
334
|
+
} catch (error) {
|
|
335
|
+
console.warn('[MarkdownImageGrants] failed to prepare images:', error?.message || error);
|
|
336
|
+
return res.status(503).json({ error: 'Failed to prepare session images' });
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
);
|
|
340
|
+
};
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import request from 'supertest';
|
|
4
|
+
import crypto from 'node:crypto';
|
|
5
|
+
import fs from 'node:fs/promises';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { registerMarkdownImageGrantRoutes } from './routes.js';
|
|
9
|
+
|
|
10
|
+
const PNG = Buffer.from(
|
|
11
|
+
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==',
|
|
12
|
+
'base64',
|
|
13
|
+
);
|
|
14
|
+
const roots = [];
|
|
15
|
+
|
|
16
|
+
afterEach(async () => {
|
|
17
|
+
vi.unstubAllGlobals();
|
|
18
|
+
await Promise.all(roots.splice(0).map((root) => fs.rm(root, { recursive: true, force: true })));
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const createFixture = async ({ sources, markdown } = {}) => {
|
|
22
|
+
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'openchamber-session-assets-'));
|
|
23
|
+
roots.push(root);
|
|
24
|
+
const approvedTempRoot = path.join(root, 'opencode');
|
|
25
|
+
const directory = path.join(root, 'workspace');
|
|
26
|
+
await Promise.all([
|
|
27
|
+
fs.mkdir(approvedTempRoot, { recursive: true }),
|
|
28
|
+
fs.mkdir(directory, { recursive: true }),
|
|
29
|
+
]);
|
|
30
|
+
const defaultPath = path.join(approvedTempRoot, 'image.png');
|
|
31
|
+
await fs.writeFile(defaultPath, PNG);
|
|
32
|
+
const requestedSources = sources ?? [new URL(`file://${defaultPath}`).toString()];
|
|
33
|
+
const text = markdown ?? requestedSources.map((source) => ``).join('\n');
|
|
34
|
+
const fetchMock = vi.fn(async () => new Response(JSON.stringify({
|
|
35
|
+
info: { id: 'msg_1', role: 'assistant' },
|
|
36
|
+
parts: [{ type: 'text', text }],
|
|
37
|
+
}), { status: 200, headers: { 'content-type': 'application/json' } }));
|
|
38
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
39
|
+
|
|
40
|
+
let fullReadCount = 0;
|
|
41
|
+
const app = express();
|
|
42
|
+
registerMarkdownImageGrantRoutes(app, {
|
|
43
|
+
fsPromises: {
|
|
44
|
+
...fs,
|
|
45
|
+
readFile: async (...args) => {
|
|
46
|
+
fullReadCount += 1;
|
|
47
|
+
return fs.readFile(...args);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
path,
|
|
51
|
+
os,
|
|
52
|
+
crypto,
|
|
53
|
+
approvedTempRoot,
|
|
54
|
+
validateDirectoryPath: async (candidate) => candidate === directory
|
|
55
|
+
? { ok: true, directory }
|
|
56
|
+
: { ok: false, error: 'Invalid directory' },
|
|
57
|
+
buildOpenCodeUrl: (route) => `http://opencode.test${route}`,
|
|
58
|
+
getOpenCodeAuthHeaders: () => ({ authorization: 'Basic test' }),
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
app,
|
|
62
|
+
approvedTempRoot,
|
|
63
|
+
directory,
|
|
64
|
+
fetchMock,
|
|
65
|
+
fullReadCount: () => fullReadCount,
|
|
66
|
+
root,
|
|
67
|
+
sources: requestedSources,
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const prepare = (app, directory, sources) => request(app)
|
|
72
|
+
.post('/api/openchamber/sessions/ses_1/markdown-image-grants')
|
|
73
|
+
.send({ directory, messageId: 'msg_1', sources })
|
|
74
|
+
.expect(200);
|
|
75
|
+
|
|
76
|
+
describe('session image assets', () => {
|
|
77
|
+
it('prepares workspace and OpenCode temporary images with one message fetch', async () => {
|
|
78
|
+
const fixture = await createFixture({ sources: ['workspace.png'] });
|
|
79
|
+
await fs.writeFile(path.join(fixture.directory, 'workspace.png'), PNG);
|
|
80
|
+
const temporaryPath = path.join(fixture.approvedTempRoot, 'temporary.png');
|
|
81
|
+
await fs.writeFile(temporaryPath, PNG);
|
|
82
|
+
const temporarySource = new URL(`file://${temporaryPath}`).toString();
|
|
83
|
+
fixture.fetchMock.mockResolvedValueOnce(new Response(JSON.stringify({
|
|
84
|
+
info: { id: 'msg_1', role: 'assistant' },
|
|
85
|
+
parts: [{ type: 'text', text: `\n` }],
|
|
86
|
+
}), { status: 200, headers: { 'content-type': 'application/json' } }));
|
|
87
|
+
|
|
88
|
+
const response = await prepare(fixture.app, fixture.directory, ['workspace.png', temporarySource]);
|
|
89
|
+
|
|
90
|
+
expect(fixture.fetchMock).toHaveBeenCalledTimes(1);
|
|
91
|
+
expect(fixture.fullReadCount()).toBe(0);
|
|
92
|
+
expect(response.body.results).toHaveLength(2);
|
|
93
|
+
const canonicalTemporaryPath = await fs.realpath(temporaryPath);
|
|
94
|
+
expect(response.body.results[0]).toEqual({
|
|
95
|
+
source: 'workspace.png',
|
|
96
|
+
status: 'ready',
|
|
97
|
+
path: path.join(fixture.directory, 'workspace.png'),
|
|
98
|
+
});
|
|
99
|
+
expect(response.body.results[1]).toEqual(expect.objectContaining({
|
|
100
|
+
source: temporarySource,
|
|
101
|
+
status: 'ready',
|
|
102
|
+
path: canonicalTemporaryPath,
|
|
103
|
+
outsideFileGrant: expect.any(String),
|
|
104
|
+
expiresAt: expect.any(Number),
|
|
105
|
+
}));
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('returns partial results without letting one missing image block valid images', async () => {
|
|
109
|
+
const fixture = await createFixture({ sources: ['present.png', 'deleted.png'] });
|
|
110
|
+
await fs.writeFile(path.join(fixture.directory, 'present.png'), PNG);
|
|
111
|
+
|
|
112
|
+
const response = await prepare(fixture.app, fixture.directory, fixture.sources);
|
|
113
|
+
|
|
114
|
+
expect(response.body.results).toEqual([
|
|
115
|
+
expect.objectContaining({ source: 'present.png', status: 'ready' }),
|
|
116
|
+
{ source: 'deleted.png', status: 'missing' },
|
|
117
|
+
]);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('resolves encoded workspace paths without treating query or fragment text as a filename', async () => {
|
|
121
|
+
const source = 'screen%20shot.png?version=1#preview';
|
|
122
|
+
const fixture = await createFixture({ sources: [source] });
|
|
123
|
+
await fs.writeFile(path.join(fixture.directory, 'screen shot.png'), PNG);
|
|
124
|
+
|
|
125
|
+
const response = await prepare(fixture.app, fixture.directory, fixture.sources);
|
|
126
|
+
|
|
127
|
+
expect(response.body.results).toEqual([
|
|
128
|
+
expect.objectContaining({ source, status: 'ready' }),
|
|
129
|
+
]);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('authorizes reference-style image syntax using its resolved destination', async () => {
|
|
133
|
+
const source = 'reference.png';
|
|
134
|
+
const fixture = await createFixture({
|
|
135
|
+
sources: [source],
|
|
136
|
+
markdown: '![screenshot][result]\n\n[result]: reference.png',
|
|
137
|
+
});
|
|
138
|
+
await fs.writeFile(path.join(fixture.directory, source), PNG);
|
|
139
|
+
|
|
140
|
+
const response = await prepare(fixture.app, fixture.directory, fixture.sources);
|
|
141
|
+
|
|
142
|
+
expect(response.body.results).toEqual([
|
|
143
|
+
expect.objectContaining({ source, status: 'ready' }),
|
|
144
|
+
]);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('authorizes inline image destinations containing balanced parentheses', async () => {
|
|
148
|
+
const source = 'screen(1).png';
|
|
149
|
+
const fixture = await createFixture({
|
|
150
|
+
sources: [source],
|
|
151
|
+
markdown: ``,
|
|
152
|
+
});
|
|
153
|
+
await fs.writeFile(path.join(fixture.directory, source), PNG);
|
|
154
|
+
|
|
155
|
+
const response = await prepare(fixture.app, fixture.directory, fixture.sources);
|
|
156
|
+
|
|
157
|
+
expect(response.body.results).toEqual([
|
|
158
|
+
expect.objectContaining({ source, status: 'ready' }),
|
|
159
|
+
]);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('requires inline image destinations with titles to close', async () => {
|
|
163
|
+
const sources = ['valid.png', 'malformed.png'];
|
|
164
|
+
const fixture = await createFixture({
|
|
165
|
+
sources,
|
|
166
|
+
markdown: '\n;
|
|
168
|
+
await Promise.all(sources.map((source) => fs.writeFile(path.join(fixture.directory, source), PNG)));
|
|
169
|
+
|
|
170
|
+
const response = await prepare(fixture.app, fixture.directory, sources);
|
|
171
|
+
|
|
172
|
+
expect(response.body.results).toEqual([
|
|
173
|
+
expect.objectContaining({ source: 'valid.png', status: 'ready' }),
|
|
174
|
+
{ source: 'malformed.png', status: 'error' },
|
|
175
|
+
]);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('rejects a source that the message does not reference', async () => {
|
|
179
|
+
const fixture = await createFixture({ markdown: 'No image here.' });
|
|
180
|
+
const response = await prepare(fixture.app, fixture.directory, fixture.sources);
|
|
181
|
+
expect(response.body.results).toEqual([{ source: fixture.sources[0], status: 'error' }]);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('does not authorize image syntax inside fenced or inline code', async () => {
|
|
185
|
+
const fixture = await createFixture({
|
|
186
|
+
markdown: '```md\n\n```\n``',
|
|
187
|
+
});
|
|
188
|
+
const sources = ['FENCED', 'INLINE'];
|
|
189
|
+
|
|
190
|
+
const response = await prepare(fixture.app, fixture.directory, sources);
|
|
191
|
+
|
|
192
|
+
expect(response.body.results).toEqual(sources.map((source) => ({ source, status: 'error' })));
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('rejects paths outside the workspace and approved temporary root', async () => {
|
|
196
|
+
const fixture = await createFixture();
|
|
197
|
+
const outsidePath = path.join(fixture.root, 'outside.png');
|
|
198
|
+
await fs.writeFile(outsidePath, PNG);
|
|
199
|
+
const source = new URL(`file://${outsidePath}`).toString();
|
|
200
|
+
fixture.fetchMock.mockResolvedValueOnce(new Response(JSON.stringify({
|
|
201
|
+
info: { id: 'msg_1', role: 'assistant' },
|
|
202
|
+
parts: [{ type: 'text', text: `` }],
|
|
203
|
+
}), { status: 200, headers: { 'content-type': 'application/json' } }));
|
|
204
|
+
|
|
205
|
+
const response = await prepare(fixture.app, fixture.directory, [source]);
|
|
206
|
+
expect(response.body.results).toEqual([{ source, status: 'error' }]);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('rejects non-image bytes and symlink escapes per source', async () => {
|
|
210
|
+
const fixture = await createFixture({ sources: ['invalid.png', 'linked.png'] });
|
|
211
|
+
await fs.writeFile(path.join(fixture.directory, 'invalid.png'), 'not an image');
|
|
212
|
+
await fs.writeFile(path.join(fixture.root, 'outside.png'), PNG);
|
|
213
|
+
await fs.symlink(path.join(fixture.root, 'outside.png'), path.join(fixture.directory, 'linked.png'));
|
|
214
|
+
|
|
215
|
+
const response = await prepare(fixture.app, fixture.directory, fixture.sources);
|
|
216
|
+
expect(response.body.results).toEqual([
|
|
217
|
+
{ source: 'invalid.png', status: 'error' },
|
|
218
|
+
{ source: 'linked.png', status: 'error' },
|
|
219
|
+
]);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
@@ -53,3 +53,12 @@ other.
|
|
|
53
53
|
directory and does not erase other session results.
|
|
54
54
|
- Destructive session/worktree deletion and project-path registration are not
|
|
55
55
|
part of the action contract.
|
|
56
|
+
- `browser.capture` writes its image on the server, into
|
|
57
|
+
`.openchamber/screenshots/` under the scoped project directory, and returns
|
|
58
|
+
the project-relative path rather than the image bytes. The client that took
|
|
59
|
+
the picture may be on a different machine than the repository, and a path is
|
|
60
|
+
what an answer, a commit, or a review can use; base64 in a tool result cannot
|
|
61
|
+
be any of those. The agent's label is reduced to a filename fragment, never
|
|
62
|
+
used as a path. The result also states how to present the image, because chat
|
|
63
|
+
renders the image paths written in a finished answer below that message —
|
|
64
|
+
saving the file is not what shows it to anyone.
|