@rizom/brain 0.2.0-alpha.50 → 0.2.0-alpha.51

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/plugins.d.ts CHANGED
@@ -197,18 +197,58 @@ interface EntityTypeConfig {
197
197
  * Core entity service interface for read-only operations
198
198
  * Used by core plugins that need entity access but shouldn't modify entities
199
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
+ }
200
240
  interface ICoreEntityService {
201
- getEntity<T extends BaseEntity>(entityType: string, id: string): Promise<T | null>;
241
+ getEntity<T extends BaseEntity>(request: GetEntityRequest$1): Promise<T | null>;
202
242
  /**
203
243
  * Get entity without content resolution (raw)
204
244
  * Used internally to avoid recursion when resolving image references
205
245
  */
206
- getEntityRaw<T extends BaseEntity>(entityType: string, id: string): Promise<T | null>;
207
- listEntities<T extends BaseEntity>(type: string, options?: ListOptions): Promise<T[]>;
208
- search<T extends BaseEntity = BaseEntity>(query: string, options?: SearchOptions): Promise<SearchResult<T>[]>;
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>[]>;
209
249
  getEntityTypes(): string[];
210
250
  hasEntityType(type: string): boolean;
211
- countEntities(entityType: string, options?: Pick<ListOptions, "publishedOnly" | "filter">): Promise<number>;
251
+ countEntities(request: CountEntitiesRequest$1): Promise<number>;
212
252
  getEntityCounts(): Promise<Array<{
213
253
  entityType: string;
214
254
  count: number;
@@ -220,18 +260,18 @@ interface ICoreEntityService {
220
260
  * Entity service interface for managing brain entities
221
261
  */
222
262
  interface EntityService extends ICoreEntityService {
223
- createEntity<T extends BaseEntity>(entity: EntityInput<T>, options?: CreateEntityOptions): Promise<EntityMutationResult>;
224
- createEntityFromMarkdown(input: CreateEntityFromMarkdownInput, options?: CreateEntityOptions): Promise<EntityMutationResult>;
225
- updateEntity<T extends BaseEntity>(entity: T, options?: EntityJobOptions): Promise<EntityMutationResult>;
226
- deleteEntity(entityType: string, id: string): Promise<boolean>;
227
- upsertEntity<T extends BaseEntity>(entity: T, options?: EntityJobOptions): Promise<EntityMutationResult & {
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 & {
228
268
  created: boolean;
229
269
  }>;
230
270
  storeEmbedding(data: StoreEmbeddingData): Promise<void>;
231
271
  serializeEntity(entity: BaseEntity): string;
232
272
  deserializeEntity(markdown: string, entityType: string): Partial<BaseEntity>;
233
273
  countEmbeddings(): Promise<number>;
234
- searchWithDistances(query: string): Promise<Array<{
274
+ searchWithDistances(request: SearchWithDistancesRequest): Promise<Array<{
235
275
  entityId: string;
236
276
  entityType: string;
237
277
  distance: number;
@@ -695,6 +735,16 @@ declare const AnchorProfileSchema: z.ZodObject<{
695
735
  }>;
696
736
  type AnchorProfile = z.infer<typeof AnchorProfileSchema>;
697
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
+
698
748
  declare const MessageResponseSchema: z.ZodUnion<[z.ZodObject<{
699
749
  success: z.ZodBoolean;
700
750
  data: z.ZodOptional<z.ZodUnknown>;
@@ -749,9 +799,15 @@ type MessageWithPayload<T = unknown> = BaseMessage & {
749
799
  payload: T;
750
800
  };
751
801
  interface MessageSendOptions {
802
+ target?: string;
803
+ metadata?: z.infer<typeof ExtensionMetadataSchema>;
752
804
  broadcast?: boolean;
753
805
  }
754
- type MessageSender<T = unknown, R = unknown> = (type: string, payload: T, options?: MessageSendOptions) => Promise<MessageResponse<R>>;
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>>;
755
811
  interface MessageContext {
756
812
  userId?: string;
757
813
  channelId?: string;
@@ -897,13 +953,29 @@ interface Channel<TPayload, TResponse = unknown> {
897
953
  readonly _response?: TResponse;
898
954
  }
899
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
+ }
900
972
  interface IEntityService {
901
- getEntity<T = unknown>(entityType: string, id: string): Promise<T | null>;
902
- listEntities<T = unknown>(type: string, options?: unknown): Promise<T[]>;
903
- search<T = unknown>(query: string, options?: unknown): Promise<T[]>;
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[]>;
904
976
  getEntityTypes(): string[];
905
977
  hasEntityType(type: string): boolean;
906
- countEntities(entityType: string, options?: unknown): Promise<number>;
978
+ countEntities(request: CountEntitiesRequest): Promise<number>;
907
979
  getEntityCounts(): Promise<Array<{
908
980
  entityType: string;
909
981
  count: number;
@@ -1054,6 +1126,19 @@ declare abstract class InterfacePlugin<TConfig = unknown, TTrackingInfo extends
1054
1126
  shutdown(): Promise<void>;
1055
1127
  }
1056
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
+
1057
1142
  declare abstract class MessageInterfacePlugin<TConfig = unknown, TTrackingInfo extends MessageJobTrackingInfo = MessageJobTrackingInfo> extends InterfacePlugin<TConfig, TTrackingInfo> {
1058
1143
  private readonly messageDelegate;
1059
1144
  protected constructor(id: string, packageJson: {
@@ -1061,15 +1146,15 @@ declare abstract class MessageInterfacePlugin<TConfig = unknown, TTrackingInfo e
1061
1146
  version: string;
1062
1147
  description?: string;
1063
1148
  }, config: Partial<TConfig>, configSchema: z.ZodTypeAny);
1064
- protected abstract sendMessageToChannel(channelId: string | null, message: string): void;
1149
+ protected abstract sendMessageToChannel(request: SendMessageToChannelRequest): void;
1065
1150
  protected onRegister(_context: InterfacePluginContext): Promise<void>;
1066
1151
  protected onReady(_context: InterfacePluginContext): Promise<void>;
1067
1152
  protected onShutdown(): Promise<void>;
1068
1153
  protected getTools(): Promise<Tool[]>;
1069
1154
  protected getResources(): Promise<Resource[]>;
1070
1155
  protected getInstructions(): Promise<string | undefined>;
1071
- protected sendMessageWithId(_channelId: string | null, _message: string): Promise<string | undefined>;
1072
- protected editMessage(_channelId: string, _messageId: string, _newMessage: string): Promise<boolean>;
1156
+ protected sendMessageWithId(_request: SendMessageWithIdRequest): Promise<string | undefined>;
1157
+ protected editMessage(_request: EditMessageRequest): Promise<boolean>;
1073
1158
  protected supportsMessageEditing(): boolean;
1074
1159
  protected onProgressUpdate(_event: JobProgressEvent): Promise<void>;
1075
1160
  protected trackAgentResponseForJob(jobId: string, messageId: string, channelId: string): void;
@@ -1106,15 +1191,5 @@ declare abstract class ServicePlugin<TConfig = unknown> implements Plugin {
1106
1191
  shutdown(): Promise<void>;
1107
1192
  }
1108
1193
 
1109
- /**
1110
- * Best-effort extension metadata carried across public DTO boundaries.
1111
- *
1112
- * Individual keys are not stable public API. When a metadata value becomes a
1113
- * documented contract, hoist it to a typed top-level field on the owning DTO
1114
- * schema and keep this bag only as optional extension data.
1115
- */
1116
- declare const ExtensionMetadataSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1117
- type ExtensionMetadata = z.infer<typeof ExtensionMetadataSchema>;
1118
-
1119
1194
  export { AgentResponseSchema, AnchorProfileSchema, AppInfoSchema, BaseMessageSchema, BrainCharacterSchema, ChatContextSchema, ConversationSchema, EntityPlugin, ExtensionMetadataSchema, InterfacePlugin, MessageInterfacePlugin, MessageResponseSchema, MessageSchema, PendingConfirmationSchema, ServicePlugin, ToolResultDataSchema, createResource, createTool, defineChannel, toolError, toolSuccess, urlCaptureConfigSchema };
1120
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 };