@yeaft/webchat-agent 1.0.226 → 1.0.228
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/local-runtime/server/handlers/agent-file-terminal.js +11 -2
- package/local-runtime/server/handlers/client-workbench.js +6 -1
- package/local-runtime/server/ws-agent.js +2 -1
- package/local-runtime/version.json +1 -1
- package/local-runtime/web/app.bundle.js +71 -71
- package/local-runtime/web/app.bundle.js.gz +0 -0
- package/local-runtime/web/index.html +1 -1
- package/package.json +1 -1
- package/terminal.js +24 -8
|
Binary file
|
package/package.json
CHANGED
package/terminal.js
CHANGED
|
@@ -58,11 +58,19 @@ export async function loadNodePty() {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
function terminalRoutingFields(source) {
|
|
62
|
+
return {
|
|
63
|
+
...(source?._requestUserId ? { _requestUserId: source._requestUserId } : {}),
|
|
64
|
+
...(source?._requestClientId ? { _requestClientId: source._requestClientId } : {}),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
61
68
|
export async function handleTerminalCreate(msg) {
|
|
62
69
|
const { conversationId, cols, rows } = msg;
|
|
63
70
|
const terminalId = msg.terminalId || conversationId;
|
|
64
71
|
const conv = ctx.conversations.get(conversationId);
|
|
65
72
|
const workDir = conv?.workDir || ctx.CONFIG.workDir;
|
|
73
|
+
const routingFields = terminalRoutingFields(msg);
|
|
66
74
|
|
|
67
75
|
// 如果已存在终端,先关闭
|
|
68
76
|
if (ctx.terminals.has(terminalId)) {
|
|
@@ -80,7 +88,8 @@ export async function handleTerminalCreate(msg) {
|
|
|
80
88
|
type: 'terminal_error',
|
|
81
89
|
conversationId,
|
|
82
90
|
terminalId,
|
|
83
|
-
message: 'Terminal backend is not installed. Run: npm install'
|
|
91
|
+
message: 'Terminal backend is not installed. Run: npm install',
|
|
92
|
+
...routingFields,
|
|
84
93
|
});
|
|
85
94
|
return;
|
|
86
95
|
}
|
|
@@ -123,7 +132,8 @@ export async function handleTerminalCreate(msg) {
|
|
|
123
132
|
type: 'terminal_output',
|
|
124
133
|
conversationId,
|
|
125
134
|
terminalId,
|
|
126
|
-
data: buffer
|
|
135
|
+
data: buffer,
|
|
136
|
+
...routingFields,
|
|
127
137
|
});
|
|
128
138
|
buffer = '';
|
|
129
139
|
timer = null;
|
|
@@ -138,7 +148,8 @@ export async function handleTerminalCreate(msg) {
|
|
|
138
148
|
type: 'terminal_output',
|
|
139
149
|
conversationId,
|
|
140
150
|
terminalId,
|
|
141
|
-
data: buffer
|
|
151
|
+
data: buffer,
|
|
152
|
+
...routingFields,
|
|
142
153
|
});
|
|
143
154
|
buffer = '';
|
|
144
155
|
}
|
|
@@ -149,7 +160,8 @@ export async function handleTerminalCreate(msg) {
|
|
|
149
160
|
ctx.sendToServer({
|
|
150
161
|
type: 'terminal_closed',
|
|
151
162
|
conversationId,
|
|
152
|
-
terminalId
|
|
163
|
+
terminalId,
|
|
164
|
+
...routingFields,
|
|
153
165
|
});
|
|
154
166
|
});
|
|
155
167
|
|
|
@@ -159,7 +171,8 @@ export async function handleTerminalCreate(msg) {
|
|
|
159
171
|
cols: cols || 80,
|
|
160
172
|
rows: rows || 24,
|
|
161
173
|
buffer: '',
|
|
162
|
-
timer: null
|
|
174
|
+
timer: null,
|
|
175
|
+
...routingFields,
|
|
163
176
|
});
|
|
164
177
|
|
|
165
178
|
console.log(`[PTY] Created terminal ${terminalId} for ${conversationId} in ${workDir}`);
|
|
@@ -167,7 +180,8 @@ export async function handleTerminalCreate(msg) {
|
|
|
167
180
|
type: 'terminal_created',
|
|
168
181
|
conversationId,
|
|
169
182
|
terminalId,
|
|
170
|
-
success: true
|
|
183
|
+
success: true,
|
|
184
|
+
...routingFields,
|
|
171
185
|
});
|
|
172
186
|
} catch (e) {
|
|
173
187
|
console.error(`[PTY] Failed to create terminal:`, e.message);
|
|
@@ -175,7 +189,8 @@ export async function handleTerminalCreate(msg) {
|
|
|
175
189
|
type: 'terminal_error',
|
|
176
190
|
conversationId,
|
|
177
191
|
terminalId,
|
|
178
|
-
message: `Failed to create terminal: ${e.message}
|
|
192
|
+
message: `Failed to create terminal: ${e.message}`,
|
|
193
|
+
...routingFields,
|
|
179
194
|
});
|
|
180
195
|
}
|
|
181
196
|
}
|
|
@@ -220,7 +235,8 @@ export function handleTerminalClose(msg) {
|
|
|
220
235
|
ctx.sendToServer({
|
|
221
236
|
type: 'terminal_closed',
|
|
222
237
|
conversationId: term.conversationId || msg.conversationId,
|
|
223
|
-
terminalId
|
|
238
|
+
terminalId,
|
|
239
|
+
...terminalRoutingFields(term),
|
|
224
240
|
});
|
|
225
241
|
}
|
|
226
242
|
}
|