@rizom/brain 0.2.0-alpha.62 → 0.2.0-alpha.63
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 +814 -731
- package/dist/entities.d.ts +71 -69
- package/dist/entities.js.map +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +28 -28
- package/dist/interfaces.js.map +2 -2
- package/dist/plugins.d.ts +196 -120
- package/dist/plugins.js +100 -100
- package/dist/plugins.js.map +16 -13
- package/dist/services.d.ts +73 -61
- package/dist/services.js.map +2 -2
- package/dist/site.js +105 -105
- package/dist/site.js.map +13 -13
- package/package.json +1 -1
package/dist/plugins.d.ts
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Context passed to all DataSource operations
|
|
5
|
+
* Contains internal state that should not be mixed with user query parameters
|
|
6
|
+
*/
|
|
7
|
+
interface BaseDataSourceContext {
|
|
8
|
+
/**
|
|
9
|
+
* Whether to filter to only published/complete content
|
|
10
|
+
* Set by site-builder: true for production, false for preview
|
|
11
|
+
*/
|
|
12
|
+
publishedOnly?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Scoped entity service that auto-applies publishedOnly filter
|
|
15
|
+
* Datasources should use this instead of their injected entityService
|
|
16
|
+
* to ensure consistent filtering behavior across environments
|
|
17
|
+
*/
|
|
18
|
+
entityService: EntityService;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* DataSource Interface
|
|
22
|
+
*
|
|
23
|
+
* Provides data for templates through fetch, generate, or transform operations.
|
|
24
|
+
* DataSources are registered in the DataSourceRegistry and referenced by templates
|
|
25
|
+
* via their dataSourceId property.
|
|
26
|
+
*/
|
|
27
|
+
interface DataSource {
|
|
28
|
+
/**
|
|
29
|
+
* Unique identifier for this data source
|
|
30
|
+
*/
|
|
31
|
+
id: string;
|
|
32
|
+
/**
|
|
33
|
+
* Human-readable name for this data source
|
|
34
|
+
*/
|
|
35
|
+
name: string;
|
|
36
|
+
/**
|
|
37
|
+
* Optional description of what this data source provides
|
|
38
|
+
*/
|
|
39
|
+
description?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Optional: Fetch existing data
|
|
42
|
+
* Used by data sources that aggregate or retrieve data (e.g., dashboard stats, API data)
|
|
43
|
+
* DataSources validate output using the provided schema
|
|
44
|
+
* @param query - Query parameters for fetching data
|
|
45
|
+
* @param outputSchema - Schema for validating output data
|
|
46
|
+
* @param context - Context with environment
|
|
47
|
+
*/
|
|
48
|
+
fetch?: <T>(query: unknown, outputSchema: z.ZodSchema<T>, context: BaseDataSourceContext) => Promise<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Optional: Generate new content
|
|
51
|
+
* Used by data sources that create content (e.g., AI-generated content, reports)
|
|
52
|
+
*/
|
|
53
|
+
generate?: <T>(request: unknown, schema: z.ZodSchema<T>) => Promise<T>;
|
|
54
|
+
/**
|
|
55
|
+
* Optional: Transform content between formats
|
|
56
|
+
* Used by data sources that convert content (e.g., markdown to HTML, data formatting)
|
|
57
|
+
*/
|
|
58
|
+
transform?: <T>(content: unknown, format: string, schema: z.ZodSchema<T>) => Promise<T>;
|
|
59
|
+
}
|
|
60
|
+
|
|
3
61
|
/**
|
|
4
62
|
* Options for entity mutation operations (create, update, upsert)
|
|
5
63
|
*/
|
|
@@ -116,6 +174,7 @@ type CreateInterceptionResult = {
|
|
|
116
174
|
kind: "continue";
|
|
117
175
|
input: CreateInput;
|
|
118
176
|
};
|
|
177
|
+
type CreateInterceptor = (input: CreateInput, executionContext: CreateExecutionContext) => Promise<CreateInterceptionResult>;
|
|
119
178
|
/**
|
|
120
179
|
* Interface for entity adapter - handles conversion between entities and markdown
|
|
121
180
|
* following the hybrid storage model
|
|
@@ -192,21 +251,24 @@ interface EntityTypeConfig {
|
|
|
192
251
|
/** Whether to generate embeddings for this entity type (default: true).
|
|
193
252
|
* Set to false for entity types with non-textual content (e.g., images). */
|
|
194
253
|
embeddable?: boolean;
|
|
254
|
+
/** Whether this entity type may be used as source material for derived projections (default: true).
|
|
255
|
+
* Set to false for projection outputs that would create feedback loops. */
|
|
256
|
+
projectionSource?: boolean;
|
|
195
257
|
}
|
|
196
258
|
/**
|
|
197
259
|
* Core entity service interface for read-only operations
|
|
198
260
|
* Used by core plugins that need entity access but shouldn't modify entities
|
|
199
261
|
*/
|
|
200
|
-
interface GetEntityRequest
|
|
262
|
+
interface GetEntityRequest {
|
|
201
263
|
entityType: string;
|
|
202
264
|
id: string;
|
|
203
265
|
}
|
|
204
|
-
type GetEntityRawRequest = GetEntityRequest
|
|
205
|
-
interface ListEntitiesRequest
|
|
266
|
+
type GetEntityRawRequest = GetEntityRequest;
|
|
267
|
+
interface ListEntitiesRequest {
|
|
206
268
|
entityType: string;
|
|
207
269
|
options?: ListOptions | undefined;
|
|
208
270
|
}
|
|
209
|
-
interface CountEntitiesRequest
|
|
271
|
+
interface CountEntitiesRequest {
|
|
210
272
|
entityType: string;
|
|
211
273
|
options?: Pick<ListOptions, "publishedOnly" | "filter"> | undefined;
|
|
212
274
|
}
|
|
@@ -230,7 +292,7 @@ interface UpsertEntityRequest<T extends BaseEntity> {
|
|
|
230
292
|
entity: T;
|
|
231
293
|
options?: EntityJobOptions | undefined;
|
|
232
294
|
}
|
|
233
|
-
interface EntitySearchRequest
|
|
295
|
+
interface EntitySearchRequest {
|
|
234
296
|
query: string;
|
|
235
297
|
options?: SearchOptions | undefined;
|
|
236
298
|
}
|
|
@@ -238,27 +300,48 @@ interface SearchWithDistancesRequest {
|
|
|
238
300
|
query: string;
|
|
239
301
|
}
|
|
240
302
|
interface ICoreEntityService {
|
|
241
|
-
getEntity<T extends BaseEntity>(request: GetEntityRequest
|
|
303
|
+
getEntity<T extends BaseEntity>(request: GetEntityRequest): Promise<T | null>;
|
|
242
304
|
/**
|
|
243
305
|
* Get entity without content resolution (raw)
|
|
244
306
|
* Used internally to avoid recursion when resolving image references
|
|
245
307
|
*/
|
|
246
308
|
getEntityRaw<T extends BaseEntity>(request: GetEntityRawRequest): Promise<T | null>;
|
|
247
|
-
listEntities<T extends BaseEntity>(request: ListEntitiesRequest
|
|
248
|
-
search<T extends BaseEntity = BaseEntity>(request: EntitySearchRequest
|
|
309
|
+
listEntities<T extends BaseEntity>(request: ListEntitiesRequest): Promise<T[]>;
|
|
310
|
+
search<T extends BaseEntity = BaseEntity>(request: EntitySearchRequest): Promise<SearchResult<T>[]>;
|
|
249
311
|
getEntityTypes(): string[];
|
|
250
312
|
hasEntityType(type: string): boolean;
|
|
251
|
-
countEntities(request: CountEntitiesRequest
|
|
313
|
+
countEntities(request: CountEntitiesRequest): Promise<number>;
|
|
252
314
|
getEntityCounts(): Promise<Array<{
|
|
253
315
|
entityType: string;
|
|
254
316
|
count: number;
|
|
255
317
|
}>>;
|
|
318
|
+
/** Get configuration for a specific entity type */
|
|
319
|
+
getEntityTypeConfig(type: string): EntityTypeConfig;
|
|
256
320
|
/** Get weight map for all registered entity types with non-default weights */
|
|
257
321
|
getWeightMap(): Record<string, number>;
|
|
258
322
|
}
|
|
259
323
|
/**
|
|
260
324
|
* Entity service interface for managing brain entities
|
|
261
325
|
*/
|
|
326
|
+
interface IEntitiesNamespace {
|
|
327
|
+
/** Register a new entity type with schema and adapter */
|
|
328
|
+
register<TEntity extends BaseEntity>(entityType: string, schema: z.ZodSchema<TEntity>, adapter: EntityAdapter<TEntity>, config?: EntityTypeConfig): void;
|
|
329
|
+
/** Get the adapter for an entity type */
|
|
330
|
+
getAdapter<TEntity extends BaseEntity>(entityType: string): EntityAdapter<TEntity> | undefined;
|
|
331
|
+
/** Extend an adapter's frontmatterSchema with additional fields */
|
|
332
|
+
extendFrontmatterSchema(type: string, extension: z.ZodObject<z.ZodRawShape>): void;
|
|
333
|
+
/** Get effective frontmatter schema (base + extensions) for an entity type */
|
|
334
|
+
getEffectiveFrontmatterSchema(type: string): z.ZodObject<z.ZodRawShape> | undefined;
|
|
335
|
+
/** Update an existing entity */
|
|
336
|
+
update<TEntity extends BaseEntity>(entity: TEntity): Promise<{
|
|
337
|
+
entityId: string;
|
|
338
|
+
jobId: string;
|
|
339
|
+
}>;
|
|
340
|
+
/** Register a data source for dynamic content */
|
|
341
|
+
registerDataSource(dataSource: DataSource): void;
|
|
342
|
+
/** Register a create interceptor for this plugin's entity type */
|
|
343
|
+
registerCreateInterceptor(entityType: string, interceptor: CreateInterceptor): void;
|
|
344
|
+
}
|
|
262
345
|
interface EntityService extends ICoreEntityService {
|
|
263
346
|
createEntity<T extends BaseEntity>(request: CreateEntityRequest<T>): Promise<EntityMutationResult>;
|
|
264
347
|
createEntityFromMarkdown(request: CreateEntityFromMarkdownRequest): Promise<EntityMutationResult>;
|
|
@@ -284,78 +367,102 @@ interface EntityService extends ICoreEntityService {
|
|
|
284
367
|
}
|
|
285
368
|
|
|
286
369
|
/**
|
|
287
|
-
*
|
|
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.
|
|
370
|
+
* User permission level schema
|
|
309
371
|
*/
|
|
310
|
-
|
|
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
|
-
}
|
|
372
|
+
declare const UserPermissionLevelSchema: z.ZodEnum<["anchor", "trusted", "public"]>;
|
|
373
|
+
type UserPermissionLevel = z.infer<typeof UserPermissionLevelSchema>;
|
|
343
374
|
|
|
344
375
|
declare const ChatContextSchema: z.ZodObject<{
|
|
345
|
-
userPermissionLevel: z.ZodOptional<z.ZodEnum<["
|
|
376
|
+
userPermissionLevel: z.ZodOptional<z.ZodEnum<["anchor", "trusted", "public"]>>;
|
|
346
377
|
interfaceType: z.ZodOptional<z.ZodString>;
|
|
347
378
|
channelId: z.ZodOptional<z.ZodString>;
|
|
348
379
|
channelName: z.ZodOptional<z.ZodString>;
|
|
380
|
+
actor: z.ZodOptional<z.ZodObject<{
|
|
381
|
+
actorId: z.ZodString;
|
|
382
|
+
canonicalId: z.ZodOptional<z.ZodString>;
|
|
383
|
+
interfaceType: z.ZodString;
|
|
384
|
+
role: z.ZodEnum<["user", "assistant", "system"]>;
|
|
385
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
386
|
+
username: z.ZodOptional<z.ZodString>;
|
|
387
|
+
isBot: z.ZodOptional<z.ZodBoolean>;
|
|
388
|
+
}, "strip", z.ZodTypeAny, {
|
|
389
|
+
interfaceType: string;
|
|
390
|
+
actorId: string;
|
|
391
|
+
role: "user" | "assistant" | "system";
|
|
392
|
+
canonicalId?: string | undefined;
|
|
393
|
+
displayName?: string | undefined;
|
|
394
|
+
username?: string | undefined;
|
|
395
|
+
isBot?: boolean | undefined;
|
|
396
|
+
}, {
|
|
397
|
+
interfaceType: string;
|
|
398
|
+
actorId: string;
|
|
399
|
+
role: "user" | "assistant" | "system";
|
|
400
|
+
canonicalId?: string | undefined;
|
|
401
|
+
displayName?: string | undefined;
|
|
402
|
+
username?: string | undefined;
|
|
403
|
+
isBot?: boolean | undefined;
|
|
404
|
+
}>>;
|
|
405
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
406
|
+
messageId: z.ZodOptional<z.ZodString>;
|
|
407
|
+
channelId: z.ZodOptional<z.ZodString>;
|
|
408
|
+
channelName: z.ZodOptional<z.ZodString>;
|
|
409
|
+
threadId: z.ZodOptional<z.ZodString>;
|
|
410
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
411
|
+
}, "strip", z.ZodTypeAny, {
|
|
412
|
+
channelId?: string | undefined;
|
|
413
|
+
channelName?: string | undefined;
|
|
414
|
+
messageId?: string | undefined;
|
|
415
|
+
threadId?: string | undefined;
|
|
416
|
+
metadata?: Record<string, unknown> | undefined;
|
|
417
|
+
}, {
|
|
418
|
+
channelId?: string | undefined;
|
|
419
|
+
channelName?: string | undefined;
|
|
420
|
+
messageId?: string | undefined;
|
|
421
|
+
threadId?: string | undefined;
|
|
422
|
+
metadata?: Record<string, unknown> | undefined;
|
|
423
|
+
}>>;
|
|
349
424
|
}, "strip", z.ZodTypeAny, {
|
|
350
|
-
userPermissionLevel?: "
|
|
425
|
+
userPermissionLevel?: "anchor" | "trusted" | "public" | undefined;
|
|
351
426
|
interfaceType?: string | undefined;
|
|
352
427
|
channelId?: string | undefined;
|
|
353
428
|
channelName?: string | undefined;
|
|
429
|
+
actor?: {
|
|
430
|
+
interfaceType: string;
|
|
431
|
+
actorId: string;
|
|
432
|
+
role: "user" | "assistant" | "system";
|
|
433
|
+
canonicalId?: string | undefined;
|
|
434
|
+
displayName?: string | undefined;
|
|
435
|
+
username?: string | undefined;
|
|
436
|
+
isBot?: boolean | undefined;
|
|
437
|
+
} | undefined;
|
|
438
|
+
source?: {
|
|
439
|
+
channelId?: string | undefined;
|
|
440
|
+
channelName?: string | undefined;
|
|
441
|
+
messageId?: string | undefined;
|
|
442
|
+
threadId?: string | undefined;
|
|
443
|
+
metadata?: Record<string, unknown> | undefined;
|
|
444
|
+
} | undefined;
|
|
354
445
|
}, {
|
|
355
|
-
userPermissionLevel?: "
|
|
446
|
+
userPermissionLevel?: "anchor" | "trusted" | "public" | undefined;
|
|
356
447
|
interfaceType?: string | undefined;
|
|
357
448
|
channelId?: string | undefined;
|
|
358
449
|
channelName?: string | undefined;
|
|
450
|
+
actor?: {
|
|
451
|
+
interfaceType: string;
|
|
452
|
+
actorId: string;
|
|
453
|
+
role: "user" | "assistant" | "system";
|
|
454
|
+
canonicalId?: string | undefined;
|
|
455
|
+
displayName?: string | undefined;
|
|
456
|
+
username?: string | undefined;
|
|
457
|
+
isBot?: boolean | undefined;
|
|
458
|
+
} | undefined;
|
|
459
|
+
source?: {
|
|
460
|
+
channelId?: string | undefined;
|
|
461
|
+
channelName?: string | undefined;
|
|
462
|
+
messageId?: string | undefined;
|
|
463
|
+
threadId?: string | undefined;
|
|
464
|
+
metadata?: Record<string, unknown> | undefined;
|
|
465
|
+
} | undefined;
|
|
359
466
|
}>;
|
|
360
467
|
type ChatContext = z.infer<typeof ChatContextSchema>;
|
|
361
468
|
declare const PendingConfirmationSchema: z.ZodObject<{
|
|
@@ -621,24 +728,24 @@ declare const ConversationSchema: z.ZodObject<{
|
|
|
621
728
|
}, "strip", z.ZodTypeAny, {
|
|
622
729
|
interfaceType: string;
|
|
623
730
|
channelId: string;
|
|
731
|
+
metadata: Record<string, unknown>;
|
|
624
732
|
id: string;
|
|
625
733
|
sessionId: string;
|
|
626
734
|
startedAt: string;
|
|
627
735
|
lastActiveAt: string;
|
|
628
736
|
createdAt: string;
|
|
629
737
|
updatedAt: string;
|
|
630
|
-
metadata: Record<string, unknown>;
|
|
631
738
|
channelName?: string | undefined;
|
|
632
739
|
}, {
|
|
633
740
|
interfaceType: string;
|
|
634
741
|
channelId: string;
|
|
742
|
+
metadata: Record<string, unknown>;
|
|
635
743
|
id: string;
|
|
636
744
|
sessionId: string;
|
|
637
745
|
startedAt: string;
|
|
638
746
|
lastActiveAt: string;
|
|
639
747
|
createdAt: string;
|
|
640
748
|
updatedAt: string;
|
|
641
|
-
metadata: Record<string, unknown>;
|
|
642
749
|
channelName?: string | undefined;
|
|
643
750
|
}>;
|
|
644
751
|
type Conversation = z.infer<typeof ConversationSchema>;
|
|
@@ -652,17 +759,17 @@ declare const MessageSchema: z.ZodObject<{
|
|
|
652
759
|
timestamp: z.ZodString;
|
|
653
760
|
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
654
761
|
}, "strip", z.ZodTypeAny, {
|
|
655
|
-
|
|
762
|
+
role: "user" | "assistant" | "system";
|
|
656
763
|
metadata: Record<string, unknown>;
|
|
764
|
+
id: string;
|
|
657
765
|
conversationId: string;
|
|
658
|
-
role: "user" | "assistant" | "system";
|
|
659
766
|
content: string;
|
|
660
767
|
timestamp: string;
|
|
661
768
|
}, {
|
|
662
|
-
|
|
769
|
+
role: "user" | "assistant" | "system";
|
|
663
770
|
metadata: Record<string, unknown>;
|
|
771
|
+
id: string;
|
|
664
772
|
conversationId: string;
|
|
665
|
-
role: "user" | "assistant" | "system";
|
|
666
773
|
content: string;
|
|
667
774
|
timestamp: string;
|
|
668
775
|
}>;
|
|
@@ -674,14 +781,14 @@ declare const BrainCharacterSchema: z.ZodObject<{
|
|
|
674
781
|
purpose: z.ZodString;
|
|
675
782
|
values: z.ZodArray<z.ZodString, "many">;
|
|
676
783
|
}, "strip", z.ZodTypeAny, {
|
|
784
|
+
role: string;
|
|
677
785
|
values: string[];
|
|
678
786
|
name: string;
|
|
679
|
-
role: string;
|
|
680
787
|
purpose: string;
|
|
681
788
|
}, {
|
|
789
|
+
role: string;
|
|
682
790
|
values: string[];
|
|
683
791
|
name: string;
|
|
684
|
-
role: string;
|
|
685
792
|
purpose: string;
|
|
686
793
|
}>;
|
|
687
794
|
type BrainCharacter = z.infer<typeof BrainCharacterSchema>;
|
|
@@ -781,16 +888,16 @@ declare const BaseMessageSchema: z.ZodObject<{
|
|
|
781
888
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
782
889
|
}, "strip", z.ZodTypeAny, {
|
|
783
890
|
type: string;
|
|
891
|
+
source: string;
|
|
784
892
|
id: string;
|
|
785
893
|
timestamp: string;
|
|
786
|
-
source: string;
|
|
787
894
|
metadata?: Record<string, unknown> | undefined;
|
|
788
895
|
target?: string | undefined;
|
|
789
896
|
}, {
|
|
790
897
|
type: string;
|
|
898
|
+
source: string;
|
|
791
899
|
id: string;
|
|
792
900
|
timestamp: string;
|
|
793
|
-
source: string;
|
|
794
901
|
metadata?: Record<string, unknown> | undefined;
|
|
795
902
|
target?: string | undefined;
|
|
796
903
|
}>;
|
|
@@ -814,7 +921,7 @@ interface MessageContext {
|
|
|
814
921
|
messageId?: string;
|
|
815
922
|
timestamp?: string;
|
|
816
923
|
interfaceType?: string;
|
|
817
|
-
userPermissionLevel?:
|
|
924
|
+
userPermissionLevel?: UserPermissionLevel;
|
|
818
925
|
threadId?: string;
|
|
819
926
|
}
|
|
820
927
|
|
|
@@ -856,7 +963,7 @@ interface ToolResponse<T = unknown> {
|
|
|
856
963
|
data?: T;
|
|
857
964
|
error?: string;
|
|
858
965
|
}
|
|
859
|
-
type ToolVisibility =
|
|
966
|
+
type ToolVisibility = UserPermissionLevel;
|
|
860
967
|
interface ToolConfirmation {
|
|
861
968
|
required: boolean;
|
|
862
969
|
message?: string;
|
|
@@ -953,34 +1060,9 @@ interface Channel<TPayload, TResponse = unknown> {
|
|
|
953
1060
|
readonly _response?: TResponse;
|
|
954
1061
|
}
|
|
955
1062
|
declare function defineChannel<TPayload, TResponse = unknown>(name: string, schema: z.ZodType<TPayload>): Channel<TPayload, TResponse>;
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
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
|
-
}
|
|
1063
|
+
type PublicEntityServiceMethods = "getEntity" | "listEntities" | "search" | "getEntityTypes" | "hasEntityType" | "countEntities" | "getEntityCounts" | "getEntityTypeConfig";
|
|
1064
|
+
type IEntityService = Pick<ICoreEntityService, PublicEntityServiceMethods>;
|
|
1065
|
+
|
|
984
1066
|
interface IIdentityNamespace {
|
|
985
1067
|
get: () => BrainCharacter;
|
|
986
1068
|
getProfile: () => AnchorProfile;
|
|
@@ -1008,7 +1090,7 @@ interface IMessagingNamespace {
|
|
|
1008
1090
|
type EvalHandler<TInput = unknown, TOutput = unknown> = (input: TInput) => Promise<TOutput>;
|
|
1009
1091
|
type InsightHandler = (entityService: IEntityService) => Promise<Record<string, unknown>>;
|
|
1010
1092
|
interface IEvalNamespace {
|
|
1011
|
-
registerHandler
|
|
1093
|
+
registerHandler(handlerId: string, handler: EvalHandler): void;
|
|
1012
1094
|
}
|
|
1013
1095
|
interface IInsightsNamespace {
|
|
1014
1096
|
register(type: string, handler: InsightHandler): void;
|
|
@@ -1028,16 +1110,6 @@ interface BasePluginContext {
|
|
|
1028
1110
|
readonly eval: IEvalNamespace;
|
|
1029
1111
|
readonly insights: IInsightsNamespace;
|
|
1030
1112
|
}
|
|
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
1113
|
interface IPromptsNamespace {
|
|
1042
1114
|
resolve(target: string, fallback: string): Promise<string>;
|
|
1043
1115
|
}
|
|
@@ -1045,7 +1117,11 @@ interface IServiceTemplatesNamespace {
|
|
|
1045
1117
|
register(templates: unknown): void;
|
|
1046
1118
|
}
|
|
1047
1119
|
interface IViewsNamespace {
|
|
1048
|
-
|
|
1120
|
+
get(name: string): unknown | undefined;
|
|
1121
|
+
list(): unknown[];
|
|
1122
|
+
hasRenderer(templateName: string): boolean;
|
|
1123
|
+
getRenderer(templateName: string): unknown | undefined;
|
|
1124
|
+
validate(templateName: string, content: unknown): boolean;
|
|
1049
1125
|
}
|
|
1050
1126
|
interface ServicePluginContext extends BasePluginContext {
|
|
1051
1127
|
readonly entities: IEntitiesNamespace;
|
|
@@ -1192,4 +1268,4 @@ declare abstract class ServicePlugin<TConfig = unknown> implements Plugin {
|
|
|
1192
1268
|
}
|
|
1193
1269
|
|
|
1194
1270
|
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 };
|
|
1271
|
+
export type { AgentNamespace, AgentResponse, AnchorProfile, AppInfo, BaseJobTrackingInfo, BaseMessage, BasePluginContext, BrainCharacter, Channel, ChatContext, Conversation, EntityPluginContext, ExtensionMetadata, IConversationsNamespace, IEntitiesNamespace, IEntityService, 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 };
|