@yeaft/webchat-agent 1.0.494 → 1.0.495
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.
|
@@ -185,7 +185,8 @@ async function handleOneShotResponse(agentId, agent, msg, routeKey) {
|
|
|
185
185
|
userId: pending.userId,
|
|
186
186
|
role: pending.role,
|
|
187
187
|
});
|
|
188
|
-
if (
|
|
188
|
+
if (currentGeneration === null) return;
|
|
189
|
+
if (currentGeneration && currentGeneration !== pending.workspaceGeneration) return;
|
|
189
190
|
const projected = msg.type === 'file_content' && msg.binary
|
|
190
191
|
? cacheBinaryPreview(msg)
|
|
191
192
|
: msg;
|
|
@@ -37,8 +37,20 @@ function isYeaftVirtualConversation(conversationId) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
async function denyWorkbenchRoute(client, msg) {
|
|
40
|
+
const error = 'Invalid Workbench Session route';
|
|
40
41
|
console.warn(`[Security] Invalid Workbench route for ${msg?.type || 'unknown'}`);
|
|
41
|
-
|
|
42
|
+
const response = workbenchFailureResponse({
|
|
43
|
+
agentId: msg?.agentId || client.currentAgent,
|
|
44
|
+
msg,
|
|
45
|
+
resolved: {
|
|
46
|
+
conversationId: msg?.conversationId,
|
|
47
|
+
routeKey: msg?.workbenchRouteKey,
|
|
48
|
+
workspaceGeneration: msg?.workbenchWorkspaceGeneration,
|
|
49
|
+
},
|
|
50
|
+
error,
|
|
51
|
+
});
|
|
52
|
+
if (response) await sendToWebClient(client, response);
|
|
53
|
+
await sendToWebClient(client, { type: 'error', message: error });
|
|
42
54
|
}
|
|
43
55
|
|
|
44
56
|
const AGENT_DIRECTORY_PICKER_CONVERSATION = '_workdir_picker';
|
|
@@ -93,10 +105,9 @@ const FILE_OPERATIONS = Object.freeze({
|
|
|
93
105
|
upload_to_dir: 'upload',
|
|
94
106
|
});
|
|
95
107
|
|
|
96
|
-
function
|
|
108
|
+
function workbenchFailureResponse({ agentId, msg, resolved, error }) {
|
|
97
109
|
const type = TIMEOUT_RESPONSE_TYPES[msg.type];
|
|
98
110
|
if (!type) return null;
|
|
99
|
-
const error = 'Workbench request timed out';
|
|
100
111
|
const response = {
|
|
101
112
|
type,
|
|
102
113
|
agentId,
|
|
@@ -189,7 +200,12 @@ function correlateWorkbenchRequest({ agentId, clientId, client, msg, resolved, c
|
|
|
189
200
|
allowLegacyCorrelation: !supportsRequestCorrelation,
|
|
190
201
|
onTimeout: async () => {
|
|
191
202
|
if (!client.authenticated || client.userId !== registration.userId) return;
|
|
192
|
-
const response =
|
|
203
|
+
const response = workbenchFailureResponse({
|
|
204
|
+
agentId,
|
|
205
|
+
msg,
|
|
206
|
+
resolved,
|
|
207
|
+
error: 'Workbench request timed out',
|
|
208
|
+
});
|
|
193
209
|
if (response) await sendToWebClient(client, response);
|
|
194
210
|
},
|
|
195
211
|
};
|
|
@@ -120,14 +120,19 @@ function resolveChatRow(client, route) {
|
|
|
120
120
|
*
|
|
121
121
|
* `legacy: true` preserves old clients that predate route-scoped Workbench.
|
|
122
122
|
*/
|
|
123
|
+
/**
|
|
124
|
+
* Return null when the route is no longer valid, an empty string when the
|
|
125
|
+
* Session is valid but has no Server-owned cwd, or its canonical generation.
|
|
126
|
+
*/
|
|
123
127
|
export function currentWorkbenchWorkspaceGeneration({ route, userId, role }) {
|
|
124
|
-
if (!route || !userId) return
|
|
128
|
+
if (!route || !userId) return null;
|
|
125
129
|
const client = { userId, role };
|
|
126
130
|
const row = route.runtimeProvider === 'yeaft'
|
|
127
131
|
? resolveYeaftRow(client, route)
|
|
128
132
|
: resolveChatRow(client, route);
|
|
129
|
-
if (!row || row.isArchived) return
|
|
133
|
+
if (!row || row.isArchived) return null;
|
|
130
134
|
const workDir = clean(route.runtimeProvider === 'yeaft' ? row.workDir : row.work_dir, 4096);
|
|
135
|
+
if (!workDir) return '';
|
|
131
136
|
return workbenchWorkspaceGeneration(workbenchRouteKey(route), workDir);
|
|
132
137
|
}
|
|
133
138
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.0.
|
|
1
|
+
{"version":"1.0.495"}
|
package/package.json
CHANGED