Commit 047e2c0
committed
openapi: stream compile + serve from content-addressed bindings (no re-parse)
The serve path (resolveOpenApiBackedTools, the 2nd OOM site) re-parsed the
whole spec on every tools/list. For the full Microsoft Graph spec (37MB /
16.5k ops) that rebuilt a ~300MB document tree and OOM'd the 128MB Workers
isolate even after the add-path parser swap.
Add a memory-safe compile + serve path that never re-parses:
- streamOperationBindings (extract.ts): two-pass streaming compile. Pass 1
plans tool paths from schema-free metadata (planToolPaths, extracted from
compileToolDefinitions); pass 2 builds invocation bindings in bounded
chunks, flushing each before the next so a huge spec's bindings are never
all co-resident with the parsed tree.
- Content-addressed defs blob (store.ts: putDefs/getDefs, keyed by specHash):
the normalized #/$defs schemas, built once per spec at add time and shared
across tenants. buildDefsJson serializes them one schema at a time so the
normalized tree never co-resides with the parsed document.
- Persist a resolved description per operation so the serve path rebuilds each
tool def from the binding alone.
- resolveOpenApiBackedTools fast path: getDefs(specHash) + listOperations +
toolDefFromStoredOperation, falling back to a spec re-parse for legacy rows
or a missing/corrupt blob.
- Route the openapi, microsoft (full-graph), and google add/update paths
through the streaming persist + putDefs.1 parent 395ba97 commit 047e2c0
10 files changed
Lines changed: 509 additions & 78 deletions
File tree
- packages/plugins
- google/src/sdk
- microsoft/src/sdk
- openapi/src/sdk
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
146 | 147 | | |
147 | 148 | | |
148 | 149 | | |
| |||
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
| 187 | + | |
186 | 188 | | |
187 | 189 | | |
188 | 190 | | |
| |||
298 | 300 | | |
299 | 301 | | |
300 | 302 | | |
301 | | - | |
| 303 | + | |
| 304 | + | |
302 | 305 | | |
303 | 306 | | |
304 | 307 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
341 | 342 | | |
342 | 343 | | |
343 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
344 | 384 | | |
345 | 385 | | |
346 | 386 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
22 | | - | |
| 22 | + | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| 34 | + | |
32 | 35 | | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| |||
122 | 126 | | |
123 | 127 | | |
124 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
125 | 151 | | |
126 | 152 | | |
127 | 153 | | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | 154 | | |
133 | 155 | | |
134 | 156 | | |
| |||
156 | 178 | | |
157 | 179 | | |
158 | 180 | | |
159 | | - | |
| 181 | + | |
160 | 182 | | |
161 | 183 | | |
162 | 184 | | |
| |||
167 | 189 | | |
168 | 190 | | |
169 | 191 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 192 | + | |
174 | 193 | | |
175 | 194 | | |
176 | 195 | | |
177 | | - | |
| 196 | + | |
178 | 197 | | |
179 | 198 | | |
180 | 199 | | |
| |||
199 | 218 | | |
200 | 219 | | |
201 | 220 | | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | 221 | | |
208 | 222 | | |
209 | | - | |
210 | 223 | | |
211 | 224 | | |
212 | 225 | | |
| |||
229 | 242 | | |
230 | 243 | | |
231 | 244 | | |
232 | | - | |
| 245 | + | |
233 | 246 | | |
234 | 247 | | |
235 | 248 | | |
236 | 249 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
| 250 | + | |
241 | 251 | | |
242 | 252 | | |
| 253 | + | |
243 | 254 | | |
244 | 255 | | |
245 | 256 | | |
| |||
257 | 268 | | |
258 | 269 | | |
259 | 270 | | |
260 | | - | |
| 271 | + | |
261 | 272 | | |
262 | 273 | | |
263 | 274 | | |
| |||
340 | 351 | | |
341 | 352 | | |
342 | 353 | | |
343 | | - | |
| 354 | + | |
| 355 | + | |
344 | 356 | | |
345 | 357 | | |
346 | 358 | | |
| |||
0 commit comments