@wordbricks/persona 0.1.0

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.
@@ -0,0 +1,622 @@
1
+ import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
2
+ import { PersonaEmbeddingTargetKind, PersonaProfile, PersonaAliasSurface, PersonaAlias, PersonaWorkspacePayload, PersonaMemoryState, PersonaBeliefType, PersonaPrivacyLevel, PersonaBeliefStance, NewPersonaEpisodeMemory, PersonaFactType, PersonaFactObjectType, PersonaToneVector, PersonaSourceDocument, PersonaEmotionAnnotation, PersonaSemanticBelief } from './schema/index.js';
3
+ import { x as PersonaTurnPlan, p as PersonaMemoryType, u as PersonaQueryType, i as PersonaLogger, f as PersonaEmbedder, c as PersonaAffectVector, w as PersonaTurnAffectEstimate, t as PersonaMoodUpdateTrace, j as PersonaMemoryCandidate, e as PersonaContextGatewayOutput, q as PersonaMoodEmotionLabel, k as PersonaMemorySelectionResult, D as DisclosurePolicy, h as PersonaJsonLlm, v as PersonaRuntimeContext, l as PersonaMemoryTriageDecision } from './types-BHEW4MGH.js';
4
+
5
+ type PersonaDatabase = PostgresJsDatabase<Record<string, unknown>>;
6
+
7
+ type HindsightPersonaMemoryEnv = {
8
+ HINDSIGHT_ENABLED?: boolean | string;
9
+ HINDSIGHT_API_KEY?: string;
10
+ HINDSIGHT_BASE_URL?: string;
11
+ HINDSIGHT_TIMEOUT_MS?: number | string;
12
+ HINDSIGHT_RECALL_ENABLED?: boolean | string;
13
+ HINDSIGHT_RECALL_TOP_K?: number | string;
14
+ HINDSIGHT_RETAIN_ENABLED?: boolean | string;
15
+ HINDSIGHT_RETAIN_ASYNC_ENABLED?: boolean | string;
16
+ HINDSIGHT_REFLECT_ENABLED?: boolean | string;
17
+ HINDSIGHT_REFLECT_TIMEOUT_MS?: number | string;
18
+ HINDSIGHT_FAIL_OPEN?: boolean | string;
19
+ };
20
+ type HindsightPersonaMemoryConfig = {
21
+ apiKey: string | null;
22
+ baseUrl: string | null;
23
+ enabled: boolean;
24
+ failOpen: boolean;
25
+ recallEnabled: boolean;
26
+ recallTopK: number;
27
+ reflectEnabled: boolean;
28
+ reflectTimeoutMs: number;
29
+ retainAsyncEnabled: boolean;
30
+ retainEnabled: boolean;
31
+ timeoutMs: number;
32
+ };
33
+ type HindsightRecallInput = {
34
+ contextKeys: PersonaTurnPlan["context"]["contextKeys"];
35
+ desiredMemoryTypes: PersonaMemoryType[];
36
+ maxResults: number;
37
+ message: string;
38
+ organizationId: string;
39
+ personaId: string;
40
+ personaKey: string;
41
+ retrievalQueries: PersonaTurnPlan["context"]["retrievalQueries"];
42
+ turnQueryType: PersonaQueryType;
43
+ userId: string;
44
+ };
45
+ type HindsightRawRecallMemory = {
46
+ bankId: string;
47
+ chunkId: string | null;
48
+ context: string | null;
49
+ documentId: string | null;
50
+ entities: string[];
51
+ id: string;
52
+ mentionedAt: string | null;
53
+ metadata: Record<string, string>;
54
+ occurredEnd: string | null;
55
+ occurredStart: string | null;
56
+ sourceFactIds: string[];
57
+ tags: string[];
58
+ text: string;
59
+ type: string | null;
60
+ };
61
+ type HindsightRecallResult = {
62
+ attempted: boolean;
63
+ enabled: boolean;
64
+ latencyMs?: number;
65
+ memories: HindsightRawRecallMemory[];
66
+ provider: "hindsight";
67
+ skippedReason?: string;
68
+ };
69
+ type HindsightRetainInput = {
70
+ chatMessageId?: string | null;
71
+ chatSessionId?: string | null;
72
+ content: string;
73
+ context?: string | null;
74
+ documentId?: string | null;
75
+ organizationId: string;
76
+ personaId: string;
77
+ personaKey: string;
78
+ privacyLevel: "public" | "internal" | "private" | "sensitive";
79
+ scope: "persona_global" | "persona_user";
80
+ tags?: string[];
81
+ themes?: string[];
82
+ timestamp?: Date | string | null;
83
+ userId?: string | null;
84
+ };
85
+ type HindsightRetainResult = {
86
+ attempted: boolean;
87
+ bankId?: string;
88
+ enabled: boolean;
89
+ error?: string;
90
+ latencyMs?: number;
91
+ operationId?: string | null;
92
+ provider: "hindsight";
93
+ skippedReason?: string;
94
+ succeeded: boolean;
95
+ };
96
+ type HindsightReflectInput = {
97
+ context?: string | null;
98
+ maxTokens?: number;
99
+ organizationId: string;
100
+ personaId: string;
101
+ personaKey: string;
102
+ query: string;
103
+ scope: "persona_global" | "persona_user";
104
+ tags?: string[];
105
+ userId?: string | null;
106
+ };
107
+ type HindsightReflectResult = {
108
+ attempted: boolean;
109
+ enabled: boolean;
110
+ error?: string;
111
+ latencyMs?: number;
112
+ provider: "hindsight";
113
+ skippedReason?: string;
114
+ text: string | null;
115
+ };
116
+ type HindsightPersonaMemoryClient = {
117
+ recall(input: HindsightRecallInput): Promise<HindsightRecallResult>;
118
+ reflect(input: HindsightReflectInput): Promise<HindsightReflectResult>;
119
+ retain(input: HindsightRetainInput): Promise<HindsightRetainResult>;
120
+ };
121
+ type FetchLike = typeof fetch;
122
+ declare function createHindsightPersonaMemoryConfig(env?: HindsightPersonaMemoryEnv | null): HindsightPersonaMemoryConfig;
123
+ declare function createNoopHindsightPersonaMemoryClient(reason?: string): HindsightPersonaMemoryClient;
124
+ declare function hindsightPersonaBankId(input: {
125
+ organizationId: string;
126
+ personaId: string;
127
+ scope: "persona_global" | "persona_user";
128
+ userId?: string | null;
129
+ }): string;
130
+ declare function hindsightPersonaTags(input: {
131
+ organizationId: string;
132
+ personaId: string;
133
+ themes?: string[];
134
+ userId?: string | null;
135
+ }): string[];
136
+ declare function createHindsightPersonaMemoryClient(config: HindsightPersonaMemoryConfig, fetchImpl?: FetchLike, logger?: PersonaLogger): HindsightPersonaMemoryClient;
137
+
138
+ declare function createOpenAiPersonaEmbedder(openaiApiKey?: string | null): PersonaEmbedder | undefined;
139
+ declare function hashPersonaMemoryText(text: string): string;
140
+ type PersonaMemoryEmbeddingEntry = {
141
+ organizationId: string;
142
+ personaId: string;
143
+ targetId: string;
144
+ targetKind: PersonaEmbeddingTargetKind;
145
+ text: string;
146
+ };
147
+ declare function normalizePersonaEmbeddingText(text: string): string;
148
+ declare function upsertPersonaMemoryEmbeddings(db: PersonaDatabase, input: {
149
+ embed: PersonaEmbedder;
150
+ entries: PersonaMemoryEmbeddingEntry[];
151
+ logger?: PersonaLogger;
152
+ }): Promise<number>;
153
+ declare function backfillPersonaMemoryEmbeddings(db: PersonaDatabase, input: {
154
+ embed?: PersonaEmbedder;
155
+ limit?: number;
156
+ logger?: PersonaLogger;
157
+ }): Promise<{
158
+ embedded: number;
159
+ }>;
160
+
161
+ type PersonaProfileDeleteCounts = {
162
+ aliases: number;
163
+ beliefs: number;
164
+ embeddings: number;
165
+ emotionalSalience: number;
166
+ episodes: number;
167
+ externalMemoryRefs: number;
168
+ facts: number;
169
+ habits: number;
170
+ interactionMemories: number;
171
+ moodStates: number;
172
+ sourceChunks: number;
173
+ sourceDocuments: number;
174
+ styleProfiles: number;
175
+ workspaceStates: number;
176
+ };
177
+ declare function deletePersonaProfile(db: PersonaDatabase, input: {
178
+ organizationId: string;
179
+ personaKey: string;
180
+ updatedByUserId?: string | null;
181
+ }): Promise<{
182
+ deletedCounts: PersonaProfileDeleteCounts;
183
+ profile: PersonaProfile;
184
+ }>;
185
+
186
+ declare const PERSONA_MOOD_BASELINE: PersonaAffectVector;
187
+ declare function estimateTurnAffect(input: {
188
+ selected: PersonaMemoryCandidate[];
189
+ turnPlan: PersonaTurnPlan;
190
+ }): PersonaAffectVector | null;
191
+ declare function explainTurnAffect(input: {
192
+ selected: PersonaMemoryCandidate[];
193
+ turnPlan: PersonaTurnPlan;
194
+ }): PersonaTurnAffectEstimate;
195
+ declare function updatePersonaMood(input: {
196
+ current: PersonaAffectVector | null;
197
+ elapsedMs: number;
198
+ impulse: PersonaAffectVector | null;
199
+ }): PersonaAffectVector;
200
+ declare function calculatePersonaMoodUpdate(input: {
201
+ current: PersonaAffectVector | null;
202
+ elapsedMs: number;
203
+ impulse: PersonaAffectVector | null;
204
+ turnAffect?: PersonaTurnAffectEstimate | null;
205
+ }): {
206
+ mood: PersonaAffectVector;
207
+ trace: PersonaMoodUpdateTrace;
208
+ };
209
+
210
+ declare function loadPersonaProfile(db: PersonaDatabase, input: {
211
+ organizationId: string;
212
+ personaKey: string;
213
+ }): Promise<PersonaProfile>;
214
+ declare function upsertPersonaProfile(db: PersonaDatabase, input: {
215
+ consentStatus?: PersonaProfile["consentStatus"];
216
+ displayName?: string | null;
217
+ organizationId: string;
218
+ personaKey: string;
219
+ personaType?: PersonaProfile["personaType"];
220
+ personaVersion?: string | null;
221
+ policy?: Partial<PersonaProfile["policy"]>;
222
+ profile?: Record<string, unknown>;
223
+ sourceRef?: string | null;
224
+ updatedByUserId?: string | null;
225
+ }): Promise<PersonaProfile>;
226
+ declare function upsertPersonaAlias(db: PersonaDatabase, input: {
227
+ aliasKey: string;
228
+ organizationId: string;
229
+ personaKey: string;
230
+ state?: PersonaAlias["state"];
231
+ surface?: PersonaAliasSurface;
232
+ updatedByUserId?: string | null;
233
+ }): Promise<PersonaAlias>;
234
+ declare function listPersonaAliases(db: PersonaDatabase, input: {
235
+ organizationId: string;
236
+ personaKey?: string | null;
237
+ surface?: PersonaAliasSurface;
238
+ }): Promise<Array<PersonaAlias & {
239
+ personaKey: string;
240
+ }>>;
241
+ declare function forgetPersonaLayerMemory(db: PersonaDatabase, input: {
242
+ memoryId: string;
243
+ organizationId: string;
244
+ personaKey: string;
245
+ sourceTitle?: string | null;
246
+ }): Promise<{
247
+ forgottenEmbeddings: number;
248
+ forgottenMemory: {
249
+ id: string;
250
+ memoryKind: "episode" | "fact" | "belief" | "habit" | "style";
251
+ title: string;
252
+ };
253
+ forgottenSourceChunks: number;
254
+ forgottenSourceDocuments: number;
255
+ }>;
256
+ declare function copyPersonaProfile(db: PersonaDatabase, input: {
257
+ sourcePersonaKey: string;
258
+ targetOrganizationId: string;
259
+ targetPersonaKey?: string | null;
260
+ updatedByUserId?: string | null;
261
+ }): Promise<{
262
+ copiedCounts: {
263
+ beliefs: number;
264
+ episodes: number;
265
+ habits: number;
266
+ sourceChunks: number;
267
+ sourceDocuments: number;
268
+ styleProfiles: number;
269
+ };
270
+ persona: PersonaProfile;
271
+ sourcePersona: PersonaProfile;
272
+ }>;
273
+ declare function publishPersonaProfile(db: PersonaDatabase, input: {
274
+ organizationId: string;
275
+ personaKey: string;
276
+ publicPersonaKey?: string | null;
277
+ updatedByUserId?: string | null;
278
+ }): Promise<{
279
+ persona: PersonaProfile;
280
+ publishedCounts: {
281
+ beliefs: number;
282
+ episodes: number;
283
+ habits: number;
284
+ sourceChunks: number;
285
+ sourceDocuments: number;
286
+ styleProfiles: number;
287
+ };
288
+ sourcePersona: PersonaProfile;
289
+ }>;
290
+ declare function listPublicPersonaProfiles(db: PersonaDatabase): Promise<PersonaProfile[]>;
291
+
292
+ declare const PERSONA_TURN_PLANNER_SYSTEM_PROMPT: string;
293
+ declare const PERSONA_CONSOLIDATION_SYSTEM_PROMPT: string;
294
+ declare const PERSONA_SOURCE_DRAFTING_SYSTEM_PROMPT: string;
295
+ declare const PERSONA_MEMORY_TRIAGE_SYSTEM_PROMPT: string;
296
+
297
+ declare function normalizeCosineSimilarity(value: number | null): number;
298
+ declare function calculateMemoryAvailability(input: {
299
+ candidate: Pick<PersonaMemoryCandidate, "activationCount" | "createdAt" | "kind" | "lastActivatedAt" | "sourceConfidence">;
300
+ now: Date;
301
+ }): number;
302
+ declare function selectPersonaMemories(input: {
303
+ candidates: PersonaMemoryCandidate[];
304
+ context: PersonaContextGatewayOutput;
305
+ mood?: PersonaAffectVector | null;
306
+ moodEmotionLabels?: PersonaMoodEmotionLabel[] | null;
307
+ now?: Date;
308
+ }): PersonaMemoryCandidate[];
309
+ declare function selectPersonaMemoriesWithScores(input: {
310
+ candidates: PersonaMemoryCandidate[];
311
+ context: PersonaContextGatewayOutput;
312
+ mood?: PersonaAffectVector | null;
313
+ moodEmotionLabels?: PersonaMoodEmotionLabel[] | null;
314
+ now?: Date;
315
+ }): PersonaMemorySelectionResult;
316
+
317
+ declare function formatWorkspacePrompt(input: {
318
+ disclosurePolicy?: DisclosurePolicy;
319
+ mood?: PersonaAffectVector | null;
320
+ moodUpdate?: PersonaMoodUpdateTrace | null;
321
+ profile: PersonaProfile;
322
+ turnPlan: PersonaTurnPlan;
323
+ selected: PersonaMemoryCandidate[];
324
+ workspacePayload: PersonaWorkspacePayload;
325
+ }): string;
326
+ declare function recallPersonaMemoriesForCue(db: PersonaDatabase, input: {
327
+ cue: string;
328
+ embed?: PersonaEmbedder;
329
+ logger?: PersonaLogger;
330
+ organizationId: string;
331
+ personaKey: string;
332
+ }): Promise<string>;
333
+ declare function planPersonaTurnWithLlm(input: {
334
+ llm: PersonaJsonLlm;
335
+ message: string;
336
+ persona: PersonaProfile;
337
+ }): Promise<PersonaTurnPlan>;
338
+ type PostResponseMemoryReview = NonNullable<PersonaWorkspacePayload["memoryReview"]>;
339
+ declare function evaluatePostResponseInteractionMemory(input: {
340
+ assistantMessage: string;
341
+ turnPlan: PersonaTurnPlan;
342
+ userMessage: string;
343
+ }): {
344
+ memoryIntent: "self_correction_feedback" | "durable_product_lesson" | null;
345
+ reason: string;
346
+ shouldRemember: boolean;
347
+ summary: string | null;
348
+ themes: string[];
349
+ };
350
+ declare function recordPostResponsePersonaMemoryReview(db: PersonaDatabase, input: {
351
+ assistantMessage: string;
352
+ assistantMessageId?: string | null;
353
+ chatSessionId?: string | null;
354
+ defer?: (promise: Promise<unknown>) => void;
355
+ hindsight?: HindsightPersonaMemoryClient | null;
356
+ logger?: PersonaLogger;
357
+ llm?: PersonaJsonLlm;
358
+ organizationId: string;
359
+ persona: PersonaProfile;
360
+ turnPlan: PersonaTurnPlan;
361
+ userId: string;
362
+ userMessage: string;
363
+ workspaceId: string;
364
+ }): Promise<PostResponseMemoryReview>;
365
+ declare function triageInteractionMemoryWithLlm(input: {
366
+ logger?: PersonaLogger;
367
+ llm?: PersonaJsonLlm;
368
+ message: string;
369
+ persona: PersonaProfile;
370
+ selected?: PersonaMemoryCandidate[];
371
+ turnPlan: PersonaTurnPlan;
372
+ }): Promise<PersonaMemoryTriageDecision>;
373
+ declare function triagePostResponseInteractionMemoryWithLlm(input: {
374
+ assistantMessage: string;
375
+ logger?: PersonaLogger;
376
+ llm?: PersonaJsonLlm;
377
+ persona: PersonaProfile;
378
+ turnPlan: PersonaTurnPlan;
379
+ userMessage: string;
380
+ }): Promise<PersonaMemoryTriageDecision>;
381
+ declare function shouldRecordInteractionMemory(input: {
382
+ message: string;
383
+ selected?: PersonaMemoryCandidate[];
384
+ turnPlan: PersonaTurnPlan;
385
+ }): boolean;
386
+ declare function preparePersonaRuntimeContext(db: PersonaDatabase, input: {
387
+ chatMessageId?: string | null;
388
+ chatSessionId?: string | null;
389
+ defer?: (promise: Promise<unknown>) => void;
390
+ disclosurePolicy?: DisclosurePolicy;
391
+ embed?: PersonaEmbedder;
392
+ hindsight?: HindsightPersonaMemoryClient | null;
393
+ logger?: PersonaLogger;
394
+ llm: PersonaJsonLlm;
395
+ message: string;
396
+ organizationId: string;
397
+ personaKey: string;
398
+ userId: string;
399
+ }): Promise<PersonaRuntimeContext>;
400
+
401
+ declare function hashPersonaSourceContent(text: string): Promise<string>;
402
+ type PersonaSourceTextChunk = {
403
+ endChar: number;
404
+ startChar: number;
405
+ text: string;
406
+ };
407
+ declare function chunkPersonaSourceText(rawText: string, input?: {
408
+ maxChars?: number;
409
+ overlapChars?: number;
410
+ }): PersonaSourceTextChunk[];
411
+ declare function formatPersonaSourceExcerptForQuery(input: {
412
+ maxChars?: number;
413
+ query: string;
414
+ text: string;
415
+ }): string;
416
+ type PersonaSourceIngestionResult = {
417
+ chunkCount: number;
418
+ sourceDocument: PersonaSourceDocument;
419
+ };
420
+ declare function ingestPersonaSourceDocument(db: PersonaDatabase, input: {
421
+ author?: string | null;
422
+ consentStatus?: PersonaSourceDocument["consentStatus"] | null;
423
+ defer?: (promise: Promise<unknown>) => void;
424
+ embed?: PersonaEmbedder;
425
+ hindsight?: HindsightPersonaMemoryClient | null;
426
+ logger?: PersonaLogger;
427
+ metadata?: Record<string, unknown>;
428
+ organizationId: string;
429
+ personaKey: string;
430
+ privacyLevel?: PersonaPrivacyLevel | null;
431
+ publicationDate?: string | null;
432
+ rawText: string;
433
+ reliability?: number | null;
434
+ rightsStatus?: PersonaSourceDocument["rightsStatus"] | null;
435
+ sourcePriority?: PersonaSourceDocument["sourcePriority"] | null;
436
+ sourceType?: PersonaSourceDocument["sourceType"] | null;
437
+ sourceUri?: string | null;
438
+ title: string;
439
+ }): Promise<PersonaSourceIngestionResult>;
440
+ type PersonaSourceDraftEpisode = {
441
+ confidence: number;
442
+ eventSummary: string;
443
+ firstPersonRecollection?: string | null;
444
+ privacyLevel?: PersonaPrivacyLevel | null;
445
+ quoteSpan?: string | null;
446
+ sourceChunkIds?: string[];
447
+ themes?: string[];
448
+ thoughtAnnotations?: string[];
449
+ time?: NewPersonaEpisodeMemory["time"];
450
+ title: string;
451
+ };
452
+ type PersonaSourceDraftBelief = {
453
+ beliefType: PersonaBeliefType;
454
+ confidence: number;
455
+ domain: string;
456
+ exceptions?: string[];
457
+ firstPersonForm?: string | null;
458
+ privacyLevel?: PersonaPrivacyLevel | null;
459
+ proposition: string;
460
+ sourceChunkIds?: string[];
461
+ stance?: PersonaBeliefStance;
462
+ strength?: number | null;
463
+ };
464
+ type PersonaSourceDraftFact = {
465
+ beliefType?: PersonaBeliefType;
466
+ claimText?: string;
467
+ confidence: number;
468
+ domain?: string;
469
+ evidenceSpan?: string | null;
470
+ fact?: string;
471
+ factType?: PersonaFactType | null;
472
+ firstPersonForm?: string | null;
473
+ objectKey?: string | null;
474
+ objectName?: string | null;
475
+ objectType?: PersonaFactObjectType | null;
476
+ privacyLevel?: PersonaPrivacyLevel | null;
477
+ sourceChunkIds?: string[];
478
+ strength?: number | null;
479
+ };
480
+ type PersonaSourceDraftHabit = {
481
+ avoidPatterns?: string[];
482
+ confidence: number;
483
+ defaultResponsePattern: string[];
484
+ rhetoricalMoves?: string[];
485
+ sourceChunkIds?: string[];
486
+ strength?: number | null;
487
+ tone?: PersonaToneVector;
488
+ trigger: {
489
+ description: string;
490
+ type: string;
491
+ };
492
+ };
493
+ type PersonaSourceDraftStyleProfile = {
494
+ avoidPhrases?: string[];
495
+ commonPhrases?: string[];
496
+ lexicalPreferences?: {
497
+ avoids?: string[];
498
+ uses?: string[];
499
+ };
500
+ preferredRhetoricalMoves?: string[];
501
+ register: string;
502
+ sentenceLength: string;
503
+ sourceChunkIds?: string[];
504
+ toneVector?: PersonaToneVector;
505
+ };
506
+ type PersonaSourceDraftMemoryInput = {
507
+ beliefs?: PersonaSourceDraftBelief[];
508
+ episodes?: PersonaSourceDraftEpisode[];
509
+ habits?: PersonaSourceDraftHabit[];
510
+ sourceFacts?: PersonaSourceDraftFact[];
511
+ styleProfiles?: PersonaSourceDraftStyleProfile[];
512
+ };
513
+ type PersonaDraftMemorySummary = {
514
+ id: string;
515
+ memoryKind: "episode" | "fact" | "belief" | "habit" | "style";
516
+ state: PersonaMemoryState;
517
+ title: string;
518
+ };
519
+ type PersonaSourceDraftMemoryResult = {
520
+ drafts: PersonaDraftMemorySummary[];
521
+ sourceDocumentId: string;
522
+ };
523
+ declare function draftPersonaMemoriesFromSourceDocument(db: PersonaDatabase, input: {
524
+ draft: PersonaSourceDraftMemoryInput;
525
+ embed?: PersonaEmbedder;
526
+ logger?: PersonaLogger;
527
+ organizationId: string;
528
+ personaKey: string;
529
+ sourceDocumentId: string;
530
+ }): Promise<PersonaSourceDraftMemoryResult>;
531
+ declare function activatePersonaDraftMemory(db: PersonaDatabase, input: {
532
+ memoryId: string;
533
+ memoryKind: "episode" | "fact" | "belief" | "habit" | "style";
534
+ organizationId: string;
535
+ personaKey: string;
536
+ }): Promise<PersonaDraftMemorySummary | null>;
537
+
538
+ declare function applyBeliefReinforcement(belief: Pick<PersonaSemanticBelief, "confidence" | "strength">, input: {
539
+ evidenceConfidence: number;
540
+ }): {
541
+ confidence: number;
542
+ strength: number;
543
+ };
544
+ declare function applyBeliefContradiction(belief: Pick<PersonaSemanticBelief, "confidence" | "strength">, input: {
545
+ evidenceConfidence: number;
546
+ }): {
547
+ confidence: number;
548
+ state: PersonaMemoryState;
549
+ strength: number;
550
+ };
551
+ declare function parsePersonaToneVector(value: unknown): PersonaToneVector;
552
+ declare function parsePersonaBeliefStance(value: unknown): PersonaBeliefStance;
553
+ declare function parsePersonaLexicalPreferences(value: unknown): {
554
+ uses?: string[];
555
+ avoids?: string[];
556
+ };
557
+ type PersonaEpisodeAffectInput = {
558
+ arousal: number;
559
+ dominance: number;
560
+ emotions: PersonaEmotionAnnotation[];
561
+ retrievalBoost: number;
562
+ salienceScore: number;
563
+ selfRelevance: number;
564
+ valence: number;
565
+ };
566
+ declare function parsePersonaEpisodeAffect(value: unknown): PersonaEpisodeAffectInput | null;
567
+ declare function rememberPersonaLayerMemory(db: PersonaDatabase, input: {
568
+ confidence?: number | null;
569
+ content?: Record<string, unknown> | null;
570
+ defer?: (promise: Promise<unknown>) => void;
571
+ embed?: PersonaEmbedder;
572
+ hindsight?: HindsightPersonaMemoryClient | null;
573
+ logger?: PersonaLogger;
574
+ memoryKind: "episode" | "fact" | "belief" | "habit" | "style" | "interaction";
575
+ organizationId: string;
576
+ personaKey: string;
577
+ privacyLevel?: PersonaPrivacyLevel | null;
578
+ summary: string;
579
+ title: string;
580
+ updatedByUserId?: string | null;
581
+ userId?: string | null;
582
+ }): Promise<{
583
+ id: string;
584
+ memoryKind: "episode" | "fact" | "belief" | "habit" | "style" | "interaction";
585
+ }>;
586
+ declare function consolidatePersonaMemoryScope(input: {
587
+ consolidate: PersonaJsonLlm;
588
+ db: PersonaDatabase;
589
+ defer?: (promise: Promise<unknown>) => void;
590
+ embed?: PersonaEmbedder;
591
+ hindsight?: HindsightPersonaMemoryClient | null;
592
+ logger?: PersonaLogger;
593
+ organizationId: string;
594
+ personaKey: string;
595
+ userId?: string | null;
596
+ }): Promise<{
597
+ contradictedBeliefs: number;
598
+ createdBeliefs: number;
599
+ createdEpisodes: number;
600
+ createdHabits: number;
601
+ createdStyleProfiles: number;
602
+ personaKey: string;
603
+ reinforcedBeliefs: number;
604
+ }>;
605
+ declare function processPersonaMemoryConsolidationTick(input: {
606
+ consolidate: PersonaJsonLlm;
607
+ db: PersonaDatabase;
608
+ embed?: PersonaEmbedder;
609
+ logger?: PersonaLogger;
610
+ now?: Date;
611
+ }): Promise<{
612
+ processedScopes: number;
613
+ contradictedBeliefs: number;
614
+ createdBeliefs: number;
615
+ createdEpisodes: number;
616
+ createdHabits: number;
617
+ createdStyleProfiles: number;
618
+ embeddedMemories: number;
619
+ reinforcedBeliefs: number;
620
+ }>;
621
+
622
+ export { ingestPersonaSourceDocument as $, activatePersonaDraftMemory as A, applyBeliefContradiction as B, applyBeliefReinforcement as C, backfillPersonaMemoryEmbeddings as D, calculateMemoryAvailability as E, calculatePersonaMoodUpdate as F, chunkPersonaSourceText as G, type HindsightPersonaMemoryClient as H, consolidatePersonaMemoryScope as I, copyPersonaProfile as J, createHindsightPersonaMemoryClient as K, createHindsightPersonaMemoryConfig as L, createNoopHindsightPersonaMemoryClient as M, createOpenAiPersonaEmbedder as N, deletePersonaProfile as O, PERSONA_CONSOLIDATION_SYSTEM_PROMPT as P, draftPersonaMemoriesFromSourceDocument as Q, estimateTurnAffect as R, evaluatePostResponseInteractionMemory as S, explainTurnAffect as T, forgetPersonaLayerMemory as U, formatPersonaSourceExcerptForQuery as V, formatWorkspacePrompt as W, hashPersonaMemoryText as X, hashPersonaSourceContent as Y, hindsightPersonaBankId as Z, hindsightPersonaTags as _, type HindsightPersonaMemoryConfig as a, listPersonaAliases as a0, listPublicPersonaProfiles as a1, loadPersonaProfile as a2, normalizeCosineSimilarity as a3, normalizePersonaEmbeddingText as a4, parsePersonaBeliefStance as a5, parsePersonaEpisodeAffect as a6, parsePersonaLexicalPreferences as a7, parsePersonaToneVector as a8, planPersonaTurnWithLlm as a9, preparePersonaRuntimeContext as aa, processPersonaMemoryConsolidationTick as ab, publishPersonaProfile as ac, recallPersonaMemoriesForCue as ad, recordPostResponsePersonaMemoryReview as ae, rememberPersonaLayerMemory as af, selectPersonaMemories as ag, selectPersonaMemoriesWithScores as ah, shouldRecordInteractionMemory as ai, triageInteractionMemoryWithLlm as aj, triagePostResponseInteractionMemoryWithLlm as ak, updatePersonaMood as al, upsertPersonaAlias as am, upsertPersonaMemoryEmbeddings as an, upsertPersonaProfile as ao, type HindsightPersonaMemoryEnv as b, type HindsightRecallInput as c, type HindsightRecallResult as d, type HindsightReflectInput as e, type HindsightReflectResult as f, type HindsightRetainInput as g, type HindsightRetainResult as h, PERSONA_MEMORY_TRIAGE_SYSTEM_PROMPT as i, PERSONA_MOOD_BASELINE as j, PERSONA_SOURCE_DRAFTING_SYSTEM_PROMPT as k, PERSONA_TURN_PLANNER_SYSTEM_PROMPT as l, type PersonaDatabase as m, type PersonaDraftMemorySummary as n, type PersonaEpisodeAffectInput as o, type PersonaMemoryEmbeddingEntry as p, type PersonaProfileDeleteCounts as q, type PersonaSourceDraftBelief as r, type PersonaSourceDraftEpisode as s, type PersonaSourceDraftFact as t, type PersonaSourceDraftHabit as u, type PersonaSourceDraftMemoryInput as v, type PersonaSourceDraftMemoryResult as w, type PersonaSourceDraftStyleProfile as x, type PersonaSourceIngestionResult as y, type PersonaSourceTextChunk as z };
@@ -0,0 +1,6 @@
1
+ export { PersonaLanguage, buildPersonaInstructions } from './agent/index.js';
2
+ export { H as HindsightPersonaMemoryClient, a as HindsightPersonaMemoryConfig, b as HindsightPersonaMemoryEnv, c as HindsightRecallInput, d as HindsightRecallResult, e as HindsightReflectInput, f as HindsightReflectResult, g as HindsightRetainInput, h as HindsightRetainResult, P as PERSONA_CONSOLIDATION_SYSTEM_PROMPT, i as PERSONA_MEMORY_TRIAGE_SYSTEM_PROMPT, j as PERSONA_MOOD_BASELINE, k as PERSONA_SOURCE_DRAFTING_SYSTEM_PROMPT, l as PERSONA_TURN_PLANNER_SYSTEM_PROMPT, m as PersonaDatabase, n as PersonaDraftMemorySummary, o as PersonaEpisodeAffectInput, p as PersonaMemoryEmbeddingEntry, q as PersonaProfileDeleteCounts, r as PersonaSourceDraftBelief, s as PersonaSourceDraftEpisode, t as PersonaSourceDraftFact, u as PersonaSourceDraftHabit, v as PersonaSourceDraftMemoryInput, w as PersonaSourceDraftMemoryResult, x as PersonaSourceDraftStyleProfile, y as PersonaSourceIngestionResult, z as PersonaSourceTextChunk, A as activatePersonaDraftMemory, B as applyBeliefContradiction, C as applyBeliefReinforcement, D as backfillPersonaMemoryEmbeddings, E as calculateMemoryAvailability, F as calculatePersonaMoodUpdate, G as chunkPersonaSourceText, I as consolidatePersonaMemoryScope, J as copyPersonaProfile, K as createHindsightPersonaMemoryClient, L as createHindsightPersonaMemoryConfig, M as createNoopHindsightPersonaMemoryClient, N as createOpenAiPersonaEmbedder, O as deletePersonaProfile, Q as draftPersonaMemoriesFromSourceDocument, R as estimateTurnAffect, S as evaluatePostResponseInteractionMemory, T as explainTurnAffect, U as forgetPersonaLayerMemory, V as formatPersonaSourceExcerptForQuery, W as formatWorkspacePrompt, X as hashPersonaMemoryText, Y as hashPersonaSourceContent, Z as hindsightPersonaBankId, _ as hindsightPersonaTags, $ as ingestPersonaSourceDocument, a0 as listPersonaAliases, a1 as listPublicPersonaProfiles, a2 as loadPersonaProfile, a3 as normalizeCosineSimilarity, a4 as normalizePersonaEmbeddingText, a5 as parsePersonaBeliefStance, a6 as parsePersonaEpisodeAffect, a7 as parsePersonaLexicalPreferences, a8 as parsePersonaToneVector, a9 as planPersonaTurnWithLlm, aa as preparePersonaRuntimeContext, ab as processPersonaMemoryConsolidationTick, ac as publishPersonaProfile, ad as recallPersonaMemoriesForCue, ae as recordPostResponsePersonaMemoryReview, af as rememberPersonaLayerMemory, ag as selectPersonaMemories, ah as selectPersonaMemoriesWithScores, ai as shouldRecordInteractionMemory, aj as triageInteractionMemoryWithLlm, ak as triagePostResponseInteractionMemoryWithLlm, al as updatePersonaMood, am as upsertPersonaAlias, an as upsertPersonaMemoryEmbeddings, ao as upsertPersonaProfile } from './index-swXvBCre.js';
3
+ export { NewPersonaAlias, NewPersonaAuditLog, NewPersonaEmotionalSalience, NewPersonaEpisodeMemory, NewPersonaExternalMemoryRef, NewPersonaFact, NewPersonaHabitPattern, NewPersonaInteractionMemory, NewPersonaLifecycleEffect, NewPersonaMemoryEmbedding, NewPersonaMoodState, NewPersonaProfile, NewPersonaSemanticBelief, NewPersonaSourceChunk, NewPersonaSourceDocument, NewPersonaStyleProfile, NewPersonaWorkspaceState, PERSONA_ALIAS_STATES, PERSONA_ALIAS_SURFACES, PERSONA_BELIEF_STANCES, PERSONA_BELIEF_TYPES, PERSONA_CONSENT_STATUSES, PERSONA_EMBEDDING_DIMENSION, PERSONA_EMBEDDING_TARGET_KINDS, PERSONA_EXTERNAL_MEMORY_LOCAL_TARGET_KINDS, PERSONA_EXTERNAL_MEMORY_PROVIDERS, PERSONA_EXTERNAL_MEMORY_REF_STATES, PERSONA_FACT_OBJECT_TYPES, PERSONA_FACT_TYPES, PERSONA_INTERACTION_MEMORY_STATES, PERSONA_LIFECYCLE_EFFECT_STATUSES, PERSONA_LIFECYCLE_EFFECT_TYPES, PERSONA_MEMORY_STATES, PERSONA_PRIVACY_LEVELS, PERSONA_PROFILE_STATES, PERSONA_PROFILE_TYPES, PERSONA_RIGHTS_STATUSES, PERSONA_SCOPES, PERSONA_SOURCE_PRIORITIES, PERSONA_SOURCE_TYPES, PersonaAlias, PersonaAliasState, PersonaAliasSurface, PersonaAuditLog, PersonaBeliefStance, PersonaBeliefType, PersonaConsentStatus, PersonaEmbeddingTargetKind, PersonaEmotionAnnotation, PersonaEmotionalSalience, PersonaEpisodeMemory, PersonaExternalMemoryAudit, PersonaExternalMemoryCandidate, PersonaExternalMemoryLocalTargetKind, PersonaExternalMemoryProvider, PersonaExternalMemoryRef, PersonaExternalMemoryRefState, PersonaFact, PersonaFactObjectType, PersonaFactType, PersonaHabitPattern, PersonaInteractionMemory, PersonaInteractionMemoryState, PersonaLifecycleEffect, PersonaLifecycleEffectStatus, PersonaLifecycleEffectType, PersonaLocationMetadata, PersonaMemoryEmbedding, PersonaMemoryRetrievalCandidateKind, PersonaMemoryRetrievalCandidateScore, PersonaMemoryRetrievalPayload, PersonaMemoryRetrievalQueryKind, PersonaMemoryRetrievalScoreComponents, PersonaMemoryState, PersonaMoodState, PersonaPersonRef, PersonaPrivacyLevel, PersonaProfile, PersonaProfilePolicy, PersonaProfileState, PersonaProfileType, PersonaRightsStatus, PersonaScope, PersonaSemanticBelief, PersonaSourceChunk, PersonaSourceDocument, PersonaSourceMetadata, PersonaSourcePriority, PersonaSourceRef, PersonaSourceType, PersonaStyleProfile, PersonaTimeMetadata, PersonaToneVector, PersonaWorkspacePayload, PersonaWorkspaceState, personaAliases, personaAuditLogs, personaEmotionalSalience, personaEpisodeMemories, personaExternalMemoryRefs, personaFacts, personaHabitPatterns, personaInteractionMemories, personaLifecycleEffects, personaMemoryEmbeddings, personaMoodStates, personaProfiles, personaSemanticBeliefs, personaSourceChunks, personaSourceDocuments, personaStyleProfiles, personaWorkspaceStates } from './schema/index.js';
4
+ export { D as DisclosurePolicy, P as PERSONA_ANSWER_MODES, a as PERSONA_MEMORY_TYPES, b as PERSONA_QUERY_TYPES, c as PersonaAffectVector, d as PersonaAnswerMode, e as PersonaContextGatewayOutput, f as PersonaEmbedder, g as PersonaGateOutput, h as PersonaJsonLlm, i as PersonaLogger, j as PersonaMemoryCandidate, k as PersonaMemorySelectionResult, l as PersonaMemoryTriageDecision, m as PersonaMemoryTriageIntent, n as PersonaMemoryTriageSource, o as PersonaMemoryTriageType, p as PersonaMemoryType, q as PersonaMoodEmotionLabel, r as PersonaMoodEmotionLabelSource, s as PersonaMoodSignal, t as PersonaMoodUpdateTrace, u as PersonaQueryType, v as PersonaRuntimeContext, w as PersonaTurnAffectEstimate, x as PersonaTurnPlan } from './types-BHEW4MGH.js';
5
+ import 'drizzle-orm/postgres-js';
6
+ import 'drizzle-orm/pg-core';