@rizom/site-rizom-ai 0.2.0-alpha.258 → 0.2.0-alpha.259

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 (47) hide show
  1. package/dist/index.d.ts +4317 -110
  2. package/dist/index.js +4461 -7891
  3. package/dist/index.js.map +39 -23
  4. package/package.json +1 -1
  5. package/src/brain.tsx +165 -311
  6. package/src/favicon.svg +1 -0
  7. package/src/foundation.tsx +120 -95
  8. package/src/index.ts +0 -1
  9. package/src/layout.tsx +87 -265
  10. package/src/living-memory.tsx +86 -291
  11. package/src/opening-datasource.ts +82 -0
  12. package/src/opening.tsx +218 -0
  13. package/src/rizom/create-site.ts +17 -2
  14. package/src/rizom/runtime/boot/boot.boot.js +1 -82
  15. package/src/rizom/runtime/plugin.ts +20 -10
  16. package/src/routes.ts +14 -53
  17. package/src/shared.ts +14 -0
  18. package/src/site.ts +15 -13
  19. package/src/story/brain-organism.tsx +153 -0
  20. package/src/story/emphasis.tsx +11 -0
  21. package/src/story/foundation-organism.tsx +150 -0
  22. package/src/story/living-organism.tsx +213 -0
  23. package/src/story/network.ts +81 -0
  24. package/src/story/organism.tsx +223 -0
  25. package/src/story/runtime.ts +116 -0
  26. package/src/story/story-page.tsx +72 -0
  27. package/src/story/work-organism.tsx +159 -0
  28. package/src/story.css +1221 -0
  29. package/src/work.tsx +105 -292
  30. package/src/writing-datasource.ts +71 -0
  31. package/src/writing.css +201 -0
  32. package/src/writing.tsx +199 -0
  33. package/src/assets/brain/README.md +0 -11
  34. package/src/assets/brain/chat-desktop-dark.svg +0 -1
  35. package/src/assets/brain/chat-desktop-light.svg +0 -1
  36. package/src/assets/brain/chat-mobile-dark.svg +0 -1
  37. package/src/assets/brain/chat-mobile-light.svg +0 -1
  38. package/src/brain-assets.ts +0 -12
  39. package/src/brain-network.tsx +0 -113
  40. package/src/brain-screens.tsx +0 -474
  41. package/src/brain.css +0 -1453
  42. package/src/growth-diagram.tsx +0 -343
  43. package/src/home.tsx +0 -218
  44. package/src/living-memory-art.tsx +0 -394
  45. package/src/living-memory-maps.css +0 -326
  46. package/src/living-memory.css +0 -1771
  47. package/src/shared.tsx +0 -276
package/dist/index.d.ts CHANGED
@@ -1,22 +1,25 @@
1
- import { JSX, ReactNode } from "react";
2
- import { z } from "zod/v4";
1
+ import { JSX, ReactElement, ReactNode } from "react";
2
+ import { ZodRawShape, ZodType, z, z as z$1 } from "zod/v4";
3
+ import { LibSQLDatabase } from "drizzle-orm/libsql";
4
+ import { SQLiteColumn, SQLiteTableWithColumns } from "drizzle-orm/sqlite-core";
5
+ import { McpServer, ToolAnnotations } from "@modelcontextprotocol/server";
3
6
  //#region ../../packages/site/src/index.d.ts
4
7
  /** Permission levels for editable site content templates. */
5
- type UserPermissionLevel = "admin" | "trusted" | "public";
6
- type JsonPrimitive = null | boolean | number | string;
7
- type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
8
+ type UserPermissionLevel$1 = "admin" | "trusted" | "public";
9
+ type JsonPrimitive$1 = null | boolean | number | string;
10
+ type JsonValue$1 = JsonPrimitive$1 | JsonValue$1[] | JsonObject$1;
8
11
  /** A JSON document with an object at its root. */
9
- interface JsonObject {
10
- [key: string]: JsonValue;
12
+ interface JsonObject$1 {
13
+ [key: string]: JsonValue$1;
11
14
  }
12
15
  /** Runtime script declaration attached to a content section/template. */
13
- interface RuntimeScript {
16
+ interface RuntimeScript$1 {
14
17
  src: string;
15
18
  defer?: boolean;
16
19
  module?: boolean;
17
20
  }
18
21
  /** Bivariant component type for author-supplied layout components. */
19
- type ComponentType<P = unknown> = {
22
+ type ComponentType$1<P = unknown> = {
20
23
  bivarianceHack(props: P): JSX.Element;
21
24
  }["bivarianceHack"];
22
25
  /** Navigation slot types exposed to authored routes and generated entity routes. */
@@ -89,11 +92,11 @@ type SiteContentFieldDefinition = SiteContentStringFieldDefinition | SiteContent
89
92
  interface SiteContentSectionDefinition {
90
93
  description: string;
91
94
  title: string;
92
- layout: ComponentType<unknown>;
95
+ layout: ComponentType$1<unknown>;
93
96
  fields: Record<string, SiteContentFieldDefinition>;
94
- requiredPermission?: UserPermissionLevel;
97
+ requiredPermission?: UserPermissionLevel$1;
95
98
  fullscreen?: boolean;
96
- runtimeScripts?: RuntimeScript[];
99
+ runtimeScripts?: RuntimeScript$1[];
97
100
  }
98
101
  interface SiteContentDefinition {
99
102
  namespace: string;
@@ -103,16 +106,16 @@ interface SiteContentDefinition {
103
106
  interface SectionMeta {
104
107
  title: string;
105
108
  description: string;
106
- requiredPermission?: UserPermissionLevel | undefined;
109
+ requiredPermission?: UserPermissionLevel$1 | undefined;
107
110
  fullscreen?: boolean | undefined;
108
111
  }
109
112
  /**
110
113
  * A schema-first content section. Its component props are inferred from the
111
114
  * same schema used by runtime validation, markdown formatting, and editing.
112
115
  */
113
- interface SiteSectionDefinition<S extends z.ZodType = z.ZodType<JsonObject>> extends SectionMeta {
116
+ interface SiteSectionDefinition<S extends z$1.ZodType = z$1.ZodType<JsonObject$1>> extends SectionMeta {
114
117
  schema: S;
115
- component: ComponentType<z.output<S>>;
118
+ component: ComponentType$1<z$1.output<S>>;
116
119
  }
117
120
  interface SiteSectionGroup {
118
121
  namespace: string;
@@ -165,12 +168,12 @@ interface SiteLayoutProps {
165
168
  }
166
169
  /** Initial section content keyed by section-group namespace and section id. */
167
170
  interface SiteContent {
168
- [namespace: string]: Record<string, JsonObject>;
171
+ [namespace: string]: Record<string, JsonObject$1>;
169
172
  }
170
173
  /** Declarative site-package shape authored by public site packages. */
171
174
  interface SiteDefinition {
172
175
  /** Layout components keyed by name — a `default` layout is required. */
173
- layouts: Record<string, ComponentType<SiteLayoutProps>>;
176
+ layouts: Record<string, ComponentType$1<SiteLayoutProps>>;
174
177
  /** Hand-written route definitions (home, about, etc.). */
175
178
  routes: RouteDefinitionInput[];
176
179
  /** Optional initial content validated by the corresponding section schema. */
@@ -187,28 +190,28 @@ interface SiteDefinition {
187
190
  staticAssets?: Record<string, string> | undefined;
188
191
  }
189
192
  type SiteDefinitionOverrides = { [K in keyof SiteDefinition]?: SiteDefinition[K] | undefined; };
190
- type Strict<Shape extends z.ZodRawShape> = z.ZodObject<Shape, z.core.$strict>;
193
+ type Strict$2<Shape extends z$1.ZodRawShape> = z$1.ZodObject<Shape, z$1.core.$strict>;
191
194
  /**
192
195
  * Display and behavior metadata for an entity type, as a site declares it.
193
196
  * The one definition: the site-builder takes it as it is.
194
197
  */
195
- declare const entityDisplaySchema: Strict<{
196
- label: z.ZodString;
197
- pluralName: z.ZodOptional<z.ZodString>;
198
- layout: z.ZodOptional<z.ZodString>;
199
- paginate: z.ZodOptional<z.ZodBoolean>;
200
- pageSize: z.ZodOptional<z.ZodNumber>;
201
- citable: z.ZodOptional<z.ZodBoolean>;
202
- navigation: z.ZodOptional<Strict<{
203
- show: z.ZodOptional<z.ZodBoolean>;
204
- slot: z.ZodOptional<z.ZodEnum<{
198
+ declare const entityDisplaySchema: Strict$2<{
199
+ label: z$1.ZodString;
200
+ pluralName: z$1.ZodOptional<z$1.ZodString>;
201
+ layout: z$1.ZodOptional<z$1.ZodString>;
202
+ paginate: z$1.ZodOptional<z$1.ZodBoolean>;
203
+ pageSize: z$1.ZodOptional<z$1.ZodNumber>;
204
+ citable: z$1.ZodOptional<z$1.ZodBoolean>;
205
+ navigation: z$1.ZodOptional<Strict$2<{
206
+ show: z$1.ZodOptional<z$1.ZodBoolean>;
207
+ slot: z$1.ZodOptional<z$1.ZodEnum<{
205
208
  primary: "primary";
206
209
  secondary: "secondary";
207
210
  }>>;
208
- priority: z.ZodOptional<z.ZodNumber>;
211
+ priority: z$1.ZodOptional<z$1.ZodNumber>;
209
212
  }>>;
210
213
  }>;
211
- type EntityDisplayEntry = z.output<typeof entityDisplaySchema>;
214
+ type EntityDisplayEntry = z$1.output<typeof entityDisplaySchema>;
212
215
  //#endregion
213
216
  //#region src/rizom/contracts.d.ts
214
217
  interface RizomLink {
@@ -245,14 +248,14 @@ interface RizomMessageBus {
245
248
  interface RizomLogger {
246
249
  info(message: string): void;
247
250
  }
248
- interface DataSourceRegistry {
251
+ interface DataSourceRegistry$1 {
249
252
  register(dataSource: unknown): void;
250
253
  }
251
254
  interface RizomSiteShell {
252
255
  getMessageBus(): RizomMessageBus;
253
256
  getLogger(): RizomLogger;
254
257
  registerTemplates(templates: Record<string, unknown>, namespace?: string): void;
255
- getDataSourceRegistry(): DataSourceRegistry;
258
+ getDataSourceRegistry(): DataSourceRegistry$1;
256
259
  }
257
260
  interface SiteCompositionPlugin {
258
261
  readonly id: string;
@@ -349,108 +352,4312 @@ interface DividerProps {
349
352
  }
350
353
  declare const Divider: ({ className }: DividerProps) => JSX.Element;
351
354
  //#endregion
352
- //#region ../../shared/ui-library/src/highlighted-text.d.ts
355
+ //#region ../../shell/entity-service/src/entity-type-classification.d.ts
356
+ /** Plugin-owned semantic classification, independent of access and projection policy. */
357
+ declare const entityTypeClassificationSchema: z.ZodDefault<z.ZodEnum<{
358
+ content: "content";
359
+ system: "system";
360
+ }>>;
361
+ type EntityTypeClassification = z.output<typeof entityTypeClassificationSchema>;
362
+ //#endregion
363
+ //#region ../../shell/entity-service/src/visibility.d.ts
364
+ declare const canonicalContentVisibilitySchema: z.ZodEnum<{
365
+ public: "public";
366
+ shared: "shared";
367
+ restricted: "restricted";
368
+ }>;
369
+ type ContentVisibility = z.infer<typeof canonicalContentVisibilitySchema>;
370
+ type RawContentVisibility = ContentVisibility | "private";
371
+ //#endregion
372
+ //#region ../../shell/entity-service/src/entity-grouping.d.ts
373
+ declare const entityGroupingSchema: z.ZodObject<{
374
+ key: z.ZodString;
375
+ label: z.ZodString;
376
+ field: z.ZodString;
377
+ types: z.ZodArray<z.ZodString>;
378
+ }>;
379
+ type EntityGrouping = z.infer<typeof entityGroupingSchema>;
380
+ /** One ordering vocabulary, shared by the queries, the routes and the UI. */
381
+ declare const groupingSortSchema: z.ZodEnum<{
382
+ "updated-desc": "updated-desc";
383
+ "updated-asc": "updated-asc";
384
+ "created-desc": "created-desc";
385
+ "created-asc": "created-asc";
386
+ }>;
387
+ declare const queryGroupingCatalogSchema: z.ZodObject<{
388
+ grouping: z.ZodString;
389
+ entityTypes: z.ZodArray<z.ZodString>;
390
+ visibilityScope: z.ZodOptional<typeof canonicalContentVisibilitySchema>;
391
+ limit: z.ZodDefault<z.ZodNumber>;
392
+ offset: z.ZodDefault<z.ZodNumber>;
393
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
394
+ }>;
395
+ declare const queryGroupingMembersSchema: z.ZodObject<{
396
+ grouping: z.ZodString;
397
+ entityTypes: z.ZodArray<z.ZodString>;
398
+ visibilityScope: z.ZodOptional<typeof canonicalContentVisibilitySchema>;
399
+ limit: z.ZodDefault<z.ZodNumber>;
400
+ offset: z.ZodDefault<z.ZodNumber>;
401
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
402
+ value: z.ZodString;
403
+ q: z.ZodOptional<z.ZodString>;
404
+ sort: z.ZodDefault<typeof groupingSortSchema>;
405
+ }>;
406
+ /** Usage is a distinct entry total plus counts for a bounded set of exact values. */
407
+ declare const queryGroupingUsageSchema: z.ZodObject<{
408
+ grouping: z.ZodString;
409
+ entityTypes: z.ZodArray<z.ZodString>;
410
+ visibilityScope: z.ZodOptional<typeof canonicalContentVisibilitySchema>;
411
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
412
+ values: z.ZodDefault<z.ZodArray<z.ZodString>>;
413
+ }>;
414
+ type QueryGroupingUsageRequest = z.input<typeof queryGroupingUsageSchema>;
415
+ interface EntityGroupingUsage {
416
+ /** Entries with at least one text membership, including values outside a list. */
417
+ entries: number;
418
+ /** Request order and literals preserved; unused values have a zero count. */
419
+ values: Array<{
420
+ value: string;
421
+ count: number;
422
+ }>;
423
+ }
424
+ type QueryGroupingCatalogRequest = z.input<typeof queryGroupingCatalogSchema>;
425
+ type QueryGroupingMembersRequest = z.input<typeof queryGroupingMembersSchema>;
426
+ interface EntityGroupingCatalog {
427
+ values: Array<{
428
+ value: string;
429
+ count: number;
430
+ }>;
431
+ total: number;
432
+ }
433
+ //#endregion
434
+ //#region ../../shell/entity-service/src/grouping-projection-state.d.ts
435
+ interface GroupingProjectionTarget {
436
+ entityType: string;
437
+ field: string;
438
+ generation: number;
439
+ }
440
+ //#endregion
441
+ //#region ../../shared/assets/src/index.d.ts
442
+ type AssetRef = `asset://sha256/${string}`;
443
+ interface AssetStat {
444
+ ref: AssetRef;
445
+ sizeBytes: number;
446
+ }
447
+ interface AssetVerification extends AssetStat {
448
+ expectedDigest: string;
449
+ actualDigest: string;
450
+ valid: boolean;
451
+ }
353
452
  /**
354
- * Render a content string with two lightweight markup conventions:
453
+ * Validated, bounded bytes ready to join an entity mutation. Preparation does
454
+ * not write durable state; only the entity transaction may commit the bytes.
455
+ */
456
+ interface PreparedAsset extends AssetRecord {
457
+ bytes: Uint8Array;
458
+ }
459
+ /** Read-only durable asset surface. There is deliberately no independent put. */
460
+ interface AssetReader {
461
+ read(ref: AssetRef): Promise<Uint8Array>;
462
+ stat(ref: AssetRef): Promise<AssetStat | null>;
463
+ verify(ref: AssetRef): Promise<AssetVerification>;
464
+ }
465
+ declare const assetRefSchema: z.ZodCustom<AssetRef, AssetRef>;
466
+ declare const assetRecordSchema: z.ZodObject<{
467
+ ref: typeof assetRefSchema;
468
+ digest: z.ZodString;
469
+ sizeBytes: z.ZodNumber;
470
+ }>;
471
+ type AssetRecord = z.output<typeof assetRecordSchema>;
472
+ //#endregion
473
+ //#region ../../shell/entity-service/src/entity-id-path.d.ts
474
+ type EntityIdPath = [string, ...string[]];
475
+ type EntityIdPathInput = readonly [string, ...string[]];
476
+ //#endregion
477
+ //#region ../../shared/contracts/src/guest-execution.d.ts
478
+ type Strict$1<Shape extends z.ZodRawShape> = z.ZodObject<Shape, z.core.$strict>;
479
+ /** Server-owned limits, not a browser's requested model settings. */
480
+ declare const guestExecutionLimitsSchema: Strict$1<{
481
+ messageCharacters: z.ZodNumber;
482
+ requestTimeoutSeconds: z.ZodNumber;
483
+ }>;
484
+ declare const guestExecutionPolicySchema: Strict$1<{
485
+ limits: typeof guestExecutionLimitsSchema;
486
+ maxCostMicroUsd: z.ZodNumber;
487
+ }>;
488
+ type GuestExecutionPolicy = z.output<typeof guestExecutionPolicySchema>;
489
+ /** What the provider reported for a guest turn, summed across its calls. */
490
+ declare const guestTurnUsageSchema: Strict$1<{
491
+ modelCalls: z.ZodNumber;
492
+ inputTokens: z.ZodNumber;
493
+ cachedInputTokens: z.ZodNumber;
494
+ outputTokens: z.ZodNumber;
495
+ reasoningTokens: z.ZodNumber;
496
+ embeddingTokens: z.ZodNumber;
497
+ }>;
498
+ /**
499
+ * A turn's cost from provider usage at a pinned pricing revision. Computed
500
+ * locally, not reconciled billing; a quote is never a known cost. Missing
501
+ * usage or pricing the revision does not cover stays unknown.
502
+ */
503
+ declare const guestTurnCostSchema: z.ZodDiscriminatedUnion<[Strict$1<{
504
+ state: z.ZodLiteral<"known">;
505
+ microUsd: z.ZodNumber;
506
+ pricing: z.ZodString;
507
+ }>, Strict$1<{
508
+ state: z.ZodLiteral<"unknown">;
509
+ reason: z.ZodEnum<{
510
+ "missing-usage": "missing-usage";
511
+ "unsupported-pricing": "unsupported-pricing";
512
+ }>;
513
+ }>], "state">;
514
+ declare const guestTurnSettlementSchema: Strict$1<{
515
+ usage: typeof guestTurnUsageSchema;
516
+ cost: typeof guestTurnCostSchema;
517
+ }>;
518
+ //#endregion
519
+ //#region ../../shared/contracts/src/agent-response.d.ts
520
+ type PendingConfirmationSchema = z.ZodObject<{
521
+ id: z.ZodString;
522
+ toolCallId: z.ZodOptional<z.ZodString>;
523
+ toolName: z.ZodString;
524
+ summary: z.ZodString;
525
+ completionSummary: z.ZodOptional<z.ZodString>;
526
+ preview: z.ZodOptional<z.ZodString>;
527
+ args: z.ZodUnknown;
528
+ }>;
529
+ declare const PendingConfirmationSchema: PendingConfirmationSchema;
530
+ type ToolApprovalCardStateSchema = z.ZodEnum<{
531
+ "approval-requested": "approval-requested";
532
+ "approval-responded": "approval-responded";
533
+ "output-available": "output-available";
534
+ "output-denied": "output-denied";
535
+ "output-error": "output-error";
536
+ }>;
537
+ declare const ToolApprovalCardStateSchema: ToolApprovalCardStateSchema;
538
+ type ToolApprovalCardSchema = z.ZodObject<{
539
+ kind: z.ZodLiteral<"tool-approval">;
540
+ id: z.ZodString;
541
+ toolCallId: z.ZodOptional<z.ZodString>;
542
+ toolName: z.ZodString;
543
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
544
+ summary: z.ZodString;
545
+ completionSummary: z.ZodOptional<z.ZodString>;
546
+ preview: z.ZodOptional<z.ZodString>;
547
+ state: ToolApprovalCardStateSchema;
548
+ output: z.ZodOptional<z.ZodUnknown>;
549
+ error: z.ZodOptional<z.ZodString>;
550
+ }>;
551
+ declare const ToolApprovalCardSchema: ToolApprovalCardSchema;
552
+ type AttachmentCardSourceSchema = z.ZodObject<{
553
+ entityType: z.ZodOptional<z.ZodString>;
554
+ entityId: z.ZodOptional<z.ZodString>;
555
+ attachmentType: z.ZodOptional<z.ZodString>;
556
+ }>;
557
+ declare const AttachmentCardSourceSchema: AttachmentCardSourceSchema;
558
+ type AttachmentCardDataSchema = z.ZodObject<{
559
+ mediaType: z.ZodString;
560
+ url: z.ZodString;
561
+ downloadUrl: z.ZodOptional<z.ZodString>;
562
+ previewUrl: z.ZodOptional<z.ZodString>;
563
+ filename: z.ZodOptional<z.ZodString>;
564
+ sizeBytes: z.ZodOptional<z.ZodNumber>;
565
+ source: z.ZodOptional<AttachmentCardSourceSchema>;
566
+ }>;
567
+ declare const AttachmentCardDataSchema: AttachmentCardDataSchema;
568
+ type AttachmentCardSchema = z.ZodObject<{
569
+ kind: z.ZodLiteral<"attachment">;
570
+ id: z.ZodString;
571
+ jobId: z.ZodOptional<z.ZodString>;
572
+ title: z.ZodString;
573
+ description: z.ZodOptional<z.ZodString>;
574
+ attachment: AttachmentCardDataSchema;
575
+ }>;
576
+ declare const AttachmentCardSchema: AttachmentCardSchema;
577
+ type SourceCitationSchema = z.ZodObject<{
578
+ id: z.ZodString;
579
+ title: z.ZodOptional<z.ZodString>;
580
+ source: z.ZodString;
581
+ url: z.ZodOptional<z.ZodString>;
582
+ entityType: z.ZodOptional<z.ZodString>;
583
+ entityId: z.ZodOptional<z.ZodString>;
584
+ excerpt: z.ZodOptional<z.ZodString>;
585
+ provenance: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
586
+ }>;
587
+ declare const SourceCitationSchema: SourceCitationSchema;
588
+ type SourcesCardSchema = z.ZodObject<{
589
+ kind: z.ZodLiteral<"sources">;
590
+ id: z.ZodString;
591
+ title: z.ZodOptional<z.ZodString>;
592
+ sources: z.ZodArray<SourceCitationSchema>;
593
+ }>;
594
+ declare const SourcesCardSchema: SourcesCardSchema;
595
+ type PromptChatActionSchema = z.ZodObject<{
596
+ type: z.ZodLiteral<"prompt">;
597
+ id: z.ZodString;
598
+ label: z.ZodString;
599
+ prompt: z.ZodString;
600
+ description: z.ZodOptional<z.ZodString>;
601
+ }>;
602
+ declare const PromptChatActionSchema: PromptChatActionSchema;
603
+ type EventChatActionSchema = z.ZodObject<{
604
+ type: z.ZodLiteral<"event">;
605
+ id: z.ZodString;
606
+ label: z.ZodString;
607
+ event: z.ZodString;
608
+ fromState: z.ZodOptional<z.ZodString>;
609
+ description: z.ZodOptional<z.ZodString>;
610
+ }>;
611
+ declare const EventChatActionSchema: EventChatActionSchema;
612
+ type ChatActionSchema = z.ZodDiscriminatedUnion<[PromptChatActionSchema, EventChatActionSchema]>;
613
+ declare const ChatActionSchema: ChatActionSchema;
614
+ type ActionsCardSchema = z.ZodObject<{
615
+ kind: z.ZodLiteral<"actions">;
616
+ id: z.ZodString;
617
+ title: z.ZodOptional<z.ZodString>;
618
+ defaultOpen: z.ZodOptional<z.ZodBoolean>;
619
+ actions: z.ZodArray<ChatActionSchema>;
620
+ }>;
621
+ declare const ActionsCardSchema: ActionsCardSchema;
622
+ type StructuredChatCardSchema = z.ZodDiscriminatedUnion<[ToolApprovalCardSchema, AttachmentCardSchema, SourcesCardSchema, ActionsCardSchema]>;
623
+ declare const StructuredChatCardSchema: StructuredChatCardSchema;
624
+ type ToolResultErrorDataSchema = z.ZodObject<{
625
+ message: z.ZodString;
626
+ code: z.ZodOptional<z.ZodString>;
627
+ }>;
628
+ type ToolResultDataSchema = z.ZodObject<{
629
+ toolName: z.ZodString;
630
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
631
+ jobId: z.ZodOptional<z.ZodString>;
632
+ data: z.ZodOptional<z.ZodUnknown>;
633
+ error: z.ZodOptional<ToolResultErrorDataSchema>;
634
+ }>;
635
+ declare const ToolResultDataSchema: ToolResultDataSchema;
636
+ type AgentResponseUsageSchema = z.ZodObject<{
637
+ promptTokens: z.ZodNumber;
638
+ completionTokens: z.ZodNumber;
639
+ totalTokens: z.ZodNumber;
640
+ }>;
641
+ type AgentResponseSchema = z.ZodObject<{
642
+ text: z.ZodString;
643
+ error: z.ZodOptional<z.ZodString>;
644
+ toolResults: z.ZodOptional<z.ZodArray<ToolResultDataSchema>>;
645
+ cards: z.ZodOptional<z.ZodArray<StructuredChatCardSchema>>;
646
+ pendingConfirmations: z.ZodOptional<z.ZodArray<PendingConfirmationSchema>>;
647
+ usage: AgentResponseUsageSchema;
648
+ guestSettlement: z.ZodOptional<typeof guestTurnSettlementSchema>;
649
+ }>;
650
+ declare const AgentResponseSchema: AgentResponseSchema;
651
+ type AgentResponse = z.output<typeof AgentResponseSchema>;
652
+ //#endregion
653
+ //#region ../../shared/contracts/src/actor-ref.d.ts
654
+ type ActorRefSchema = z.ZodDiscriminatedUnion<[z.ZodObject<{
655
+ kind: z.ZodLiteral<"user">;
656
+ userId: z.ZodString;
657
+ canonicalId: z.ZodOptional<z.ZodString>;
658
+ }>, z.ZodObject<{
659
+ kind: z.ZodLiteral<"external">;
660
+ externalActorId: z.ZodString;
661
+ }>, z.ZodObject<{
662
+ kind: z.ZodLiteral<"agent">;
663
+ agentId: z.ZodString;
664
+ }>, z.ZodObject<{
665
+ kind: z.ZodLiteral<"service">;
666
+ serviceId: z.ZodString;
667
+ }>]>;
668
+ declare const actorRefSchema: ActorRefSchema;
669
+ type ActorRef = z.output<typeof actorRefSchema>;
670
+ //#endregion
671
+ //#region ../../shared/contracts/src/interface-principal.d.ts
672
+ interface InterfacePrincipalGrantState {
673
+ interfaceType: string;
674
+ principalKeyHash: string;
675
+ permissionLevel: "admin" | "trusted";
676
+ }
677
+ interface InterfaceAnchorBindingState {
678
+ interfaceType: string;
679
+ principalKeyHash: string;
680
+ }
681
+ interface RuntimeInterfacePrincipalState {
682
+ grants: InterfacePrincipalGrantState[];
683
+ anchors: InterfaceAnchorBindingState[];
684
+ }
685
+ //#endregion
686
+ //#region ../../shared/contracts/src/json.d.ts
687
+ type JsonPrimitive = null | boolean | number | string;
688
+ type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
689
+ /** A JSON document with an object at its root. */
690
+ interface JsonObject {
691
+ [key: string]: JsonValue;
692
+ }
693
+ //#endregion
694
+ //#region ../../shared/contracts/src/message-role.d.ts
695
+ type MessageRoleSchema = z.ZodEnum<{
696
+ user: "user";
697
+ assistant: "assistant";
698
+ }>;
699
+ declare const messageRoleSchema: MessageRoleSchema;
700
+ /** Canonical role of a stored conversation message. */
701
+ type MessageRole = z.output<typeof messageRoleSchema>;
702
+ //#endregion
703
+ //#region ../../shared/contracts/src/operation-provenance.d.ts
704
+ type ProvenanceEntityReferenceSchema = z.ZodObject<{
705
+ entityType: z.ZodString;
706
+ entityId: z.ZodString;
707
+ contentHash: z.ZodOptional<z.ZodString>;
708
+ }>;
709
+ declare const ProvenanceEntityReferenceSchema: ProvenanceEntityReferenceSchema;
710
+ type ProvenanceEntityReference = z.output<typeof ProvenanceEntityReferenceSchema>;
711
+ type OperationProvenanceSchema = z.ZodObject<{
712
+ rootJobId: z.ZodString;
713
+ causationId: z.ZodString;
714
+ projectionId: z.ZodOptional<z.ZodString>;
715
+ projectionLineage: z.ZodArray<z.ZodString>;
716
+ sourceEntity: z.ZodOptional<ProvenanceEntityReferenceSchema>;
717
+ derivationDepth: z.ZodNumber;
718
+ }>;
719
+ declare const OperationProvenanceSchema: OperationProvenanceSchema;
720
+ //#endregion
721
+ //#region ../../shared/contracts/src/publish-types.d.ts
722
+ type PublishMediaData = {
723
+ type: "document";
724
+ data: Buffer;
725
+ mimeType: "application/pdf";
726
+ filename: string;
727
+ } | {
728
+ type: "image";
729
+ data: Buffer;
730
+ mimeType: "image/png";
731
+ filename: string;
732
+ };
733
+ //#endregion
734
+ //#region ../../shared/contracts/src/response-types.d.ts
735
+ /**
736
+ * Query response schemas used throughout the system
737
+ */
738
+ type DefaultQuerySourceSchema = z.ZodObject<{
739
+ id: z.ZodString;
740
+ type: z.ZodString;
741
+ excerpt: z.ZodOptional<z.ZodString>;
742
+ relevance: z.ZodOptional<z.ZodNumber>;
743
+ }>;
744
+ type DefaultQueryResponseSchema = z.ZodObject<{
745
+ message: z.ZodString;
746
+ summary: z.ZodOptional<z.ZodString>;
747
+ topics: z.ZodOptional<z.ZodArray<z.ZodString>>;
748
+ sources: z.ZodOptional<z.ZodArray<DefaultQuerySourceSchema>>;
749
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
750
+ }>;
751
+ declare const defaultQueryResponseSchema: DefaultQueryResponseSchema;
752
+ type DefaultQueryResponse = z.output<typeof defaultQueryResponseSchema>;
753
+ //#endregion
754
+ //#region ../../shared/db/src/sqlite.d.ts
755
+ type SqliteDatabase = LibSQLDatabase<Record<string, unknown>>;
756
+ //#endregion
757
+ //#region ../../shared/utils/src/logger.d.ts
758
+ /**
759
+ * What a logger provides to callers.
355
760
  *
356
- * - `\n` in the string produces a `<br />` (for multi-line headlines)
357
- * - Any `*...*` run is wrapped in a `<span>` carrying `highlightClass`
761
+ * Consumers depend on this rather than on `ConsoleLogger`. The class carries
762
+ * private fields and a private constructor, so nothing else can be assignable
763
+ * to it — which is why every test double had to be asserted into place, a cast
764
+ * that also erased the check on the members the double did define.
765
+ */
766
+ interface Logger {
767
+ silly(message: string, ...args: unknown[]): void;
768
+ verbose(message: string, ...args: unknown[]): void;
769
+ debug(message: string, ...args: unknown[]): void;
770
+ info(message: string, ...args: unknown[]): void;
771
+ warn(message: string, ...args: unknown[]): void;
772
+ error(message: string, ...args: unknown[]): void;
773
+ child(context: string): Logger;
774
+ setUseStderr(useStderr: boolean): void;
775
+ }
776
+ //#endregion
777
+ //#region ../../shared/db/src/sqlite-columns.d.ts
778
+ /**
779
+ * Drizzle column annotation aliases for exported SQLite tables.
358
780
  *
359
- * Authors write the phrase as one natural string in markdown content;
360
- * the renderer does the structural split. Highlight styling is passed
361
- * per-brand (rizom.ai uses accent+midline, professional uses italic+accent)
362
- * so each consumer owns its own emphasis treatment while the parsing/
363
- * structure is shared.
781
+ * `isolatedDeclarations` requires exported table constants to carry explicit
782
+ * types, and drizzle's inferred column types are internal `SQLiteColumn`
783
+ * config objects. Before this module, every DB-owning package hand-wrote the
784
+ * same sixteen-key config literal per column kind; these aliases are that
785
+ * literal written once, with every axis the schemas actually vary on exposed
786
+ * as a parameter.
787
+ *
788
+ * Schema files keep short local aliases binding their table name (and any
789
+ * fixed axes) so the table declarations below them stay readable.
364
790
  */
365
- declare function renderHighlightedText(text: string, highlightClass: string): JSX.Element;
791
+ type SqliteTextColumn<TTableName extends string, TName extends string, TNotNull extends boolean, THasDefault extends boolean = false, TPrimaryKey extends boolean = false, THasRuntimeDefault extends boolean = false, TData = string, TEnumValues extends [string, ...string[]] = [string, ...string[]]> = SQLiteColumn<{
792
+ name: TName;
793
+ tableName: TTableName;
794
+ dataType: "string";
795
+ columnType: "SQLiteText";
796
+ data: TData;
797
+ driverParam: string;
798
+ notNull: TNotNull;
799
+ hasDefault: THasDefault;
800
+ isPrimaryKey: TPrimaryKey;
801
+ isAutoincrement: false;
802
+ hasRuntimeDefault: THasRuntimeDefault;
803
+ enumValues: TEnumValues;
804
+ baseColumn: never;
805
+ identity: undefined;
806
+ generated: undefined;
807
+ }, Record<string, never>, {
808
+ length: number | undefined;
809
+ }>;
810
+ type SqliteIntegerColumn<TTableName extends string, TName extends string, TNotNull extends boolean, THasDefault extends boolean = false, THasRuntimeDefault extends boolean = false, TPrimaryKey extends boolean = false, TAutoincrement extends boolean = false, TData = number> = SQLiteColumn<{
811
+ name: TName;
812
+ tableName: TTableName;
813
+ dataType: "number";
814
+ columnType: "SQLiteInteger";
815
+ data: TData;
816
+ driverParam: number;
817
+ notNull: TNotNull;
818
+ hasDefault: THasDefault;
819
+ isPrimaryKey: TPrimaryKey;
820
+ isAutoincrement: TAutoincrement;
821
+ hasRuntimeDefault: THasRuntimeDefault;
822
+ enumValues: undefined;
823
+ baseColumn: never;
824
+ identity: undefined;
825
+ generated: undefined;
826
+ }, Record<string, never>, Record<string, never>>;
827
+ type SqliteJsonColumn<TTableName extends string, TName extends string, TData, TNotNull extends boolean, TExtraConfig extends object = Record<string, never>, THasDefault extends boolean = false> = SQLiteColumn<{
828
+ name: TName;
829
+ tableName: TTableName;
830
+ dataType: "json";
831
+ columnType: "SQLiteTextJson";
832
+ data: TData;
833
+ driverParam: string;
834
+ notNull: TNotNull;
835
+ hasDefault: THasDefault;
836
+ isPrimaryKey: false;
837
+ isAutoincrement: false;
838
+ hasRuntimeDefault: false;
839
+ enumValues: undefined;
840
+ baseColumn: never;
841
+ identity: undefined;
842
+ generated: undefined;
843
+ }, Record<string, never>, TExtraConfig>;
366
844
  //#endregion
367
- //#region src/rizom/ui/site-info-links.d.ts
368
- declare function socialLinksToRizomLinks(siteInfo: Pick<SiteLayoutInfo, "socialLinks">, allowedPlatforms?: string[]): RizomLink[];
845
+ //#region ../../shell/entity-service/src/db/index.d.ts
846
+ type EntityDB = SqliteDatabase;
369
847
  //#endregion
370
- //#region src/rizom/ui/Wordmark.d.ts
371
- interface WordmarkProps {
372
- /** Brand name before the dot. Defaults to `"rizom"`. */
373
- name?: string;
374
- /** Suffix after the dot. Any string (e.g. `"ai"`, `"io"`, `"foundation"`). */
375
- brandSuffix: RizomBrandSuffix | string;
376
- className?: string;
377
- dotClassName?: string;
378
- suffixClassName?: string;
848
+ //#region ../../shell/entity-service/src/mutation-admission.d.ts
849
+ interface EntityMutationAdmissionTarget {
850
+ operation: "create" | "update" | "delete";
851
+ entityType: string;
852
+ entityId: string;
853
+ }
854
+ interface EntityMutationAdmission {
855
+ assertMutationAdmission(target: EntityMutationAdmissionTarget): Promise<void>;
379
856
  }
380
- declare const Wordmark: ({ name, brandSuffix, className, dotClassName, suffixClassName }: WordmarkProps) => JSX.Element;
381
857
  //#endregion
382
- //#region src/rizom/ui/Ecosystem.d.ts
383
- interface EcosystemCard {
384
- suffix: RizomBrandSuffix;
385
- title: string;
386
- body: string;
387
- linkLabel: string;
388
- linkHref: string;
858
+ //#region ../../shell/entity-service/src/projection-batch-contracts.d.ts
859
+ interface BulkMutationInput {
860
+ source: string;
861
+ operationId: string;
389
862
  }
390
- interface EcosystemContent {
391
- eyebrow: string;
392
- headline: string;
393
- cards: EcosystemCard[];
863
+ interface DurableBulkMutationRootInput extends BulkMutationInput {
864
+ rootJobId: string;
865
+ expectedChildren: number;
866
+ }
867
+ interface DurableBulkMutationChildInput extends DurableBulkMutationRootInput {
868
+ childKey: string;
869
+ jobId: string;
870
+ }
871
+ interface SettleDurableBulkMutationChildInput {
872
+ operationId: string;
873
+ childKey: string;
874
+ jobId: string;
875
+ outcome: "completed" | "failed";
876
+ }
877
+ interface ProjectionBatchOwnedJob {
878
+ jobId: string;
879
+ childKey: string;
880
+ status: "pending" | "processing" | "completed" | "failed";
881
+ terminalAt: number | null;
882
+ }
883
+ type ProjectionBatchRootReader = (rootJobId: string, operationId: string) => Promise<readonly ProjectionBatchOwnedJob[]>;
884
+ interface ProjectionBatchRecoveryResult {
885
+ fencedCallbacks: number;
886
+ releasedDurableRoots: number;
394
887
  }
395
- declare const Ecosystem: ({ eyebrow, headline, cards }: EcosystemContent) => JSX.Element;
396
888
  //#endregion
397
- //#region src/rizom/runtime/default-layout.d.ts
398
- declare const DefaultRizomLayout: ({ sections }: RizomLayoutProps) => JSX.Element;
889
+ //#region ../../shell/entity-service/src/projection-transaction-runner.d.ts
890
+ type EntityTransaction = Parameters<Parameters<EntityDB["transaction"]>[0]>[0];
399
891
  //#endregion
400
- //#region src/rizom/runtime/base-site.d.ts
401
- declare const rizomBaseSite: SiteDefinition;
892
+ //#region ../../shell/entity-service/src/projection-batch-coordinator.d.ts
893
+ interface ProjectionBatchDiagnostics {
894
+ preparing: number;
895
+ open: number;
896
+ abandoned: number;
897
+ expiredCallbackLeases: number;
898
+ oldestActiveAgeMs: number | null;
899
+ oldestProgressAgeMs: number | null;
900
+ }
402
901
  //#endregion
403
- //#region src/rizom/create-site.d.ts
404
- interface RizomRuntimeHooks {
405
- contentNamespace: string;
406
- templates?: Record<string, unknown>;
407
- dataSources?: unknown[];
902
+ //#region ../../shell/entity-service/src/projection-contracts.d.ts
903
+ type ProjectionJsonObject = JsonObject;
904
+ interface ProjectionEntityWrite<TMetadata extends ProjectionJsonObject = ProjectionJsonObject> {
905
+ id: string;
906
+ entityType: string;
907
+ content: string;
908
+ metadata: TMetadata;
909
+ visibility: ContentVisibility;
408
910
  }
409
- interface CreateRizomSiteOptions {
410
- packageName: string;
411
- layout: unknown;
412
- routes: RouteDefinitionInput[];
413
- content?: SiteContent;
911
+ type ProjectionWriteIntent<TMetadata extends ProjectionJsonObject = ProjectionJsonObject> = {
912
+ operation: "upsert";
913
+ entity: ProjectionEntityWrite<TMetadata>;
914
+ } | {
915
+ operation: "delete";
916
+ entityType: string;
917
+ id: string;
918
+ };
919
+ //#endregion
920
+ //#region ../../shell/entity-service/src/schema/projection-state.d.ts
921
+ type ProjectionTextColumn<TTable extends string, TName extends string, TNotNull extends boolean, THasDefault extends boolean = false, TPrimaryKey extends boolean = false, TData = string, TEnumValues extends [string, ...string[]] = [string, ...string[]]> = SqliteTextColumn<TTable, TName, TNotNull, THasDefault, TPrimaryKey, false, TData, TEnumValues>;
922
+ type ProjectionIntegerColumn<TTable extends string, TName extends string, TNotNull extends boolean, THasDefault extends boolean = false, TPrimaryKey extends boolean = false, TAutoincrement extends boolean = false> = SqliteIntegerColumn<TTable, TName, TNotNull, THasDefault, false, TPrimaryKey, TAutoincrement>;
923
+ type ProjectionJsonColumn<TTable extends string, TName extends string, TData, THasDefault extends boolean = false> = SqliteJsonColumn<TTable, TName, TData, true, {
924
+ $type: TData;
925
+ }, THasDefault>;
926
+ type ProjectionDirtyInputsTable = SQLiteTableWithColumns<{
927
+ name: "projection_dirty_inputs";
928
+ schema: undefined;
929
+ columns: {
930
+ generation: ProjectionIntegerColumn<"projection_dirty_inputs", "generation", true, true, true>;
931
+ sourceType: ProjectionTextColumn<"projection_dirty_inputs", "source_type", true>;
932
+ sourceId: ProjectionTextColumn<"projection_dirty_inputs", "source_id", true>;
933
+ revision: ProjectionTextColumn<"projection_dirty_inputs", "revision", true>;
934
+ operation: ProjectionTextColumn<"projection_dirty_inputs", "operation", true, false, false, "upsert" | "delete", ["upsert", "delete"]>;
935
+ markedAt: ProjectionIntegerColumn<"projection_dirty_inputs", "marked_at", true>;
936
+ };
937
+ dialect: "sqlite";
938
+ }>;
939
+ type ProjectionWavesTable = SQLiteTableWithColumns<{
940
+ name: "projection_waves";
941
+ schema: undefined;
942
+ columns: {
943
+ id: ProjectionTextColumn<"projection_waves", "id", true, false, true>;
944
+ cutoffGeneration: ProjectionIntegerColumn<"projection_waves", "cutoff_generation", true>;
945
+ graphFingerprint: ProjectionTextColumn<"projection_waves", "graph_fingerprint", true>;
946
+ admissionEpoch: ProjectionIntegerColumn<"projection_waves", "admission_epoch", true, true>;
947
+ status: ProjectionTextColumn<"projection_waves", "status", true, false, false, "running" | "completed" | "failed" | "superseded", ["running", "completed", "failed", "superseded"]>;
948
+ startedAt: ProjectionIntegerColumn<"projection_waves", "started_at", true>;
949
+ completedAt: ProjectionIntegerColumn<"projection_waves", "completed_at", false>;
950
+ };
951
+ dialect: "sqlite";
952
+ }>;
953
+ type ProjectionIncidentsTable = SQLiteTableWithColumns<{
954
+ name: "projection_incidents";
955
+ schema: undefined;
956
+ columns: {
957
+ waveId: ProjectionTextColumn<"projection_incidents", "wave_id", true, false, true>;
958
+ ruleId: ProjectionTextColumn<"projection_incidents", "rule_id", true>;
959
+ jobId: ProjectionTextColumn<"projection_incidents", "job_id", false>;
960
+ failureReason: ProjectionTextColumn<"projection_incidents", "failure_reason", true>;
961
+ recoveryGeneration: ProjectionIntegerColumn<"projection_incidents", "recovery_generation", true>;
962
+ createdAt: ProjectionIntegerColumn<"projection_incidents", "created_at", true>;
963
+ resolvedAt: ProjectionIntegerColumn<"projection_incidents", "resolved_at", false>;
964
+ };
965
+ dialect: "sqlite";
966
+ }>;
967
+ type ProjectionWaveInputsTable = SQLiteTableWithColumns<{
968
+ name: "projection_wave_inputs";
969
+ schema: undefined;
970
+ columns: {
971
+ waveId: ProjectionTextColumn<"projection_wave_inputs", "wave_id", true>;
972
+ sourceType: ProjectionTextColumn<"projection_wave_inputs", "source_type", true>;
973
+ sourceId: ProjectionTextColumn<"projection_wave_inputs", "source_id", true>;
974
+ revision: ProjectionTextColumn<"projection_wave_inputs", "revision", true>;
975
+ operation: ProjectionTextColumn<"projection_wave_inputs", "operation", true, false, false, "upsert" | "delete", ["upsert", "delete"]>;
976
+ generation: ProjectionIntegerColumn<"projection_wave_inputs", "generation", true>;
977
+ };
978
+ dialect: "sqlite";
979
+ }>;
980
+ interface ProjectionChangedTarget {
981
+ entityType: string;
982
+ entityId: string;
983
+ operation: "upsert" | "delete";
984
+ contentHash?: string | undefined;
985
+ }
986
+ type ProjectionWaveRulesTable = SQLiteTableWithColumns<{
987
+ name: "projection_wave_rules";
988
+ schema: undefined;
989
+ columns: {
990
+ waveId: ProjectionTextColumn<"projection_wave_rules", "wave_id", true>;
991
+ ruleId: ProjectionTextColumn<"projection_wave_rules", "rule_id", true>;
992
+ targetType: ProjectionTextColumn<"projection_wave_rules", "target_type", true>;
993
+ level: ProjectionIntegerColumn<"projection_wave_rules", "level", true>;
994
+ jobId: ProjectionTextColumn<"projection_wave_rules", "job_id", false>;
995
+ status: ProjectionTextColumn<"projection_wave_rules", "status", true, false, false, "pending" | "queued" | "completed" | "failed", ["pending", "queued", "completed", "failed"]>;
996
+ inputFingerprint: ProjectionTextColumn<"projection_wave_rules", "input_fingerprint", false>;
997
+ changedTargets: ProjectionJsonColumn<"projection_wave_rules", "changed_targets", ProjectionChangedTarget[], true>;
998
+ };
999
+ dialect: "sqlite";
1000
+ }>;
1001
+ type ProjectionRuleMemosTable = SQLiteTableWithColumns<{
1002
+ name: "projection_rule_memos";
1003
+ schema: undefined;
1004
+ columns: {
1005
+ ruleId: ProjectionTextColumn<"projection_rule_memos", "rule_id", true>;
1006
+ ruleVersion: ProjectionTextColumn<"projection_rule_memos", "rule_version", true>;
1007
+ inputFingerprint: ProjectionTextColumn<"projection_rule_memos", "input_fingerprint", true>;
1008
+ writeIntents: ProjectionJsonColumn<"projection_rule_memos", "write_intents", ProjectionWriteIntent[]>;
1009
+ createdAt: ProjectionIntegerColumn<"projection_rule_memos", "created_at", true>;
1010
+ };
1011
+ dialect: "sqlite";
1012
+ }>;
1013
+ declare const projectionDirtyInputs: ProjectionDirtyInputsTable;
1014
+ declare const projectionWaves: ProjectionWavesTable;
1015
+ declare const projectionIncidents: ProjectionIncidentsTable;
1016
+ declare const projectionWaveInputs: ProjectionWaveInputsTable;
1017
+ declare const projectionWaveRules: ProjectionWaveRulesTable;
1018
+ declare const projectionRuleMemos: ProjectionRuleMemosTable;
1019
+ type ProjectionDirtyInput = typeof projectionDirtyInputs.$inferSelect;
1020
+ type ProjectionIncident = typeof projectionIncidents.$inferSelect;
1021
+ type ProjectionWave = typeof projectionWaves.$inferSelect;
1022
+ type ProjectionWaveInput = typeof projectionWaveInputs.$inferSelect;
1023
+ type ProjectionWaveRule = typeof projectionWaveRules.$inferSelect;
1024
+ type ProjectionRuleMemo = typeof projectionRuleMemos.$inferSelect;
1025
+ //#endregion
1026
+ //#region ../../shell/entity-service/src/projection-rule-contracts.d.ts
1027
+ interface GetProjectionRuleMemoInput {
1028
+ ruleId: string;
1029
+ ruleVersion: string;
1030
+ inputFingerprint: string;
1031
+ }
1032
+ interface ProjectionWaveRuleInput {
1033
+ ruleId: string;
1034
+ targetType: string;
1035
+ level: number;
1036
+ }
1037
+ interface ApplyProjectionRuleResultInput {
1038
+ waveId: string;
1039
+ ruleId: string;
1040
+ ruleVersion: string;
1041
+ inputFingerprint: string;
1042
+ writeIntents: readonly ProjectionWriteIntent[];
1043
+ completedAt: number;
1044
+ }
1045
+ interface ProjectionRuleMemoValue extends Omit<ProjectionRuleMemo, "writeIntents"> {
1046
+ writeIntents: ProjectionWriteIntent[];
1047
+ }
1048
+ //#endregion
1049
+ //#region ../../shell/entity-service/src/projection-wave-contracts.d.ts
1050
+ interface ProjectionIncidentDiagnostics {
1051
+ total: number;
1052
+ incidents: ProjectionIncident[];
1053
+ }
1054
+ interface ClaimProjectionWaveInput {
1055
+ waveId: string;
1056
+ graphFingerprint: string;
1057
+ startedAt: number;
1058
+ }
1059
+ interface ProjectionIncidentInput {
1060
+ waveId: string;
1061
+ ruleId: string;
1062
+ jobId: string | null;
1063
+ failureReason: string;
1064
+ failedAt: number;
1065
+ }
1066
+ //#endregion
1067
+ //#region ../../shell/entity-service/src/entity-export-types.d.ts
1068
+ interface EntityExportIntent {
1069
+ entityType: string;
1070
+ entityId: string;
1071
+ operation: "upsert" | "delete";
1072
+ revision: string;
1073
+ markedAt: number;
1074
+ }
1075
+ interface EntityExportAcknowledgement {
1076
+ entityType: string;
1077
+ entityId: string;
1078
+ revision: string;
1079
+ }
1080
+ interface AcknowledgeEntityExportsRequest {
1081
+ intents: readonly EntityExportAcknowledgement[];
1082
+ }
1083
+ //#endregion
1084
+ //#region ../../shell/entity-service/src/sqlite-asset-repository.d.ts
1085
+ type AssetTransaction = Parameters<Parameters<EntityDB["transaction"]>[0]>[0];
1086
+ /** Validated and copied before a transaction acquires SQLite's write lock. */
1087
+ interface StagedAsset extends AssetRecord {
1088
+ bytes: Buffer;
1089
+ }
1090
+ /**
1091
+ * SQLite implementation owned by the entity database. Durable insertion is
1092
+ * intentionally package-private and requires the entity transaction type.
1093
+ */
1094
+ declare class SqliteAssetRepository implements AssetReader {
1095
+ private readonly db;
1096
+ private readonly maxBytes;
1097
+ private readonly now;
1098
+ constructor(db: EntityDB, options?: {
1099
+ maxBytes?: number;
1100
+ now?: () => number;
1101
+ });
1102
+ /** Validate and copy bytes before entering an entity transaction. */
1103
+ stage(prepared: PreparedAsset): StagedAsset;
414
1104
  /**
415
- * Schema-first section groups (authored via `@rizom/site`'
416
- * `defineSection`/`sectionGroup`). Registered as content templates at brain
417
- * boot exactly like `content`, so the Studio + directory-sync + resolver treat
418
- * them identically — but the section shape is derived from one zod schema.
1105
+ * Bind asset-backed entity content to bytes in the same transaction. Legacy
1106
+ * inline content is left alone for the temporary image migration window.
419
1107
  */
420
- sections?: SiteSectionGroup | SiteSectionGroup[];
421
- themeOverride?: string;
1108
+ bindEntityContent(transaction: AssetTransaction, content: string, staged?: StagedAsset): Promise<void>;
1109
+ read(ref: AssetRef): Promise<Uint8Array>;
1110
+ stat(ref: AssetRef): Promise<AssetStat | null>;
1111
+ verify(ref: AssetRef): Promise<AssetVerification>;
1112
+ private insertOrVerify;
1113
+ private assertExists;
1114
+ private assertSize;
1115
+ }
1116
+ //#endregion
1117
+ //#region ../../shell/entity-service/src/projection-write-intent-applier.d.ts
1118
+ /** Stored row plus timestamps, including schema-normalized owner metadata. */
1119
+ interface ProjectionPersistEntity extends Omit<ProjectionEntityWrite, "metadata"> {
1120
+ metadata: Record<string, unknown>;
1121
+ contentHash: string;
1122
+ created: string;
1123
+ updated: string;
1124
+ }
1125
+ interface ProjectionEntityStoragePolicy {
1126
+ assetRepository: SqliteAssetRepository;
1127
+ isAssetBacked(entityType: string): boolean;
1128
+ isFullTextSearchable(entityType: string): boolean;
1129
+ /** Normalize source fields and check read-only persistence constraints
1130
+ * inside the admitted transaction, before any upsert effects. */
1131
+ prepareEntity?(entity: ProjectionPersistEntity, operation: "create" | "update"): Promise<ProjectionPersistEntity>;
1132
+ }
1133
+ //#endregion
1134
+ //#region ../../shell/entity-service/src/projection-store.d.ts
1135
+ interface MarkProjectionDirtyInput {
1136
+ sourceType: string;
1137
+ sourceId: string;
1138
+ revision: string;
1139
+ operation: "upsert" | "delete";
1140
+ markedAt: number;
1141
+ }
1142
+ interface ProjectionOwnedEntityInput {
1143
+ entityType: string;
1144
+ id: string;
1145
+ }
1146
+ /** Entity-database persistence boundary for scheduler coordination state. */
1147
+ declare class ProjectionStore {
1148
+ private readonly db;
1149
+ private readonly writeIntentApplier;
1150
+ private readonly transactions;
1151
+ private readonly batches;
1152
+ private readonly waves;
1153
+ private readonly rules;
1154
+ constructor(db: EntityDB, mutationAdmission?: EntityMutationAdmission, now?: () => number, storagePolicy?: ProjectionEntityStoragePolicy);
1155
+ runBulkMutation<TResult>(input: BulkMutationInput, mutation: () => Promise<TResult>): Promise<TResult>;
422
1156
  /**
423
- * Presentation config for entity-backed list/detail routes (labels, plural
424
- * names, navigation). Merged onto the base site's empty map. Sites that
425
- * surface plugin lists — e.g. `post`→"Essay", `deck`→"Talk" — set it here.
1157
+ * Force the batch coordinator's ambient scope to empty for the duration of
1158
+ * `fn`. A caller that defines a fresh unit of work (the job queue, once per
1159
+ * job) must wrap that unit in this so it never inherits another unit's
1160
+ * batch identity — see ProjectionBatchCoordinator.runFreshBatchScope.
426
1161
  */
427
- entityDisplay?: Record<string, EntityDisplayEntry>;
428
- /** Advanced runtime hooks for in-repo sites that need custom template/data-source wiring. */
429
- runtime?: RizomRuntimeHooks;
1162
+ runFreshBatchScope<T>(fn: () => T): T;
1163
+ prepareDurableBulkMutation(input: DurableBulkMutationRootInput): Promise<void>;
1164
+ finalizeDurableBulkMutationEnqueue(operationId: string): Promise<void>;
1165
+ failDurableBulkMutationEnqueue(operationId: string): Promise<void>;
1166
+ runDurableBulkMutationChild<TResult>(input: DurableBulkMutationChildInput, mutation: () => Promise<TResult>): Promise<TResult>;
1167
+ settleDurableBulkMutationChild(input: SettleDurableBulkMutationChildInput): Promise<boolean>;
1168
+ recoverProjectionBatches(readRoot: ProjectionBatchRootReader): Promise<ProjectionBatchRecoveryResult>;
1169
+ cleanupProjectionBatches(retentionMs?: number, maximumRecords?: number): Promise<number>;
1170
+ getProjectionBatchDiagnostics(): Promise<ProjectionBatchDiagnostics>;
1171
+ isProjectionOwnedEntity(input: ProjectionOwnedEntityInput): Promise<boolean>;
1172
+ releaseProjectionOwnership(input: ProjectionOwnedEntityInput): Promise<void>;
1173
+ transferEntityAuthority<TResult>(input: ProjectionOwnedEntityInput, mutation: (transaction: EntityTransaction) => Promise<TResult>): Promise<TResult>;
1174
+ markDirty(input: MarkProjectionDirtyInput): Promise<number>;
1175
+ withDirtyInput<TResult>(input: MarkProjectionDirtyInput, mutation: (transaction: EntityTransaction) => Promise<TResult>): Promise<TResult>;
1176
+ listPendingInputs(): Promise<ProjectionDirtyInput[]>;
1177
+ hasActiveProjectionBatch(): Promise<boolean>;
1178
+ claimPendingWave(input: ClaimProjectionWaveInput): Promise<ProjectionWave | null>;
1179
+ listWaveInputs(waveId: string): Promise<ProjectionWaveInput[]>;
1180
+ getWave(waveId: string): Promise<ProjectionWave | null>;
1181
+ getActiveWave(): Promise<ProjectionWave | null>;
1182
+ completeWave(waveId: string, completedAt: number): Promise<ProjectionWave>;
1183
+ supersedeWaveIfStale(waveId: string, supersededAt: number): Promise<boolean>;
1184
+ failWave(waveId: string, failedAt: number): Promise<ProjectionWave>;
1185
+ failWaveWithIncident(input: ProjectionIncidentInput): Promise<ProjectionWave>;
1186
+ getUnresolvedProjectionIncidentDiagnostics(limit?: number): Promise<ProjectionIncidentDiagnostics>;
1187
+ putWaveRules(waveId: string, rules: readonly ProjectionWaveRuleInput[]): Promise<void>;
1188
+ listWaveRules(waveId: string): Promise<ProjectionWaveRule[]>;
1189
+ queueWaveRule(waveId: string, ruleId: string, jobId: string): Promise<ProjectionWaveRule>;
1190
+ getWaveRule(waveId: string, ruleId: string): Promise<ProjectionWaveRule | null>;
1191
+ applyRuleResult(input: ApplyProjectionRuleResultInput): Promise<ProjectionWaveRule | null>;
1192
+ getRuleMemo(input: GetProjectionRuleMemoInput): Promise<ProjectionRuleMemoValue | null>;
430
1193
  }
431
- declare function createRizomSite(options: CreateRizomSiteOptions): SitePackage;
432
1194
  //#endregion
433
- //#region src/site.d.ts
434
- declare const rizomAiSite: SitePackage;
1195
+ //#region ../../shell/entity-service/src/entity-write-contracts.d.ts
1196
+ /** null means create only if absent; a token means replace that incarnation. */
1197
+ interface EntityWriteCondition {
1198
+ expectedRevision: string | null;
1199
+ }
435
1200
  //#endregion
436
- //#region src/routes.d.ts
1201
+ //#region ../../shell/entity-service/src/types.d.ts
437
1202
  /**
438
- * The consolidated Rizom site routes. The home page composes the living-memory
439
- * content namespace; the layout owns navigation (the
440
- * two-tier faces strip), so routes stay out of the entity nav.
1203
+ * Options for entity mutation operations (create, update, upsert)
441
1204
  */
442
- declare const aiRoutes: RouteDefinitionInput[];
443
- //#endregion
444
- //#region src/home.d.ts
1205
+ interface EntityMutationEventContext {
1206
+ conversationId?: string;
1207
+ channelId?: string;
1208
+ runId?: string;
1209
+ toolCallId?: string;
1210
+ actor?: ActorRef;
1211
+ interfaceType?: string;
1212
+ }
1213
+ interface EntityWriteSnapshot {
1214
+ entity: BaseEntity;
1215
+ revision: string;
1216
+ }
1217
+ type EntityPersistenceOrigin = "ordinary" | "directory-sync";
1218
+ interface EntityJobOptions {
1219
+ priority?: number;
1220
+ maxRetries?: number;
1221
+ eventContext?: EntityMutationEventContext;
1222
+ /**
1223
+ * Identifies authoritative file imports/deletes so they clear, rather than
1224
+ * create, an outbound directory-export intent.
1225
+ */
1226
+ persistenceOrigin?: EntityPersistenceOrigin;
1227
+ }
1228
+ /**
1229
+ * Options for entity creation (extends EntityJobOptions with deduplication)
1230
+ */
1231
+ interface CreateEntityOptions extends EntityJobOptions {
1232
+ /** Cancel before the atomic write boundary, not after a mutation commits. */
1233
+ signal?: AbortSignal;
1234
+ /** Runtime-only guard over the final persisted fields, immediately before writing. */
1235
+ beforeWrite?: (entity: Readonly<BaseEntity>) => Promise<void>;
1236
+ deduplicateId?: boolean;
1237
+ /** Atomic create-if-absent. Cannot deduplicate. */
1238
+ conditionalWrite?: EntityWriteCondition;
1239
+ }
1240
+ /** Options for updating an existing entity. */
1241
+ interface UpdateEntityOptions extends EntityJobOptions {
1242
+ /** Cancel before the atomic write boundary, not after a mutation commits. */
1243
+ signal?: AbortSignal;
1244
+ /** Runtime-only guard over the final persisted fields, immediately before writing. */
1245
+ beforeWrite?: (entity: Readonly<BaseEntity>) => Promise<void>;
1246
+ /** Apply only while the stored entity still has this content hash. */
1247
+ expectedContentHash?: string | undefined;
1248
+ /** Atomic full-revision replace. */
1249
+ conditionalWrite?: EntityWriteCondition;
1250
+ }
1251
+ /**
1252
+ * Result of an entity mutation that triggers an embedding job.
1253
+ * When skipped is true, no DB write, event, or embedding job was produced.
1254
+ */
1255
+ interface EntityMutationResult {
1256
+ entityId: string;
1257
+ jobId: string;
1258
+ skipped: boolean;
1259
+ skipReason?: "content-conflict" | undefined;
1260
+ }
1261
+ /**
1262
+ * Input for adapter-validated direct creation from finalized markdown.
1263
+ */
1264
+ interface CreateEntityFromMarkdownInput {
1265
+ entityType: string;
1266
+ id: string;
1267
+ markdown: string;
1268
+ /** Explicit core visibility. When omitted, markdown frontmatter or the public default applies. */
1269
+ visibility?: ContentVisibility;
1270
+ }
1271
+ /**
1272
+ * Data for storing an embedding for an entity
1273
+ */
1274
+ interface StoreEmbeddingData {
1275
+ entityId: string;
1276
+ entityType: string;
1277
+ embedding: Float32Array;
1278
+ contentHash: string;
1279
+ }
1280
+ type EntitySchema<T> = z.ZodType<T, unknown>;
1281
+ type UnknownEntitySchema = EntitySchema<unknown>;
1282
+ type FrontmatterSchema = z.ZodObject<z.ZodRawShape>;
1283
+ /**
1284
+ * Base entity type - generic to support typed metadata
1285
+ * TMetadata defaults to Record<string, unknown> for backward compatibility
1286
+ */
1287
+ interface BaseEntity<TMetadata = Record<string, unknown>> {
1288
+ id: string;
1289
+ entityType: string;
1290
+ content: string;
1291
+ created: string;
1292
+ updated: string;
1293
+ visibility: ContentVisibility;
1294
+ metadata: TMetadata;
1295
+ /** SHA256 hash of content for change detection */
1296
+ contentHash: string;
1297
+ }
1298
+ /**
1299
+ * Entity input type for creation - allows partial entities with optional system fields
1300
+ * contentHash is excluded because it's computed automatically by the entity service
1301
+ */
1302
+ type EntityInput<T extends BaseEntity> = Omit<T, "id" | "created" | "updated" | "contentHash" | "visibility"> & {
1303
+ id?: string;
1304
+ created?: string;
1305
+ updated?: string;
1306
+ visibility?: RawContentVisibility;
1307
+ };
1308
+ /**
1309
+ * Search result type
1310
+ */
1311
+ interface SearchResult<T extends BaseEntity = BaseEntity> {
1312
+ entity: T;
1313
+ score: number;
1314
+ excerpt: string;
1315
+ }
1316
+ /**
1317
+ * Normalized system_create input shape used by plugin create interceptors.
1318
+ */
1319
+ interface CreateCoverImageInput {
1320
+ generate?: boolean | undefined;
1321
+ prompt?: string | undefined;
1322
+ }
1323
+ interface CreateFromAttachmentInput {
1324
+ kind: "entity-attachment";
1325
+ sourceEntityType: string;
1326
+ sourceEntityId: string;
1327
+ attachmentType: string;
1328
+ }
1329
+ interface CreateFromUploadInput {
1330
+ kind: "upload";
1331
+ id: string;
1332
+ }
1333
+ interface CreateFromConversationMessageInput {
1334
+ kind: "conversation-message";
1335
+ messageId?: string | undefined;
1336
+ }
1337
+ type CreateFromInput = CreateFromAttachmentInput | CreateFromUploadInput | CreateFromConversationMessageInput;
1338
+ type CreateTransform = "extract-markdown" | "preserve";
1339
+ interface CreateInput {
1340
+ entityType: string;
1341
+ prompt?: string;
1342
+ title?: string;
1343
+ visibility?: ContentVisibility;
1344
+ content?: string;
1345
+ url?: string;
1346
+ from?: CreateFromInput;
1347
+ transform?: CreateTransform;
1348
+ replace?: boolean;
1349
+ sourceEntityType?: string;
1350
+ sourceEntityId?: string;
1351
+ sourceEntityIds?: string[];
1352
+ targetEntityType?: string;
1353
+ targetEntityId?: string;
1354
+ coverImage?: boolean | CreateCoverImageInput;
1355
+ }
1356
+ /**
1357
+ * Minimal caller context forwarded to plugin create interceptors.
1358
+ */
1359
+ interface CreateExecutionContext {
1360
+ interfaceType: string;
1361
+ actor: ActorRef;
1362
+ channelId?: string;
1363
+ channelName?: string;
1364
+ }
1365
+ /**
1366
+ * Result returned to system_create when a plugin fully handles creation.
1367
+ */
1368
+ declare const createResultAttachmentSchema: z.ZodObject<{
1369
+ mediaType: z.ZodString;
1370
+ url: z.ZodString;
1371
+ downloadUrl: z.ZodOptional<z.ZodString>;
1372
+ previewUrl: z.ZodOptional<z.ZodString>;
1373
+ filename: z.ZodOptional<z.ZodString>;
1374
+ sizeBytes: z.ZodOptional<z.ZodNumber>;
1375
+ source: z.ZodOptional<z.ZodObject<{
1376
+ entityType: z.ZodOptional<z.ZodString>;
1377
+ entityId: z.ZodOptional<z.ZodString>;
1378
+ attachmentType: z.ZodOptional<z.ZodString>;
1379
+ }>>;
1380
+ }>;
1381
+ type CreateResultAttachment = z.infer<typeof createResultAttachmentSchema>;
1382
+ type CreateResult = {
1383
+ success: true;
1384
+ data: {
1385
+ entityId?: string;
1386
+ jobId?: string;
1387
+ status: string;
1388
+ attachment?: CreateResultAttachment;
1389
+ };
1390
+ } | {
1391
+ success: false;
1392
+ error: string;
1393
+ };
1394
+ /**
1395
+ * Plugin create interceptors can either fully handle creation,
1396
+ * or continue with a rewritten normalized input.
1397
+ */
1398
+ type CreateInterceptionResult = {
1399
+ kind: "handled";
1400
+ result: CreateResult;
1401
+ } | {
1402
+ kind: "continue";
1403
+ input: CreateInput;
1404
+ };
1405
+ type CreateInterceptor = (input: CreateInput, executionContext: CreateExecutionContext) => Promise<CreateInterceptionResult>;
1406
+ interface UploadSaveInput {
1407
+ upload: CreateFromUploadInput;
1408
+ title?: string;
1409
+ visibility?: ContentVisibility;
1410
+ }
1411
+ type UploadSaveHandler = (input: UploadSaveInput, executionContext: CreateExecutionContext) => Promise<CreateResult>;
1412
+ interface UploadSaveHandlerRegistration {
1413
+ entityType: string;
1414
+ mediaTypes: string[];
1415
+ handler: UploadSaveHandler;
1416
+ }
1417
+ /**
1418
+ * Called before an entity is persisted (on create or update). Throws to reject
1419
+ * the write with an operator-facing error. Use this for cross-entity invariants
1420
+ * the per-entity Zod schema cannot express. Includes projection upserts, which
1421
+ * validate inside their transaction. Read-only lookups are allowed; mutations
1422
+ * and external effects are not.
1423
+ */
1424
+ type PersistValidator<T extends BaseEntity = BaseEntity> = (entity: T, context: {
1425
+ operation: "create" | "update";
1426
+ }) => Promise<void>;
445
1427
  /**
446
- * The umbrella home page's authored sections. The namespace ("home") matches
447
- * the route id, so each stores as site-content/home/<section>.md and resolves
448
- * as "home:<section>". Two sections live elsewhere: the hero is the live
449
- * agent proximity map (agent-discovery:proximity-map) and the proof/ask is
450
- * the knowledge map (topics:knowledge-map) — both authored via overlay
451
- * markdown merged over their live datasource payloads.
1428
+ * Interface for entity adapter - handles conversion between entities and markdown
1429
+ * following the hybrid storage model
1430
+ *
1431
+ * @template TEntity - The full entity type
1432
+ * @template TMetadata - The metadata type (defaults to Record<string, unknown>)
452
1433
  */
453
- declare const homeSections: SiteSectionGroup;
1434
+ interface EntityAdapter<TEntity extends BaseEntity<TMetadata>, TMetadata = Record<string, unknown>> {
1435
+ entityType: string;
1436
+ /**
1437
+ * One declarative sentence describing what this entity type is. This is the
1438
+ * data the model reads to select `entityType`, replacing hardcoded example
1439
+ * phrasings in system instructions. Required: every type must define itself.
1440
+ */
1441
+ purpose: string;
1442
+ schema: EntitySchema<TEntity>;
1443
+ toMarkdown(entity: TEntity): string;
1444
+ fromMarkdown(markdown: string): Partial<TEntity>;
1445
+ extractMetadata(entity: TEntity): TMetadata;
1446
+ parseFrontMatter<TFrontmatter>(markdown: string, schema: {
1447
+ parse(data: unknown): TFrontmatter;
1448
+ }): TFrontmatter;
1449
+ generateFrontMatter(entity: TEntity): string;
1450
+ /** Optional: Zod schema for frontmatter fields. Used by Studio config generation. */
1451
+ frontmatterSchema?: z.ZodObject<z.ZodRawShape>;
1452
+ /** Optional: Declares this entity type is a singleton (one file, e.g., identity/identity.md). Used by Studio to generate files collection. */
1453
+ isSingleton?: boolean;
1454
+ /** Optional: Whether this entity has a free-form markdown body below frontmatter. Defaults to true. When false, Studio omits the body widget. */
1455
+ hasBody?: boolean;
1456
+ /** Returns a markdown body template with section headings for this entity type. Empty string for free-form entities. */
1457
+ getBodyTemplate(): string;
1458
+ /** Optional: Declares that this entity type supports cover images via coverImageId in frontmatter */
1459
+ supportsCoverImage?: boolean;
1460
+ /**
1461
+ * Optional: the `metadata.status` values that count as published for
1462
+ * `publishedOnly` queries (production site builds). Declaring this makes the
1463
+ * list exact — entities without a status are NOT published. When absent, the
1464
+ * default lifecycle semantics apply: status `published`, `active`, or no
1465
+ * status at all.
1466
+ */
1467
+ publishedStatuses?: string[];
1468
+ /** Optional: Extract coverImageId from entity content/frontmatter */
1469
+ getCoverImageId?(entity: TEntity): string | undefined;
1470
+ /**
1471
+ * Optional: build the markdown content and metadata for a queued-generation stub.
1472
+ * When undefined, this entity type does not support prompt-based queued creation
1473
+ * via system_create; the tool will reject the call rather than silently degrade.
1474
+ * The returned metadata must satisfy this entity's metadata schema (with
1475
+ * status set to "generating"); central code only stamps id/timestamps/visibility.
1476
+ */
1477
+ buildStub?(input: {
1478
+ id: string;
1479
+ title: string;
1480
+ }): {
1481
+ content: string;
1482
+ metadata: TMetadata;
1483
+ };
1484
+ }
1485
+ /**
1486
+ * Sort field specification for multi-field sorting
1487
+ */
1488
+ interface SortField {
1489
+ /** Field to sort by - "created", "updated", or a metadata field name */
1490
+ field: string;
1491
+ /** Sort direction */
1492
+ direction: "asc" | "desc";
1493
+ /** Sort NULL values before non-NULL values (default: false / SQLite default) */
1494
+ nullsFirst?: boolean;
1495
+ }
1496
+ /**
1497
+ * List entities options
1498
+ * Generic over metadata type for type-safe filtering
1499
+ */
1500
+ interface EntityReadOptions {
1501
+ /** Cooperative boundary checks, not proof of remote SQL cancellation. */
1502
+ signal?: AbortSignal;
1503
+ }
1504
+ interface ListOptions<TMetadata = Record<string, unknown>> extends EntityReadOptions {
1505
+ limit?: number;
1506
+ offset?: number;
1507
+ /** Multi-field sorting - supports system fields (created, updated) and metadata fields */
1508
+ sortFields?: SortField[];
1509
+ filter?: {
1510
+ metadata?: Partial<TMetadata>;
1511
+ /** Literal substring search through serialized content, including frontmatter. */
1512
+ contentContains?: string | undefined;
1513
+ /** Exact visibility, intersected with visibilityScope rather than widening it. */
1514
+ visibility?: ContentVisibility | undefined;
1515
+ visibilityScope?: ContentVisibility | undefined;
1516
+ };
1517
+ /** Filter to only entities with metadata.status = "published" */
1518
+ publishedOnly?: boolean;
1519
+ }
1520
+ /**
1521
+ * Search options
1522
+ */
1523
+ interface SearchOptions extends EntityReadOptions {
1524
+ limit?: number;
1525
+ offset?: number;
1526
+ types?: string[];
1527
+ excludeTypes?: string[];
1528
+ sortBy?: "relevance" | "created" | "updated";
1529
+ sortDirection?: "asc" | "desc";
1530
+ /** Score multipliers per entity type - applied after initial search */
1531
+ weight?: Record<string, number>;
1532
+ visibilityScope?: ContentVisibility | undefined;
1533
+ /** Include queued/failed generation stubs in search results (default: false) */
1534
+ includeUngenerated?: boolean;
1535
+ /** Only entities their type counts as published, as for published-only listings (default: false) */
1536
+ publishedOnly?: boolean;
1537
+ /** Minimum relevance score to return. Omit for no score cutoff. */
1538
+ minScore?: number;
1539
+ }
1540
+ type ProjectionSourceRole = "canonical" | "primary" | "secondary" | "supporting" | "ambient" | "excluded";
1541
+ /**
1542
+ * Configuration for entity type registration
1543
+ */
1544
+ interface EntityTypeConfig {
1545
+ /** Plugin-owned semantic role, defaulting to content. System types cannot contribute to groupings. */
1546
+ classification?: EntityTypeClassification;
1547
+ /** Score multiplier for search results (default: 1.0) */
1548
+ weight?: number;
1549
+ /** Whether to generate embeddings for this entity type (default: true).
1550
+ * Set to false for entity types with non-textual content (e.g., images). */
1551
+ embeddable?: boolean;
1552
+ /** Whether to index serialized content in full-text search (default: true).
1553
+ * Set to false for binary entity types. Mutations remove stale FTS rows. */
1554
+ fullTextSearchable?: boolean;
1555
+ /** Binary storage policy. Absence means text content. */
1556
+ binaryStorage?: "data-url" | "asset";
1557
+ /** Default system_list order, applied by the entity service before pagination. */
1558
+ defaultSort?: SortField[];
1559
+ /** Accepts upload text extraction through system_create extract-markdown. */
1560
+ markdownImport?: boolean;
1561
+ /**
1562
+ * The type's own minimum action policy, from whoever registers it. It
1563
+ * tightens wildcard defaults without relaxing stricter rules, including
1564
+ * `never`, so an admin-only type stays protected without its bundle's rule.
1565
+ * An explicit per-type instance entry still overrides, action by action.
1566
+ */
1567
+ actionPolicy?: Partial<Record<"create" | "update" | "delete" | "extract" | "publish", "never" | "admin" | "trusted" | "public">>;
1568
+ /** Whether this entity type may be used as source material for derived projections (default: true).
1569
+ * Set to false for projection outputs that would create feedback loops. */
1570
+ projectionSource?: boolean;
1571
+ /** Default source authority role for derived projections. Entity types own
1572
+ * their durable/source character; consumers may map roles to local policy. */
1573
+ projectionSourceRole?: ProjectionSourceRole;
1574
+ /** Publish semantics for status-bearing entity types. Statuses listed here
1575
+ * represent publication commitment/execution states and require the
1576
+ * `publish` entity action when entered or modified. */
1577
+ publish?: {
1578
+ publishStatuses: string[];
1579
+ };
1580
+ }
1581
+ /**
1582
+ * Core entity service interface for read-only operations
1583
+ * Used by core plugins that need entity access but shouldn't modify entities
1584
+ */
1585
+ interface GetEntityRequest extends EntityReadOptions {
1586
+ entityType: string;
1587
+ id: string;
1588
+ /**
1589
+ * Optional visibility scope. Undefined fails closed to "public" — callers
1590
+ * with elevated access must opt up explicitly.
1591
+ */
1592
+ visibilityScope?: ContentVisibility | undefined;
1593
+ /** Only an entity its type counts as published, as for published-only listings. */
1594
+ publishedOnly?: boolean | undefined;
1595
+ }
1596
+ type GetEntityRawRequest = GetEntityRequest;
1597
+ interface ProjectionOwnedEntityRequest {
1598
+ entityType: string;
1599
+ id: string;
1600
+ }
1601
+ interface ListEntitiesRequest {
1602
+ entityType: string;
1603
+ options?: ListOptions | undefined;
1604
+ }
1605
+ interface QueryEntityHierarchyRequest {
1606
+ entityType: string;
1607
+ /** Null/omitted means the collection root; segments identify stored identity. */
1608
+ prefix?: EntityIdPathInput | null | undefined;
1609
+ /** Search matching entries throughout the prefix; no folder rows in this mode. */
1610
+ includeDescendants?: boolean | undefined;
1611
+ /** Omitted fails closed to public, including folder names and counts. */
1612
+ visibilityScope?: ContentVisibility | undefined;
1613
+ limit?: number | undefined;
1614
+ offset?: number | undefined;
1615
+ sortFields?: SortField[] | undefined;
1616
+ filter?: {
1617
+ metadata?: Record<string, unknown> | undefined;
1618
+ contentContains?: string | undefined;
1619
+ visibility?: ContentVisibility | undefined;
1620
+ } | undefined;
1621
+ signal?: AbortSignal | undefined;
1622
+ }
1623
+ interface EntityHierarchyPage {
1624
+ prefix: EntityIdPath | null;
1625
+ folders: Array<{
1626
+ path: EntityIdPath;
1627
+ name: string;
1628
+ descendantCount: number;
1629
+ }>;
1630
+ /** Only direct children, with derived paths kept outside durable entity data. */
1631
+ entities: Array<{
1632
+ entity: BaseEntity;
1633
+ path: EntityIdPath;
1634
+ }>;
1635
+ offset: number;
1636
+ totalEntities: number;
1637
+ }
1638
+ interface CountEntitiesRequest {
1639
+ entityType: string;
1640
+ options?: Pick<ListOptions, "publishedOnly" | "filter"> | undefined;
1641
+ }
1642
+ interface CreateEntityRequest<T extends BaseEntity> {
1643
+ entity: EntityInput<T>;
1644
+ /** Prepared bytes committed in the same transaction as their entity reference. */
1645
+ preparedAsset?: PreparedAsset | undefined;
1646
+ options?: CreateEntityOptions | undefined;
1647
+ }
1648
+ interface CreateEntityFromMarkdownRequest {
1649
+ input: CreateEntityFromMarkdownInput;
1650
+ options?: CreateEntityOptions | undefined;
1651
+ }
1652
+ interface UpdateEntityRequest<T extends BaseEntity> {
1653
+ entity: T;
1654
+ /** Prepared bytes committed in the same transaction as their entity reference. */
1655
+ preparedAsset?: PreparedAsset | undefined;
1656
+ options?: UpdateEntityOptions | undefined;
1657
+ }
1658
+ interface DeleteEntityRequest {
1659
+ entityType: string;
1660
+ id: string;
1661
+ options?: Pick<EntityJobOptions, "eventContext" | "persistenceOrigin"> | undefined;
1662
+ }
1663
+ interface UpsertEntityRequest<T extends BaseEntity> {
1664
+ entity: T;
1665
+ /** Prepared bytes committed in the same transaction as their entity reference. */
1666
+ preparedAsset?: PreparedAsset | undefined;
1667
+ /** Conditional upserts never fall through from a raced create to update. */
1668
+ options?: (EntityJobOptions & {
1669
+ conditionalWrite?: EntityWriteCondition;
1670
+ }) | undefined;
1671
+ }
1672
+ interface EntitySearchRequest {
1673
+ query: string;
1674
+ options?: SearchOptions | undefined;
1675
+ }
1676
+ interface SearchWithDistancesRequest {
1677
+ query: string;
1678
+ }
1679
+ interface SemanticEntityReference {
1680
+ entityId: string;
1681
+ entityType: string;
1682
+ }
1683
+ interface ProjectSemanticSpaceRequest {
1684
+ /** Entity types to include as projected points. Empty or omitted includes all types. */
1685
+ types?: string[];
1686
+ /** Optional entity used as the semantic origin. Missing origins fall back to the point centroid. */
1687
+ origin?: SemanticEntityReference;
1688
+ /** Include pairwise neighbors at or below this cosine distance. */
1689
+ maxNeighborDistance?: number;
1690
+ /** Undefined fails closed to public-only visibility. */
1691
+ visibilityScope?: ContentVisibility | undefined;
1692
+ }
1693
+ interface SemanticSpacePoint extends SemanticEntityReference {
1694
+ /** Coordinates on the first two principal components of the semantic space. */
1695
+ coordinates: [number, number];
1696
+ /** Cosine distance from the requested origin or the fallback centroid. */
1697
+ distanceToOrigin: number;
1698
+ }
1699
+ interface SemanticSpaceNeighbor {
1700
+ source: SemanticEntityReference;
1701
+ target: SemanticEntityReference;
1702
+ distance: number;
1703
+ }
1704
+ type SemanticSpaceOrigin = ({
1705
+ kind: "entity";
1706
+ } & SemanticEntityReference) | {
1707
+ kind: "centroid";
1708
+ };
1709
+ interface SemanticSpaceDistanceRange {
1710
+ min: number;
1711
+ max: number;
1712
+ }
1713
+ interface SemanticSpaceProjection {
1714
+ origin: SemanticSpaceOrigin;
1715
+ points: SemanticSpacePoint[];
1716
+ neighbors: SemanticSpaceNeighbor[];
1717
+ /** Observed origin-distance extent for projection-independent scaling. */
1718
+ distanceRange: SemanticSpaceDistanceRange;
1719
+ }
1720
+ /**
1721
+ * Context passed to all DataSource operations
1722
+ * Contains internal state that should not be mixed with user query parameters
1723
+ */
1724
+ interface BaseDataSourceContext {
1725
+ /**
1726
+ * Whether to filter to only published/complete content
1727
+ * Set by site-builder: true for production, false for preview
1728
+ */
1729
+ publishedOnly?: boolean;
1730
+ /**
1731
+ * Scoped entity service that auto-applies publishedOnly filter
1732
+ * Datasources should use this instead of their injected entityService
1733
+ * to ensure consistent filtering behavior across environments
1734
+ */
1735
+ entityService: EntityServiceClient;
1736
+ }
1737
+ /**
1738
+ * DataSource Interface
1739
+ *
1740
+ * Provides data for templates through fetch, generate, or transform operations.
1741
+ * DataSources are registered in the DataSourceRegistry and referenced by templates
1742
+ * via their dataSourceId property.
1743
+ */
1744
+ /** Runtime-only, read-only access for caller-bound generation. */
1745
+ interface DataSourceGenerationContext {
1746
+ readonly visibilityScope: ContentVisibility;
1747
+ readonly signal?: AbortSignal;
1748
+ getEntity(entityType: string, id: string): Promise<BaseEntity | null>;
1749
+ search(query: string, options?: Pick<SearchOptions, "limit" | "weight">): Promise<SearchResult[]>;
1750
+ }
1751
+ interface DataSource {
1752
+ /**
1753
+ * Unique identifier for this data source
1754
+ */
1755
+ id: string;
1756
+ /**
1757
+ * Human-readable name for this data source
1758
+ */
1759
+ name: string;
1760
+ /**
1761
+ * Optional description of what this data source provides
1762
+ */
1763
+ description?: string;
1764
+ /**
1765
+ * Optional: Fetch existing data
1766
+ * Used by data sources that aggregate or retrieve data (e.g., dashboard stats, API data)
1767
+ * DataSources validate output using the provided schema
1768
+ * @param query - Query parameters for fetching data
1769
+ * @param outputSchema - Schema for validating output data
1770
+ * @param context - Context with environment
1771
+ */
1772
+ fetch?: <T>(query: unknown, outputSchema: z.ZodSchema<T>, context: BaseDataSourceContext) => Promise<T>;
1773
+ /**
1774
+ * Optional: Generate new content
1775
+ * Used by data sources that create content (e.g., AI-generated content, reports)
1776
+ */
1777
+ generate?: <T>(request: unknown, schema: z.ZodSchema<T>, signal?: AbortSignal) => Promise<T>;
1778
+ /**
1779
+ * Opt-in scoped generation. All content reads must use this runtime context,
1780
+ * not ambient entity services/caches. Never fall back to generate().
1781
+ */
1782
+ generateScoped?: <T>(request: unknown, schema: z.ZodSchema<T>, context: DataSourceGenerationContext) => Promise<T>;
1783
+ /**
1784
+ * Optional: Transform content between formats
1785
+ * Used by data sources that convert content (e.g., markdown to HTML, data formatting)
1786
+ */
1787
+ transform?: <T>(content: unknown, format: string, schema: z.ZodSchema<T>) => Promise<T>;
1788
+ }
1789
+ /**
1790
+ * DataSource capabilities for discovery and validation
1791
+ */
1792
+ interface DataSourceCapabilities {
1793
+ canFetch: boolean;
1794
+ canGenerate: boolean;
1795
+ canTransform: boolean;
1796
+ }
1797
+ interface ICoreEntityService {
1798
+ getEntity(request: GetEntityRequest): Promise<BaseEntity | null>;
1799
+ getEntity<T extends BaseEntity>(request: GetEntityRequest, schema: EntitySchema<T>): Promise<T | null>;
1800
+ /**
1801
+ * Get entity without content resolution (raw)
1802
+ * Used internally to avoid recursion when resolving image references
1803
+ */
1804
+ getEntityRaw(request: GetEntityRawRequest): Promise<BaseEntity | null>;
1805
+ getEntityRaw<T extends BaseEntity>(request: GetEntityRawRequest, schema: EntitySchema<T>): Promise<T | null>;
1806
+ listEntities(request: ListEntitiesRequest): Promise<BaseEntity[]>;
1807
+ listEntities<T extends BaseEntity>(request: ListEntitiesRequest, schema: EntitySchema<T>): Promise<T[]>;
1808
+ /** Immediate folders and paginated direct children; no filesystem interpretation. */
1809
+ queryEntityHierarchy(request: QueryEntityHierarchyRequest): Promise<EntityHierarchyPage>;
1810
+ queryGroupingCatalog(request: QueryGroupingCatalogRequest): Promise<EntityGroupingCatalog>;
1811
+ queryGroupingMembers(request: QueryGroupingMembersRequest): Promise<EntityGroupingMembers>;
1812
+ queryGroupingUsage(request: QueryGroupingUsageRequest): Promise<EntityGroupingUsage>;
1813
+ search(request: EntitySearchRequest): Promise<SearchResult<BaseEntity>[]>;
1814
+ search<T extends BaseEntity>(request: EntitySearchRequest, schema: EntitySchema<T>): Promise<SearchResult<T>[]>;
1815
+ /** Return embedded entities with raw cosine distance to a query. */
1816
+ searchWithDistances(request: SearchWithDistancesRequest): Promise<Array<{
1817
+ entityId: string;
1818
+ entityType: string;
1819
+ distance: number;
1820
+ }>>;
1821
+ /** Project visible entities into a provider-independent semantic space. */
1822
+ projectSemanticSpace(request: ProjectSemanticSpaceRequest): Promise<SemanticSpaceProjection>;
1823
+ getEntityTypes(): string[];
1824
+ hasEntityType(type: string): boolean;
1825
+ countEntities(request: CountEntitiesRequest): Promise<number>;
1826
+ /**
1827
+ * Group counts by entity type. Fails closed: undefined visibilityScope
1828
+ * filters to public-only counts so aggregate insights cannot reveal
1829
+ * non-public entity existence.
1830
+ */
1831
+ getEntityCounts(visibilityScope?: ContentVisibility): Promise<Array<{
1832
+ entityType: string;
1833
+ count: number;
1834
+ }>>;
1835
+ /** Get configuration for a specific entity type */
1836
+ getEntityTypeConfig(type: string): EntityTypeConfig;
1837
+ /** Get weight map for all registered entity types with non-default weights */
1838
+ getWeightMap(): Record<string, number>;
1839
+ }
1840
+ /** One visibility-scoped, mixed-type member page. */
1841
+ interface EntityGroupingMembers {
1842
+ entities: BaseEntity[];
1843
+ total: number;
1844
+ }
1845
+ /** A single document owner refreshes in-memory grouping contracts before use. */
1846
+ interface EntityGroupingSource {
1847
+ readonly entityType: string;
1848
+ /** Read-only with respect to persistence: never mutate entities or reproject. */
1849
+ ensureCurrent(options?: {
1850
+ afterWrite?: boolean;
1851
+ }): Promise<void>;
1852
+ }
1853
+ interface EmbeddingBackfillResult {
1854
+ queued: number;
1855
+ skipped: number;
1856
+ }
1857
+ interface EmbeddingIndexStats {
1858
+ missingEmbeddings: number;
1859
+ staleEmbeddings: number;
1860
+ failedEmbeddings: number;
1861
+ /** Entities whose type generates embeddings (non-embeddable types excluded). */
1862
+ embeddableEntities: number;
1863
+ /** Embeddable entities whose embedding is present and current. */
1864
+ embeddedEntities: number;
1865
+ }
1866
+ interface IndexReadinessOptions {
1867
+ /** Stop polling after this duration. Omit for an owning runtime monitor. */
1868
+ timeoutMs?: number;
1869
+ intervalMs?: number;
1870
+ /** Cancels readiness polling when the owning runtime shuts down. */
1871
+ signal?: AbortSignal;
1872
+ }
1873
+ interface IndexReadinessStatus extends EmbeddingIndexStats {
1874
+ ready: boolean;
1875
+ degraded: boolean;
1876
+ activeEmbeddingJobs: number;
1877
+ }
1878
+ /**
1879
+ * The entity-service surface ordinary plugins receive. A real interface
1880
+ * rather than Omit<EntityService, ...>: mapped types collapse overloaded
1881
+ * methods (like the schema-taking reads) down to one signature.
1882
+ */
1883
+ interface EntityServiceClient extends ICoreEntityService {
1884
+ /** Visibility-scoped read and revision for atomic conditional writes. */
1885
+ getEntityWriteSnapshot(request: GetEntityRequest): Promise<EntityWriteSnapshot | null>;
1886
+ /** Local admission state; grouping endpoints must not serve partial bootstrap results. */
1887
+ areGroupingsReady(): boolean;
1888
+ /** Refresh definitions and start missing scans outside write transactions. */
1889
+ ensureGroupingsReady(): Promise<boolean>;
1890
+ /** Internal source-authority check used by persistence integrations. */
1891
+ isProjectionOwnedEntity(request: ProjectionOwnedEntityRequest): Promise<boolean>;
1892
+ listPendingEntityExports(): Promise<EntityExportIntent[]>;
1893
+ hasPendingEntityExports(): Promise<boolean>;
1894
+ acknowledgeEntityExports(request: AcknowledgeEntityExportsRequest): Promise<number>;
1895
+ runBulkMutation<TResult>(input: BulkMutationInput, mutation: () => Promise<TResult>): Promise<TResult>;
1896
+ createEntity<T extends BaseEntity>(request: CreateEntityRequest<T>): Promise<EntityMutationResult>;
1897
+ createEntityFromMarkdown(request: CreateEntityFromMarkdownRequest): Promise<EntityMutationResult>;
1898
+ updateEntity<T extends BaseEntity>(request: UpdateEntityRequest<T>): Promise<EntityMutationResult>;
1899
+ deleteEntity(request: DeleteEntityRequest): Promise<boolean>;
1900
+ upsertEntity<T extends BaseEntity>(request: UpsertEntityRequest<T>): Promise<EntityMutationResult & {
1901
+ created: boolean;
1902
+ }>;
1903
+ storeEmbedding(data: StoreEmbeddingData): Promise<void>;
1904
+ reconcileProjectionTargets(targets: readonly ProjectionChangedTarget[]): Promise<void>;
1905
+ backfillMissingEmbeddings(): Promise<EmbeddingBackfillResult>;
1906
+ isIndexReady(): boolean;
1907
+ awaitIndexReady(options: IndexReadinessOptions): Promise<IndexReadinessStatus>;
1908
+ serializeEntity(entity: BaseEntity): string;
1909
+ deserializeEntity(markdown: string, entityType: string): Partial<BaseEntity>;
1910
+ countEmbeddings(): Promise<number>;
1911
+ initialize(): Promise<void>;
1912
+ getAsyncJobStatus(jobId: string): Promise<{
1913
+ status: "pending" | "processing" | "completed" | "failed";
1914
+ error?: string;
1915
+ } | null>;
1916
+ }
1917
+ interface EntityService extends EntityServiceClient {
1918
+ /** Normal web/combined boot only, after initial sync; not an ordinary mutation. */
1919
+ reprojectRegisteredGroupings(): Promise<void>;
1920
+ getProjectionStore(): ProjectionStore;
1921
+ setProjectionWakeup(wakeup: () => Promise<void>): () => void;
1922
+ prepareDurableBulkMutation(input: DurableBulkMutationRootInput): Promise<void>;
1923
+ finalizeDurableBulkMutationEnqueue(operationId: string): Promise<void>;
1924
+ failDurableBulkMutationEnqueue(operationId: string): Promise<void>;
1925
+ runDurableBulkMutationChild<TResult>(input: DurableBulkMutationChildInput, mutation: () => Promise<TResult>): Promise<TResult>;
1926
+ settleDurableBulkMutationChild(input: SettleDurableBulkMutationChildInput): Promise<boolean>;
1927
+ recoverProjectionBatches(readRoot: ProjectionBatchRootReader): Promise<ProjectionBatchRecoveryResult>;
1928
+ }
1929
+ /**
1930
+ * Entity Registry interface for managing entity types and their schemas/adapters
1931
+ */
1932
+ interface EntityRegistry {
1933
+ registerEntityType<TEntity extends BaseEntity<TMetadata>, TMetadata extends Record<string, unknown> = Record<string, unknown>>(type: string, schema: UnknownEntitySchema, adapter: EntityAdapter<TEntity, TMetadata>, config?: EntityTypeConfig): void;
1934
+ /** Remove an entity type after failed plugin registration or shell teardown. */
1935
+ unregisterEntityType(type: string): void;
1936
+ getSchema(type: string): UnknownEntitySchema;
1937
+ getAdapter(type: string): EntityAdapter<BaseEntity>;
1938
+ hasEntityType(type: string): boolean;
1939
+ validateEntity(type: string, entity: unknown): BaseEntity;
1940
+ getAllEntityTypes(): string[];
1941
+ /** Get configuration for a specific entity type */
1942
+ getEntityTypeConfig(type: string): EntityTypeConfig;
1943
+ /** Get weight map for all registered entity types with non-default weights */
1944
+ getWeightMap(): Record<string, number>;
1945
+ registerCreateInterceptor(type: string, interceptor: CreateInterceptor): void;
1946
+ getCreateInterceptor(type: string): CreateInterceptor | undefined;
1947
+ registerUploadSaveHandler(registration: UploadSaveHandlerRegistration): void;
1948
+ getUploadSaveHandler(mediaType: string): UploadSaveHandlerRegistration | undefined;
1949
+ registerPersistValidator(type: string, validator: PersistValidator): void;
1950
+ getPersistValidator(type: string): PersistValidator | undefined;
1951
+ /**
1952
+ * Extend an adapter's frontmatterSchema with additional fields.
1953
+ * Used by plugins to add domain-specific fields (e.g., professional-site adds tagline to profile).
1954
+ * Extensions are merged into the effective schema returned by getEffectiveFrontmatterSchema().
1955
+ */
1956
+ extendFrontmatterSchema(type: string, extension: z.ZodObject<z.ZodRawShape>): void;
1957
+ registerGroupingSource(source: EntityGroupingSource): void;
1958
+ /** Capture preparation state; invoke the guard inside the write transaction. */
1959
+ captureGroupingWriteGuard(entityType: string): () => Promise<void>;
1960
+ getGroupingSourceType(): string | undefined;
1961
+ getPendingGroupingProjections(): GroupingProjectionTarget[];
1962
+ completeGroupingProjections(targets: readonly GroupingProjectionTarget[]): void;
1963
+ /** The source's own entity reads skip refresh to avoid recursion. */
1964
+ ensureGroupingsCurrent(entityType?: string, options?: {
1965
+ afterWrite?: boolean;
1966
+ }): Promise<void>;
1967
+ /** Preflight a complete replacement set without modifying active schemas. */
1968
+ validateGroupings(groupings: readonly EntityGrouping[]): void;
1969
+ /** Atomically replace declarations; observers may recheck retained fields. */
1970
+ replaceGroupings(groupings: readonly EntityGrouping[], options?: {
1971
+ reprojectExisting?: boolean;
1972
+ }): void;
1973
+ registerGrouping(grouping: EntityGrouping): void;
1974
+ getGrouping(key: string): EntityGrouping;
1975
+ getGroupings(): EntityGrouping[];
1976
+ projectMetadata(type: string, content: string, metadata: Record<string, unknown>): Record<string, unknown>;
1977
+ /** Bootstrap projection: an invalid stored value is omitted, never fatal. */
1978
+ projectStoredMetadata(type: string, content: string, metadata: Record<string, unknown>): Record<string, unknown>;
1979
+ groupingFields(type: string): string[];
1980
+ isGroupingContributor(type: string): boolean;
1981
+ /** Registered extension contracts, including their refinements. */
1982
+ getFrontmatterExtensions(type: string): readonly FrontmatterSchema[];
1983
+ /**
1984
+ * Get the effective frontmatter schema for an entity type,
1985
+ * with all registered extensions merged in.
1986
+ * Returns undefined if the adapter has no frontmatterSchema.
1987
+ */
1988
+ getEffectiveFrontmatterSchema(type: string): z.ZodObject<z.ZodRawShape> | undefined;
1989
+ }
1990
+ /**
1991
+ * The read-only projection of the entity service.
1992
+ *
1993
+ * What a plugin is handed when it has no business writing: insight handlers
1994
+ * compute over entities and return a summary. A projection of
1995
+ * `ICoreEntityService` rather than a hand-written parallel interface, so a
1996
+ * method that changes shape fails to compile here instead of drifting.
1997
+ *
1998
+ * `@brains/plugins` restates this as `IEntityService` on its published
1999
+ * authoring surface; `public-surface-soundness.test.ts` holds the two
2000
+ * together.
2001
+ */
2002
+ type ReadOnlyEntityService = Pick<ICoreEntityService, "getEntity" | "listEntities" | "search" | "searchWithDistances" | "getEntityTypes" | "hasEntityType" | "countEntities" | "getEntityCounts" | "getEntityTypeConfig">;
2003
+ //#endregion
2004
+ //#region ../../shell/job-queue/src/schema/types.d.ts
2005
+ /**
2006
+ * Operation type enum for structured progress tracking and aggregation
2007
+ * Using generic categories to accommodate various plugin operations
2008
+ */
2009
+ declare const OperationTypeEnum: z.ZodEnum<{
2010
+ file_operations: "file_operations";
2011
+ content_operations: "content_operations";
2012
+ data_processing: "data_processing";
2013
+ batch_processing: "batch_processing";
2014
+ }>;
2015
+ type JobContextInputSchema = z.ZodObject<{
2016
+ pluginId: z.ZodOptional<z.ZodString>;
2017
+ progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
2018
+ operationType: typeof OperationTypeEnum;
2019
+ operationTarget: z.ZodOptional<z.ZodString>;
2020
+ interfaceType: z.ZodOptional<z.ZodString>;
2021
+ conversationId: z.ZodOptional<z.ZodString>;
2022
+ channelId: z.ZodOptional<z.ZodString>;
2023
+ requestedByActor: z.ZodOptional<typeof actorRefSchema>;
2024
+ requestedByUserId: z.ZodOptional<z.ZodString>;
2025
+ requestedByInterface: z.ZodOptional<z.ZodString>;
2026
+ silent: z.ZodOptional<z.ZodBoolean>;
2027
+ provenance: z.ZodOptional<typeof OperationProvenanceSchema>;
2028
+ }, z.core.$loose>;
2029
+ /**
2030
+ * Job context input schema - what callers provide when creating jobs
2031
+ * Note: rootJobId is not included here - it's managed internally by the job queue service
2032
+ * and defaults to the job's own ID for standalone jobs, or the batch ID for batch children.
2033
+ *
2034
+ * Callers attach further keys of their own; the object is loose so parsing
2035
+ * keeps them and the type admits them.
2036
+ */
2037
+ declare const JobContextInputSchema: JobContextInputSchema;
2038
+ type JobContextInput = z.output<typeof JobContextInputSchema>;
2039
+ /**
2040
+ * Full job context schema - includes rootJobId for stored/transmitted metadata
2041
+ * This is what gets stored in the database and sent in progress events.
2042
+ */
2043
+ declare const JobContextSchema: z.ZodObject<JobContextInputSchema["shape"] & {
2044
+ rootJobId: z.ZodString;
2045
+ }, z.core.$loose>;
2046
+ /**
2047
+ * Deduplication strategy for job queue
2048
+ */
2049
+ declare const DeduplicationStrategyEnum: z.ZodEnum<{
2050
+ none: "none";
2051
+ skip: "skip";
2052
+ replace: "replace";
2053
+ coalesce: "coalesce";
2054
+ }>;
2055
+ type DeduplicationStrategy = z.output<typeof DeduplicationStrategyEnum>;
2056
+ /**
2057
+ * Job options for job creation
2058
+ */
2059
+ interface ProjectionJobContext {
2060
+ id: string;
2061
+ sourceEntity?: ProvenanceEntityReference | undefined;
2062
+ }
2063
+ interface JobOptions {
2064
+ priority?: number;
2065
+ maxRetries?: number;
2066
+ delayMs?: number;
2067
+ source: string;
2068
+ metadata: JobContextInput;
2069
+ deduplication?: DeduplicationStrategy;
2070
+ deduplicationKey?: string;
2071
+ /** Projection identity used to advance inherited causal provenance. */
2072
+ projection?: ProjectionJobContext;
2073
+ /**
2074
+ * Override rootJobId for batch child jobs
2075
+ * External callers should not use this - it's set automatically by the job queue service
2076
+ * Batch jobs use this to link child jobs to the parent batch
2077
+ */
2078
+ rootJobId?: string;
2079
+ }
2080
+ //#endregion
2081
+ //#region ../../shared/utils/src/progress.d.ts
2082
+ /**
2083
+ * Progress notification for long-running operations
2084
+ */
2085
+ interface ProgressNotification {
2086
+ progress: number;
2087
+ total?: number;
2088
+ message?: string;
2089
+ rate?: number;
2090
+ eta?: number;
2091
+ }
2092
+ /**
2093
+ * Progress callback type
2094
+ */
2095
+ type ProgressCallback = (notification: ProgressNotification) => Promise<void>;
2096
+ /**
2097
+ * A simple utility class for managing progress reporting in nested operations
2098
+ *
2099
+ * @example
2100
+ * ```typescript
2101
+ * // Create from a callback
2102
+ * const progress = ProgressReporter.from(sendProgress);
2103
+ *
2104
+ * // Report progress
2105
+ * await progress?.report({
2106
+ * message: "Building project",
2107
+ * progress: 10,
2108
+ * total: 100
2109
+ * });
2110
+ *
2111
+ * // Create sub-progress with scaled range
2112
+ * const subProgress = progress?.createSub({ scale: { start: 10, end: 90 } });
2113
+ *
2114
+ * // Use with APIs that expect a callback
2115
+ * await someApi(subProgress?.toCallback());
2116
+ * ```
2117
+ */
2118
+ /**
2119
+ * What a progress reporter provides to callers.
2120
+ *
2121
+ * Consumers depend on this rather than on `CallbackProgressReporter`. The class
2122
+ * carries a private callback and a private constructor, so nothing else can be
2123
+ * assignable to it — which is why every test double had to be asserted into
2124
+ * place, a cast that also erased the check on the members it did define.
2125
+ */
2126
+ interface ProgressReporter {
2127
+ createSub(options?: {
2128
+ scale?: {
2129
+ start: number;
2130
+ end: number;
2131
+ };
2132
+ }): ProgressReporter;
2133
+ report(notification: ProgressNotification): Promise<void>;
2134
+ startHeartbeat(message: string, intervalMs?: number): void;
2135
+ stopHeartbeat(): void;
2136
+ toCallback(): ProgressCallback;
2137
+ }
2138
+ //#endregion
2139
+ //#region ../../shell/job-queue/src/batch-schemas.d.ts
2140
+ type BatchOperationSchema = z.ZodObject<{
2141
+ type: z.ZodString;
2142
+ data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2143
+ }>;
2144
+ /**
2145
+ * Schema for batch operation data
2146
+ */
2147
+ declare const BatchOperationSchema: BatchOperationSchema;
2148
+ type BatchOperation = z.output<typeof BatchOperationSchema>;
2149
+ type BatchJobStatusSchema = z.ZodObject<{
2150
+ batchId: z.ZodString;
2151
+ totalOperations: z.ZodNumber;
2152
+ completedOperations: z.ZodNumber;
2153
+ failedOperations: z.ZodNumber;
2154
+ currentOperation: z.ZodOptional<z.ZodString>;
2155
+ errors: z.ZodArray<z.ZodString>;
2156
+ status: z.ZodEnum<{
2157
+ pending: "pending";
2158
+ processing: "processing";
2159
+ completed: "completed";
2160
+ failed: "failed";
2161
+ }>;
2162
+ metadata: z.ZodOptional<typeof JobContextSchema>;
2163
+ }>;
2164
+ /**
2165
+ * Schema for batch job status response
2166
+ */
2167
+ declare const BatchJobStatusSchema: BatchJobStatusSchema;
2168
+ type BatchJobStatus = z.output<typeof BatchJobStatusSchema>;
2169
+ type BatchSchema = z.ZodObject<{
2170
+ batchId: z.ZodString;
2171
+ status: BatchJobStatusSchema;
2172
+ metadata: z.ZodObject<{
2173
+ operations: z.ZodArray<BatchOperationSchema>;
2174
+ source: z.ZodString;
2175
+ startedAt: z.ZodString;
2176
+ metadata: typeof JobContextSchema;
2177
+ }>;
2178
+ }>;
2179
+ /**
2180
+ * Schema for batch result with full metadata
2181
+ */
2182
+ declare const BatchSchema: BatchSchema;
2183
+ type Batch = z.output<typeof BatchSchema>;
2184
+ //#endregion
2185
+ //#region ../../shell/job-queue/src/types.d.ts
2186
+ /**
2187
+ * Request for enqueueing a job in the core job queue service.
2188
+ */
2189
+ interface JobQueueEnqueueRequest {
2190
+ /** Job type to enqueue */
2191
+ type: string;
2192
+ /** Job payload passed to the registered handler */
2193
+ data: unknown;
2194
+ /** Optional queue behavior, routing metadata, and retry settings */
2195
+ options?: JobOptions;
2196
+ }
2197
+ /** Ownership attached atomically when a worker dequeues a job. */
2198
+ interface JobClaimOptions {
2199
+ workerSlotId: string;
2200
+ workerSessionId: string;
2201
+ leaseDurationMs: number;
2202
+ }
2203
+ type JobInfoSchema = z.ZodObject<{
2204
+ id: z.ZodString;
2205
+ type: z.ZodString;
2206
+ data: z.ZodString;
2207
+ status: z.ZodEnum<{
2208
+ pending: "pending";
2209
+ processing: "processing";
2210
+ completed: "completed";
2211
+ failed: "failed";
2212
+ }>;
2213
+ source: z.ZodNullable<z.ZodString>;
2214
+ priority: z.ZodNumber;
2215
+ retryCount: z.ZodNumber;
2216
+ maxRetries: z.ZodNumber;
2217
+ lastError: z.ZodNullable<z.ZodString>;
2218
+ createdAt: z.ZodNumber;
2219
+ scheduledFor: z.ZodNumber;
2220
+ startedAt: z.ZodNullable<z.ZodNumber>;
2221
+ completedAt: z.ZodNullable<z.ZodNumber>;
2222
+ attemptId: z.ZodNullable<z.ZodString>;
2223
+ workerSlotId: z.ZodNullable<z.ZodString>;
2224
+ workerSessionId: z.ZodNullable<z.ZodString>;
2225
+ leaseExpiresAt: z.ZodNullable<z.ZodNumber>;
2226
+ attemptHeartbeatAt: z.ZodNullable<z.ZodNumber>;
2227
+ runtimeUpdatedAt: z.ZodNullable<z.ZodNumber>;
2228
+ metadata: typeof JobContextSchema;
2229
+ progress: z.ZodNullable<z.ZodCustom<ProgressNotification, ProgressNotification>>;
2230
+ result: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
2231
+ }>;
2232
+ /**
2233
+ * Simplified job info schema for external packages
2234
+ * Avoids exposing the complex Drizzle-inferred JobQueue type
2235
+ */
2236
+ declare const JobInfoSchema: JobInfoSchema;
2237
+ type JobInfo = z.output<typeof JobInfoSchema>;
2238
+ interface JobValidator<TInput = unknown> {
2239
+ /** Validate and parse job data before durable enqueue. */
2240
+ validateAndParse(data: unknown): TInput | null;
2241
+ }
2242
+ /** Immutable declaration derived from a registered durable handler. */
2243
+ interface JobExecutionRegistration {
2244
+ readonly type: string;
2245
+ readonly pluginId: string | undefined;
2246
+ }
2247
+ /**
2248
+ * Job handler interface for processing specific job types
2249
+ *
2250
+ * @template TJobType - The job type string (can be any string for plugin extensibility)
2251
+ * @template TInput - The input data type for the job
2252
+ * @template TOutput - The output data type for the job
2253
+ */
2254
+ interface JobHandler<_TJobType extends string = string, TInput = unknown, TOutput = unknown> extends JobValidator<TInput> {
2255
+ /** Per-type execution deadline; falls back to the worker default. */
2256
+ readonly executionTimeoutMs?: number | undefined;
2257
+ /**
2258
+ * Process a job of this type
2259
+ * @param data - The job input data
2260
+ * @param jobId - Unique identifier for this job
2261
+ * @param progressReporter - Progress reporter for granular updates
2262
+ */
2263
+ process(data: TInput, jobId: string, progressReporter: ProgressReporter, signal: AbortSignal): Promise<TOutput>;
2264
+ /**
2265
+ * Handle job failure (optional)
2266
+ */
2267
+ /** Runs after successful terminal state is durably persisted. */
2268
+ onTerminalSuccess?(data: TInput, jobId: string, progressReporter: ProgressReporter, signal: AbortSignal): Promise<void>;
2269
+ onError?(error: Error, data: TInput, jobId: string, progressReporter: ProgressReporter, signal: AbortSignal): Promise<void>;
2270
+ /** Runs once after the queue exhausts retries and persists terminal failure. */
2271
+ onTerminalError?(error: Error, data: TInput, jobId: string, progressReporter: ProgressReporter, signal: AbortSignal): Promise<void>;
2272
+ }
2273
+ interface JobQueueStats {
2274
+ pending: number;
2275
+ processing: number;
2276
+ failed: number;
2277
+ completed: number;
2278
+ total: number;
2279
+ }
2280
+ interface JobRuntimeUpdateCursor {
2281
+ readonly updatedAt: number;
2282
+ readonly jobId: string;
2283
+ }
2284
+ interface JobRuntimeUpdate {
2285
+ readonly job: JobInfo;
2286
+ readonly cursor: JobRuntimeUpdateCursor;
2287
+ }
2288
+ interface JobWorkerSessionDiagnostics {
2289
+ total: number;
2290
+ active: number;
2291
+ stale: number;
2292
+ latestHeartbeatAgeMs: number | null;
2293
+ }
2294
+ interface JobQueueDiagnostics {
2295
+ totals: Omit<JobQueueStats, "total">;
2296
+ byType: Array<{
2297
+ type: string;
2298
+ status: JobInfo["status"];
2299
+ count: number;
2300
+ }>;
2301
+ oldestPendingAgeMs: number | null;
2302
+ duePending: number;
2303
+ oldestDuePendingAgeMs: number | null;
2304
+ latestClaimAgeMs: number | null;
2305
+ oldestProcessingAgeMs: number | null;
2306
+ staleLeaseCount: number;
2307
+ workerSessions: JobWorkerSessionDiagnostics;
2308
+ }
2309
+ interface JobQueueIdleOptions {
2310
+ /** How long the queue must stay empty before it counts as settled. */
2311
+ quietMs?: number;
2312
+ /** Give up after this long and report what is still outstanding. */
2313
+ timeoutMs?: number;
2314
+ pollIntervalMs?: number;
2315
+ signal?: AbortSignal;
2316
+ }
2317
+ /**
2318
+ * Job queue service interface
2319
+ */
2320
+ interface IJobQueueService {
2321
+ /** Settle database readiness work before runtime services start. */
2322
+ initialize?(): Promise<void>;
2323
+ /**
2324
+ * Register a job handler for a specific type
2325
+ */
2326
+ registerHandler(type: string, handler: JobHandler, pluginId?: string): void;
2327
+ /**
2328
+ * Unregister a job handler for a specific type
2329
+ */
2330
+ unregisterHandler(type: string): void;
2331
+ /**
2332
+ * Unregister all handlers for a specific plugin
2333
+ */
2334
+ unregisterPluginHandlers(pluginId: string): void;
2335
+ /**
2336
+ * Get a handler for a specific job type
2337
+ */
2338
+ getHandler(type: string): JobHandler | undefined;
2339
+ /**
2340
+ * Get the validator for a declared job type. Present in every registration
2341
+ * mode, including validation-only processes that hold no executable handler.
2342
+ */
2343
+ getValidator(type: string): JobValidator | undefined;
2344
+ /** Freeze handler declarations before runtime services can admit work. */
2345
+ finalizeHandlerRegistrations(): readonly JobExecutionRegistration[];
2346
+ /** Read the immutable handler declarations derived during boot. */
2347
+ getExecutionRegistrations(): readonly JobExecutionRegistration[];
2348
+ /**
2349
+ * Enqueue a job for processing
2350
+ */
2351
+ enqueue(request: JobQueueEnqueueRequest): Promise<string>;
2352
+ /** Dequeue and attach explicit attempt ownership. */
2353
+ dequeue(claim?: JobClaimOptions): Promise<JobInfo | null>;
2354
+ /** Register or supersede the live session for a stable worker slot. */
2355
+ startWorkerSession(workerSlotId: string, workerSessionId: string, workerSessionTimeoutMs?: number): Promise<void>;
2356
+ /** Persist worker liveness only while the session still owns its slot. */
2357
+ heartbeatWorkerSession(workerSlotId: string, workerSessionId: string, workerSessionTimeoutMs?: number): Promise<boolean>;
2358
+ /** Remove a normally stopped worker session. */
2359
+ endWorkerSession(workerSlotId: string, workerSessionId: string): Promise<boolean>;
2360
+ /** Renew a processing attempt's fenced lease. */
2361
+ renewAttemptLease(jobId: string, attemptId: string, leaseDurationMs: number): Promise<boolean>;
2362
+ /** Fence and persist a progress snapshot without extending the lease. */
2363
+ recordAttemptProgress(jobId: string, attemptId: string, progress: ProgressNotification): Promise<boolean>;
2364
+ /** Mark job as completed, fenced when an attempt token is supplied. */
2365
+ complete(jobId: string, result: unknown, attemptId?: string): Promise<boolean>;
2366
+ /** Mark job as failed, fenced when an attempt token is supplied. */
2367
+ fail(jobId: string, error: Error, attemptId?: string): Promise<boolean>;
2368
+ /** Update job data, fenced when an attempt token is supplied. */
2369
+ update(jobId: string, data: unknown, attemptId?: string): Promise<boolean>;
2370
+ /**
2371
+ * Get job status by job ID
2372
+ */
2373
+ getStatus(jobId: string): Promise<JobInfo | null>;
2374
+ /** Read all durable jobs belonging to one root operation. */
2375
+ getJobsByRootJobId(rootJobId: string): Promise<JobInfo[]>;
2376
+ /**
2377
+ * Get job status by entity ID (for embedding jobs)
2378
+ */
2379
+ getStatusByEntityId(entityId: string): Promise<JobInfo | null>;
2380
+ /**
2381
+ * Get queue statistics
2382
+ */
2383
+ getStats(): Promise<JobQueueStats>;
2384
+ /** Get bounded operational diagnostics without loading queue rows. */
2385
+ getDiagnostics(now?: number): Promise<JobQueueDiagnostics>;
2386
+ /** Settle once nothing is in flight and nothing new has arrived. */
2387
+ waitForIdle(options?: JobQueueIdleOptions): Promise<void>;
2388
+ /** Read durable processing and terminal updates for web-owned publication. */
2389
+ getRuntimeUpdates(cursor: JobRuntimeUpdateCursor, limit?: number): Promise<JobRuntimeUpdate[]>;
2390
+ /**
2391
+ * Clean up old completed jobs
2392
+ */
2393
+ cleanup(olderThanMs: number): Promise<number>;
2394
+ /**
2395
+ * Get active jobs (pending or processing)
2396
+ */
2397
+ getActiveJobs(types?: string[]): Promise<JobInfo[]>;
2398
+ /**
2399
+ * Get recent jobs of any status, newest first
2400
+ */
2401
+ getRecentJobs(types?: string[], limit?: number): Promise<JobInfo[]>;
2402
+ /**
2403
+ * Get failed jobs
2404
+ */
2405
+ getFailedJobs(types?: string[]): Promise<JobInfo[]>;
2406
+ /**
2407
+ * Get registered job types
2408
+ */
2409
+ getRegisteredTypes(): string[];
2410
+ /**
2411
+ * Close the underlying database connection.
2412
+ */
2413
+ close(): void;
2414
+ }
2415
+ /**
2416
+ * Unified jobs namespace interface
2417
+ * Combines job queue and batch operations for shell/context usage
2418
+ */
2419
+ interface IJobsNamespace {
2420
+ /** Get active jobs, optionally filtered by type */
2421
+ getActiveJobs(types?: string[]): Promise<JobInfo[]>;
2422
+ /** Get recent jobs of any status, newest first, optionally filtered by type */
2423
+ getRecentJobs(types?: string[], limit?: number): Promise<JobInfo[]>;
2424
+ /** Get status of a specific job */
2425
+ getStatus(jobId: string): Promise<JobInfo | null>;
2426
+ /** Enqueue multiple operations as a batch */
2427
+ enqueueBatch(operations: BatchOperation[], options: JobOptions, batchId: string, pluginId: string): Promise<string>;
2428
+ /** Get all active batches */
2429
+ getActiveBatches(): Promise<Batch[]>;
2430
+ /** Get status of a specific batch */
2431
+ getBatchStatus(batchId: string): Promise<BatchJobStatus | null>;
2432
+ }
2433
+ //#endregion
2434
+ //#region ../../shared/content-formatters/src/types.d.ts
2435
+ /**
2436
+ * Interface for content formatters (human-editable content formatting)
2437
+ *
2438
+ * ContentFormatters handle bidirectional transformation between structured data
2439
+ * and human-editable markdown templates. Unlike SchemaFormatters which are for
2440
+ * one-way API response formatting, ContentFormatters support parsing edited
2441
+ * content back into structured data.
2442
+ */
2443
+ interface ContentFormatter<T = unknown> {
2444
+ /**
2445
+ * Format structured data into human-editable markdown
2446
+ * @param data - The structured data to format
2447
+ * @returns Human-editable markdown representation
2448
+ */
2449
+ format(data: T): string;
2450
+ /**
2451
+ * Parse human-editable markdown back into structured data
2452
+ * @param content - The markdown content to parse
2453
+ * @returns Structured data parsed from the markdown
2454
+ * @throws Error if the content cannot be parsed
2455
+ */
2456
+ parse(content: string): T;
2457
+ }
2458
+ //#endregion
2459
+ //#region ../../shell/templates/src/types.d.ts
2460
+ /**
2461
+ * Component type for layouts - using React
2462
+ * Returns a React element
2463
+ */
2464
+ type ComponentType<P = unknown> = {
2465
+ bivarianceHack(props: P): ReactElement;
2466
+ }["bivarianceHack"];
2467
+ type TemplateDataSchema<T> = ZodType<T, unknown>;
2468
+ /**
2469
+ * A runtime script that a template depends on. Site-builder collects
2470
+ * these per route across all templates rendered on the page, dedupes
2471
+ * by `src`, and injects them as <script> tags.
2472
+ *
2473
+ * Use this for non-hydration runtime scripts (background canvases,
2474
+ * scroll observers, decorative animations) that should ONLY load on
2475
+ * pages where the template actually renders — unlike the plugin-level
2476
+ * head-script registration which fires on every page.
2477
+ */
2478
+ interface RuntimeScript {
2479
+ src: string;
2480
+ defer?: boolean;
2481
+ module?: boolean;
2482
+ }
2483
+ /**
2484
+ * Unified template interface that bundles content generation and view rendering
2485
+ * This is the single source of truth for what constitutes a template
2486
+ */
2487
+ interface TemplateBase extends Omit<TemplateInput, "schema" | "layout" | "formatter"> {
2488
+ formatter?: ContentFormatter<unknown>;
2489
+ /**
2490
+ * Opt-in content overlay. When set alongside a `dataSourceId`, the section's
2491
+ * saved content is parsed with this formatter and merged over the datasource
2492
+ * output (authored fields win), rather than the two being mutually exclusive.
2493
+ * Lets a live datasource-backed section carry content-authored fields — e.g.
2494
+ * a map whose data is live but whose hero copy is editable. Absent → the
2495
+ * classic datasource-or-saved precedence is unchanged.
2496
+ */
2497
+ overlayFormatter?: ContentFormatter<unknown>;
2498
+ /**
2499
+ * Whether to retrieve relevant entities from the knowledge base
2500
+ * and inject them as context before AI generation. Default: false.
2501
+ */
2502
+ useKnowledgeContext?: boolean;
2503
+ /**
2504
+ * Runtime script dependencies. Loaded only on routes where this
2505
+ * template actually renders — site-builder collects from all
2506
+ * templates on a route, dedupes by src, and injects into <head>.
2507
+ */
2508
+ runtimeScripts?: RuntimeScript[];
2509
+ /**
2510
+ * Static files this template needs served alongside the site — typically
2511
+ * the file behind a runtimeScripts src. Keyed by output-relative path;
2512
+ * site-builder writes each entry into the build output for routes that
2513
+ * actually render this template.
2514
+ */
2515
+ staticAssets?: Record<string, string>;
2516
+ }
2517
+ /** A renderer template must parse to a JSON document before it can be snapshotted. */
2518
+ interface LayoutTemplate extends TemplateBase {
2519
+ schema: TemplateDataSchema<JsonObject>;
2520
+ layout: {
2521
+ component?: ComponentType<unknown>;
2522
+ fullscreen?: boolean;
2523
+ };
2524
+ }
2525
+ /** Generation-only templates never enter the serializable site-build snapshot. */
2526
+ interface NonLayoutTemplate extends TemplateBase {
2527
+ schema: TemplateDataSchema<unknown>;
2528
+ layout?: undefined;
2529
+ }
2530
+ type Template = LayoutTemplate | NonLayoutTemplate;
2531
+ /**
2532
+ * Template schema for validation
2533
+ */
2534
+ declare const TemplateSchema: z.ZodObject<{
2535
+ name: z.ZodString;
2536
+ description: z.ZodString;
2537
+ schema: z.ZodUnknown;
2538
+ basePrompt: z.ZodOptional<z.ZodString>;
2539
+ useKnowledgeContext: z.ZodOptional<z.ZodBoolean>;
2540
+ requiredPermission: z.ZodEnum<{
2541
+ admin: "admin";
2542
+ trusted: "trusted";
2543
+ public: "public";
2544
+ }>;
2545
+ formatter: z.ZodOptional<z.ZodUnknown>;
2546
+ overlayFormatter: z.ZodOptional<z.ZodUnknown>;
2547
+ layout: z.ZodOptional<z.ZodObject<{
2548
+ component: z.ZodOptional<z.ZodUnknown>;
2549
+ fullscreen: z.ZodOptional<z.ZodBoolean>;
2550
+ }>>;
2551
+ dataSourceId: z.ZodOptional<z.ZodString>;
2552
+ }>;
2553
+ type TemplateInput = z.output<typeof TemplateSchema>;
2554
+ //#endregion
2555
+ //#region ../../shell/templates/src/permission-service.d.ts
2556
+ /**
2557
+ * User permission level schema
2558
+ */
2559
+ declare const UserPermissionLevelSchema: z.ZodEnum<{
2560
+ admin: "admin";
2561
+ trusted: "trusted";
2562
+ public: "public";
2563
+ }>;
2564
+ type UserPermissionLevel = z.output<typeof UserPermissionLevelSchema>;
2565
+ declare const EntityActionSchema: z.ZodEnum<{
2566
+ create: "create";
2567
+ update: "update";
2568
+ delete: "delete";
2569
+ extract: "extract";
2570
+ publish: "publish";
2571
+ }>;
2572
+ type EntityAction = z.output<typeof EntityActionSchema>;
2573
+ /**
2574
+ * Required level for an entity action.
2575
+ *
2576
+ * `never` forbids the action through system tools regardless of caller level.
2577
+ */
2578
+ declare const EntityActionRequiredLevelSchema: z.ZodEnum<{
2579
+ never: "never";
2580
+ admin: "admin";
2581
+ trusted: "trusted";
2582
+ public: "public";
2583
+ }>;
2584
+ type EntityActionRequiredLevel = z.output<typeof EntityActionRequiredLevelSchema>;
2585
+ declare const entityActionPolicyRuleSchema: z.ZodObject<{
2586
+ create: z.ZodOptional<typeof EntityActionRequiredLevelSchema>;
2587
+ update: z.ZodOptional<typeof EntityActionRequiredLevelSchema>;
2588
+ delete: z.ZodOptional<typeof EntityActionRequiredLevelSchema>;
2589
+ extract: z.ZodOptional<typeof EntityActionRequiredLevelSchema>;
2590
+ publish: z.ZodOptional<typeof EntityActionRequiredLevelSchema>;
2591
+ }, z.core.$strict>;
2592
+ type EntityActionPolicyRule = z.output<typeof entityActionPolicyRuleSchema>;
2593
+ declare const entityActionPolicyConfigSchema: z.ZodRecord<z.ZodString, typeof entityActionPolicyRuleSchema>;
2594
+ type EntityActionPolicyConfigInput = z.input<typeof entityActionPolicyConfigSchema>;
2595
+ /**
2596
+ * Generic interface for items with visibility
2597
+ */
2598
+ interface WithVisibility {
2599
+ visibility?: UserPermissionLevel;
2600
+ }
2601
+ /**
2602
+ * Permission rule for pattern-based permission matching
2603
+ */
2604
+ interface PermissionRule {
2605
+ pattern: string;
2606
+ level: UserPermissionLevel;
2607
+ }
2608
+ type PermissionRuleInput = PermissionRule;
2609
+ /**
2610
+ * Configuration for the permission system
2611
+ */
2612
+ interface ConfiguredPrincipalSeeds {
2613
+ admins: string[];
2614
+ anchors: string[];
2615
+ trusted: string[];
2616
+ }
2617
+ interface PermissionConfig {
2618
+ /** Callers with administrative permission. */
2619
+ admins?: string[];
2620
+ /** Caller identities that represent the brain's person anchor in chat. */
2621
+ anchors?: string[];
2622
+ trusted?: string[];
2623
+ rules?: PermissionRuleInput[];
2624
+ entityActions?: EntityActionPolicyConfigInput;
2625
+ }
2626
+ /**
2627
+ * Additional context interfaces can provide for shared-space permission checks.
2628
+ *
2629
+ * Each interface normalizes its location concept (Discord channel/thread,
2630
+ * Slack channel, Matrix room, ...) into the single canonical `channelId`
2631
+ * before calling the resolver.
2632
+ */
2633
+ interface PermissionLookupContext {
2634
+ channelId?: string;
2635
+ isBot?: boolean;
2636
+ isGuest?: boolean;
2637
+ }
2638
+ interface PermissionServiceOptions {
2639
+ /** Shared conversation space selectors, e.g. discord:123 or discord:project-* */
2640
+ spaces?: string[];
2641
+ /**
2642
+ * A type's own minimum, from whoever registered it. It tightens wildcard
2643
+ * defaults without relaxing stricter rules, including `never`, so a brain
2644
+ * assembled without the canonical bundle cannot leave an admin-only type
2645
+ * open. An explicit entry for the type still wins, action by action.
2646
+ */
2647
+ entityActionFloor?: (entityType: string) => EntityActionPolicyRule | undefined;
2648
+ }
2649
+ /**
2650
+ * Centralized permission service for determining user permission levels
2651
+ * Handles both explicit user lists and pattern-based rules
2652
+ * Replaces the previous permission handler.
2653
+ */
2654
+ declare class PermissionService {
2655
+ private admins;
2656
+ private anchors;
2657
+ private trusted;
2658
+ private readonly configuredPrincipalSeeds;
2659
+ private rules;
2660
+ private spaces;
2661
+ private entityActions?;
2662
+ private readonly entityActionFloor?;
2663
+ constructor(config: PermissionConfig, options?: PermissionServiceOptions);
2664
+ /**
2665
+ * Determine the permission level for a user in a specific interface.
2666
+ *
2667
+ * Resolution order (load-bearing — locks user-facing trust semantics):
2668
+ * 1. Explicit admin/trusted lists win — they encode operator intent.
2669
+ * 2. Pattern rules granting admin/trusted win — same intent, broader.
2670
+ * 3. Configured shared-space membership grants `trusted` — only raises
2671
+ * otherwise-public callers; never elevates to `admin`.
2672
+ * 4. Public-fallback pattern rules apply.
2673
+ * 5. Default `public`.
2674
+ */
2675
+ determineUserLevel(interfaceType: string, userId: string, context?: PermissionLookupContext): UserPermissionLevel;
2676
+ /** Whether the caller is this professional brain's Anchor identity. */
2677
+ isAnchor(interfaceType: string, userId: string): boolean;
2678
+ getConfiguredPrincipalSeeds(): ConfiguredPrincipalSeeds;
2679
+ replaceRuntimePrincipalState(state: RuntimeInterfacePrincipalState): void;
2680
+ /**
2681
+ * Return the merged entity action policy for an entity type.
2682
+ * Entity-specific entries override the "*" default one action at a time.
2683
+ */
2684
+ getResolvedEntityActionPolicy(entityType: string): EntityActionPolicyRule | undefined;
2685
+ getEntityActionRequiredLevel(entityType: string, action: EntityAction): EntityActionRequiredLevel | undefined;
2686
+ getRequiredEntityActionLevel(entityType: string, action: EntityAction): EntityActionRequiredLevel | undefined;
2687
+ canPerformEntityAction(userLevel: UserPermissionLevel | undefined, entityType: string, action: EntityAction): boolean;
2688
+ assertEntityActionAllowed(entityType: string, action: EntityAction, userLevel: UserPermissionLevel | undefined): void;
2689
+ /**
2690
+ * Check if a user has a specific permission level or higher
2691
+ * @param userLevel The user's actual permission level
2692
+ * @param requiredLevel The required permission level
2693
+ * @returns True if the user meets the permission requirement
2694
+ */
2695
+ hasPermission(userLevel: UserPermissionLevel, requiredLevel: UserPermissionLevel): boolean;
2696
+ /**
2697
+ * Filter items based on user permission level
2698
+ * Works for tools, commands, or any item with a visibility property
2699
+ * @param items Array of items with visibility levels
2700
+ * @param userLevel The user's permission level
2701
+ * @returns Filtered array of items the user can access
2702
+ */
2703
+ filterByPermission<T extends WithVisibility>(items: T[], userLevel: UserPermissionLevel): T[];
2704
+ /**
2705
+ * Static method to check if a permission level meets the required level
2706
+ * Used by Shell for interface-based permission checking (commands, templates, etc.)
2707
+ * Maintains compatibility with existing Shell.generateContent() usage
2708
+ */
2709
+ static hasPermission(grantedLevel: UserPermissionLevel, requiredLevel: UserPermissionLevel): boolean;
2710
+ private getPatternLevel;
2711
+ private matchesConfiguredSpace;
2712
+ }
2713
+ //#endregion
2714
+ //#region ../../shell/templates/src/render-types.d.ts
2715
+ /**
2716
+ * Renderer output formats supported by view templates.
2717
+ */
2718
+ declare const OutputFormatSchema: z.ZodEnum<{
2719
+ web: "web";
2720
+ image: "image";
2721
+ pdf: "pdf";
2722
+ }>;
2723
+ type OutputFormat = z.output<typeof OutputFormatSchema>;
2724
+ /**
2725
+ * Renderer types for different output formats
2726
+ */
2727
+ type WebRenderer<T = unknown> = ComponentType<T> | string;
2728
+ type ImageRenderer<T = unknown> = ComponentType<T> | string;
2729
+ type PdfRenderer<T = unknown> = ComponentType<T> | string;
2730
+ type MediaRenderer<T = unknown> = ImageRenderer<T> | PdfRenderer<T>;
2731
+ type Renderer<T = unknown> = WebRenderer<T> | MediaRenderer<T>;
2732
+ /**
2733
+ * View template with support for multiple output formats
2734
+ */
2735
+ interface ViewTemplate<T extends JsonObject = JsonObject> {
2736
+ name: string;
2737
+ schema: TemplateDataSchema<T>;
2738
+ description?: string;
2739
+ pluginId: string;
2740
+ renderers: {
2741
+ web?: WebRenderer<T>;
2742
+ image?: ImageRenderer<T>;
2743
+ pdf?: PdfRenderer<T>;
2744
+ };
2745
+ fullscreen?: boolean;
2746
+ providerId?: string;
2747
+ formatter?: ContentFormatter<T>;
2748
+ /** Runtime script dependencies (see Template.runtimeScripts). */
2749
+ runtimeScripts?: RuntimeScript[];
2750
+ /** Static files behind runtimeScripts srcs (see Template.staticAssets). */
2751
+ staticAssets?: Record<string, string>;
2752
+ }
2753
+ /**
2754
+ * View template registry interface
2755
+ */
2756
+ /**
2757
+ * The render service as consumers use it.
2758
+ *
2759
+ * `hasRenderer` and `listFormats` were missing here even though callers use
2760
+ * both: consumers took the `RenderService` class instead, which meant a test
2761
+ * double had to be asserted into a type with private state.
2762
+ */
2763
+ interface ViewTemplateRegistry {
2764
+ get(name: string): ViewTemplate | undefined;
2765
+ list(): ViewTemplate[];
2766
+ validate(templateName: string, content: unknown): boolean;
2767
+ findViewTemplate(filter: {
2768
+ name?: string;
2769
+ pluginId?: string;
2770
+ namePattern?: string;
2771
+ }): ViewTemplate | undefined;
2772
+ getRenderer(templateName: string, format: OutputFormat): Renderer | undefined;
2773
+ hasRenderer(templateName: string, format: OutputFormat): boolean;
2774
+ listFormats(templateName: string): OutputFormat[];
2775
+ }
2776
+ //#endregion
2777
+ //#region ../../shell/messaging-service/src/message-validator.d.ts
2778
+ type MessageValidationResult<T> = {
2779
+ valid: true;
2780
+ data: T;
2781
+ } | {
2782
+ valid: false;
2783
+ error: string;
2784
+ };
2785
+ type MessageValidationSchema<T> = ZodType<T, unknown>;
2786
+ //#endregion
2787
+ //#region ../../shell/messaging-service/src/base-types.d.ts
2788
+ /**
2789
+ * Simple response schema for message handlers
2790
+ */
2791
+ declare const messageResponseSchema: z.ZodObject<{
2792
+ success: z.ZodBoolean;
2793
+ data: z.ZodOptional<z.ZodUnknown>;
2794
+ error: z.ZodOptional<z.ZodString>;
2795
+ }>;
2796
+ /** A handler's reply: the parsed response with its data narrowed to T, or a no-op. */
2797
+ type MessageResponse<T = unknown> = (Omit<z.output<typeof messageResponseSchema>, "data"> & {
2798
+ data?: T | undefined;
2799
+ }) | {
2800
+ noop: true;
2801
+ };
2802
+ type BaseMessageSchema = z.ZodObject<{
2803
+ id: z.ZodString;
2804
+ timestamp: z.ZodString;
2805
+ type: z.ZodString;
2806
+ source: z.ZodString;
2807
+ target: z.ZodOptional<z.ZodString>;
2808
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2809
+ }>;
2810
+ /**
2811
+ * Base message schema - all messages must have these fields
2812
+ */
2813
+ declare const baseMessageSchema: BaseMessageSchema;
2814
+ type BaseMessage = z.output<typeof baseMessageSchema>;
2815
+ type MessageWithPayload<T = unknown> = BaseMessage & {
2816
+ payload: T;
2817
+ };
2818
+ /**
2819
+ * Message handler type
2820
+ */
2821
+ type MessageHandler<T = unknown, R = unknown> = (message: MessageWithPayload<T>) => Promise<MessageResponse<R>> | MessageResponse<R>;
2822
+ /**
2823
+ * Options for sending messages
2824
+ */
2825
+ interface MessageSendOptions {
2826
+ /** Optional target for filtered delivery */
2827
+ target?: string;
2828
+ /** Optional metadata for filtered delivery */
2829
+ metadata?: Record<string, unknown>;
2830
+ /** If true, all matching handlers are called regardless of responses */
2831
+ broadcast?: boolean;
2832
+ }
2833
+ interface MessageSendRequest<T = unknown> extends MessageSendOptions {
2834
+ type: string;
2835
+ payload: T;
2836
+ }
2837
+ interface MessageBusSendRequest<T = unknown> extends MessageSendRequest<T> {
2838
+ sender: string;
2839
+ }
2840
+ //#endregion
2841
+ //#region ../../shell/messaging-service/src/types.d.ts
2842
+ /**
2843
+ * Subscription filter for targeted message delivery
2844
+ */
2845
+ interface SubscriptionFilter {
2846
+ source?: string | RegExp;
2847
+ target?: string | RegExp;
2848
+ metadata?: Record<string, unknown>;
2849
+ predicate?: (message: MessageWithPayload) => boolean;
2850
+ }
2851
+ /**
2852
+ * Message bus interface
2853
+ */
2854
+ interface IMessageBus {
2855
+ send<T = unknown, R = unknown>(request: MessageBusSendRequest<T>): Promise<MessageResponse<R>>;
2856
+ subscribe<T = unknown, R = unknown>(type: string, handler: MessageHandler<T, R>, filter?: SubscriptionFilter): () => void;
2857
+ /** Collect one response from every matching handler, in registration order. */
2858
+ collect<T = unknown, R = unknown>(request: MessageBusSendRequest<T>): Promise<MessageResponse<R>[]>;
2859
+ validateMessage<T>(message: unknown, schema: MessageValidationSchema<T>): MessageValidationResult<T>;
2860
+ unsubscribe<T = unknown, R = unknown>(type: string, handler: MessageHandler<T, R>): void;
2861
+ hasHandlers?(type: string): boolean;
2862
+ getHandlerCount(messageType: string): number;
2863
+ getTargetedHandlerCount(messageType: string, target: string): number;
2864
+ clearHandlers(messageType: string): void;
2865
+ clearAllHandlers(): void;
2866
+ }
2867
+ //#endregion
2868
+ //#region ../../shell/mcp-service/src/types.d.ts
2869
+ /**
2870
+ * Tool visibility levels for permission control
2871
+ * Uses the same levels as UserPermissionLevel for consistency
2872
+ */
2873
+ type ToolVisibility = UserPermissionLevel;
2874
+ /**
2875
+ * Tool execution context
2876
+ * Provides progress reporting and routing metadata
2877
+ */
2878
+ interface ToolContext {
2879
+ progressToken?: string | number;
2880
+ sendProgress?: (notification: ProgressNotification) => Promise<void>;
2881
+ /** Cancellation for the active request; handlers may opt in. */
2882
+ signal?: AbortSignal;
2883
+ interfaceType: string;
2884
+ actor: ActorRef;
2885
+ displayName?: string;
2886
+ conversationId?: string;
2887
+ channelId?: string;
2888
+ channelName?: string;
2889
+ runId?: string;
2890
+ toolCallId?: string;
2891
+ /** Caller's permission level. Tools that read/write entities use this to derive
2892
+ * the content-visibility scope they are allowed to see. */
2893
+ userPermissionLevel?: UserPermissionLevel;
2894
+ /** Whether the authenticated caller is the brain's configured Anchor. */
2895
+ isAnchor?: boolean;
2896
+ }
2897
+ /**
2898
+ * Success response schema
2899
+ */
2900
+ declare const toolSuccessSchema: z.ZodObject<{
2901
+ success: z.ZodLiteral<true>;
2902
+ data: z.ZodOptional<z.ZodUnknown>;
2903
+ message: z.ZodOptional<z.ZodString>;
2904
+ cached: z.ZodOptional<z.ZodLiteral<true>>;
2905
+ }, z.core.$strict>;
2906
+ /**
2907
+ * Error response schema
2908
+ */
2909
+ declare const toolErrorSchema: z.ZodObject<{
2910
+ success: z.ZodLiteral<false>;
2911
+ error: z.ZodString;
2912
+ code: z.ZodOptional<z.ZodString>;
2913
+ }, z.core.$strict>;
2914
+ /**
2915
+ * Confirmation response schema
2916
+ * Tools return this when an operation needs user approval.
2917
+ * The agent service detects this shape and enters the confirmation flow.
2918
+ */
2919
+ declare const toolConfirmationSchema: z.ZodObject<{
2920
+ needsConfirmation: z.ZodLiteral<true>;
2921
+ toolName: z.ZodString;
2922
+ summary: z.ZodString;
2923
+ completionSummary: z.ZodOptional<z.ZodString>;
2924
+ preview: z.ZodOptional<z.ZodString>;
2925
+ args: z.ZodUnknown;
2926
+ }, z.core.$strict>;
2927
+ /**
2928
+ * Standardized tool response schema
2929
+ * All tools return one of: success, error, or confirmation request.
2930
+ */
2931
+ declare const toolResponseSchema: z.ZodUnion<readonly [typeof toolSuccessSchema, typeof toolErrorSchema, typeof toolConfirmationSchema]>;
2932
+ type ToolResponse = z.output<typeof toolResponseSchema>;
2933
+ type ToolSideEffects = "none" | "writes" | "external";
2934
+ type DirectMcpExposure = "none" | "basic" | "debug";
2935
+ type ToolInputSchema = ZodRawShape;
2936
+ type ToolOutputSchema = z.ZodType;
2937
+ type MCPProtocolMode = "basic" | "debug";
2938
+ /**
2939
+ * Tool definition
2940
+ * @template TOutput - The output type, defaults to ToolResponse for backward compatibility
2941
+ */
2942
+ interface Tool<TOutput = ToolResponse> {
2943
+ name: string;
2944
+ description: string;
2945
+ inputSchema: ToolInputSchema;
2946
+ outputSchema?: ToolOutputSchema;
2947
+ handler: (input: unknown, context: ToolContext) => Promise<TOutput>;
2948
+ visibility?: ToolVisibility;
2949
+ /** Declares whether this tool is safe to repeat/cache within one model turn. Undefined defaults to not cacheable. */
2950
+ sideEffects?: ToolSideEffects;
2951
+ /** Whether the LLM agent may receive this tool in its callable tool set. Defaults to true. */
2952
+ agentTool?: boolean;
2953
+ /** Direct external MCP protocol exposure. Defaults to debug; basic exposure requires an explicit opt-in. */
2954
+ directMcpExposure?: DirectMcpExposure;
2955
+ /** MCP protocol annotations advertised to external clients. Derived from sideEffects when omitted. */
2956
+ annotations?: ToolAnnotations;
2957
+ /** Optional CLI metadata — makes this tool invocable as a brain CLI command */
2958
+ cli?: {
2959
+ /** CLI command name (e.g. "list", "sync", "build") */
2960
+ name: string;
2961
+ };
2962
+ }
2963
+ /**
2964
+ * Resource definition
2965
+ */
2966
+ interface Resource {
2967
+ uri: string;
2968
+ name: string;
2969
+ description?: string;
2970
+ mimeType?: string;
2971
+ handler: () => Promise<{
2972
+ contents: Array<{
2973
+ text: string;
2974
+ uri: string;
2975
+ mimeType?: string;
2976
+ }>;
2977
+ }>;
2978
+ }
2979
+ /**
2980
+ * Variables extracted from a URI template.
2981
+ * Generic parameter ensures handlers receive typed vars, not loose index signatures.
2982
+ */
2983
+ type ResourceVars<K extends string = string> = { [P in K]: string; };
2984
+ /**
2985
+ * A parameterized resource with URI template (e.g. "entity://{type}/{id}")
2986
+ */
2987
+ interface ResourceTemplate<K extends string = string> {
2988
+ name: string;
2989
+ uriTemplate: string;
2990
+ description?: string;
2991
+ mimeType?: string;
2992
+ /** List all concrete resources matching this template (for resources/list) */
2993
+ list?: () => Promise<Array<{
2994
+ uri: string;
2995
+ name: string;
2996
+ }>>;
2997
+ /** Autocomplete values for template variables (populates client selectors) */
2998
+ complete?: Record<K, (value: string, context?: {
2999
+ arguments?: Partial<ResourceVars<K>>;
3000
+ }) => string[] | Promise<string[]>>;
3001
+ /** Read a single resource by resolved template variables */
3002
+ handler: (vars: ResourceVars<K>) => Promise<{
3003
+ contents: Array<{
3004
+ text: string;
3005
+ uri: string;
3006
+ mimeType?: string;
3007
+ }>;
3008
+ }>;
3009
+ }
3010
+ /**
3011
+ * An MCP prompt — parameterized message template for client prompt pickers
3012
+ */
3013
+ interface Prompt {
3014
+ name: string;
3015
+ description?: string;
3016
+ args: Record<string, {
3017
+ description: string;
3018
+ required?: boolean;
3019
+ }>;
3020
+ handler: (args: Record<string, string>) => Promise<{
3021
+ messages: Array<{
3022
+ role: "user" | "assistant";
3023
+ content: {
3024
+ type: "text";
3025
+ text: string;
3026
+ };
3027
+ }>;
3028
+ }>;
3029
+ /** Default: "admin" — prompt bodies can reference restricted workflows,
3030
+ * so they ship as admin-only unless explicitly marked. */
3031
+ visibility?: ToolVisibility;
3032
+ }
3033
+ /**
3034
+ * Minimal interface exposed to transport layers
3035
+ * Only provides what's needed to connect transports to the MCP server
3036
+ */
3037
+ interface IMCPTransport {
3038
+ /**
3039
+ * Get the underlying MCP server for transport layers to connect to
3040
+ * Transport layers should import McpServer from @modelcontextprotocol/server directly
3041
+ */
3042
+ getMcpServer(): McpServer;
3043
+ /**
3044
+ * Create a fresh MCP server instance with all registered tools/resources.
3045
+ * Stateless HTTP invokes this for every authenticated request.
3046
+ */
3047
+ createMcpServer(permissionLevel?: UserPermissionLevel): McpServer;
3048
+ /**
3049
+ * Set the permission level for this transport
3050
+ */
3051
+ setPermissionLevel(level: UserPermissionLevel): void;
3052
+ /** Set whether the transport's configured caller is the brain Anchor. */
3053
+ setAnchorStatus?(isAnchor: boolean): void;
3054
+ /** Select which registered tools are exposed on the external MCP protocol server. */
3055
+ setProtocolMode(mode: MCPProtocolMode): void;
3056
+ }
3057
+ /**
3058
+ * Tool registration info
3059
+ */
3060
+ interface ToolInfo {
3061
+ name: string;
3062
+ description: string;
3063
+ pluginId: string;
3064
+ }
3065
+ //#endregion
3066
+ //#region ../../shell/entity-service/src/datasource-registry.d.ts
3067
+ /**
3068
+ * The data source registry as consumers use it.
3069
+ *
3070
+ * They depend on this rather than on `InMemoryDataSourceRegistry`: the class
3071
+ * has private state and a private constructor, so nothing else can be
3072
+ * assignable to it — which is why every test double had to be asserted in.
3073
+ */
3074
+ interface DataSourceRegistry {
3075
+ register(dataSource: DataSource): void;
3076
+ unregister(id: string): void;
3077
+ get(id: string): DataSource | undefined;
3078
+ has(id: string): boolean;
3079
+ list(): DataSource[];
3080
+ getIds(): string[];
3081
+ getByCapability(capability: keyof DataSourceCapabilities): DataSource[];
3082
+ find(predicate: (dataSource: DataSource) => boolean): DataSource[];
3083
+ clear(): void;
3084
+ }
3085
+ //#endregion
3086
+ //#region ../../shell/plugins/src/manager/daemon-types.d.ts
3087
+ /**
3088
+ * Daemon health status schema
3089
+ */
3090
+ declare const DaemonHealthSchema: z.ZodObject<{
3091
+ status: z.ZodEnum<{
3092
+ healthy: "healthy";
3093
+ warning: "warning";
3094
+ error: "error";
3095
+ unknown: "unknown";
3096
+ }>;
3097
+ message: z.ZodOptional<z.ZodString>;
3098
+ lastCheck: z.ZodOptional<z.ZodDate>;
3099
+ details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3100
+ }>;
3101
+ type DaemonHealth = z.output<typeof DaemonHealthSchema>;
3102
+ /**
3103
+ * Daemon status info schema for validation
3104
+ */
3105
+ declare const DaemonStatusInfoSchema: z.ZodObject<{
3106
+ name: z.ZodString;
3107
+ pluginId: z.ZodString;
3108
+ status: z.ZodString;
3109
+ health: z.ZodOptional<typeof DaemonHealthSchema>;
3110
+ }>;
3111
+ /**
3112
+ * Daemon interface for long-running interface processes
3113
+ */
3114
+ interface Daemon {
3115
+ /**
3116
+ * Start the daemon - called when plugin is initialized
3117
+ */
3118
+ start: () => Promise<void>;
3119
+ /**
3120
+ * Stop the daemon - called when plugin is unloaded/shutdown
3121
+ */
3122
+ stop: () => Promise<void>;
3123
+ /**
3124
+ * Optional health check - called periodically to monitor daemon health
3125
+ */
3126
+ healthCheck?: () => Promise<DaemonHealth>;
3127
+ }
3128
+ //#endregion
3129
+ //#region ../../shell/content-service/src/generation-context.d.ts
3130
+ /** Context shared by immediate and durable template-based generation. */
3131
+ declare const generationContextSchema: z.ZodObject<{
3132
+ prompt: z.ZodOptional<z.ZodString>;
3133
+ conversationHistory: z.ZodOptional<z.ZodString>;
3134
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3135
+ representedIdentity: z.ZodOptional<z.ZodEnum<{
3136
+ brain: "brain";
3137
+ anchor: "anchor";
3138
+ none: "none";
3139
+ }>>;
3140
+ styleGuide: z.ZodOptional<z.ZodObject<{
3141
+ voice: z.ZodOptional<z.ZodString>;
3142
+ visual: z.ZodOptional<z.ZodString>;
3143
+ }>>;
3144
+ }>;
3145
+ type GenerationContext = z.output<typeof generationContextSchema>;
3146
+ //#endregion
3147
+ //#region ../../shell/content-service/src/generation-authorization.d.ts
3148
+ /** Supplied by a trusted runtime binding, never by a tool's input schema. */
3149
+ interface GenerationCaller {
3150
+ actor: ActorRef;
3151
+ permissionLevel: UserPermissionLevel;
3152
+ }
3153
+ /** Durable delegation: account binding and an admission-time permission ceiling. */
3154
+ interface GenerationAuthority {
3155
+ actor: ActorRef;
3156
+ permissionCeiling: UserPermissionLevel;
3157
+ principalId?: string | undefined;
3158
+ }
3159
+ interface GenerationAccess {
3160
+ permissionLevel: UserPermissionLevel;
3161
+ visibilityScope: ContentVisibility;
3162
+ }
3163
+ //#endregion
3164
+ //#region ../../shell/content-service/src/generation-contracts.d.ts
3165
+ interface DurableGenerationContext extends Omit<GenerationContext, "data"> {
3166
+ data?: JsonObject | undefined;
3167
+ }
3168
+ interface ContentGenerationDestination {
3169
+ entityType: string;
3170
+ idPath: EntityIdPath;
3171
+ metadata: JsonObject;
3172
+ visibility?: ContentVisibility | undefined;
3173
+ }
3174
+ interface ContentGenerationDestinationInput {
3175
+ entityType: string;
3176
+ idPath: EntityIdPathInput;
3177
+ metadata: JsonObject;
3178
+ visibility?: ContentVisibility | undefined;
3179
+ }
3180
+ interface ContentGenerationTarget {
3181
+ templateName: string;
3182
+ context: DurableGenerationContext;
3183
+ destination: ContentGenerationDestination;
3184
+ }
3185
+ interface ContentGenerationTargetInput {
3186
+ templateName: string;
3187
+ context?: DurableGenerationContext;
3188
+ destination: ContentGenerationDestinationInput;
3189
+ }
3190
+ interface ContentGenerationOptions {
3191
+ dryRun?: boolean;
3192
+ force?: boolean;
3193
+ }
3194
+ interface ContentGenerationRequestInput {
3195
+ caller: GenerationCaller;
3196
+ targets: ContentGenerationTargetInput[];
3197
+ options?: ContentGenerationOptions;
3198
+ /** Template names are local to this plugin and scoped by the runtime. */
3199
+ pluginId?: string;
3200
+ }
3201
+ interface PersistedContentGenerationDestination {
3202
+ entityType: string;
3203
+ entityId: string;
3204
+ metadata: JsonObject;
3205
+ visibility: ContentVisibility;
3206
+ }
3207
+ interface ContentGenerationJobData {
3208
+ authority: GenerationAuthority;
3209
+ templateName: string;
3210
+ context: DurableGenerationContext;
3211
+ destination: PersistedContentGenerationDestination;
3212
+ expectedRevision: string | null;
3213
+ }
3214
+ declare const contentGenerationSkipReasons: readonly ["content-exists", "template-not-found", "template-cannot-generate"];
3215
+ type ContentGenerationSkipReason = (typeof contentGenerationSkipReasons)[number];
3216
+ /** `index` is the target's position in the request, so results keep its order. */
3217
+ interface PlannedContentGeneration {
3218
+ readonly index: number;
3219
+ readonly target: ContentGenerationTarget;
3220
+ readonly entityId: string;
3221
+ readonly jobData: ContentGenerationJobData;
3222
+ }
3223
+ interface SkippedContentGeneration {
3224
+ readonly index: number;
3225
+ readonly target: ContentGenerationTarget;
3226
+ readonly entityId: string;
3227
+ readonly reason: ContentGenerationSkipReason;
3228
+ }
3229
+ interface ContentGenerationPlan {
3230
+ readonly planned: readonly PlannedContentGeneration[];
3231
+ readonly skipped: readonly SkippedContentGeneration[];
3232
+ readonly totalTargets: number;
3233
+ }
3234
+ interface ContentGenerationItemBase {
3235
+ readonly destination: {
3236
+ readonly entityType: string;
3237
+ readonly idPath: EntityIdPath;
3238
+ readonly entityId: string;
3239
+ };
3240
+ readonly templateName: string;
3241
+ }
3242
+ /** One admission decision per requested target, in request order. */
3243
+ type ContentGenerationItemResult = (ContentGenerationItemBase & {
3244
+ readonly status: "planned";
3245
+ }) | (ContentGenerationItemBase & {
3246
+ readonly status: "queued";
3247
+ readonly jobId: string;
3248
+ }) | (ContentGenerationItemBase & {
3249
+ readonly status: "skipped";
3250
+ readonly reason: ContentGenerationSkipReason;
3251
+ });
3252
+ interface ContentGenerationBatchResult {
3253
+ readonly items: readonly ContentGenerationItemResult[];
3254
+ readonly totalTargets: number;
3255
+ readonly plannedTargets: number;
3256
+ readonly queuedTargets: number;
3257
+ readonly skippedTargets: number;
3258
+ readonly batchId?: string;
3259
+ }
3260
+ //#endregion
3261
+ //#region ../../shell/content-service/src/generation-submission.d.ts
3262
+ /**
3263
+ * Runtime wiring, never author-supplied tool input. The plugin layer owns job
3264
+ * options and attribution; content-service only decides what to enqueue.
3265
+ */
3266
+ interface GenerationQueueBinding {
3267
+ /** Existing root job ID to share; a fresh one is allocated otherwise. */
3268
+ batchId?: string | undefined;
3269
+ enqueue(jobData: ContentGenerationJobData, batchId: string): Promise<string>;
3270
+ }
3271
+ //#endregion
3272
+ //#region ../../shell/content-service/src/types.d.ts
3273
+ type ContentTemplateDataSchema<T> = ZodType<T, unknown>;
3274
+ /**
3275
+ * Zod schema for ContentTemplate validation (used in plugin configurations)
3276
+ */
3277
+ declare const ContentTemplateSchema: z.ZodObject<{
3278
+ name: z.ZodString;
3279
+ description: z.ZodString;
3280
+ schema: z.ZodUnknown;
3281
+ basePrompt: z.ZodOptional<z.ZodString>;
3282
+ requiredPermission: z.ZodEnum<{
3283
+ admin: "admin";
3284
+ trusted: "trusted";
3285
+ public: "public";
3286
+ }>;
3287
+ formatter: z.ZodOptional<z.ZodUnknown>;
3288
+ dataSourceId: z.ZodOptional<z.ZodString>;
3289
+ layout: z.ZodOptional<z.ZodObject<{
3290
+ component: z.ZodUnknown;
3291
+ description: z.ZodOptional<z.ZodString>;
3292
+ packageName: z.ZodOptional<z.ZodString>;
3293
+ }>>;
3294
+ }>;
3295
+ type ContentTemplateInput = z.output<typeof ContentTemplateSchema>;
3296
+ /**
3297
+ * ContentTemplate for reusable generation patterns and view rendering
3298
+ */
3299
+ interface ContentTemplate<T = unknown> extends Omit<ContentTemplateInput, "schema" | "formatter"> {
3300
+ schema: ContentTemplateDataSchema<T>;
3301
+ formatter?: ContentFormatter<T>;
3302
+ dataSourceId?: string;
3303
+ }
3304
+ /**
3305
+ * Options for content resolution with multiple strategies
3306
+ */
3307
+ interface ResolutionOptions {
3308
+ /** Look up previously saved content from entity storage */
3309
+ savedContent?: {
3310
+ entityType: string;
3311
+ entityId: string;
3312
+ };
3313
+ /** Parameters for DataSource fetch operation */
3314
+ dataParams?: unknown;
3315
+ /** Format for DataSource transform operation (e.g., "list" or "detail") */
3316
+ transformFormat?: string;
3317
+ /** Static fallback content */
3318
+ fallback?: unknown;
3319
+ /**
3320
+ * Whether to filter to only published/complete content
3321
+ * Set by site-builder: true for production, false for preview
3322
+ */
3323
+ publishedOnly?: boolean;
3324
+ /**
3325
+ * Visibility scope to enforce on entity lookups within this resolution.
3326
+ * Set by site-builder: "public" for production, anchor scope for preview.
3327
+ * Undefined fails closed at the entity-service chokepoint to "public".
3328
+ */
3329
+ visibilityScope?: ContentVisibility;
3330
+ }
3331
+ /**
3332
+ * Public interface for ContentService
3333
+ * Used by plugins and for testing
3334
+ */
3335
+ /** Runtime-only generation settings; never author input. */
3336
+ interface GenerateContentOptions {
3337
+ pluginId?: string | undefined;
3338
+ signal?: AbortSignal | undefined;
3339
+ /** Fixes every read to the authorized output visibility (durable jobs). */
3340
+ visibilityScope?: ContentVisibility | undefined;
3341
+ }
3342
+ interface ContentService {
3343
+ /**
3344
+ * Authorize a durable generation job: the full policy when it starts, and
3345
+ * current authority over the final fields when `persisted` is supplied.
3346
+ */
3347
+ authorizeGenerationWrite(data: ContentGenerationJobData, persisted?: Readonly<BaseEntity>): Promise<GenerationAccess>;
3348
+ submitGeneration(request: ContentGenerationRequestInput, binding: GenerationQueueBinding, signal?: AbortSignal): Promise<ContentGenerationBatchResult>;
3349
+ /** Plan validated, template-backed generation without enqueueing work. */
3350
+ planGeneration(request: ContentGenerationRequestInput, signal?: AbortSignal): Promise<ContentGenerationPlan>;
3351
+ /**
3352
+ * Get a registered template
3353
+ */
3354
+ getTemplate(name: string): ContentTemplate<unknown> | null;
3355
+ /**
3356
+ * List all available templates
3357
+ */
3358
+ listTemplates(): ContentTemplate<unknown>[];
3359
+ /**
3360
+ * Resolve content for a template using multiple resolution strategies
3361
+ * Priority order: DataSource fetch -> saved content -> fallback
3362
+ *
3363
+ * Returns `unknown`: the value is validated against the *template's* schema,
3364
+ * which a caller-chosen type parameter has no relationship to. Callers that
3365
+ * need a specific type should parse it.
3366
+ */
3367
+ resolveContent(templateName: string, options?: ResolutionOptions, pluginId?: string): Promise<unknown>;
3368
+ /**
3369
+ * Generate content using a template with entity-aware context.
3370
+ *
3371
+ * Returns unknown: generation validates against the template's schema, and
3372
+ * callers parse the shape they need.
3373
+ */
3374
+ generateContent(templateName: string, context?: GenerationContext, options?: GenerateContentOptions): Promise<unknown>;
3375
+ /**
3376
+ * Format content using a template's formatter
3377
+ */
3378
+ formatContent<T = unknown>(templateName: string, data: T, options?: {
3379
+ truncate?: number;
3380
+ pluginId?: string;
3381
+ }): string;
3382
+ /**
3383
+ * Parse existing content using a template's formatter. Returns unknown:
3384
+ * the formatter parses to the template's own shape.
3385
+ */
3386
+ parseContent(templateName: string, content: string, pluginId?: string): unknown;
3387
+ }
3388
+ //#endregion
3389
+ //#region ../../shell/ai-service/src/types.d.ts
3390
+ type AIGenerationSchema<T> = ZodType<T>;
3391
+ /**
3392
+ * Aspect ratio for image generation
3393
+ */
3394
+ type AspectRatio = "1:1" | "16:9" | "9:16" | "4:3" | "3:4";
3395
+ /**
3396
+ * Options for image generation
3397
+ */
3398
+ interface ImageGenerationOptions {
3399
+ /** Aspect ratio for the generated image (default: "16:9") */
3400
+ aspectRatio?: AspectRatio;
3401
+ /** Cancel the underlying provider request. */
3402
+ signal?: AbortSignal;
3403
+ }
3404
+ /**
3405
+ * Result of image generation
3406
+ */
3407
+ interface ImageGenerationResult {
3408
+ /** Raw base64-encoded image data */
3409
+ base64: string;
3410
+ /** Data URL format: data:image/png;base64,... */
3411
+ dataUrl: string;
3412
+ }
3413
+ //#endregion
3414
+ //#region ../../shared/contracts/src/chat.d.ts
3415
+ type Strict<Shape extends z.ZodRawShape> = z.ZodObject<Shape, z.core.$strict>;
3416
+ /** Pinned when a guest conversation is created; reads cannot renew retention. */
3417
+ declare const guestRetentionSchema: Strict<{
3418
+ idleSeconds: z.ZodNumber;
3419
+ maxAgeSeconds: z.ZodNumber;
3420
+ }>;
3421
+ declare const guestConversationOwnershipSchema: Strict<{
3422
+ visitorId: z.ZodString;
3423
+ retention: typeof guestRetentionSchema;
3424
+ }>;
3425
+ type GuestConversationOwnership = z.output<typeof guestConversationOwnershipSchema>;
3426
+ //#endregion
3427
+ //#region ../../shell/conversation-service/src/schema.d.ts
3428
+ type ConversationTextColumn<TTable extends string, TName extends string, TNotNull extends boolean, TPrimaryKey extends boolean = false> = SqliteTextColumn<TTable, TName, TNotNull, false, TPrimaryKey, false, TNotNull extends true ? string : string | null>;
3429
+ type ConversationsTable = SQLiteTableWithColumns<{
3430
+ name: "conversations";
3431
+ schema: undefined;
3432
+ columns: {
3433
+ id: ConversationTextColumn<"conversations", "id", true, true>;
3434
+ sessionId: ConversationTextColumn<"conversations", "session_id", true>;
3435
+ interfaceType: ConversationTextColumn<"conversations", "interface_type", true>;
3436
+ channelId: ConversationTextColumn<"conversations", "channel_id", true>;
3437
+ personId: ConversationTextColumn<"conversations", "person_id", false>;
3438
+ started: ConversationTextColumn<"conversations", "started", true>;
3439
+ lastActive: ConversationTextColumn<"conversations", "last_active", true>;
3440
+ metadata: ConversationTextColumn<"conversations", "metadata", false>;
3441
+ created: ConversationTextColumn<"conversations", "created", true>;
3442
+ updated: ConversationTextColumn<"conversations", "updated", true>;
3443
+ };
3444
+ dialect: "sqlite";
3445
+ }>;
3446
+ type MessagesTable = SQLiteTableWithColumns<{
3447
+ name: "messages";
3448
+ schema: undefined;
3449
+ columns: {
3450
+ id: ConversationTextColumn<"messages", "id", true, true>;
3451
+ conversationId: ConversationTextColumn<"messages", "conversation_id", true>;
3452
+ role: ConversationTextColumn<"messages", "role", true>;
3453
+ content: ConversationTextColumn<"messages", "content", true>;
3454
+ timestamp: ConversationTextColumn<"messages", "timestamp", true>;
3455
+ metadata: ConversationTextColumn<"messages", "metadata", false>;
3456
+ };
3457
+ dialect: "sqlite";
3458
+ }>;
3459
+ /**
3460
+ * Conversations table - tracks conversation sessions
3461
+ */
3462
+ declare const conversations: ConversationsTable;
3463
+ /**
3464
+ * Messages table - stores individual messages in conversations
3465
+ */
3466
+ declare const messages: MessagesTable;
3467
+ type Conversation = typeof conversations.$inferSelect;
3468
+ type Message = typeof messages.$inferSelect;
3469
+ //#endregion
3470
+ //#region ../../shell/conversation-service/src/types.d.ts
3471
+ /**
3472
+ * Metadata for a conversation
3473
+ */
3474
+ interface ConversationMetadata {
3475
+ guest?: GuestConversationOwnership;
3476
+ channelName: string;
3477
+ interfaceType: string;
3478
+ channelId: string;
3479
+ }
3480
+ /**
3481
+ * Service interface for conversation storage
3482
+ */
3483
+ /**
3484
+ * Options for retrieving messages
3485
+ */
3486
+ interface GetMessagesOptions {
3487
+ limit?: number;
3488
+ range?: {
3489
+ start: number;
3490
+ end: number;
3491
+ };
3492
+ }
3493
+ interface StartConversationRequest {
3494
+ sessionId: string;
3495
+ interfaceType: string;
3496
+ channelId: string;
3497
+ personId?: string;
3498
+ metadata: ConversationMetadata;
3499
+ }
3500
+ declare const conversationMessageActorSchema: z.ZodObject<{
3501
+ identity: typeof actorRefSchema;
3502
+ interfaceType: z.ZodString;
3503
+ role: typeof messageRoleSchema;
3504
+ displayName: z.ZodOptional<z.ZodString>;
3505
+ username: z.ZodOptional<z.ZodString>;
3506
+ isBot: z.ZodOptional<z.ZodBoolean>;
3507
+ }>;
3508
+ type ConversationMessageActor = z.output<typeof conversationMessageActorSchema>;
3509
+ declare const conversationMessageSourceSchema: z.ZodObject<{
3510
+ messageId: z.ZodOptional<z.ZodString>;
3511
+ channelId: z.ZodOptional<z.ZodString>;
3512
+ channelName: z.ZodOptional<z.ZodString>;
3513
+ threadId: z.ZodOptional<z.ZodString>;
3514
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3515
+ }>;
3516
+ type ConversationMessageSource = z.output<typeof conversationMessageSourceSchema>;
3517
+ interface AddConversationMessageRequest {
3518
+ conversationId: string;
3519
+ role: MessageRole;
3520
+ content: string;
3521
+ metadata?: Record<string, unknown>;
3522
+ }
3523
+ interface UpdateConversationMetadataRequest {
3524
+ conversationId: string;
3525
+ metadata: Record<string, unknown>;
3526
+ }
3527
+ interface ListConversationsOptions {
3528
+ limit?: number;
3529
+ offset?: number;
3530
+ /** Match title or message text literally, case-insensitively. */
3531
+ query?: string;
3532
+ /** Omit to include both active and archived conversations. */
3533
+ archived?: boolean;
3534
+ updatedAfter?: string;
3535
+ interfaceType?: string;
3536
+ sessionId?: string;
3537
+ channelId?: string;
3538
+ personId?: string;
3539
+ }
3540
+ interface IConversationService {
3541
+ /** Settle non-fatal database readiness work (connection pragmas). */
3542
+ initialize?(): Promise<void>;
3543
+ startConversation(request: StartConversationRequest): Promise<string>;
3544
+ addMessage(request: AddConversationMessageRequest): Promise<void>;
3545
+ getMessages(conversationId: string, options?: GetMessagesOptions): Promise<Message[]>;
3546
+ countMessages(conversationId: string): Promise<number>;
3547
+ getConversation(conversationId: string): Promise<Conversation | null>;
3548
+ listConversations(options?: ListConversationsOptions): Promise<Conversation[]>;
3549
+ updateConversationMetadata(request: UpdateConversationMetadataRequest): Promise<boolean>;
3550
+ deleteConversation(conversationId: string): Promise<boolean>;
3551
+ /** Trusted host maintenance; never an anonymous conversation action. */
3552
+ deleteExpiredGuestConversations(limit?: number): Promise<number>;
3553
+ searchConversations(query: string, sessionId?: string): Promise<Conversation[]>;
3554
+ close(): void;
3555
+ }
3556
+ //#endregion
3557
+ //#region ../../shell/identity-service/src/brain-character-schema.d.ts
3558
+ interface BrainCharacter {
3559
+ name: string;
3560
+ role: string;
3561
+ purpose: string;
3562
+ values: string[];
3563
+ }
3564
+ //#endregion
3565
+ //#region ../../shell/identity-service/src/anchor-profile-schema.d.ts
3566
+ interface AnchorProfileSocialLink {
3567
+ platform: "github" | "instagram" | "linkedin" | "email" | "website";
3568
+ url: string;
3569
+ label?: string | undefined;
3570
+ }
3571
+ interface AnchorProfile {
3572
+ name: string;
3573
+ organization?: string | undefined;
3574
+ description?: string | undefined;
3575
+ avatar?: string | undefined;
3576
+ website?: string | undefined;
3577
+ email?: string | undefined;
3578
+ socialLinks?: AnchorProfileSocialLink[] | undefined;
3579
+ }
3580
+ //#endregion
3581
+ //#region ../../shell/identity-service/src/profile-kind-registry.d.ts
3582
+ declare const profileCategorySchema: z.ZodEnum<{
3583
+ person: "person";
3584
+ team: "team";
3585
+ organization: "organization";
3586
+ }>;
3587
+ type ProfileCategory = z.infer<typeof profileCategorySchema>;
3588
+ interface ProfileKindLabels {
3589
+ singular: string;
3590
+ plural: string;
3591
+ }
3592
+ interface ProfileKindDefinition {
3593
+ kind: string;
3594
+ category: ProfileCategory;
3595
+ fields: FrontmatterSchema;
3596
+ labels: ProfileKindLabels;
3597
+ }
3598
+ interface ResolvedProfileKind {
3599
+ kind: string;
3600
+ category: ProfileCategory;
3601
+ labels: ProfileKindLabels;
3602
+ }
3603
+ type ResolvedProfileSelection = ResolvedProfileKind | null;
3604
+ interface IProfileKindRegistry {
3605
+ register(pluginId: string, definition: ProfileKindDefinition): void;
3606
+ unregisterPlugin(pluginId: string): void;
3607
+ finalize(): ResolvedProfileSelection;
3608
+ getResolved(): ResolvedProfileSelection;
3609
+ getSelectedDefinition(): ProfileKindDefinition | undefined;
3610
+ isFinalized(): boolean;
3611
+ }
3612
+ //#endregion
3613
+ //#region ../../shell/ai-service/src/agent-types.d.ts
3614
+ /**
3615
+ * Context for a chat message
3616
+ * Contains per-message information like user permission level
3617
+ */
3618
+ interface ChatAttachmentSource {
3619
+ kind: string;
3620
+ id: string;
3621
+ }
3622
+ interface TextChatAttachment {
3623
+ kind: "text";
3624
+ filename: string;
3625
+ mediaType: string;
3626
+ content: string;
3627
+ sizeBytes?: number | undefined;
3628
+ source?: ChatAttachmentSource | undefined;
3629
+ }
3630
+ interface FileChatAttachment {
3631
+ kind: "file";
3632
+ filename: string;
3633
+ mediaType: string;
3634
+ data: Uint8Array;
3635
+ sizeBytes?: number | undefined;
3636
+ source?: ChatAttachmentSource | undefined;
3637
+ }
3638
+ type ChatAttachment = TextChatAttachment | FileChatAttachment;
3639
+ interface ChatContext {
3640
+ /** Server-owned limits bound to the already-reserved guest execution. */
3641
+ guestExecution?: GuestExecutionPolicy;
3642
+ userPermissionLevel?: UserPermissionLevel;
3643
+ /** Whether the authenticated caller is the brain's configured Anchor. */
3644
+ isAnchor?: boolean;
3645
+ interfaceType?: string;
3646
+ channelId?: string;
3647
+ channelName?: string;
3648
+ actor?: ConversationMessageActor;
3649
+ source?: ConversationMessageSource;
3650
+ attachments?: ChatAttachment[] | undefined;
3651
+ }
3652
+ /**
3653
+ * Agent service interface
3654
+ */
3655
+ interface IAgentService {
3656
+ /** Guest turns can run: the search index they read is ready. */
3657
+ readonly guestReady?: boolean;
3658
+ /**
3659
+ * Send a message to the agent and get a response
3660
+ * @param message - The user's message
3661
+ * @param conversationId - ID of the conversation for history tracking
3662
+ * @param context - Optional context including user permission level
3663
+ */
3664
+ chat(message: string, conversationId: string, context?: ChatContext, signal?: AbortSignal): Promise<AgentResponse>;
3665
+ /**
3666
+ * Confirm a pending approval-gated action
3667
+ * @param conversationId - ID of the conversation
3668
+ * @param confirmed - Whether the user confirmed the operation
3669
+ * @param approvalId - Explicit approval/action id to resolve
3670
+ */
3671
+ confirmPendingAction(conversationId: string, confirmed: boolean, approvalId: string, context: ChatContext, signal?: AbortSignal): Promise<AgentResponse>;
3672
+ /** Stop active turns and release conversation actors. */
3673
+ shutdown?(): Promise<void>;
3674
+ /**
3675
+ * Invalidate the cached agent so the next conversation rebuilds
3676
+ * with fresh identity, profile, and instructions.
3677
+ */
3678
+ invalidateAgent(): void;
3679
+ }
3680
+ //#endregion
3681
+ //#region ../../shell/plugins/src/channel-registry.d.ts
3682
+ interface ChannelSubjectPattern {
3683
+ source: string;
3684
+ flags?: string | undefined;
3685
+ }
3686
+ interface ChannelDescriptor {
3687
+ type: string;
3688
+ displayName: string;
3689
+ subjectLabel: string;
3690
+ subjectPattern?: ChannelSubjectPattern | undefined;
3691
+ manualDelivery?: boolean | undefined;
3692
+ }
3693
+ type ChannelDeliverySensitivity = "normal" | "secret";
3694
+ interface ChannelDeliveryThreading {
3695
+ inReplyTo: string;
3696
+ references: string[];
3697
+ }
3698
+ interface ChannelDeliveryInput {
3699
+ recipient: string;
3700
+ subject: string;
3701
+ text: string;
3702
+ idempotencyKey: string;
3703
+ /** Optional rich body for transports that render it. */
3704
+ html?: string | undefined;
3705
+ /**
3706
+ * "secret" keeps recipient and subject out of provider logs. Providers that
3707
+ * cannot honour it should treat every delivery as secret.
3708
+ */
3709
+ sensitivity?: ChannelDeliverySensitivity | undefined;
3710
+ /** Optional transport threading metadata. Unsupported channels may ignore it. */
3711
+ threading?: ChannelDeliveryThreading | undefined;
3712
+ }
3713
+ type ChannelDeliveryResult = {
3714
+ status: "sent";
3715
+ providerDeliveryId?: string | undefined;
3716
+ } | {
3717
+ status: "failed";
3718
+ failureCode: string;
3719
+ };
3720
+ interface ChannelDeliveryProvider {
3721
+ channelType: string;
3722
+ isAvailable(): Promise<boolean>;
3723
+ send(input: ChannelDeliveryInput): Promise<ChannelDeliveryResult>;
3724
+ }
3725
+ interface IChannelRegistry {
3726
+ registerDescriptor(pluginId: string, descriptor: ChannelDescriptor): void;
3727
+ registerDeliveryProvider(pluginId: string, provider: ChannelDeliveryProvider): void;
3728
+ unregisterPlugin(pluginId: string): void;
3729
+ finalize(): void;
3730
+ listDescriptors(): ChannelDescriptor[];
3731
+ getDescriptor(channelType: string): ChannelDescriptor | undefined;
3732
+ getDeliveryProvider(channelType: string): ChannelDeliveryProvider | undefined;
3733
+ isFinalized(): boolean;
3734
+ }
3735
+ //#endregion
3736
+ //#region ../../shell/plugins/src/inbox-registry.d.ts
3737
+ declare const inboxUrgencySchema: z.ZodEnum<{
3738
+ high: "high";
3739
+ normal: "normal";
3740
+ }>;
3741
+ type InboxFacetOptionSchema = z.ZodObject<{
3742
+ value: z.ZodString;
3743
+ label: z.ZodString;
3744
+ }, z.core.$strict>;
3745
+ type InboxFacetDefinitionSchema = z.ZodObject<{
3746
+ key: z.ZodString;
3747
+ label: z.ZodString;
3748
+ values: z.ZodArray<InboxFacetOptionSchema>;
3749
+ }, z.core.$strict>;
3750
+ declare const inboxFacetDefinitionsSchema: z.ZodArray<InboxFacetDefinitionSchema>;
3751
+ declare const inboxFacetsSchema: z.ZodRecord<z.ZodString, z.ZodString>;
3752
+ type InboxFollowUpDeclarationSchema = z.ZodObject<{
3753
+ kind: z.ZodString;
3754
+ context: z.ZodRecord<z.ZodString, z.ZodString>;
3755
+ }, z.core.$strict>;
3756
+ declare const inboxFollowUpDeclarationsSchema: z.ZodArray<InboxFollowUpDeclarationSchema>;
3757
+ type InboxActionSchema = z.ZodObject<{
3758
+ id: z.ZodString;
3759
+ label: z.ZodString;
3760
+ confirm: z.ZodOptional<z.ZodBoolean>;
3761
+ }, z.core.$strict>;
3762
+ type InboxEntityRefSchema = z.ZodObject<{
3763
+ entityType: z.ZodString;
3764
+ entityId: z.ZodString;
3765
+ }, z.core.$strict>;
3766
+ type InboxContactSchema = z.ZodObject<{
3767
+ label: z.ZodString;
3768
+ personId: z.ZodOptional<z.ZodString>;
3769
+ }, z.core.$strict>;
3770
+ type InboxItemSchema = z.ZodObject<{
3771
+ id: z.ZodString;
3772
+ title: z.ZodString;
3773
+ summary: z.ZodOptional<z.ZodString>;
3774
+ contact: z.ZodOptional<InboxContactSchema>;
3775
+ threadOrdinal: z.ZodOptional<z.ZodNumber>;
3776
+ receivedAt: z.ZodISODateTime;
3777
+ urgency: typeof inboxUrgencySchema;
3778
+ entityRef: z.ZodOptional<InboxEntityRefSchema>;
3779
+ facets: z.ZodOptional<typeof inboxFacetsSchema>;
3780
+ followUps: z.ZodOptional<typeof inboxFollowUpDeclarationsSchema>;
3781
+ actions: z.ZodArray<InboxActionSchema>;
3782
+ }, z.core.$strict>;
3783
+ declare const inboxItemSchema: InboxItemSchema;
3784
+ type InboxActorSchema = z.ZodObject<{
3785
+ permissionLevel: z.ZodEnum<{
3786
+ admin: "admin";
3787
+ trusted: "trusted";
3788
+ public: "public";
3789
+ }>;
3790
+ }, z.core.$strict>;
3791
+ declare const inboxActorSchema: InboxActorSchema;
3792
+ type InboxItemDetailSchema = z.ZodObject<{
3793
+ kind: z.ZodLiteral<"plain">;
3794
+ text: z.ZodString;
3795
+ truncated: z.ZodBoolean;
3796
+ }, z.core.$strict>;
3797
+ declare const inboxItemDetailSchema: InboxItemDetailSchema;
3798
+ type InboxSourceDescriptorSchema = z.ZodObject<{
3799
+ sourceId: z.ZodString;
3800
+ displayName: z.ZodString;
3801
+ facets: z.ZodOptional<typeof inboxFacetDefinitionsSchema>;
3802
+ }, z.core.$strict>;
3803
+ declare const inboxSourceDescriptorSchema: InboxSourceDescriptorSchema;
3804
+ type InboxItem = z.output<typeof inboxItemSchema>;
3805
+ type InboxActor = z.output<typeof inboxActorSchema>;
3806
+ type InboxItemDetail = z.output<typeof inboxItemDetailSchema>;
3807
+ type InboxSourceDescriptor = z.output<typeof inboxSourceDescriptorSchema>;
3808
+ interface InboxSource extends InboxSourceDescriptor {
3809
+ list(): Promise<InboxItem[]>;
3810
+ resolveDetail?(itemId: string, actor: InboxActor, signal: AbortSignal): Promise<InboxItemDetail>;
3811
+ act(itemId: string, actionId: string, actor: InboxActor): Promise<void>;
3812
+ }
3813
+ interface IInboxRegistry {
3814
+ registerSource(pluginId: string, source: InboxSource): void;
3815
+ unregisterPlugin(pluginId: string): void;
3816
+ finalize(): void;
3817
+ listSources(): InboxSource[];
3818
+ getSource(sourceId: string): InboxSource | undefined;
3819
+ isFinalized(): boolean;
3820
+ }
3821
+ //#endregion
3822
+ //#region ../../shell/plugins/src/inbox-follow-up-registry.d.ts
3823
+ type InboxFollowUpMode = "universal" | "declared";
3824
+ type InboxFollowUpContext = Readonly<Record<string, string>>;
3825
+ interface InboxFollowUpResolutionInput {
3826
+ sourceId: string;
3827
+ item: InboxItem;
3828
+ actor: InboxActor;
3829
+ context?: InboxFollowUpContext | undefined;
3830
+ }
3831
+ interface InboxFollowUpTargetInput {
3832
+ href: string;
3833
+ state?: unknown;
3834
+ }
3835
+ interface InboxFollowUpKindRegistration {
3836
+ kind: string;
3837
+ label: string;
3838
+ priority: number;
3839
+ mode: InboxFollowUpMode;
3840
+ permissionLevel: UserPermissionLevel;
3841
+ contextSchema?: z.ZodType<InboxFollowUpContext, unknown> | undefined;
3842
+ applies(input: InboxFollowUpResolutionInput): boolean | Promise<boolean>;
3843
+ resolve(input: InboxFollowUpResolutionInput): InboxFollowUpTargetInput | undefined | Promise<InboxFollowUpTargetInput | undefined>;
3844
+ }
3845
+ type RegisteredInboxFollowUpKind = Readonly<InboxFollowUpKindRegistration>;
3846
+ interface IInboxFollowUpRegistry {
3847
+ registerKind(pluginId: string, registration: InboxFollowUpKindRegistration): void;
3848
+ unregisterPlugin(pluginId: string): void;
3849
+ finalize(): void;
3850
+ listKinds(): RegisteredInboxFollowUpKind[];
3851
+ getKind(kind: string): RegisteredInboxFollowUpKind | undefined;
3852
+ resolve(input: Omit<InboxFollowUpResolutionInput, "context">): Promise<ResolvedInboxFollowUp[]>;
3853
+ resolveUniversal(input: Omit<InboxFollowUpResolutionInput, "context">): Promise<ResolvedInboxFollowUp[]>;
3854
+ isFinalized(): boolean;
3855
+ }
3856
+ declare const inboxFollowUpStateSchema: z.ZodRecord<z.ZodString, ReturnType<typeof z.json>>;
3857
+ type ResolvedInboxFollowUpSchema = z.ZodObject<{
3858
+ kind: z.ZodString;
3859
+ label: z.ZodString;
3860
+ href: z.ZodString;
3861
+ state: z.ZodOptional<typeof inboxFollowUpStateSchema>;
3862
+ }, z.core.$strict>;
3863
+ declare const resolvedInboxFollowUpSchema: ResolvedInboxFollowUpSchema;
3864
+ type ResolvedInboxFollowUp = z.output<typeof resolvedInboxFollowUpSchema>;
3865
+ //#endregion
3866
+ //#region ../../shell/plugins/src/contracts/runtime-health.d.ts
3867
+ type RuntimeHealthCheckSchema = z.ZodObject<{
3868
+ name: z.ZodString;
3869
+ status: z.ZodEnum<{
3870
+ healthy: "healthy";
3871
+ degraded: "degraded";
3872
+ unhealthy: "unhealthy";
3873
+ }>;
3874
+ message: z.ZodOptional<z.ZodString>;
3875
+ details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3876
+ }>;
3877
+ declare const RuntimeHealthCheckSchema: RuntimeHealthCheckSchema;
3878
+ type RuntimeHealthCheck = z.output<typeof RuntimeHealthCheckSchema>;
3879
+ type RuntimeWorkerSignalsSchema = z.ZodObject<{
3880
+ total: z.ZodNumber;
3881
+ active: z.ZodNumber;
3882
+ stale: z.ZodNumber;
3883
+ latestHeartbeatAgeMs: z.ZodNullable<z.ZodNumber>;
3884
+ }>;
3885
+ type RuntimeQueueSignalsSchema = z.ZodObject<{
3886
+ totals: z.ZodObject<{
3887
+ pending: z.ZodNumber;
3888
+ processing: z.ZodNumber;
3889
+ completed: z.ZodNumber;
3890
+ failed: z.ZodNumber;
3891
+ }>;
3892
+ byType: z.ZodArray<z.ZodObject<{
3893
+ type: z.ZodString;
3894
+ status: z.ZodEnum<{
3895
+ pending: "pending";
3896
+ processing: "processing";
3897
+ completed: "completed";
3898
+ failed: "failed";
3899
+ }>;
3900
+ count: z.ZodNumber;
3901
+ }>>;
3902
+ oldestPendingAgeMs: z.ZodNullable<z.ZodNumber>;
3903
+ duePending: z.ZodNumber;
3904
+ oldestDuePendingAgeMs: z.ZodNullable<z.ZodNumber>;
3905
+ latestClaimAgeMs: z.ZodNullable<z.ZodNumber>;
3906
+ oldestProcessingAgeMs: z.ZodNullable<z.ZodNumber>;
3907
+ staleLeaseCount: z.ZodNumber;
3908
+ workerSessions: RuntimeWorkerSignalsSchema;
3909
+ }>;
3910
+ declare const RuntimeQueueSignalsSchema: RuntimeQueueSignalsSchema;
3911
+ type RuntimeResourceSignalsSchema = z.ZodObject<{
3912
+ memory: z.ZodObject<{
3913
+ rssBytes: z.ZodNumber;
3914
+ heapUsedBytes: z.ZodNumber;
3915
+ heapTotalBytes: z.ZodNumber;
3916
+ }>;
3917
+ fileDescriptors: z.ZodNullable<z.ZodNumber>;
3918
+ processes: z.ZodObject<{
3919
+ total: z.ZodNullable<z.ZodNumber>;
3920
+ zombies: z.ZodNullable<z.ZodNumber>;
3921
+ }>;
3922
+ queue: z.ZodNullable<RuntimeQueueSignalsSchema>;
3923
+ projection: z.ZodObject<{
3924
+ initialized: z.ZodBoolean;
3925
+ trackedRoots: z.ZodNumber;
3926
+ openCircuits: z.ZodArray<z.ZodObject<{
3927
+ projectionId: z.ZodString;
3928
+ reason: z.ZodString;
3929
+ openedAt: z.ZodNumber;
3930
+ expiresAt: z.ZodNumber;
3931
+ }>>;
3932
+ }>;
3933
+ worker: RuntimeWorkerSignalsSchema;
3934
+ }>;
3935
+ declare const RuntimeResourceSignalsSchema: RuntimeResourceSignalsSchema;
3936
+ type RuntimeReadinessSchema = z.ZodObject<{
3937
+ status: z.ZodEnum<{
3938
+ ready: "ready";
3939
+ not_ready: "not_ready";
3940
+ }>;
3941
+ operationalStatus: z.ZodEnum<{
3942
+ operational: "operational";
3943
+ degraded: "degraded";
3944
+ }>;
3945
+ checkedAt: z.ZodISODateTime;
3946
+ checks: z.ZodArray<RuntimeHealthCheckSchema>;
3947
+ resources: RuntimeResourceSignalsSchema;
3948
+ }>;
3949
+ declare const RuntimeReadinessSchema: RuntimeReadinessSchema;
3950
+ type RuntimeReadiness = z.output<typeof RuntimeReadinessSchema>;
3951
+ //#endregion
3952
+ //#region ../../shell/plugins/src/operational-health-registry.d.ts
3953
+ type OperationalHealthProvider = () => Promise<Omit<RuntimeHealthCheck, "name">> | Omit<RuntimeHealthCheck, "name">;
3954
+ interface IOperationalHealthRegistry {
3955
+ register(pluginId: string, name: string, provider: OperationalHealthProvider): () => void;
3956
+ unregisterPlugin(pluginId: string): void;
3957
+ getChecks(): Promise<RuntimeHealthCheck[]>;
3958
+ }
3959
+ //#endregion
3960
+ //#region ../../shell/plugins/src/operator/operator-field-contract.d.ts
3961
+ /** Host-rendered scalar controls shared by Account and Studio action forms. */
3962
+ declare const operatorFieldControlSchema: z.ZodEnum<{
3963
+ text: "text";
3964
+ url: "url";
3965
+ number: "number";
3966
+ checkbox: "checkbox";
3967
+ select: "select";
3968
+ }>;
3969
+ type OperatorFieldControl = z.output<typeof operatorFieldControlSchema>;
3970
+ declare const accountSettingsControlSchema: z.ZodEnum<{
3971
+ text: "text";
3972
+ url: "url";
3973
+ number: "number";
3974
+ checkbox: "checkbox";
3975
+ }>;
3976
+ type AccountSettingsControl = z.output<typeof accountSettingsControlSchema>;
3977
+ interface OperatorFieldDefinitionBase<TControl extends OperatorFieldControl = OperatorFieldControl> {
3978
+ readonly label: string;
3979
+ readonly control: TControl;
3980
+ readonly secret?: boolean | undefined;
3981
+ }
3982
+ //#endregion
3983
+ //#region ../../shell/plugins/src/operator/account-settings-definition-contract.d.ts
3984
+ type AccountSettingsSchema = z.ZodObject<z.ZodRawShape>;
3985
+ interface AccountSettingsFieldDefinition extends Omit<OperatorFieldDefinitionBase<AccountSettingsControl>, "control"> {
3986
+ readonly control?: AccountSettingsControl | undefined;
3987
+ }
3988
+ /**
3989
+ * Every schema field must be declared. Totality is what makes `secret` a
3990
+ * decision rather than an omission: a missing entry would otherwise render a
3991
+ * credential as an ordinary echoing text input.
3992
+ */
3993
+ type AccountSettingsFieldMap<TSchema extends AccountSettingsSchema> = { readonly [K in Extract<keyof z.input<TSchema>, string>]: AccountSettingsFieldDefinition; };
3994
+ interface AccountSettingsDefinition<TSchema extends AccountSettingsSchema = AccountSettingsSchema, TFields extends AccountSettingsFieldMap<TSchema> = AccountSettingsFieldMap<TSchema>> {
3995
+ readonly kind: "rizom-account-settings";
3996
+ readonly title: string;
3997
+ readonly description?: string | undefined;
3998
+ readonly schema: TSchema;
3999
+ readonly fields: TFields;
4000
+ }
4001
+ type AnyAccountSettingsDefinition = AccountSettingsDefinition<AccountSettingsSchema, AccountSettingsFieldMap<AccountSettingsSchema>>;
4002
+ type AccountSettingsValue<TDefinition extends AnyAccountSettingsDefinition> = z.output<TDefinition["schema"]>;
4003
+ //#endregion
4004
+ //#region ../../shell/plugins/src/operator/account-settings-registry.d.ts
4005
+ type AccountSettingsScalar = z.output<typeof accountSettingsScalarSchema>;
4006
+ type AccountSettingsStoredValues = Readonly<Record<string, AccountSettingsScalar>>;
4007
+ interface AccountSettingsStorageIdentity {
4008
+ readonly packageName: string;
4009
+ readonly definitionId: string;
4010
+ readonly actorId: string;
4011
+ }
4012
+ interface StoredAccountSettings {
4013
+ readonly values: AccountSettingsStoredValues;
4014
+ readonly revision: number;
4015
+ }
4016
+ interface AccountSettingsBackend {
4017
+ read(identity: AccountSettingsStorageIdentity): Promise<StoredAccountSettings | null>;
4018
+ list(input: {
4019
+ readonly packageName: string;
4020
+ readonly definitionId: string;
4021
+ }): Promise<readonly {
4022
+ readonly actorId: string;
4023
+ readonly values: AccountSettingsStoredValues;
4024
+ readonly revision: number;
4025
+ }[]>;
4026
+ write(identity: AccountSettingsStorageIdentity, values: AccountSettingsStoredValues): Promise<StoredAccountSettings>;
4027
+ delete(identity: AccountSettingsStorageIdentity): Promise<boolean>;
4028
+ deleteActor(actorId: string): Promise<number>;
4029
+ }
4030
+ interface AccountSettingsRegistration<TDefinition extends AnyAccountSettingsDefinition = AnyAccountSettingsDefinition> {
4031
+ readonly id: string;
4032
+ readonly ownerPluginId: string;
4033
+ readonly packageName: string;
4034
+ readonly definitionId: string;
4035
+ readonly definition: TDefinition;
4036
+ }
4037
+ interface AccountSettingsFormField {
4038
+ readonly name: string;
4039
+ readonly label: string;
4040
+ readonly control: "text" | "url" | "number" | "checkbox";
4041
+ readonly secret: boolean;
4042
+ readonly required: boolean;
4043
+ readonly value?: AccountSettingsScalar | undefined;
4044
+ readonly set?: boolean | undefined;
4045
+ }
4046
+ interface AccountSettingsForm {
4047
+ readonly id: string;
4048
+ readonly title: string;
4049
+ readonly description?: string | undefined;
4050
+ readonly configured: boolean;
4051
+ /** Opaque change token for host form reset; never contains stored values. */
4052
+ readonly revision: number | null;
4053
+ readonly fields: readonly AccountSettingsFormField[];
4054
+ }
4055
+ interface ConfiguredAccountSettings<TDefinition extends AnyAccountSettingsDefinition = AnyAccountSettingsDefinition> {
4056
+ readonly id: string;
4057
+ readonly settings: AccountSettingsValue<TDefinition>;
4058
+ readonly revision: number;
4059
+ }
4060
+ interface RegisterAccountSettingsInput<TDefinition extends AnyAccountSettingsDefinition = AnyAccountSettingsDefinition> {
4061
+ readonly ownerPluginId: string;
4062
+ readonly packageName: string;
4063
+ readonly definitionId: string;
4064
+ readonly definition: TDefinition;
4065
+ }
4066
+ type AccountSettingsChangeListener = () => void;
4067
+ declare const accountSettingsScalarSchema: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
4068
+ /** App-scoped definition catalog and guarded access to the auth-owned backend. */
4069
+ declare class AccountSettingsRegistry {
4070
+ private readonly registrations;
4071
+ private readonly listeners;
4072
+ private readonly mutationTails;
4073
+ private backend;
4074
+ register<TDefinition extends AnyAccountSettingsDefinition>(input: RegisterAccountSettingsInput<TDefinition>): AccountSettingsRegistration<TDefinition>;
4075
+ unregister(registration: AccountSettingsRegistration): void;
4076
+ bindBackend(backend: AccountSettingsBackend): () => void;
4077
+ hasRegistrations(): boolean;
4078
+ hasBackend(): boolean;
4079
+ listRegistrations(): readonly AccountSettingsRegistration[];
4080
+ listForms(actorId: string): Promise<readonly AccountSettingsForm[]>;
4081
+ save(registrationIdValue: string, actorId: string, input: Readonly<Record<string, unknown>>): Promise<AccountSettingsForm>;
4082
+ delete(registrationIdValue: string, actorId: string): Promise<boolean>;
4083
+ deleteActor(actorId: string): Promise<number>;
4084
+ /** Notify account-bound supervisors after auth-owned cascade deletion. */
4085
+ accountDeleted(actorId: string): void;
4086
+ private refreshActor;
4087
+ getForActor<TDefinition extends AnyAccountSettingsDefinition>(registration: AccountSettingsRegistration<TDefinition>, actorId: string): Promise<AccountSettingsValue<TDefinition> | null>;
4088
+ listConfigured<TDefinition extends AnyAccountSettingsDefinition>(registration: AccountSettingsRegistration<TDefinition>): Promise<readonly ConfiguredAccountSettings<TDefinition>[]>;
4089
+ subscribe(registration: AccountSettingsRegistration, listener: AccountSettingsChangeListener): () => void;
4090
+ private formFor;
4091
+ private requireRegistration;
4092
+ private requireAttached;
4093
+ private requireBackend;
4094
+ private notify;
4095
+ private serializeMutation;
4096
+ }
4097
+ //#endregion
4098
+ //#region ../../shell/plugins/src/service/attachment-registry.d.ts
4099
+ interface AttachmentResolveRequest {
4100
+ sourceEntityType: string;
4101
+ sourceEntityId: string;
4102
+ attachmentType: string;
4103
+ }
4104
+ interface AttachmentProviderMetadata {
4105
+ outputEntityType: "image" | "document";
4106
+ targetField?: "coverImageId" | "ogImageId";
4107
+ }
4108
+ interface AttachmentProvider {
4109
+ metadata?: AttachmentProviderMetadata;
4110
+ resolve(request: AttachmentResolveRequest): Promise<PublishMediaData | undefined> | PublishMediaData | undefined;
4111
+ }
4112
+ /**
4113
+ * Attachment namespace — source-derived publish artifacts.
4114
+ * Source plugins register providers; publishers resolve by semantic attachment type.
4115
+ */
4116
+ interface IAttachmentsNamespace {
4117
+ /** Register an attachment provider for a source entity type and semantic attachment type. */
4118
+ register: (sourceEntityType: string, attachmentType: string, provider: AttachmentProvider) => () => void;
4119
+ /** Resolve a source-derived attachment if a provider is available. */
4120
+ resolve: (request: AttachmentResolveRequest) => Promise<PublishMediaData | undefined>;
4121
+ /** Check whether a provider exists for the requested source/attachment type. */
4122
+ hasProvider: (sourceEntityType: string, attachmentType: string) => boolean;
4123
+ /** Get registered provider capability metadata, if declared. */
4124
+ getProviderMetadata: (sourceEntityType: string, attachmentType: string) => AttachmentProviderMetadata | undefined;
4125
+ }
4126
+ //#endregion
4127
+ //#region ../../shell/runtime-state/src/types.d.ts
4128
+ type RuntimeStateValueSchema<T> = ZodType<T, unknown>;
4129
+ interface RuntimeStateScopeOptions<T> {
4130
+ /** Stable consumer namespace, e.g. "chat.discord.subscriptions". */
4131
+ namespace: string;
4132
+ /** Schema used to validate values crossing the persistence boundary. */
4133
+ schema: RuntimeStateValueSchema<T>;
4134
+ }
4135
+ interface RuntimeStateRecordValue<T> {
4136
+ key: string;
4137
+ value: T;
4138
+ createdAt: Date;
4139
+ updatedAt: Date;
4140
+ }
4141
+ interface RuntimeStateListOptions {
4142
+ keyPrefix?: string | undefined;
4143
+ /** Exclusive key cursor, ordered using SQLite's binary key order. */
4144
+ afterKey?: string | undefined;
4145
+ /** Optional bounded page size (1–1000); applied before value parsing. */
4146
+ limit?: number | undefined;
4147
+ }
4148
+ interface IRuntimeStateStore<T> {
4149
+ get(key: string): Promise<T | null>;
4150
+ has(key: string): Promise<boolean>;
4151
+ set(key: string, value: T): Promise<void>;
4152
+ setIfNotExists(key: string, value: T): Promise<boolean>;
4153
+ /** Atomically replace an existing value only if its schema-serialized value matches.
4154
+ * Use a revision field when the consumer must distinguish an ABA change.
4155
+ * Independent processes must use the same backing database to coordinate.
4156
+ */
4157
+ compareAndSet(key: string, expected: T, value: T): Promise<boolean>;
4158
+ delete(key: string): Promise<boolean>;
4159
+ list(options?: RuntimeStateListOptions): Promise<RuntimeStateRecordValue<T>[]>;
4160
+ clear(options?: {
4161
+ keyPrefix?: string | undefined;
4162
+ }): Promise<number>;
4163
+ }
4164
+ interface IRuntimeStateNamespace {
4165
+ scoped<T>(options: RuntimeStateScopeOptions<T>): IRuntimeStateStore<T>;
4166
+ }
4167
+ //#endregion
4168
+ //#region ../../shell/recurring-checks/src/types.d.ts
4169
+ type RecurringCheckCadence = "daily" | "weekly";
4170
+ /** Alert payloads are operational state and must not contain secrets. */
4171
+ declare const recurringAlertSchema: z.ZodObject<{
4172
+ dedupeKey: z.ZodString;
4173
+ title: z.ZodString;
4174
+ body: z.ZodString;
4175
+ html: z.ZodOptional<z.ZodString>;
4176
+ sensitivity: z.ZodOptional<z.ZodEnum<{
4177
+ normal: "normal";
4178
+ secret: "secret";
4179
+ }>>;
4180
+ includeInInbox: z.ZodOptional<z.ZodBoolean>;
4181
+ }, z.core.$strict>;
4182
+ declare const recurringCheckResultSchema: z.ZodObject<{
4183
+ alerts: z.ZodOptional<z.ZodArray<typeof recurringAlertSchema>>;
4184
+ }, z.core.$strict>;
4185
+ type RecurringCheckResult = z.output<typeof recurringCheckResultSchema>;
4186
+ interface RecurringCheckRunContext {
4187
+ /** Aborted when the caller cancels or the recurring-check daemon stops. */
4188
+ signal: AbortSignal;
4189
+ }
4190
+ interface RecurringCheckDefinition {
4191
+ id: string;
4192
+ cadence: RecurringCheckCadence;
4193
+ /** Deliver returned alerts and retry pending alerts. False suppresses notification delivery. Defaults to true. */
4194
+ deliverAlerts?: boolean | undefined;
4195
+ /** Project returned alerts into the shared Inbox. Defaults to true. */
4196
+ includeInInbox?: boolean | undefined;
4197
+ run(context: RecurringCheckRunContext): Promise<RecurringCheckResult>;
4198
+ }
4199
+ interface IRecurringChecksNamespace {
4200
+ /** Register a plugin-owned recurring check. Returns an unregister callback. */
4201
+ register(check: RecurringCheckDefinition): () => void;
4202
+ }
4203
+ //#endregion
4204
+ //#region ../../shell/plugins/src/service/upload-registry.d.ts
4205
+ interface RuntimeUploadRef {
4206
+ kind: string;
4207
+ id: string;
4208
+ }
4209
+ interface RuntimeUploadRecord {
4210
+ id: string;
4211
+ ref: RuntimeUploadRef;
4212
+ filename: string;
4213
+ mediaType: string;
4214
+ sizeBytes: number;
4215
+ createdAt: string;
4216
+ metadata?: Record<string, unknown> | undefined;
4217
+ }
4218
+ interface RuntimeUploadResponseBody extends RuntimeUploadRecord {
4219
+ url: string;
4220
+ downloadUrl: string;
4221
+ }
4222
+ interface RuntimeUploadScopeOptions {
4223
+ /** Filesystem namespace below the runtime data directory, e.g. "upload". */
4224
+ namespace: string;
4225
+ /** Ref discriminator exposed to clients, e.g. "upload". */
4226
+ refKind: string;
4227
+ /** HTTP route used to resolve stored uploads, e.g. "/api/chat/uploads". */
4228
+ routePath: string;
4229
+ retentionMs?: number | undefined;
4230
+ maxCount?: number | undefined;
4231
+ createId?: (() => string) | undefined;
4232
+ now?: (() => Date) | undefined;
4233
+ }
4234
+ interface SaveRuntimeUploadInput {
4235
+ filename: string;
4236
+ mediaType: string;
4237
+ content: Buffer;
4238
+ metadata?: Record<string, unknown> | undefined;
4239
+ }
4240
+ interface ResolvedRuntimeUpload {
4241
+ record: RuntimeUploadRecord;
4242
+ content: Buffer;
4243
+ }
4244
+ /**
4245
+ * The store surface consumers get, rather than the class that implements it.
4246
+ *
4247
+ * Declaring the class here made every consumer depend on its private fields
4248
+ * too, so nothing could stand in for a scoped store without asserting it was
4249
+ * one. The class satisfies this by construction.
4250
+ */
4251
+ type ScopedRuntimeUploadStore = Pick<RuntimeUploadStore, "save" | "read" | "readRecord" | "toResponseBody" | "prune" | "getUploadDir" | "remove">;
4252
+ interface IRuntimeUploadsNamespace {
4253
+ /** Create a scoped runtime upload store for an interface/plugin namespace. */
4254
+ scoped(options: RuntimeUploadScopeOptions): ScopedRuntimeUploadStore;
4255
+ }
4256
+ interface RuntimeUploadStoreOptions extends RuntimeUploadScopeOptions {
4257
+ dataDir: string;
4258
+ logger?: Logger | undefined;
4259
+ }
4260
+ declare class RuntimeUploadStore {
4261
+ private readonly options;
4262
+ private readonly retentionMs;
4263
+ private readonly maxCount;
4264
+ private readonly createUploadId;
4265
+ private readonly getNow;
4266
+ private readonly logger;
4267
+ constructor(options: RuntimeUploadStoreOptions);
4268
+ save(input: SaveRuntimeUploadInput): Promise<RuntimeUploadRecord>;
4269
+ remove(uploadId: string): Promise<void>;
4270
+ read(uploadId: string): Promise<ResolvedRuntimeUpload>;
4271
+ readRecord(uploadId: string): Promise<RuntimeUploadRecord>;
4272
+ toResponseBody(record: RuntimeUploadRecord): RuntimeUploadResponseBody;
4273
+ /**
4274
+ * Drop uploads past the retention window or the count cap.
4275
+ *
4276
+ * Returns quietly only when the uploads directory does not exist yet — it is
4277
+ * created on first save. Every other failure raises: an unreadable directory
4278
+ * or a deletion that did not happen means uploads accumulate unbounded, and
4279
+ * a silent catch here made that indistinguishable from a successful prune.
4280
+ */
4281
+ prune(): Promise<void>;
4282
+ getUploadDir(uploadId: string): string;
4283
+ private getUploadsRoot;
4284
+ private getUploadUrl;
4285
+ private assertValidUploadId;
4286
+ }
4287
+ //#endregion
4288
+ //#region ../../shell/plugins/src/contracts/runtime-app-info.d.ts
4289
+ declare const userPermissionLevelSchema: z.ZodEnum<{
4290
+ admin: "admin";
4291
+ trusted: "trusted";
4292
+ public: "public";
4293
+ }>;
4294
+ declare const endpointInfoSchema: z.ZodObject<{
4295
+ label: z.ZodString;
4296
+ url: z.ZodString;
4297
+ pluginId: z.ZodString;
4298
+ priority: z.ZodDefault<z.ZodNumber>;
4299
+ visibility: z.ZodDefault<typeof userPermissionLevelSchema>;
4300
+ requiresActiveSession: z.ZodOptional<z.ZodBoolean>;
4301
+ }>;
4302
+ type EndpointInfo = z.output<typeof endpointInfoSchema>;
4303
+ type EndpointInfoInput = z.input<typeof endpointInfoSchema>;
4304
+ declare const interactionKindSchema: z.ZodEnum<{
4305
+ human: "human";
4306
+ agent: "agent";
4307
+ admin: "admin";
4308
+ protocol: "protocol";
4309
+ }>;
4310
+ declare const interactionStatusSchema: z.ZodEnum<{
4311
+ available: "available";
4312
+ "coming-soon": "coming-soon";
4313
+ disabled: "disabled";
4314
+ }>;
4315
+ declare const interactionInfoSchema: z.ZodObject<{
4316
+ id: z.ZodString;
4317
+ label: z.ZodString;
4318
+ description: z.ZodOptional<z.ZodString>;
4319
+ href: z.ZodString;
4320
+ kind: typeof interactionKindSchema;
4321
+ pluginId: z.ZodString;
4322
+ priority: z.ZodDefault<z.ZodNumber>;
4323
+ visibility: z.ZodDefault<typeof userPermissionLevelSchema>;
4324
+ requiresActiveSession: z.ZodOptional<z.ZodBoolean>;
4325
+ status: z.ZodDefault<typeof interactionStatusSchema>;
4326
+ }>;
4327
+ type InteractionInfo = z.output<typeof interactionInfoSchema>;
4328
+ type InteractionInfoInput = z.input<typeof interactionInfoSchema>;
4329
+ declare const entityCountSchema: z.ZodObject<{
4330
+ entityType: z.ZodString;
4331
+ count: z.ZodNumber;
4332
+ }>;
4333
+ declare const backgroundWorkInfoSchema: z.ZodObject<{
4334
+ status: z.ZodEnum<{
4335
+ operational: "operational";
4336
+ degraded: "degraded";
4337
+ }>;
4338
+ reasons: z.ZodArray<z.ZodString>;
4339
+ worker: z.ZodObject<{
4340
+ state: z.ZodEnum<{
4341
+ active: "active";
4342
+ missing: "missing";
4343
+ stale: "stale";
4344
+ }>;
4345
+ activeSessions: z.ZodNumber;
4346
+ staleSessions: z.ZodNumber;
4347
+ latestHeartbeatAgeMs: z.ZodNullable<z.ZodNumber>;
4348
+ }>;
4349
+ queue: z.ZodObject<{
4350
+ duePending: z.ZodNumber;
4351
+ processing: z.ZodNumber;
4352
+ oldestDuePendingAgeMs: z.ZodNullable<z.ZodNumber>;
4353
+ latestClaimAgeMs: z.ZodNullable<z.ZodNumber>;
4354
+ stalled: z.ZodBoolean;
4355
+ }>;
4356
+ }>;
4357
+ declare const appInfoSchema: z.ZodObject<{
4358
+ model: z.ZodString;
4359
+ version: z.ZodString;
4360
+ uptime: z.ZodNumber;
4361
+ entities: z.ZodNumber;
4362
+ entityCounts: z.ZodArray<typeof entityCountSchema>;
4363
+ embeddings: z.ZodNumber;
4364
+ backgroundWork: typeof backgroundWorkInfoSchema;
4365
+ ai: z.ZodObject<{
4366
+ model: z.ZodString;
4367
+ embeddingModel: z.ZodString;
4368
+ }>;
4369
+ daemons: z.ZodArray<typeof DaemonStatusInfoSchema>;
4370
+ endpoints: z.ZodArray<typeof endpointInfoSchema>;
4371
+ interactions: z.ZodArray<typeof interactionInfoSchema>;
4372
+ }>;
4373
+ type RuntimeAppInfo = z.output<typeof appInfoSchema>;
4374
+ //#endregion
4375
+ //#region ../../shell/plugins/src/contracts/generation.d.ts
4376
+ interface GenerationStyleGuide {
4377
+ voice?: string;
4378
+ visual?: string;
4379
+ }
4380
+ interface ContentGenerationConfig {
4381
+ prompt: string;
4382
+ templateName: string;
4383
+ conversationHistory?: string;
4384
+ data?: Record<string, unknown>;
4385
+ representedIdentity?: "brain" | "anchor" | "none";
4386
+ styleGuide?: GenerationStyleGuide;
4387
+ interfacePermissionGrant?: UserPermissionLevel;
4388
+ }
4389
+ //#endregion
4390
+ //#region ../../shell/plugins/src/types/api-routes.d.ts
4391
+ declare const apiRouteDefinitionSchema: z.ZodObject<{
4392
+ path: z.ZodString;
4393
+ method: z.ZodDefault<z.ZodEnum<{
4394
+ GET: "GET";
4395
+ POST: "POST";
4396
+ PUT: "PUT";
4397
+ DELETE: "DELETE";
4398
+ }>>;
4399
+ tool: z.ZodString;
4400
+ public: z.ZodDefault<z.ZodBoolean>;
4401
+ successRedirect: z.ZodOptional<z.ZodString>;
4402
+ errorRedirect: z.ZodOptional<z.ZodString>;
4403
+ }>;
4404
+ type ApiRouteDefinition = z.output<typeof apiRouteDefinitionSchema>;
4405
+ /**
4406
+ * A registered API route with full path and plugin context
4407
+ * Returned by Shell.getPluginApiRoutes()
4408
+ */
4409
+ interface RegisteredApiRoute {
4410
+ /** The plugin that registered this route */
4411
+ pluginId: string;
4412
+ /** Full path including /api/{pluginId} prefix */
4413
+ fullPath: string;
4414
+ /** The original route definition */
4415
+ definition: ApiRouteDefinition;
4416
+ }
4417
+ //#endregion
4418
+ //#region ../../shell/plugins/src/types/web-routes.d.ts
4419
+ declare const WebRouteMethods: readonly ["GET", "POST", "PUT", "DELETE", "OPTIONS"];
4420
+ type WebRouteMethod = (typeof WebRouteMethods)[number];
4421
+ /** Host-supplied socket metadata. Never derive this from HTTP/forwarding headers. */
4422
+ interface WebRouteTransportContext {
4423
+ readonly remoteAddress?: string;
4424
+ }
4425
+ type WebRouteHandler = (request: Request, transport?: WebRouteTransportContext) => Response | Promise<Response>;
4426
+ type WebRouteMatch = "exact" | "prefix";
4427
+ interface WebRouteDefinition {
4428
+ /** Absolute mounted path (e.g. "/studio" or "/studio-config") */
4429
+ path: string;
4430
+ /** Match only `path` (default) or descendants on a segment boundary. */
4431
+ match?: WebRouteMatch;
4432
+ /** HTTP method */
4433
+ method?: WebRouteMethod;
4434
+ /** Allow unauthenticated access */
4435
+ public?: boolean;
4436
+ /** Also serve on the preview host. Reachability only; admission checks still apply. */
4437
+ preview?: boolean;
4438
+ /** Request handler */
4439
+ handler: WebRouteHandler;
4440
+ }
4441
+ interface RegisteredWebRoute {
4442
+ /** The plugin that registered this route */
4443
+ pluginId: string;
4444
+ /** The mounted path */
4445
+ fullPath: string;
4446
+ /** The original route definition */
4447
+ definition: WebRouteDefinition;
4448
+ }
4449
+ //#endregion
4450
+ //#region ../../shell/plugins/src/contracts/handlers.d.ts
4451
+ type EvalHandler<TInput = unknown, TOutput = unknown> = (input: TInput) => Promise<TOutput>;
4452
+ /**
4453
+ * Computes a domain summary over entities.
4454
+ *
4455
+ * Takes the read-only projection, not the full service: an insight reports on
4456
+ * what exists and must not write. `@brains/plugins` publishes this signature
4457
+ * to plugin authors, so widening it here would promise them less than they
4458
+ * are given.
4459
+ */
4460
+ type InsightHandler = (entityService: ReadOnlyEntityService, visibilityScope: ContentVisibility) => Promise<Record<string, unknown>>;
4461
+ //#endregion
4462
+ //#region ../../shell/plugins/src/interfaces.d.ts
4463
+ /**
4464
+ * Query context for shell queries
4465
+ */
4466
+ interface QueryContext {
4467
+ userId?: string;
4468
+ conversationHistory?: string;
4469
+ messageId?: string;
4470
+ threadId?: string;
4471
+ timestamp?: string;
4472
+ [key: string]: unknown;
4473
+ }
4474
+ /**
4475
+ * Bounded model-as-judge request exposed to plugins.
4476
+ * Kept structural here so public plugin declarations do not import ai-service internals.
4477
+ */
4478
+ interface JudgeInput<T> {
4479
+ instruction: string;
4480
+ material: string;
4481
+ schema: AIGenerationSchema<T>;
4482
+ }
4483
+ /**
4484
+ * Shell interface that plugins use to access core services
4485
+ * This avoids circular dependencies between core and plugin-context
4486
+ */
4487
+ /**
4488
+ * Registry for insight types.
4489
+ * Core registers generic insights; plugins register domain-specific ones.
4490
+ */
4491
+ interface IInsightsRegistry {
4492
+ register(type: string, handler: InsightHandler): void;
4493
+ unregister(type: string): void;
4494
+ getTypes(): string[];
4495
+ get(type: string, entityService: ReadOnlyEntityService, visibilityScope: ContentVisibility): Promise<Record<string, unknown>>;
4496
+ }
4497
+ interface IShell {
4498
+ getMessageBus(): IMessageBus;
4499
+ getContentService(): ContentService;
4500
+ getLogger(): Logger;
4501
+ getEntityService(): EntityService;
4502
+ getEntityRegistry(): EntityRegistry;
4503
+ getJobQueueService(): IJobQueueService;
4504
+ getRenderService(): ViewTemplateRegistry;
4505
+ getConversationService(): IConversationService;
4506
+ getMCPService(): IMCPTransport;
4507
+ listToolsForPermissionLevel(level: UserPermissionLevel): ToolInfo[];
4508
+ getPermissionService(): PermissionService;
4509
+ getDataSourceRegistry(): DataSourceRegistry;
4510
+ getAgentService(): IAgentService;
4511
+ getAttachmentRegistry(): IAttachmentsNamespace;
4512
+ getRuntimeUploadRegistry(): IRuntimeUploadsNamespace;
4513
+ getRuntimeState(): IRuntimeStateNamespace;
4514
+ getRecurringChecks(pluginId: string): IRecurringChecksNamespace;
4515
+ getIdentity(): BrainCharacter;
4516
+ getProfile(): AnchorProfile;
4517
+ getProfileKindRegistry(): IProfileKindRegistry;
4518
+ getChannelRegistry(): IChannelRegistry;
4519
+ getInboxRegistry(): IInboxRegistry;
4520
+ getInboxFollowUpRegistry(): IInboxFollowUpRegistry;
4521
+ getOperationalHealthRegistry(): IOperationalHealthRegistry;
4522
+ getAccountSettingsRegistry(): AccountSettingsRegistry;
4523
+ getDomain(): string | undefined;
4524
+ getLocalSiteUrl(): string | undefined;
4525
+ shouldPreferLocalUrls(): boolean;
4526
+ getThemeCSS(): string;
4527
+ getSpaces(): string[];
4528
+ getDataDir(): string;
4529
+ getGitBrokerSocket(): string | undefined;
4530
+ getGitBrokerCheckout(): string | undefined;
4531
+ getAppInfo(): Promise<RuntimeAppInfo>;
4532
+ getRuntimeReadiness(): Promise<RuntimeReadiness>;
4533
+ generateContent(config: ContentGenerationConfig): Promise<unknown>;
4534
+ generateObject<T>(prompt: string, schema: AIGenerationSchema<T>, signal?: AbortSignal): Promise<{
4535
+ object: T;
4536
+ }>;
4537
+ judge<T>(input: JudgeInput<T>): Promise<{
4538
+ verdict: T;
4539
+ usage: {
4540
+ promptTokens: number;
4541
+ completionTokens: number;
4542
+ totalTokens: number;
4543
+ };
4544
+ }>;
4545
+ query(prompt: string, context?: QueryContext): Promise<DefaultQueryResponse>;
4546
+ generateImage(prompt: string, options?: ImageGenerationOptions): Promise<ImageGenerationResult>;
4547
+ canGenerateImages(): boolean;
4548
+ registerTemplates(templates: Record<string, Template>, pluginId?: string): void;
4549
+ getTemplate(name: string): Template | undefined;
4550
+ registerTools(pluginId: string, tools: Tool[]): void;
4551
+ registerResources(pluginId: string, resources: Resource[]): void;
4552
+ registerResourceTemplate<K extends string = string>(pluginId: string, template: ResourceTemplate<K>): void;
4553
+ registerPrompt(pluginId: string, prompt: Prompt): void;
4554
+ registerInstructions(pluginId: string, instructions: string): void;
4555
+ getPluginPackageName(pluginId: string): string | undefined;
4556
+ hasPlugin(id: string): boolean;
4557
+ readonly jobs: IJobsNamespace;
4558
+ registerDaemon(name: string, daemon: Daemon, pluginId: string): void;
4559
+ registerEndpoint(endpoint: EndpointInfoInput): void;
4560
+ listEndpoints(): EndpointInfo[];
4561
+ registerInteraction(interaction: InteractionInfoInput): void;
4562
+ listInteractions(): InteractionInfo[];
4563
+ registerEvalHandler(pluginId: string, handlerId: string, handler: EvalHandler): void;
4564
+ getInsightsRegistry(): IInsightsRegistry;
4565
+ getPluginApiRoutes(): RegisteredApiRoute[];
4566
+ getPluginWebRoutes(): RegisteredWebRoute[];
4567
+ }
4568
+ //#endregion
4569
+ //#region ../../shared/ui-library/src/highlighted-text.d.ts
4570
+ /**
4571
+ * Render a content string with two lightweight markup conventions:
4572
+ *
4573
+ * - `\n` in the string produces a `<br />` (for multi-line headlines)
4574
+ * - Any `*...*` run is wrapped in a `<span>` carrying `highlightClass`
4575
+ *
4576
+ * Authors write the phrase as one natural string in markdown content;
4577
+ * the renderer does the structural split. Highlight styling is passed
4578
+ * per-brand (rizom.ai uses accent+midline, professional uses italic+accent)
4579
+ * so each consumer owns its own emphasis treatment while the parsing/
4580
+ * structure is shared.
4581
+ */
4582
+ declare function renderHighlightedText(text: string, highlightClass: string): JSX.Element;
4583
+ //#endregion
4584
+ //#region src/rizom/ui/site-info-links.d.ts
4585
+ declare function socialLinksToRizomLinks(siteInfo: Pick<SiteLayoutInfo, "socialLinks">, allowedPlatforms?: string[]): RizomLink[];
4586
+ //#endregion
4587
+ //#region src/rizom/ui/Wordmark.d.ts
4588
+ interface WordmarkProps {
4589
+ /** Brand name before the dot. Defaults to `"rizom"`. */
4590
+ name?: string;
4591
+ /** Suffix after the dot. Any string (e.g. `"ai"`, `"io"`, `"foundation"`). */
4592
+ brandSuffix: RizomBrandSuffix | string;
4593
+ className?: string;
4594
+ dotClassName?: string;
4595
+ suffixClassName?: string;
4596
+ }
4597
+ declare const Wordmark: ({ name, brandSuffix, className, dotClassName, suffixClassName }: WordmarkProps) => JSX.Element;
4598
+ //#endregion
4599
+ //#region src/rizom/ui/Ecosystem.d.ts
4600
+ interface EcosystemCard {
4601
+ suffix: RizomBrandSuffix;
4602
+ title: string;
4603
+ body: string;
4604
+ linkLabel: string;
4605
+ linkHref: string;
4606
+ }
4607
+ interface EcosystemContent {
4608
+ eyebrow: string;
4609
+ headline: string;
4610
+ cards: EcosystemCard[];
4611
+ }
4612
+ declare const Ecosystem: ({ eyebrow, headline, cards }: EcosystemContent) => JSX.Element;
4613
+ //#endregion
4614
+ //#region src/rizom/runtime/default-layout.d.ts
4615
+ declare const DefaultRizomLayout: ({ sections }: RizomLayoutProps) => JSX.Element;
4616
+ //#endregion
4617
+ //#region src/rizom/runtime/base-site.d.ts
4618
+ declare const rizomBaseSite: SiteDefinition;
4619
+ //#endregion
4620
+ //#region src/rizom/create-site.d.ts
4621
+ interface RizomRuntimeHooks {
4622
+ contentNamespace: string;
4623
+ templates?: Record<string, unknown>;
4624
+ dataSources?: unknown[];
4625
+ /** Datasources that need the plugin's runtime, built when it registers. */
4626
+ dataSourceFactories?: Array<(shell: IShell) => unknown>;
4627
+ }
4628
+ interface CreateRizomSiteOptions {
4629
+ packageName: string;
4630
+ layout: unknown;
4631
+ routes: RouteDefinitionInput[];
4632
+ content?: SiteContent;
4633
+ /**
4634
+ * Schema-first section groups (authored via `@rizom/site`'
4635
+ * `defineSection`/`sectionGroup`). Registered as content templates at brain
4636
+ * boot exactly like `content`, so the Studio + directory-sync + resolver treat
4637
+ * them identically — but the section shape is derived from one zod schema.
4638
+ */
4639
+ sections?: SiteSectionGroup | SiteSectionGroup[];
4640
+ themeOverride?: string;
4641
+ /**
4642
+ * Presentation config for entity-backed list/detail routes (labels, plural
4643
+ * names, navigation). Merged onto the base site's empty map. Sites that
4644
+ * surface plugin lists — e.g. `post`→"Essay", `deck`→"Talk" — set it here.
4645
+ */
4646
+ entityDisplay?: Record<string, EntityDisplayEntry>;
4647
+ /** Advanced runtime hooks for in-repo sites that need custom template/data-source wiring. */
4648
+ runtime?: RizomRuntimeHooks;
4649
+ }
4650
+ declare function createRizomSite(options: CreateRizomSiteOptions): SitePackage;
4651
+ //#endregion
4652
+ //#region src/site.d.ts
4653
+ declare const rizomAiSite: SitePackage;
4654
+ //#endregion
4655
+ //#region src/routes.d.ts
4656
+ /**
4657
+ * The consolidated Rizom site routes. The home page composes the living-memory
4658
+ * content namespace; the layout owns navigation (the one bar), so routes stay out of the entity nav.
4659
+ */
4660
+ declare const aiRoutes: RouteDefinitionInput[];
454
4661
  //#endregion
455
4662
  //#region src/living-memory.d.ts
456
4663
  declare const livingMemorySections: SiteSectionGroup;
@@ -461,4 +4668,4 @@ declare const workSections: SiteSectionGroup;
461
4668
  //#region src/foundation.d.ts
462
4669
  declare const foundationSections: SiteSectionGroup;
463
4670
  //#endregion
464
- export { Badge, type BadgeProps, Button, type ButtonProps, type ButtonSize, type ButtonVariant, type CreateRizomSiteOptions, DefaultRizomLayout, Divider, type DividerProps, Ecosystem, type EcosystemCard, type EcosystemContent, type EntityDisplayEntry, Footer, GUTTER, Header, type RizomBrandSuffix, type RizomFooterTagline, RizomFrame, type RizomFrameProps, type RizomLayoutProps, type RizomLink, type RizomSideNavItem, type RouteDefinitionInput, Section, type SectionDefinitionInput, type SectionProps, SideNav, type SiteContentArrayFieldDefinition, type SiteContentDefinition, type SiteContentEnumFieldDefinition, type SiteContentFieldDefinition, type SiteContentNumberFieldDefinition, type SiteContentObjectFieldDefinition, type SiteContentSectionDefinition, type SiteContentStringFieldDefinition, type SiteDefinition, type SiteDefinitionOverrides, type SiteLayoutInfo, type SitePackage, Wordmark, type WordmarkProps, aiRoutes, createRizomSite, rizomAiSite as default, rizomAiSite, foundationSections, homeSections, livingMemorySections, renderHighlightedText, rizomBaseSite, socialLinksToRizomLinks, workSections };
4671
+ export { Badge, type BadgeProps, Button, type ButtonProps, type ButtonSize, type ButtonVariant, type CreateRizomSiteOptions, DefaultRizomLayout, Divider, type DividerProps, Ecosystem, type EcosystemCard, type EcosystemContent, type EntityDisplayEntry, Footer, GUTTER, Header, type RizomBrandSuffix, type RizomFooterTagline, RizomFrame, type RizomFrameProps, type RizomLayoutProps, type RizomLink, type RizomSideNavItem, type RouteDefinitionInput, Section, type SectionDefinitionInput, type SectionProps, SideNav, type SiteContentArrayFieldDefinition, type SiteContentDefinition, type SiteContentEnumFieldDefinition, type SiteContentFieldDefinition, type SiteContentNumberFieldDefinition, type SiteContentObjectFieldDefinition, type SiteContentSectionDefinition, type SiteContentStringFieldDefinition, type SiteDefinition, type SiteDefinitionOverrides, type SiteLayoutInfo, type SitePackage, Wordmark, type WordmarkProps, aiRoutes, createRizomSite, rizomAiSite as default, rizomAiSite, foundationSections, livingMemorySections, renderHighlightedText, rizomBaseSite, socialLinksToRizomLinks, workSections };