@deepagents/elements 7.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.
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # @deepagents/elements
2
+
3
+ Platform-neutral interactive element catalogs for DeepAgents runtimes and
4
+ renderers.
5
+
6
+ Use this package when a model may write inline HTML-style tags that a host turns
7
+ into interactive UI. The package owns the serializable contract: element names,
8
+ allowed attributes, validation, descriptor serialization, context fragments, and
9
+ stream chunking that keeps an element tag together while text streams.
10
+
11
+ React component registration lives in `@deepagents/react-genai`; this package
12
+ does not ship renderer-specific components.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @deepagents/elements
18
+ ```
19
+
20
+ ## Define a catalog
21
+
22
+ ```typescript
23
+ import { defineElements } from '@deepagents/elements';
24
+
25
+ const elements = defineElements([
26
+ {
27
+ name: 'followup',
28
+ allowedAttributes: ['question'],
29
+ description: 'Suggest a follow-up question',
30
+ },
31
+ ]);
32
+ ```
33
+
34
+ Element names and attributes must use kebab-case. Reserved DOM-clobbering
35
+ attributes such as `id`, `name`, `aria-describedby`, and `aria-labelledby` are
36
+ rejected at definition time because markdown sanitizers rewrite them before the
37
+ component can receive props.
38
+
39
+ ## Add elements to context
40
+
41
+ ```typescript
42
+ import {
43
+ elementsFragment,
44
+ elementsStreamTransform,
45
+ } from '@deepagents/elements/context';
46
+
47
+ context.set(elementsFragment(elements));
48
+
49
+ const stream = await chat(agent, {
50
+ transform: [elementsStreamTransform],
51
+ });
52
+ ```
53
+
54
+ `elementsFragment()` advertises the catalog as structured context and stores a
55
+ descriptor snapshot on fragment metadata for host readback.
56
+
57
+ `elementsStreamTransform` buffers an HTML-style element until its root tag is
58
+ complete, so clients do not render partial custom tags during streaming.
59
+
60
+ ## React hosts
61
+
62
+ React hosts can define renderer-backed elements through
63
+ `@deepagents/react-genai`, which re-exports `defineElements` and adds the
64
+ `GenAIInteractiveElement` type:
65
+
66
+ ```typescript
67
+ import {
68
+ type GenAIInteractiveElement,
69
+ defineElements,
70
+ } from '@deepagents/react-genai';
71
+
72
+ const elements = defineElements<GenAIInteractiveElement>([
73
+ {
74
+ name: 'followup',
75
+ allowedAttributes: ['question'],
76
+ description: 'Suggest a follow-up question',
77
+ component: FollowupQuestion,
78
+ },
79
+ ]);
80
+ ```
@@ -0,0 +1,23 @@
1
+ import type { ContextFragment } from '@deepagents/context';
2
+ import type { ElementDescriptor } from '../lib/types.ts';
3
+ /**
4
+ * Create a context fragment advertising the interactive-element catalog to
5
+ * the model.
6
+ *
7
+ * Built from structured child fragments (like the skills fragment) rather
8
+ * than a pre-formatted XML string: the XmlRenderer HTML-escapes string data,
9
+ * so a pre-rendered blob would reach the model as `&lt;element&gt;` entities
10
+ * instead of real tags.
11
+ *
12
+ * The descriptor snapshot rides on `metadata` for programmatic readback; it
13
+ * is not rendered.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * context.set(elementsFragment([
18
+ * { name: 'followup', allowedAttributes: ['question'] },
19
+ * ]));
20
+ * ```
21
+ */
22
+ export declare function elementsFragment(descriptors: ElementDescriptor[]): ContextFragment;
23
+ //# sourceMappingURL=fragment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragment.d.ts","sourceRoot":"","sources":["../../src/context/fragment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,iBAAiB,EAAE,GAC/B,eAAe,CA0BjB"}
@@ -0,0 +1,3 @@
1
+ export * from './fragment.ts';
2
+ export * from './transform.ts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,111 @@
1
+ // packages/elements/src/context/fragment.ts
2
+ import dedent from "dedent";
3
+
4
+ // packages/elements/src/lib/serialize.ts
5
+ function toDescriptor(element) {
6
+ const { name, allowedAttributes, description } = element;
7
+ return { name, allowedAttributes, description };
8
+ }
9
+
10
+ // packages/elements/src/context/fragment.ts
11
+ function elementsFragment(descriptors) {
12
+ const snapshot = descriptors.map(toDescriptor);
13
+ if (snapshot.length === 0) {
14
+ return { name: "elements", data: [], metadata: { elements: snapshot } };
15
+ }
16
+ const items = snapshot.map((descriptor) => ({
17
+ name: "element",
18
+ data: {
19
+ name: descriptor.name,
20
+ ...descriptor.description ? { description: descriptor.description } : {},
21
+ "allowed-attributes": descriptor.allowedAttributes.join(", ")
22
+ }
23
+ }));
24
+ return {
25
+ name: "elements",
26
+ data: [
27
+ { name: "instructions", data: ELEMENTS_INSTRUCTIONS },
28
+ ...items
29
+ ],
30
+ metadata: { elements: snapshot }
31
+ };
32
+ }
33
+ var ELEMENTS_INSTRUCTIONS = dedent`The UI elements listed below can be rendered inline in your response: write one as an HTML-style tag directly in your prose (e.g. \`<element-name attribute="value" />\`) and the client renders it as an interactive component.
34
+
35
+ ### How to use elements
36
+ - Use an element only when the conversation matches its declared purpose.
37
+ - Only use element names from this list. Never invent elements.
38
+ - Only write attributes listed in that element's allowed-attributes. Never invent attributes.
39
+ - Keep the rest of your response as normal markdown; elements flow inline with the text.
40
+ `;
41
+
42
+ // packages/elements/src/context/transform.ts
43
+ import { smoothStream } from "ai";
44
+ import { Parser } from "htmlparser2";
45
+ function elementChunking() {
46
+ const WORD_REGEX = /\S+\s+/m;
47
+ return (buffer) => {
48
+ if (!buffer.startsWith("<")) {
49
+ const ltIndex = buffer.indexOf("<");
50
+ if (ltIndex > 0) {
51
+ const textBefore = buffer.slice(0, ltIndex);
52
+ const wordMatch2 = WORD_REGEX.exec(textBefore);
53
+ if (wordMatch2) {
54
+ return textBefore.slice(0, wordMatch2.index + wordMatch2[0].length);
55
+ }
56
+ return textBefore;
57
+ }
58
+ const wordMatch = WORD_REGEX.exec(buffer);
59
+ if (wordMatch) {
60
+ return buffer.slice(0, wordMatch.index + wordMatch[0].length);
61
+ }
62
+ return null;
63
+ }
64
+ if (!/^<[a-z]/i.test(buffer)) {
65
+ const wordMatch = WORD_REGEX.exec(buffer);
66
+ if (wordMatch) {
67
+ return buffer.slice(0, wordMatch.index + wordMatch[0].length);
68
+ }
69
+ return null;
70
+ }
71
+ if (/^<[a-z][a-z0-9-]*$/i.test(buffer)) {
72
+ return null;
73
+ }
74
+ let elementEnd = -1;
75
+ let depth = 0;
76
+ let rootTagName = null;
77
+ const parser = new Parser(
78
+ {
79
+ onopentag(name) {
80
+ if (rootTagName === null) {
81
+ rootTagName = name;
82
+ }
83
+ depth++;
84
+ },
85
+ onclosetag(name) {
86
+ depth--;
87
+ if (elementEnd === -1 && depth === 0 && name === rootTagName) {
88
+ elementEnd = parser.endIndex + 1;
89
+ }
90
+ }
91
+ },
92
+ {
93
+ recognizeSelfClosing: true,
94
+ lowerCaseTags: true
95
+ }
96
+ );
97
+ parser.write(buffer);
98
+ if (elementEnd !== -1) {
99
+ return buffer.slice(0, elementEnd);
100
+ }
101
+ return null;
102
+ };
103
+ }
104
+ var smoothFactory = smoothStream({ chunking: elementChunking() });
105
+ var elementsStreamTransform = (options) => smoothFactory({ tools: options.tools });
106
+ export {
107
+ elementChunking,
108
+ elementsFragment,
109
+ elementsStreamTransform
110
+ };
111
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/context/fragment.ts", "../../src/lib/serialize.ts", "../../src/context/transform.ts"],
4
+ "sourcesContent": ["import dedent from 'dedent';\n\nimport type { ContextFragment } from '@deepagents/context';\n\nimport { toDescriptor } from '../lib/serialize.ts';\nimport type { ElementDescriptor } from '../lib/types.ts';\n\n/**\n * Create a context fragment advertising the interactive-element catalog to\n * the model.\n *\n * Built from structured child fragments (like the skills fragment) rather\n * than a pre-formatted XML string: the XmlRenderer HTML-escapes string data,\n * so a pre-rendered blob would reach the model as `&lt;element&gt;` entities\n * instead of real tags.\n *\n * The descriptor snapshot rides on `metadata` for programmatic readback; it\n * is not rendered.\n *\n * @example\n * ```ts\n * context.set(elementsFragment([\n * { name: 'followup', allowedAttributes: ['question'] },\n * ]));\n * ```\n */\nexport function elementsFragment(\n descriptors: ElementDescriptor[],\n): ContextFragment {\n const snapshot = descriptors.map(toDescriptor);\n\n if (snapshot.length === 0) {\n return { name: 'elements', data: [], metadata: { elements: snapshot } };\n }\n\n const items: ContextFragment[] = snapshot.map((descriptor) => ({\n name: 'element',\n data: {\n name: descriptor.name,\n ...(descriptor.description\n ? { description: descriptor.description }\n : {}),\n 'allowed-attributes': descriptor.allowedAttributes.join(', '),\n },\n }));\n\n return {\n name: 'elements',\n data: [\n { name: 'instructions', data: ELEMENTS_INSTRUCTIONS } as ContextFragment,\n ...items,\n ],\n metadata: { elements: snapshot },\n };\n}\n\nconst ELEMENTS_INSTRUCTIONS = dedent`The UI elements listed below can be rendered inline in your response: write one as an HTML-style tag directly in your prose (e.g. \\`<element-name attribute=\"value\" />\\`) and the client renders it as an interactive component.\n\n### How to use elements\n- Use an element only when the conversation matches its declared purpose.\n- Only use element names from this list. Never invent elements.\n- Only write attributes listed in that element's allowed-attributes. Never invent attributes.\n- Keep the rest of your response as normal markdown; elements flow inline with the text.\n`;\n", "import { type ElementDescriptor, findDuplicateName } from './types.ts';\n\nexport function toDescriptor<T extends ElementDescriptor>(\n element: T,\n): ElementDescriptor {\n const { name, allowedAttributes, description } = element;\n return { name, allowedAttributes, description };\n}\n\n/**\n * Base-wins merging: an extra whose name collides with a base element is\n * dropped, so a platform's defaults cannot be hijacked by app extras.\n * Duplicate names WITHIN extras throw \u2014 silently keeping either copy would\n * make the prompt catalog and the render registry disagree.\n */\nexport function mergeElements<T extends ElementDescriptor>(\n base: T[],\n extras: T[] | undefined,\n): T[] {\n if (!extras || extras.length === 0) return base;\n const duplicate = findDuplicateName(extras);\n if (duplicate !== undefined) {\n throw new Error(\n `Duplicate extra element <${duplicate}>: a catalog must map each tag to exactly one element.`,\n );\n }\n const baseNames = new Set(base.map((el) => el.name));\n const additions = extras.filter((el) => !baseNames.has(el.name));\n return [...base, ...additions];\n}\n\nfunction escapeXmlAttribute(value: string): string {\n return value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;');\n}\n\nexport function formatElementsCatalog(elements: ElementDescriptor[]): string {\n if (elements.length === 0) return '';\n\n const items = elements\n .map((el) => {\n const description = el.description\n ? ` description=\"${escapeXmlAttribute(el.description)}\"`\n : '';\n const attrs = el.allowedAttributes.map(escapeXmlAttribute).join(', ');\n return `<element name=\"${escapeXmlAttribute(el.name)}\"${description}>\\n <allowed-attributes>${attrs}</allowed-attributes>\\n</element>`;\n })\n .join('\\n');\n\n return `<elements>\nThe following UI components are available to render inline in your response.\nUse them only when the user's question matches their declared purpose. Never\ninvent attributes outside the listed allowedAttributes for each element.\n\n${items}\n</elements>`;\n}\n", "import { type StreamTextTransform, type ToolSet, smoothStream } from 'ai';\nimport { Parser } from 'htmlparser2';\n\n/**\n * A `smoothStream` chunking detector that buffers an HTML-style element\n * until its root tag closes, so no partial custom tag ever reaches the\n * client mid-stream.\n *\n * - Regular text: chunks word-by-word (same as smoothStream's default)\n * - Elements: held until complete, including self-closing (`<kpi />`)\n * - Closing tags inside HTML comments are ignored\n * - Content passes through verbatim: `smoothStream` requires every detected\n * chunk to be a prefix of its buffer, so rewriting (e.g. unescaping a\n * literal `\\n` in an attribute) belongs to the rendering client\n *\n * Boundary control only applies while consecutive text deltas stream:\n * `smoothStream` force-flushes its buffer when a non-text chunk arrives, so\n * an element left unclosed at the end of a text part is emitted raw.\n */\nexport function elementChunking(): (buffer: string) => string | null {\n const WORD_REGEX = /\\S+\\s+/m;\n\n return (buffer: string): string | null => {\n if (!buffer.startsWith('<')) {\n const ltIndex = buffer.indexOf('<');\n if (ltIndex > 0) {\n const textBefore = buffer.slice(0, ltIndex);\n const wordMatch = WORD_REGEX.exec(textBefore);\n if (wordMatch) {\n return textBefore.slice(0, wordMatch.index + wordMatch[0].length);\n }\n return textBefore;\n }\n const wordMatch = WORD_REGEX.exec(buffer);\n if (wordMatch) {\n return buffer.slice(0, wordMatch.index + wordMatch[0].length);\n }\n return null;\n }\n\n // A `<` not opening a tag (e.g. `< ` or `<123`) is plain text\n if (!/^<[a-z]/i.test(buffer)) {\n const wordMatch = WORD_REGEX.exec(buffer);\n if (wordMatch) {\n return buffer.slice(0, wordMatch.index + wordMatch[0].length);\n }\n return null;\n }\n\n // `<bar` could still become `<bar-chart`; wait for the name to finish\n if (/^<[a-z][a-z0-9-]*$/i.test(buffer)) {\n return null;\n }\n\n let elementEnd = -1;\n let depth = 0;\n let rootTagName: string | null = null;\n\n const parser = new Parser(\n {\n onopentag(name) {\n if (rootTagName === null) {\n rootTagName = name;\n }\n depth++;\n },\n onclosetag(name) {\n depth--;\n // First completed root element wins: without the guard, a later\n // same-name sibling in the buffer would keep pushing elementEnd\n // forward, merging separate elements (and any text between them)\n // into one chunk\n if (elementEnd === -1 && depth === 0 && name === rootTagName) {\n elementEnd = parser.endIndex + 1;\n }\n },\n },\n {\n recognizeSelfClosing: true,\n lowerCaseTags: true,\n },\n );\n\n // No parser.end(): it would auto-close a dangling tag and report a\n // still-incomplete element as finished\n parser.write(buffer);\n\n if (elementEnd !== -1) {\n return buffer.slice(0, elementEnd);\n }\n\n return null;\n };\n}\n\n// smoothStream's return type is narrower than the exported StreamTextTransform\n// (no stopStream param), so we bridge by dropping stopStream before forwarding.\nconst smoothFactory = smoothStream({ chunking: elementChunking() });\n\n/**\n * Element-safe replacement for the default `smoothStream()` transform. Pass\n * it to `chat()`/`agent.stream()` whenever an element catalog is active:\n *\n * ```ts\n * const stream = await chat(agent, { transform: [elementsStreamTransform] });\n * ```\n */\nexport const elementsStreamTransform: StreamTextTransform<ToolSet> = (\n options,\n) => smoothFactory({ tools: options.tools });\n"],
5
+ "mappings": ";AAAA,OAAO,YAAY;;;ACEZ,SAAS,aACd,SACmB;AACnB,QAAM,EAAE,MAAM,mBAAmB,YAAY,IAAI;AACjD,SAAO,EAAE,MAAM,mBAAmB,YAAY;AAChD;;;ADmBO,SAAS,iBACd,aACiB;AACjB,QAAM,WAAW,YAAY,IAAI,YAAY;AAE7C,MAAI,SAAS,WAAW,GAAG;AACzB,WAAO,EAAE,MAAM,YAAY,MAAM,CAAC,GAAG,UAAU,EAAE,UAAU,SAAS,EAAE;AAAA,EACxE;AAEA,QAAM,QAA2B,SAAS,IAAI,CAAC,gBAAgB;AAAA,IAC7D,MAAM;AAAA,IACN,MAAM;AAAA,MACJ,MAAM,WAAW;AAAA,MACjB,GAAI,WAAW,cACX,EAAE,aAAa,WAAW,YAAY,IACtC,CAAC;AAAA,MACL,sBAAsB,WAAW,kBAAkB,KAAK,IAAI;AAAA,IAC9D;AAAA,EACF,EAAE;AAEF,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,MACJ,EAAE,MAAM,gBAAgB,MAAM,sBAAsB;AAAA,MACpD,GAAG;AAAA,IACL;AAAA,IACA,UAAU,EAAE,UAAU,SAAS;AAAA,EACjC;AACF;AAEA,IAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AExD9B,SAAiD,oBAAoB;AACrE,SAAS,cAAc;AAkBhB,SAAS,kBAAqD;AACnE,QAAM,aAAa;AAEnB,SAAO,CAAC,WAAkC;AACxC,QAAI,CAAC,OAAO,WAAW,GAAG,GAAG;AAC3B,YAAM,UAAU,OAAO,QAAQ,GAAG;AAClC,UAAI,UAAU,GAAG;AACf,cAAM,aAAa,OAAO,MAAM,GAAG,OAAO;AAC1C,cAAMA,aAAY,WAAW,KAAK,UAAU;AAC5C,YAAIA,YAAW;AACb,iBAAO,WAAW,MAAM,GAAGA,WAAU,QAAQA,WAAU,CAAC,EAAE,MAAM;AAAA,QAClE;AACA,eAAO;AAAA,MACT;AACA,YAAM,YAAY,WAAW,KAAK,MAAM;AACxC,UAAI,WAAW;AACb,eAAO,OAAO,MAAM,GAAG,UAAU,QAAQ,UAAU,CAAC,EAAE,MAAM;AAAA,MAC9D;AACA,aAAO;AAAA,IACT;AAGA,QAAI,CAAC,WAAW,KAAK,MAAM,GAAG;AAC5B,YAAM,YAAY,WAAW,KAAK,MAAM;AACxC,UAAI,WAAW;AACb,eAAO,OAAO,MAAM,GAAG,UAAU,QAAQ,UAAU,CAAC,EAAE,MAAM;AAAA,MAC9D;AACA,aAAO;AAAA,IACT;AAGA,QAAI,sBAAsB,KAAK,MAAM,GAAG;AACtC,aAAO;AAAA,IACT;AAEA,QAAI,aAAa;AACjB,QAAI,QAAQ;AACZ,QAAI,cAA6B;AAEjC,UAAM,SAAS,IAAI;AAAA,MACjB;AAAA,QACE,UAAU,MAAM;AACd,cAAI,gBAAgB,MAAM;AACxB,0BAAc;AAAA,UAChB;AACA;AAAA,QACF;AAAA,QACA,WAAW,MAAM;AACf;AAKA,cAAI,eAAe,MAAM,UAAU,KAAK,SAAS,aAAa;AAC5D,yBAAa,OAAO,WAAW;AAAA,UACjC;AAAA,QACF;AAAA,MACF;AAAA,MACA;AAAA,QACE,sBAAsB;AAAA,QACtB,eAAe;AAAA,MACjB;AAAA,IACF;AAIA,WAAO,MAAM,MAAM;AAEnB,QAAI,eAAe,IAAI;AACrB,aAAO,OAAO,MAAM,GAAG,UAAU;AAAA,IACnC;AAEA,WAAO;AAAA,EACT;AACF;AAIA,IAAM,gBAAgB,aAAa,EAAE,UAAU,gBAAgB,EAAE,CAAC;AAU3D,IAAM,0BAAwD,CACnE,YACG,cAAc,EAAE,OAAO,QAAQ,MAAM,CAAC;",
6
+ "names": ["wordMatch"]
7
+ }
@@ -0,0 +1,28 @@
1
+ import { type StreamTextTransform, type ToolSet } from 'ai';
2
+ /**
3
+ * A `smoothStream` chunking detector that buffers an HTML-style element
4
+ * until its root tag closes, so no partial custom tag ever reaches the
5
+ * client mid-stream.
6
+ *
7
+ * - Regular text: chunks word-by-word (same as smoothStream's default)
8
+ * - Elements: held until complete, including self-closing (`<kpi />`)
9
+ * - Closing tags inside HTML comments are ignored
10
+ * - Content passes through verbatim: `smoothStream` requires every detected
11
+ * chunk to be a prefix of its buffer, so rewriting (e.g. unescaping a
12
+ * literal `\n` in an attribute) belongs to the rendering client
13
+ *
14
+ * Boundary control only applies while consecutive text deltas stream:
15
+ * `smoothStream` force-flushes its buffer when a non-text chunk arrives, so
16
+ * an element left unclosed at the end of a text part is emitted raw.
17
+ */
18
+ export declare function elementChunking(): (buffer: string) => string | null;
19
+ /**
20
+ * Element-safe replacement for the default `smoothStream()` transform. Pass
21
+ * it to `chat()`/`agent.stream()` whenever an element catalog is active:
22
+ *
23
+ * ```ts
24
+ * const stream = await chat(agent, { transform: [elementsStreamTransform] });
25
+ * ```
26
+ */
27
+ export declare const elementsStreamTransform: StreamTextTransform<ToolSet>;
28
+ //# sourceMappingURL=transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/context/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,OAAO,EAAgB,MAAM,IAAI,CAAC;AAG1E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,IAAI,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CA0EnE;AAMD;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,EAAE,mBAAmB,CAAC,OAAO,CAErB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './lib/define.ts';
2
+ export * from './lib/schema.ts';
3
+ export * from './lib/serialize.ts';
4
+ export * from './lib/types.ts';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,121 @@
1
+ // packages/elements/src/lib/define.ts
2
+ import { z as z2 } from "zod";
3
+
4
+ // packages/elements/src/lib/schema.ts
5
+ import { z } from "zod";
6
+
7
+ // packages/elements/src/lib/types.ts
8
+ var RESERVED_ELEMENT_ATTRIBUTES = /* @__PURE__ */ new Set([
9
+ "name",
10
+ "id",
11
+ "aria-describedby",
12
+ "aria-labelledby"
13
+ ]);
14
+ function findDuplicateName(elements) {
15
+ const seen = /* @__PURE__ */ new Set();
16
+ for (const { name } of elements) {
17
+ if (seen.has(name)) return name;
18
+ seen.add(name);
19
+ }
20
+ return void 0;
21
+ }
22
+ function assertNoReservedAttributes(element) {
23
+ const reserved = element.allowedAttributes.filter(
24
+ (attribute) => RESERVED_ELEMENT_ATTRIBUTES.has(attribute)
25
+ );
26
+ if (reserved.length > 0) {
27
+ throw new Error(
28
+ `Interactive element <${element.name}> declares reserved attribute(s) ${reserved.join(", ")}. The markdown sanitizer rewrites these to "user-content-<value>" (DOM-clobbering protection), so the component would receive a mangled value. Use a domain attribute instead (e.g. "param").`
29
+ );
30
+ }
31
+ }
32
+
33
+ // packages/elements/src/lib/schema.ts
34
+ var kebabName = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
35
+ var attributeName = z.string().min(1).max(64).regex(kebabName).refine((attribute) => !RESERVED_ELEMENT_ATTRIBUTES.has(attribute), {
36
+ message: 'Attribute is reserved: the markdown sanitizer rewrites it to "user-content-<value>". Use a domain attribute instead (e.g. "param").'
37
+ });
38
+ var elementSchema = z.strictObject({
39
+ name: z.string().min(1).max(64).regex(kebabName),
40
+ description: z.string().max(512).optional(),
41
+ allowedAttributes: z.array(attributeName).max(20)
42
+ });
43
+ var elementsSchema = z.array(elementSchema).max(100).superRefine((elements, ctx) => {
44
+ const duplicate = findDuplicateName(elements);
45
+ if (duplicate !== void 0) {
46
+ ctx.addIssue({
47
+ code: "custom",
48
+ message: `Duplicate element name "${duplicate}": a catalog must map each tag to exactly one element.`
49
+ });
50
+ }
51
+ }).optional();
52
+
53
+ // packages/elements/src/lib/serialize.ts
54
+ function toDescriptor(element) {
55
+ const { name, allowedAttributes, description } = element;
56
+ return { name, allowedAttributes, description };
57
+ }
58
+ function mergeElements(base, extras) {
59
+ if (!extras || extras.length === 0) return base;
60
+ const duplicate = findDuplicateName(extras);
61
+ if (duplicate !== void 0) {
62
+ throw new Error(
63
+ `Duplicate extra element <${duplicate}>: a catalog must map each tag to exactly one element.`
64
+ );
65
+ }
66
+ const baseNames = new Set(base.map((el) => el.name));
67
+ const additions = extras.filter((el) => !baseNames.has(el.name));
68
+ return [...base, ...additions];
69
+ }
70
+ function escapeXmlAttribute(value) {
71
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
72
+ }
73
+ function formatElementsCatalog(elements) {
74
+ if (elements.length === 0) return "";
75
+ const items = elements.map((el) => {
76
+ const description = el.description ? ` description="${escapeXmlAttribute(el.description)}"` : "";
77
+ const attrs = el.allowedAttributes.map(escapeXmlAttribute).join(", ");
78
+ return `<element name="${escapeXmlAttribute(el.name)}"${description}>
79
+ <allowed-attributes>${attrs}</allowed-attributes>
80
+ </element>`;
81
+ }).join("\n");
82
+ return `<elements>
83
+ The following UI components are available to render inline in your response.
84
+ Use them only when the user's question matches their declared purpose. Never
85
+ invent attributes outside the listed allowedAttributes for each element.
86
+
87
+ ${items}
88
+ </elements>`;
89
+ }
90
+
91
+ // packages/elements/src/lib/define.ts
92
+ function defineElements(elements) {
93
+ for (const element of elements) {
94
+ const parsed = elementSchema.safeParse(toDescriptor(element));
95
+ if (!parsed.success) {
96
+ throw new Error(
97
+ `Interactive element <${element.name}> is invalid:
98
+ ${z2.prettifyError(parsed.error)}`
99
+ );
100
+ }
101
+ }
102
+ const duplicate = findDuplicateName(elements);
103
+ if (duplicate !== void 0) {
104
+ throw new Error(
105
+ `Duplicate element name <${duplicate}>: a catalog must map each tag to exactly one element.`
106
+ );
107
+ }
108
+ return [...elements];
109
+ }
110
+ export {
111
+ RESERVED_ELEMENT_ATTRIBUTES,
112
+ assertNoReservedAttributes,
113
+ defineElements,
114
+ elementSchema,
115
+ elementsSchema,
116
+ findDuplicateName,
117
+ formatElementsCatalog,
118
+ mergeElements,
119
+ toDescriptor
120
+ };
121
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lib/define.ts", "../src/lib/schema.ts", "../src/lib/types.ts", "../src/lib/serialize.ts"],
4
+ "sourcesContent": ["import { z } from 'zod';\n\nimport { elementSchema } from './schema.ts';\nimport { toDescriptor } from './serialize.ts';\nimport { type ElementDescriptor, findDuplicateName } from './types.ts';\n\n/**\n * Validate a local element registry at definition time, so a bad descriptor\n * fails where it is written \u2014 not later inside a prompt or a render pass.\n * Extra host fields (e.g. a React `component`) pass through untouched; only\n * the descriptor projection is validated.\n */\nexport function defineElements<T extends ElementDescriptor>(\n elements: readonly T[],\n): T[] {\n for (const element of elements) {\n const parsed = elementSchema.safeParse(toDescriptor(element));\n if (!parsed.success) {\n throw new Error(\n `Interactive element <${element.name}> is invalid:\\n${z.prettifyError(parsed.error)}`,\n );\n }\n }\n const duplicate = findDuplicateName(elements);\n if (duplicate !== undefined) {\n throw new Error(\n `Duplicate element name <${duplicate}>: a catalog must map each tag to exactly one element.`,\n );\n }\n return [...elements];\n}\n", "import { z } from 'zod';\n\nimport { RESERVED_ELEMENT_ATTRIBUTES, findDuplicateName } from './types.ts';\n\nconst kebabName = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;\n\nconst attributeName = z\n .string()\n .min(1)\n .max(64)\n .regex(kebabName)\n .refine((attribute) => !RESERVED_ELEMENT_ATTRIBUTES.has(attribute), {\n message:\n 'Attribute is reserved: the markdown sanitizer rewrites it to \"user-content-<value>\". Use a domain attribute instead (e.g. \"param\").',\n });\n\n/**\n * Strict on purpose: a descriptor crossing a trust boundary must carry data\n * only. Unknown keys \u2014 above all executable ones like `component` \u2014 are\n * rejected rather than stripped.\n */\nexport const elementSchema = z.strictObject({\n name: z.string().min(1).max(64).regex(kebabName),\n description: z.string().max(512).optional(),\n allowedAttributes: z.array(attributeName).max(20),\n});\n\nexport const elementsSchema = z\n .array(elementSchema)\n .max(100)\n .superRefine((elements, ctx) => {\n const duplicate = findDuplicateName(elements);\n if (duplicate !== undefined) {\n ctx.addIssue({\n code: 'custom',\n message: `Duplicate element name \"${duplicate}\": a catalog must map each tag to exactly one element.`,\n });\n }\n })\n .optional();\n", "/**\n * The platform-neutral, serializable description of one interactive element:\n * the vocabulary a model may write as inline HTML-style tags. Rendering\n * concerns (e.g. a React component) belong to host adapters that extend this\n * shape \u2014 never to this package.\n */\nexport interface ElementDescriptor {\n name: string;\n /**\n * HTML attributes the model may write on this element. Must not contain\n * {@link RESERVED_ELEMENT_ATTRIBUTES}: the markdown sanitizer rewrites\n * those to `user-content-<value>` (DOM-clobbering protection), so the\n * component would silently receive a mangled value. Use a domain attribute\n * instead \u2014 e.g. `param`, not `name`.\n */\n allowedAttributes: string[];\n description?: string;\n}\n\n/**\n * Attributes the markdown sanitizer clobber-prefixes with `user-content-`\n * before props reach the component. Interactive elements must not declare\n * them; {@link assertNoReservedAttributes} enforces this at registration.\n */\nexport const RESERVED_ELEMENT_ATTRIBUTES = new Set([\n 'name',\n 'id',\n 'aria-describedby',\n 'aria-labelledby',\n]);\n\nexport function findDuplicateName(\n elements: Iterable<Pick<ElementDescriptor, 'name'>>,\n): string | undefined {\n const seen = new Set<string>();\n for (const { name } of elements) {\n if (seen.has(name)) return name;\n seen.add(name);\n }\n return undefined;\n}\n\nexport function assertNoReservedAttributes(\n element: Pick<ElementDescriptor, 'name' | 'allowedAttributes'>,\n): void {\n const reserved = element.allowedAttributes.filter((attribute) =>\n RESERVED_ELEMENT_ATTRIBUTES.has(attribute),\n );\n if (reserved.length > 0) {\n throw new Error(\n `Interactive element <${element.name}> declares reserved attribute(s) ${reserved.join(', ')}. ` +\n `The markdown sanitizer rewrites these to \"user-content-<value>\" (DOM-clobbering protection), ` +\n `so the component would receive a mangled value. Use a domain attribute instead (e.g. \"param\").`,\n );\n }\n}\n", "import { type ElementDescriptor, findDuplicateName } from './types.ts';\n\nexport function toDescriptor<T extends ElementDescriptor>(\n element: T,\n): ElementDescriptor {\n const { name, allowedAttributes, description } = element;\n return { name, allowedAttributes, description };\n}\n\n/**\n * Base-wins merging: an extra whose name collides with a base element is\n * dropped, so a platform's defaults cannot be hijacked by app extras.\n * Duplicate names WITHIN extras throw \u2014 silently keeping either copy would\n * make the prompt catalog and the render registry disagree.\n */\nexport function mergeElements<T extends ElementDescriptor>(\n base: T[],\n extras: T[] | undefined,\n): T[] {\n if (!extras || extras.length === 0) return base;\n const duplicate = findDuplicateName(extras);\n if (duplicate !== undefined) {\n throw new Error(\n `Duplicate extra element <${duplicate}>: a catalog must map each tag to exactly one element.`,\n );\n }\n const baseNames = new Set(base.map((el) => el.name));\n const additions = extras.filter((el) => !baseNames.has(el.name));\n return [...base, ...additions];\n}\n\nfunction escapeXmlAttribute(value: string): string {\n return value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;');\n}\n\nexport function formatElementsCatalog(elements: ElementDescriptor[]): string {\n if (elements.length === 0) return '';\n\n const items = elements\n .map((el) => {\n const description = el.description\n ? ` description=\"${escapeXmlAttribute(el.description)}\"`\n : '';\n const attrs = el.allowedAttributes.map(escapeXmlAttribute).join(', ');\n return `<element name=\"${escapeXmlAttribute(el.name)}\"${description}>\\n <allowed-attributes>${attrs}</allowed-attributes>\\n</element>`;\n })\n .join('\\n');\n\n return `<elements>\nThe following UI components are available to render inline in your response.\nUse them only when the user's question matches their declared purpose. Never\ninvent attributes outside the listed allowedAttributes for each element.\n\n${items}\n</elements>`;\n}\n"],
5
+ "mappings": "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",
6
+ "names": ["z", "z"]
7
+ }
@@ -0,0 +1,9 @@
1
+ import { type ElementDescriptor } from './types.ts';
2
+ /**
3
+ * Validate a local element registry at definition time, so a bad descriptor
4
+ * fails where it is written — not later inside a prompt or a render pass.
5
+ * Extra host fields (e.g. a React `component`) pass through untouched; only
6
+ * the descriptor projection is validated.
7
+ */
8
+ export declare function defineElements<T extends ElementDescriptor>(elements: readonly T[]): T[];
9
+ //# sourceMappingURL=define.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../src/lib/define.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,YAAY,CAAC;AAEvE;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,iBAAiB,EACxD,QAAQ,EAAE,SAAS,CAAC,EAAE,GACrB,CAAC,EAAE,CAgBL"}
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Strict on purpose: a descriptor crossing a trust boundary must carry data
4
+ * only. Unknown keys — above all executable ones like `component` — are
5
+ * rejected rather than stripped.
6
+ */
7
+ export declare const elementSchema: z.ZodObject<{
8
+ name: z.ZodString;
9
+ description: z.ZodOptional<z.ZodString>;
10
+ allowedAttributes: z.ZodArray<z.ZodString>;
11
+ }, z.core.$strict>;
12
+ export declare const elementsSchema: z.ZodOptional<z.ZodArray<z.ZodObject<{
13
+ name: z.ZodString;
14
+ description: z.ZodOptional<z.ZodString>;
15
+ allowedAttributes: z.ZodArray<z.ZodString>;
16
+ }, z.core.$strict>>>;
17
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBxB;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;kBAIxB,CAAC;AAEH,eAAO,MAAM,cAAc;;;;oBAYd,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type ElementDescriptor } from './types.ts';
2
+ export declare function toDescriptor<T extends ElementDescriptor>(element: T): ElementDescriptor;
3
+ /**
4
+ * Base-wins merging: an extra whose name collides with a base element is
5
+ * dropped, so a platform's defaults cannot be hijacked by app extras.
6
+ * Duplicate names WITHIN extras throw — silently keeping either copy would
7
+ * make the prompt catalog and the render registry disagree.
8
+ */
9
+ export declare function mergeElements<T extends ElementDescriptor>(base: T[], extras: T[] | undefined): T[];
10
+ export declare function formatElementsCatalog(elements: ElementDescriptor[]): string;
11
+ //# sourceMappingURL=serialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/lib/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,YAAY,CAAC;AAEvE,wBAAgB,YAAY,CAAC,CAAC,SAAS,iBAAiB,EACtD,OAAO,EAAE,CAAC,GACT,iBAAiB,CAGnB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,iBAAiB,EACvD,IAAI,EAAE,CAAC,EAAE,EACT,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,GACtB,CAAC,EAAE,CAWL;AAUD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAoB3E"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The platform-neutral, serializable description of one interactive element:
3
+ * the vocabulary a model may write as inline HTML-style tags. Rendering
4
+ * concerns (e.g. a React component) belong to host adapters that extend this
5
+ * shape — never to this package.
6
+ */
7
+ export interface ElementDescriptor {
8
+ name: string;
9
+ /**
10
+ * HTML attributes the model may write on this element. Must not contain
11
+ * {@link RESERVED_ELEMENT_ATTRIBUTES}: the markdown sanitizer rewrites
12
+ * those to `user-content-<value>` (DOM-clobbering protection), so the
13
+ * component would silently receive a mangled value. Use a domain attribute
14
+ * instead — e.g. `param`, not `name`.
15
+ */
16
+ allowedAttributes: string[];
17
+ description?: string;
18
+ }
19
+ /**
20
+ * Attributes the markdown sanitizer clobber-prefixes with `user-content-`
21
+ * before props reach the component. Interactive elements must not declare
22
+ * them; {@link assertNoReservedAttributes} enforces this at registration.
23
+ */
24
+ export declare const RESERVED_ELEMENT_ATTRIBUTES: Set<string>;
25
+ export declare function findDuplicateName(elements: Iterable<Pick<ElementDescriptor, 'name'>>): string | undefined;
26
+ export declare function assertNoReservedAttributes(element: Pick<ElementDescriptor, 'name' | 'allowedAttributes'>): void;
27
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,aAKtC,CAAC;AAEH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,GAClD,MAAM,GAAG,SAAS,CAOpB;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,mBAAmB,CAAC,GAC7D,IAAI,CAWN"}
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@deepagents/elements",
3
+ "version": "7.0.0",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/JanuaryLabs/deepagents",
8
+ "directory": "packages/elements"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/JanuaryLabs/deepagents/issues"
12
+ },
13
+ "homepage": "https://github.com/JanuaryLabs/deepagents#readme",
14
+ "type": "module",
15
+ "nx": {
16
+ "targets": {
17
+ "test": {
18
+ "inputs": [
19
+ "default",
20
+ "^production"
21
+ ],
22
+ "outputs": [
23
+ "{workspaceRoot}/test-results/elements.xml"
24
+ ],
25
+ "options": {
26
+ "command": "node ../../tools/src/run-node-tests.ts ../../test-results/elements.xml"
27
+ }
28
+ }
29
+ }
30
+ },
31
+ "main": "./dist/index.js",
32
+ "module": "./dist/index.js",
33
+ "types": "./dist/index.d.ts",
34
+ "exports": {
35
+ "./package.json": "./package.json",
36
+ ".": {
37
+ "types": "./dist/index.d.ts",
38
+ "import": "./dist/index.js",
39
+ "default": "./dist/index.js"
40
+ },
41
+ "./context": {
42
+ "types": "./dist/context/index.d.ts",
43
+ "import": "./dist/context/index.js",
44
+ "default": "./dist/context/index.js"
45
+ }
46
+ },
47
+ "files": [
48
+ "dist",
49
+ "!dist/spec/**",
50
+ "!**/*.tsbuildinfo",
51
+ "!**/*.test.*"
52
+ ],
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "dependencies": {
57
+ "ai": "^7.0.85",
58
+ "dedent": "^1.7.2",
59
+ "htmlparser2": "^10.0.0",
60
+ "zod": "^4.4.3"
61
+ },
62
+ "peerDependencies": {
63
+ "@deepagents/context": "7.0.0"
64
+ },
65
+ "peerDependenciesMeta": {
66
+ "@deepagents/context": {
67
+ "optional": true
68
+ }
69
+ },
70
+ "devDependencies": {
71
+ "@deepagents/context": "7.0.0"
72
+ }
73
+ }