@webmcp-auto-ui/agent 2.5.8 → 2.5.10
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 +1 -1
- package/src/autoui-server.ts +134 -134
- package/src/diagnostics.ts +3 -3
- package/src/loop.ts +6 -6
- package/src/providers/wasm.ts +5 -5
- package/src/recipes/_generated.ts +446 -446
- package/src/recipes/afficher-oeuvres-art-collection-musee.md +45 -45
- package/src/recipes/analyser-actualites-hacker-news.md +52 -52
- package/src/recipes/cartographier-observations-biodiversite.md +44 -44
- package/src/recipes/cross-server.md +48 -48
- package/src/recipes/dashboard-kpi.md +45 -45
- package/src/recipes/explorer-dossiers-legislatifs-parcours-texte.md +48 -48
- package/src/recipes/gallery-images.md +33 -33
- package/src/recipes/parlementaire-profile.md +58 -58
- package/src/recipes/rechercher-textes-juridiques-legifrance.md +38 -38
- package/src/recipes/weather-viz.md +35 -35
- package/src/recipes/widgets/actions.md +6 -6
- package/src/recipes/widgets/alert.md +6 -6
- package/src/recipes/widgets/cards.md +10 -10
- package/src/recipes/widgets/carousel.md +8 -8
- package/src/recipes/widgets/chart-rich.md +10 -10
- package/src/recipes/widgets/chart.md +9 -9
- package/src/recipes/widgets/code.md +6 -6
- package/src/recipes/widgets/d3.md +10 -10
- package/src/recipes/widgets/data-table.md +10 -10
- package/src/recipes/widgets/gallery.md +10 -10
- package/src/recipes/widgets/grid-data.md +11 -11
- package/src/recipes/widgets/hemicycle.md +9 -9
- package/src/recipes/widgets/js-sandbox.md +10 -10
- package/src/recipes/widgets/json-viewer.md +8 -8
- package/src/recipes/widgets/kv.md +9 -9
- package/src/recipes/widgets/list.md +7 -7
- package/src/recipes/widgets/log.md +6 -6
- package/src/recipes/widgets/map.md +10 -10
- package/src/recipes/widgets/profile.md +9 -9
- package/src/recipes/widgets/recipe-browser.md +33 -33
- package/src/recipes/widgets/sankey.md +10 -10
- package/src/recipes/widgets/stat-card.md +7 -7
- package/src/recipes/widgets/stat.md +10 -10
- package/src/recipes/widgets/tags.md +6 -6
- package/src/recipes/widgets/text.md +6 -6
- package/src/recipes/widgets/timeline.md +6 -6
- package/src/recipes/widgets/trombinoscope.md +8 -8
- package/src/summarize.ts +6 -6
- package/src/tool-layers.ts +26 -26
package/src/loop.ts
CHANGED
|
@@ -56,7 +56,7 @@ function compressOldToolResults(messages: ChatMessage[], previewSize: number, re
|
|
|
56
56
|
const totalLen = block.content.length;
|
|
57
57
|
const id = block.tool_use_id;
|
|
58
58
|
if (resultBuffer && resultBuffer.has(id)) {
|
|
59
|
-
(block as any).content = `${preview}... [recall('${id}')
|
|
59
|
+
(block as any).content = `${preview}... [recall('${id}') for the full result, ${totalLen} chars]`;
|
|
60
60
|
} else {
|
|
61
61
|
(block as any).content = `${preview}... [compressed, ${totalLen} chars original]`;
|
|
62
62
|
}
|
|
@@ -80,10 +80,10 @@ function truncateResult(result: string, maxLen: number = MAX_RESULT_LEN): string
|
|
|
80
80
|
while (JSON.stringify(sliced).length > maxLen && sliced.length > 1) {
|
|
81
81
|
sliced = sliced.slice(0, Math.ceil(sliced.length / 2));
|
|
82
82
|
}
|
|
83
|
-
return JSON.stringify(sliced) + `\n... (
|
|
83
|
+
return JSON.stringify(sliced) + `\n... (truncated, ${parsed.length} items total)`;
|
|
84
84
|
}
|
|
85
85
|
} catch { /* not JSON */ }
|
|
86
|
-
return result.slice(0, maxLen) + '\n... (
|
|
86
|
+
return result.slice(0, maxLen) + '\n... (truncated)';
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export interface AgentLoopOptions {
|
|
@@ -184,7 +184,7 @@ export async function runAgentLoop(
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
const systemPrompt = maxTokens
|
|
187
|
-
? `${baseSystemPrompt}\n\nIMPORTANT
|
|
187
|
+
? `${baseSystemPrompt}\n\nIMPORTANT: Limit your responses to ${maxTokens} tokens.`
|
|
188
188
|
: baseSystemPrompt;
|
|
189
189
|
|
|
190
190
|
const messages: ChatMessage[] = [
|
|
@@ -297,7 +297,7 @@ export async function runAgentLoop(
|
|
|
297
297
|
if (!hasRendered && !nudgedOnce && metrics.toolCalls > 0) {
|
|
298
298
|
nudgedOnce = true;
|
|
299
299
|
messages.push({ role: 'assistant', content: response.content });
|
|
300
|
-
messages.push({ role: 'user', content: '
|
|
300
|
+
messages.push({ role: 'user', content: 'You have not displayed any visual result yet. Call widget_display() with the data you have collected.' });
|
|
301
301
|
continue;
|
|
302
302
|
}
|
|
303
303
|
messages.push({ role: 'assistant', content: response.content });
|
|
@@ -442,7 +442,7 @@ export async function runAgentLoop(
|
|
|
442
442
|
// Intercept recall BEFORE hitting executeTool — use the local resultBuffer directly
|
|
443
443
|
if (realToolName === 'recall' && resultBuffer.size > 0) {
|
|
444
444
|
const recallId = (toolInput as { id: string }).id;
|
|
445
|
-
result = resultBuffer.get(recallId) ?? `
|
|
445
|
+
result = resultBuffer.get(recallId) ?? `No result found for id '${recallId}'.`;
|
|
446
446
|
} else {
|
|
447
447
|
// Route to WebMCP server
|
|
448
448
|
const webmcpServer = webmcpServers.get(serverName);
|
package/src/providers/wasm.ts
CHANGED
|
@@ -622,7 +622,7 @@ export class WasmProvider implements LLMProvider {
|
|
|
622
622
|
let inferredType = val.type;
|
|
623
623
|
if (!inferredType) {
|
|
624
624
|
const descLower = (val.description ?? '').toLowerCase();
|
|
625
|
-
if (descLower.includes('objet') || descLower.includes('object') || descLower.includes('paramètre') || key === 'params') {
|
|
625
|
+
if (descLower.includes('objet') || descLower.includes('object') || descLower.includes('parameter') || descLower.includes('paramètre') || key === 'params') {
|
|
626
626
|
inferredType = 'object';
|
|
627
627
|
} else {
|
|
628
628
|
inferredType = 'string';
|
|
@@ -692,15 +692,15 @@ export class WasmProvider implements LLMProvider {
|
|
|
692
692
|
: tools;
|
|
693
693
|
|
|
694
694
|
// Minimal instruction — Gemma 4 is trained on native tool format
|
|
695
|
-
systemParts.push(`
|
|
696
|
-
|
|
697
|
-
|
|
695
|
+
systemParts.push(`You are a UI assistant connected to MCP servers.
|
|
696
|
+
Use the available tools to respond. After each DATA call, render visually with component().
|
|
697
|
+
Do NOT ask for confirmation. Execute directly.`);
|
|
698
698
|
|
|
699
699
|
// Native Gemma 4 tool declarations
|
|
700
700
|
systemParts.push(limitedTools.map(t => WasmProvider.formatToolDeclaration(t)).join('\n'));
|
|
701
701
|
|
|
702
702
|
// Enable thinking mode — Gemma 4 reasons before tool calls
|
|
703
|
-
systemParts.push('
|
|
703
|
+
systemParts.push('Before each tool call, think briefly in a <|channel>thought block then call the tool.');
|
|
704
704
|
}
|
|
705
705
|
|
|
706
706
|
// Build a map of tool_use_id → tool_name from all messages for tool_result resolution
|