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.
- package/CHANGELOG.md +61 -0
- package/README.md +3 -1
- package/dist/ai.cjs.js +36 -0
- package/dist/ai.cjs.js.map +1 -1
- package/dist/ai.esm.js +1 -1
- package/dist/astro/server.cjs.js +3 -3
- package/dist/astro/server.cjs.js.map +1 -1
- package/dist/astro/server.mjs +3 -3
- package/dist/astro/server.mjs.map +1 -1
- package/dist/diagnostics.cjs.js +164 -3
- package/dist/diagnostics.cjs.js.map +1 -1
- package/dist/diagnostics.esm.js +164 -3
- package/dist/diagnostics.esm.js.map +1 -1
- package/dist/guide/agent.md +7 -1
- package/dist/guide/ai-cards.md +319 -0
- package/dist/guide/ai-chat.md +4 -0
- package/dist/guide/ai-compose.md +881 -0
- package/dist/guide/ai-decisions.md +16 -0
- package/dist/guide/http.md +1 -0
- package/dist/index.cjs.js +5695 -347
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +638 -8
- package/dist/index.esm.js +5685 -347
- package/dist/index.esm.js.map +1 -1
- package/dist/sygnal.min.js +1 -1
- package/dist/sygnal.min.js.map +1 -1
- package/dist/vike/config/package.json +1 -1
- package/dist/vike/onRenderClient.cjs.js +3 -2
- package/dist/vike/onRenderClient.cjs.js.map +1 -1
- package/dist/vike/onRenderClient.mjs +3 -2
- package/dist/vike/onRenderClient.mjs.map +1 -1
- package/llms.txt +6 -4
- package/package.json +2 -1
- package/src/ai.d.ts +642 -7
- package/src/ai.ts +6 -0
- package/src/collection.ts +2 -1
- package/src/core/instance.ts +6 -3
- package/src/core/markers/lazy.ts +7 -3
- package/src/core/markers/portal.ts +5 -2
- package/src/core/markers/suspense.ts +3 -2
- package/src/core/markers/transition.ts +6 -3
- package/src/core/registry.ts +9 -5
- package/src/cycle/dom/IsolateModule.ts +25 -22
- package/src/extra/ai/chat/behavior.ts +354 -81
- package/src/extra/ai/chat/driver.ts +7 -4
- package/src/extra/ai/compose/agent.ts +55 -0
- package/src/extra/ai/compose/ask.ts +147 -0
- package/src/extra/ai/compose/behavior.ts +183 -0
- package/src/extra/ai/compose/catalog.ts +211 -0
- package/src/extra/ai/compose/composed.ts +61 -0
- package/src/extra/ai/compose/decisions.ts +1649 -0
- package/src/extra/ai/compose/diag.ts +33 -0
- package/src/extra/ai/compose/index.ts +23 -0
- package/src/extra/ai/compose/layout.ts +441 -0
- package/src/extra/ai/compose/llm.ts +1120 -0
- package/src/extra/ai/compose/render.ts +159 -0
- package/src/extra/ai/compose/testing.ts +71 -0
- package/src/extra/ai/compose/types.ts +159 -0
- package/src/extra/ai/decide.ts +97 -1
- package/src/extra/ai/index.ts +6 -1
- package/src/extra/diagnostics/checks/next.ts +86 -2
- package/src/extra/diagnostics/codes.ts +54 -0
- package/src/extra/fetchDriver.ts +58 -27
- package/src/extra/lens.ts +15 -0
- package/src/extra/ssr.ts +3 -3
- package/src/extra/testing.ts +2 -0
- package/src/extra/widget.ts +3 -3
- package/src/index.d.ts +41 -0
- package/src/index.ts +8 -0
- package/src/lazy.ts +3 -2
- package/src/portal.ts +5 -2
- package/src/pragma/index.ts +2 -1
- package/src/suspense.ts +5 -2
- package/src/switchable.ts +2 -1
- package/src/transition.ts +5 -2
- package/src/vike/onRenderClient.ts +3 -2
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* PLAN-9 M-1 (D466): `<Composed catalog={catalog} from="page" />`, catalog.render as a JSX tag.
|
|
3
|
+
* A template rewrite (registry `pres`, as Portal and Transition; no host): in the owner's
|
|
4
|
+
* reconcile walk the marker is replaced by `catalog.render(slice, state, opts)` on the owner's own
|
|
5
|
+
* state, so the parts are the owner's children with the same identity as `{catalog.render(...)}`
|
|
6
|
+
* in its view (CHILD.select, lenses, keys and container views behave the same).
|
|
7
|
+
* - `from`: a state key ('page', the default) or a path (['boards', 0, 'page']); it is `at`.
|
|
8
|
+
* - `card={part}`: an `ask_user` tool part's card, as askCard() renders it (`from` is then the
|
|
9
|
+
* chat's key, default 'assistant'); nothing while the card has no layout.
|
|
10
|
+
* - `scope`, `frozen`, `answer`: as catalog.render's options.
|
|
11
|
+
* - Error containment: a container view or part `props()` that throws replaces only the
|
|
12
|
+
* composition with the owner's `onError` (SYG408), where `{catalog.render(...)}` in a view shows a
|
|
13
|
+
* `.compose-error` element (SYG406).
|
|
14
|
+
* - Misuse (SYG451, dev): no catalog, or `from` not naming a composition slice: nothing rendered.
|
|
15
|
+
* - Registration (G-751): the pragma calls `Composed.$reg` when a tag uses it, so an app that never
|
|
16
|
+
* renders `<Composed>` ships none of this. The marker reads the owner's state cell: a composition
|
|
17
|
+
* computed in the view needs catalog.render().
|
|
18
|
+
*/
|
|
19
|
+
import {pres} from '../../../core/registry'
|
|
20
|
+
import {renderLayout, cardArgs} from './render'
|
|
21
|
+
import {dev} from './diag'
|
|
22
|
+
|
|
23
|
+
const EMPTY = () => ({sel: undefined, data: {}, children: [], text: undefined, elm: undefined, key: undefined})
|
|
24
|
+
const misuse = (owner: any, msg: string) => (dev('SYG451', owner.def.name, '<Composed> ' + msg + ': nothing rendered', 'warn', owner, msg), EMPTY())
|
|
25
|
+
|
|
26
|
+
function rewrite(n: any, owner: any): any {
|
|
27
|
+
// a lowercase <composed> element (no marker function) is left as it is
|
|
28
|
+
if (!n.data?.m) return n
|
|
29
|
+
const {catalog, from, card, scope, frozen, answer} = n.data.props || {}
|
|
30
|
+
if (typeof catalog?.render != 'function') return misuse(owner, 'has no catalog')
|
|
31
|
+
const state = owner.cell.get()
|
|
32
|
+
let slice: any, opts: any
|
|
33
|
+
if (card !== undefined) {
|
|
34
|
+
if (!card || typeof card != 'object' || !card.toolCallId) return misuse(owner, 'card is not a tool part')
|
|
35
|
+
const c = cardArgs(state, card, from)
|
|
36
|
+
if (!c) return EMPTY()
|
|
37
|
+
;[slice, opts] = c
|
|
38
|
+
} else {
|
|
39
|
+
const at = Array.isArray(from) ? from : [from ?? 'page']
|
|
40
|
+
slice = at.reduce((x: any, k: any) => x?.[k], state)
|
|
41
|
+
if (!slice || typeof slice != 'object' || !('layout' in slice || 'preview' in slice)) {
|
|
42
|
+
return misuse(owner, `from=${JSON.stringify(from ?? 'page')} is not a composition`)
|
|
43
|
+
}
|
|
44
|
+
opts = {at}
|
|
45
|
+
}
|
|
46
|
+
if (scope !== undefined) opts.scope = scope
|
|
47
|
+
if (frozen !== undefined) opts.frozen = frozen
|
|
48
|
+
if (answer !== undefined) opts.answer = answer
|
|
49
|
+
try { return renderLayout(catalog, slice, state, opts, false) || EMPTY() }
|
|
50
|
+
catch (e) { return owner.failed(e).outv }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const reg = () => { pres.composed = rewrite }
|
|
54
|
+
|
|
55
|
+
/** `<Composed catalog={catalog} from="page" />`: the composition's parts as the owner's children */
|
|
56
|
+
export function Composed(_props: any): any {
|
|
57
|
+
// never called: the pragma makes a `composed` marker vnode (preventInstantiation)
|
|
58
|
+
}
|
|
59
|
+
(Composed as any).componentName = 'composed';
|
|
60
|
+
(Composed as any).preventInstantiation = true;
|
|
61
|
+
(Composed as any).$reg = reg;
|