@byline/ai 1.9.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 (248) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -0
  3. package/dist/@types.d.ts +103 -0
  4. package/dist/@types.d.ts.map +1 -0
  5. package/dist/@types.js +68 -0
  6. package/dist/@types.js.map +1 -0
  7. package/dist/config/ai-config.d.ts +76 -0
  8. package/dist/config/ai-config.d.ts.map +1 -0
  9. package/dist/config/ai-config.js +108 -0
  10. package/dist/config/ai-config.js.map +1 -0
  11. package/dist/config/ai-config.test.node.d.ts +9 -0
  12. package/dist/config/ai-config.test.node.d.ts.map +1 -0
  13. package/dist/config/ai-config.test.node.js +31 -0
  14. package/dist/config/ai-config.test.node.js.map +1 -0
  15. package/dist/config/ai-provider.d.ts +17 -0
  16. package/dist/config/ai-provider.d.ts.map +1 -0
  17. package/dist/config/ai-provider.js +32 -0
  18. package/dist/config/ai-provider.js.map +1 -0
  19. package/dist/execute.d.ts +15 -0
  20. package/dist/execute.d.ts.map +1 -0
  21. package/dist/execute.js +473 -0
  22. package/dist/execute.js.map +1 -0
  23. package/dist/generate.d.ts +64 -0
  24. package/dist/generate.d.ts.map +1 -0
  25. package/dist/generate.js +235 -0
  26. package/dist/generate.js.map +1 -0
  27. package/dist/index.d.ts +28 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +43 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/lexical-text-edits.d.ts +23 -0
  32. package/dist/lexical-text-edits.d.ts.map +1 -0
  33. package/dist/lexical-text-edits.js +62 -0
  34. package/dist/lexical-text-edits.js.map +1 -0
  35. package/dist/lib/logger.d.ts +10 -0
  36. package/dist/lib/logger.d.ts.map +1 -0
  37. package/dist/lib/logger.js +16 -0
  38. package/dist/lib/logger.js.map +1 -0
  39. package/dist/models/anthropic/anthropic-models.d.ts +14 -0
  40. package/dist/models/anthropic/anthropic-models.d.ts.map +1 -0
  41. package/dist/models/anthropic/anthropic-models.js +41 -0
  42. package/dist/models/anthropic/anthropic-models.js.map +1 -0
  43. package/dist/models/anthropic/anthropic.d.ts +9 -0
  44. package/dist/models/anthropic/anthropic.d.ts.map +1 -0
  45. package/dist/models/anthropic/anthropic.js +20 -0
  46. package/dist/models/anthropic/anthropic.js.map +1 -0
  47. package/dist/models/anthropic/generate-native.d.ts +59 -0
  48. package/dist/models/anthropic/generate-native.d.ts.map +1 -0
  49. package/dist/models/anthropic/generate-native.js +271 -0
  50. package/dist/models/anthropic/generate-native.js.map +1 -0
  51. package/dist/models/anthropic/generate-vercel.d.ts +59 -0
  52. package/dist/models/anthropic/generate-vercel.d.ts.map +1 -0
  53. package/dist/models/anthropic/generate-vercel.js +126 -0
  54. package/dist/models/anthropic/generate-vercel.js.map +1 -0
  55. package/dist/models/anthropic/generate.d.ts +16 -0
  56. package/dist/models/anthropic/generate.d.ts.map +1 -0
  57. package/dist/models/anthropic/generate.js +28 -0
  58. package/dist/models/anthropic/generate.js.map +1 -0
  59. package/dist/models/anthropic/generate.test.node.d.ts +9 -0
  60. package/dist/models/anthropic/generate.test.node.d.ts.map +1 -0
  61. package/dist/models/anthropic/generate.test.node.js +106 -0
  62. package/dist/models/anthropic/generate.test.node.js.map +1 -0
  63. package/dist/models/anthropic/patch-native.d.ts +33 -0
  64. package/dist/models/anthropic/patch-native.d.ts.map +1 -0
  65. package/dist/models/anthropic/patch-native.js +152 -0
  66. package/dist/models/anthropic/patch-native.js.map +1 -0
  67. package/dist/models/anthropic/patch-vercel.d.ts +33 -0
  68. package/dist/models/anthropic/patch-vercel.d.ts.map +1 -0
  69. package/dist/models/anthropic/patch-vercel.js +47 -0
  70. package/dist/models/anthropic/patch-vercel.js.map +1 -0
  71. package/dist/models/anthropic/patch.d.ts +12 -0
  72. package/dist/models/anthropic/patch.d.ts.map +1 -0
  73. package/dist/models/anthropic/patch.js +16 -0
  74. package/dist/models/anthropic/patch.js.map +1 -0
  75. package/dist/models/anthropic/patch.test.node.d.ts +9 -0
  76. package/dist/models/anthropic/patch.test.node.d.ts.map +1 -0
  77. package/dist/models/anthropic/patch.test.node.js +110 -0
  78. package/dist/models/anthropic/patch.test.node.js.map +1 -0
  79. package/dist/models/anthropic/schema.d.ts +212 -0
  80. package/dist/models/anthropic/schema.d.ts.map +1 -0
  81. package/dist/models/anthropic/schema.js +131 -0
  82. package/dist/models/anthropic/schema.js.map +1 -0
  83. package/dist/models/google/generate-native.d.ts +59 -0
  84. package/dist/models/google/generate-native.d.ts.map +1 -0
  85. package/dist/models/google/generate-native.js +244 -0
  86. package/dist/models/google/generate-native.js.map +1 -0
  87. package/dist/models/google/generate-vercel.d.ts +59 -0
  88. package/dist/models/google/generate-vercel.d.ts.map +1 -0
  89. package/dist/models/google/generate-vercel.js +133 -0
  90. package/dist/models/google/generate-vercel.js.map +1 -0
  91. package/dist/models/google/generate.d.ts +16 -0
  92. package/dist/models/google/generate.d.ts.map +1 -0
  93. package/dist/models/google/generate.js +28 -0
  94. package/dist/models/google/generate.js.map +1 -0
  95. package/dist/models/google/generate.test.node.d.ts +9 -0
  96. package/dist/models/google/generate.test.node.d.ts.map +1 -0
  97. package/dist/models/google/generate.test.node.js +106 -0
  98. package/dist/models/google/generate.test.node.js.map +1 -0
  99. package/dist/models/google/google-models.d.ts +14 -0
  100. package/dist/models/google/google-models.d.ts.map +1 -0
  101. package/dist/models/google/google-models.js +25 -0
  102. package/dist/models/google/google-models.js.map +1 -0
  103. package/dist/models/google/normalize-generated-doc.d.ts +10 -0
  104. package/dist/models/google/normalize-generated-doc.d.ts.map +1 -0
  105. package/dist/models/google/normalize-generated-doc.js +48 -0
  106. package/dist/models/google/normalize-generated-doc.js.map +1 -0
  107. package/dist/models/google/patch-native.d.ts +33 -0
  108. package/dist/models/google/patch-native.d.ts.map +1 -0
  109. package/dist/models/google/patch-native.js +164 -0
  110. package/dist/models/google/patch-native.js.map +1 -0
  111. package/dist/models/google/patch-vercel.d.ts +33 -0
  112. package/dist/models/google/patch-vercel.d.ts.map +1 -0
  113. package/dist/models/google/patch-vercel.js +49 -0
  114. package/dist/models/google/patch-vercel.js.map +1 -0
  115. package/dist/models/google/patch.d.ts +12 -0
  116. package/dist/models/google/patch.d.ts.map +1 -0
  117. package/dist/models/google/patch.js +16 -0
  118. package/dist/models/google/patch.js.map +1 -0
  119. package/dist/models/google/patch.test.node.d.ts +9 -0
  120. package/dist/models/google/patch.test.node.d.ts.map +1 -0
  121. package/dist/models/google/patch.test.node.js +110 -0
  122. package/dist/models/google/patch.test.node.js.map +1 -0
  123. package/dist/models/google/schema.d.ts +416 -0
  124. package/dist/models/google/schema.d.ts.map +1 -0
  125. package/dist/models/google/schema.js +254 -0
  126. package/dist/models/google/schema.js.map +1 -0
  127. package/dist/models/openai/generate-native.d.ts +65 -0
  128. package/dist/models/openai/generate-native.d.ts.map +1 -0
  129. package/dist/models/openai/generate-native.js +276 -0
  130. package/dist/models/openai/generate-native.js.map +1 -0
  131. package/dist/models/openai/generate-vercel.d.ts +59 -0
  132. package/dist/models/openai/generate-vercel.d.ts.map +1 -0
  133. package/dist/models/openai/generate-vercel.js +132 -0
  134. package/dist/models/openai/generate-vercel.js.map +1 -0
  135. package/dist/models/openai/generate.d.ts +16 -0
  136. package/dist/models/openai/generate.d.ts.map +1 -0
  137. package/dist/models/openai/generate.js +28 -0
  138. package/dist/models/openai/generate.js.map +1 -0
  139. package/dist/models/openai/generate.test.node.d.ts +9 -0
  140. package/dist/models/openai/generate.test.node.d.ts.map +1 -0
  141. package/dist/models/openai/generate.test.node.js +106 -0
  142. package/dist/models/openai/generate.test.node.js.map +1 -0
  143. package/dist/models/openai/openai-models.d.ts +14 -0
  144. package/dist/models/openai/openai-models.d.ts.map +1 -0
  145. package/dist/models/openai/openai-models.js +23 -0
  146. package/dist/models/openai/openai-models.js.map +1 -0
  147. package/dist/models/openai/patch-native.d.ts +33 -0
  148. package/dist/models/openai/patch-native.d.ts.map +1 -0
  149. package/dist/models/openai/patch-native.js +151 -0
  150. package/dist/models/openai/patch-native.js.map +1 -0
  151. package/dist/models/openai/patch-vercel.d.ts +33 -0
  152. package/dist/models/openai/patch-vercel.d.ts.map +1 -0
  153. package/dist/models/openai/patch-vercel.js +49 -0
  154. package/dist/models/openai/patch-vercel.js.map +1 -0
  155. package/dist/models/openai/patch.d.ts +12 -0
  156. package/dist/models/openai/patch.d.ts.map +1 -0
  157. package/dist/models/openai/patch.js +16 -0
  158. package/dist/models/openai/patch.js.map +1 -0
  159. package/dist/models/openai/patch.test.node.d.ts +9 -0
  160. package/dist/models/openai/patch.test.node.d.ts.map +1 -0
  161. package/dist/models/openai/patch.test.node.js +110 -0
  162. package/dist/models/openai/patch.test.node.js.map +1 -0
  163. package/dist/models/openai/schema.d.ts +460 -0
  164. package/dist/models/openai/schema.d.ts.map +1 -0
  165. package/dist/models/openai/schema.js +327 -0
  166. package/dist/models/openai/schema.js.map +1 -0
  167. package/dist/patch.d.ts +45 -0
  168. package/dist/patch.d.ts.map +1 -0
  169. package/dist/patch.js +138 -0
  170. package/dist/patch.js.map +1 -0
  171. package/dist/plugins/ai-plugin-base.d.ts +40 -0
  172. package/dist/plugins/ai-plugin-base.d.ts.map +1 -0
  173. package/dist/plugins/ai-plugin-base.js +218 -0
  174. package/dist/plugins/ai-plugin-base.js.map +1 -0
  175. package/dist/plugins/ai-plugin.css +181 -0
  176. package/dist/plugins/lexical/create-empty-editor-state.d.ts +32 -0
  177. package/dist/plugins/lexical/create-empty-editor-state.d.ts.map +1 -0
  178. package/dist/plugins/lexical/create-empty-editor-state.js +51 -0
  179. package/dist/plugins/lexical/create-empty-editor-state.js.map +1 -0
  180. package/dist/plugins/lexical/import-html.d.ts +10 -0
  181. package/dist/plugins/lexical/import-html.d.ts.map +1 -0
  182. package/dist/plugins/lexical/import-html.js +31 -0
  183. package/dist/plugins/lexical/import-html.js.map +1 -0
  184. package/dist/plugins/lexical/index.d.ts +9 -0
  185. package/dist/plugins/lexical/index.d.ts.map +1 -0
  186. package/dist/plugins/lexical/index.js +9 -0
  187. package/dist/plugins/lexical/index.js.map +1 -0
  188. package/dist/plugins/lexical/plugin.d.ts +11 -0
  189. package/dist/plugins/lexical/plugin.d.ts.map +1 -0
  190. package/dist/plugins/lexical/plugin.js +305 -0
  191. package/dist/plugins/lexical/plugin.js.map +1 -0
  192. package/dist/plugins/storage.d.ts +18 -0
  193. package/dist/plugins/storage.d.ts.map +1 -0
  194. package/dist/plugins/storage.js +57 -0
  195. package/dist/plugins/storage.js.map +1 -0
  196. package/dist/plugins/streaming-preview.d.ts +12 -0
  197. package/dist/plugins/streaming-preview.d.ts.map +1 -0
  198. package/dist/plugins/streaming-preview.js +24 -0
  199. package/dist/plugins/streaming-preview.js.map +1 -0
  200. package/dist/plugins/text/index.d.ts +9 -0
  201. package/dist/plugins/text/index.d.ts.map +1 -0
  202. package/dist/plugins/text/index.js +9 -0
  203. package/dist/plugins/text/index.js.map +1 -0
  204. package/dist/plugins/text/plugin.d.ts +18 -0
  205. package/dist/plugins/text/plugin.d.ts.map +1 -0
  206. package/dist/plugins/text/plugin.js +261 -0
  207. package/dist/plugins/text/plugin.js.map +1 -0
  208. package/dist/prompts.d.ts +30 -0
  209. package/dist/prompts.d.ts.map +1 -0
  210. package/dist/prompts.js +83 -0
  211. package/dist/prompts.js.map +1 -0
  212. package/dist/schemas/lexical-json-schema.d.ts +68 -0
  213. package/dist/schemas/lexical-json-schema.d.ts.map +1 -0
  214. package/dist/schemas/lexical-json-schema.js +434 -0
  215. package/dist/schemas/lexical-json-schema.js.map +1 -0
  216. package/dist/scripts/list-models.d.ts +9 -0
  217. package/dist/scripts/list-models.d.ts.map +1 -0
  218. package/dist/scripts/list-models.js +55 -0
  219. package/dist/scripts/list-models.js.map +1 -0
  220. package/dist/server.d.ts +25 -0
  221. package/dist/server.d.ts.map +1 -0
  222. package/dist/server.js +22 -0
  223. package/dist/server.js.map +1 -0
  224. package/dist/utils/convert-to-lexical.d.ts +62 -0
  225. package/dist/utils/convert-to-lexical.d.ts.map +1 -0
  226. package/dist/utils/convert-to-lexical.js +210 -0
  227. package/dist/utils/convert-to-lexical.js.map +1 -0
  228. package/dist/utils/create-empty-editor-state.d.ts +32 -0
  229. package/dist/utils/create-empty-editor-state.d.ts.map +1 -0
  230. package/dist/utils/create-empty-editor-state.js +51 -0
  231. package/dist/utils/create-empty-editor-state.js.map +1 -0
  232. package/dist/utils/has-text.d.ts +10 -0
  233. package/dist/utils/has-text.d.ts.map +1 -0
  234. package/dist/utils/has-text.js +35 -0
  235. package/dist/utils/has-text.js.map +1 -0
  236. package/dist/utils/has-text.test.d.ts +9 -0
  237. package/dist/utils/has-text.test.d.ts.map +1 -0
  238. package/dist/utils/has-text.test.js +69 -0
  239. package/dist/utils/has-text.test.js.map +1 -0
  240. package/dist/utils/is-object-schema.d.ts +17 -0
  241. package/dist/utils/is-object-schema.d.ts.map +1 -0
  242. package/dist/utils/is-object-schema.js +19 -0
  243. package/dist/utils/is-object-schema.js.map +1 -0
  244. package/dist/utils/lexical-text-edits.d.ts +23 -0
  245. package/dist/utils/lexical-text-edits.d.ts.map +1 -0
  246. package/dist/utils/lexical-text-edits.js +62 -0
  247. package/dist/utils/lexical-text-edits.js.map +1 -0
  248. package/package.json +111 -0
@@ -0,0 +1,434 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * Type guard to check if a value is an object schema.
10
+ * Inlined here to avoid circular dependency with utils.
11
+ */
12
+ function isObjectSchema(schema) {
13
+ return typeof schema === 'object' && schema !== null && !Array.isArray(schema);
14
+ }
15
+ export const documentSchema = {
16
+ type: 'object',
17
+ $schema: 'http://json-schema.org/draft-07/schema#',
18
+ additionalProperties: false,
19
+ definitions: {
20
+ LineBreakNode: {
21
+ type: 'object',
22
+ additionalProperties: false,
23
+ properties: {
24
+ type: { type: 'string', enum: ['linebreak'] },
25
+ version: { type: 'number' },
26
+ },
27
+ required: ['type', 'version'],
28
+ },
29
+ TabNode: {
30
+ type: 'object',
31
+ additionalProperties: false,
32
+ properties: {
33
+ type: { type: 'string', enum: ['tab'] },
34
+ version: { type: 'number' },
35
+ },
36
+ required: ['type', 'version'],
37
+ },
38
+ // Text Node (Leaf Node)
39
+ TextNode: {
40
+ type: 'object',
41
+ additionalProperties: false,
42
+ properties: {
43
+ type: { type: 'string', enum: ['text'] },
44
+ detail: {
45
+ type: 'number',
46
+ description: 'Text detail flags',
47
+ enum: [
48
+ 0, // No details
49
+ 1, // IS_DIRECTIONLESS
50
+ 2, // IS_UNMERGEABLE
51
+ 3, // IS_DIRECTIONLESS + IS_UNMERGEABLE
52
+ ],
53
+ examples: [
54
+ { description: 'No special details', value: 0 },
55
+ { description: 'Directionless', value: 1 },
56
+ { description: 'Unmergeable', value: 2 },
57
+ { description: 'Directionless + Unmergeable', value: 3 },
58
+ ],
59
+ },
60
+ direction: {
61
+ type: ['string', 'null'],
62
+ enum: ['ltr', null],
63
+ },
64
+ format: {
65
+ type: 'number',
66
+ description: `Format flags for text:
67
+ 0 = No format
68
+ 1 = Bold
69
+ 2 = Italic
70
+ 3 = Bold + Italic (1|2)
71
+ 4 = Strikethrough
72
+ 8 = Underline
73
+ 9 = Bold + Underline (1|8)
74
+ 16 = Code
75
+ 32 = Subscript
76
+ 64 = Superscript
77
+ 128 = Highlight
78
+
79
+ Formats can be combined using binary OR (|).
80
+ Example combinations:
81
+ - Bold + Italic = 1|2 = 3
82
+ - Bold + Underline = 1|8 = 9
83
+ - Italic + Underline = 2|8 = 10
84
+ - Bold + Italic + Underline = 1|2|8 = 11`,
85
+ },
86
+ indent: { type: 'number' },
87
+ mode: {
88
+ type: 'number',
89
+ description: 'Text mode flags',
90
+ enum: [
91
+ 0, // Normal
92
+ 1, // Token
93
+ 2, // Segmented
94
+ ],
95
+ examples: [
96
+ { description: 'Normal text', value: 0 },
97
+ { description: 'Token text', value: 1 },
98
+ { description: 'Segmented text', value: 2 },
99
+ ],
100
+ },
101
+ style: {
102
+ type: 'string',
103
+ description: 'CSS style string (e.g., "color: red; font-size: 12px;")',
104
+ },
105
+ text: { type: 'string' },
106
+ version: { type: 'number' },
107
+ },
108
+ required: [
109
+ 'type',
110
+ 'text',
111
+ 'format',
112
+ 'style',
113
+ 'mode',
114
+ 'detail',
115
+ 'direction',
116
+ 'indent',
117
+ 'version',
118
+ ],
119
+ },
120
+ // Styled Table Cell Node
121
+ TableCellNode: {
122
+ type: 'object',
123
+ additionalProperties: false,
124
+ properties: {
125
+ type: { type: 'string', enum: ['tablecell'] },
126
+ children: {
127
+ type: 'array',
128
+ items: {
129
+ $ref: '#/definitions/TextNode',
130
+ },
131
+ },
132
+ colSpan: { type: 'number' },
133
+ direction: {
134
+ type: ['string', 'null'],
135
+ enum: ['ltr', null],
136
+ },
137
+ headerState: { type: 'number' },
138
+ indent: { type: 'number' },
139
+ version: { type: 'number' },
140
+ width: {
141
+ type: ['null'],
142
+ enum: [null],
143
+ },
144
+ },
145
+ required: [
146
+ 'type',
147
+ 'children',
148
+ 'headerState',
149
+ 'colSpan',
150
+ 'width',
151
+ 'direction',
152
+ 'indent',
153
+ 'version',
154
+ ],
155
+ },
156
+ // Styled Table Row Node
157
+ TableRowNode: {
158
+ type: 'object',
159
+ additionalProperties: false,
160
+ properties: {
161
+ type: { type: 'string', enum: ['tablerow'] },
162
+ children: {
163
+ type: 'array',
164
+ items: {
165
+ $ref: '#/definitions/TableCellNode',
166
+ },
167
+ },
168
+ height: { type: 'number' },
169
+ },
170
+ required: ['type', 'children', 'height'],
171
+ },
172
+ // Styled Table Node
173
+ TableNode: {
174
+ type: 'object',
175
+ additionalProperties: false,
176
+ properties: {
177
+ type: { type: 'string', enum: ['table'] },
178
+ children: {
179
+ type: 'array',
180
+ items: {
181
+ $ref: '#/definitions/TableRowNode',
182
+ },
183
+ },
184
+ },
185
+ required: ['type', 'children'],
186
+ },
187
+ // Heading Node
188
+ HeadingNode: {
189
+ type: 'object',
190
+ additionalProperties: false,
191
+ properties: {
192
+ type: { type: 'string', enum: ['heading'] },
193
+ children: {
194
+ type: 'array',
195
+ items: {
196
+ anyOf: [
197
+ { $ref: '#/definitions/TextNode' },
198
+ { $ref: '#/definitions/LinkNode' },
199
+ { $ref: '#/definitions/LineBreakNode' },
200
+ { $ref: '#/definitions/TabNode' },
201
+ ],
202
+ },
203
+ },
204
+ direction: {
205
+ type: ['string', 'null'],
206
+ enum: ['ltr', null],
207
+ },
208
+ indent: { type: 'number' },
209
+ tag: { type: 'string', enum: ['h1', 'h2', 'h3'] },
210
+ version: { type: 'number' },
211
+ },
212
+ required: ['type', 'tag', 'children', 'direction', 'indent', 'version'],
213
+ },
214
+ // Paragraph Node
215
+ ParagraphNode: {
216
+ type: 'object',
217
+ additionalProperties: false,
218
+ properties: {
219
+ type: { type: 'string', enum: ['paragraph'] },
220
+ children: {
221
+ type: 'array',
222
+ items: {
223
+ anyOf: [
224
+ { $ref: '#/definitions/TextNode' },
225
+ { $ref: '#/definitions/LinkNode' },
226
+ { $ref: '#/definitions/CodeNode' },
227
+ { $ref: '#/definitions/LineBreakNode' },
228
+ { $ref: '#/definitions/TabNode' },
229
+ ],
230
+ },
231
+ },
232
+ direction: {
233
+ type: ['string', 'null'],
234
+ enum: ['ltr', null],
235
+ },
236
+ format: {
237
+ type: 'string',
238
+ description: 'Format alignment based on content. Prioritize "start", then "center", and use "right" only when appropriate.',
239
+ enum: ['start', 'center', 'right'],
240
+ },
241
+ indent: { type: 'number' },
242
+ textFormat: { type: 'number' },
243
+ textStyle: {
244
+ type: 'string',
245
+ description: 'CSS style string (e.g., "color: red; font-size: 12px;")',
246
+ },
247
+ version: { type: 'number' },
248
+ },
249
+ required: [
250
+ 'type',
251
+ 'children',
252
+ 'direction',
253
+ 'format',
254
+ 'indent',
255
+ 'textFormat',
256
+ 'textStyle',
257
+ 'version',
258
+ ],
259
+ },
260
+ // Link Node
261
+ LinkNode: {
262
+ type: 'object',
263
+ additionalProperties: false,
264
+ properties: {
265
+ type: { type: 'string', enum: ['link'] },
266
+ children: {
267
+ type: 'array',
268
+ items: {
269
+ $ref: '#/definitions/TextNode',
270
+ },
271
+ },
272
+ url: { type: 'string' },
273
+ },
274
+ required: ['type', 'url', 'children'],
275
+ },
276
+ // List Item Node
277
+ ListItemNode: {
278
+ type: 'object',
279
+ additionalProperties: false,
280
+ properties: {
281
+ // NOTE: Do not change the position of "indent", models like gpt generate properties as they are
282
+ // defined in schema, moving the position of property "indent"
283
+ // can cause issue with schema validation while streaming generated json to lexical editor
284
+ indent: { type: 'number', enum: [0, 1] },
285
+ type: { type: 'string', enum: ['listitem'] },
286
+ children: {
287
+ type: 'array',
288
+ items: {
289
+ anyOf: [
290
+ { $ref: '#/definitions/ParagraphNode' },
291
+ { $ref: '#/definitions/ListNode' },
292
+ { $ref: '#/definitions/LineBreakNode' },
293
+ ],
294
+ },
295
+ },
296
+ },
297
+ required: ['indent', 'type', 'children'],
298
+ },
299
+ // List Node
300
+ ListNode: {
301
+ type: 'object',
302
+ additionalProperties: false,
303
+ properties: {
304
+ type: { type: 'string', enum: ['list'] },
305
+ children: {
306
+ type: 'array',
307
+ items: {
308
+ $ref: '#/definitions/ListItemNode',
309
+ },
310
+ },
311
+ listType: { type: 'string', enum: ['bullet', 'number'] },
312
+ },
313
+ required: ['type', 'listType', 'children'],
314
+ },
315
+ // Quote Node
316
+ QuoteNode: {
317
+ type: 'object',
318
+ additionalProperties: false,
319
+ properties: {
320
+ type: { type: 'string', enum: ['quote'] },
321
+ children: {
322
+ type: 'array',
323
+ items: {
324
+ anyOf: [
325
+ { $ref: '#/definitions/TextNode' },
326
+ { $ref: '#/definitions/ParagraphNode' },
327
+ { $ref: '#/definitions/LineBreakNode' },
328
+ { $ref: '#/definitions/TabNode' },
329
+ ],
330
+ },
331
+ },
332
+ },
333
+ required: ['type', 'children'],
334
+ },
335
+ // Code Node
336
+ CodeNode: {
337
+ type: 'object',
338
+ additionalProperties: false,
339
+ properties: {
340
+ type: { type: 'string', enum: ['code'] },
341
+ code: { type: 'string' },
342
+ language: { type: 'string' },
343
+ },
344
+ required: ['type', 'code', 'language'],
345
+ },
346
+ // Horizontal Rule Node
347
+ HorizontalRuleNode: {
348
+ type: 'object',
349
+ additionalProperties: false,
350
+ properties: {
351
+ type: { type: 'string', enum: ['horizontalrule'] },
352
+ },
353
+ required: ['type'],
354
+ },
355
+ // Image Node
356
+ ImageNode: {
357
+ type: 'object',
358
+ additionalProperties: false,
359
+ properties: {
360
+ type: { type: 'string', enum: ['image'] },
361
+ alt: { type: 'string' },
362
+ caption: {
363
+ type: 'array',
364
+ items: {
365
+ $ref: '#/definitions/TextNode',
366
+ },
367
+ },
368
+ src: { type: 'string' },
369
+ },
370
+ required: ['type', 'src', 'alt', 'caption'],
371
+ },
372
+ // Root Node
373
+ RootNode: {
374
+ type: 'object',
375
+ additionalProperties: false,
376
+ properties: {
377
+ type: { type: 'string', enum: ['root'] },
378
+ children: {
379
+ type: 'array',
380
+ items: {
381
+ anyOf: [
382
+ { $ref: '#/definitions/TextNode' },
383
+ { $ref: '#/definitions/HeadingNode' },
384
+ { $ref: '#/definitions/ParagraphNode' },
385
+ { $ref: '#/definitions/LinkNode' },
386
+ { $ref: '#/definitions/ListNode' },
387
+ { $ref: '#/definitions/QuoteNode' },
388
+ { $ref: '#/definitions/CodeNode' },
389
+ { $ref: '#/definitions/HorizontalRuleNode' },
390
+ { $ref: '#/definitions/ImageNode' },
391
+ { $ref: '#/definitions/TableNode' },
392
+ ],
393
+ },
394
+ },
395
+ direction: {
396
+ type: ['string', 'null'],
397
+ enum: ['ltr', null],
398
+ },
399
+ indent: { type: 'number' },
400
+ version: { type: 'number' },
401
+ },
402
+ required: ['type', 'children', 'direction', 'indent', 'version'],
403
+ },
404
+ },
405
+ properties: {
406
+ root: {
407
+ $ref: '#/definitions/RootNode',
408
+ },
409
+ },
410
+ required: ['root'],
411
+ };
412
+ export const lexicalJsonSchema = (customNodes) => {
413
+ const schema = structuredClone(documentSchema);
414
+ if (Array.isArray(customNodes) && customNodes.length > 0) {
415
+ customNodes.forEach((nodeObj) => {
416
+ for (const [nodeName, nodeDefinition] of Object.entries(nodeObj)) {
417
+ // @ts-expect-error
418
+ schema.definitions[nodeName] = nodeDefinition;
419
+ // @ts-expect-error
420
+ const rootNode = schema.definitions.RootNode;
421
+ if (isObjectSchema(rootNode)) {
422
+ const children = rootNode.properties?.children;
423
+ const items = children?.items;
424
+ const anyOfList = items?.anyOf;
425
+ if (Array.isArray(anyOfList)) {
426
+ anyOfList.push({ $ref: `#/definitions/${nodeName}` });
427
+ }
428
+ }
429
+ }
430
+ });
431
+ }
432
+ return schema;
433
+ };
434
+ //# sourceMappingURL=lexical-json-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lexical-json-schema.js","sourceRoot":"","sources":["../../src/schemas/lexical-json-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAuCH;;;GAGG;AACH,SAAS,cAAc,CAAC,MAAe;IACrC,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;AAChF,CAAC;AAwBD,MAAM,CAAC,MAAM,cAAc,GAAsB;IAC/C,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,yCAAyC;IAClD,oBAAoB,EAAE,KAAK;IAC3B,WAAW,EAAE;QACX,aAAa,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE,KAAK;YAC3B,UAAU,EAAE;gBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE;gBAC7C,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;aAC5B;YACD,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;SAC9B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,CAAC,CAAA;IAE9C,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzD,WAAW,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9B,KAAK,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBACjE,mBAAmB;gBACnB,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAA;gBAE7C,mBAAmB;gBACnB,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAA;gBAC5C,IAAI,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC7B,MAAM,QAAQ,GAAG,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAA;oBAC9C,MAAM,KAAK,GAAG,QAAQ,EAAE,KAAK,CAAA;oBAC7B,MAAM,SAAS,GAAI,KAAa,EAAE,KAAK,CAAA;oBAEvC,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;wBAC7B,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,iBAAiB,QAAQ,EAAE,EAAE,CAAC,CAAA;oBACvD,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=list-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-models.d.ts","sourceRoot":"","sources":["../../src/scripts/list-models.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import { listAllModels as listAnthropic } from '../models/anthropic/anthropic-models';
9
+ import { listAllModels as listGoogle } from '../models/google/google-models';
10
+ import { listAllModels as listOpenAI } from '../models/openai/openai-models';
11
+ async function fetchProvider(provider, fn) {
12
+ try {
13
+ const models = await fn();
14
+ return { provider, models };
15
+ }
16
+ catch (err) {
17
+ const message = err instanceof Error ? err.message : String(err);
18
+ return { provider, models: [], error: message };
19
+ }
20
+ }
21
+ function printResults(results) {
22
+ const divider = '─'.repeat(72);
23
+ for (const { provider, models, error } of results) {
24
+ console.log(`\n${divider}`);
25
+ console.log(` ${provider}`);
26
+ console.log(divider);
27
+ if (error) {
28
+ console.log(` ⚠ Error: ${error}\n`);
29
+ continue;
30
+ }
31
+ if (models.length === 0) {
32
+ console.log(' No models found.\n');
33
+ continue;
34
+ }
35
+ const sorted = [...models].sort((a, b) => a.id.localeCompare(b.id));
36
+ const maxIdLen = Math.min(48, sorted.reduce((max, m) => Math.max(max, m.id.length), 0));
37
+ for (const model of sorted) {
38
+ const id = model.id.padEnd(maxIdLen);
39
+ const name = model.name !== model.id ? ` ${model.name}` : '';
40
+ console.log(` ${id}${name}`);
41
+ }
42
+ }
43
+ console.log();
44
+ }
45
+ async function main() {
46
+ console.log('\nFetching models from all providers...');
47
+ const results = await Promise.all([
48
+ fetchProvider('OpenAI', listOpenAI),
49
+ fetchProvider('Google', listGoogle),
50
+ fetchProvider('Anthropic', listAnthropic),
51
+ ]);
52
+ printResults(results);
53
+ }
54
+ main();
55
+ //# sourceMappingURL=list-models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-models.js","sourceRoot":"","sources":["../../src/scripts/list-models.ts"],"names":[],"mapp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source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * Server-only surface for `@byline/ai`.
10
+ *
11
+ * Pulls in the AI execution code (pino, the Anthropic/OpenAI/Google
12
+ * SDKs, etc.). Import from this entry only on the server — typically
13
+ * from a TanStack Start server function or a Node-side route handler.
14
+ *
15
+ * Browser code should import from `@byline/ai` (the root entry) for
16
+ * types, the public config provider, and provider/model helpers.
17
+ */
18
+ export { getAiServerConfig } from './config/ai-config';
19
+ export { executeInstruction, executeInstructionStreaming } from './execute';
20
+ export { generateStructured, generateStructuredStreaming } from './generate';
21
+ export { patch, patchStreaming } from './patch';
22
+ export type { ExecuteInstructionStreamingResult } from './execute';
23
+ export type { GenerateError, GenerateOptions, GenerateResult, GenerateStreamingResult, } from './generate';
24
+ export type { PatchError, PatchOptions, PatchResult, PatchStreamingResult, } from './patch';
25
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAA;AAC3E,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC/C,YAAY,EAAE,iCAAiC,EAAE,MAAM,WAAW,CAAA;AAClE,YAAY,EACV,aAAa,EACb,eAAe,EACf,cAAc,EACd,uBAAuB,GACxB,MAAM,YAAY,CAAA;AACnB,YAAY,EACV,UAAU,EACV,YAAY,EACZ,WAAW,EACX,oBAAoB,GACrB,MAAM,SAAS,CAAA"}
package/dist/server.js ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * Server-only surface for `@byline/ai`.
10
+ *
11
+ * Pulls in the AI execution code (pino, the Anthropic/OpenAI/Google
12
+ * SDKs, etc.). Import from this entry only on the server — typically
13
+ * from a TanStack Start server function or a Node-side route handler.
14
+ *
15
+ * Browser code should import from `@byline/ai` (the root entry) for
16
+ * types, the public config provider, and provider/model helpers.
17
+ */
18
+ export { getAiServerConfig } from './config/ai-config';
19
+ export { executeInstruction, executeInstructionStreaming } from './execute';
20
+ export { generateStructured, generateStructuredStreaming } from './generate';
21
+ export { patch, patchStreaming } from './patch';
22
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAA;AAC3E,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import type { SerializedEditorState } from 'lexical';
9
+ export type Marks = {
10
+ bold: boolean;
11
+ italic: boolean;
12
+ underline: boolean;
13
+ code: boolean;
14
+ };
15
+ export type InlineText = {
16
+ kind: 'text';
17
+ text: string;
18
+ marks: Marks;
19
+ };
20
+ export type InlineLink = {
21
+ kind: 'link';
22
+ url: string;
23
+ text: string;
24
+ marks: Marks;
25
+ };
26
+ export type InlineBr = {
27
+ kind: 'br';
28
+ };
29
+ export type Inline = InlineText | InlineLink | InlineBr;
30
+ export type ParagraphBlock = {
31
+ kind: 'paragraph';
32
+ align: 'start' | 'center' | 'right';
33
+ inlines: Inline[];
34
+ };
35
+ export type HeadingBlock = {
36
+ kind: 'heading';
37
+ level: 1 | 2 | 3;
38
+ inlines: Inline[];
39
+ };
40
+ export type QuoteBlock = {
41
+ kind: 'quote';
42
+ blocks: ParagraphBlock[];
43
+ };
44
+ export type HrBlock = {
45
+ kind: 'hr';
46
+ };
47
+ export type ListItemBlock = {
48
+ indent: 0 | 1;
49
+ blocks: ParagraphBlock[];
50
+ };
51
+ export type ListBlock = {
52
+ kind: 'list';
53
+ listType: 'bullet' | 'number';
54
+ items: ListItemBlock[];
55
+ };
56
+ export type Block = HeadingBlock | ParagraphBlock | ListBlock | QuoteBlock | HrBlock;
57
+ export type GeneratedDoc = {
58
+ title: string | null;
59
+ blocks: Block[];
60
+ };
61
+ export declare function convertToLexical(doc: GeneratedDoc): SerializedEditorState;
62
+ //# sourceMappingURL=convert-to-lexical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-to-lexical.d.ts","sourceRoot":"","sources":["../../src/utils/convert-to-lexical.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,OAAO,CAAA;IACb,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAA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