@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,1195 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Options for entity mutation operations (create, update, upsert)
5
+ */
6
+ interface EntityJobOptions {
7
+ priority?: number;
8
+ maxRetries?: number;
9
+ }
10
+ /**
11
+ * Options for entity creation (extends EntityJobOptions with deduplication)
12
+ */
13
+ interface CreateEntityOptions extends EntityJobOptions {
14
+ deduplicateId?: boolean;
15
+ }
16
+ /**
17
+ * Result of an entity mutation that triggers an embedding job.
18
+ * When skipped is true, content was unchanged — no DB write, no event, no embedding job.
19
+ */
20
+ interface EntityMutationResult {
21
+ entityId: string;
22
+ jobId: string;
23
+ skipped: boolean;
24
+ }
25
+ /**
26
+ * Input for adapter-validated direct creation from finalized markdown.
27
+ */
28
+ interface CreateEntityFromMarkdownInput {
29
+ entityType: string;
30
+ id: string;
31
+ markdown: string;
32
+ }
33
+ /**
34
+ * Data for storing an embedding for an entity
35
+ */
36
+ interface StoreEmbeddingData {
37
+ entityId: string;
38
+ entityType: string;
39
+ embedding: Float32Array;
40
+ contentHash: string;
41
+ }
42
+ /**
43
+ * Base entity type - generic to support typed metadata
44
+ * TMetadata defaults to Record<string, unknown> for backward compatibility
45
+ */
46
+ interface BaseEntity<TMetadata = Record<string, unknown>> {
47
+ id: string;
48
+ entityType: string;
49
+ content: string;
50
+ created: string;
51
+ updated: string;
52
+ metadata: TMetadata;
53
+ /** SHA256 hash of content for change detection */
54
+ contentHash: string;
55
+ }
56
+ /**
57
+ * Entity input type for creation - allows partial entities with optional system fields
58
+ * contentHash is excluded because it's computed automatically by the entity service
59
+ */
60
+ type EntityInput<T extends BaseEntity> = Omit<T, "id" | "created" | "updated" | "contentHash"> & {
61
+ id?: string;
62
+ created?: string;
63
+ updated?: string;
64
+ };
65
+ /**
66
+ * Search result type
67
+ */
68
+ interface SearchResult<T extends BaseEntity = BaseEntity> {
69
+ entity: T;
70
+ score: number;
71
+ excerpt: string;
72
+ }
73
+ /**
74
+ * Normalized system_create input shape used by plugin create interceptors.
75
+ */
76
+ interface CreateInput {
77
+ entityType: string;
78
+ prompt?: string;
79
+ title?: string;
80
+ content?: string;
81
+ url?: string;
82
+ targetEntityType?: string;
83
+ targetEntityId?: string;
84
+ }
85
+ /**
86
+ * Minimal caller context forwarded to plugin create interceptors.
87
+ */
88
+ interface CreateExecutionContext {
89
+ interfaceType: string;
90
+ userId: string;
91
+ channelId?: string;
92
+ channelName?: string;
93
+ }
94
+ /**
95
+ * Result returned to system_create when a plugin fully handles creation.
96
+ */
97
+ type CreateResult = {
98
+ success: true;
99
+ data: {
100
+ entityId?: string;
101
+ jobId?: string;
102
+ status: string;
103
+ };
104
+ } | {
105
+ success: false;
106
+ error: string;
107
+ };
108
+ /**
109
+ * Plugin create interceptors can either fully handle creation,
110
+ * or continue with a rewritten normalized input.
111
+ */
112
+ type CreateInterceptionResult = {
113
+ kind: "handled";
114
+ result: CreateResult;
115
+ } | {
116
+ kind: "continue";
117
+ input: CreateInput;
118
+ };
119
+ /**
120
+ * Interface for entity adapter - handles conversion between entities and markdown
121
+ * following the hybrid storage model
122
+ *
123
+ * @template TEntity - The full entity type
124
+ * @template TMetadata - The metadata type (defaults to Record<string, unknown>)
125
+ */
126
+ interface EntityAdapter<TEntity extends BaseEntity<TMetadata>, TMetadata = Record<string, unknown>> {
127
+ entityType: string;
128
+ schema: z.ZodSchema<TEntity>;
129
+ toMarkdown(entity: TEntity): string;
130
+ fromMarkdown(markdown: string): Partial<TEntity>;
131
+ extractMetadata(entity: TEntity): TMetadata;
132
+ parseFrontMatter<TFrontmatter>(markdown: string, schema: z.ZodSchema<TFrontmatter>): TFrontmatter;
133
+ generateFrontMatter(entity: TEntity): string;
134
+ /** Optional: Zod schema for frontmatter fields. Used by CMS config generation. */
135
+ frontmatterSchema?: z.ZodObject<z.ZodRawShape>;
136
+ /** Optional: Declares this entity type is a singleton (one file, e.g., identity/identity.md). Used by CMS to generate files collection. */
137
+ isSingleton?: boolean;
138
+ /** Optional: Whether this entity has a free-form markdown body below frontmatter. Defaults to true. When false, CMS omits the body widget. */
139
+ hasBody?: boolean;
140
+ /** Returns a markdown body template with section headings for this entity type. Empty string for free-form entities. */
141
+ getBodyTemplate(): string;
142
+ /** Optional: Declares that this entity type supports cover images via coverImageId in frontmatter */
143
+ supportsCoverImage?: boolean;
144
+ /** Optional: Extract coverImageId from entity content/frontmatter */
145
+ getCoverImageId?(entity: TEntity): string | undefined;
146
+ }
147
+ /**
148
+ * Sort field specification for multi-field sorting
149
+ */
150
+ interface SortField {
151
+ /** Field to sort by - "created", "updated", or a metadata field name */
152
+ field: string;
153
+ /** Sort direction */
154
+ direction: "asc" | "desc";
155
+ /** Sort NULL values before non-NULL values (default: false / SQLite default) */
156
+ nullsFirst?: boolean;
157
+ }
158
+ /**
159
+ * List entities options
160
+ * Generic over metadata type for type-safe filtering
161
+ */
162
+ interface ListOptions<TMetadata = Record<string, unknown>> {
163
+ limit?: number;
164
+ offset?: number;
165
+ /** Multi-field sorting - supports system fields (created, updated) and metadata fields */
166
+ sortFields?: SortField[];
167
+ filter?: {
168
+ metadata?: Partial<TMetadata>;
169
+ };
170
+ /** Filter to only entities with metadata.status = "published" */
171
+ publishedOnly?: boolean;
172
+ }
173
+ /**
174
+ * Search options
175
+ */
176
+ interface SearchOptions {
177
+ limit?: number;
178
+ offset?: number;
179
+ types?: string[];
180
+ excludeTypes?: string[];
181
+ sortBy?: "relevance" | "created" | "updated";
182
+ sortDirection?: "asc" | "desc";
183
+ /** Score multipliers per entity type - applied after initial search */
184
+ weight?: Record<string, number>;
185
+ }
186
+ /**
187
+ * Configuration for entity type registration
188
+ */
189
+ interface EntityTypeConfig {
190
+ /** Score multiplier for search results (default: 1.0) */
191
+ weight?: number;
192
+ /** Whether to generate embeddings for this entity type (default: true).
193
+ * Set to false for entity types with non-textual content (e.g., images). */
194
+ embeddable?: boolean;
195
+ }
196
+ /**
197
+ * Core entity service interface for read-only operations
198
+ * Used by core plugins that need entity access but shouldn't modify entities
199
+ */
200
+ interface GetEntityRequest$1 {
201
+ entityType: string;
202
+ id: string;
203
+ }
204
+ type GetEntityRawRequest = GetEntityRequest$1;
205
+ interface ListEntitiesRequest$1 {
206
+ entityType: string;
207
+ options?: ListOptions | undefined;
208
+ }
209
+ interface CountEntitiesRequest$1 {
210
+ entityType: string;
211
+ options?: Pick<ListOptions, "publishedOnly" | "filter"> | undefined;
212
+ }
213
+ interface CreateEntityRequest<T extends BaseEntity> {
214
+ entity: EntityInput<T>;
215
+ options?: CreateEntityOptions | undefined;
216
+ }
217
+ interface CreateEntityFromMarkdownRequest {
218
+ input: CreateEntityFromMarkdownInput;
219
+ options?: CreateEntityOptions | undefined;
220
+ }
221
+ interface UpdateEntityRequest<T extends BaseEntity> {
222
+ entity: T;
223
+ options?: EntityJobOptions | undefined;
224
+ }
225
+ interface DeleteEntityRequest {
226
+ entityType: string;
227
+ id: string;
228
+ }
229
+ interface UpsertEntityRequest<T extends BaseEntity> {
230
+ entity: T;
231
+ options?: EntityJobOptions | undefined;
232
+ }
233
+ interface EntitySearchRequest$1 {
234
+ query: string;
235
+ options?: SearchOptions | undefined;
236
+ }
237
+ interface SearchWithDistancesRequest {
238
+ query: string;
239
+ }
240
+ interface ICoreEntityService {
241
+ getEntity<T extends BaseEntity>(request: GetEntityRequest$1): Promise<T | null>;
242
+ /**
243
+ * Get entity without content resolution (raw)
244
+ * Used internally to avoid recursion when resolving image references
245
+ */
246
+ getEntityRaw<T extends BaseEntity>(request: GetEntityRawRequest): Promise<T | null>;
247
+ listEntities<T extends BaseEntity>(request: ListEntitiesRequest$1): Promise<T[]>;
248
+ search<T extends BaseEntity = BaseEntity>(request: EntitySearchRequest$1): Promise<SearchResult<T>[]>;
249
+ getEntityTypes(): string[];
250
+ hasEntityType(type: string): boolean;
251
+ countEntities(request: CountEntitiesRequest$1): Promise<number>;
252
+ getEntityCounts(): Promise<Array<{
253
+ entityType: string;
254
+ count: number;
255
+ }>>;
256
+ /** Get weight map for all registered entity types with non-default weights */
257
+ getWeightMap(): Record<string, number>;
258
+ }
259
+ /**
260
+ * Entity service interface for managing brain entities
261
+ */
262
+ interface EntityService extends ICoreEntityService {
263
+ createEntity<T extends BaseEntity>(request: CreateEntityRequest<T>): Promise<EntityMutationResult>;
264
+ createEntityFromMarkdown(request: CreateEntityFromMarkdownRequest): Promise<EntityMutationResult>;
265
+ updateEntity<T extends BaseEntity>(request: UpdateEntityRequest<T>): Promise<EntityMutationResult>;
266
+ deleteEntity(request: DeleteEntityRequest): Promise<boolean>;
267
+ upsertEntity<T extends BaseEntity>(request: UpsertEntityRequest<T>): Promise<EntityMutationResult & {
268
+ created: boolean;
269
+ }>;
270
+ storeEmbedding(data: StoreEmbeddingData): Promise<void>;
271
+ serializeEntity(entity: BaseEntity): string;
272
+ deserializeEntity(markdown: string, entityType: string): Partial<BaseEntity>;
273
+ countEmbeddings(): Promise<number>;
274
+ searchWithDistances(request: SearchWithDistancesRequest): Promise<Array<{
275
+ entityId: string;
276
+ entityType: string;
277
+ distance: number;
278
+ }>>;
279
+ initialize(): Promise<void>;
280
+ getAsyncJobStatus(jobId: string): Promise<{
281
+ status: "pending" | "processing" | "completed" | "failed";
282
+ error?: string;
283
+ } | null>;
284
+ }
285
+
286
+ /**
287
+ * Context passed to all DataSource operations
288
+ * Contains internal state that should not be mixed with user query parameters
289
+ */
290
+ interface BaseDataSourceContext {
291
+ /**
292
+ * Whether to filter to only published/complete content
293
+ * Set by site-builder: true for production, false for preview
294
+ */
295
+ publishedOnly?: boolean;
296
+ /**
297
+ * Scoped entity service that auto-applies publishedOnly filter
298
+ * Datasources should use this instead of their injected entityService
299
+ * to ensure consistent filtering behavior across environments
300
+ */
301
+ entityService: EntityService;
302
+ }
303
+ /**
304
+ * DataSource Interface
305
+ *
306
+ * Provides data for templates through fetch, generate, or transform operations.
307
+ * DataSources are registered in the DataSourceRegistry and referenced by templates
308
+ * via their dataSourceId property.
309
+ */
310
+ interface DataSource {
311
+ /**
312
+ * Unique identifier for this data source
313
+ */
314
+ id: string;
315
+ /**
316
+ * Human-readable name for this data source
317
+ */
318
+ name: string;
319
+ /**
320
+ * Optional description of what this data source provides
321
+ */
322
+ description?: string;
323
+ /**
324
+ * Optional: Fetch existing data
325
+ * Used by data sources that aggregate or retrieve data (e.g., dashboard stats, API data)
326
+ * DataSources validate output using the provided schema
327
+ * @param query - Query parameters for fetching data
328
+ * @param outputSchema - Schema for validating output data
329
+ * @param context - Context with environment
330
+ */
331
+ fetch?: <T>(query: unknown, outputSchema: z.ZodSchema<T>, context: BaseDataSourceContext) => Promise<T>;
332
+ /**
333
+ * Optional: Generate new content
334
+ * Used by data sources that create content (e.g., AI-generated content, reports)
335
+ */
336
+ generate?: <T>(request: unknown, schema: z.ZodSchema<T>) => Promise<T>;
337
+ /**
338
+ * Optional: Transform content between formats
339
+ * Used by data sources that convert content (e.g., markdown to HTML, data formatting)
340
+ */
341
+ transform?: <T>(content: unknown, format: string, schema: z.ZodSchema<T>) => Promise<T>;
342
+ }
343
+
344
+ declare const ChatContextSchema: z.ZodObject<{
345
+ userPermissionLevel: z.ZodOptional<z.ZodEnum<["public", "trusted", "anchor"]>>;
346
+ interfaceType: z.ZodOptional<z.ZodString>;
347
+ channelId: z.ZodOptional<z.ZodString>;
348
+ channelName: z.ZodOptional<z.ZodString>;
349
+ }, "strip", z.ZodTypeAny, {
350
+ userPermissionLevel?: "public" | "trusted" | "anchor" | undefined;
351
+ interfaceType?: string | undefined;
352
+ channelId?: string | undefined;
353
+ channelName?: string | undefined;
354
+ }, {
355
+ userPermissionLevel?: "public" | "trusted" | "anchor" | undefined;
356
+ interfaceType?: string | undefined;
357
+ channelId?: string | undefined;
358
+ channelName?: string | undefined;
359
+ }>;
360
+ type ChatContext = z.infer<typeof ChatContextSchema>;
361
+ declare const PendingConfirmationSchema: z.ZodObject<{
362
+ toolName: z.ZodString;
363
+ description: z.ZodString;
364
+ args: z.ZodUnknown;
365
+ }, "strip", z.ZodTypeAny, {
366
+ toolName: string;
367
+ description: string;
368
+ args?: unknown;
369
+ }, {
370
+ toolName: string;
371
+ description: string;
372
+ args?: unknown;
373
+ }>;
374
+ type PendingConfirmation = z.infer<typeof PendingConfirmationSchema>;
375
+ declare const ToolResultDataSchema: z.ZodObject<{
376
+ toolName: z.ZodString;
377
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
378
+ jobId: z.ZodOptional<z.ZodString>;
379
+ data: z.ZodOptional<z.ZodUnknown>;
380
+ }, "strip", z.ZodTypeAny, {
381
+ toolName: string;
382
+ args?: Record<string, unknown> | undefined;
383
+ jobId?: string | undefined;
384
+ data?: unknown;
385
+ }, {
386
+ toolName: string;
387
+ args?: Record<string, unknown> | undefined;
388
+ jobId?: string | undefined;
389
+ data?: unknown;
390
+ }>;
391
+ type ToolResultData = z.infer<typeof ToolResultDataSchema>;
392
+ declare const AgentResponseSchema: z.ZodObject<{
393
+ text: z.ZodString;
394
+ toolResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
395
+ toolName: z.ZodString;
396
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
397
+ jobId: z.ZodOptional<z.ZodString>;
398
+ data: z.ZodOptional<z.ZodUnknown>;
399
+ }, "strip", z.ZodTypeAny, {
400
+ toolName: string;
401
+ args?: Record<string, unknown> | undefined;
402
+ jobId?: string | undefined;
403
+ data?: unknown;
404
+ }, {
405
+ toolName: string;
406
+ args?: Record<string, unknown> | undefined;
407
+ jobId?: string | undefined;
408
+ data?: unknown;
409
+ }>, "many">>;
410
+ pendingConfirmation: z.ZodOptional<z.ZodObject<{
411
+ toolName: z.ZodString;
412
+ description: z.ZodString;
413
+ args: z.ZodUnknown;
414
+ }, "strip", z.ZodTypeAny, {
415
+ toolName: string;
416
+ description: string;
417
+ args?: unknown;
418
+ }, {
419
+ toolName: string;
420
+ description: string;
421
+ args?: unknown;
422
+ }>>;
423
+ usage: z.ZodObject<{
424
+ promptTokens: z.ZodNumber;
425
+ completionTokens: z.ZodNumber;
426
+ totalTokens: z.ZodNumber;
427
+ }, "strip", z.ZodTypeAny, {
428
+ promptTokens: number;
429
+ completionTokens: number;
430
+ totalTokens: number;
431
+ }, {
432
+ promptTokens: number;
433
+ completionTokens: number;
434
+ totalTokens: number;
435
+ }>;
436
+ }, "strip", z.ZodTypeAny, {
437
+ text: string;
438
+ usage: {
439
+ promptTokens: number;
440
+ completionTokens: number;
441
+ totalTokens: number;
442
+ };
443
+ toolResults?: {
444
+ toolName: string;
445
+ args?: Record<string, unknown> | undefined;
446
+ jobId?: string | undefined;
447
+ data?: unknown;
448
+ }[] | undefined;
449
+ pendingConfirmation?: {
450
+ toolName: string;
451
+ description: string;
452
+ args?: unknown;
453
+ } | undefined;
454
+ }, {
455
+ text: string;
456
+ usage: {
457
+ promptTokens: number;
458
+ completionTokens: number;
459
+ totalTokens: number;
460
+ };
461
+ toolResults?: {
462
+ toolName: string;
463
+ args?: Record<string, unknown> | undefined;
464
+ jobId?: string | undefined;
465
+ data?: unknown;
466
+ }[] | undefined;
467
+ pendingConfirmation?: {
468
+ toolName: string;
469
+ description: string;
470
+ args?: unknown;
471
+ } | undefined;
472
+ }>;
473
+ type AgentResponse = z.infer<typeof AgentResponseSchema>;
474
+ interface AgentNamespace {
475
+ chat(message: string, conversationId: string, context?: ChatContext): Promise<AgentResponse>;
476
+ confirmPendingAction(conversationId: string, confirmed: boolean): Promise<AgentResponse>;
477
+ invalidate(): void;
478
+ }
479
+
480
+ declare const AppInfoSchema: z.ZodObject<{
481
+ model: z.ZodString;
482
+ version: z.ZodString;
483
+ uptime: z.ZodNumber;
484
+ entities: z.ZodNumber;
485
+ embeddings: z.ZodNumber;
486
+ ai: z.ZodObject<{
487
+ model: z.ZodString;
488
+ embeddingModel: z.ZodString;
489
+ }, "strip", z.ZodTypeAny, {
490
+ model: string;
491
+ embeddingModel: string;
492
+ }, {
493
+ model: string;
494
+ embeddingModel: string;
495
+ }>;
496
+ daemons: z.ZodArray<z.ZodObject<{
497
+ name: z.ZodString;
498
+ pluginId: z.ZodString;
499
+ status: z.ZodString;
500
+ health: z.ZodOptional<z.ZodObject<{
501
+ status: z.ZodEnum<["healthy", "warning", "error", "unknown"]>;
502
+ message: z.ZodOptional<z.ZodString>;
503
+ lastCheck: z.ZodOptional<z.ZodString>;
504
+ details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
505
+ }, "strip", z.ZodTypeAny, {
506
+ status: "unknown" | "healthy" | "warning" | "error";
507
+ message?: string | undefined;
508
+ lastCheck?: string | undefined;
509
+ details?: Record<string, unknown> | undefined;
510
+ }, {
511
+ status: "unknown" | "healthy" | "warning" | "error";
512
+ message?: string | undefined;
513
+ lastCheck?: string | undefined;
514
+ details?: Record<string, unknown> | undefined;
515
+ }>>;
516
+ }, "strip", z.ZodTypeAny, {
517
+ status: string;
518
+ name: string;
519
+ pluginId: string;
520
+ health?: {
521
+ status: "unknown" | "healthy" | "warning" | "error";
522
+ message?: string | undefined;
523
+ lastCheck?: string | undefined;
524
+ details?: Record<string, unknown> | undefined;
525
+ } | undefined;
526
+ }, {
527
+ status: string;
528
+ name: string;
529
+ pluginId: string;
530
+ health?: {
531
+ status: "unknown" | "healthy" | "warning" | "error";
532
+ message?: string | undefined;
533
+ lastCheck?: string | undefined;
534
+ details?: Record<string, unknown> | undefined;
535
+ } | undefined;
536
+ }>, "many">;
537
+ endpoints: z.ZodArray<z.ZodObject<{
538
+ label: z.ZodString;
539
+ url: z.ZodString;
540
+ pluginId: z.ZodString;
541
+ priority: z.ZodNumber;
542
+ }, "strip", z.ZodTypeAny, {
543
+ pluginId: string;
544
+ label: string;
545
+ url: string;
546
+ priority: number;
547
+ }, {
548
+ pluginId: string;
549
+ label: string;
550
+ url: string;
551
+ priority: number;
552
+ }>, "many">;
553
+ }, "strip", z.ZodTypeAny, {
554
+ model: string;
555
+ version: string;
556
+ uptime: number;
557
+ entities: number;
558
+ embeddings: number;
559
+ ai: {
560
+ model: string;
561
+ embeddingModel: string;
562
+ };
563
+ daemons: {
564
+ status: string;
565
+ name: string;
566
+ pluginId: string;
567
+ health?: {
568
+ status: "unknown" | "healthy" | "warning" | "error";
569
+ message?: string | undefined;
570
+ lastCheck?: string | undefined;
571
+ details?: Record<string, unknown> | undefined;
572
+ } | undefined;
573
+ }[];
574
+ endpoints: {
575
+ pluginId: string;
576
+ label: string;
577
+ url: string;
578
+ priority: number;
579
+ }[];
580
+ }, {
581
+ model: string;
582
+ version: string;
583
+ uptime: number;
584
+ entities: number;
585
+ embeddings: number;
586
+ ai: {
587
+ model: string;
588
+ embeddingModel: string;
589
+ };
590
+ daemons: {
591
+ status: string;
592
+ name: string;
593
+ pluginId: string;
594
+ health?: {
595
+ status: "unknown" | "healthy" | "warning" | "error";
596
+ message?: string | undefined;
597
+ lastCheck?: string | undefined;
598
+ details?: Record<string, unknown> | undefined;
599
+ } | undefined;
600
+ }[];
601
+ endpoints: {
602
+ pluginId: string;
603
+ label: string;
604
+ url: string;
605
+ priority: number;
606
+ }[];
607
+ }>;
608
+ type AppInfo = z.infer<typeof AppInfoSchema>;
609
+
610
+ declare const ConversationSchema: z.ZodObject<{
611
+ id: z.ZodString;
612
+ sessionId: z.ZodString;
613
+ interfaceType: z.ZodString;
614
+ channelId: z.ZodString;
615
+ channelName: z.ZodOptional<z.ZodString>;
616
+ startedAt: z.ZodString;
617
+ lastActiveAt: z.ZodString;
618
+ createdAt: z.ZodString;
619
+ updatedAt: z.ZodString;
620
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
621
+ }, "strip", z.ZodTypeAny, {
622
+ interfaceType: string;
623
+ channelId: string;
624
+ id: string;
625
+ sessionId: string;
626
+ startedAt: string;
627
+ lastActiveAt: string;
628
+ createdAt: string;
629
+ updatedAt: string;
630
+ metadata: Record<string, unknown>;
631
+ channelName?: string | undefined;
632
+ }, {
633
+ interfaceType: string;
634
+ channelId: string;
635
+ id: string;
636
+ sessionId: string;
637
+ startedAt: string;
638
+ lastActiveAt: string;
639
+ createdAt: string;
640
+ updatedAt: string;
641
+ metadata: Record<string, unknown>;
642
+ channelName?: string | undefined;
643
+ }>;
644
+ type Conversation = z.infer<typeof ConversationSchema>;
645
+ declare const messageRoleSchema: z.ZodEnum<["user", "assistant", "system"]>;
646
+ type MessageRole = z.infer<typeof messageRoleSchema>;
647
+ declare const MessageSchema: z.ZodObject<{
648
+ id: z.ZodString;
649
+ conversationId: z.ZodString;
650
+ role: z.ZodEnum<["user", "assistant", "system"]>;
651
+ content: z.ZodString;
652
+ timestamp: z.ZodString;
653
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
654
+ }, "strip", z.ZodTypeAny, {
655
+ id: string;
656
+ metadata: Record<string, unknown>;
657
+ conversationId: string;
658
+ role: "user" | "assistant" | "system";
659
+ content: string;
660
+ timestamp: string;
661
+ }, {
662
+ id: string;
663
+ metadata: Record<string, unknown>;
664
+ conversationId: string;
665
+ role: "user" | "assistant" | "system";
666
+ content: string;
667
+ timestamp: string;
668
+ }>;
669
+ type Message = z.infer<typeof MessageSchema>;
670
+
671
+ declare const BrainCharacterSchema: z.ZodObject<{
672
+ name: z.ZodString;
673
+ role: z.ZodString;
674
+ purpose: z.ZodString;
675
+ values: z.ZodArray<z.ZodString, "many">;
676
+ }, "strip", z.ZodTypeAny, {
677
+ values: string[];
678
+ name: string;
679
+ role: string;
680
+ purpose: string;
681
+ }, {
682
+ values: string[];
683
+ name: string;
684
+ role: string;
685
+ purpose: string;
686
+ }>;
687
+ type BrainCharacter = z.infer<typeof BrainCharacterSchema>;
688
+ declare const AnchorProfileSchema: z.ZodObject<{
689
+ name: z.ZodString;
690
+ kind: z.ZodEnum<["professional", "team", "collective"]>;
691
+ organization: z.ZodOptional<z.ZodString>;
692
+ description: z.ZodOptional<z.ZodString>;
693
+ avatar: z.ZodOptional<z.ZodString>;
694
+ website: z.ZodOptional<z.ZodString>;
695
+ email: z.ZodOptional<z.ZodString>;
696
+ socialLinks: z.ZodOptional<z.ZodArray<z.ZodObject<{
697
+ platform: z.ZodEnum<["github", "instagram", "linkedin", "email", "website"]>;
698
+ url: z.ZodString;
699
+ label: z.ZodOptional<z.ZodString>;
700
+ }, "strip", z.ZodTypeAny, {
701
+ url: string;
702
+ platform: "website" | "email" | "github" | "instagram" | "linkedin";
703
+ label?: string | undefined;
704
+ }, {
705
+ url: string;
706
+ platform: "website" | "email" | "github" | "instagram" | "linkedin";
707
+ label?: string | undefined;
708
+ }>, "many">>;
709
+ }, "strip", z.ZodTypeAny, {
710
+ name: string;
711
+ kind: "professional" | "team" | "collective";
712
+ description?: string | undefined;
713
+ organization?: string | undefined;
714
+ avatar?: string | undefined;
715
+ website?: string | undefined;
716
+ email?: string | undefined;
717
+ socialLinks?: {
718
+ url: string;
719
+ platform: "website" | "email" | "github" | "instagram" | "linkedin";
720
+ label?: string | undefined;
721
+ }[] | undefined;
722
+ }, {
723
+ name: string;
724
+ kind: "professional" | "team" | "collective";
725
+ description?: string | undefined;
726
+ organization?: string | undefined;
727
+ avatar?: string | undefined;
728
+ website?: string | undefined;
729
+ email?: string | undefined;
730
+ socialLinks?: {
731
+ url: string;
732
+ platform: "website" | "email" | "github" | "instagram" | "linkedin";
733
+ label?: string | undefined;
734
+ }[] | undefined;
735
+ }>;
736
+ type AnchorProfile = z.infer<typeof AnchorProfileSchema>;
737
+
738
+ /**
739
+ * Best-effort extension metadata carried across public DTO boundaries.
740
+ *
741
+ * Individual keys are not stable public API. When a metadata value becomes a
742
+ * documented contract, hoist it to a typed top-level field on the owning DTO
743
+ * schema and keep this bag only as optional extension data.
744
+ */
745
+ declare const ExtensionMetadataSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
746
+ type ExtensionMetadata = z.infer<typeof ExtensionMetadataSchema>;
747
+
748
+ declare const MessageResponseSchema: z.ZodUnion<[z.ZodObject<{
749
+ success: z.ZodBoolean;
750
+ data: z.ZodOptional<z.ZodUnknown>;
751
+ error: z.ZodOptional<z.ZodString>;
752
+ }, "strip", z.ZodTypeAny, {
753
+ success: boolean;
754
+ data?: unknown;
755
+ error?: string | undefined;
756
+ }, {
757
+ success: boolean;
758
+ data?: unknown;
759
+ error?: string | undefined;
760
+ }>, z.ZodObject<{
761
+ noop: z.ZodLiteral<true>;
762
+ }, "strip", z.ZodTypeAny, {
763
+ noop: true;
764
+ }, {
765
+ noop: true;
766
+ }>]>;
767
+ type MessageResponse<T = unknown> = ({
768
+ success: boolean;
769
+ error?: string | undefined;
770
+ } & {
771
+ data?: T | undefined;
772
+ }) | {
773
+ noop: true;
774
+ };
775
+ declare const BaseMessageSchema: z.ZodObject<{
776
+ id: z.ZodString;
777
+ timestamp: z.ZodString;
778
+ type: z.ZodString;
779
+ source: z.ZodString;
780
+ target: z.ZodOptional<z.ZodString>;
781
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
782
+ }, "strip", z.ZodTypeAny, {
783
+ type: string;
784
+ id: string;
785
+ timestamp: string;
786
+ source: string;
787
+ metadata?: Record<string, unknown> | undefined;
788
+ target?: string | undefined;
789
+ }, {
790
+ type: string;
791
+ id: string;
792
+ timestamp: string;
793
+ source: string;
794
+ metadata?: Record<string, unknown> | undefined;
795
+ target?: string | undefined;
796
+ }>;
797
+ type BaseMessage = z.infer<typeof BaseMessageSchema>;
798
+ type MessageWithPayload<T = unknown> = BaseMessage & {
799
+ payload: T;
800
+ };
801
+ interface MessageSendOptions {
802
+ target?: string;
803
+ metadata?: z.infer<typeof ExtensionMetadataSchema>;
804
+ broadcast?: boolean;
805
+ }
806
+ interface MessageSendRequest<T = unknown> extends MessageSendOptions {
807
+ type: string;
808
+ payload: T;
809
+ }
810
+ type MessageSender<T = unknown, R = unknown> = (request: MessageSendRequest<T>) => Promise<MessageResponse<R>>;
811
+ interface MessageContext {
812
+ userId?: string;
813
+ channelId?: string;
814
+ messageId?: string;
815
+ timestamp?: string;
816
+ interfaceType?: string;
817
+ userPermissionLevel?: "public" | "trusted" | "anchor";
818
+ threadId?: string;
819
+ }
820
+
821
+ type PluginConfig = Record<string, unknown>;
822
+ type PluginConfigInput<T extends z.ZodTypeAny> = z.input<T>;
823
+ interface Plugin {
824
+ readonly id: string;
825
+ readonly version: string;
826
+ readonly type: "core" | "entity" | "service" | "interface";
827
+ readonly packageName: string;
828
+ readonly description?: string;
829
+ readonly dependencies?: string[];
830
+ ready?(): Promise<void>;
831
+ shutdown?(): Promise<void>;
832
+ requiresDaemonStartup?(): boolean;
833
+ }
834
+ type PluginFactory = (config: PluginConfig) => Plugin | Plugin[];
835
+ interface Logger {
836
+ debug(message: string, data?: unknown): void;
837
+ info(message: string, data?: unknown): void;
838
+ warn(message: string, data?: unknown): void;
839
+ error(message: string, data?: unknown): void;
840
+ child(context: string): Logger;
841
+ }
842
+ interface ToolContext {
843
+ progressToken?: string | number;
844
+ sendProgress?: (notification: {
845
+ progress?: number;
846
+ total?: number;
847
+ message?: string;
848
+ }) => Promise<void>;
849
+ interfaceType?: string;
850
+ userId?: string;
851
+ channelId?: string;
852
+ channelName?: string;
853
+ }
854
+ interface ToolResponse<T = unknown> {
855
+ success: boolean;
856
+ data?: T;
857
+ error?: string;
858
+ }
859
+ type ToolVisibility = "public" | "trusted" | "anchor";
860
+ interface ToolConfirmation {
861
+ required: boolean;
862
+ message?: string;
863
+ }
864
+ interface Tool<TArgs = unknown, TResult = unknown> {
865
+ name: string;
866
+ description: string;
867
+ inputSchema: z.ZodRawShape;
868
+ handler: (args: TArgs, context: ToolContext) => Promise<TResult> | TResult;
869
+ visibility?: ToolVisibility;
870
+ confirmation?: ToolConfirmation;
871
+ }
872
+ interface Resource<TResult = unknown> {
873
+ uri: string;
874
+ name: string;
875
+ description?: string;
876
+ mimeType?: string;
877
+ handler: () => Promise<TResult> | TResult;
878
+ }
879
+ interface ResourceTemplate<K extends string = string> {
880
+ uriTemplate: K;
881
+ name: string;
882
+ description?: string;
883
+ mimeType?: string;
884
+ }
885
+ interface Prompt {
886
+ name: string;
887
+ description?: string;
888
+ arguments?: Array<{
889
+ name: string;
890
+ description?: string;
891
+ required?: boolean;
892
+ }>;
893
+ }
894
+ declare function createTool<TArgs = unknown, TResult = unknown>(tool: Tool<TArgs, TResult>): Tool<TArgs, TResult>;
895
+ declare function createResource<TResult = unknown>(resource: Resource<TResult>): Resource<TResult>;
896
+ declare function toolSuccess<T = unknown>(data?: T): ToolResponse<T>;
897
+ declare function toolError(error: string): ToolResponse<never>;
898
+ interface BaseJobTrackingInfo {
899
+ rootJobId: string;
900
+ }
901
+ interface MessageJobTrackingInfo extends BaseJobTrackingInfo {
902
+ messageId?: string;
903
+ channelId?: string;
904
+ }
905
+ type JobProgressStatus = "pending" | "processing" | "completed" | "failed";
906
+ interface JobProgressContext {
907
+ rootJobId: string;
908
+ operationType: "file_operations" | "content_operations" | "data_processing" | "batch_processing";
909
+ pluginId?: string | undefined;
910
+ progressToken?: string | number | undefined;
911
+ operationTarget?: string | undefined;
912
+ interfaceType?: string | undefined;
913
+ channelId?: string | undefined;
914
+ }
915
+ interface JobProgressEvent {
916
+ id: string;
917
+ type: "job" | "batch";
918
+ status: JobProgressStatus;
919
+ message?: string | undefined;
920
+ progress?: {
921
+ current: number;
922
+ total: number;
923
+ percentage: number;
924
+ } | undefined;
925
+ aggregationKey?: string | undefined;
926
+ batchDetails?: {
927
+ totalOperations: number;
928
+ completedOperations: number;
929
+ failedOperations: number;
930
+ currentOperation?: string | undefined;
931
+ errors?: string[] | undefined;
932
+ } | undefined;
933
+ jobDetails?: {
934
+ jobType: string;
935
+ priority: number;
936
+ retryCount: number;
937
+ } | undefined;
938
+ metadata: JobProgressContext;
939
+ }
940
+ declare const urlCaptureConfigSchema: z.ZodObject<{
941
+ captureUrls: z.ZodDefault<z.ZodBoolean>;
942
+ blockedUrlDomains: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
943
+ }, "strip", z.ZodTypeAny, {
944
+ captureUrls: boolean;
945
+ blockedUrlDomains: string[];
946
+ }, {
947
+ captureUrls?: boolean | undefined;
948
+ blockedUrlDomains?: string[] | undefined;
949
+ }>;
950
+ interface Channel<TPayload, TResponse = unknown> {
951
+ readonly name: string;
952
+ readonly schema: z.ZodType<TPayload>;
953
+ readonly _response?: TResponse;
954
+ }
955
+ declare function defineChannel<TPayload, TResponse = unknown>(name: string, schema: z.ZodType<TPayload>): Channel<TPayload, TResponse>;
956
+ interface GetEntityRequest {
957
+ entityType: string;
958
+ id: string;
959
+ }
960
+ interface ListEntitiesRequest {
961
+ entityType: string;
962
+ options?: unknown;
963
+ }
964
+ interface CountEntitiesRequest {
965
+ entityType: string;
966
+ options?: unknown;
967
+ }
968
+ interface EntitySearchRequest {
969
+ query: string;
970
+ options?: unknown;
971
+ }
972
+ interface IEntityService {
973
+ getEntity<T = unknown>(request: GetEntityRequest): Promise<T | null>;
974
+ listEntities<T = unknown>(request: ListEntitiesRequest): Promise<T[]>;
975
+ search<T = unknown>(request: EntitySearchRequest): Promise<T[]>;
976
+ getEntityTypes(): string[];
977
+ hasEntityType(type: string): boolean;
978
+ countEntities(request: CountEntitiesRequest): Promise<number>;
979
+ getEntityCounts(): Promise<Array<{
980
+ entityType: string;
981
+ count: number;
982
+ }>>;
983
+ }
984
+ interface IIdentityNamespace {
985
+ get: () => BrainCharacter;
986
+ getProfile: () => AnchorProfile;
987
+ getAppInfo: () => Promise<AppInfo>;
988
+ }
989
+ interface IConversationsNamespace {
990
+ get(conversationId: string): Promise<Conversation | null>;
991
+ search(query: string): Promise<Conversation[]>;
992
+ list(options?: {
993
+ limit?: number;
994
+ updatedAfter?: string;
995
+ }): Promise<Conversation[]>;
996
+ getMessages(conversationId: string, options?: {
997
+ limit?: number;
998
+ range?: {
999
+ start: number;
1000
+ end: number;
1001
+ };
1002
+ }): Promise<Message[]>;
1003
+ }
1004
+ interface IMessagingNamespace {
1005
+ send: MessageSender;
1006
+ subscribe<T = unknown, R = unknown>(channel: string | Channel<T, R>, handler: (message: MessageWithPayload<T>) => Promise<MessageResponse<R>>): () => void;
1007
+ }
1008
+ type EvalHandler<TInput = unknown, TOutput = unknown> = (input: TInput) => Promise<TOutput>;
1009
+ type InsightHandler = (entityService: IEntityService) => Promise<Record<string, unknown>>;
1010
+ interface IEvalNamespace {
1011
+ registerHandler<TInput = unknown, TOutput = unknown>(handlerId: string, handler: EvalHandler<TInput, TOutput>): void;
1012
+ }
1013
+ interface IInsightsNamespace {
1014
+ register(type: string, handler: InsightHandler): void;
1015
+ }
1016
+ interface BasePluginContext {
1017
+ readonly pluginId: string;
1018
+ readonly logger: Logger;
1019
+ readonly dataDir: string;
1020
+ readonly domain: string | undefined;
1021
+ readonly siteUrl: string | undefined;
1022
+ readonly previewUrl: string | undefined;
1023
+ readonly appInfo: () => Promise<AppInfo>;
1024
+ readonly entityService: IEntityService;
1025
+ readonly identity: IIdentityNamespace;
1026
+ readonly messaging: IMessagingNamespace;
1027
+ readonly conversations: IConversationsNamespace;
1028
+ readonly eval: IEvalNamespace;
1029
+ readonly insights: IInsightsNamespace;
1030
+ }
1031
+ interface IEntitiesNamespace {
1032
+ register<TEntity extends BaseEntity>(entityType: string, schema: z.ZodSchema<TEntity>, adapter: EntityAdapter<TEntity>, config?: EntityTypeConfig): void;
1033
+ getAdapter<TEntity extends BaseEntity>(entityType: string): EntityAdapter<TEntity> | undefined;
1034
+ update<TEntity extends BaseEntity>(entity: TEntity): Promise<{
1035
+ entityId: string;
1036
+ jobId: string;
1037
+ }>;
1038
+ registerDataSource(dataSource: DataSource): void;
1039
+ registerCreateInterceptor(entityType: string, interceptor: (input: CreateInput, executionContext: CreateExecutionContext) => Promise<CreateInterceptionResult>): void;
1040
+ }
1041
+ interface IPromptsNamespace {
1042
+ resolve(target: string, fallback: string): Promise<string>;
1043
+ }
1044
+ interface IServiceTemplatesNamespace {
1045
+ register(templates: unknown): void;
1046
+ }
1047
+ interface IViewsNamespace {
1048
+ register(views: unknown): void;
1049
+ }
1050
+ interface ServicePluginContext extends BasePluginContext {
1051
+ readonly entities: IEntitiesNamespace;
1052
+ readonly templates: IServiceTemplatesNamespace;
1053
+ readonly views: IViewsNamespace;
1054
+ readonly prompts: IPromptsNamespace;
1055
+ registerInstructions(instructions: string): void;
1056
+ }
1057
+ interface EntityPluginContext extends BasePluginContext {
1058
+ readonly entities: IEntitiesNamespace;
1059
+ readonly prompts: IPromptsNamespace;
1060
+ }
1061
+ interface InterfacePluginContext extends BasePluginContext {
1062
+ readonly agent: AgentNamespace;
1063
+ }
1064
+
1065
+ declare abstract class EntityPlugin<TEntity extends BaseEntity = BaseEntity, TConfig = unknown> implements Plugin {
1066
+ readonly type: "entity";
1067
+ readonly id: string;
1068
+ readonly version: string;
1069
+ readonly packageName: string;
1070
+ readonly description?: string;
1071
+ abstract readonly entityType: string;
1072
+ abstract readonly schema: z.ZodSchema<TEntity>;
1073
+ abstract readonly adapter: EntityAdapter<TEntity>;
1074
+ private readonly delegate;
1075
+ protected constructor(id: string, packageJson: {
1076
+ name: string;
1077
+ version: string;
1078
+ description?: string;
1079
+ }, config: Partial<TConfig>, configSchema: z.ZodTypeAny);
1080
+ protected onRegister(_context: EntityPluginContext): Promise<void>;
1081
+ protected onReady(_context: EntityPluginContext): Promise<void>;
1082
+ protected onShutdown(): Promise<void>;
1083
+ protected getInstructions(): Promise<string | undefined>;
1084
+ protected getEntityTypeConfig(): EntityTypeConfig | undefined;
1085
+ protected getDataSources(): DataSource[];
1086
+ protected interceptCreate(input: CreateInput, _executionContext: CreateExecutionContext, _context: EntityPluginContext): Promise<CreateInterceptionResult>;
1087
+ ready(): Promise<void>;
1088
+ shutdown(): Promise<void>;
1089
+ }
1090
+
1091
+ declare const WebRouteMethods: readonly ["GET", "POST", "PUT", "DELETE", "OPTIONS"];
1092
+ type WebRouteMethod = (typeof WebRouteMethods)[number];
1093
+ type WebRouteHandler = (request: Request) => Response | Promise<Response>;
1094
+ interface WebRouteDefinition {
1095
+ /** Absolute mounted path (e.g. "/cms" or "/cms-config") */
1096
+ path: string;
1097
+ /** HTTP method */
1098
+ method?: WebRouteMethod;
1099
+ /** Allow unauthenticated access */
1100
+ public?: boolean;
1101
+ /** Request handler */
1102
+ handler: WebRouteHandler;
1103
+ }
1104
+
1105
+ declare abstract class InterfacePlugin<TConfig = unknown, TTrackingInfo extends BaseJobTrackingInfo = BaseJobTrackingInfo> implements Plugin {
1106
+ readonly type: "interface";
1107
+ readonly id: string;
1108
+ readonly version: string;
1109
+ readonly packageName: string;
1110
+ readonly description?: string;
1111
+ private readonly delegate;
1112
+ protected constructor(id: string, packageJson: {
1113
+ name: string;
1114
+ version: string;
1115
+ description?: string;
1116
+ }, config: Partial<TConfig>, configSchema: z.ZodTypeAny);
1117
+ protected onRegister(_context: InterfacePluginContext): Promise<void>;
1118
+ protected onReady(_context: InterfacePluginContext): Promise<void>;
1119
+ protected onShutdown(): Promise<void>;
1120
+ protected getTools(): Promise<Tool[]>;
1121
+ protected getResources(): Promise<Resource[]>;
1122
+ protected getInstructions(): Promise<string | undefined>;
1123
+ getWebRoutes(): WebRouteDefinition[];
1124
+ requiresDaemonStartup(): boolean;
1125
+ ready(): Promise<void>;
1126
+ shutdown(): Promise<void>;
1127
+ }
1128
+
1129
+ interface SendMessageToChannelRequest {
1130
+ /** The channel/room to send to (null for single-channel interfaces like CLI) */
1131
+ channelId: string | null;
1132
+ /** The message to send */
1133
+ message: string;
1134
+ }
1135
+ type SendMessageWithIdRequest = SendMessageToChannelRequest;
1136
+ interface EditMessageRequest {
1137
+ channelId: string | null;
1138
+ messageId: string;
1139
+ newMessage: string;
1140
+ }
1141
+
1142
+ declare abstract class MessageInterfacePlugin<TConfig = unknown, TTrackingInfo extends MessageJobTrackingInfo = MessageJobTrackingInfo> extends InterfacePlugin<TConfig, TTrackingInfo> {
1143
+ private readonly messageDelegate;
1144
+ protected constructor(id: string, packageJson: {
1145
+ name: string;
1146
+ version: string;
1147
+ description?: string;
1148
+ }, config: Partial<TConfig>, configSchema: z.ZodTypeAny);
1149
+ protected abstract sendMessageToChannel(request: SendMessageToChannelRequest): void;
1150
+ protected onRegister(_context: InterfacePluginContext): Promise<void>;
1151
+ protected onReady(_context: InterfacePluginContext): Promise<void>;
1152
+ protected onShutdown(): Promise<void>;
1153
+ protected getTools(): Promise<Tool[]>;
1154
+ protected getResources(): Promise<Resource[]>;
1155
+ protected getInstructions(): Promise<string | undefined>;
1156
+ protected sendMessageWithId(_request: SendMessageWithIdRequest): Promise<string | undefined>;
1157
+ protected editMessage(_request: EditMessageRequest): Promise<boolean>;
1158
+ protected supportsMessageEditing(): boolean;
1159
+ protected onProgressUpdate(_event: JobProgressEvent): Promise<void>;
1160
+ protected trackAgentResponseForJob(jobId: string, messageId: string, channelId: string): void;
1161
+ registerProgressCallback(callback: (events: JobProgressEvent[]) => void): void;
1162
+ unregisterProgressCallback(): void;
1163
+ getProgressEvents(): JobProgressEvent[];
1164
+ getActiveProgressEvents(): JobProgressEvent[];
1165
+ startProcessingInput(channelId?: string | null): void;
1166
+ endProcessingInput(): void;
1167
+ protected getCurrentChannelId(): string | null;
1168
+ ready(): Promise<void>;
1169
+ shutdown(): Promise<void>;
1170
+ }
1171
+
1172
+ declare abstract class ServicePlugin<TConfig = unknown> implements Plugin {
1173
+ readonly type: "service";
1174
+ readonly id: string;
1175
+ readonly version: string;
1176
+ readonly packageName: string;
1177
+ readonly description?: string;
1178
+ private readonly delegate;
1179
+ protected constructor(id: string, packageJson: {
1180
+ name: string;
1181
+ version: string;
1182
+ description?: string;
1183
+ }, config: Partial<TConfig>, configSchema: z.ZodTypeAny);
1184
+ protected onRegister(_context: ServicePluginContext): Promise<void>;
1185
+ protected onReady(_context: ServicePluginContext): Promise<void>;
1186
+ protected onShutdown(): Promise<void>;
1187
+ protected getTools(): Promise<Tool[]>;
1188
+ protected getResources(): Promise<Resource[]>;
1189
+ protected getInstructions(): Promise<string | undefined>;
1190
+ ready(): Promise<void>;
1191
+ shutdown(): Promise<void>;
1192
+ }
1193
+
1194
+ export { AgentResponseSchema, AnchorProfileSchema, AppInfoSchema, BaseMessageSchema, BrainCharacterSchema, ChatContextSchema, ConversationSchema, EntityPlugin, ExtensionMetadataSchema, InterfacePlugin, MessageInterfacePlugin, MessageResponseSchema, MessageSchema, PendingConfirmationSchema, ServicePlugin, ToolResultDataSchema, createResource, createTool, defineChannel, toolError, toolSuccess, urlCaptureConfigSchema };
1195
+ export type { AgentNamespace, AgentResponse, AnchorProfile, AppInfo, BaseJobTrackingInfo, BaseMessage, BasePluginContext, BrainCharacter, Channel, ChatContext, Conversation, EntityPluginContext, ExtensionMetadata, IConversationsNamespace, IEntitiesNamespace, IEvalNamespace, IIdentityNamespace, IInsightsNamespace, IMessagingNamespace, IPromptsNamespace, IServiceTemplatesNamespace, IViewsNamespace, InterfacePluginContext, JobProgressContext, JobProgressEvent, JobProgressStatus, Message, MessageContext, MessageJobTrackingInfo, MessageResponse, MessageRole, MessageSendOptions, MessageSender, MessageWithPayload, PendingConfirmation, Plugin, PluginConfig, PluginConfigInput, PluginFactory, Prompt, Resource, ResourceTemplate, ServicePluginContext, Tool, ToolConfirmation, ToolContext, ToolResponse, ToolResultData, ToolVisibility };