@xcanwin/manyoyo 5.7.12 → 5.7.13
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/lib/web/server.js +46 -6
- package/package.json +1 -1
package/lib/web/server.js
CHANGED
|
@@ -158,17 +158,57 @@ function normalizeWebAgentSessionRecord(agentId, rawAgent) {
|
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
function resolveEffectiveAgentPromptCommand(template, applied) {
|
|
162
|
+
const normalizedTemplate = normalizeAgentPromptCommandTemplate(template, 'agentPromptCommand');
|
|
163
|
+
if (!normalizedTemplate) {
|
|
164
|
+
return '';
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const program = resolveAgentProgram(normalizedTemplate);
|
|
168
|
+
const defaultCommand = applied && typeof applied === 'object'
|
|
169
|
+
? String(applied.defaultCommand || '').trim()
|
|
170
|
+
: '';
|
|
171
|
+
if (!program || !defaultCommand) {
|
|
172
|
+
return normalizedTemplate;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const defaultProgram = resolveAgentProgram(defaultCommand);
|
|
176
|
+
if (!defaultProgram || defaultProgram !== program) {
|
|
177
|
+
return normalizedTemplate;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const genericTemplate = normalizeAgentPromptCommandTemplate(
|
|
181
|
+
resolveAgentPromptCommandTemplate(program),
|
|
182
|
+
'agentPromptCommand'
|
|
183
|
+
);
|
|
184
|
+
if (normalizedTemplate !== genericTemplate) {
|
|
185
|
+
return normalizedTemplate;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const inferredTemplate = normalizeAgentPromptCommandTemplate(
|
|
189
|
+
resolveAgentPromptCommandTemplate(defaultCommand),
|
|
190
|
+
'agentPromptCommand'
|
|
191
|
+
);
|
|
192
|
+
if (!inferredTemplate || inferredTemplate === genericTemplate) {
|
|
193
|
+
return normalizedTemplate;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return inferredTemplate;
|
|
197
|
+
}
|
|
198
|
+
|
|
161
199
|
function normalizeWebHistoryRecord(containerName, rawData) {
|
|
162
200
|
const data = rawData && typeof rawData === 'object' && !Array.isArray(rawData) ? rawData : {};
|
|
201
|
+
const applied = data.applied && typeof data.applied === 'object' && !Array.isArray(data.applied)
|
|
202
|
+
? data.applied
|
|
203
|
+
: null;
|
|
163
204
|
const history = {
|
|
164
205
|
containerName,
|
|
165
206
|
updatedAt: typeof data.updatedAt === 'string' ? data.updatedAt : null,
|
|
166
|
-
agentPromptCommand:
|
|
167
|
-
? data.agentPromptCommand
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
: null,
|
|
207
|
+
agentPromptCommand: resolveEffectiveAgentPromptCommand(
|
|
208
|
+
typeof data.agentPromptCommand === 'string' ? data.agentPromptCommand : '',
|
|
209
|
+
applied
|
|
210
|
+
),
|
|
211
|
+
applied,
|
|
172
212
|
agents: {}
|
|
173
213
|
};
|
|
174
214
|
|