@yeaft/webchat-agent 1.0.620 → 1.0.622

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "1.0.620",
3
+ "version": "1.0.622",
4
4
  "description": "Remote worker agent for Yeaft Web Code Agent — connects the native Yeaft engine, CLI providers, and workbench tools",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -37,14 +37,22 @@ async function validateResponseImagePath(filePath, workDir) {
37
37
  return canonicalFile;
38
38
  }
39
39
 
40
- async function canonicalVideoFile(filePath, workDir) {
41
- const canonicalRoot = await realpath(resolve(workDir));
42
- const resolved = await realpath(resolveAndValidatePath(filePath, canonicalRoot));
43
- const relativePath = relative(canonicalRoot, resolved);
44
- const outside = relativePath === '..'
45
- || relativePath.startsWith(`..${platform() === 'win32' ? '\\' : '/'}`)
46
- || isAbsolute(relativePath);
47
- if (outside) throw new Error('Video is outside the active workspace.');
40
+ /**
41
+ * Explicit Files actions operate on Agent-local paths, not just the Session cwd.
42
+ * WorkItem routes remain confined to their Agent-resolved workspace; automatic
43
+ * response image reads use the separate canonicalWorkspaceReadPath check above.
44
+ */
45
+ async function canonicalWorkbenchReadPath(msg, filePath, workDir) {
46
+ const resolved = await resolveWorkItemPath(msg, filePath, workDir);
47
+ // Old preview capabilities predate explicit external reads. Preserve their
48
+ // original workspace boundary on cache refills, without an image-only check.
49
+ return msg.workspaceBoundPreview === true
50
+ ? canonicalWorkspaceReadPath(resolved, workDir)
51
+ : realpath(resolved);
52
+ }
53
+
54
+ async function canonicalVideoFile(msg, filePath, workDir) {
55
+ const resolved = await canonicalWorkbenchReadPath(msg, filePath, workDir);
48
56
  const mimeType = VIDEO_EXTENSIONS[extname(resolved).toLowerCase()];
49
57
  if (!mimeType) throw new Error('Unsupported video format.');
50
58
  return { resolved, mimeType };
@@ -53,7 +61,7 @@ async function canonicalVideoFile(filePath, workDir) {
53
61
  export async function handleVideoMetadata(msg) {
54
62
  const { conversationId, filePath, requestId, _requestUserId, _requestClientId } = msg;
55
63
  try {
56
- const { resolved, mimeType } = await canonicalVideoFile(filePath, msg.workDir || ctx.CONFIG.workDir);
64
+ const { resolved, mimeType } = await canonicalVideoFile(msg, filePath, msg.workDir || ctx.conversations.get(conversationId)?.workDir || ctx.CONFIG.workDir);
57
65
  const handle = await open(resolved, 'r');
58
66
  try {
59
67
  const fileStat = await handle.stat();
@@ -79,7 +87,7 @@ export async function handleVideoChunk(msg) {
79
87
  const { conversationId, filePath, requestId, _requestUserId, _requestClientId } = msg;
80
88
  let handle;
81
89
  try {
82
- const { resolved, mimeType } = await canonicalVideoFile(filePath, msg.workDir || ctx.CONFIG.workDir);
90
+ const { resolved, mimeType } = await canonicalVideoFile(msg, filePath, msg.workDir || ctx.conversations.get(conversationId)?.workDir || ctx.CONFIG.workDir);
83
91
  handle = await open(resolved, 'r');
84
92
  const fileStat = await handle.stat();
85
93
  if (!fileStat.isFile() || !Number.isSafeInteger(fileStat.size)) throw new Error('Video path is not a supported file.');
@@ -183,7 +191,7 @@ export async function handleReadFile(msg) {
183
191
  try {
184
192
  const resolved = msg.responseImagePreview
185
193
  ? await validateResponseImagePath(filePath, workDir)
186
- : await canonicalWorkspaceReadPath(filePath, workDir);
194
+ : await canonicalWorkbenchReadPath(msg, filePath, workDir);
187
195
  const ext = extname(resolved).toLowerCase();
188
196
  if (VIDEO_EXTENSIONS[ext]) {
189
197
  const error = new Error('Video files require the Workbench streaming protocol.');