@rizom/brain 0.2.0-alpha.6 → 0.2.0-alpha.60

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 (40) hide show
  1. package/README.md +1 -1
  2. package/dist/brain.js +4762 -26509
  3. package/dist/deploy.d.ts +17 -26
  4. package/dist/deploy.js +25 -25
  5. package/dist/deploy.js.map +4 -4
  6. package/dist/entities.d.ts +561 -0
  7. package/dist/entities.js +172 -0
  8. package/dist/entities.js.map +242 -0
  9. package/dist/index.d.ts +65 -0
  10. package/dist/index.js +5 -0
  11. package/dist/index.js.map +11 -0
  12. package/dist/interfaces.d.ts +923 -0
  13. package/dist/interfaces.js +172 -0
  14. package/dist/interfaces.js.map +209 -0
  15. package/dist/plugins.d.ts +1195 -0
  16. package/dist/plugins.js +178 -0
  17. package/dist/plugins.js.map +294 -0
  18. package/dist/seed-content/relay/README.md +28 -371
  19. package/dist/seed-content/relay/anchor-profile/anchor-profile.md +8 -11
  20. package/dist/seed-content/relay/brain-character/brain-character.md +5 -4
  21. package/dist/seed-content/relay/site-content/about/about.md +20 -0
  22. package/dist/seed-content/relay/site-content/home/diagram.md +184 -0
  23. package/dist/seed-content/relay/site-info/site-info.md +11 -1
  24. package/dist/services.d.ts +601 -0
  25. package/dist/services.js +172 -0
  26. package/dist/services.js.map +242 -0
  27. package/dist/site.d.ts +56 -157
  28. package/dist/site.js +323 -463
  29. package/dist/site.js.map +131 -249
  30. package/dist/templates.d.ts +302 -0
  31. package/dist/templates.js +172 -0
  32. package/dist/templates.js.map +206 -0
  33. package/dist/themes.d.ts +5 -44
  34. package/dist/themes.js +91 -8
  35. package/dist/themes.js.map +2 -2
  36. package/package.json +35 -4
  37. package/templates/deploy/scripts/provision-server.ts +109 -0
  38. package/templates/deploy/scripts/update-dns.ts +65 -0
  39. package/templates/deploy/scripts/write-ssh-key.ts +17 -0
  40. package/tsconfig.instance.json +31 -0
@@ -0,0 +1,302 @@
1
+ import { z } from 'zod';
2
+ import { VNode } from 'preact';
3
+
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;
13
+ }
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;
41
+ }
42
+
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;
62
+ }
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[];
94
+ }
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>;
160
+
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[];
222
+ }
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;
230
+ }
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>;
299
+ }
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 };