waypoi 0.0.0
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/.github/instructions/ui.instructions.md +42 -0
- package/.github/workflows/ci.yml +35 -0
- package/.github/workflows/publish.yml +71 -0
- package/.github/workflows/release.yml +48 -0
- package/.playwright-mcp/console-2026-04-04T01-41-10-746Z.log +2 -0
- package/.playwright-mcp/console-2026-04-04T01-41-28-799Z.log +3 -0
- package/.playwright-mcp/console-2026-04-05T02-26-51-909Z.log +76 -0
- package/.playwright-mcp/page-2026-04-04T01-41-10-816Z.yml +1 -0
- package/.playwright-mcp/page-2026-04-04T01-41-29-141Z.yml +77 -0
- package/.playwright-mcp/page-2026-04-04T01-41-42-633Z.yml +190 -0
- package/.playwright-mcp/page-2026-04-04T01-42-03-929Z.yml +262 -0
- package/.playwright-mcp/page-2026-04-04T02-12-54-813Z.yml +6 -0
- package/.playwright-mcp/page-2026-04-04T02-14-58-600Z.yml +190 -0
- package/.playwright-mcp/page-2026-04-04T02-15-03-923Z.yml +190 -0
- package/.playwright-mcp/page-2026-04-04T02-15-07-426Z.yml +190 -0
- package/.playwright-mcp/page-2026-04-04T02-15-25-729Z.yml +262 -0
- package/.playwright-mcp/page-2026-04-04T02-16-22-984Z.yml +262 -0
- package/.playwright-mcp/page-2026-04-04T02-17-00-599Z.yml +190 -0
- package/.playwright-mcp/page-2026-04-04T02-17-50-874Z.yml +190 -0
- package/.playwright-mcp/page-2026-04-05T02-26-55-570Z.yml +6 -0
- package/AGENTS.md +48 -0
- package/CHANGELOG.md +131 -0
- package/README.md +552 -0
- package/assets/agent-mode.png +0 -0
- package/assets/categorize.png +0 -0
- package/assets/dashboard.png +0 -0
- package/assets/endpoint-proxy.png +0 -0
- package/assets/icon.png +0 -0
- package/assets/mcp-generate-image.png +0 -0
- package/assets/mcp-understand-image.png +0 -0
- package/assets/peek-token-flow.png +0 -0
- package/assets/playground.png +0 -0
- package/assets/sankey.png +0 -0
- package/cli/index.ts +2805 -0
- package/cli/legacyRewrite.ts +108 -0
- package/cli/modelRef.ts +24 -0
- package/dist/cli/index.js +2536 -0
- package/dist/cli/legacyRewrite.js +92 -0
- package/dist/cli/modelRef.js +20 -0
- package/dist/src/benchmark/artifacts.js +131 -0
- package/dist/src/benchmark/capabilityClassifier.js +81 -0
- package/dist/src/benchmark/capabilityStore.js +144 -0
- package/dist/src/benchmark/config.js +238 -0
- package/dist/src/benchmark/gates.js +118 -0
- package/dist/src/benchmark/jobs.js +252 -0
- package/dist/src/benchmark/runner.js +1847 -0
- package/dist/src/benchmark/schema.js +353 -0
- package/dist/src/benchmark/suites.js +314 -0
- package/dist/src/benchmark/tinyQaDataset.js +422 -0
- package/dist/src/benchmark/types.js +25 -0
- package/dist/src/config.js +47 -0
- package/dist/src/index.js +178 -0
- package/dist/src/mcp/client.js +215 -0
- package/dist/src/mcp/discovery.js +226 -0
- package/dist/src/mcp/policy.js +65 -0
- package/dist/src/mcp/registry.js +129 -0
- package/dist/src/mcp/service.js +460 -0
- package/dist/src/middleware/auth.js +179 -0
- package/dist/src/middleware/requestCapture.js +192 -0
- package/dist/src/middleware/requestStats.js +118 -0
- package/dist/src/pools/builder.js +132 -0
- package/dist/src/pools/repository.js +69 -0
- package/dist/src/pools/scheduler.js +360 -0
- package/dist/src/pools/types.js +2 -0
- package/dist/src/protocols/adapters/dashscope.js +267 -0
- package/dist/src/protocols/adapters/inferenceV2.js +346 -0
- package/dist/src/protocols/adapters/openai.js +27 -0
- package/dist/src/protocols/registry.js +99 -0
- package/dist/src/protocols/types.js +2 -0
- package/dist/src/providers/health.js +153 -0
- package/dist/src/providers/importer.js +289 -0
- package/dist/src/providers/modelRegistry.js +313 -0
- package/dist/src/providers/repository.js +361 -0
- package/dist/src/providers/types.js +2 -0
- package/dist/src/routes/admin.js +531 -0
- package/dist/src/routes/audio.js +295 -0
- package/dist/src/routes/chat.js +240 -0
- package/dist/src/routes/embeddings.js +157 -0
- package/dist/src/routes/images.js +288 -0
- package/dist/src/routes/mcp.js +256 -0
- package/dist/src/routes/mcpService.js +100 -0
- package/dist/src/routes/models.js +48 -0
- package/dist/src/routes/responses.js +711 -0
- package/dist/src/routes/sessions.js +450 -0
- package/dist/src/routes/stats.js +270 -0
- package/dist/src/routes/ui.js +97 -0
- package/dist/src/routes/videos.js +107 -0
- package/dist/src/routing/router.js +338 -0
- package/dist/src/services/imageGeneration.js +280 -0
- package/dist/src/services/imageUnderstanding.js +352 -0
- package/dist/src/services/videoGeneration.js +79 -0
- package/dist/src/storage/captureRepository.js +1591 -0
- package/dist/src/storage/files.js +157 -0
- package/dist/src/storage/imageCache.js +346 -0
- package/dist/src/storage/repositories.js +388 -0
- package/dist/src/storage/sessionRepository.js +370 -0
- package/dist/src/storage/statsRepository.js +204 -0
- package/dist/src/transport/httpClient.js +126 -0
- package/dist/src/types.js +2 -0
- package/dist/src/utils/messageMedia.js +285 -0
- package/dist/src/utils/modelCapabilities.js +108 -0
- package/dist/src/utils/modelDiscovery.js +170 -0
- package/dist/src/version.js +5 -0
- package/dist/src/workers/captureRetention.js +25 -0
- package/dist/src/workers/configWatcher.js +91 -0
- package/dist/src/workers/healthChecker.js +21 -0
- package/dist/src/workers/statsRotation.js +41 -0
- package/docs/LLM/output_schema.md +312 -0
- package/docs/benchmark.md +208 -0
- package/docs/mcp-guidelines.md +125 -0
- package/docs/mcp-service.md +178 -0
- package/docs/opencode.md +86 -0
- package/docs/providers.md +79 -0
- package/examples/benchmark.config.yaml +28 -0
- package/examples/providers/alibaba-dashscope.yaml +88 -0
- package/examples/providers/alibaba-llm.yaml +64 -0
- package/examples/providers/alibaba-registry.yaml +7 -0
- package/examples/providers/inference-v2-ray.yaml +29 -0
- package/examples/scenarios/assets/omni-call-sample.wav +0 -0
- package/examples/scenarios/custom.jsonl +5 -0
- package/examples/scenarios/custom.yaml +40 -0
- package/model-form-v2.png +0 -0
- package/package.json +66 -0
- package/provider-form-v2.png +0 -0
- package/provider-form.png +0 -0
- package/scripts/manual-test.sh +11 -0
- package/scripts/version-from-git.js +23 -0
- package/src/benchmark/artifacts.ts +149 -0
- package/src/benchmark/capabilityClassifier.ts +99 -0
- package/src/benchmark/capabilityStore.ts +174 -0
- package/src/benchmark/config.ts +337 -0
- package/src/benchmark/gates.ts +164 -0
- package/src/benchmark/jobs.ts +312 -0
- package/src/benchmark/runner.ts +2519 -0
- package/src/benchmark/schema.ts +443 -0
- package/src/benchmark/suites.ts +323 -0
- package/src/benchmark/tinyQaDataset.ts +428 -0
- package/src/benchmark/types.ts +442 -0
- package/src/config.ts +44 -0
- package/src/index.ts +195 -0
- package/src/mcp/client.ts +305 -0
- package/src/mcp/discovery.ts +266 -0
- package/src/mcp/policy.ts +105 -0
- package/src/mcp/registry.ts +164 -0
- package/src/mcp/service.ts +611 -0
- package/src/middleware/auth.ts +251 -0
- package/src/middleware/requestCapture.ts +245 -0
- package/src/middleware/requestStats.ts +163 -0
- package/src/pools/builder.ts +159 -0
- package/src/pools/repository.ts +71 -0
- package/src/pools/scheduler.ts +425 -0
- package/src/pools/types.ts +117 -0
- package/src/protocols/adapters/dashscope.ts +335 -0
- package/src/protocols/adapters/inferenceV2.ts +428 -0
- package/src/protocols/adapters/openai.ts +32 -0
- package/src/protocols/registry.ts +117 -0
- package/src/protocols/types.ts +81 -0
- package/src/providers/health.ts +207 -0
- package/src/providers/importer.ts +402 -0
- package/src/providers/modelRegistry.ts +415 -0
- package/src/providers/repository.ts +439 -0
- package/src/providers/types.ts +113 -0
- package/src/routes/admin.ts +666 -0
- package/src/routes/audio.ts +372 -0
- package/src/routes/chat.ts +301 -0
- package/src/routes/embeddings.ts +197 -0
- package/src/routes/images.ts +356 -0
- package/src/routes/mcp.ts +320 -0
- package/src/routes/mcpService.ts +114 -0
- package/src/routes/models.ts +50 -0
- package/src/routes/responses.ts +872 -0
- package/src/routes/sessions.ts +558 -0
- package/src/routes/stats.ts +312 -0
- package/src/routes/ui.ts +96 -0
- package/src/routes/videos.ts +132 -0
- package/src/routing/router.ts +501 -0
- package/src/services/imageGeneration.ts +396 -0
- package/src/services/imageUnderstanding.ts +449 -0
- package/src/services/videoGeneration.ts +127 -0
- package/src/storage/captureRepository.ts +1835 -0
- package/src/storage/files.ts +178 -0
- package/src/storage/imageCache.ts +405 -0
- package/src/storage/repositories.ts +494 -0
- package/src/storage/sessionRepository.ts +419 -0
- package/src/storage/statsRepository.ts +238 -0
- package/src/transport/httpClient.ts +145 -0
- package/src/types.ts +322 -0
- package/src/utils/messageMedia.ts +293 -0
- package/src/utils/modelCapabilities.ts +161 -0
- package/src/utils/modelDiscovery.ts +203 -0
- package/src/workers/captureRetention.ts +25 -0
- package/src/workers/configWatcher.ts +115 -0
- package/src/workers/healthChecker.ts +22 -0
- package/src/workers/statsRotation.ts +49 -0
- package/tests/benchmarkAdminRoutes.test.ts +82 -0
- package/tests/benchmarkBasics.test.ts +116 -0
- package/tests/captureAdminRoutes.test.ts +420 -0
- package/tests/captureRepository.test.ts +797 -0
- package/tests/cliLegacyRewrite.test.ts +45 -0
- package/tests/imageGeneration.service.test.ts +107 -0
- package/tests/imageUnderstanding.service.test.ts +123 -0
- package/tests/mcpPolicy.test.ts +105 -0
- package/tests/mcpService.test.ts +1245 -0
- package/tests/modelRef.test.ts +23 -0
- package/tests/modelsRoutes.test.ts +154 -0
- package/tests/sessionMediaCache.test.ts +167 -0
- package/tests/statsRoutes.test.ts +323 -0
- package/tsconfig.json +15 -0
- package/ui/index.html +16 -0
- package/ui/package-lock.json +8521 -0
- package/ui/package.json +52 -0
- package/ui/postcss.config.js +6 -0
- package/ui/public/assets/apple-touch-icon.png +0 -0
- package/ui/public/assets/favicon-16.png +0 -0
- package/ui/public/assets/favicon-32.png +0 -0
- package/ui/public/assets/icon-192.png +0 -0
- package/ui/public/assets/icon-512.png +0 -0
- package/ui/src/App.tsx +27 -0
- package/ui/src/api/client.ts +1503 -0
- package/ui/src/components/EndpointUsageGuide.tsx +361 -0
- package/ui/src/components/Layout.tsx +124 -0
- package/ui/src/components/MessageContent.tsx +365 -0
- package/ui/src/components/ToolCallMessage.tsx +179 -0
- package/ui/src/components/ToolPicker.tsx +442 -0
- package/ui/src/components/messageContentParser.test.ts +41 -0
- package/ui/src/components/messageContentParser.ts +73 -0
- package/ui/src/components/thinkingPreview.test.ts +27 -0
- package/ui/src/components/thinkingPreview.ts +15 -0
- package/ui/src/components/toMermaidSankey.test.ts +78 -0
- package/ui/src/components/toMermaidSankey.ts +56 -0
- package/ui/src/components/ui/button.tsx +58 -0
- package/ui/src/components/ui/input.tsx +21 -0
- package/ui/src/components/ui/textarea.tsx +21 -0
- package/ui/src/lib/utils.ts +6 -0
- package/ui/src/main.tsx +9 -0
- package/ui/src/pages/AgentPlayground.tsx +2010 -0
- package/ui/src/pages/Benchmark.tsx +988 -0
- package/ui/src/pages/Dashboard.tsx +581 -0
- package/ui/src/pages/Peek.tsx +962 -0
- package/ui/src/pages/Settings.tsx +2013 -0
- package/ui/src/pages/agentPlaygroundPayload.test.ts +109 -0
- package/ui/src/pages/agentPlaygroundPayload.ts +97 -0
- package/ui/src/pages/agentThinkingContent.test.ts +50 -0
- package/ui/src/pages/agentThinkingContent.ts +57 -0
- package/ui/src/pages/dashboardTokenUsage.test.ts +66 -0
- package/ui/src/pages/dashboardTokenUsage.ts +36 -0
- package/ui/src/pages/imageUpload.test.ts +39 -0
- package/ui/src/pages/imageUpload.ts +71 -0
- package/ui/src/pages/peekFilters.test.ts +29 -0
- package/ui/src/pages/peekFilters.ts +13 -0
- package/ui/src/pages/peekMedia.test.ts +58 -0
- package/ui/src/pages/peekMedia.ts +148 -0
- package/ui/src/pages/sessionAutoTitle.test.ts +128 -0
- package/ui/src/pages/sessionAutoTitle.ts +106 -0
- package/ui/src/stores/settings.ts +58 -0
- package/ui/src/styles/globals.css +223 -0
- package/ui/src/vite-env.d.ts +8 -0
- package/ui/tailwind.config.js +106 -0
- package/ui/tsconfig.json +32 -0
- package/ui/vite.config.ts +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/icon.png" alt="Waypoi" width="128" height="128" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Waypoi</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Local AI Gateway</strong> — OpenAI-compatible proxy with intelligent routing, failover, and a built-in playground UI for agentic workflows.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<em>Sometimes a good LLM endpoint works behind a bad SSL cert. Waypoi bridges the gap—connect to any backend, handle SSL issues gracefully, and unify multiple endpoints behind one secure local interface.</em>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Screenshots
|
|
18
|
+
|
|
19
|
+
### Playground
|
|
20
|
+
<p align="center">
|
|
21
|
+
<img src="assets/playground.png" alt="Playground with chat interface" width="800" />
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
### Agent Mode with Tool Calling
|
|
25
|
+
<p align="center">
|
|
26
|
+
<img src="assets/agent-mode.png" alt="Agent mode with MCP tools" width="800" />
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
### Endpoint Proxy & Usage Guides
|
|
30
|
+
<p align="center">
|
|
31
|
+
<img src="assets/endpoint-proxy.png" alt="Local proxy to remote LLM endpoints with usage examples" width="800" />
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
### Dashboard
|
|
35
|
+
<p align="center">
|
|
36
|
+
<img src="assets/dashboard.png" alt="Real-time statistics dashboard" width="800" />
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
### MCP Image Generation
|
|
40
|
+
<p align="center">
|
|
41
|
+
<img src="assets/mcp-generate-image.png" alt="MCP generate_image tool in agent mode" width="800" />
|
|
42
|
+
</p>
|
|
43
|
+
|
|
44
|
+
### MCP Image Understanding
|
|
45
|
+
<p align="center">
|
|
46
|
+
<img src="assets/mcp-understand-image.png" alt="MCP understand_image tool analyzing uploaded image" width="800" />
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
### Token Flow Sankey
|
|
50
|
+
<p align="center">
|
|
51
|
+
<img src="assets/peek-token-flow.png" alt="Peek token flow Sankey visualization" width="800" />
|
|
52
|
+
</p>
|
|
53
|
+
|
|
54
|
+
### Naming and Logo
|
|
55
|
+
|
|
56
|
+
I admit, the name "Waypoi" is proposed by LLM (shut out to Qwen3-vl-30B) after it reads my early repositoy. In the beginning, the work was just intended to be a simple proxy for ill-configured LLM endpoints. I am talking about PCAI.
|
|
57
|
+
|
|
58
|
+
At the time, way point was just a term, similar to "route point", providing access to the LLM endpoints.
|
|
59
|
+
|
|
60
|
+
As I learn more about the AI agents, I start to be convinced the name do has more meanings. AI agents are clearly a waypoi to the future AGI, superintelligence or singularity. I hope this project can be my stepping stone to that future.
|
|
61
|
+
|
|
62
|
+
But I feel I am not smart enough to do it by myself. In this sense, the project can provide a helping waypoi betwen me and a smarter me, what I projected myself in my tiny mind.
|
|
63
|
+
|
|
64
|
+
I asked the LLM (thanks again qwen3-vl-30B) to design a logo prompt and `zimage` to generate the logo. After several rounds of judging, the winner comes with the following prompt:
|
|
65
|
+
|
|
66
|
+
> Minimal abstract gateway icon, two vertical parallel lines with a glowing orb passing through center, neon cyan accent on dark background, geometric precision, symbolizing data flow through a unified portal, clean vector style, icon design
|
|
67
|
+
|
|
68
|
+
Suprisingly, the logo looks like a layed down box plot.
|
|
69
|
+
|
|
70
|
+
Here is the ascii art version of the logo:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
├─o─┤
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Features
|
|
79
|
+
|
|
80
|
+
| Feature | Description |
|
|
81
|
+
|---|---|
|
|
82
|
+
| **Reverse Proxy** | Route LLM, diffusion, audio, and embedding requests to multiple backends behind a single OpenAI-compatible API |
|
|
83
|
+
| **Health-Based Failover** | Automatic retry with circuit breaker, latency-aware routing, and per-endpoint TLS policy |
|
|
84
|
+
| **Smart Pools** | Virtual model aliases (e.g. `smart`) that load-balance across providers matching capability requirements |
|
|
85
|
+
| **Web Playground** | Chat interface with session history, image upload, streaming, voice call mode, and agentic tool use |
|
|
86
|
+
| **Agent Mode** | Built-in MCP (Model Context Protocol) client — connect external servers or use the built-in `/mcp` endpoint; tools auto-connected and pre-selected on startup |
|
|
87
|
+
| **Built-in MCP Tools** | `generate_image` (diffusion routing, file output to `~/.config/waypoi`) and `understand_image` (vision model analysis with geometry metadata) |
|
|
88
|
+
| **Model Capability Matrix** | Per-model input/output modality classification (`text`, `image`, `audio`, `embedding`, `reasoning`) with configured or inferred sources |
|
|
89
|
+
| **Provider Catalog** | First-class provider and model management via `waypoi providers` / `waypoi models` CLI; supports `openai`, `inference_v2`, and custom adapters |
|
|
90
|
+
| **Responses API Shim** | `/v1/responses` compatibility shim translates Responses-style requests to chat completions with SSE event mapping |
|
|
91
|
+
| **Benchmark Showcase** | Live example replays and diagnostic suites via `waypoi bench`; supports file-driven scenarios, baselines, and per-model targeting |
|
|
92
|
+
| **Peek** | Request-capture browser with calendar view, timeline inspection, media artifacts tab, and token-flow Sankey visualization |
|
|
93
|
+
| **Statistics** | Per-model/endpoint request tracking with 7-day window, latency distribution, token usage charts, and CLI summaries |
|
|
94
|
+
| **Usage Guides** | Dashboard-embedded copy-paste code snippets (cURL, Python, Node.js) for every proxied endpoint |
|
|
95
|
+
| **Hot Reload** | Config changes apply without restart via filesystem watcher |
|
|
96
|
+
| **Auth Ready** | Optional token-based authentication (disabled by default); MCP endpoint is always localhost-only |
|
|
97
|
+
|
|
98
|
+
## Architecture
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
┌─────────────────────────────────────────────────────────────────────┐
|
|
102
|
+
│ Waypoi Gateway │
|
|
103
|
+
├─────────────────────────────────────────────────────────────────────┤
|
|
104
|
+
│ Routes: │
|
|
105
|
+
│ /v1/chat/completions → LLM backends │
|
|
106
|
+
│ /v1/embeddings → Embedding backends │
|
|
107
|
+
│ /v1/images/* → Diffusion backends │
|
|
108
|
+
│ /v1/audio/* → Audio backends (TTS/STT) │
|
|
109
|
+
│ /v1/models → Aggregated model list │
|
|
110
|
+
│ /v1/responses → Responses API shim │
|
|
111
|
+
│ /mcp → Built-in MCP tool server │
|
|
112
|
+
│ │
|
|
113
|
+
│ Admin: │
|
|
114
|
+
│ /admin/endpoints → Endpoint CRUD │
|
|
115
|
+
│ /admin/health → Health status │
|
|
116
|
+
│ /admin/stats → Request statistics │
|
|
117
|
+
│ /admin/sessions → Chat session storage │
|
|
118
|
+
│ /admin/mcp/* → MCP server management │
|
|
119
|
+
│ │
|
|
120
|
+
│ UI: │
|
|
121
|
+
│ /ui → React playground & dashboard │
|
|
122
|
+
├─────────────────────────────────────────────────────────────────────┤
|
|
123
|
+
│ Storage (~/.config/waypoi): │
|
|
124
|
+
│ config.yaml │ Endpoint configuration │
|
|
125
|
+
│ health.json │ Health state cache │
|
|
126
|
+
│ stats/*.jsonl │ Request logs (30-day rotation) │
|
|
127
|
+
│ sessions/*.json │ Chat session history │
|
|
128
|
+
│ images/ │ AIGC image cache (LRU, 1GB default) │
|
|
129
|
+
│ mcp-servers.yaml │ MCP server registry │
|
|
130
|
+
└─────────────────────────────────────────────────────────────────────┘
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Quickstart
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Install dependencies
|
|
137
|
+
npm install
|
|
138
|
+
cd ui && npm install && cd ..
|
|
139
|
+
|
|
140
|
+
# Build
|
|
141
|
+
npm run build:all
|
|
142
|
+
|
|
143
|
+
# Start server
|
|
144
|
+
npm run start
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Open http://localhost:9469/ui for the web interface.
|
|
148
|
+
|
|
149
|
+
## Add an Endpoint
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Via CLI
|
|
153
|
+
waypoi add \
|
|
154
|
+
--name local-llm \
|
|
155
|
+
--url http://localhost:11434 \
|
|
156
|
+
--priority 1 \
|
|
157
|
+
--type llm \
|
|
158
|
+
--model local-default=llama3
|
|
159
|
+
|
|
160
|
+
# Diffusion endpoint
|
|
161
|
+
waypoi add \
|
|
162
|
+
--name local-sd \
|
|
163
|
+
--url http://localhost:7860 \
|
|
164
|
+
--priority 1 \
|
|
165
|
+
--type diffusion \
|
|
166
|
+
--model sd-xl=stable-diffusion-xl
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## OpenAI-Compatible Endpoints
|
|
170
|
+
|
|
171
|
+
| Endpoint | Description |
|
|
172
|
+
|----------|-------------|
|
|
173
|
+
| `POST /v1/chat/completions` | Chat with streaming and tool calling |
|
|
174
|
+
| `POST /v1/embeddings` | Text embeddings for RAG |
|
|
175
|
+
| `GET /v1/models` | List available models |
|
|
176
|
+
| `POST /v1/images/generations` | Image generation |
|
|
177
|
+
| `POST /v1/images/edits` | Image editing |
|
|
178
|
+
| `POST /v1/audio/transcriptions` | Speech-to-text |
|
|
179
|
+
| `POST /v1/audio/speech` | Text-to-speech |
|
|
180
|
+
| `POST /v1/responses` | Responses API shim |
|
|
181
|
+
| `POST /mcp` | Built-in MCP service endpoint |
|
|
182
|
+
|
|
183
|
+
`GET /v1/models` includes both legacy `endpoint_type` and detailed `capabilities` metadata when available.
|
|
184
|
+
|
|
185
|
+
### Responses API Shim
|
|
186
|
+
|
|
187
|
+
Waypoi exposes `/v1/responses` as a compatibility shim for clients that use Responses-style requests.
|
|
188
|
+
Internally, requests are translated to chat completions and routed through the same failover path.
|
|
189
|
+
|
|
190
|
+
Key behavior:
|
|
191
|
+
|
|
192
|
+
- `input_text` / `output_text` content parts are normalized to `text`
|
|
193
|
+
- function call payloads are mapped to OpenAI tool-call shape
|
|
194
|
+
- `developer` role is normalized to `system`
|
|
195
|
+
|
|
196
|
+
For `stream: true`, Waypoi emits Responses-style SSE events (`response.created`, deltas, output items, and `response.completed`).
|
|
197
|
+
|
|
198
|
+
## Admin Endpoints
|
|
199
|
+
|
|
200
|
+
| Endpoint | Description |
|
|
201
|
+
|----------|-------------|
|
|
202
|
+
| `GET /admin/endpoints` | List all endpoints |
|
|
203
|
+
| `POST /admin/endpoints` | Add endpoint |
|
|
204
|
+
| `PATCH /admin/endpoints/:id` | Update endpoint |
|
|
205
|
+
| `DELETE /admin/endpoints/:id` | Remove endpoint |
|
|
206
|
+
| `GET /admin/health` | Health status by endpoint |
|
|
207
|
+
| `GET /admin/stats` | Aggregated statistics |
|
|
208
|
+
| `GET /admin/stats/latency` | Latency distribution |
|
|
209
|
+
| `GET /admin/stats/tokens` | Token usage over time |
|
|
210
|
+
| `GET/POST/DELETE /admin/sessions` | Chat session CRUD |
|
|
211
|
+
| `GET/POST/DELETE /admin/mcp/servers` | MCP server CRUD |
|
|
212
|
+
| `GET /admin/mcp/tools` | List discovered tools |
|
|
213
|
+
| `POST /admin/mcp/tools/execute` | Execute a tool |
|
|
214
|
+
| `GET /admin/providers` | Provider catalog |
|
|
215
|
+
| `GET /admin/providers/:id` | Provider details |
|
|
216
|
+
| `GET /admin/pools` | Smart pool definitions |
|
|
217
|
+
| `POST /admin/pools/rebuild` | Rebuild smart pools from providers |
|
|
218
|
+
|
|
219
|
+
## Built-In MCP Service (`/mcp`)
|
|
220
|
+
|
|
221
|
+
Waypoi exposes a first-party MCP server for local agent-to-tool workflows without going through chat models.
|
|
222
|
+
|
|
223
|
+
- Endpoint: `POST /mcp` (Streamable HTTP MCP transport)
|
|
224
|
+
- Access: localhost only (`localhost`, `127.0.0.1`, `::1`)
|
|
225
|
+
- Auth: intentionally open on localhost, even when `authEnabled=true`
|
|
226
|
+
|
|
227
|
+
Client flow:
|
|
228
|
+
1. `initialize`
|
|
229
|
+
2. `notifications/initialized`
|
|
230
|
+
3. `tools/list`
|
|
231
|
+
4. `tools/call`
|
|
232
|
+
|
|
233
|
+
Initial built-in tool:
|
|
234
|
+
- `generate_image`
|
|
235
|
+
- Generates image(s) using Waypoi's diffusion routing
|
|
236
|
+
- Depends on at least one live diffusion-capable model
|
|
237
|
+
- Always writes generated files to `~/.config/waypoi/generated-images` by default
|
|
238
|
+
- Override output location with `WAYPOI_MCP_OUTPUT_ROOT` (and optionally `WAYPOI_MCP_OUTPUT_SUBDIR`)
|
|
239
|
+
- Returns structured result with model metadata plus `file_path` or `file_paths` relative to the output root; raw `url`/`b64_json` are optional via `include_data`
|
|
240
|
+
- `understand_image`
|
|
241
|
+
- Performs image-to-text understanding with a vision-capable model
|
|
242
|
+
- Supports `image_path` or `image_url` input with top-level `text` plus structured `result` output (`ocr_text`, objects, scene, details)
|
|
243
|
+
- For local `image_path` inputs, preserves original image geometry and reports optional `image_geometry` metadata so coordinate-based tasks stay aligned with the source file
|
|
244
|
+
|
|
245
|
+
Agent defaults (summary):
|
|
246
|
+
1. Keep `include_data=false` unless inline image payload is explicitly required.
|
|
247
|
+
2. Set `WAYPOI_MCP_OUTPUT_ROOT` if you want images written to a specific location.
|
|
248
|
+
|
|
249
|
+
Example `generate_image` tool call:
|
|
250
|
+
|
|
251
|
+
```json
|
|
252
|
+
{
|
|
253
|
+
"name": "generate_image",
|
|
254
|
+
"arguments": {
|
|
255
|
+
"prompt": "Minimal icon with clean geometric shape"
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Example `understand_image` coordinate-sensitive prompt:
|
|
261
|
+
|
|
262
|
+
```json
|
|
263
|
+
{
|
|
264
|
+
"name": "understand_image",
|
|
265
|
+
"arguments": {
|
|
266
|
+
"image_path": "./assets/layout.png",
|
|
267
|
+
"instruction": "Return the center point of the submit button as JSON with x and y in original image pixels."
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Canonical MCP governance and behavior contract: [`docs/mcp-guidelines.md`](docs/mcp-guidelines.md).
|
|
273
|
+
Detailed MCP tool contract and examples: [`docs/mcp-service.md`](docs/mcp-service.md).
|
|
274
|
+
|
|
275
|
+
## CLI Commands
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
# Endpoint management
|
|
279
|
+
waypoi ls # List endpoints
|
|
280
|
+
waypoi add --name --url --priority # Deprecated (blocked in provider-first mode)
|
|
281
|
+
waypoi rm <id|name> # Deprecated (blocked in provider-first mode)
|
|
282
|
+
waypoi edit # Deprecated (blocked in provider-first mode)
|
|
283
|
+
waypoi stat # Run health check
|
|
284
|
+
waypoi test <model> # Test a model
|
|
285
|
+
waypoi acct # Token usage by endpoint
|
|
286
|
+
|
|
287
|
+
# Service management
|
|
288
|
+
waypoi service start # Start background service
|
|
289
|
+
waypoi service stop # Stop service
|
|
290
|
+
waypoi service restart # Restart service
|
|
291
|
+
waypoi service status # Check if running
|
|
292
|
+
|
|
293
|
+
# Logs & stats
|
|
294
|
+
waypoi logs # Show last 50 log lines
|
|
295
|
+
waypoi logs -f # Follow log output
|
|
296
|
+
waypoi stats # Show 7-day statistics
|
|
297
|
+
waypoi stats --window=24h # Custom time window
|
|
298
|
+
waypoi stats --json # JSON output
|
|
299
|
+
|
|
300
|
+
# MCP server management
|
|
301
|
+
waypoi mcp add --name --url # Add MCP server
|
|
302
|
+
waypoi mcp list # List MCP servers
|
|
303
|
+
waypoi mcp rm <id|name> # Remove MCP server
|
|
304
|
+
waypoi mcp enable <id|name> # Enable server
|
|
305
|
+
waypoi mcp disable <id|name> # Disable server
|
|
306
|
+
|
|
307
|
+
# Provider catalog + smart pools
|
|
308
|
+
waypoi providers # List providers (canonical)
|
|
309
|
+
waypoi providers import -f .env # Import providers and credentials, rebuild pools
|
|
310
|
+
waypoi providers show <providerId> # Show one provider
|
|
311
|
+
waypoi providers update <providerId> --insecure-tls|--strict-tls
|
|
312
|
+
waypoi providers update <providerId> --auto-insecure-domain ai-application.stjude.org
|
|
313
|
+
waypoi providers enable <providerId> # Enable provider
|
|
314
|
+
waypoi providers disable <providerId># Disable provider
|
|
315
|
+
waypoi providers migrate-endpoints --provider pcai --match-domain ai-application.stjude.org --protocol openai
|
|
316
|
+
waypoi providers pools # List smart pools
|
|
317
|
+
|
|
318
|
+
# Models (one-hop by provider)
|
|
319
|
+
waypoi models # List models across providers
|
|
320
|
+
waypoi models pcai # List models for provider
|
|
321
|
+
waypoi models show pcai/gpt-4o # Show one model
|
|
322
|
+
waypoi models add <providerId> --model-id <id> --upstream <name> --base-url <url>
|
|
323
|
+
waypoi models update <providerId> <modelRef> [patch options]
|
|
324
|
+
waypoi models rm <providerId> <modelRef>
|
|
325
|
+
waypoi models enable pcai/gpt-4o
|
|
326
|
+
waypoi models disable pcai/gpt-4o
|
|
327
|
+
waypoi models set-key pcai/gpt-4o --api-key <key>|--env-var <ENV>
|
|
328
|
+
|
|
329
|
+
# Benchmark showcase
|
|
330
|
+
waypoi bench # Default live showcase example suite
|
|
331
|
+
waypoi bench --list-examples # List showcase examples
|
|
332
|
+
waypoi bench --example showcase-tinyqa-001
|
|
333
|
+
waypoi bench --suite showcase --model smart
|
|
334
|
+
waypoi bench --scenario file.json # File-driven scenarios
|
|
335
|
+
waypoi bench --mode diagnostic --suite pool_smoke
|
|
336
|
+
waypoi bench --baseline ./bench-prev.json
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
Benchmark showcase examples are sourced from Hugging Face dataset
|
|
340
|
+
`vincentkoc/tiny_qa_benchmark` (train split, 52 QA prompts).
|
|
341
|
+
|
|
342
|
+
Provider credentials imported with `waypoi providers import -f .env` are stored in plaintext at
|
|
343
|
+
`$WAYPOI_DIR/providers.json` by design for local operation.
|
|
344
|
+
|
|
345
|
+
### Canonical Provider-First Workflow
|
|
346
|
+
|
|
347
|
+
Use these commands as the primary operational path:
|
|
348
|
+
|
|
349
|
+
1. `waypoi providers`
|
|
350
|
+
2. `waypoi providers show <providerId>`
|
|
351
|
+
3. `waypoi models`
|
|
352
|
+
4. `waypoi models <providerId>`
|
|
353
|
+
5. `waypoi models show <providerId>/<modelId>`
|
|
354
|
+
|
|
355
|
+
Legacy `waypoi provider ...` and `waypoi provider model ...` forms are rewritten to canonical commands with a deprecation warning. Set `WAYPOI_NO_WARN=1` to suppress legacy rewrite warnings in scripts.
|
|
356
|
+
|
|
357
|
+
TLS policy is provider-first:
|
|
358
|
+
- Provider `insecureTls` is the default for all provider models.
|
|
359
|
+
- Model `insecureTls` is an optional override (`--clear-insecure-tls` restores inheritance).
|
|
360
|
+
- Optional provider allowlist (`autoInsecureTlsDomains`) enables one-time TLS verify fallback and persists model override on successful retry.
|
|
361
|
+
|
|
362
|
+
Endpoint migrations use copy-then-disable semantics for rollback safety. Migrated source endpoints
|
|
363
|
+
stay in `config.yaml` with `disabled: true` and can be re-enabled if needed.
|
|
364
|
+
|
|
365
|
+
Detailed benchmark format and assertions: [`docs/benchmark.md`](docs/benchmark.md).
|
|
366
|
+
Provider protocol adapter onboarding (including `inference_v2`): [`docs/providers.md`](docs/providers.md).
|
|
367
|
+
|
|
368
|
+
## External Client Integration (Opencode)
|
|
369
|
+
|
|
370
|
+
Waypoi is a local AI gateway for external clients. Configure Opencode (or other OpenAI-compatible clients) to use:
|
|
371
|
+
|
|
372
|
+
- Base URL: `http://localhost:9469/v1`
|
|
373
|
+
- API key: `local-dev` (or your configured token)
|
|
374
|
+
- Model: `smart` (recommended default free-model pool alias)
|
|
375
|
+
- Note: legacy `smart-*` aliases are removed; use `smart` or canonical `provider/model` IDs.
|
|
376
|
+
|
|
377
|
+
Protocol note: non-OpenAI upstreams are adapter-backed. `inference_v2` is supported in sync mode
|
|
378
|
+
for `/v1/chat/completions` (text + optional image), while keeping external OpenAI-compatible calls.
|
|
379
|
+
|
|
380
|
+
See [`docs/opencode.md`](docs/opencode.md) for setup details.
|
|
381
|
+
|
|
382
|
+
## Web UI
|
|
383
|
+
|
|
384
|
+
Access the playground at `http://localhost:9469/ui`:
|
|
385
|
+
|
|
386
|
+
- **Playground** — Chat interface with session history, image upload (VL models), and agent mode
|
|
387
|
+
- **Dashboard** — Real-time stats with latency charts, token usage, endpoint health, and **usage guides** with copy-paste code snippets (cURL, Python, Node.js)
|
|
388
|
+
- **Peek** — Calendar browser for captured requests, timeline inspection, media artifacts, and token-flow analysis
|
|
389
|
+
- **Settings** — Provider/model catalog management, MCP guidance, and image defaults
|
|
390
|
+
|
|
391
|
+
### Endpoint Usage Guides
|
|
392
|
+
|
|
393
|
+
Each endpoint in the Dashboard includes an expandable "Usage Guide" dropdown showing:
|
|
394
|
+
- **cURL** — Command-line examples for quick testing
|
|
395
|
+
- **Python** — OpenAI SDK code with your proxy URL
|
|
396
|
+
- **Node.js** — TypeScript/JavaScript examples
|
|
397
|
+
|
|
398
|
+
All code snippets use `localhost:PORT` (your proxy) instead of the upstream endpoint, so you can copy-paste and run immediately.
|
|
399
|
+
|
|
400
|
+
### Agent Mode
|
|
401
|
+
|
|
402
|
+
Toggle "Agent Mode" in the playground to enable tool calling:
|
|
403
|
+
|
|
404
|
+
1. Add MCP servers via UI or CLI
|
|
405
|
+
2. Connect to discover available tools
|
|
406
|
+
3. Select which tools to enable
|
|
407
|
+
4. Chat normally — the agent will use tools when appropriate
|
|
408
|
+
|
|
409
|
+
The agentic loop supports up to 10 tool iterations per message.
|
|
410
|
+
|
|
411
|
+
### Peek
|
|
412
|
+
|
|
413
|
+
Peek is the request-capture browser for debugging prompts, routing, tool use, and media-heavy interactions:
|
|
414
|
+
|
|
415
|
+
- **Calendar browse** — move day by day through captured traffic
|
|
416
|
+
- **Timeline view** — inspect ordered request and response segments, including assistant reasoning/tool-call structure
|
|
417
|
+
- **Request/Response tabs** — compare raw payloads and normalized previews
|
|
418
|
+
- **Media tab** — review persisted images and other artifacts
|
|
419
|
+
- **Token Flow Sankey** — visualize where captured input/output tokens were attributed
|
|
420
|
+
|
|
421
|
+
Timeline inspection example:
|
|
422
|
+
|
|
423
|
+

|
|
424
|
+
|
|
425
|
+
Token-flow Sankey example:
|
|
426
|
+
|
|
427
|
+

|
|
428
|
+
|
|
429
|
+
### Statistics
|
|
430
|
+
|
|
431
|
+
Waypoi exposes request statistics in both CLI and UI:
|
|
432
|
+
|
|
433
|
+
- `waypoi stats` for aggregated CLI summaries
|
|
434
|
+
- Dashboard cards and charts for latency, throughput, errors, and token usage
|
|
435
|
+
- `/admin/stats` for aggregate windows
|
|
436
|
+
- `/admin/stats/latency` for latency distribution buckets
|
|
437
|
+
- `/admin/stats/tokens` for token usage over time
|
|
438
|
+
|
|
439
|
+
Statistics are derived from the local JSONL request log store with retention-based rotation. Use them to validate routing changes, benchmark regressions, and slow/failing upstream behavior.
|
|
440
|
+
|
|
441
|
+
## Configuration
|
|
442
|
+
|
|
443
|
+
### config.yaml
|
|
444
|
+
|
|
445
|
+
```yaml
|
|
446
|
+
endpoints:
|
|
447
|
+
- name: openai
|
|
448
|
+
baseUrl: https://api.openai.com
|
|
449
|
+
apiKey: sk-...
|
|
450
|
+
priority: 1
|
|
451
|
+
type: llm
|
|
452
|
+
models:
|
|
453
|
+
- publicName: gpt-4
|
|
454
|
+
upstreamModel: gpt-4-turbo
|
|
455
|
+
capabilities:
|
|
456
|
+
input: [text]
|
|
457
|
+
output: [text]
|
|
458
|
+
- publicName: qwen3-vl
|
|
459
|
+
upstreamModel: qwen3-vl
|
|
460
|
+
capabilities:
|
|
461
|
+
input: [text, image]
|
|
462
|
+
output: [text]
|
|
463
|
+
|
|
464
|
+
- name: local-sd
|
|
465
|
+
baseUrl: http://localhost:7860
|
|
466
|
+
priority: 1
|
|
467
|
+
type: diffusion
|
|
468
|
+
models:
|
|
469
|
+
- publicName: sd-xl
|
|
470
|
+
upstreamModel: stable-diffusion-xl-base-1.0
|
|
471
|
+
capabilities:
|
|
472
|
+
input: [text]
|
|
473
|
+
output: [image]
|
|
474
|
+
|
|
475
|
+
# Enable authentication (default: false)
|
|
476
|
+
authEnabled: false
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
`capabilities` is optional. If omitted, Waypoi infers capabilities from model metadata/name and endpoint type.
|
|
480
|
+
|
|
481
|
+
### Environment Variables
|
|
482
|
+
|
|
483
|
+
| Variable | Default | Description |
|
|
484
|
+
|----------|---------|-------------|
|
|
485
|
+
| `PORT` | `9469` | Server port |
|
|
486
|
+
| `ADMIN_TOKEN` | — | Bearer token for admin endpoints |
|
|
487
|
+
| `WAYPOI_DIR` | `~/.config/waypoi` | Storage directory |
|
|
488
|
+
| `WAYPOI_CONFIG` | `{dir}/config.yaml` | Config file path |
|
|
489
|
+
| `WAYPOI_DEBUG_ERRORS` | `0` | Set to `1` for verbose internal error logs |
|
|
490
|
+
|
|
491
|
+
## Storage
|
|
492
|
+
|
|
493
|
+
All data is stored in `~/.config/waypoi` (or `$WAYPOI_DIR`):
|
|
494
|
+
|
|
495
|
+
| File/Directory | Purpose |
|
|
496
|
+
|----------------|---------|
|
|
497
|
+
| `config.yaml` | Endpoint configuration |
|
|
498
|
+
| `health.json` | Cached health state |
|
|
499
|
+
| `stats/` | JSONL stats files (30-day retention) |
|
|
500
|
+
| `sessions/` | Chat session JSON files |
|
|
501
|
+
| `images/` | AIGC image cache (1GB LRU) |
|
|
502
|
+
| `benchmarks/` | Benchmark reports |
|
|
503
|
+
| `mcp-servers.yaml` | MCP server registry |
|
|
504
|
+
| `waypoi.pid` | Service PID file |
|
|
505
|
+
| `waypoi.log` | Service log file |
|
|
506
|
+
|
|
507
|
+
## Development
|
|
508
|
+
|
|
509
|
+
```bash
|
|
510
|
+
# Run in development mode
|
|
511
|
+
npm run dev
|
|
512
|
+
|
|
513
|
+
# Build
|
|
514
|
+
npm run build
|
|
515
|
+
|
|
516
|
+
# Run tests
|
|
517
|
+
npm test
|
|
518
|
+
|
|
519
|
+
# Lint
|
|
520
|
+
npm run lint
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
## Authentication
|
|
524
|
+
|
|
525
|
+
Authentication is disabled by default. To enable:
|
|
526
|
+
|
|
527
|
+
1. Set `authEnabled: true` in `config.yaml`
|
|
528
|
+
2. Restart (or wait for hot-reload)
|
|
529
|
+
3. Include `Authorization: Bearer <token>` header
|
|
530
|
+
|
|
531
|
+
The auth middleware protects `/admin/*` and `/ui/*` routes.
|
|
532
|
+
|
|
533
|
+
## Manual Testing
|
|
534
|
+
|
|
535
|
+
```bash
|
|
536
|
+
# Test chat completions
|
|
537
|
+
curl http://localhost:9469/v1/chat/completions \
|
|
538
|
+
-H "Content-Type: application/json" \
|
|
539
|
+
-d '{"model": "local-default", "messages": [{"role": "user", "content": "Hello"}]}'
|
|
540
|
+
|
|
541
|
+
# Test image generation
|
|
542
|
+
curl http://localhost:9469/v1/images/generations \
|
|
543
|
+
-H "Content-Type: application/json" \
|
|
544
|
+
-d '{"model": "sd-xl", "prompt": "A sunset over mountains"}'
|
|
545
|
+
|
|
546
|
+
# Run manual test script
|
|
547
|
+
BASE_URL=http://localhost:9469 MODEL=local-default npm run manual-test
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
## License
|
|
551
|
+
|
|
552
|
+
MIT
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/icon.png
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|