sygnal 6.2.0 → 6.3.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 (76) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +3 -1
  3. package/dist/ai.cjs.js +36 -0
  4. package/dist/ai.cjs.js.map +1 -1
  5. package/dist/ai.esm.js +1 -1
  6. package/dist/astro/server.cjs.js +3 -3
  7. package/dist/astro/server.cjs.js.map +1 -1
  8. package/dist/astro/server.mjs +3 -3
  9. package/dist/astro/server.mjs.map +1 -1
  10. package/dist/diagnostics.cjs.js +164 -3
  11. package/dist/diagnostics.cjs.js.map +1 -1
  12. package/dist/diagnostics.esm.js +164 -3
  13. package/dist/diagnostics.esm.js.map +1 -1
  14. package/dist/guide/agent.md +7 -1
  15. package/dist/guide/ai-cards.md +319 -0
  16. package/dist/guide/ai-chat.md +4 -0
  17. package/dist/guide/ai-compose.md +881 -0
  18. package/dist/guide/ai-decisions.md +16 -0
  19. package/dist/guide/http.md +1 -0
  20. package/dist/index.cjs.js +5695 -347
  21. package/dist/index.cjs.js.map +1 -1
  22. package/dist/index.d.ts +638 -8
  23. package/dist/index.esm.js +5685 -347
  24. package/dist/index.esm.js.map +1 -1
  25. package/dist/sygnal.min.js +1 -1
  26. package/dist/sygnal.min.js.map +1 -1
  27. package/dist/vike/config/package.json +1 -1
  28. package/dist/vike/onRenderClient.cjs.js +3 -2
  29. package/dist/vike/onRenderClient.cjs.js.map +1 -1
  30. package/dist/vike/onRenderClient.mjs +3 -2
  31. package/dist/vike/onRenderClient.mjs.map +1 -1
  32. package/llms.txt +6 -4
  33. package/package.json +2 -1
  34. package/src/ai.d.ts +642 -7
  35. package/src/ai.ts +6 -0
  36. package/src/collection.ts +2 -1
  37. package/src/core/instance.ts +6 -3
  38. package/src/core/markers/lazy.ts +7 -3
  39. package/src/core/markers/portal.ts +5 -2
  40. package/src/core/markers/suspense.ts +3 -2
  41. package/src/core/markers/transition.ts +6 -3
  42. package/src/core/registry.ts +9 -5
  43. package/src/cycle/dom/IsolateModule.ts +25 -22
  44. package/src/extra/ai/chat/behavior.ts +354 -81
  45. package/src/extra/ai/chat/driver.ts +7 -4
  46. package/src/extra/ai/compose/agent.ts +55 -0
  47. package/src/extra/ai/compose/ask.ts +147 -0
  48. package/src/extra/ai/compose/behavior.ts +183 -0
  49. package/src/extra/ai/compose/catalog.ts +211 -0
  50. package/src/extra/ai/compose/composed.ts +61 -0
  51. package/src/extra/ai/compose/decisions.ts +1649 -0
  52. package/src/extra/ai/compose/diag.ts +33 -0
  53. package/src/extra/ai/compose/index.ts +23 -0
  54. package/src/extra/ai/compose/layout.ts +441 -0
  55. package/src/extra/ai/compose/llm.ts +1120 -0
  56. package/src/extra/ai/compose/render.ts +159 -0
  57. package/src/extra/ai/compose/testing.ts +71 -0
  58. package/src/extra/ai/compose/types.ts +159 -0
  59. package/src/extra/ai/decide.ts +97 -1
  60. package/src/extra/ai/index.ts +6 -1
  61. package/src/extra/diagnostics/checks/next.ts +86 -2
  62. package/src/extra/diagnostics/codes.ts +54 -0
  63. package/src/extra/fetchDriver.ts +58 -27
  64. package/src/extra/lens.ts +15 -0
  65. package/src/extra/ssr.ts +3 -3
  66. package/src/extra/testing.ts +2 -0
  67. package/src/extra/widget.ts +3 -3
  68. package/src/index.d.ts +41 -0
  69. package/src/index.ts +8 -0
  70. package/src/lazy.ts +3 -2
  71. package/src/portal.ts +5 -2
  72. package/src/pragma/index.ts +2 -1
  73. package/src/suspense.ts +5 -2
  74. package/src/switchable.ts +2 -1
  75. package/src/transition.ts +5 -2
  76. package/src/vike/onRenderClient.ts +3 -2
@@ -248,6 +248,21 @@ Ticket.resources = {
248
248
 
249
249
  A `noul` question becomes a `predicate` whose instructions include the criteria. OpenAI may refuse a question: its answer is then `{ type: 'refusal', … }`, so check `answer.type` before reading `choice`. The type `Decision<Q, RefusalAnswer>` includes it.
250
250
 
251
+ ## Large question sets
252
+
253
+ Servers limit what one request may ask: Ollama's `/v1/systemone` takes at most 64 questions, and each question's prompt (the `state` plus every question of the request) must fit the model's context, 8,192 tokens for `nimble`. `decide()` handles it, and your component still gets one reply:
254
+
255
+ - More than `maxQuestions` questions (default 64): the request goes as several requests of about even size, sent in parallel. Their replies arrive as one: `answers` merged by name, `usage` summed, `model` from the first.
256
+ - `maxPromptTokens`: the same split when the estimated prompt of one question passes it. The estimate runs high (on `nimble`, 1.13 to 1.30 times the count Ollama reports), and there is no default.
257
+ - A request the server rejects as too large is halved and sent again, at most 3 times deep. "Too large" means HTTP 400 or 413 whose body mentions tokens, fields, context, a limit, or "too long", "too many" or "too large". Other errors arrive as before. A rejection costs one fast round trip (Ollama answers it in about 10 ms), so Jev's requests, which fit, go out exactly as before.
258
+ - `split: false` sends every request whole and never halves it.
259
+
260
+ ```js
261
+ decide({ model: 'nimble', url: 'http://localhost:11434/v1/systemone', state, questions, maxQuestions: 32 })
262
+ ```
263
+
264
+ The request keeps the whole decision in `json`, and its parts in `batch`, with `combine` and `split`. The [fetch driver](./http.md) reads those three keys, and any request can use them. Under `renderComponent` the fake answers a split request as one: `t.requests('HTTP')` lists it once, and `t.respond('HTTP', answers(questions, picks))` answers all its questions together.
265
+
251
266
  ## Keys stay on the server
252
267
 
253
268
  The browser never holds a provider key ([SYG670](https://sygnal.js.org/reference/errors/#syg670) refuses to send one to another origin). `decide()` posts to `/api/decide` on your own server by default, and that route adds the key. Keep it narrow, as for [chat](./ai-chat.md#shipping-it): fix the model, require a session, and limit the size of `state`, so the route can't be used as a free decision API.
@@ -326,5 +341,6 @@ It reads the actions from the components' [`agent` declarations](./agent.md#the-
326
341
 
327
342
  - [Agents](./agent.md): the `agent` static, the command bar and the in-app assistant
328
343
  - [AI Chat](./ai-chat.md): the chat driver, transports, and shipping an AI SDK route
344
+ - [Composing UI with a Model](./ai-compose.md): a decision model builds a page from your catalog of parts with `compose.decisions()`
329
345
  - [Resources and Caching](./resources.md): the rules a decision resource follows
330
346
  - [Support inbox](./recipes/ai-support-inbox.md): triage, sorting and escalation in a whole inbox
@@ -137,6 +137,7 @@ A request is an object (or a URL string, for a plain GET with no reply actions):
137
137
  | `updates` | — | After a 2xx reply, write it into this component's resources (and their cache entries): `updates: 'item'`, or `{ items: (list, reply) => newList }` ([Writing a reply into the cache](./resources.md#writing-a-reply-into-the-cache)) |
138
138
  | `retry` | driver's `retry` for GET/HEAD (0) | Retry network errors, 408, 429 and 5xx: a count or `{ count, delayMs, maxDelayMs, jitter }` ([Retries](./resources.md#retries)) |
139
139
  | `validate` | — | A Standard Schema the body must pass ([Validation](./resources.md#validation)) |
140
+ | `batch`, `combine`, `split` | — | One reply from several fetches: `batch` sends these requests in parallel instead (each inherits this request's fields; its own `json`, `body`, `parse` win), `combine(bodies, requests)` merges their parsed bodies into the reply, and `split(request, error)` returns the requests to try instead when one fails (at most 3 deep). `decide()` sets them for [large question sets](./ai-decisions.md#large-question-sets); the test fake answers such a request as one |
140
141
 
141
142
  Any other field is yours (an id, the query text): it isn't sent, and it comes back on the failure's `request`. A sink that returns `ABORT`, `null` or `undefined` sends nothing.
142
143