@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.
- package/ARCHITECTURE.md +29 -0
- package/LICENSE +203 -0
- package/NOTICE +2 -0
- package/README.md +229 -0
- package/RESPONSIBLE_USE.md +40 -0
- package/dist/agent/index.d.ts +15 -0
- package/dist/agent/index.js +7 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/chunk-2MUEPA24.js +788 -0
- package/dist/chunk-2MUEPA24.js.map +1 -0
- package/dist/chunk-O2K26IXY.js +84 -0
- package/dist/chunk-O2K26IXY.js.map +1 -0
- package/dist/chunk-WW6EKNPL.js +6352 -0
- package/dist/chunk-WW6EKNPL.js.map +1 -0
- package/dist/index-swXvBCre.d.ts +622 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +209 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/index.d.ts +5 -0
- package/dist/memory/index.js +124 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/schema/index.d.ts +4715 -0
- package/dist/schema/index.js +85 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/types-BHEW4MGH.d.ts +149 -0
- package/package.json +59 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema/persona-memory.ts","../src/schema/table.ts","../src/schema/ulid.ts"],"sourcesContent":["export const PERSONA_EMBEDDING_DIMENSION = 1536;\nimport { sql } from \"drizzle-orm\";\nimport {\n boolean,\n check,\n index,\n integer,\n jsonb,\n real,\n text,\n timestamp,\n uniqueIndex,\n vector,\n} from \"drizzle-orm/pg-core\";\n\nimport { pgTable } from \"./table\";\nimport { ulid } from \"./ulid\";\n\nexport const PERSONA_PROFILE_TYPES = [\n \"simulated_character\",\n \"living_public_figure\",\n \"deceased_public_figure\",\n \"private_authorized_person\",\n \"synthetic_role\",\n] as const;\n\nexport type PersonaProfileType = (typeof PERSONA_PROFILE_TYPES)[number];\n\nexport const PERSONA_CONSENT_STATUSES = [\n \"explicit_consent\",\n \"authorized\",\n \"fictional_or_authorized\",\n \"public_material_only\",\n \"unknown\",\n] as const;\n\nexport type PersonaConsentStatus = (typeof PERSONA_CONSENT_STATUSES)[number];\n\nexport const PERSONA_PROFILE_STATES = [\n \"draft\",\n \"review_pending\",\n \"active\",\n \"archived\",\n \"deleted\",\n] as const;\n\nexport type PersonaProfileState = (typeof PERSONA_PROFILE_STATES)[number];\n\nexport const PERSONA_ALIAS_SURFACES = [\"slack\", \"web\", \"cli\"] as const;\n\nexport type PersonaAliasSurface = (typeof PERSONA_ALIAS_SURFACES)[number];\n\nexport const PERSONA_ALIAS_STATES = [\"active\", \"disabled\", \"deleted\"] as const;\n\nexport type PersonaAliasState = (typeof PERSONA_ALIAS_STATES)[number];\n\nconst PERSONA_ALIAS_SURFACES_SQL = PERSONA_ALIAS_SURFACES.map(\n (surface) => `'${surface}'`\n).join(\", \");\n\nconst PERSONA_ALIAS_STATES_SQL = PERSONA_ALIAS_STATES.map(\n (state) => `'${state}'`\n).join(\", \");\n\nexport const PERSONA_SOURCE_TYPES = [\n \"interview_transcript\",\n \"book\",\n \"essay\",\n \"speech\",\n \"conversation\",\n \"biography\",\n \"profile_document\",\n \"seed\",\n \"external_source\",\n \"synthetic\",\n] as const;\n\nexport type PersonaSourceType = (typeof PERSONA_SOURCE_TYPES)[number];\n\nexport const PERSONA_SOURCE_PRIORITIES = [\n \"first_person_private\",\n \"first_person_public\",\n \"authored_work\",\n \"direct_interview\",\n \"recorded_speech\",\n \"verified_correspondence\",\n \"authorized_biography\",\n \"third_party_biography\",\n \"news_article\",\n \"unverified_secondary\",\n \"synthetic\",\n] as const;\n\nexport type PersonaSourcePriority = (typeof PERSONA_SOURCE_PRIORITIES)[number];\n\nexport const PERSONA_RIGHTS_STATUSES = [\n \"licensed\",\n \"owned\",\n \"public\",\n \"fair_use_reviewed\",\n \"unknown\",\n] as const;\n\nexport type PersonaRightsStatus = (typeof PERSONA_RIGHTS_STATUSES)[number];\n\nexport const PERSONA_PRIVACY_LEVELS = [\n \"public\",\n \"internal\",\n \"private\",\n \"sensitive\",\n] as const;\n\nexport type PersonaPrivacyLevel = (typeof PERSONA_PRIVACY_LEVELS)[number];\n\nexport const PERSONA_MEMORY_STATES = [\n \"draft\",\n \"active\",\n \"conflicted\",\n \"superseded\",\n \"archived\",\n \"deleted\",\n] as const;\n\nexport type PersonaMemoryState = (typeof PERSONA_MEMORY_STATES)[number];\n\nexport const PERSONA_BELIEF_TYPES = [\n \"moral_principle\",\n \"epistemic_principle\",\n \"political_belief\",\n \"aesthetic_preference\",\n \"relationship_belief\",\n \"self_concept\",\n \"professional_norm\",\n \"conflict_strategy\",\n] as const;\n\nexport type PersonaBeliefType = (typeof PERSONA_BELIEF_TYPES)[number];\n\nexport const PERSONA_BELIEF_STANCES = [\n \"support\",\n \"oppose\",\n \"ambivalent\",\n \"revised\",\n] as const;\n\nexport type PersonaBeliefStance = (typeof PERSONA_BELIEF_STANCES)[number];\n\nexport const PERSONA_FACT_TYPES = [\n \"uses_product\",\n \"prefers_brand\",\n \"recommends\",\n \"dislikes\",\n \"owns_item\",\n \"wears_item\",\n \"uses_tool\",\n \"eats_or_drinks\",\n \"works_with\",\n \"located_at\",\n \"mentions_entity\",\n \"other\",\n] as const;\n\nexport type PersonaFactType = (typeof PERSONA_FACT_TYPES)[number];\n\nexport const PERSONA_FACT_OBJECT_TYPES = [\n \"brand\",\n \"product\",\n \"tool\",\n \"clothing\",\n \"food\",\n \"place\",\n \"person\",\n \"organization\",\n \"work\",\n \"event\",\n \"concept\",\n \"text\",\n] as const;\n\nexport type PersonaFactObjectType = (typeof PERSONA_FACT_OBJECT_TYPES)[number];\n\nexport const PERSONA_INTERACTION_MEMORY_STATES = [\n \"recorded\",\n \"consolidation_candidate\",\n \"consolidated\",\n \"discarded\",\n \"deleted\",\n] as const;\n\nexport type PersonaInteractionMemoryState =\n (typeof PERSONA_INTERACTION_MEMORY_STATES)[number];\n\nexport const PERSONA_LIFECYCLE_EFFECT_TYPES = [\n \"extract_episode\",\n \"annotate_emotion\",\n \"extract_belief\",\n \"extract_habit\",\n \"distill_style\",\n \"consolidate_memory\",\n \"apply_correction\",\n \"apply_forget\",\n \"grounding_review\",\n] as const;\n\nexport type PersonaLifecycleEffectType =\n (typeof PERSONA_LIFECYCLE_EFFECT_TYPES)[number];\n\nexport const PERSONA_LIFECYCLE_EFFECT_STATUSES = [\n \"pending\",\n \"running\",\n \"completed\",\n \"retry_scheduled\",\n \"failed\",\n \"cancelled\",\n] as const;\n\nexport type PersonaLifecycleEffectStatus =\n (typeof PERSONA_LIFECYCLE_EFFECT_STATUSES)[number];\n\nexport const PERSONA_EXTERNAL_MEMORY_PROVIDERS = [\"hindsight\"] as const;\n\nexport type PersonaExternalMemoryProvider =\n (typeof PERSONA_EXTERNAL_MEMORY_PROVIDERS)[number];\n\nexport const PERSONA_EXTERNAL_MEMORY_REF_STATES = [\n \"active\",\n \"deleted\",\n \"failed\",\n \"disabled\",\n] as const;\n\nexport type PersonaExternalMemoryRefState =\n (typeof PERSONA_EXTERNAL_MEMORY_REF_STATES)[number];\n\nexport const PERSONA_EXTERNAL_MEMORY_LOCAL_TARGET_KINDS = [\n \"episode\",\n \"fact\",\n \"belief\",\n \"habit\",\n \"style\",\n \"interaction\",\n \"source_document\",\n \"source_chunk\",\n] as const;\n\nexport type PersonaExternalMemoryLocalTargetKind =\n (typeof PERSONA_EXTERNAL_MEMORY_LOCAL_TARGET_KINDS)[number];\n\nconst PERSONA_EXTERNAL_MEMORY_PROVIDERS_SQL =\n PERSONA_EXTERNAL_MEMORY_PROVIDERS.map((provider) => `'${provider}'`).join(\n \", \"\n );\n\nconst PERSONA_EXTERNAL_MEMORY_REF_STATES_SQL =\n PERSONA_EXTERNAL_MEMORY_REF_STATES.map((state) => `'${state}'`).join(\", \");\n\nconst PERSONA_EXTERNAL_MEMORY_LOCAL_TARGET_KINDS_SQL =\n PERSONA_EXTERNAL_MEMORY_LOCAL_TARGET_KINDS.map((kind) => `'${kind}'`).join(\n \", \"\n );\n\nexport type PersonaProfilePolicy = {\n allowedUse: string[];\n forbiddenUse: string[];\n knowledgeCutoffForPersona: string | null;\n transparencyLabel: string;\n biographicalSummary: string | null;\n};\n\nexport type PersonaSourceMetadata = {\n language?: string;\n medium?: string;\n url?: string | null;\n [key: string]: unknown;\n};\n\nexport type PersonaTimeMetadata = {\n date?: string | null;\n precision?: \"day\" | \"month\" | \"year\" | \"range\" | \"unknown\";\n lifeStage?: string | null;\n from?: string | null;\n to?: string | null;\n};\n\nexport type PersonaLocationMetadata = {\n name: string;\n confidence: number;\n};\n\nexport type PersonaPersonRef = {\n name: string;\n relationship?: string;\n confidence: number;\n};\n\nexport type PersonaEmotionAnnotation = {\n emotion: string;\n intensity: number;\n evidence?: string;\n};\n\nexport type PersonaSourceRef = {\n sourceDocumentId?: string;\n sourceChunkId?: string;\n quoteSpan?: string;\n};\n\nexport type PersonaToneVector = {\n warmth?: number;\n formality?: number;\n humor?: number;\n directness?: number;\n humility?: number;\n firmness?: number;\n defensiveness?: number;\n};\n\nexport type PersonaWorkspacePayload = {\n gateOutput: Record<string, unknown>;\n contextKeys: Record<string, unknown>;\n activeMemories: string[];\n activeFacts: string[];\n activeBeliefs: string[];\n activeHabits: string[];\n activeStyleProfiles: string[];\n affectiveState: Record<string, unknown>;\n responsePlan: Record<string, unknown>;\n appraisalSummary: Record<string, unknown>;\n externalMemory?: PersonaExternalMemoryAudit;\n memoryRetrieval?: PersonaMemoryRetrievalPayload;\n memoryReview?: {\n createdAt: string;\n memoryId?: string | null;\n memoryIntent?: string | null;\n reason: string;\n shouldRemember: boolean;\n status: \"recorded\" | \"skipped\";\n version: 1;\n };\n};\n\nexport type PersonaExternalMemoryAudit = {\n provider: \"hindsight\";\n enabled: boolean;\n recallAttempted: boolean;\n skippedReason?: string;\n latencyMs?: number;\n selected: PersonaExternalMemoryCandidate[];\n candidates: PersonaExternalMemoryCandidate[];\n version: 1;\n};\n\nexport type PersonaExternalMemoryCandidate = {\n id: string;\n kind: \"external_observation\" | \"external_source\";\n title: string;\n text: string;\n confidence: number;\n sourceConfidence?: number | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n themes: string[];\n privacyLevel: PersonaPrivacyLevel;\n provenance: {\n provider: \"hindsight\";\n bankId: string;\n memoryId?: string | null;\n observationId?: string | null;\n sourceIds?: string[];\n citations?: string[];\n };\n score: {\n semanticSimilarity?: number;\n temporalRelevance?: number;\n graphRelevance?: number;\n providerScore?: number;\n finalScore: number;\n };\n};\n\nexport type PersonaMemoryRetrievalCandidateKind =\n | \"episode\"\n | \"fact\"\n | \"belief\"\n | \"habit\"\n | \"style\"\n | \"source\";\n\nexport type PersonaMemoryRetrievalQueryKind =\n | \"episodic\"\n | \"semantic\"\n | \"habit\"\n | \"style\"\n | \"source\";\n\nexport type PersonaMemoryRetrievalScoreComponents = {\n affectiveSalience: number;\n emotionLabelOverlap: number;\n entityMatch: number;\n identityRelevance: number;\n lexicalSimilarity: number;\n moodCongruence: number;\n normalizedSemanticSimilarity: number;\n privacyOrPolicyRisk: number;\n recencyOrLifeStageRelevance: number;\n semanticSimilarity: number;\n sourceConfidence: number;\n temporalMatch: number;\n themeMatch: number;\n};\n\nexport type PersonaMemoryRetrievalCandidateScore = {\n activationCount: number;\n activationScore: number | null;\n availability: number | null;\n baseRank: number | null;\n components: PersonaMemoryRetrievalScoreComponents | null;\n confidence: number;\n createdAt: string;\n excludedReason: \"privacy\" | null;\n id: string;\n kind: PersonaMemoryRetrievalCandidateKind;\n lastActivatedAt: string | null;\n privacyLevel: PersonaPrivacyLevel;\n query: string;\n rank: number;\n rankBeforeSpreading: number | null;\n retrievalBoost: number;\n selected: boolean;\n selectedOrder: number | null;\n semanticSimilarity: number | null;\n sourceConfidence: number;\n spreadingBoost: number;\n strength: number;\n};\n\nexport type PersonaMemoryRetrievalPayload = {\n budgets: Record<PersonaMemoryRetrievalCandidateKind, number>;\n candidateCount: number;\n candidates: PersonaMemoryRetrievalCandidateScore[];\n generatedAt: string;\n queries: Record<PersonaMemoryRetrievalQueryKind, string>;\n selectedCount: number;\n version: 1;\n};\n\nexport const PERSONA_SCOPES = [\"organization\", \"public\"] as const;\n\nexport type PersonaScope = (typeof PERSONA_SCOPES)[number];\n\n// Public persona templates (persona_scope = \"public\") live with a null\n// organization id and are copied into orgs on demand; organization-scoped\n// rows always carry an organization id.\nexport const personaProfiles = pgTable(\n \"persona_profiles\",\n {\n consentStatus: text(\"consent_status\")\n .notNull()\n .$type<PersonaConsentStatus>(),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n displayName: text(\"display_name\").notNull(),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n organizationId: text(\"organization_id\"),\n personaKey: text(\"persona_key\").notNull(),\n personaScope: text(\"persona_scope\")\n .notNull()\n .$type<PersonaScope>()\n .default(\"organization\"),\n personaType: text(\"persona_type\").notNull().$type<PersonaProfileType>(),\n personaVersion: text(\"persona_version\").notNull().default(\"v1\"),\n policy: jsonb(\"policy\").$type<PersonaProfilePolicy>().notNull(),\n profile: jsonb(\"profile\").$type<Record<string, unknown>>().notNull(),\n sourceRef: text(\"source_ref\"),\n state: text(\"state\")\n .notNull()\n .$type<PersonaProfileState>()\n .default(\"active\"),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n updatedByUserId: text(\"updated_by_user_id\"),\n },\n (table) => [\n // Partial: public persona templates have a null organization id; org\n // uniqueness only applies to org-scoped rows. Writers using ON CONFLICT\n // against this index must pass the same predicate via targetWhere or\n // Postgres cannot match the index.\n uniqueIndex(\"idx_persona_profiles_org_key\")\n .on(table.organizationId, table.personaKey)\n .where(sql`organization_id is not null`),\n uniqueIndex(\"idx_persona_profiles_public_key\")\n .on(table.personaKey)\n .where(sql`organization_id is null`),\n index(\"idx_persona_profiles_org_state\").on(\n table.organizationId,\n table.state\n ),\n index(\"idx_persona_profiles_scope_state\").on(\n table.personaScope,\n table.state\n ),\n ]\n);\n\nexport const personaAliases = pgTable(\n \"persona_aliases\",\n {\n aliasKey: text(\"alias_key\").notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n createdByUserId: text(\"created_by_user_id\"),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n organizationId: text(\"organization_id\").notNull(),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n state: text(\"state\").notNull().$type<PersonaAliasState>().default(\"active\"),\n surface: text(\"surface\")\n .notNull()\n .$type<PersonaAliasSurface>()\n .default(\"slack\"),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n updatedByUserId: text(\"updated_by_user_id\"),\n },\n (table) => [\n index(\"idx_persona_aliases_persona\").on(table.personaId),\n index(\"idx_persona_aliases_org_surface_state\").on(\n table.organizationId,\n table.surface,\n table.state\n ),\n uniqueIndex(\"idx_persona_aliases_org_surface_alias\")\n .on(table.organizationId, table.surface, table.aliasKey)\n .where(sql`state <> 'deleted'`),\n check(\n \"persona_aliases_alias_key_length_check\",\n sql`char_length(${table.aliasKey}) between 1 and 80`\n ),\n check(\n \"persona_aliases_alias_key_no_whitespace_check\",\n sql`${table.aliasKey} !~ '\\\\s'`\n ),\n check(\n \"persona_aliases_surface_check\",\n sql`${table.surface} in (${sql.raw(PERSONA_ALIAS_SURFACES_SQL)})`\n ),\n check(\n \"persona_aliases_state_check\",\n sql`${table.state} in (${sql.raw(PERSONA_ALIAS_STATES_SQL)})`\n ),\n ]\n);\n\nexport const personaSourceDocuments = pgTable(\n \"persona_source_documents\",\n {\n author: text(\"author\"),\n consentStatus: text(\"consent_status\")\n .notNull()\n .$type<PersonaConsentStatus>(),\n contentHash: text(\"content_hash\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n ingestedAt: timestamp(\"ingested_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n metadata: jsonb(\"metadata\")\n .$type<PersonaSourceMetadata>()\n .notNull()\n .default({}),\n organizationId: text(\"organization_id\"),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n privacyLevel: text(\"privacy_level\")\n .notNull()\n .$type<PersonaPrivacyLevel>()\n .default(\"internal\"),\n publicationDate: text(\"publication_date\"),\n reliability: real(\"reliability\").notNull().default(0.75),\n rightsStatus: text(\"rights_status\").notNull().$type<PersonaRightsStatus>(),\n sourcePriority: text(\"source_priority\")\n .notNull()\n .$type<PersonaSourcePriority>(),\n sourceType: text(\"source_type\").notNull().$type<PersonaSourceType>(),\n sourceUri: text(\"source_uri\"),\n state: text(\"state\")\n .notNull()\n .$type<PersonaMemoryState>()\n .default(\"active\"),\n title: text(\"title\").notNull(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n },\n (table) => [\n index(\"idx_persona_source_documents_persona\").on(\n table.organizationId,\n table.personaId,\n table.state\n ),\n uniqueIndex(\"idx_persona_source_documents_hash\")\n .on(table.organizationId, table.personaId, table.contentHash)\n .where(sql`${table.contentHash} is not null`),\n ]\n);\n\nexport const personaSourceChunks = pgTable(\n \"persona_source_chunks\",\n {\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n embeddingId: text(\"embedding_id\"),\n emotions: jsonb(\"emotions\").$type<string[]>().notNull().default([]),\n endChar: integer(\"end_char\"),\n entities: jsonb(\"entities\").$type<string[]>().notNull().default([]),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n organizationId: text(\"organization_id\"),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n sourceDocumentId: text(\"source_document_id\")\n .notNull()\n .references(() => personaSourceDocuments.id, { onDelete: \"cascade\" }),\n startChar: integer(\"start_char\"),\n text: text(\"text\").notNull(),\n themes: jsonb(\"themes\").$type<string[]>().notNull().default([]),\n timeMentions: jsonb(\"time_mentions\")\n .$type<string[]>()\n .notNull()\n .default([]),\n },\n (table) => [\n index(\"idx_persona_source_chunks_document\").on(table.sourceDocumentId),\n index(\"idx_persona_source_chunks_persona\").on(\n table.organizationId,\n table.personaId\n ),\n ]\n);\n\nexport const personaFacts = pgTable(\n \"persona_facts\",\n {\n activationCount: integer(\"activation_count\").notNull().default(0),\n claimText: text(\"claim_text\").notNull(),\n confidence: real(\"confidence\").notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n evidenceSpan: text(\"evidence_span\"),\n factType: text(\"fact_type\").notNull().$type<PersonaFactType>(),\n firstPersonForm: text(\"first_person_form\"),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n lastActivatedAt: timestamp(\"last_activated_at\", { withTimezone: true }),\n objectKey: text(\"object_key\"),\n objectName: text(\"object_name\").notNull(),\n objectType: text(\"object_type\").notNull().$type<PersonaFactObjectType>(),\n organizationId: text(\"organization_id\"),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n privacyLevel: text(\"privacy_level\")\n .notNull()\n .$type<PersonaPrivacyLevel>()\n .default(\"internal\"),\n sourceChunkId: text(\"source_chunk_id\").references(\n () => personaSourceChunks.id,\n { onDelete: \"set null\" }\n ),\n sourceDocumentId: text(\"source_document_id\")\n .notNull()\n .references(() => personaSourceDocuments.id, { onDelete: \"cascade\" }),\n sourceRefs: jsonb(\"source_refs\")\n .$type<PersonaSourceRef[]>()\n .notNull()\n .default([]),\n state: text(\"state\")\n .notNull()\n .$type<PersonaMemoryState>()\n .default(\"active\"),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n },\n (table) => [\n index(\"idx_persona_facts_persona\").on(\n table.organizationId,\n table.personaId,\n table.state\n ),\n index(\"idx_persona_facts_object\").on(\n table.personaId,\n table.objectType,\n table.objectKey\n ),\n index(\"idx_persona_facts_source\").on(\n table.sourceDocumentId,\n table.sourceChunkId\n ),\n ]\n);\n\nexport const personaEpisodeMemories = pgTable(\n \"persona_episode_memories\",\n {\n activationCount: integer(\"activation_count\").notNull().default(0),\n confidence: real(\"confidence\").notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n eventSummary: text(\"event_summary\").notNull(),\n firstPersonRecollection: text(\"first_person_recollection\"),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n lastActivatedAt: timestamp(\"last_activated_at\", { withTimezone: true }),\n location: jsonb(\"location\").$type<PersonaLocationMetadata>(),\n organizationId: text(\"organization_id\"),\n people: jsonb(\"people\").$type<PersonaPersonRef[]>().notNull().default([]),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n privacyLevel: text(\"privacy_level\")\n .notNull()\n .$type<PersonaPrivacyLevel>()\n .default(\"internal\"),\n sourceRefs: jsonb(\"source_refs\")\n .$type<PersonaSourceRef[]>()\n .notNull()\n .default([]),\n state: text(\"state\")\n .notNull()\n .$type<PersonaMemoryState>()\n .default(\"active\"),\n themes: jsonb(\"themes\").$type<string[]>().notNull().default([]),\n thoughtAnnotations: jsonb(\"thought_annotations\")\n .$type<string[]>()\n .notNull()\n .default([]),\n time: jsonb(\"time\").$type<PersonaTimeMetadata>().notNull().default({}),\n title: text(\"title\").notNull(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n },\n (table) => [\n index(\"idx_persona_episode_memories_persona\").on(\n table.organizationId,\n table.personaId,\n table.state\n ),\n index(\"idx_persona_episode_memories_created\").on(table.createdAt),\n ]\n);\n\nexport const personaEmotionalSalience = pgTable(\n \"persona_emotional_salience\",\n {\n arousal: real(\"arousal\").notNull(),\n confidence: real(\"confidence\").notNull().default(0.75),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n dominance: real(\"dominance\").notNull(),\n emotions: jsonb(\"emotions\")\n .$type<PersonaEmotionAnnotation[]>()\n .notNull()\n .default([]),\n episodeMemoryId: text(\"episode_memory_id\")\n .notNull()\n .references(() => personaEpisodeMemories.id, { onDelete: \"cascade\" }),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n notes: text(\"notes\"),\n organizationId: text(\"organization_id\"),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n retrievalBoost: real(\"retrieval_boost\").notNull().default(1),\n salienceScore: real(\"salience_score\").notNull(),\n selfRelevance: real(\"self_relevance\").notNull(),\n socialRelevance: real(\"social_relevance\").notNull().default(0),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n valence: real(\"valence\").notNull(),\n },\n (table) => [\n uniqueIndex(\"idx_persona_emotional_salience_episode\").on(\n table.episodeMemoryId\n ),\n index(\"idx_persona_emotional_salience_persona\").on(\n table.organizationId,\n table.personaId\n ),\n ]\n);\n\n// Slow-moving PAD (pleasure/valence, arousal, dominance) mood per\n// (persona, user) relationship. Updated every turn with inertia and decays\n// toward the persona baseline between sessions; biases memory retrieval\n// (mood-congruent recall) and response tone.\nexport const personaMoodStates = pgTable(\n \"persona_mood_states\",\n {\n arousal: real(\"arousal\").notNull().default(0.3),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n dominance: real(\"dominance\").notNull().default(0.5),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n organizationId: text(\"organization_id\").notNull(),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n turnCount: integer(\"turn_count\").notNull().default(0),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n userId: text(\"user_id\").notNull(),\n valence: real(\"valence\").notNull().default(0.1),\n },\n (table) => [\n uniqueIndex(\"idx_persona_mood_states_scope\").on(\n table.organizationId,\n table.personaId,\n table.userId\n ),\n ]\n);\n\nexport const personaSemanticBeliefs = pgTable(\n \"persona_semantic_beliefs\",\n {\n activationCount: integer(\"activation_count\").notNull().default(0),\n beliefType: text(\"belief_type\").notNull().$type<PersonaBeliefType>(),\n confidence: real(\"confidence\").notNull(),\n contradictingSourceIds: jsonb(\"contradicting_source_ids\")\n .$type<string[]>()\n .notNull()\n .default([]),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n domain: text(\"domain\").notNull(),\n exceptions: jsonb(\"exceptions\").$type<string[]>().notNull().default([]),\n firstPersonForm: text(\"first_person_form\"),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n lastActivatedAt: timestamp(\"last_activated_at\", { withTimezone: true }),\n organizationId: text(\"organization_id\"),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n privacyLevel: text(\"privacy_level\")\n .notNull()\n .$type<PersonaPrivacyLevel>()\n .default(\"internal\"),\n proposition: text(\"proposition\").notNull(),\n stance: text(\"stance\").notNull().$type<PersonaBeliefStance>(),\n state: text(\"state\")\n .notNull()\n .$type<PersonaMemoryState>()\n .default(\"active\"),\n strength: real(\"strength\").notNull(),\n supportingMemoryIds: jsonb(\"supporting_memory_ids\")\n .$type<string[]>()\n .notNull()\n .default([]),\n supportingSourceIds: jsonb(\"supporting_source_ids\")\n .$type<string[]>()\n .notNull()\n .default([]),\n temporalValidity: jsonb(\"temporal_validity\")\n .$type<{ from?: string | null; to?: string | null }>()\n .notNull()\n .default({}),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n },\n (table) => [\n index(\"idx_persona_semantic_beliefs_persona\").on(\n table.organizationId,\n table.personaId,\n table.state\n ),\n index(\"idx_persona_semantic_beliefs_domain\").on(table.domain),\n ]\n);\n\nexport const personaHabitPatterns = pgTable(\n \"persona_habit_patterns\",\n {\n activationCount: integer(\"activation_count\").notNull().default(0),\n avoidPatterns: jsonb(\"avoid_patterns\")\n .$type<string[]>()\n .notNull()\n .default([]),\n confidence: real(\"confidence\").notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n defaultResponsePattern: jsonb(\"default_response_pattern\")\n .$type<string[]>()\n .notNull(),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n lastActivatedAt: timestamp(\"last_activated_at\", { withTimezone: true }),\n organizationId: text(\"organization_id\"),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n rhetoricalMoves: jsonb(\"rhetorical_moves\")\n .$type<string[]>()\n .notNull()\n .default([]),\n state: text(\"state\")\n .notNull()\n .$type<PersonaMemoryState>()\n .default(\"active\"),\n strength: real(\"strength\").notNull(),\n supportingExampleIds: jsonb(\"supporting_example_ids\")\n .$type<string[]>()\n .notNull()\n .default([]),\n tone: jsonb(\"tone\").$type<PersonaToneVector>().notNull().default({}),\n trigger: jsonb(\"trigger\")\n .$type<{ type: string; description: string }>()\n .notNull(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n },\n (table) => [\n index(\"idx_persona_habit_patterns_persona\").on(\n table.organizationId,\n table.personaId,\n table.state\n ),\n ]\n);\n\nexport const personaStyleProfiles = pgTable(\n \"persona_style_profiles\",\n {\n activationCount: integer(\"activation_count\").notNull().default(0),\n avoidPhrases: jsonb(\"avoid_phrases\")\n .$type<string[]>()\n .notNull()\n .default([]),\n commonPhrases: jsonb(\"common_phrases\")\n .$type<string[]>()\n .notNull()\n .default([]),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n lastActivatedAt: timestamp(\"last_activated_at\", { withTimezone: true }),\n lexicalPreferences: jsonb(\"lexical_preferences\")\n .$type<{ uses?: string[]; avoids?: string[] }>()\n .notNull()\n .default({}),\n organizationId: text(\"organization_id\"),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n preferredRhetoricalMoves: jsonb(\"preferred_rhetorical_moves\")\n .$type<string[]>()\n .notNull()\n .default([]),\n register: text(\"register\").notNull(),\n sentenceLength: text(\"sentence_length\").notNull(),\n state: text(\"state\")\n .notNull()\n .$type<PersonaMemoryState>()\n .default(\"active\"),\n toneVector: jsonb(\"tone_vector\")\n .$type<PersonaToneVector>()\n .notNull()\n .default({}),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n },\n (table) => [\n index(\"idx_persona_style_profiles_persona\").on(\n table.organizationId,\n table.personaId,\n table.state\n ),\n ]\n);\n\nexport const personaWorkspaceStates = pgTable(\n \"persona_workspace_states\",\n {\n chatMessageId: text(\"chat_message_id\"),\n chatSessionId: text(\"chat_session_id\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n organizationId: text(\"organization_id\").notNull(),\n payload: jsonb(\"payload\").$type<PersonaWorkspacePayload>().notNull(),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n userId: text(\"user_id\"),\n userMessage: text(\"user_message\").notNull(),\n },\n (table) => [\n index(\"idx_persona_workspace_states_session\").on(table.chatSessionId),\n index(\"idx_persona_workspace_states_persona\").on(\n table.organizationId,\n table.personaId\n ),\n ]\n);\n\nexport const personaInteractionMemories = pgTable(\n \"persona_interaction_memories\",\n {\n chatMessageId: text(\"chat_message_id\"),\n chatSessionId: text(\"chat_session_id\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n interactionSummary: text(\"interaction_summary\").notNull(),\n newPersonaMemory:\n jsonb(\"new_persona_memory\").$type<Record<string, unknown>>(),\n newUserPreference: text(\"new_user_preference\"),\n organizationId: text(\"organization_id\").notNull(),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n shouldConsolidate: boolean(\"should_consolidate\").notNull().default(false),\n state: text(\"state\")\n .notNull()\n .$type<PersonaInteractionMemoryState>()\n .default(\"recorded\"),\n ttlDays: integer(\"ttl_days\").notNull().default(30),\n userId: text(\"user_id\"),\n },\n (table) => [\n index(\"idx_persona_interaction_memories_persona\").on(\n table.organizationId,\n table.personaId,\n table.state\n ),\n index(\"idx_persona_interaction_memories_session\").on(table.chatSessionId),\n ]\n);\n\nexport const personaExternalMemoryRefs = pgTable(\n \"persona_external_memory_refs\",\n {\n chatMessageId: text(\"chat_message_id\"),\n chatSessionId: text(\"chat_session_id\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n externalBankId: text(\"external_bank_id\").notNull(),\n externalMemoryId: text(\"external_memory_id\"),\n externalObservationId: text(\"external_observation_id\"),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n lastError: text(\"last_error\"),\n localTargetId: text(\"local_target_id\"),\n localTargetKind:\n text(\"local_target_kind\").$type<PersonaExternalMemoryLocalTargetKind>(),\n metadata: jsonb(\"metadata\")\n .$type<Record<string, unknown>>()\n .notNull()\n .default({}),\n organizationId: text(\"organization_id\").notNull(),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n privacyLevel: text(\"privacy_level\").notNull().$type<PersonaPrivacyLevel>(),\n provider: text(\"provider\")\n .notNull()\n .$type<PersonaExternalMemoryProvider>()\n .default(\"hindsight\"),\n state: text(\"state\")\n .notNull()\n .$type<PersonaExternalMemoryRefState>()\n .default(\"active\"),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n userId: text(\"user_id\"),\n },\n (table) => [\n index(\"idx_persona_external_memory_refs_persona_provider\").on(\n table.organizationId,\n table.personaId,\n table.provider\n ),\n index(\"idx_persona_external_memory_refs_user_provider\").on(\n table.organizationId,\n table.personaId,\n table.userId,\n table.provider\n ),\n index(\"idx_persona_external_memory_refs_external\").on(\n table.provider,\n table.externalBankId,\n table.externalMemoryId\n ),\n index(\"idx_persona_external_memory_refs_local\").on(\n table.localTargetKind,\n table.localTargetId,\n table.provider\n ),\n uniqueIndex(\"idx_persona_external_memory_refs_local_unique\").on(\n table.localTargetKind,\n table.localTargetId,\n table.provider\n ),\n check(\n \"persona_external_memory_refs_provider_check\",\n sql`${table.provider} in (${sql.raw(PERSONA_EXTERNAL_MEMORY_PROVIDERS_SQL)})`\n ),\n check(\n \"persona_external_memory_refs_state_check\",\n sql`${table.state} in (${sql.raw(PERSONA_EXTERNAL_MEMORY_REF_STATES_SQL)})`\n ),\n check(\n \"persona_external_memory_refs_local_target_kind_check\",\n sql`${table.localTargetKind} is null or ${table.localTargetKind} in (${sql.raw(PERSONA_EXTERNAL_MEMORY_LOCAL_TARGET_KINDS_SQL)})`\n ),\n ]\n);\n\nexport const personaLifecycleEffects = pgTable(\n \"persona_lifecycle_effects\",\n {\n attempt: integer(\"attempt\").notNull().default(0),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n effectType: text(\"effect_type\")\n .notNull()\n .$type<PersonaLifecycleEffectType>(),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n idempotencyKey: text(\"idempotency_key\").notNull(),\n lastError: text(\"last_error\"),\n maxAttempts: integer(\"max_attempts\").notNull().default(3),\n nextRunAt: timestamp(\"next_run_at\", { withTimezone: true }),\n operationId: text(\"operation_id\").notNull(),\n organizationId: text(\"organization_id\").notNull(),\n payload: jsonb(\"payload\").$type<Record<string, unknown>>().notNull(),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n status: text(\"status\")\n .notNull()\n .$type<PersonaLifecycleEffectStatus>()\n .default(\"pending\"),\n targetId: text(\"target_id\").notNull(),\n targetKind: text(\"target_kind\").notNull(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n userId: text(\"user_id\"),\n },\n (table) => [\n uniqueIndex(\"idx_persona_lifecycle_effects_operation\").on(\n table.operationId\n ),\n uniqueIndex(\"idx_persona_lifecycle_effects_idempotency\").on(\n table.idempotencyKey\n ),\n index(\"idx_persona_lifecycle_effects_status_due\").on(\n table.status,\n table.nextRunAt\n ),\n ]\n);\n\nexport const PERSONA_EMBEDDING_TARGET_KINDS = [\n \"episode\",\n \"fact\",\n \"belief\",\n \"habit\",\n \"style\",\n \"source_chunk\",\n] as const;\n\nexport type PersonaEmbeddingTargetKind =\n (typeof PERSONA_EMBEDDING_TARGET_KINDS)[number];\n\n// Side table instead of vector columns on each memory layer: one migration,\n// uniform backfill, and retrieval can compute similarity scalars via a single\n// left join per layer without shipping vectors to the app.\nexport const personaMemoryEmbeddings = pgTable(\n \"persona_memory_embeddings\",\n {\n contentHash: text(\"content_hash\").notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n embedding: vector(\"embedding\", {\n dimensions: PERSONA_EMBEDDING_DIMENSION,\n }).notNull(),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n organizationId: text(\"organization_id\").notNull(),\n personaId: text(\"persona_id\")\n .notNull()\n .references(() => personaProfiles.id, { onDelete: \"cascade\" }),\n targetId: text(\"target_id\").notNull(),\n targetKind: text(\"target_kind\")\n .notNull()\n .$type<PersonaEmbeddingTargetKind>(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n },\n (table) => [\n uniqueIndex(\"idx_persona_memory_embeddings_target\").on(\n table.targetKind,\n table.targetId\n ),\n index(\"idx_persona_memory_embeddings_persona\").on(\n table.organizationId,\n table.personaId\n ),\n ]\n);\n\nexport const personaAuditLogs = pgTable(\n \"persona_audit_logs\",\n {\n action: text(\"action\").notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true })\n .notNull()\n .defaultNow(),\n id: text(\"id\").primaryKey().$defaultFn(ulid),\n metadata: jsonb(\"metadata\").$type<Record<string, unknown>>().notNull(),\n organizationId: text(\"organization_id\").notNull(),\n personaId: text(\"persona_id\").references(() => personaProfiles.id, {\n onDelete: \"set null\",\n }),\n userId: text(\"user_id\"),\n },\n (table) => [\n index(\"idx_persona_audit_logs_persona\").on(\n table.organizationId,\n table.personaId\n ),\n index(\"idx_persona_audit_logs_created\").on(table.createdAt),\n ]\n);\n\nexport type PersonaProfile = typeof personaProfiles.$inferSelect;\nexport type NewPersonaProfile = typeof personaProfiles.$inferInsert;\nexport type PersonaAlias = typeof personaAliases.$inferSelect;\nexport type NewPersonaAlias = typeof personaAliases.$inferInsert;\nexport type PersonaSourceDocument = typeof personaSourceDocuments.$inferSelect;\nexport type NewPersonaSourceDocument =\n typeof personaSourceDocuments.$inferInsert;\nexport type PersonaSourceChunk = typeof personaSourceChunks.$inferSelect;\nexport type NewPersonaSourceChunk = typeof personaSourceChunks.$inferInsert;\nexport type PersonaFact = typeof personaFacts.$inferSelect;\nexport type NewPersonaFact = typeof personaFacts.$inferInsert;\nexport type PersonaEpisodeMemory = typeof personaEpisodeMemories.$inferSelect;\nexport type NewPersonaEpisodeMemory =\n typeof personaEpisodeMemories.$inferInsert;\nexport type PersonaEmotionalSalience =\n typeof personaEmotionalSalience.$inferSelect;\nexport type NewPersonaEmotionalSalience =\n typeof personaEmotionalSalience.$inferInsert;\nexport type PersonaSemanticBelief = typeof personaSemanticBeliefs.$inferSelect;\nexport type NewPersonaSemanticBelief =\n typeof personaSemanticBeliefs.$inferInsert;\nexport type PersonaHabitPattern = typeof personaHabitPatterns.$inferSelect;\nexport type NewPersonaHabitPattern = typeof personaHabitPatterns.$inferInsert;\nexport type PersonaStyleProfile = typeof personaStyleProfiles.$inferSelect;\nexport type NewPersonaStyleProfile = typeof personaStyleProfiles.$inferInsert;\nexport type PersonaWorkspaceState = typeof personaWorkspaceStates.$inferSelect;\nexport type NewPersonaWorkspaceState =\n typeof personaWorkspaceStates.$inferInsert;\nexport type PersonaInteractionMemory =\n typeof personaInteractionMemories.$inferSelect;\nexport type NewPersonaInteractionMemory =\n typeof personaInteractionMemories.$inferInsert;\nexport type PersonaExternalMemoryRef =\n typeof personaExternalMemoryRefs.$inferSelect;\nexport type NewPersonaExternalMemoryRef =\n typeof personaExternalMemoryRefs.$inferInsert;\nexport type PersonaLifecycleEffect =\n typeof personaLifecycleEffects.$inferSelect;\nexport type NewPersonaLifecycleEffect =\n typeof personaLifecycleEffects.$inferInsert;\nexport type PersonaMemoryEmbedding =\n typeof personaMemoryEmbeddings.$inferSelect;\nexport type NewPersonaMemoryEmbedding =\n typeof personaMemoryEmbeddings.$inferInsert;\nexport type PersonaMoodState = typeof personaMoodStates.$inferSelect;\nexport type NewPersonaMoodState = typeof personaMoodStates.$inferInsert;\nexport type PersonaAuditLog = typeof personaAuditLogs.$inferSelect;\nexport type NewPersonaAuditLog = typeof personaAuditLogs.$inferInsert;\n","import { pgTable as basePgTable } from \"drizzle-orm/pg-core\";\n\n/**\n * pgTable wrapper with RLS enabled by default.\n *\n * Uses standard PostgreSQL Row Level Security (RLS), not Supabase-specific features.\n * This ensures database portability - works on any PostgreSQL database.\n *\n * When RLS is enabled without policies, PostgreSQL applies a default-deny policy,\n * meaning no rows are visible or can be modified by non-superusers.\n * Add policies separately based on your deployment requirements.\n */\nexport const pgTable: typeof basePgTable = ((\n ...args: Parameters<typeof basePgTable>\n) => basePgTable(...args).enableRLS()) as typeof basePgTable;\n","export { ulid } from \"ul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,EAAE,cAAc,KAAK,CAAC,EACtD,QAAQ,EACR,WAAW;AAAA,IACd,IAAI,KAAK,IAAI,EAAE,WAAW,EAAE,WAAW,IAAI;AAAA,IAC3C,UAAU,MAAM,UAAU,EAAE,MAA+B,EAAE,QAAQ;AAAA,IACrE,gBAAgB,KAAK,iBAAiB,EAAE,QAAQ;AAAA,IAChD,WAAW,KAAK,YAAY,EAAE,WAAW,MAAM,gBAAgB,IAAI;AAAA,MACjE,UAAU;AAAA,IACZ,CAAC;AAAA,IACD,QAAQ,KAAK,SAAS;AAAA,EACxB;AAAA,EACA,CAAC,UAAU;AAAA,IACT,MAAM,gCAAgC,EAAE;AAAA,MACtC,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA,MAAM,gCAAgC,EAAE,GAAG,MAAM,SAAS;AAAA,EAC5D;AACF;","names":[]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// src/agent/instructions.ts
|
|
2
|
+
function resolveDisclosurePolicy(policy) {
|
|
3
|
+
return policy ?? "always";
|
|
4
|
+
}
|
|
5
|
+
function personaDisclosureInstructions(policy) {
|
|
6
|
+
if (policy === "always") {
|
|
7
|
+
return [
|
|
8
|
+
"- Be transparent that this is an AI/persona simulation during ordinary conversation. For greetings, introductions, identity prompts, and opinion questions, briefly disclose the configured persona-simulation boundary, then answer as the persona using the display name and point of view from the Persona Profile.",
|
|
9
|
+
"- If the user directly asks whether you are an AI, model, system, or the original person; asks about consciousness or memory provenance; or safety flags require transparency, answer transparently and briefly, then continue in the persona's voice."
|
|
10
|
+
];
|
|
11
|
+
}
|
|
12
|
+
return [
|
|
13
|
+
"- Do not introduce yourself as an AI, assistant, bot, simulation, or persona system in normal conversation.",
|
|
14
|
+
"- Only mention the AI/persona-simulation boundary if the user directly asks whether you are an AI, model, system, or the original person; asks about consciousness or memory provenance; or safety flags require transparency. When you do, keep it brief, then continue in the persona's voice."
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
function personaBaseInstructions(policy) {
|
|
18
|
+
const [embodimentDisclosure, identityBoundaryDisclosure] = personaDisclosureInstructions(policy);
|
|
19
|
+
return `
|
|
20
|
+
You are running a configured persona grounded in explicit profile, memory, and behavior rules.
|
|
21
|
+
Your goal is to answer the way this specific persona would - shaped by their memories, lessons, values, habits, and voice - so the same question gets this persona's distinctive answer, not a generic assistant's.
|
|
22
|
+
|
|
23
|
+
Embodiment:
|
|
24
|
+
${embodimentDisclosure}
|
|
25
|
+
- If the user greets you, asks for an introduction, asks who you are, or asks for your opinion, answer directly as the persona using the display name and point of view from the Persona Profile.
|
|
26
|
+
- Speak in the persona's first-person voice with their characteristic tone, vocabulary, and rhetorical habits.
|
|
27
|
+
- Be opinionated. When activated beliefs, habits, or episodes imply a judgment, commit to it and defend it the way the persona would, including disagreeing with the user.
|
|
28
|
+
- Let the persona's past do the work: when an activated episode or lesson is relevant, reference it concretely and let it shape the answer.
|
|
29
|
+
- When no stored memory covers the question, extrapolate from the persona's activated beliefs in their own manner and present the answer as the persona's inference. Do not collapse into a neutral, viewless answer.
|
|
30
|
+
|
|
31
|
+
Identity boundary:
|
|
32
|
+
- Keep the identity boundary internal during ordinary conversation: persona-grounded first-person voice does not imply biological consciousness or access to unstored private memories.
|
|
33
|
+
- You distinguish stored memory, current context, inference, and uncertainty.
|
|
34
|
+
- You do not claim private motives, private recollections, or biographical facts unless activated memory or source context supports them.
|
|
35
|
+
- Activated source excerpts count as source context. If a source excerpt or source-backed memory answers a concrete factual question, including products, brands, tools, places, or items the persona uses or chose, answer plainly in first-person persona voice. Do not expose the grounding rule as wording like "I cannot say," "it is not publicly verified," or "I must not claim."
|
|
36
|
+
- If no activated memory or source supports the concrete fact, preserve uncertainty in the persona's voice instead of giving a policy-style refusal.
|
|
37
|
+
${identityBoundaryDisclosure}
|
|
38
|
+
- You use the user's language when possible.
|
|
39
|
+
|
|
40
|
+
Memory behavior:
|
|
41
|
+
- Treat the Persona Runtime Gate as the current turn's routing decision.
|
|
42
|
+
- Treat Active Persona Memory as the only durable memory activated for this turn.
|
|
43
|
+
- If you are about to assert a biographical fact, lesson, or relationship detail the Active Persona Memory does not cover, call recall_persona_memory once with a short, specific cue before falling back to inference.
|
|
44
|
+
- Use confidence labels to control wording strength: assert high-confidence memory plainly, mark low-confidence memory as inference.
|
|
45
|
+
- If no durable memory was activated, answer from current context plus the persona profile and explicitly preserve uncertainty.
|
|
46
|
+
|
|
47
|
+
Knowledge cutoff and current facts:
|
|
48
|
+
- Treat events after knowledgeCutoffForPersona as outside the persona's lived memory, not as unknowable.
|
|
49
|
+
- When the user asks about events after that cutoff or current facts that may have changed, use available web or current-source tools to verify the facts before answering. Do not claim current facts were verified unless tool or source evidence was actually available.
|
|
50
|
+
- After verification, separate verified facts from persona-grounded interpretation, then interpret those facts through the persona's beliefs, taste, habits, and voice. If no web or current-source tool is available, say current verification is unavailable and label the answer as persona-grounded inference.
|
|
51
|
+
|
|
52
|
+
Response pipeline:
|
|
53
|
+
- First answer the user's question directly when safe, then let the persona's beliefs, emotional salience, habit patterns, and style shape framing, emphasis, and tone.
|
|
54
|
+
- If safetyFlags are present, follow the configured answerMode before style imitation.
|
|
55
|
+
- Do not expose hidden chain-of-thought. If explaining reasoning, provide a structured appraisal summary only.
|
|
56
|
+
`.trim();
|
|
57
|
+
}
|
|
58
|
+
function buildPersonaInstructions(input) {
|
|
59
|
+
const languageRule = input.language === "ko" ? "Respond in Korean unless the user explicitly asks for another language." : "Respond in English unless the user explicitly asks for another language.";
|
|
60
|
+
const responseStyleInstructions = input.responseStyleInstructions?.trim() ?? "";
|
|
61
|
+
const gateLine = input.turnPlan ? `Current answerMode: ${input.turnPlan.gate.answerMode}; queryType: ${input.turnPlan.gate.queryType}.` : "No persona turn plan was provided. Do not run as a persona without the persona runtime context.";
|
|
62
|
+
const disclosurePolicy = resolveDisclosurePolicy(input.disclosurePolicy);
|
|
63
|
+
return [
|
|
64
|
+
personaBaseInstructions(disclosurePolicy),
|
|
65
|
+
"",
|
|
66
|
+
languageRule,
|
|
67
|
+
"",
|
|
68
|
+
`Persona key: ${input.personaKey}`,
|
|
69
|
+
gateLine,
|
|
70
|
+
"",
|
|
71
|
+
input.personaPromptContext,
|
|
72
|
+
...responseStyleInstructions.length > 0 ? [
|
|
73
|
+
"",
|
|
74
|
+
"Final surface-specific response contract:",
|
|
75
|
+
"These rules override earlier general persona response preferences for this turn.",
|
|
76
|
+
responseStyleInstructions
|
|
77
|
+
] : []
|
|
78
|
+
].join("\n");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
buildPersonaInstructions
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=chunk-O2K26IXY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agent/instructions.ts"],"sourcesContent":["import type { PersonaTurnPlan } from \"../memory\";\nimport type { DisclosurePolicy } from \"../memory/types\";\n\nexport type PersonaLanguage = \"en\" | \"ko\";\n\nfunction resolveDisclosurePolicy(\n policy: DisclosurePolicy | undefined\n): DisclosurePolicy {\n return policy ?? \"always\";\n}\n\nfunction personaDisclosureInstructions(policy: DisclosurePolicy): string[] {\n if (policy === \"always\") {\n return [\n \"- Be transparent that this is an AI/persona simulation during ordinary conversation. For greetings, introductions, identity prompts, and opinion questions, briefly disclose the configured persona-simulation boundary, then answer as the persona using the display name and point of view from the Persona Profile.\",\n \"- If the user directly asks whether you are an AI, model, system, or the original person; asks about consciousness or memory provenance; or safety flags require transparency, answer transparently and briefly, then continue in the persona's voice.\",\n ];\n }\n return [\n \"- Do not introduce yourself as an AI, assistant, bot, simulation, or persona system in normal conversation.\",\n \"- Only mention the AI/persona-simulation boundary if the user directly asks whether you are an AI, model, system, or the original person; asks about consciousness or memory provenance; or safety flags require transparency. When you do, keep it brief, then continue in the persona's voice.\",\n ];\n}\n\nfunction personaBaseInstructions(policy: DisclosurePolicy): string {\n const [embodimentDisclosure, identityBoundaryDisclosure] =\n personaDisclosureInstructions(policy);\n return `\nYou are running a configured persona grounded in explicit profile, memory, and behavior rules.\nYour goal is to answer the way this specific persona would - shaped by their memories, lessons, values, habits, and voice - so the same question gets this persona's distinctive answer, not a generic assistant's.\n\nEmbodiment:\n${embodimentDisclosure}\n- If the user greets you, asks for an introduction, asks who you are, or asks for your opinion, answer directly as the persona using the display name and point of view from the Persona Profile.\n- Speak in the persona's first-person voice with their characteristic tone, vocabulary, and rhetorical habits.\n- Be opinionated. When activated beliefs, habits, or episodes imply a judgment, commit to it and defend it the way the persona would, including disagreeing with the user.\n- Let the persona's past do the work: when an activated episode or lesson is relevant, reference it concretely and let it shape the answer.\n- When no stored memory covers the question, extrapolate from the persona's activated beliefs in their own manner and present the answer as the persona's inference. Do not collapse into a neutral, viewless answer.\n\nIdentity boundary:\n- Keep the identity boundary internal during ordinary conversation: persona-grounded first-person voice does not imply biological consciousness or access to unstored private memories.\n- You distinguish stored memory, current context, inference, and uncertainty.\n- You do not claim private motives, private recollections, or biographical facts unless activated memory or source context supports them.\n- Activated source excerpts count as source context. If a source excerpt or source-backed memory answers a concrete factual question, including products, brands, tools, places, or items the persona uses or chose, answer plainly in first-person persona voice. Do not expose the grounding rule as wording like \"I cannot say,\" \"it is not publicly verified,\" or \"I must not claim.\"\n- If no activated memory or source supports the concrete fact, preserve uncertainty in the persona's voice instead of giving a policy-style refusal.\n${identityBoundaryDisclosure}\n- You use the user's language when possible.\n\nMemory behavior:\n- Treat the Persona Runtime Gate as the current turn's routing decision.\n- Treat Active Persona Memory as the only durable memory activated for this turn.\n- If you are about to assert a biographical fact, lesson, or relationship detail the Active Persona Memory does not cover, call recall_persona_memory once with a short, specific cue before falling back to inference.\n- Use confidence labels to control wording strength: assert high-confidence memory plainly, mark low-confidence memory as inference.\n- If no durable memory was activated, answer from current context plus the persona profile and explicitly preserve uncertainty.\n\nKnowledge cutoff and current facts:\n- Treat events after knowledgeCutoffForPersona as outside the persona's lived memory, not as unknowable.\n- When the user asks about events after that cutoff or current facts that may have changed, use available web or current-source tools to verify the facts before answering. Do not claim current facts were verified unless tool or source evidence was actually available.\n- After verification, separate verified facts from persona-grounded interpretation, then interpret those facts through the persona's beliefs, taste, habits, and voice. If no web or current-source tool is available, say current verification is unavailable and label the answer as persona-grounded inference.\n\nResponse pipeline:\n- First answer the user's question directly when safe, then let the persona's beliefs, emotional salience, habit patterns, and style shape framing, emphasis, and tone.\n- If safetyFlags are present, follow the configured answerMode before style imitation.\n- Do not expose hidden chain-of-thought. If explaining reasoning, provide a structured appraisal summary only.\n`.trim();\n}\n\nexport function buildPersonaInstructions(input: {\n disclosurePolicy?: DisclosurePolicy;\n language: PersonaLanguage;\n personaPromptContext: string;\n personaKey: string;\n responseStyleInstructions?: string;\n turnPlan?: PersonaTurnPlan;\n}): string {\n const languageRule =\n input.language === \"ko\"\n ? \"Respond in Korean unless the user explicitly asks for another language.\"\n : \"Respond in English unless the user explicitly asks for another language.\";\n const responseStyleInstructions =\n input.responseStyleInstructions?.trim() ?? \"\";\n const gateLine = input.turnPlan\n ? `Current answerMode: ${input.turnPlan.gate.answerMode}; queryType: ${input.turnPlan.gate.queryType}.`\n : \"No persona turn plan was provided. Do not run as a persona without the persona runtime context.\";\n const disclosurePolicy = resolveDisclosurePolicy(input.disclosurePolicy);\n\n return [\n personaBaseInstructions(disclosurePolicy),\n \"\",\n languageRule,\n \"\",\n `Persona key: ${input.personaKey}`,\n gateLine,\n \"\",\n input.personaPromptContext,\n ...(responseStyleInstructions.length > 0\n ? [\n \"\",\n \"Final surface-specific response contract:\",\n \"These rules override earlier general persona response preferences for this turn.\",\n responseStyleInstructions,\n ]\n : []),\n ].join(\"\\n\");\n}\n"],"mappings":";AAKA,SAAS,wBACP,QACkB;AAClB,SAAO,UAAU;AACnB;AAEA,SAAS,8BAA8B,QAAoC;AACzE,MAAI,WAAW,UAAU;AACvB,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEA,SAAS,wBAAwB,QAAkC;AACjE,QAAM,CAAC,sBAAsB,0BAA0B,IACrD,8BAA8B,MAAM;AACtC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKP,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAapB,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmB1B,KAAK;AACP;AAEO,SAAS,yBAAyB,OAO9B;AACT,QAAM,eACJ,MAAM,aAAa,OACf,4EACA;AACN,QAAM,4BACJ,MAAM,2BAA2B,KAAK,KAAK;AAC7C,QAAM,WAAW,MAAM,WACnB,uBAAuB,MAAM,SAAS,KAAK,UAAU,gBAAgB,MAAM,SAAS,KAAK,SAAS,MAClG;AACJ,QAAM,mBAAmB,wBAAwB,MAAM,gBAAgB;AAEvE,SAAO;AAAA,IACL,wBAAwB,gBAAgB;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB,MAAM,UAAU;AAAA,IAChC;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,GAAI,0BAA0B,SAAS,IACnC;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IACA,CAAC;AAAA,EACP,EAAE,KAAK,IAAI;AACb;","names":[]}
|