Commit fe5b58e
committed
feat(core,sdk,webapp): version skew protection for chat.agent sessions
A chat session now carries an external deployment id, so every run it
schedules lands on the deployment that matched the app build that
started the conversation: the first run, each continuation after an idle
suspend, and each recovery after a crash.
Public SDK surface:
- `triggerConfig.externalDeploymentId`, on every entry point that starts
a session (`sessions.start`, `chat.createStartSessionAction`,
`chat.headStart`, `chat.handover`, `AgentChat`). Normally omitted: it
is discovered wherever the session is started, with the same
precedence `trigger()` uses. `null` opts one chat out.
- `pendingVersion` on the session-create and `.in/append` responses, on
`ChatStartSessionResult` and on `StartSessionResult`, plus a new
`run-pending-version` transport event, so a chat waiting on a
deployment that is still building can say so instead of appearing to
stall.
- `chat.requestUpgrade({ externalDeploymentId })`. Called without a
target it now clears the session's pin, which is what makes upgrading
away from a pinned version possible at all, and the cleared pin is
persisted so the next continuation cannot bounce back.
- `SessionTriggerConfigInput` and `CreateSessionInput`, the caller-facing
forms of the trigger config and the create body.
Parking is the right failure mode here, and an improvement on
`lockToVersion`, which throws on session create and is swallowed on the
append path, leaving the chat hung with no run at all. `PENDING_VERSION`
is non-final, so a parked run is reused rather than re-triggered and
appended messages stay durable until the deployment lands.
`lockToVersion` is deliberately untouched: it still wins where both are
set, and `requestUpgrade()` still cannot escape it.1 parent 4c16387 commit fe5b58e
24 files changed
Lines changed: 1379 additions & 71 deletions
File tree
- .changeset
- apps/webapp
- app
- routes
- services/realtime
- test
- docs
- ai-chat
- patterns
- deployment
- packages
- core/src/v3/schemas
- trigger-sdk/src/v3
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| 249 | + | |
249 | 250 | | |
250 | 251 | | |
251 | 252 | | |
| |||
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
240 | 247 | | |
241 | 248 | | |
242 | 249 | | |
| |||
Lines changed: 69 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
123 | 125 | | |
124 | 126 | | |
125 | 127 | | |
126 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
127 | 133 | | |
128 | 134 | | |
129 | 135 | | |
| |||
210 | 216 | | |
211 | 217 | | |
212 | 218 | | |
213 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
214 | 224 | | |
215 | 225 | | |
216 | 226 | | |
| |||
255 | 265 | | |
256 | 266 | | |
257 | 267 | | |
258 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
259 | 273 | | |
260 | 274 | | |
261 | 275 | | |
| |||
272 | 286 | | |
273 | 287 | | |
274 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
275 | 307 | | |
276 | 308 | | |
277 | 309 | | |
| |||
288 | 320 | | |
289 | 321 | | |
290 | 322 | | |
291 | | - | |
| 323 | + | |
292 | 324 | | |
293 | 325 | | |
294 | 326 | | |
| |||
302 | 334 | | |
303 | 335 | | |
304 | 336 | | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
| 337 | + | |
314 | 338 | | |
315 | 339 | | |
316 | 340 | | |
| |||
329 | 353 | | |
330 | 354 | | |
331 | 355 | | |
332 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
333 | 361 | | |
334 | 362 | | |
335 | 363 | | |
| |||
359 | 387 | | |
360 | 388 | | |
361 | 389 | | |
| 390 | + | |
| 391 | + | |
362 | 392 | | |
363 | 393 | | |
364 | 394 | | |
| |||
371 | 401 | | |
372 | 402 | | |
373 | 403 | | |
| 404 | + | |
| 405 | + | |
374 | 406 | | |
375 | 407 | | |
376 | 408 | | |
| |||
413 | 445 | | |
414 | 446 | | |
415 | 447 | | |
416 | | - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
417 | 457 | | |
418 | 458 | | |
419 | 459 | | |
| |||
430 | 470 | | |
431 | 471 | | |
432 | 472 | | |
| 473 | + | |
433 | 474 | | |
434 | 475 | | |
435 | 476 | | |
| |||
446 | 487 | | |
447 | 488 | | |
448 | 489 | | |
449 | | - | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
450 | 495 | | |
451 | 496 | | |
452 | 497 | | |
| |||
480 | 525 | | |
481 | 526 | | |
482 | 527 | | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
483 | 534 | | |
484 | 535 | | |
485 | 536 | | |
| 537 | + | |
486 | 538 | | |
487 | 539 | | |
488 | 540 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
351 | | - | |
| 351 | + | |
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
| 426 | + | |
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
| |||
0 commit comments