@rizom/brain 0.2.0-alpha.47 → 0.2.0-alpha.48
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/dist/brain.js +800 -800
- package/dist/deploy.d.ts +17 -26
- package/dist/entities.d.ts +509 -142
- package/dist/entities.js +2 -2
- package/dist/entities.js.map +6 -6
- package/dist/index.d.ts +60 -46
- package/dist/index.js +2 -501
- package/dist/index.js.map +4 -579
- package/dist/interfaces.d.ts +908 -112
- package/dist/interfaces.js +145 -145
- package/dist/interfaces.js.map +7 -83
- package/dist/plugins.d.ts +1078 -489
- package/dist/plugins.js +139 -139
- package/dist/plugins.js.map +30 -41
- package/dist/services.d.ts +551 -105
- package/dist/services.js +136 -136
- package/dist/services.js.map +40 -88
- package/dist/site.d.ts +56 -157
- package/dist/site.js +285 -285
- package/dist/site.js.map +47 -35
- package/dist/templates.d.ts +292 -52
- package/dist/themes.d.ts +5 -44
- package/package.json +3 -1
package/dist/templates.d.ts
CHANGED
|
@@ -1,62 +1,302 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { VNode } from 'preact';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Progress notification for long-running operations
|
|
6
|
+
*/
|
|
7
|
+
interface ProgressNotification {
|
|
8
|
+
progress: number;
|
|
9
|
+
total?: number;
|
|
10
|
+
message?: string;
|
|
11
|
+
rate?: number;
|
|
12
|
+
eta?: number;
|
|
8
13
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Progress callback type
|
|
16
|
+
*/
|
|
17
|
+
type ProgressCallback = (notification: ProgressNotification) => Promise<void>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Interface for content formatters (human-editable content formatting)
|
|
21
|
+
*
|
|
22
|
+
* ContentFormatters handle bidirectional transformation between structured data
|
|
23
|
+
* and human-editable markdown templates. Unlike SchemaFormatters which are for
|
|
24
|
+
* one-way API response formatting, ContentFormatters support parsing edited
|
|
25
|
+
* content back into structured data.
|
|
26
|
+
*/
|
|
27
|
+
interface ContentFormatter<T = unknown> {
|
|
28
|
+
/**
|
|
29
|
+
* Format structured data into human-editable markdown
|
|
30
|
+
* @param data - The structured data to format
|
|
31
|
+
* @returns Human-editable markdown representation
|
|
32
|
+
*/
|
|
33
|
+
format(data: T): string;
|
|
34
|
+
/**
|
|
35
|
+
* Parse human-editable markdown back into structured data
|
|
36
|
+
* @param content - The markdown content to parse
|
|
37
|
+
* @returns Structured data parsed from the markdown
|
|
38
|
+
* @throws Error if the content cannot be parsed
|
|
39
|
+
*/
|
|
40
|
+
parse(content: string): T;
|
|
19
41
|
}
|
|
20
|
-
export const TemplateSchema: z.ZodSchema<Template>;
|
|
21
|
-
export function createTemplate<T = unknown>(
|
|
22
|
-
input: TemplateInput<T>,
|
|
23
|
-
): Template<T>;
|
|
24
|
-
export function createTypedComponent<P>(
|
|
25
|
-
component: ComponentType<P>,
|
|
26
|
-
): ComponentType<P>;
|
|
27
42
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Component type for layouts - using Preact
|
|
45
|
+
* Returns a Preact VNode
|
|
46
|
+
*/
|
|
47
|
+
type ComponentType<P = unknown> = (props: P) => VNode;
|
|
48
|
+
/**
|
|
49
|
+
* A runtime script that a template depends on. Site-builder collects
|
|
50
|
+
* these per route across all templates rendered on the page, dedupes
|
|
51
|
+
* by `src`, and injects them as <script> tags.
|
|
52
|
+
*
|
|
53
|
+
* Use this for non-hydration runtime scripts (background canvases,
|
|
54
|
+
* scroll observers, decorative animations) that should ONLY load on
|
|
55
|
+
* pages where the template actually renders — unlike the plugin-level
|
|
56
|
+
* head-script registration which fires on every page.
|
|
57
|
+
*/
|
|
58
|
+
interface RuntimeScript {
|
|
59
|
+
src: string;
|
|
60
|
+
defer?: boolean;
|
|
61
|
+
module?: boolean;
|
|
38
62
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Helper function to create a type-safe component that automatically parses props
|
|
65
|
+
* using the provided Zod schema
|
|
66
|
+
*
|
|
67
|
+
* Supports transformation between schema type and component type (e.g., enrichment)
|
|
68
|
+
* @param TSchema - Type validated by schema (e.g., with optional url/typeLabel)
|
|
69
|
+
* @param TComponent - Type expected by component (e.g., with required url/typeLabel)
|
|
70
|
+
*/
|
|
71
|
+
declare function createTypedComponent<TSchema, TComponent = TSchema>(schema: z.ZodType<TSchema>, component: ComponentType<TComponent>): ComponentType<unknown>;
|
|
72
|
+
/**
|
|
73
|
+
* Unified template interface that bundles content generation and view rendering
|
|
74
|
+
* This is the single source of truth for what constitutes a template
|
|
75
|
+
*/
|
|
76
|
+
interface Template extends Omit<z.infer<typeof TemplateSchema>, "schema" | "layout" | "formatter"> {
|
|
77
|
+
schema: z.ZodSchema;
|
|
78
|
+
layout?: {
|
|
79
|
+
component?: ComponentType<unknown>;
|
|
80
|
+
fullscreen?: boolean;
|
|
81
|
+
};
|
|
82
|
+
formatter?: ContentFormatter<unknown>;
|
|
83
|
+
/**
|
|
84
|
+
* Whether to retrieve relevant entities from the knowledge base
|
|
85
|
+
* and inject them as context before AI generation. Default: false.
|
|
86
|
+
*/
|
|
87
|
+
useKnowledgeContext?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Runtime script dependencies. Loaded only on routes where this
|
|
90
|
+
* template actually renders — site-builder collects from all
|
|
91
|
+
* templates on a route, dedupes by src, and injects into <head>.
|
|
92
|
+
*/
|
|
93
|
+
runtimeScripts?: RuntimeScript[];
|
|
42
94
|
}
|
|
43
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Helper to create a template with automatic component wrapping
|
|
97
|
+
*
|
|
98
|
+
* Supports transformation between schema type and component type (e.g., enrichment)
|
|
99
|
+
* @param TSchema - Type validated by schema (datasource output)
|
|
100
|
+
* @param TComponent - Type expected by component (after enrichment)
|
|
101
|
+
*/
|
|
102
|
+
declare function createTemplate<TSchema = unknown, TComponent = TSchema>(template: Omit<Template, "layout" | "schema"> & {
|
|
103
|
+
schema: z.ZodType<TSchema>;
|
|
104
|
+
layout?: {
|
|
105
|
+
component?: ComponentType<TComponent>;
|
|
106
|
+
fullscreen?: boolean;
|
|
107
|
+
};
|
|
108
|
+
runtimeScripts?: RuntimeScript[];
|
|
109
|
+
}): Template;
|
|
110
|
+
/**
|
|
111
|
+
* Template schema for validation
|
|
112
|
+
*/
|
|
113
|
+
declare const TemplateSchema: z.ZodObject<{
|
|
114
|
+
name: z.ZodString;
|
|
115
|
+
description: z.ZodString;
|
|
116
|
+
schema: z.ZodAny;
|
|
117
|
+
basePrompt: z.ZodOptional<z.ZodString>;
|
|
118
|
+
useKnowledgeContext: z.ZodOptional<z.ZodBoolean>;
|
|
119
|
+
requiredPermission: z.ZodEnum<["anchor", "trusted", "public"]>;
|
|
120
|
+
formatter: z.ZodOptional<z.ZodAny>;
|
|
121
|
+
layout: z.ZodOptional<z.ZodObject<{
|
|
122
|
+
component: z.ZodAny;
|
|
123
|
+
fullscreen: z.ZodOptional<z.ZodBoolean>;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
component?: any;
|
|
126
|
+
fullscreen?: boolean | undefined;
|
|
127
|
+
}, {
|
|
128
|
+
component?: any;
|
|
129
|
+
fullscreen?: boolean | undefined;
|
|
130
|
+
}>>;
|
|
131
|
+
dataSourceId: z.ZodOptional<z.ZodString>;
|
|
132
|
+
}, "strip", z.ZodTypeAny, {
|
|
133
|
+
name: string;
|
|
134
|
+
description: string;
|
|
135
|
+
requiredPermission: "anchor" | "trusted" | "public";
|
|
136
|
+
schema?: any;
|
|
137
|
+
basePrompt?: string | undefined;
|
|
138
|
+
useKnowledgeContext?: boolean | undefined;
|
|
139
|
+
formatter?: any;
|
|
140
|
+
layout?: {
|
|
141
|
+
component?: any;
|
|
142
|
+
fullscreen?: boolean | undefined;
|
|
143
|
+
} | undefined;
|
|
144
|
+
dataSourceId?: string | undefined;
|
|
145
|
+
}, {
|
|
146
|
+
name: string;
|
|
147
|
+
description: string;
|
|
148
|
+
requiredPermission: "anchor" | "trusted" | "public";
|
|
149
|
+
schema?: any;
|
|
150
|
+
basePrompt?: string | undefined;
|
|
151
|
+
useKnowledgeContext?: boolean | undefined;
|
|
152
|
+
formatter?: any;
|
|
153
|
+
layout?: {
|
|
154
|
+
component?: any;
|
|
155
|
+
fullscreen?: boolean | undefined;
|
|
156
|
+
} | undefined;
|
|
157
|
+
dataSourceId?: string | undefined;
|
|
158
|
+
}>;
|
|
159
|
+
type TemplateInput = z.infer<typeof TemplateSchema>;
|
|
44
160
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
161
|
+
/**
|
|
162
|
+
* Site content entity types
|
|
163
|
+
*/
|
|
164
|
+
declare const SiteContentEntityTypeSchema: z.ZodEnum<["site-content-preview", "site-content-production"]>;
|
|
165
|
+
type SiteContentEntityType = z.infer<typeof SiteContentEntityTypeSchema>;
|
|
166
|
+
/**
|
|
167
|
+
* View template schema
|
|
168
|
+
*/
|
|
169
|
+
declare const ViewTemplateSchema: z.ZodObject<{
|
|
170
|
+
name: z.ZodString;
|
|
171
|
+
schema: z.ZodAny;
|
|
172
|
+
description: z.ZodOptional<z.ZodString>;
|
|
173
|
+
pluginId: z.ZodString;
|
|
174
|
+
renderers: z.ZodObject<{
|
|
175
|
+
web: z.ZodOptional<z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodString]>>;
|
|
176
|
+
}, "strip", z.ZodTypeAny, {
|
|
177
|
+
web?: string | ((...args: unknown[]) => unknown) | undefined;
|
|
178
|
+
}, {
|
|
179
|
+
web?: string | ((...args: unknown[]) => unknown) | undefined;
|
|
180
|
+
}>;
|
|
181
|
+
}, "strip", z.ZodTypeAny, {
|
|
182
|
+
name: string;
|
|
183
|
+
pluginId: string;
|
|
184
|
+
renderers: {
|
|
185
|
+
web?: string | ((...args: unknown[]) => unknown) | undefined;
|
|
186
|
+
};
|
|
187
|
+
description?: string | undefined;
|
|
188
|
+
schema?: any;
|
|
189
|
+
}, {
|
|
190
|
+
name: string;
|
|
191
|
+
pluginId: string;
|
|
192
|
+
renderers: {
|
|
193
|
+
web?: string | ((...args: unknown[]) => unknown) | undefined;
|
|
194
|
+
};
|
|
195
|
+
description?: string | undefined;
|
|
196
|
+
schema?: any;
|
|
197
|
+
}>;
|
|
198
|
+
/**
|
|
199
|
+
* Renderer types for different output formats
|
|
200
|
+
*/
|
|
201
|
+
type WebRenderer<T = unknown> = ComponentType<T> | string;
|
|
202
|
+
/**
|
|
203
|
+
* Output format types
|
|
204
|
+
*/
|
|
205
|
+
type OutputFormat = "web";
|
|
206
|
+
/**
|
|
207
|
+
* View template with support for multiple output formats
|
|
208
|
+
*/
|
|
209
|
+
interface ViewTemplate<T = unknown> {
|
|
210
|
+
name: string;
|
|
211
|
+
schema: z.ZodType<T>;
|
|
212
|
+
description?: string;
|
|
213
|
+
pluginId: string;
|
|
214
|
+
renderers: {
|
|
215
|
+
web?: WebRenderer<T>;
|
|
216
|
+
};
|
|
217
|
+
fullscreen?: boolean;
|
|
218
|
+
providerId?: string;
|
|
219
|
+
formatter?: ContentFormatter<T>;
|
|
220
|
+
/** Runtime script dependencies (see Template.runtimeScripts). */
|
|
221
|
+
runtimeScripts?: RuntimeScript[];
|
|
49
222
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
223
|
+
/**
|
|
224
|
+
* View template registry interface
|
|
225
|
+
*/
|
|
226
|
+
interface ViewTemplateRegistry {
|
|
227
|
+
get(name: string): ViewTemplate<unknown> | undefined;
|
|
228
|
+
list(): ViewTemplate<unknown>[];
|
|
229
|
+
validate(templateName: string, content: unknown): boolean;
|
|
55
230
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
231
|
+
/**
|
|
232
|
+
* Site builder options
|
|
233
|
+
*/
|
|
234
|
+
declare const SiteBuilderOptionsSchema: z.ZodObject<{
|
|
235
|
+
enableContentGeneration: z.ZodDefault<z.ZodBoolean>;
|
|
236
|
+
outputDir: z.ZodString;
|
|
237
|
+
workingDir: z.ZodOptional<z.ZodString>;
|
|
238
|
+
environment: z.ZodDefault<z.ZodEnum<["preview", "production"]>>;
|
|
239
|
+
siteConfig: z.ZodOptional<z.ZodObject<{
|
|
240
|
+
title: z.ZodString;
|
|
241
|
+
description: z.ZodString;
|
|
242
|
+
url: z.ZodOptional<z.ZodString>;
|
|
243
|
+
}, "strip", z.ZodTypeAny, {
|
|
244
|
+
description: string;
|
|
245
|
+
title: string;
|
|
246
|
+
url?: string | undefined;
|
|
247
|
+
}, {
|
|
248
|
+
description: string;
|
|
249
|
+
title: string;
|
|
250
|
+
url?: string | undefined;
|
|
251
|
+
}>>;
|
|
252
|
+
}, "strip", z.ZodTypeAny, {
|
|
253
|
+
enableContentGeneration: boolean;
|
|
254
|
+
outputDir: string;
|
|
255
|
+
environment: "preview" | "production";
|
|
256
|
+
workingDir?: string | undefined;
|
|
257
|
+
siteConfig?: {
|
|
258
|
+
description: string;
|
|
259
|
+
title: string;
|
|
260
|
+
url?: string | undefined;
|
|
261
|
+
} | undefined;
|
|
262
|
+
}, {
|
|
263
|
+
outputDir: string;
|
|
264
|
+
enableContentGeneration?: boolean | undefined;
|
|
265
|
+
workingDir?: string | undefined;
|
|
266
|
+
environment?: "preview" | "production" | undefined;
|
|
267
|
+
siteConfig?: {
|
|
268
|
+
description: string;
|
|
269
|
+
title: string;
|
|
270
|
+
url?: string | undefined;
|
|
271
|
+
} | undefined;
|
|
272
|
+
}>;
|
|
273
|
+
type SiteBuilderOptions = z.infer<typeof SiteBuilderOptionsSchema>;
|
|
274
|
+
/**
|
|
275
|
+
* Build result schema
|
|
276
|
+
*/
|
|
277
|
+
declare const BuildResultSchema: z.ZodObject<{
|
|
278
|
+
success: z.ZodBoolean;
|
|
279
|
+
routesBuilt: z.ZodNumber;
|
|
280
|
+
errors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
281
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
282
|
+
}, "strip", z.ZodTypeAny, {
|
|
283
|
+
success: boolean;
|
|
284
|
+
routesBuilt: number;
|
|
285
|
+
errors?: string[] | undefined;
|
|
286
|
+
warnings?: string[] | undefined;
|
|
287
|
+
}, {
|
|
288
|
+
success: boolean;
|
|
289
|
+
routesBuilt: number;
|
|
290
|
+
errors?: string[] | undefined;
|
|
291
|
+
warnings?: string[] | undefined;
|
|
292
|
+
}>;
|
|
293
|
+
type BuildResult = z.infer<typeof BuildResultSchema>;
|
|
294
|
+
/**
|
|
295
|
+
* Site builder interface
|
|
296
|
+
*/
|
|
297
|
+
interface SiteBuilder {
|
|
298
|
+
build(options: SiteBuilderOptions, progress?: ProgressCallback): Promise<BuildResult>;
|
|
59
299
|
}
|
|
60
|
-
|
|
61
|
-
export
|
|
62
|
-
export
|
|
300
|
+
|
|
301
|
+
export { BuildResultSchema, SiteBuilderOptionsSchema, SiteContentEntityTypeSchema, TemplateSchema, ViewTemplateSchema, createTemplate, createTypedComponent };
|
|
302
|
+
export type { BuildResult, ComponentType, OutputFormat, RuntimeScript, SiteBuilder, SiteBuilderOptions, SiteContentEntityType, Template, TemplateInput, ViewTemplate, ViewTemplateRegistry, WebRenderer };
|
package/dist/themes.d.ts
CHANGED
|
@@ -1,48 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Compose a complete theme by prepending shared base utilities.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* edge cases of the `@brains/*` type graph. See
|
|
7
|
-
* `docs/plans/external-plugin-api.md` for the replacement plan.
|
|
8
|
-
*
|
|
9
|
-
* **Sync rules:**
|
|
10
|
-
* - When `composeTheme`'s signature changes in `@brains/theme-base`,
|
|
11
|
-
* update this file in the same commit.
|
|
12
|
-
* - The runtime side (`../entries/themes.ts`) re-exports the real
|
|
13
|
-
* implementation from `@brains/theme-base`. The .js bundle
|
|
14
|
-
* produced by `scripts/build.ts` is what consumers execute.
|
|
15
|
-
* This .d.ts file is what their tsc sees.
|
|
4
|
+
* Base utilities live in @layer theme-base; theme-specific styles
|
|
5
|
+
* should use @layer theme-override to guarantee correct cascade order.
|
|
16
6
|
*/
|
|
7
|
+
declare function composeTheme(themeCSS: string): string;
|
|
17
8
|
|
|
18
|
-
|
|
19
|
-
* Prepend the shared base theme utilities to a raw theme CSS string
|
|
20
|
-
* and return the combined result.
|
|
21
|
-
*
|
|
22
|
-
* The base utilities layer contains:
|
|
23
|
-
*
|
|
24
|
-
* - Palette tokens (`--palette-*`) for neutral colors, status colors,
|
|
25
|
-
* and universal UI signals
|
|
26
|
-
* - `@theme inline` declarations that expose the semantic color
|
|
27
|
-
* tokens (`--color-brand`, `--color-bg`, `--color-text`, etc.) to
|
|
28
|
-
* Tailwind v4's JIT so utilities like `bg-brand`, `text-brand`,
|
|
29
|
-
* `border-brand`, `focus-visible:ring-brand` auto-generate
|
|
30
|
-
* - Layer ordering (`@layer theme-base, theme-override`) so theme
|
|
31
|
-
* overrides cascade correctly regardless of concat order
|
|
32
|
-
* - Universal gradient, status, selection, and warning utilities
|
|
33
|
-
* - Prose color slots for `@tailwindcss/typography`
|
|
34
|
-
*
|
|
35
|
-
* The framework resolver uses this helper when it loads a raw theme
|
|
36
|
-
* package or inline theme CSS. Advanced consumers can use the same
|
|
37
|
-
* helper when they need a fully composed CSS string outside the
|
|
38
|
-
* resolver.
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```ts
|
|
42
|
-
* import { composeTheme } from "@rizom/brain/themes";
|
|
43
|
-
* import themeCSS from "./theme.css" with { type: "text" };
|
|
44
|
-
*
|
|
45
|
-
* const fullThemeCSS = composeTheme(themeCSS);
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export function composeTheme(themeCSS: string): string;
|
|
9
|
+
export { composeTheme };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rizom/brain",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.48",
|
|
4
4
|
"description": "Brain runtime + CLI — scaffold, run, and manage AI brain instances",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -95,6 +95,8 @@
|
|
|
95
95
|
"@brains/typescript-config": "workspace:*",
|
|
96
96
|
"@brains/utils": "workspace:*",
|
|
97
97
|
"@types/bun": "latest",
|
|
98
|
+
"rollup": "^4.60.2",
|
|
99
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
98
100
|
"typescript": "^5.3.3"
|
|
99
101
|
},
|
|
100
102
|
"publishConfig": {
|