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.
Files changed (260) hide show
  1. package/.github/instructions/ui.instructions.md +42 -0
  2. package/.github/workflows/ci.yml +35 -0
  3. package/.github/workflows/publish.yml +71 -0
  4. package/.github/workflows/release.yml +48 -0
  5. package/.playwright-mcp/console-2026-04-04T01-41-10-746Z.log +2 -0
  6. package/.playwright-mcp/console-2026-04-04T01-41-28-799Z.log +3 -0
  7. package/.playwright-mcp/console-2026-04-05T02-26-51-909Z.log +76 -0
  8. package/.playwright-mcp/page-2026-04-04T01-41-10-816Z.yml +1 -0
  9. package/.playwright-mcp/page-2026-04-04T01-41-29-141Z.yml +77 -0
  10. package/.playwright-mcp/page-2026-04-04T01-41-42-633Z.yml +190 -0
  11. package/.playwright-mcp/page-2026-04-04T01-42-03-929Z.yml +262 -0
  12. package/.playwright-mcp/page-2026-04-04T02-12-54-813Z.yml +6 -0
  13. package/.playwright-mcp/page-2026-04-04T02-14-58-600Z.yml +190 -0
  14. package/.playwright-mcp/page-2026-04-04T02-15-03-923Z.yml +190 -0
  15. package/.playwright-mcp/page-2026-04-04T02-15-07-426Z.yml +190 -0
  16. package/.playwright-mcp/page-2026-04-04T02-15-25-729Z.yml +262 -0
  17. package/.playwright-mcp/page-2026-04-04T02-16-22-984Z.yml +262 -0
  18. package/.playwright-mcp/page-2026-04-04T02-17-00-599Z.yml +190 -0
  19. package/.playwright-mcp/page-2026-04-04T02-17-50-874Z.yml +190 -0
  20. package/.playwright-mcp/page-2026-04-05T02-26-55-570Z.yml +6 -0
  21. package/AGENTS.md +48 -0
  22. package/CHANGELOG.md +131 -0
  23. package/README.md +552 -0
  24. package/assets/agent-mode.png +0 -0
  25. package/assets/categorize.png +0 -0
  26. package/assets/dashboard.png +0 -0
  27. package/assets/endpoint-proxy.png +0 -0
  28. package/assets/icon.png +0 -0
  29. package/assets/mcp-generate-image.png +0 -0
  30. package/assets/mcp-understand-image.png +0 -0
  31. package/assets/peek-token-flow.png +0 -0
  32. package/assets/playground.png +0 -0
  33. package/assets/sankey.png +0 -0
  34. package/cli/index.ts +2805 -0
  35. package/cli/legacyRewrite.ts +108 -0
  36. package/cli/modelRef.ts +24 -0
  37. package/dist/cli/index.js +2536 -0
  38. package/dist/cli/legacyRewrite.js +92 -0
  39. package/dist/cli/modelRef.js +20 -0
  40. package/dist/src/benchmark/artifacts.js +131 -0
  41. package/dist/src/benchmark/capabilityClassifier.js +81 -0
  42. package/dist/src/benchmark/capabilityStore.js +144 -0
  43. package/dist/src/benchmark/config.js +238 -0
  44. package/dist/src/benchmark/gates.js +118 -0
  45. package/dist/src/benchmark/jobs.js +252 -0
  46. package/dist/src/benchmark/runner.js +1847 -0
  47. package/dist/src/benchmark/schema.js +353 -0
  48. package/dist/src/benchmark/suites.js +314 -0
  49. package/dist/src/benchmark/tinyQaDataset.js +422 -0
  50. package/dist/src/benchmark/types.js +25 -0
  51. package/dist/src/config.js +47 -0
  52. package/dist/src/index.js +178 -0
  53. package/dist/src/mcp/client.js +215 -0
  54. package/dist/src/mcp/discovery.js +226 -0
  55. package/dist/src/mcp/policy.js +65 -0
  56. package/dist/src/mcp/registry.js +129 -0
  57. package/dist/src/mcp/service.js +460 -0
  58. package/dist/src/middleware/auth.js +179 -0
  59. package/dist/src/middleware/requestCapture.js +192 -0
  60. package/dist/src/middleware/requestStats.js +118 -0
  61. package/dist/src/pools/builder.js +132 -0
  62. package/dist/src/pools/repository.js +69 -0
  63. package/dist/src/pools/scheduler.js +360 -0
  64. package/dist/src/pools/types.js +2 -0
  65. package/dist/src/protocols/adapters/dashscope.js +267 -0
  66. package/dist/src/protocols/adapters/inferenceV2.js +346 -0
  67. package/dist/src/protocols/adapters/openai.js +27 -0
  68. package/dist/src/protocols/registry.js +99 -0
  69. package/dist/src/protocols/types.js +2 -0
  70. package/dist/src/providers/health.js +153 -0
  71. package/dist/src/providers/importer.js +289 -0
  72. package/dist/src/providers/modelRegistry.js +313 -0
  73. package/dist/src/providers/repository.js +361 -0
  74. package/dist/src/providers/types.js +2 -0
  75. package/dist/src/routes/admin.js +531 -0
  76. package/dist/src/routes/audio.js +295 -0
  77. package/dist/src/routes/chat.js +240 -0
  78. package/dist/src/routes/embeddings.js +157 -0
  79. package/dist/src/routes/images.js +288 -0
  80. package/dist/src/routes/mcp.js +256 -0
  81. package/dist/src/routes/mcpService.js +100 -0
  82. package/dist/src/routes/models.js +48 -0
  83. package/dist/src/routes/responses.js +711 -0
  84. package/dist/src/routes/sessions.js +450 -0
  85. package/dist/src/routes/stats.js +270 -0
  86. package/dist/src/routes/ui.js +97 -0
  87. package/dist/src/routes/videos.js +107 -0
  88. package/dist/src/routing/router.js +338 -0
  89. package/dist/src/services/imageGeneration.js +280 -0
  90. package/dist/src/services/imageUnderstanding.js +352 -0
  91. package/dist/src/services/videoGeneration.js +79 -0
  92. package/dist/src/storage/captureRepository.js +1591 -0
  93. package/dist/src/storage/files.js +157 -0
  94. package/dist/src/storage/imageCache.js +346 -0
  95. package/dist/src/storage/repositories.js +388 -0
  96. package/dist/src/storage/sessionRepository.js +370 -0
  97. package/dist/src/storage/statsRepository.js +204 -0
  98. package/dist/src/transport/httpClient.js +126 -0
  99. package/dist/src/types.js +2 -0
  100. package/dist/src/utils/messageMedia.js +285 -0
  101. package/dist/src/utils/modelCapabilities.js +108 -0
  102. package/dist/src/utils/modelDiscovery.js +170 -0
  103. package/dist/src/version.js +5 -0
  104. package/dist/src/workers/captureRetention.js +25 -0
  105. package/dist/src/workers/configWatcher.js +91 -0
  106. package/dist/src/workers/healthChecker.js +21 -0
  107. package/dist/src/workers/statsRotation.js +41 -0
  108. package/docs/LLM/output_schema.md +312 -0
  109. package/docs/benchmark.md +208 -0
  110. package/docs/mcp-guidelines.md +125 -0
  111. package/docs/mcp-service.md +178 -0
  112. package/docs/opencode.md +86 -0
  113. package/docs/providers.md +79 -0
  114. package/examples/benchmark.config.yaml +28 -0
  115. package/examples/providers/alibaba-dashscope.yaml +88 -0
  116. package/examples/providers/alibaba-llm.yaml +64 -0
  117. package/examples/providers/alibaba-registry.yaml +7 -0
  118. package/examples/providers/inference-v2-ray.yaml +29 -0
  119. package/examples/scenarios/assets/omni-call-sample.wav +0 -0
  120. package/examples/scenarios/custom.jsonl +5 -0
  121. package/examples/scenarios/custom.yaml +40 -0
  122. package/model-form-v2.png +0 -0
  123. package/package.json +66 -0
  124. package/provider-form-v2.png +0 -0
  125. package/provider-form.png +0 -0
  126. package/scripts/manual-test.sh +11 -0
  127. package/scripts/version-from-git.js +23 -0
  128. package/src/benchmark/artifacts.ts +149 -0
  129. package/src/benchmark/capabilityClassifier.ts +99 -0
  130. package/src/benchmark/capabilityStore.ts +174 -0
  131. package/src/benchmark/config.ts +337 -0
  132. package/src/benchmark/gates.ts +164 -0
  133. package/src/benchmark/jobs.ts +312 -0
  134. package/src/benchmark/runner.ts +2519 -0
  135. package/src/benchmark/schema.ts +443 -0
  136. package/src/benchmark/suites.ts +323 -0
  137. package/src/benchmark/tinyQaDataset.ts +428 -0
  138. package/src/benchmark/types.ts +442 -0
  139. package/src/config.ts +44 -0
  140. package/src/index.ts +195 -0
  141. package/src/mcp/client.ts +305 -0
  142. package/src/mcp/discovery.ts +266 -0
  143. package/src/mcp/policy.ts +105 -0
  144. package/src/mcp/registry.ts +164 -0
  145. package/src/mcp/service.ts +611 -0
  146. package/src/middleware/auth.ts +251 -0
  147. package/src/middleware/requestCapture.ts +245 -0
  148. package/src/middleware/requestStats.ts +163 -0
  149. package/src/pools/builder.ts +159 -0
  150. package/src/pools/repository.ts +71 -0
  151. package/src/pools/scheduler.ts +425 -0
  152. package/src/pools/types.ts +117 -0
  153. package/src/protocols/adapters/dashscope.ts +335 -0
  154. package/src/protocols/adapters/inferenceV2.ts +428 -0
  155. package/src/protocols/adapters/openai.ts +32 -0
  156. package/src/protocols/registry.ts +117 -0
  157. package/src/protocols/types.ts +81 -0
  158. package/src/providers/health.ts +207 -0
  159. package/src/providers/importer.ts +402 -0
  160. package/src/providers/modelRegistry.ts +415 -0
  161. package/src/providers/repository.ts +439 -0
  162. package/src/providers/types.ts +113 -0
  163. package/src/routes/admin.ts +666 -0
  164. package/src/routes/audio.ts +372 -0
  165. package/src/routes/chat.ts +301 -0
  166. package/src/routes/embeddings.ts +197 -0
  167. package/src/routes/images.ts +356 -0
  168. package/src/routes/mcp.ts +320 -0
  169. package/src/routes/mcpService.ts +114 -0
  170. package/src/routes/models.ts +50 -0
  171. package/src/routes/responses.ts +872 -0
  172. package/src/routes/sessions.ts +558 -0
  173. package/src/routes/stats.ts +312 -0
  174. package/src/routes/ui.ts +96 -0
  175. package/src/routes/videos.ts +132 -0
  176. package/src/routing/router.ts +501 -0
  177. package/src/services/imageGeneration.ts +396 -0
  178. package/src/services/imageUnderstanding.ts +449 -0
  179. package/src/services/videoGeneration.ts +127 -0
  180. package/src/storage/captureRepository.ts +1835 -0
  181. package/src/storage/files.ts +178 -0
  182. package/src/storage/imageCache.ts +405 -0
  183. package/src/storage/repositories.ts +494 -0
  184. package/src/storage/sessionRepository.ts +419 -0
  185. package/src/storage/statsRepository.ts +238 -0
  186. package/src/transport/httpClient.ts +145 -0
  187. package/src/types.ts +322 -0
  188. package/src/utils/messageMedia.ts +293 -0
  189. package/src/utils/modelCapabilities.ts +161 -0
  190. package/src/utils/modelDiscovery.ts +203 -0
  191. package/src/workers/captureRetention.ts +25 -0
  192. package/src/workers/configWatcher.ts +115 -0
  193. package/src/workers/healthChecker.ts +22 -0
  194. package/src/workers/statsRotation.ts +49 -0
  195. package/tests/benchmarkAdminRoutes.test.ts +82 -0
  196. package/tests/benchmarkBasics.test.ts +116 -0
  197. package/tests/captureAdminRoutes.test.ts +420 -0
  198. package/tests/captureRepository.test.ts +797 -0
  199. package/tests/cliLegacyRewrite.test.ts +45 -0
  200. package/tests/imageGeneration.service.test.ts +107 -0
  201. package/tests/imageUnderstanding.service.test.ts +123 -0
  202. package/tests/mcpPolicy.test.ts +105 -0
  203. package/tests/mcpService.test.ts +1245 -0
  204. package/tests/modelRef.test.ts +23 -0
  205. package/tests/modelsRoutes.test.ts +154 -0
  206. package/tests/sessionMediaCache.test.ts +167 -0
  207. package/tests/statsRoutes.test.ts +323 -0
  208. package/tsconfig.json +15 -0
  209. package/ui/index.html +16 -0
  210. package/ui/package-lock.json +8521 -0
  211. package/ui/package.json +52 -0
  212. package/ui/postcss.config.js +6 -0
  213. package/ui/public/assets/apple-touch-icon.png +0 -0
  214. package/ui/public/assets/favicon-16.png +0 -0
  215. package/ui/public/assets/favicon-32.png +0 -0
  216. package/ui/public/assets/icon-192.png +0 -0
  217. package/ui/public/assets/icon-512.png +0 -0
  218. package/ui/src/App.tsx +27 -0
  219. package/ui/src/api/client.ts +1503 -0
  220. package/ui/src/components/EndpointUsageGuide.tsx +361 -0
  221. package/ui/src/components/Layout.tsx +124 -0
  222. package/ui/src/components/MessageContent.tsx +365 -0
  223. package/ui/src/components/ToolCallMessage.tsx +179 -0
  224. package/ui/src/components/ToolPicker.tsx +442 -0
  225. package/ui/src/components/messageContentParser.test.ts +41 -0
  226. package/ui/src/components/messageContentParser.ts +73 -0
  227. package/ui/src/components/thinkingPreview.test.ts +27 -0
  228. package/ui/src/components/thinkingPreview.ts +15 -0
  229. package/ui/src/components/toMermaidSankey.test.ts +78 -0
  230. package/ui/src/components/toMermaidSankey.ts +56 -0
  231. package/ui/src/components/ui/button.tsx +58 -0
  232. package/ui/src/components/ui/input.tsx +21 -0
  233. package/ui/src/components/ui/textarea.tsx +21 -0
  234. package/ui/src/lib/utils.ts +6 -0
  235. package/ui/src/main.tsx +9 -0
  236. package/ui/src/pages/AgentPlayground.tsx +2010 -0
  237. package/ui/src/pages/Benchmark.tsx +988 -0
  238. package/ui/src/pages/Dashboard.tsx +581 -0
  239. package/ui/src/pages/Peek.tsx +962 -0
  240. package/ui/src/pages/Settings.tsx +2013 -0
  241. package/ui/src/pages/agentPlaygroundPayload.test.ts +109 -0
  242. package/ui/src/pages/agentPlaygroundPayload.ts +97 -0
  243. package/ui/src/pages/agentThinkingContent.test.ts +50 -0
  244. package/ui/src/pages/agentThinkingContent.ts +57 -0
  245. package/ui/src/pages/dashboardTokenUsage.test.ts +66 -0
  246. package/ui/src/pages/dashboardTokenUsage.ts +36 -0
  247. package/ui/src/pages/imageUpload.test.ts +39 -0
  248. package/ui/src/pages/imageUpload.ts +71 -0
  249. package/ui/src/pages/peekFilters.test.ts +29 -0
  250. package/ui/src/pages/peekFilters.ts +13 -0
  251. package/ui/src/pages/peekMedia.test.ts +58 -0
  252. package/ui/src/pages/peekMedia.ts +148 -0
  253. package/ui/src/pages/sessionAutoTitle.test.ts +128 -0
  254. package/ui/src/pages/sessionAutoTitle.ts +106 -0
  255. package/ui/src/stores/settings.ts +58 -0
  256. package/ui/src/styles/globals.css +223 -0
  257. package/ui/src/vite-env.d.ts +8 -0
  258. package/ui/tailwind.config.js +106 -0
  259. package/ui/tsconfig.json +32 -0
  260. package/ui/vite.config.ts +37 -0
@@ -0,0 +1,178 @@
1
+ # MCP Service (`/mcp`)
2
+
3
+ Waypoi provides a built-in MCP server at:
4
+
5
+ - `POST /mcp` (Streamable HTTP transport)
6
+ - localhost only (`localhost`, `127.0.0.1`, `::1`)
7
+
8
+ Policy authority: [`docs/mcp-guidelines.md`](./mcp-guidelines.md)
9
+
10
+ ## Client flow
11
+
12
+ 1. `initialize`
13
+ 2. `notifications/initialized`
14
+ 3. `tools/list`
15
+ 4. `tools/call`
16
+
17
+ ## Tool: `generate_image`
18
+
19
+ Generate image(s) from text using Waypoi's diffusion routing.
20
+ When `image_path` or `image_url` is provided, the tool performs image-to-image editing.
21
+
22
+ Governance note: this tool follows the file-first policy from [`docs/mcp-guidelines.md`](./mcp-guidelines.md).
23
+
24
+ ### Server environment guards
25
+
26
+ `generate_image` file-output path can be overridden with server env vars:
27
+
28
+ - `WAYPOI_MCP_OUTPUT_ROOT` (optional, absolute path):
29
+ - sets the output base directory; defaults to `~/.config/waypoi` when unset
30
+ - `WAYPOI_MCP_OUTPUT_SUBDIR` (optional, relative path):
31
+ - narrows output to `<WAYPOI_MCP_OUTPUT_ROOT>/<subdir>` instead of `<root>/generated-images`
32
+ - example: `work`
33
+ - `WAYPOI_MCP_STRICT_OUTPUT_ROOT` (optional, `true|false`, default `false`):
34
+ - when `true`, `WAYPOI_MCP_OUTPUT_ROOT` is required and must be absolute
35
+ - invalid/missing strict config returns typed `invalid_request` errors
36
+
37
+ Example for pinning outputs to a specific project:
38
+
39
+ ```bash
40
+ export WAYPOI_MCP_OUTPUT_ROOT=/path/to/project
41
+ export WAYPOI_MCP_OUTPUT_SUBDIR=work
42
+ export WAYPOI_MCP_STRICT_OUTPUT_ROOT=true
43
+ ```
44
+
45
+ ### Input fields
46
+
47
+ - `prompt` (required, string)
48
+ - `model` (optional, string)
49
+ - `image_path` (optional, string; local file path for image-to-image editing)
50
+ - `image_url` (optional, string; supports `http(s)` or `data:` URL for image-to-image editing)
51
+ - `n` (optional, integer `1..4`)
52
+ - `size` (optional, string)
53
+ - `quality` (optional, string)
54
+ - `style` (optional, string)
55
+ - `response_format` (optional, `"url"` or `"b64_json"`)
56
+ - `include_data` (optional, boolean):
57
+ - include `url`/`b64_json` in detailed structured output
58
+ - default is `false`
59
+
60
+ ### File-output behavior
61
+
62
+ `generate_image` always writes image bytes to disk and returns metadata:
63
+
64
+ - `file_path`
65
+ - `file_paths` when multiple images are generated
66
+ - `mime_type`
67
+ - `bytes`
68
+
69
+ Default output directory: `~/.config/waypoi/generated-images` (or `$WAYPOI_DIR/generated-images`).
70
+ Override with `WAYPOI_MCP_OUTPUT_ROOT` and optionally `WAYPOI_MCP_OUTPUT_SUBDIR`.
71
+
72
+ Returned `file_path` values are relative to `WAYPOI_MCP_OUTPUT_ROOT` (or `~/.config/waypoi`).
73
+
74
+ Implementation note: `generate_image` forces upstream `response_format` to `"b64_json"` to ensure bytes are always available for writing, even if caller passes `"url"`.
75
+
76
+ ### Validation rules
77
+
78
+ - `image_path` and `image_url` are mutually exclusive.
79
+ - If `WAYPOI_MCP_OUTPUT_SUBDIR` is set, it must be a relative path.
80
+ - If `WAYPOI_MCP_STRICT_OUTPUT_ROOT=true`, `WAYPOI_MCP_OUTPUT_ROOT` must be set and absolute.
81
+
82
+ ### Response notes
83
+
84
+ - Success: `ok: true` with `summary`, `file_path`/`file_paths`, and detailed `artifacts[]`.
85
+ - Error: `ok: false` with typed `error` (`invalid_request`, `no_diffusion_model`, `upstream_error`, etc).
86
+
87
+ ## Tool: `understand_image`
88
+
89
+ Analyze an image using a vision-capable text model and return structured text.
90
+
91
+ ### Input fields
92
+
93
+ - `image_path` (optional, string; local file path)
94
+ - `image_url` (optional, string; supports `http(s)` or `data:` URL)
95
+ - `instruction` (optional, string; default: general OCR/object/scene/detail analysis)
96
+ - `model` (optional, string; auto-selects best vision-capable text-output model when omitted)
97
+ - `max_tokens` (optional, integer `1..4096`)
98
+ - `temperature` (optional, number `0..2`)
99
+
100
+ Validation:
101
+
102
+ - Exactly one image source is required: `image_path` XOR `image_url`.
103
+
104
+ ### Response shape
105
+
106
+ Success:
107
+
108
+ - `ok`
109
+ - `summary`
110
+ - `model`
111
+ - `text`
112
+ - `result`:
113
+ - `answer`
114
+ - `ocr_text`
115
+ - `objects`
116
+ - `scene`
117
+ - `notable_details`
118
+ - `safety_notes`
119
+ - `image_geometry` (optional for local image paths):
120
+ - `original_width`
121
+ - `original_height`
122
+ - `uploaded_width`
123
+ - `uploaded_height`
124
+ - `scale_x`
125
+ - `scale_y`
126
+ - `resized`
127
+ - `usage` (`prompt_tokens`, `completion_tokens`, `total_tokens`)
128
+
129
+ For local `image_path` inputs, Waypoi may resize the uploaded image before sending it upstream. When that happens, it prepends a system instruction telling the model to report any coordinates in original-image pixels and includes `image_geometry` in the success payload for debugging and downstream correction.
130
+
131
+ Error:
132
+
133
+ - `ok: false`
134
+ - typed `error` (`invalid_request`, `no_vision_model`, `upstream_error`, ...)
135
+
136
+ ## Tool: `generate_video`
137
+
138
+ Generate a video from a text prompt or image using Alibaba Cloud ModelStudio (Wan models).
139
+ Supports text-to-video and image-to-video generation. Videos are generated asynchronously
140
+ and may take 1-5 minutes.
141
+
142
+ Governance note: video URLs are returned directly (not written to disk) because videos are
143
+ streaming media files typically consumed via URL rather than embedded.
144
+
145
+ ### Input fields
146
+
147
+ - `prompt` (required, string): Detailed description of the desired video content, style, camera movement, and lighting.
148
+ - `model` (optional, string): Model name (e.g., `wan2.6-i2v-flash`, `wan2.6-t2v`). Auto-selected when omitted.
149
+ - `image_url` (optional, string): URL or data URL of the first-frame image for image-to-video generation.
150
+ - `audio_url` (optional, string): URL of an audio file to sync with the video (wan2.6/wan2.5 models only).
151
+ - `duration` (optional, integer `2..15`): Video duration in seconds. Model-dependent defaults apply.
152
+ - `resolution` (optional, `"480P"`, `"720P"`, or `"1080P"`): Output resolution tier.
153
+ - `negative_prompt` (optional, string): Description of content to exclude.
154
+ - `seed` (optional, integer `0..2147483647`): Random seed for reproducibility.
155
+ - `watermark` (optional, boolean): Add "AI Generated" watermark (default: false).
156
+ - `prompt_extend` (optional, boolean): Enable intelligent prompt rewriting (default: true).
157
+
158
+ ### Response shape
159
+
160
+ Success:
161
+
162
+ - `ok: true`
163
+ - `summary`: "Generated 1 video."
164
+ - `model`: upstream model name used
165
+ - `url`: URL to the generated MP4 video (valid for 24 hours)
166
+ - `revised_prompt` (optional): optimized prompt if prompt_extend was enabled
167
+ - `video_count`, `duration`, `resolution` (optional): usage metadata
168
+
169
+ Error:
170
+
171
+ - `ok: false`
172
+ - typed `error` (`invalid_request`, `no_video_model`, `no_video_output`, `upstream_error`, ...)
173
+
174
+ ### Response notes
175
+
176
+ - Video URLs expire after 24 hours. Download and save videos promptly to permanent storage.
177
+ - The `generate_video` tool has a 5-minute timeout to accommodate async generation.
178
+ - Output video format: MP4 (H.264 encoding), 30 fps.
@@ -0,0 +1,86 @@
1
+ # Using Waypoi with Opencode
2
+
3
+ Waypoi is a local OpenAI-compatible gateway. Opencode should connect to Waypoi as an external client.
4
+
5
+ ## 1) Start Waypoi
6
+
7
+ ```bash
8
+ waypoi provider import -f .env
9
+ npm run start
10
+ ```
11
+
12
+ Default base URL:
13
+
14
+ - `http://localhost:9469/v1`
15
+
16
+ ## 2) Point Opencode to Waypoi
17
+
18
+ Configure Opencode with:
19
+
20
+ - Base URL: `http://localhost:9469/v1`
21
+ - API key: `local-dev` (or your configured auth token)
22
+
23
+ If Waypoi auth is enabled, send the matching bearer token.
24
+
25
+ ## 3) Validate model discovery
26
+
27
+ ```bash
28
+ curl http://localhost:9469/v1/models
29
+ ```
30
+
31
+ Waypoi returns an OpenAI-style model list from healthy endpoints and smart pool aliases.
32
+ Use `smart` as the default model for free-tier routing with automatic failover.
33
+
34
+ ## 4) Optional: Responses API
35
+
36
+ Waypoi exposes:
37
+
38
+ - `POST /v1/responses`
39
+
40
+ Use this only when your client supports Responses API style requests. Otherwise use chat completions.
41
+
42
+ ## 5) Basic request check
43
+
44
+ ```bash
45
+ curl http://localhost:9469/v1/chat/completions \
46
+ -H "Content-Type: application/json" \
47
+ -H "Authorization: Bearer local-dev" \
48
+ -d '{
49
+ "model": "smart",
50
+ "messages": [{"role": "user", "content": "hello"}]
51
+ }'
52
+ ```
53
+
54
+ ## 6) Benchmark the same real-world flows
55
+
56
+ Use the built-in showcase examples to replay the same kinds of interactions you expect from Opencode:
57
+
58
+ ```bash
59
+ # See available examples
60
+ waypoi bench --list-examples
61
+
62
+ # Plain chat
63
+ waypoi bench --example showcase-chat-welcome
64
+
65
+ # Responses API compatibility
66
+ waypoi bench --example showcase-responses-basic
67
+
68
+ # Tool-calling live show
69
+ waypoi bench --example showcase-agent-tool-call
70
+ ```
71
+
72
+ The Benchmark UI shows:
73
+
74
+ - the exact scenario input
75
+ - the wire request Waypoi sent
76
+ - tool calls and tool results
77
+ - the final model response
78
+ - the final verdict
79
+
80
+ This is the fastest way to demonstrate that an Opencode-style workflow works end to end.
81
+
82
+ ## Troubleshooting
83
+
84
+ - Empty model list: verify endpoint health with `waypoi status`.
85
+ - 401/403: check auth mode and token.
86
+ - Slow/failover behavior: inspect `waypoi stats` and dashboard latency panels.
@@ -0,0 +1,79 @@
1
+ # Providers and Protocol Adapters
2
+
3
+ Waypoi uses a provider catalog with protocol adapters.
4
+ External clients still use OpenAI-compatible `/v1/*` endpoints; adapters translate to provider-native protocols.
5
+
6
+ ## Onboarding a non-OpenAI protocol provider
7
+
8
+ 1. Create a provider YAML with:
9
+ - `endpoint.protocol`
10
+ - `endpoint.baseUrl`
11
+ - protocol-specific config (for `inference_v2`: `endpoint.router`)
12
+ 2. Import with:
13
+ - `waypoi providers import --registry <registry.yaml> --env-file .env`
14
+ 3. Rebuild pools:
15
+ - `waypoi providers import ...` (default auto rebuild) or `POST /admin/pools/rebuild`
16
+ 4. Verify:
17
+ - `waypoi providers`
18
+ - `waypoi providers show <id>`
19
+ - `waypoi models <id>`
20
+ 5. Optional TLS policy:
21
+ - `waypoi providers update <id> --insecure-tls|--strict-tls`
22
+ - `waypoi providers update <id> --auto-insecure-domain <suffix...>`
23
+
24
+ ## Provider model CRUD
25
+
26
+ Use provider-first model management:
27
+
28
+ - `waypoi models add <providerId> --model-id <id> --upstream <name> --base-url <url>`
29
+ - `waypoi models update <providerId> <modelRef> ...`
30
+ - `waypoi models update <providerId> <modelRef> --clear-insecure-tls`
31
+ - `waypoi models rm <providerId> <modelRef>`
32
+ - `waypoi models enable <providerId>/<modelRef>`
33
+ - `waypoi models disable <providerId>/<modelRef>`
34
+ - `waypoi models set-key <providerId>/<modelRef> --api-key <key>`
35
+
36
+ Legacy command forms (`waypoi provider ...`, `waypoi provider model ...`) are still supported through rewrite shims with deprecation warnings.
37
+
38
+ Legacy endpoint write commands are blocked in v0.5.0; use migration + `waypoi models ...` commands.
39
+
40
+ ## Inference V2 (ray/kserve-style) example
41
+
42
+ See: `/Users/zziang/Documents/projects/vibeCoding/Agents/waypoi/examples/providers/inference-v2-ray.yaml`
43
+
44
+ Key fields:
45
+
46
+ - `endpoint.protocol: inference_v2`
47
+ - `endpoint.router: <router_name>`
48
+ - `endpoint.responseTextPaths` (optional response extraction path list)
49
+
50
+ ## Notes
51
+
52
+ - `inference_v2` v1 supports chat/vision sync (`stream=false`) only.
53
+ - Streaming requests are rejected for this protocol unless another pool candidate supports streaming.
54
+ - Unknown protocols are imported but marked non-routable.
55
+ - Pool alias surface is now a single `smart` alias; legacy `smart-*` aliases are rejected.
56
+ - TLS inheritance:
57
+ - Effective TLS mode is `model.insecureTls ?? provider.insecureTls ?? false`.
58
+ - Models added without `--insecure-tls` inherit provider TLS mode.
59
+ - Allowlisted auto-insecure fallback:
60
+ - On TLS verify failures, Waypoi retries insecure TLS only when hostname matches provider `autoInsecureTlsDomains`.
61
+ - If retry succeeds, Waypoi persists `model.insecureTls=true` for that model.
62
+
63
+ ## PCAI endpoint migration runbook (`*.ai-application.stjude.org`)
64
+
65
+ This migration copies endpoint-managed models into provider `pcai`, then disables the source endpoints.
66
+
67
+ 1. Pre-check:
68
+ - `waypoi ls`
69
+ 2. Run migration:
70
+ - `waypoi providers migrate-endpoints --provider pcai --match-domain ai-application.stjude.org --protocol openai`
71
+ 3. Verify:
72
+ - `waypoi providers show pcai`
73
+ - `waypoi models pcai`
74
+ - `waypoi providers pools`
75
+ - `waypoi ls` (legacy endpoints should show `disabled=yes`)
76
+ 4. Rollback (single model path):
77
+ - Re-enable the endpoint in `config.yaml` (`disabled: false`) or via admin endpoint patch.
78
+ - Set the corresponding `pcai` provider model `enabled: false` in `$WAYPOI_DIR/providers.json`.
79
+ - Rebuild pools: `waypoi providers pools` (or `POST /admin/pools/rebuild`).
@@ -0,0 +1,28 @@
1
+ version: 1
2
+
3
+ defaults:
4
+ requestTimeoutMs: 120000
5
+ toolTimeoutMs: 15000
6
+ maxIterations: 6
7
+ temperature: 0
8
+ top_p: 1
9
+ max_tokens: 512
10
+ presence_penalty: 0
11
+ frequency_penalty: 0
12
+
13
+ profiles:
14
+ local:
15
+ warmupRuns: 1
16
+ measuredRuns: 3
17
+ minScenarioPassRate: 1.0
18
+ ci:
19
+ warmupRuns: 2
20
+ measuredRuns: 5
21
+ minScenarioPassRate: 1.0
22
+
23
+ gates:
24
+ hard:
25
+ smokeMinSuccessRate: 1.0
26
+ soft:
27
+ maxP95RegressionPct: 20
28
+ maxThroughputDropPct: 20
@@ -0,0 +1,88 @@
1
+ $id: alibaba-dashscope
2
+ name: Alibaba Cloud Model Studio (DashScope Native)
3
+ description: Wan series models for image and video generation via DashScope native API
4
+ docs: https://www.alibabacloud.com/help/en/model-studio/wan-image-generation-api-reference
5
+ endpoint:
6
+ baseUrl: https://dashscope-intl.aliyuncs.com
7
+ protocol: dashscope
8
+ auth:
9
+ type: bearer
10
+ keyParam: Authorization
11
+ env: DASHSCOPE_API_KEY
12
+ models:
13
+ - id: wan2.6-image
14
+ upstream: wan2.6-image
15
+ free: false
16
+ modalities:
17
+ - text-to-image
18
+ capabilities:
19
+ streaming: false
20
+ benchmark:
21
+ livebench: 60.0
22
+ - id: wan2.6-i2v-flash
23
+ upstream: wan2.6-i2v-flash
24
+ free: false
25
+ modalities:
26
+ - text-to-video
27
+ - image-to-video
28
+ capabilities:
29
+ streaming: false
30
+ benchmark:
31
+ livebench: 58.0
32
+ - id: wan2.6-i2v
33
+ upstream: wan2.6-i2v
34
+ free: false
35
+ modalities:
36
+ - text-to-video
37
+ - image-to-video
38
+ capabilities:
39
+ streaming: false
40
+ benchmark:
41
+ livebench: 57.0
42
+ - id: wan2.6-t2v
43
+ upstream: wan2.6-t2v
44
+ free: false
45
+ modalities:
46
+ - text-to-video
47
+ capabilities:
48
+ streaming: false
49
+ benchmark:
50
+ livebench: 56.0
51
+ - id: wan2.5-i2v-preview
52
+ upstream: wan2.5-i2v-preview
53
+ free: false
54
+ modalities:
55
+ - text-to-video
56
+ - image-to-video
57
+ capabilities:
58
+ streaming: false
59
+ benchmark:
60
+ livebench: 55.0
61
+ - id: wan2.5-t2v-preview
62
+ upstream: wan2.5-t2v-preview
63
+ free: false
64
+ modalities:
65
+ - text-to-video
66
+ capabilities:
67
+ streaming: false
68
+ benchmark:
69
+ livebench: 54.0
70
+ - id: wan2.2-i2v-plus
71
+ upstream: wan2.2-i2v-plus
72
+ free: false
73
+ modalities:
74
+ - text-to-video
75
+ - image-to-video
76
+ capabilities:
77
+ streaming: false
78
+ benchmark:
79
+ livebench: 50.0
80
+ - id: wan2.2-t2v-plus
81
+ upstream: wan2.2-t2v-plus
82
+ free: false
83
+ modalities:
84
+ - text-to-video
85
+ capabilities:
86
+ streaming: false
87
+ benchmark:
88
+ livebench: 49.0
@@ -0,0 +1,64 @@
1
+ $id: alibaba-llm
2
+ name: Alibaba Cloud Model Studio (OpenAI Compatible)
3
+ description: Qwen series models via OpenAI-compatible interface
4
+ docs: https://www.alibabacloud.com/help/en/model-studio/compatibility-of-openai-with-dashscope
5
+ endpoint:
6
+ baseUrl: https://dashscope-intl.aliyuncs.com/compatible-mode/v1
7
+ protocol: openai
8
+ auth:
9
+ type: bearer
10
+ keyParam: Authorization
11
+ env: DASHSCOPE_API_KEY
12
+ models:
13
+ - id: qwen3-max
14
+ upstream: qwen3-max
15
+ free: false
16
+ modalities:
17
+ - text-to-text
18
+ capabilities:
19
+ streaming: true
20
+ tools: true
21
+ benchmark:
22
+ livebench: 72.0
23
+ - id: qwen-plus
24
+ upstream: qwen-plus
25
+ free: false
26
+ modalities:
27
+ - text-to-text
28
+ capabilities:
29
+ streaming: true
30
+ tools: true
31
+ benchmark:
32
+ livebench: 68.0
33
+ - id: qwen-flash
34
+ upstream: qwen-flash
35
+ free: false
36
+ modalities:
37
+ - text-to-text
38
+ capabilities:
39
+ streaming: true
40
+ tools: true
41
+ benchmark:
42
+ livebench: 62.0
43
+ - id: qwen3.5-plus
44
+ upstream: qwen3.5-plus
45
+ free: false
46
+ modalities:
47
+ - text-to-text
48
+ - image-to-text
49
+ capabilities:
50
+ streaming: true
51
+ tools: true
52
+ vision: true
53
+ benchmark:
54
+ livebench: 70.0
55
+ - id: qwen3-coder-plus
56
+ upstream: qwen3-coder-plus
57
+ free: false
58
+ modalities:
59
+ - text-to-text
60
+ capabilities:
61
+ streaming: true
62
+ tools: true
63
+ benchmark:
64
+ livebench: 65.0
@@ -0,0 +1,7 @@
1
+ providers:
2
+ - id: alibaba-llm
3
+ name: Alibaba Cloud Model Studio (OpenAI Compatible)
4
+ file: alibaba-llm.yaml
5
+ - id: alibaba-dashscope
6
+ name: Alibaba Cloud Model Studio (DashScope Native)
7
+ file: alibaba-dashscope.yaml
@@ -0,0 +1,29 @@
1
+ $id: ray-gateway
2
+ name: Ray Gateway Router
3
+ description: Example provider using /v2/models/{router}/infer protocol
4
+ docs: https://ray.io/
5
+ endpoint:
6
+ baseUrl: https://svltgpt01a.stjude.org
7
+ protocol: inference_v2
8
+ router: ray_gateway_router
9
+ responseTextPaths:
10
+ - outputs.0.outputs.text
11
+ - outputs.0.text
12
+ auth:
13
+ type: bearer
14
+ keyParam: Authorization
15
+ env: RAY_GATEWAY_API_KEY
16
+ models:
17
+ - id: qwen3-vl-30b
18
+ upstream: qwen3-VL-30B-A3B-Thinking-vllm
19
+ free: false
20
+ modalities:
21
+ - text-to-text
22
+ - image-to-text
23
+ capabilities:
24
+ streaming: false
25
+ tools: false
26
+ vision: true
27
+ benchmark:
28
+ livebench: 52.0
29
+
@@ -0,0 +1,5 @@
1
+ {"id":"jsonl-chat-1","mode":"chat","prompt":"Say WAYPOINT_JSONL_OK","assertions":{"contains":"WAYPOINT_JSONL_OK","statusCode":200}}
2
+ {"id":"jsonl-agent-1","mode":"agent","prompt":"Use a tool if available then answer.","assertions":{"statusCode":200}}
3
+ {"id":"jsonl-emb-1","mode":"embeddings","input":"waypoint jsonl embedding","assertions":{"minItems":1,"minVectorLength":1,"statusCode":200}}
4
+ {"id":"jsonl-img-1","mode":"image_generation","prompt":"A simple blue square","assertions":{"minImages":1,"statusCode":200}}
5
+ {"id":"jsonl-tts-1","mode":"audio_speech","inputText":"Waypoint jsonl speech","voice":"alloy","assertions":{"minBytes":1,"statusCode":200}}
@@ -0,0 +1,40 @@
1
+ scenarios:
2
+ - id: custom-chat-short
3
+ mode: chat
4
+ prompt: "Reply with WAYPOI_CUSTOM_OK"
5
+ assertions:
6
+ contains: "WAYPOI_CUSTOM_OK"
7
+ statusCode: 200
8
+
9
+ - id: custom-agent-tools
10
+ mode: agent
11
+ prompt: "If tools are available, call one and summarize with prefix WAYPOI_AGENT_DONE:"
12
+ maxIterations: 5
13
+ assertions:
14
+ contains: "WAYPOI_AGENT_DONE"
15
+ statusCode: 200
16
+
17
+ - id: custom-embeddings
18
+ mode: embeddings
19
+ input:
20
+ - "waypoi"
21
+ - "benchmark"
22
+ assertions:
23
+ minItems: 2
24
+ minVectorLength: 1
25
+ statusCode: 200
26
+
27
+ - id: custom-image
28
+ mode: image_generation
29
+ prompt: "A clean neon gateway symbol"
30
+ assertions:
31
+ minImages: 1
32
+ statusCode: 200
33
+
34
+ - id: custom-tts
35
+ mode: audio_speech
36
+ inputText: "Waypoi benchmark audio"
37
+ voice: "alloy"
38
+ assertions:
39
+ minBytes: 1
40
+ statusCode: 200
Binary file
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "waypoi",
3
+ "version": "0.0.0",
4
+ "description": "Local OpenAI-compatible AI gateway with intelligent routing, failover, MCP tools, and a built-in playground UI",
5
+ "license": "MIT",
6
+ "main": "dist/src/index.js",
7
+ "bin": {
8
+ "waypoi": "dist/cli/index.js",
9
+ "waypoi-dev": "dist/cli/index.js"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/ziangziangziang/waypoi.git"
14
+ },
15
+ "homepage": "https://github.com/ziangziangziang/waypoi#readme",
16
+ "bugs": {
17
+ "url": "https://github.com/ziangziangziang/waypoi/issues"
18
+ },
19
+ "keywords": [
20
+ "ai",
21
+ "llm",
22
+ "proxy",
23
+ "openai",
24
+ "mcp",
25
+ "local-ai",
26
+ "gateway",
27
+ "playground"
28
+ ],
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "scripts": {
33
+ "predev": "node scripts/version-from-git.js",
34
+ "dev": "concurrently -n server,ui -c blue,green \"WAYPOI_DEV=1 tsx watch src/index.ts\" \"VITE_BACKEND_PORT=9470 npm run dev --prefix ui\"",
35
+ "predev:server": "node scripts/version-from-git.js",
36
+ "dev:server": "WAYPOI_DEV=1 tsx watch src/index.ts",
37
+ "predev:all": "node scripts/version-from-git.js",
38
+ "dev:all": "concurrently -n server,ui -c blue,green \"WAYPOI_DEV=1 tsx watch src/index.ts\" \"VITE_BACKEND_PORT=9470 npm run dev --prefix ui\"",
39
+ "prebuild": "node scripts/version-from-git.js",
40
+ "build": "tsc -p tsconfig.json && cd ui && npm run build",
41
+ "build:ui": "cd ui && npm run build",
42
+ "build:all": "npm run build",
43
+ "start": "node dist/src/index.js",
44
+ "cli": "tsx cli/index.ts",
45
+ "manual-test": "bash scripts/manual-test.sh",
46
+ "test": "npx tsx --test tests/*.test.ts",
47
+ "pretypecheck": "node scripts/version-from-git.js",
48
+ "typecheck": "tsc --noEmit"
49
+ },
50
+ "dependencies": {
51
+ "@fastify/static": "^9.0.0",
52
+ "@modelcontextprotocol/sdk": "^1.27.1",
53
+ "commander": "^12.1.0",
54
+ "fastify": "^5.8.4",
55
+ "sharp": "^0.33.5",
56
+ "undici": "^6.19.8",
57
+ "yaml": "^2.4.5",
58
+ "zod": "^4.3.6"
59
+ },
60
+ "devDependencies": {
61
+ "@types/node": "^20.14.10",
62
+ "concurrently": "^9.1.0",
63
+ "tsx": "^4.16.2",
64
+ "typescript": "^5.5.4"
65
+ }
66
+ }
Binary file
Binary file