@webmcp-auto-ui/agent 2.5.12 → 2.5.14
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/README.md
CHANGED
|
@@ -4,12 +4,14 @@ LLM agent loop that connects MCP and WebMCP servers to a UI. Given a user messag
|
|
|
4
4
|
|
|
5
5
|
## Providers
|
|
6
6
|
|
|
7
|
-
**
|
|
7
|
+
**RemoteLLMProvider** — proxies to a `+server.ts` endpoint that holds the API key. Compatible with any OpenAI-compatible API backend (Anthropic, OpenAI, Google, Mistral, etc.). Prompt caching enabled by default. Retry on 503 with exponential backoff. Returns stats in `LLMResponse`: tok/s, totalTokens, latencyMs.
|
|
8
8
|
|
|
9
9
|
**GemmaProvider (LiteRT)** — runs Gemma 4 models via `@mediapipe/tasks-genai` (LiteRT, formerly known as MediaPipe) directly on the **main thread**. Uses WebGPU when available. No API key required. Models are cached in **OPFS** (Origin Private File System) for instant reload after first download.
|
|
10
10
|
|
|
11
11
|
> **v0.5.0 migration**: GemmaProvider was migrated from ONNX (`@huggingface/transformers`) to LiteRT (`@mediapipe/tasks-genai`). LiteRT is 2-4x faster on WebGPU and provides native Gemma 4 support. The provider now runs on the main thread because MediaPipe is incompatible with ES module workers.
|
|
12
12
|
|
|
13
|
+
**LocalLLMProvider** — runs against a local Ollama instance (or any OpenAI-compatible local server: vLLM, LM Studio, llamafile). No API key required. Converts messages and tools to the OpenAI chat completions format automatically.
|
|
14
|
+
|
|
13
15
|
**Gemma 4 prompt format** — uses `<|turn>...<turn|>` delimiters (instead of the Gemma 2/3 `<start_of_turn>...<end_of_turn>`).
|
|
14
16
|
|
|
15
17
|
**Native tool calling** — Gemma 4 tool calls are parsed from `<|tool_call>call:name{args}<tool_call|>` format. No regex heuristics needed.
|
|
@@ -46,10 +48,10 @@ npm install @webmcp-auto-ui/agent
|
|
|
46
48
|
## Usage
|
|
47
49
|
|
|
48
50
|
```ts
|
|
49
|
-
import { autoui, runAgentLoop,
|
|
51
|
+
import { autoui, runAgentLoop, RemoteLLMProvider } from '@webmcp-auto-ui/agent';
|
|
50
52
|
|
|
51
53
|
const result = await runAgentLoop('Show me sales data', {
|
|
52
|
-
provider: new
|
|
54
|
+
provider: new RemoteLLMProvider({ proxyUrl: '/api/chat' }),
|
|
53
55
|
layers: [mcpClient.layer(), autoui.layer()],
|
|
54
56
|
maxIterations: 5,
|
|
55
57
|
callbacks: {
|
|
@@ -64,8 +66,6 @@ const result = await runAgentLoop('Show me sales data', {
|
|
|
64
66
|
});
|
|
65
67
|
```
|
|
66
68
|
|
|
67
|
-
> **Migration from Phase 7**: `onBlock` still works as a deprecated alias for `onWidget`. The `UILayer`, `SkillLayer`, `COMPONENT_TOOL`, `executeComponent`, and `componentRegistry` exports are removed — use `autoui.layer()` instead.
|
|
68
|
-
|
|
69
69
|
## TokenTracker
|
|
70
70
|
|
|
71
71
|
Real-time usage metrics tracking across requests:
|
|
@@ -125,18 +125,19 @@ Requires `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Po
|
|
|
125
125
|
|
|
126
126
|
## API proxy (`+server.ts`)
|
|
127
127
|
|
|
128
|
-
The `
|
|
128
|
+
The `RemoteLLMProvider` sends requests to a local `+server.ts` endpoint that forwards them to the configured LLM API. The endpoint reads `LLM_API_KEY` from the environment, or from `body.__apiKey` as a fallback (for cases where the key is provided at runtime).
|
|
129
129
|
|
|
130
130
|
```ts
|
|
131
131
|
// src/routes/api/chat/+server.ts
|
|
132
132
|
import { env } from '$env/dynamic/private';
|
|
133
133
|
export const POST: RequestHandler = async ({ request }) => {
|
|
134
134
|
const body = await request.json();
|
|
135
|
-
const apiKey = body.__apiKey || env.
|
|
135
|
+
const apiKey = body.__apiKey || env.LLM_API_KEY;
|
|
136
136
|
delete body.__apiKey;
|
|
137
|
-
|
|
137
|
+
// Forward to your LLM provider (Anthropic, OpenAI, Mistral, etc.)
|
|
138
|
+
const res = await fetch(LLM_ENDPOINT, {
|
|
138
139
|
method: 'POST',
|
|
139
|
-
headers: { '
|
|
140
|
+
headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
|
|
140
141
|
body: JSON.stringify(body),
|
|
141
142
|
});
|
|
142
143
|
return Response.json(await res.json());
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webmcp-auto-ui/agent",
|
|
3
|
-
"version": "2.5.
|
|
4
|
-
"description": "LLM agent loop +
|
|
3
|
+
"version": "2.5.14",
|
|
4
|
+
"description": "LLM agent loop + remote/WASM/local providers + MCP wrapper",
|
|
5
5
|
"license": "AGPL-3.0-or-later",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": true,
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"import": "./src/index.ts"
|
|
12
12
|
},
|
|
13
13
|
"./server": {
|
|
14
|
-
"import": "./src/server/
|
|
14
|
+
"import": "./src/server/llmProxy.ts"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared
|
|
2
|
+
* Shared LLM proxy handler — used by all apps' /api/chat/+server.ts
|
|
3
3
|
* Accepts the parsed body (with __apiKey already extracted), the resolved
|
|
4
4
|
* API key, and the optional model override from X-Model header.
|
|
5
5
|
*/
|
|
6
|
-
export async function
|
|
6
|
+
export async function llmProxy(
|
|
7
7
|
body: Record<string, unknown>,
|
|
8
8
|
apiKey: string,
|
|
9
9
|
model?: string | null,
|