@happyvertical/smrt-personas 0.51.31 → 0.51.33

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.
@@ -1,3 +1,20 @@
1
+ /**
2
+ * AgentPersona - Tenant-owned, context-scoped persona for an agent class.
3
+ *
4
+ * A persona layers behavioral configuration on top of a {@link TenantAgent}
5
+ * binding (from `@happyvertical/smrt-agents`). Where `TenantAgent` answers
6
+ * "is this agent available for the tenant, and what is its capability ceiling",
7
+ * an `AgentPersona` answers "how should this agent behave for this tenant in
8
+ * this context" — its instructions, allowed tools, run-as principal, acting
9
+ * identity, and memory scope.
10
+ *
11
+ * There can be many personas per `(tenant, agentClass)` — one per context
12
+ * (e.g. a site, property, or chat room) plus optional tenant-wide defaults.
13
+ * Personas are unique on `(tenant_id, agent_class, name)`.
14
+ *
15
+ * Resolution (context + hierarchy + priority) lives in {@link PersonaResolver};
16
+ * this class is the persisted record and its CRUD collection only.
17
+ */
1
18
  import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
19
  /**
3
20
  * Return the canonical agent type identifier for storage and lookup.
@@ -1,9 +1,29 @@
1
- import { PromptOverride } from '@happyvertical/smrt-prompts';
2
- import { DatabaseInterface } from '@happyvertical/sql';
1
+ /**
2
+ * DirectiveApprovalService — the human-in-the-loop gate (#1889).
3
+ *
4
+ * The review queue's write side. A reviewer who holds the
5
+ * `personas.activate-directive` permission can **approve** (optionally editing
6
+ * the text), or **reject**, a pending {@link DirectiveProposal}:
7
+ *
8
+ * - **approve** activates the persona-scoped `prompt_override` (through
9
+ * `PromptOverride.save()`, so a non-editable prompt template is refused by
10
+ * `validatePromptOverride`) and records an `accept` signal.
11
+ * - **reject** records a `reject` signal and closes the proposal so the
12
+ * reflection runner never re-surfaces the same rewrite (it dedups on
13
+ * fingerprint against non-pending proposals too).
14
+ *
15
+ * The gate is purely the permission check: an actor lacking the slug — the
16
+ * autonomous reflection principal included — is denied before anything is
17
+ * written. Confidence-only reinforcement is unaffected; it never passes here.
18
+ *
19
+ * @module
20
+ */
21
+ import type { PromptOverride } from '@happyvertical/smrt-prompts';
22
+ import type { DatabaseInterface } from '@happyvertical/sql';
3
23
  import { AgentPersonaCollection } from './agent-persona.js';
4
- import { DirectivePrincipal } from './directive-principal.js';
24
+ import { type DirectivePrincipal } from './directive-principal.js';
5
25
  import { DirectiveProposal, DirectiveProposalCollection } from './directive-proposal.js';
6
- import { Feedback, FeedbackCollection } from './feedback.js';
26
+ import { type Feedback, FeedbackCollection } from './feedback.js';
7
27
  /** Raised when a principal without the activation permission attempts to review. */
8
28
  export declare class DirectiveActivationDeniedError extends Error {
9
29
  constructor(message?: string);
@@ -1,4 +1,22 @@
1
- import { PermissionDefinition, PermissionResolver } from '@happyvertical/smrt-users';
1
+ /**
2
+ * The permission split that gates persona directive activation (#1889).
3
+ *
4
+ * **The gate is the permission system, not a bespoke subsystem.** Activating a
5
+ * directive — writing/enabling the persona-scoped `prompt_override` — is a
6
+ * permissioned operation guarded by the `personas.activate-directive` slug. The
7
+ * autonomous reflection principal runs *without* that permission, so it can only
8
+ * propose; a human who holds it approves / edits / rejects. Confidence-only
9
+ * reinforcement stays automatic; only instruction rewrites are gated.
10
+ *
11
+ * This module contributes the slug to the manifest-derived permission catalog
12
+ * (via `registerPermissionDefinitions`) and provides a small
13
+ * {@link DirectivePrincipal} abstraction over "which permission slugs does this
14
+ * actor hold". In production the principal is built from a
15
+ * `PermissionResolver.resolvePermissions()` result; tests inject one directly.
16
+ *
17
+ * @module
18
+ */
19
+ import { type PermissionDefinition, type PermissionResolver } from '@happyvertical/smrt-users';
2
20
  /** The permission slug that authorises activating a persona directive. */
3
21
  export declare const ACTIVATE_DIRECTIVE_PERMISSION = "personas.activate-directive";
4
22
  /** Catalog definition contributed for {@link ACTIVATE_DIRECTIVE_PERMISSION}. */
@@ -1,3 +1,19 @@
1
+ /**
2
+ * DirectiveProposal — a pending, human-reviewable edit to a persona's
3
+ * instructions (#1889).
4
+ *
5
+ * The autonomous {@link ReflectionRunner} consolidates recent episodes and
6
+ * {@link Feedback} into candidate rewrites of a persona's instructions and
7
+ * records each as a pending `DirectiveProposal` (rationale + evidence). A
8
+ * proposal is inert data: it changes nothing until a human who holds the
9
+ * `personas.activate-directive` permission approves it through the review
10
+ * queue, at which point the persona-scoped `prompt_override` is written.
11
+ *
12
+ * The reflection principal deliberately lacks that permission, so it can only
13
+ * *propose* — the permission split is the gate. See {@link DirectiveApprovalService}.
14
+ *
15
+ * @module
16
+ */
1
17
  import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
18
  /**
3
19
  * Lifecycle status of a proposal:
@@ -1,4 +1,24 @@
1
- import { LearningOutcome, SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
1
+ /**
2
+ * Feedback — reinforcement signals for a persona's learning loop (#1889).
3
+ *
4
+ * A `Feedback` row captures one reinforcement signal against a persona and the
5
+ * `LearningMemory` episode it pertains to. Two families of signal are modelled:
6
+ *
7
+ * - **Human signals** — `accept` / `reject` / `correction` / `rating`: an
8
+ * operator's judgement on an agent's behaviour.
9
+ * - **Autonomous signals** — `outcome` / `metric`: a machine-observed result
10
+ * (a boolean success or a numeric measurement) captured without a human.
11
+ *
12
+ * Every signal carries a **correlation-id** back to the thing it judges — the
13
+ * AI call, dispatch, or job whose result prompted the feedback — so a signal
14
+ * can always be traced to its cause. Signals feed the confidence-scored
15
+ * reinforcement in {@link LearningMemory} (#1886) via {@link toLearningOutcome}:
16
+ * this is the automatic, confidence-only half of the loop. The gated half —
17
+ * rewriting a persona's instructions — lives in the directive-proposal flow.
18
+ *
19
+ * @module
20
+ */
21
+ import { type LearningOutcome, SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
22
  /**
3
23
  * The kind of reinforcement signal a {@link Feedback} row carries.
4
24
  *
package/dist/index.d.ts CHANGED
@@ -1,3 +1,19 @@
1
+ /**
2
+ * @happyvertical/smrt-personas
3
+ *
4
+ * Tenant-owned, context-scoped agent personas and their resolution. Layers over
5
+ * `@happyvertical/smrt-agents`' `TenantAgent` availability/ceiling gate to
6
+ * decide how an agent should behave for a given tenant and context.
7
+ *
8
+ * Also home to the persona **learning & adaptation loop** (#1889): feedback
9
+ * signals feed confidence-scored reinforcement, a scheduled reflection runner
10
+ * consolidates episodes + feedback into pending directive proposals, and a
11
+ * permission-gated approval service (the `personas.activate-directive` split)
12
+ * activates an approved rewrite as a tenant/persona-scoped prompt override.
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+ import './__smrt-register__.js';
1
17
  export { AgentPersona, AgentPersonaCollection, canonicalAgentClass, personaAppliesToContext, personaContextRank, } from './agent-persona.js';
2
18
  export { DirectiveActivationDeniedError, type DirectiveApprovalResult, DirectiveApprovalService, type DirectiveApprovalServiceOptions, DirectiveNotPendingError, type DirectiveRejectionResult, type ProposalRef, } from './directive-approval.js';
3
19
  export { ACTIVATE_DIRECTIVE_PERMISSION, DIRECTIVE_ACTIVATION_PERMISSION_DEF, type DirectivePrincipal, ensurePersonaPermissionsRegistered, principalFromPermissions, registerPersonaPermissions, resolveDirectivePrincipal, } from './directive-principal.js';
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { PromptOverrideCollection, PromptRegistry, definePrompt, resolvePrompt }
5
5
  import { instanceScopedSubscriber } from "@happyvertical/smrt-agents";
6
6
  import { PersonaMessagingService, SEND_MESSAGES_PERMISSION, messagingPrincipalFromPermissions } from "@happyvertical/smrt-messages";
7
7
  //#region src/__smrt-register__.ts
8
- ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":0,\"packageName\":\"@happyvertical/smrt-personas\",\"packageVersion\":\"0.51.31\",\"objects\":{\"@happyvertical/smrt-personas:AgentPersona\":{\"name\":\"agentpersona\",\"className\":\"AgentPersona\",\"qualifiedName\":\"@happyvertical/smrt-personas:AgentPersona\",\"collection\":\"agentpersonas\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/personas/src/agent-persona.ts\",\"packageName\":\"@happyvertical/smrt-personas\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":true,\"autoPopulate\":true,\"nullable\":false,\"mode\":\"required\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"agentClass\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"name\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"contextType\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"contextId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"instructions\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"allowedTools\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"runAsUserId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-users:User\"},\"actsAsProfileId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-profiles:Profile\",\"_meta\":{\"nullable\":true}},\"memoryScope\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"priority\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"enabled\":{\"type\":\"boolean\",\"required\":false,\"_meta\":{}}},\"methods\":{\"getAllowedTools\":{\"name\":\"getAllowedTools\",\"async\":false,\"parameters\":[],\"returnType\":\"string[]\",\"isStatic\":false,\"isPublic\":true},\"setAllowedTools\":{\"name\":\"setAllowedTools\",\"async\":false,\"parameters\":[{\"name\":\"tools\",\"type\":\"string[]\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_personas\",\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\"]},\"cli\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"conflictColumns\":[\"tenant_id\",\"agent_class\",\"name\"],\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"AgentPersona\",\"collectionExportName\":\"AgentPersonaCollection\",\"validationRules\":[{\"field\":\"runAsUserId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"}],\"schema\":{\"tableName\":\"agent_personas\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"agent_personas\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID NOT NULL,\\n \\\"agent_class\\\" TEXT,\\n \\\"name\\\" TEXT DEFAULT '',\\n \\\"context_type\\\" TEXT,\\n \\\"context_id\\\" TEXT,\\n \\\"instructions\\\" TEXT,\\n \\\"allowed_tools\\\" TEXT,\\n \\\"run_as_user_id\\\" UUID NOT NULL,\\n \\\"acts_as_profile_id\\\" UUID,\\n \\\"memory_scope\\\" TEXT,\\n \\\"priority\\\" INTEGER DEFAULT 0,\\n \\\"enabled\\\" BOOLEAN\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"context_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"context_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"instructions\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"allowed_tools\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"run_as_user_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"acts_as_profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":false,\"unique\":false},\"memory_scope\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"priority\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"enabled\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"agent_personas_tenant_id_agent_class_idx\",\"columns\":[\"tenant_id\",\"agent_class\",\"name\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"agent_personas_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"agent_personas_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"agent_personas_run_as_user_id_idx\",\"columns\":[\"run_as_user_id\"]},{\"name\":\"agent_personas_acts_as_profile_id_idx\",\"columns\":[\"acts_as_profile_id\"]}],\"version\":\"71e955ef\"},\"importPath\":\"@happyvertical/smrt-personas\"},\"@happyvertical/smrt-personas:AgentPersonaCollection\":{\"name\":\"agentpersonacollection\",\"className\":\"AgentPersonaCollection\",\"qualifiedName\":\"@happyvertical/smrt-personas:AgentPersonaCollection\",\"collection\":\"agentpersonas\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/personas/src/agent-persona.ts\",\"packageName\":\"@happyvertical/smrt-personas\",\"fields\":{},\"methods\":{\"byTenantAndClass\":{\"name\":\"byTenantAndClass\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"agentClass\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AgentPersona[]>\",\"isStatic\":false,\"isPublic\":true},\"findActive\":{\"name\":\"findActive\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"agentClass\",\"type\":\"string\",\"optional\":false},{\"name\":\"context\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"string | null\"]}],\"returnType\":\"Promise<AgentPersona[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_personas\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"AgentPersona\",\"exportName\":\"AgentPersonaCollection\",\"collectionExportName\":\"AgentPersonaCollectionCollection\",\"schema\":{\"tableName\":\"agent_personas\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"agent_personas\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID NOT NULL,\\n \\\"agent_class\\\" TEXT,\\n \\\"name\\\" TEXT DEFAULT '',\\n \\\"context_type\\\" TEXT,\\n \\\"context_id\\\" TEXT,\\n \\\"instructions\\\" TEXT,\\n \\\"allowed_tools\\\" TEXT,\\n \\\"run_as_user_id\\\" UUID NOT NULL,\\n \\\"acts_as_profile_id\\\" UUID,\\n \\\"memory_scope\\\" TEXT,\\n \\\"priority\\\" INTEGER DEFAULT 0,\\n \\\"enabled\\\" BOOLEAN\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"context_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"context_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"instructions\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"allowed_tools\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"run_as_user_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"acts_as_profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":false,\"unique\":false},\"memory_scope\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"priority\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"enabled\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"agent_personas_tenant_id_agent_class_idx\",\"columns\":[\"tenant_id\",\"agent_class\",\"name\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"agent_personas_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"agent_personas_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"agent_personas_run_as_user_id_idx\",\"columns\":[\"run_as_user_id\"]},{\"name\":\"agent_personas_acts_as_profile_id_idx\",\"columns\":[\"acts_as_profile_id\"]}],\"version\":\"71e955ef\"},\"importPath\":\"@happyvertical/smrt-personas\"},\"@happyvertical/smrt-personas:DirectiveProposal\":{\"name\":\"directiveproposal\",\"className\":\"DirectiveProposal\",\"qualifiedName\":\"@happyvertical/smrt-personas:DirectiveProposal\",\"collection\":\"directiveproposals\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/personas/src/directive-proposal.ts\",\"packageName\":\"@happyvertical/smrt-personas\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":true,\"autoPopulate\":true,\"nullable\":false,\"mode\":\"required\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"personaId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"AgentPersona\",\"_meta\":{\"required\":true}},\"agentClass\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"promptKey\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"proposedInstructions\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"currentInstructions\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"rationale\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"evidence\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"status\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"fingerprint\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"confidence\":{\"type\":\"decimal\",\"required\":false,\"default\":0},\"proposedBy\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"reviewedBy\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"reviewedAt\":{\"type\":\"datetime\",\"required\":false,\"_meta\":{\"nullable\":true}},\"reviewNote\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"activatedOverrideId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}}},\"methods\":{\"getEvidence\":{\"name\":\"getEvidence\",\"async\":false,\"parameters\":[],\"returnType\":\"DirectiveEvidence\",\"isStatic\":false,\"isPublic\":true},\"setEvidence\":{\"name\":\"setEvidence\",\"async\":false,\"parameters\":[{\"name\":\"value\",\"type\":\"DirectiveEvidence\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"isPending\":{\"name\":\"isPending\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"directive_proposals\",\"api\":{\"include\":[\"list\",\"get\"]},\"cli\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"tenantScoped\":{\"mode\":\"required\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"DirectiveProposal\",\"collectionExportName\":\"DirectiveProposalCollection\",\"validationRules\":[{\"field\":\"personaId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"}],\"schema\":{\"tableName\":\"directive_proposals\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"directive_proposals\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID NOT NULL,\\n \\\"persona_id\\\" UUID NOT NULL,\\n \\\"agent_class\\\" TEXT,\\n \\\"prompt_key\\\" TEXT,\\n \\\"proposed_instructions\\\" TEXT,\\n \\\"current_instructions\\\" TEXT,\\n \\\"rationale\\\" TEXT,\\n \\\"evidence\\\" TEXT,\\n \\\"status\\\" TEXT,\\n \\\"fingerprint\\\" TEXT,\\n \\\"confidence\\\" REAL DEFAULT 0,\\n \\\"proposed_by\\\" TEXT,\\n \\\"reviewed_by\\\" TEXT,\\n \\\"reviewed_at\\\" TIMESTAMP,\\n \\\"review_note\\\" TEXT,\\n \\\"activated_override_id\\\" TEXT\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"persona_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false,\"foreignKey\":{\"table\":\"agent_personas\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"prompt_key\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"proposed_instructions\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"current_instructions\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"rationale\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"evidence\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"fingerprint\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"confidence\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"proposed_by\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"reviewed_by\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"reviewed_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"review_note\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"activated_override_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"directive_proposals_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true},{\"name\":\"directive_proposals_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"directive_proposals_persona_id_idx\",\"columns\":[\"persona_id\"]}],\"version\":\"96be8911\"},\"importPath\":\"@happyvertical/smrt-personas\"},\"@happyvertical/smrt-personas:DirectiveProposalCollection\":{\"name\":\"directiveproposalcollection\",\"className\":\"DirectiveProposalCollection\",\"qualifiedName\":\"@happyvertical/smrt-personas:DirectiveProposalCollection\",\"collection\":\"directiveproposals\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/personas/src/directive-proposal.ts\",\"packageName\":\"@happyvertical/smrt-personas\",\"fields\":{},\"methods\":{\"pending\":{\"name\":\"pending\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"string\",\"number\"]}],\"returnType\":\"Promise<DirectiveProposal[]>\",\"isStatic\":false,\"isPublic\":true},\"findByFingerprint\":{\"name\":\"findByFingerprint\",\"async\":true,\"parameters\":[{\"name\":\"personaId\",\"type\":\"string\",\"optional\":false},{\"name\":\"fingerprint\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<DirectiveProposal[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"directive_proposals\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"DirectiveProposal\",\"exportName\":\"DirectiveProposalCollection\",\"collectionExportName\":\"DirectiveProposalCollectionCollection\",\"schema\":{\"tableName\":\"directive_proposals\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"directive_proposals\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID NOT NULL,\\n \\\"persona_id\\\" UUID NOT NULL,\\n \\\"agent_class\\\" TEXT,\\n \\\"prompt_key\\\" TEXT,\\n \\\"proposed_instructions\\\" TEXT,\\n \\\"current_instructions\\\" TEXT,\\n \\\"rationale\\\" TEXT,\\n \\\"evidence\\\" TEXT,\\n \\\"status\\\" TEXT,\\n \\\"fingerprint\\\" TEXT,\\n \\\"confidence\\\" REAL DEFAULT 0,\\n \\\"proposed_by\\\" TEXT,\\n \\\"reviewed_by\\\" TEXT,\\n \\\"reviewed_at\\\" TIMESTAMP,\\n \\\"review_note\\\" TEXT,\\n \\\"activated_override_id\\\" TEXT\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"persona_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false,\"foreignKey\":{\"table\":\"agent_personas\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"prompt_key\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"proposed_instructions\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"current_instructions\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"rationale\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"evidence\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"fingerprint\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"confidence\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"proposed_by\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"reviewed_by\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"reviewed_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"review_note\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"activated_override_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"directive_proposals_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true},{\"name\":\"directive_proposals_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"directive_proposals_persona_id_idx\",\"columns\":[\"persona_id\"]}],\"version\":\"96be8911\"},\"importPath\":\"@happyvertical/smrt-personas\"},\"@happyvertical/smrt-personas:Feedback\":{\"name\":\"feedback\",\"className\":\"Feedback\",\"qualifiedName\":\"@happyvertical/smrt-personas:Feedback\",\"collection\":\"feedbacks\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/personas/src/feedback.ts\",\"packageName\":\"@happyvertical/smrt-personas\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"personaId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"AgentPersona\",\"_meta\":{\"required\":true}},\"agentClass\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"memoryScope\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"scope\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"key\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"signalType\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"source\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"correlationId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"required\":true}},\"correlationType\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"rating\":{\"type\":\"decimal\",\"required\":false,\"_meta\":{\"nullable\":true}},\"metric\":{\"type\":\"decimal\",\"required\":false,\"_meta\":{\"nullable\":true}},\"success\":{\"type\":\"boolean\",\"required\":false,\"_meta\":{\"nullable\":true}},\"correction\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"comment\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"actorId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"metadata\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"reinforcedAt\":{\"type\":\"datetime\",\"required\":false,\"_meta\":{\"nullable\":true}}},\"methods\":{\"isHuman\":{\"name\":\"isHuman\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"getMetadata\":{\"name\":\"getMetadata\",\"async\":false,\"parameters\":[],\"returnType\":\"Record<string, unknown>\",\"isStatic\":false,\"isPublic\":true},\"setMetadata\":{\"name\":\"setMetadata\",\"async\":false,\"parameters\":[{\"name\":\"value\",\"type\":\"Record<string, unknown>\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"updateMetadata\":{\"name\":\"updateMetadata\",\"async\":false,\"parameters\":[{\"name\":\"patch\",\"type\":\"Record<string, unknown>\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"getCorrectionValue\":{\"name\":\"getCorrectionValue\",\"async\":false,\"parameters\":[],\"returnType\":\"string | undefined\",\"isStatic\":false,\"isPublic\":true},\"toLearningOutcome\":{\"name\":\"toLearningOutcome\",\"async\":false,\"parameters\":[{\"name\":\"options\",\"type\":\"FeedbackOutcomeOptions\",\"optional\":true}],\"returnType\":\"LearningOutcome | null\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_feedback\",\"api\":{\"include\":[\"list\",\"get\",\"create\"]},\"cli\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"Feedback\",\"collectionExportName\":\"FeedbackCollection\",\"validationRules\":[{\"field\":\"personaId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"},{\"field\":\"correlationId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"agent_feedback\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"agent_feedback\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"persona_id\\\" UUID NOT NULL,\\n \\\"agent_class\\\" TEXT,\\n \\\"memory_scope\\\" TEXT,\\n \\\"scope\\\" TEXT,\\n \\\"key\\\" TEXT,\\n \\\"signal_type\\\" TEXT,\\n \\\"source\\\" TEXT,\\n \\\"correlation_id\\\" TEXT NOT NULL,\\n \\\"correlation_type\\\" TEXT,\\n \\\"rating\\\" REAL,\\n \\\"metric\\\" REAL,\\n \\\"success\\\" BOOLEAN,\\n \\\"correction\\\" TEXT,\\n \\\"comment\\\" TEXT,\\n \\\"actor_id\\\" TEXT,\\n \\\"metadata\\\" TEXT,\\n \\\"reinforced_at\\\" TIMESTAMP\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"persona_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false,\"foreignKey\":{\"table\":\"agent_personas\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"memory_scope\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"scope\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"key\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"signal_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"source\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"correlation_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false},\"correlation_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"rating\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false},\"metric\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false},\"success\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false},\"correction\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"comment\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"actor_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"metadata\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"reinforced_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"agent_feedback_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"agent_feedback_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"agent_feedback_persona_id_idx\",\"columns\":[\"persona_id\"]}],\"version\":\"91715a87\"},\"importPath\":\"@happyvertical/smrt-personas\"},\"@happyvertical/smrt-personas:FeedbackCollection\":{\"name\":\"feedbackcollection\",\"className\":\"FeedbackCollection\",\"qualifiedName\":\"@happyvertical/smrt-personas:FeedbackCollection\",\"collection\":\"feedbacks\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/personas/src/feedback.ts\",\"packageName\":\"@happyvertical/smrt-personas\",\"fields\":{},\"methods\":{\"forPersona\":{\"name\":\"forPersona\",\"async\":true,\"parameters\":[{\"name\":\"personaId\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"number\"]}],\"returnType\":\"Promise<Feedback[]>\",\"isStatic\":false,\"isPublic\":true},\"forScope\":{\"name\":\"forScope\",\"async\":true,\"parameters\":[{\"name\":\"memoryScope\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"number\"]}],\"returnType\":\"Promise<Feedback[]>\",\"isStatic\":false,\"isPublic\":true},\"byCorrelation\":{\"name\":\"byCorrelation\",\"async\":true,\"parameters\":[{\"name\":\"correlationId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Feedback[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_feedback\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Feedback\",\"exportName\":\"FeedbackCollection\",\"collectionExportName\":\"FeedbackCollectionCollection\",\"schema\":{\"tableName\":\"agent_feedback\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"agent_feedback\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"persona_id\\\" UUID NOT NULL,\\n \\\"agent_class\\\" TEXT,\\n \\\"memory_scope\\\" TEXT,\\n \\\"scope\\\" TEXT,\\n \\\"key\\\" TEXT,\\n \\\"signal_type\\\" TEXT,\\n \\\"source\\\" TEXT,\\n \\\"correlation_id\\\" TEXT NOT NULL,\\n \\\"correlation_type\\\" TEXT,\\n \\\"rating\\\" REAL,\\n \\\"metric\\\" REAL,\\n \\\"success\\\" BOOLEAN,\\n \\\"correction\\\" TEXT,\\n \\\"comment\\\" TEXT,\\n \\\"actor_id\\\" TEXT,\\n \\\"metadata\\\" TEXT,\\n \\\"reinforced_at\\\" TIMESTAMP\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"persona_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false,\"foreignKey\":{\"table\":\"agent_personas\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"memory_scope\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"scope\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"key\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"signal_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"source\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"correlation_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false},\"correlation_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"rating\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false},\"metric\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false},\"success\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false},\"correction\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"comment\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"actor_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"metadata\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"reinforced_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"agent_feedback_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"agent_feedback_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"agent_feedback_persona_id_idx\",\"columns\":[\"persona_id\"]}],\"version\":\"91715a87\"},\"importPath\":\"@happyvertical/smrt-personas\"}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-agents\",\"@happyvertical/smrt-core\",\"@happyvertical/smrt-messages\",\"@happyvertical/smrt-prompts\",\"@happyvertical/smrt-tenancy\",\"@happyvertical/smrt-users\"]}"));
8
+ ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":0,\"packageName\":\"@happyvertical/smrt-personas\",\"packageVersion\":\"0.51.33\",\"objects\":{\"@happyvertical/smrt-personas:AgentPersona\":{\"name\":\"agentpersona\",\"className\":\"AgentPersona\",\"qualifiedName\":\"@happyvertical/smrt-personas:AgentPersona\",\"collection\":\"agentpersonas\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/personas/src/agent-persona.ts\",\"packageName\":\"@happyvertical/smrt-personas\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":true,\"autoPopulate\":true,\"nullable\":false,\"mode\":\"required\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"agentClass\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"name\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"contextType\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"contextId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"instructions\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"allowedTools\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"runAsUserId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-users:User\"},\"actsAsProfileId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-profiles:Profile\",\"_meta\":{\"nullable\":true}},\"memoryScope\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"priority\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"enabled\":{\"type\":\"boolean\",\"required\":false,\"_meta\":{}}},\"methods\":{\"getAllowedTools\":{\"name\":\"getAllowedTools\",\"async\":false,\"parameters\":[],\"returnType\":\"string[]\",\"isStatic\":false,\"isPublic\":true},\"setAllowedTools\":{\"name\":\"setAllowedTools\",\"async\":false,\"parameters\":[{\"name\":\"tools\",\"type\":\"string[]\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_personas\",\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\"]},\"cli\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"conflictColumns\":[\"tenant_id\",\"agent_class\",\"name\"],\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"AgentPersona\",\"collectionExportName\":\"AgentPersonaCollection\",\"validationRules\":[{\"field\":\"runAsUserId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"}],\"schema\":{\"tableName\":\"agent_personas\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"agent_personas\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID NOT NULL,\\n \\\"agent_class\\\" TEXT,\\n \\\"name\\\" TEXT DEFAULT '',\\n \\\"context_type\\\" TEXT,\\n \\\"context_id\\\" TEXT,\\n \\\"instructions\\\" TEXT,\\n \\\"allowed_tools\\\" TEXT,\\n \\\"run_as_user_id\\\" UUID NOT NULL,\\n \\\"acts_as_profile_id\\\" UUID,\\n \\\"memory_scope\\\" TEXT,\\n \\\"priority\\\" INTEGER DEFAULT 0,\\n \\\"enabled\\\" BOOLEAN\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"context_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"context_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"instructions\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"allowed_tools\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"run_as_user_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"acts_as_profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":false,\"unique\":false},\"memory_scope\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"priority\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"enabled\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"agent_personas_tenant_id_agent_class_idx\",\"columns\":[\"tenant_id\",\"agent_class\",\"name\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"agent_personas_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"agent_personas_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"agent_personas_run_as_user_id_idx\",\"columns\":[\"run_as_user_id\"]},{\"name\":\"agent_personas_acts_as_profile_id_idx\",\"columns\":[\"acts_as_profile_id\"]}],\"version\":\"71e955ef\"},\"importPath\":\"@happyvertical/smrt-personas\"},\"@happyvertical/smrt-personas:AgentPersonaCollection\":{\"name\":\"agentpersonacollection\",\"className\":\"AgentPersonaCollection\",\"qualifiedName\":\"@happyvertical/smrt-personas:AgentPersonaCollection\",\"collection\":\"agentpersonas\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/personas/src/agent-persona.ts\",\"packageName\":\"@happyvertical/smrt-personas\",\"fields\":{},\"methods\":{\"byTenantAndClass\":{\"name\":\"byTenantAndClass\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"agentClass\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AgentPersona[]>\",\"isStatic\":false,\"isPublic\":true},\"findActive\":{\"name\":\"findActive\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"agentClass\",\"type\":\"string\",\"optional\":false},{\"name\":\"context\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"string | null\"]}],\"returnType\":\"Promise<AgentPersona[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_personas\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"AgentPersona\",\"exportName\":\"AgentPersonaCollection\",\"collectionExportName\":\"AgentPersonaCollectionCollection\",\"schema\":{\"tableName\":\"agent_personas\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"agent_personas\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID NOT NULL,\\n \\\"agent_class\\\" TEXT,\\n \\\"name\\\" TEXT DEFAULT '',\\n \\\"context_type\\\" TEXT,\\n \\\"context_id\\\" TEXT,\\n \\\"instructions\\\" TEXT,\\n \\\"allowed_tools\\\" TEXT,\\n \\\"run_as_user_id\\\" UUID NOT NULL,\\n \\\"acts_as_profile_id\\\" UUID,\\n \\\"memory_scope\\\" TEXT,\\n \\\"priority\\\" INTEGER DEFAULT 0,\\n \\\"enabled\\\" BOOLEAN\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"context_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"context_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"instructions\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"allowed_tools\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"run_as_user_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"acts_as_profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":false,\"unique\":false},\"memory_scope\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"priority\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"enabled\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"agent_personas_tenant_id_agent_class_idx\",\"columns\":[\"tenant_id\",\"agent_class\",\"name\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"agent_personas_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"agent_personas_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"agent_personas_run_as_user_id_idx\",\"columns\":[\"run_as_user_id\"]},{\"name\":\"agent_personas_acts_as_profile_id_idx\",\"columns\":[\"acts_as_profile_id\"]}],\"version\":\"71e955ef\"},\"importPath\":\"@happyvertical/smrt-personas\"},\"@happyvertical/smrt-personas:DirectiveProposal\":{\"name\":\"directiveproposal\",\"className\":\"DirectiveProposal\",\"qualifiedName\":\"@happyvertical/smrt-personas:DirectiveProposal\",\"collection\":\"directiveproposals\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/personas/src/directive-proposal.ts\",\"packageName\":\"@happyvertical/smrt-personas\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":true,\"autoPopulate\":true,\"nullable\":false,\"mode\":\"required\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"personaId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"AgentPersona\",\"_meta\":{\"required\":true}},\"agentClass\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"promptKey\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"proposedInstructions\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"currentInstructions\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"rationale\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"evidence\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"status\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"fingerprint\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"confidence\":{\"type\":\"decimal\",\"required\":false,\"default\":0},\"proposedBy\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"reviewedBy\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"reviewedAt\":{\"type\":\"datetime\",\"required\":false,\"_meta\":{\"nullable\":true}},\"reviewNote\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"activatedOverrideId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}}},\"methods\":{\"getEvidence\":{\"name\":\"getEvidence\",\"async\":false,\"parameters\":[],\"returnType\":\"DirectiveEvidence\",\"isStatic\":false,\"isPublic\":true},\"setEvidence\":{\"name\":\"setEvidence\",\"async\":false,\"parameters\":[{\"name\":\"value\",\"type\":\"DirectiveEvidence\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"isPending\":{\"name\":\"isPending\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"directive_proposals\",\"api\":{\"include\":[\"list\",\"get\"]},\"cli\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"tenantScoped\":{\"mode\":\"required\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"DirectiveProposal\",\"collectionExportName\":\"DirectiveProposalCollection\",\"validationRules\":[{\"field\":\"personaId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"}],\"schema\":{\"tableName\":\"directive_proposals\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"directive_proposals\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID NOT NULL,\\n \\\"persona_id\\\" UUID NOT NULL,\\n \\\"agent_class\\\" TEXT,\\n \\\"prompt_key\\\" TEXT,\\n \\\"proposed_instructions\\\" TEXT,\\n \\\"current_instructions\\\" TEXT,\\n \\\"rationale\\\" TEXT,\\n \\\"evidence\\\" TEXT,\\n \\\"status\\\" TEXT,\\n \\\"fingerprint\\\" TEXT,\\n \\\"confidence\\\" REAL DEFAULT 0,\\n \\\"proposed_by\\\" TEXT,\\n \\\"reviewed_by\\\" TEXT,\\n \\\"reviewed_at\\\" TIMESTAMP,\\n \\\"review_note\\\" TEXT,\\n \\\"activated_override_id\\\" TEXT\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"persona_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false,\"foreignKey\":{\"table\":\"agent_personas\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"prompt_key\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"proposed_instructions\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"current_instructions\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"rationale\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"evidence\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"fingerprint\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"confidence\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"proposed_by\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"reviewed_by\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"reviewed_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"review_note\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"activated_override_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"directive_proposals_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true},{\"name\":\"directive_proposals_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"directive_proposals_persona_id_idx\",\"columns\":[\"persona_id\"]}],\"version\":\"96be8911\"},\"importPath\":\"@happyvertical/smrt-personas\"},\"@happyvertical/smrt-personas:DirectiveProposalCollection\":{\"name\":\"directiveproposalcollection\",\"className\":\"DirectiveProposalCollection\",\"qualifiedName\":\"@happyvertical/smrt-personas:DirectiveProposalCollection\",\"collection\":\"directiveproposals\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/personas/src/directive-proposal.ts\",\"packageName\":\"@happyvertical/smrt-personas\",\"fields\":{},\"methods\":{\"pending\":{\"name\":\"pending\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"string\",\"number\"]}],\"returnType\":\"Promise<DirectiveProposal[]>\",\"isStatic\":false,\"isPublic\":true},\"findByFingerprint\":{\"name\":\"findByFingerprint\",\"async\":true,\"parameters\":[{\"name\":\"personaId\",\"type\":\"string\",\"optional\":false},{\"name\":\"fingerprint\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<DirectiveProposal[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"directive_proposals\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"DirectiveProposal\",\"exportName\":\"DirectiveProposalCollection\",\"collectionExportName\":\"DirectiveProposalCollectionCollection\",\"schema\":{\"tableName\":\"directive_proposals\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"directive_proposals\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID NOT NULL,\\n \\\"persona_id\\\" UUID NOT NULL,\\n \\\"agent_class\\\" TEXT,\\n \\\"prompt_key\\\" TEXT,\\n \\\"proposed_instructions\\\" TEXT,\\n \\\"current_instructions\\\" TEXT,\\n \\\"rationale\\\" TEXT,\\n \\\"evidence\\\" TEXT,\\n \\\"status\\\" TEXT,\\n \\\"fingerprint\\\" TEXT,\\n \\\"confidence\\\" REAL DEFAULT 0,\\n \\\"proposed_by\\\" TEXT,\\n \\\"reviewed_by\\\" TEXT,\\n \\\"reviewed_at\\\" TIMESTAMP,\\n \\\"review_note\\\" TEXT,\\n \\\"activated_override_id\\\" TEXT\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"persona_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false,\"foreignKey\":{\"table\":\"agent_personas\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"prompt_key\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"proposed_instructions\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"current_instructions\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"rationale\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"evidence\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"fingerprint\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"confidence\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false,\"default\":0},\"proposed_by\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"reviewed_by\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"reviewed_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"review_note\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"activated_override_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"directive_proposals_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true},{\"name\":\"directive_proposals_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"directive_proposals_persona_id_idx\",\"columns\":[\"persona_id\"]}],\"version\":\"96be8911\"},\"importPath\":\"@happyvertical/smrt-personas\"},\"@happyvertical/smrt-personas:Feedback\":{\"name\":\"feedback\",\"className\":\"Feedback\",\"qualifiedName\":\"@happyvertical/smrt-personas:Feedback\",\"collection\":\"feedbacks\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/personas/src/feedback.ts\",\"packageName\":\"@happyvertical/smrt-personas\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"personaId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"AgentPersona\",\"_meta\":{\"required\":true}},\"agentClass\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"memoryScope\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"scope\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"key\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"signalType\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"source\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"correlationId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"required\":true}},\"correlationType\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"rating\":{\"type\":\"decimal\",\"required\":false,\"_meta\":{\"nullable\":true}},\"metric\":{\"type\":\"decimal\",\"required\":false,\"_meta\":{\"nullable\":true}},\"success\":{\"type\":\"boolean\",\"required\":false,\"_meta\":{\"nullable\":true}},\"correction\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"comment\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"actorId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"metadata\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"reinforcedAt\":{\"type\":\"datetime\",\"required\":false,\"_meta\":{\"nullable\":true}}},\"methods\":{\"isHuman\":{\"name\":\"isHuman\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"getMetadata\":{\"name\":\"getMetadata\",\"async\":false,\"parameters\":[],\"returnType\":\"Record<string, unknown>\",\"isStatic\":false,\"isPublic\":true},\"setMetadata\":{\"name\":\"setMetadata\",\"async\":false,\"parameters\":[{\"name\":\"value\",\"type\":\"Record<string, unknown>\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"updateMetadata\":{\"name\":\"updateMetadata\",\"async\":false,\"parameters\":[{\"name\":\"patch\",\"type\":\"Record<string, unknown>\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"getCorrectionValue\":{\"name\":\"getCorrectionValue\",\"async\":false,\"parameters\":[],\"returnType\":\"string | undefined\",\"isStatic\":false,\"isPublic\":true},\"toLearningOutcome\":{\"name\":\"toLearningOutcome\",\"async\":false,\"parameters\":[{\"name\":\"options\",\"type\":\"FeedbackOutcomeOptions\",\"optional\":true}],\"returnType\":\"LearningOutcome | null\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_feedback\",\"api\":{\"include\":[\"list\",\"get\",\"create\"]},\"cli\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"Feedback\",\"collectionExportName\":\"FeedbackCollection\",\"validationRules\":[{\"field\":\"personaId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"},{\"field\":\"correlationId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"agent_feedback\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"agent_feedback\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"persona_id\\\" UUID NOT NULL,\\n \\\"agent_class\\\" TEXT,\\n \\\"memory_scope\\\" TEXT,\\n \\\"scope\\\" TEXT,\\n \\\"key\\\" TEXT,\\n \\\"signal_type\\\" TEXT,\\n \\\"source\\\" TEXT,\\n \\\"correlation_id\\\" TEXT NOT NULL,\\n \\\"correlation_type\\\" TEXT,\\n \\\"rating\\\" REAL,\\n \\\"metric\\\" REAL,\\n \\\"success\\\" BOOLEAN,\\n \\\"correction\\\" TEXT,\\n \\\"comment\\\" TEXT,\\n \\\"actor_id\\\" TEXT,\\n \\\"metadata\\\" TEXT,\\n \\\"reinforced_at\\\" TIMESTAMP\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"persona_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false,\"foreignKey\":{\"table\":\"agent_personas\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"memory_scope\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"scope\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"key\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"signal_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"source\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"correlation_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false},\"correlation_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"rating\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false},\"metric\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false},\"success\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false},\"correction\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"comment\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"actor_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"metadata\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"reinforced_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"agent_feedback_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"agent_feedback_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"agent_feedback_persona_id_idx\",\"columns\":[\"persona_id\"]}],\"version\":\"91715a87\"},\"importPath\":\"@happyvertical/smrt-personas\"},\"@happyvertical/smrt-personas:FeedbackCollection\":{\"name\":\"feedbackcollection\",\"className\":\"FeedbackCollection\",\"qualifiedName\":\"@happyvertical/smrt-personas:FeedbackCollection\",\"collection\":\"feedbacks\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/personas/src/feedback.ts\",\"packageName\":\"@happyvertical/smrt-personas\",\"fields\":{},\"methods\":{\"forPersona\":{\"name\":\"forPersona\",\"async\":true,\"parameters\":[{\"name\":\"personaId\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"number\"]}],\"returnType\":\"Promise<Feedback[]>\",\"isStatic\":false,\"isPublic\":true},\"forScope\":{\"name\":\"forScope\",\"async\":true,\"parameters\":[{\"name\":\"memoryScope\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"number\"]}],\"returnType\":\"Promise<Feedback[]>\",\"isStatic\":false,\"isPublic\":true},\"byCorrelation\":{\"name\":\"byCorrelation\",\"async\":true,\"parameters\":[{\"name\":\"correlationId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Feedback[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_feedback\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Feedback\",\"exportName\":\"FeedbackCollection\",\"collectionExportName\":\"FeedbackCollectionCollection\",\"schema\":{\"tableName\":\"agent_feedback\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"agent_feedback\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"persona_id\\\" UUID NOT NULL,\\n \\\"agent_class\\\" TEXT,\\n \\\"memory_scope\\\" TEXT,\\n \\\"scope\\\" TEXT,\\n \\\"key\\\" TEXT,\\n \\\"signal_type\\\" TEXT,\\n \\\"source\\\" TEXT,\\n \\\"correlation_id\\\" TEXT NOT NULL,\\n \\\"correlation_type\\\" TEXT,\\n \\\"rating\\\" REAL,\\n \\\"metric\\\" REAL,\\n \\\"success\\\" BOOLEAN,\\n \\\"correction\\\" TEXT,\\n \\\"comment\\\" TEXT,\\n \\\"actor_id\\\" TEXT,\\n \\\"metadata\\\" TEXT,\\n \\\"reinforced_at\\\" TIMESTAMP\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"persona_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false,\"foreignKey\":{\"table\":\"agent_personas\",\"column\":\"id\",\"onDelete\":\"NO ACTION\",\"onUpdate\":\"CASCADE\"}},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"memory_scope\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"scope\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"key\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"signal_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"source\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"correlation_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false},\"correlation_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"rating\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false},\"metric\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false},\"success\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false},\"correction\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"comment\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"actor_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"metadata\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"reinforced_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"agent_feedback_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"agent_feedback_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"agent_feedback_persona_id_idx\",\"columns\":[\"persona_id\"]}],\"version\":\"91715a87\"},\"importPath\":\"@happyvertical/smrt-personas\"}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-agents\",\"@happyvertical/smrt-core\",\"@happyvertical/smrt-messages\",\"@happyvertical/smrt-prompts\",\"@happyvertical/smrt-tenancy\",\"@happyvertical/smrt-users\"]}"));
9
9
  //#endregion
10
10
  //#region src/directive-principal.ts
11
11
  var ACTIVATE_DIRECTIVE_PERMISSION = "personas.activate-directive";
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-personas",
5
- "packageVersion": "0.51.31",
5
+ "packageVersion": "0.51.33",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-personas:AgentPersona": {
8
8
  "name": "agentpersona",
@@ -1,5 +1,31 @@
1
- import { AgentAdminRoute, AgentManifestInfo, AgentSchedule, AgentScheduleCollection, AgentUISlots } from '@happyvertical/smrt-agents';
2
- import { AgentPersona, AgentPersonaCollection } from './agent-persona.js';
1
+ /**
2
+ * Persona-as-durable-instance helpers (#1890).
3
+ *
4
+ * Treats an {@link AgentPersona} as a **durable instance** of an agent class:
5
+ * N configured instances per tenant, each independently scheduled, memory-scoped,
6
+ * and permission-scoped. This module wires that instance concept to the
7
+ * `@happyvertical/smrt-agents` runtime:
8
+ *
9
+ * - **Identity** — {@link personaInstanceKey} / {@link agentOptionsForPersona}
10
+ * map a persona to the `AgentOptions.instanceKey` the framework folds into a
11
+ * per-instance dispatch subscriber, memory scope, and interest scope. The
12
+ * `default` persona reuses the **singleton** identity (a `null` key), which is
13
+ * what makes the singleton→multi upgrade non-destructive.
14
+ * - **Scheduling** — {@link schedulePersonaInstance} binds an `AgentSchedule` to
15
+ * a persona instance, routing the instance key through `agentConfig` so it
16
+ * reaches the constructed agent as `AgentOptions.instanceKey`.
17
+ * - **Admin** — {@link buildPersonaInstanceAdmin} renders the agent class's
18
+ * `uiSlots`/`adminRoutes` once per instance, with {@link addPersonaInstance} /
19
+ * {@link removePersonaInstance} affordances.
20
+ * - **Upgrade** — {@link upgradeSingletonToDefaultPersona} maps an existing
21
+ * singleton to a single `default` persona without touching its data.
22
+ *
23
+ * Multi-instance is a per-package opt-in on the agent class
24
+ * (`static multiInstance = true`); these helpers manage the persona rows that
25
+ * back it. A singleton (non-opted) agent needs none of this and is unchanged.
26
+ */
27
+ import { type AgentAdminRoute, type AgentManifestInfo, type AgentSchedule, type AgentScheduleCollection, type AgentUISlots } from '@happyvertical/smrt-agents';
28
+ import { type AgentPersona, type AgentPersonaCollection } from './agent-persona.js';
3
29
  /**
4
30
  * The reserved persona name for the singleton/default instance.
5
31
  *
@@ -1,6 +1,21 @@
1
- import { LearningMemory, LearningMemoryConfig, LearningMemoryRecord, LearningSemanticSearch } from '@happyvertical/smrt-core';
2
- import { DatabaseInterface } from '@happyvertical/sql';
3
- import { Feedback, FeedbackOutcomeOptions } from './feedback.js';
1
+ /**
2
+ * Persona-scoped learning memory routing (#1889).
3
+ *
4
+ * A persona's `memoryScope` routes {@link LearningMemory} so different personas
5
+ * of the same agent class learn independently. The scope becomes the memory
6
+ * partition (`owner_id`), so two personas never share confidence-scored
7
+ * strategies even when they run the identical agent class over the same tenant.
8
+ *
9
+ * The other direction of the loop — turning a {@link Feedback} signal into a
10
+ * confidence adjustment — is {@link reinforceFromFeedback}: the automatic,
11
+ * confidence-only reinforcement that stays ungated (only instruction rewrites
12
+ * are gated).
13
+ *
14
+ * @module
15
+ */
16
+ import { LearningMemory, type LearningMemoryConfig, type LearningMemoryRecord, type LearningSemanticSearch } from '@happyvertical/smrt-core';
17
+ import type { DatabaseInterface } from '@happyvertical/sql';
18
+ import type { Feedback, FeedbackOutcomeOptions } from './feedback.js';
4
19
  /** The minimal persona shape the memory router needs. */
5
20
  export interface PersonaMemoryLike {
6
21
  id?: string | null;
@@ -1,6 +1,6 @@
1
- import { PrincipalTool } from '@happyvertical/smrt-agents';
2
- import { SmrtClassOptions } from '@happyvertical/smrt-core';
3
- import { SendPersonaMessageOptions } from '@happyvertical/smrt-messages';
1
+ import type { PrincipalTool } from '@happyvertical/smrt-agents';
2
+ import type { SmrtClassOptions } from '@happyvertical/smrt-core';
3
+ import { type SendPersonaMessageOptions } from '@happyvertical/smrt-messages';
4
4
  export declare const SEND_PERSONA_MESSAGE_TOOL_SLUG = "messages.send";
5
5
  export declare const SEND_PERSONA_MESSAGE_FUNCTION_NAME = "messages-send";
6
6
  interface PersonaMessageSender {
@@ -1,5 +1,23 @@
1
- import { PromptDefinition, PromptEditableConfig, PromptOverride } from '@happyvertical/smrt-prompts';
2
- import { DatabaseInterface } from '@happyvertical/sql';
1
+ /**
2
+ * Persona ↔ prompt-override binding (#1889).
3
+ *
4
+ * A persona's `instructions` are applied to the running agent through a
5
+ * **tenant/persona-scoped `prompt_override`**, not by mutating the agent's code
6
+ * default. Each persona owns a dedicated, per-persona prompt key registered at
7
+ * runtime with a neutral empty base template; the persona's actual instructions
8
+ * live entirely in the override layer. Because the key is unique per persona,
9
+ * two personas of the same tenant and agent class resolve to different
10
+ * instructions without colliding on the `(key, context)` override identity.
11
+ *
12
+ * Activating a directive (see {@link DirectiveApprovalService}) is exactly the
13
+ * act of writing/updating this override — and it flows through
14
+ * `PromptOverride.save()`, so `validatePromptOverride` still forbids overriding
15
+ * a non-editable prompt field.
16
+ *
17
+ * @module
18
+ */
19
+ import { type PromptDefinition, type PromptEditableConfig, type PromptOverride } from '@happyvertical/smrt-prompts';
20
+ import type { DatabaseInterface } from '@happyvertical/sql';
3
21
  /** The minimal persona shape these helpers need. */
4
22
  export interface PersonaLike {
5
23
  id?: string | null;
@@ -1,5 +1,34 @@
1
- import { ResolvedAgentAvailability } from '@happyvertical/smrt-agents';
2
- import { AgentPersonaCollection, personaAppliesToContext } from './agent-persona.js';
1
+ /**
2
+ * PersonaResolver - resolves the active {@link AgentPersona} for a
3
+ * `(tenant, agentClass, context)` request.
4
+ *
5
+ * Layering, bottom to top (each layer overrides the previous):
6
+ *
7
+ * 1. **Manifest defaults** — the agent's built-in instructions / tools /
8
+ * memory scope (supplied by the caller as {@link ManifestPersonaDefaults}).
9
+ * 2. **TenantAgent** — the tenant/class availability gate and capability
10
+ * ceiling (supplied as a {@link PersonaAvailabilityGate}; build one from a
11
+ * `ResolvedAgentAvailability` via {@link availabilityFromResolvedAgent}).
12
+ * `TenantAgent` decides *whether* the agent runs and *caps* its tools;
13
+ * it never sets instructions.
14
+ * 3. **AgentPersona** — the tenant's own persona for the context: overrides
15
+ * instructions, sets tools (within the ceiling), run-as principal, acting
16
+ * identity, and memory scope.
17
+ *
18
+ * Tenant-hierarchy inheritance mirrors `TenantAgentCollection.resolveForTenant`:
19
+ * the resolver walks from the requesting tenant up its ancestors (nearest
20
+ * first). The nearest tenant level that has any applicable persona wins the
21
+ * resolution (a closer level shadows a farther one); within that level the most
22
+ * context-specific, highest-priority persona is selected. When no level has an
23
+ * applicable persona a defined default is returned.
24
+ *
25
+ * The hierarchy walk reads personas across tenants, so `resolve()` is meant to
26
+ * run in a system/admin path where cross-tenant reads are permitted (i.e. not
27
+ * inside a strict per-tenant interceptor context) — the same expectation
28
+ * `TenantAgentCollection.resolveForTenant` carries.
29
+ */
30
+ import type { ResolvedAgentAvailability } from '@happyvertical/smrt-agents';
31
+ import { type AgentPersonaCollection, personaAppliesToContext } from './agent-persona.js';
3
32
  /**
4
33
  * The context a persona is being resolved for.
5
34
  */
@@ -1,8 +1,31 @@
1
- import { LearningMemory, LearningMemoryRecord } from '@happyvertical/smrt-core';
2
- import { DatabaseInterface } from '@happyvertical/sql';
3
- import { DirectivePrincipal } from './directive-principal.js';
4
- import { DirectiveProposal, DirectiveProposalCollection } from './directive-proposal.js';
5
- import { Feedback, FeedbackCollection } from './feedback.js';
1
+ /**
2
+ * ReflectionRunner — the scheduled consolidation step of the learning loop (#1889).
3
+ *
4
+ * Runs under the **autonomous reflection principal**, which deliberately lacks
5
+ * the `personas.activate-directive` permission. For a persona it:
6
+ *
7
+ * 1. Applies recent {@link Feedback} to the persona's {@link LearningMemory}
8
+ * as automatic, confidence-only reinforcement (ungated).
9
+ * 2. Consolidates the resulting episodes + feedback and asks an injected
10
+ * reflector (the AI boundary, mocked in tests) for a candidate rewrite of
11
+ * the persona's instructions.
12
+ * 3. Records that rewrite as a **pending** {@link DirectiveProposal} with
13
+ * rationale + evidence — deduped by fingerprint so an already-seen (e.g.
14
+ * rejected) rewrite is never re-surfaced.
15
+ *
16
+ * It cannot activate anything: writing the persona override is gated by the
17
+ * permission its principal does not hold. That split is the whole gate.
18
+ *
19
+ * The runner is transport-agnostic; schedule it through an `AgentSchedule` /
20
+ * background job by calling {@link run} on a cadence.
21
+ *
22
+ * @module
23
+ */
24
+ import type { LearningMemory, LearningMemoryRecord } from '@happyvertical/smrt-core';
25
+ import type { DatabaseInterface } from '@happyvertical/sql';
26
+ import type { DirectivePrincipal } from './directive-principal.js';
27
+ import { type DirectiveProposal, DirectiveProposalCollection } from './directive-proposal.js';
28
+ import { type Feedback, FeedbackCollection } from './feedback.js';
6
29
  /** The (normalised) persona shape handed to the reflector. */
7
30
  export interface ReflectionPersona {
8
31
  id: string;
@@ -3,12 +3,12 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-personas",
6
- "packageVersion": "0.51.31",
6
+ "packageVersion": "0.51.33",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "118d5431d87b02d624b6d56a7e28b73a74748bbd73e988103bfb6aa064f302b3",
11
- "packageJson": "227412c8c16a0ef0e9cb416b48f66eb353460d93a3f5c0d58ca548aa07f360f8",
10
+ "manifest": "cd69588f70e23240d42e08e5af7c36b800cc5fcf7d6b89fd03bb7dba6ddf8d94",
11
+ "packageJson": "50015a0bdf91c4f47beaca48dfb9debd5fe851b33dd319f442bb53aa501c8979",
12
12
  "agents": "fe6c54f7d6c724b76906629eeb7bd17a332faad631179771acea73db1e159733"
13
13
  },
14
14
  "exports": [
@@ -32,7 +32,7 @@
32
32
  "@types/node": "24.13.6",
33
33
  "svelte": "^5.57.1",
34
34
  "svelte-check": "^4.7.6",
35
- "typescript": "5.9.3",
35
+ "typescript": "6.0.3",
36
36
  "vite": "8.1.4",
37
37
  "vitest": "4.1.10"
38
38
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-personas",
3
- "version": "0.51.31",
3
+ "version": "0.51.33",
4
4
  "smrtJsdoc": "strict",
5
5
  "description": "Tenant-owned, context-scoped agent personas and resolution for the SMRT framework",
6
6
  "type": "module",
@@ -25,26 +25,26 @@
25
25
  "./manifest.json": "./dist/manifest.json"
26
26
  },
27
27
  "dependencies": {
28
- "@happyvertical/smrt-agents": "0.51.31",
29
- "@happyvertical/smrt-core": "0.51.31",
30
- "@happyvertical/smrt-messages": "0.51.31",
31
- "@happyvertical/smrt-prompts": "0.51.31",
32
- "@happyvertical/smrt-tenancy": "0.51.31",
33
- "@happyvertical/smrt-ui": "0.51.31",
34
- "@happyvertical/smrt-users": "0.51.31",
28
+ "@happyvertical/smrt-agents": "0.51.33",
29
+ "@happyvertical/smrt-core": "0.51.33",
30
+ "@happyvertical/smrt-messages": "0.51.33",
31
+ "@happyvertical/smrt-prompts": "0.51.33",
32
+ "@happyvertical/smrt-tenancy": "0.51.33",
33
+ "@happyvertical/smrt-ui": "0.51.33",
34
+ "@happyvertical/smrt-users": "0.51.33",
35
35
  "@happyvertical/sql": "^0.94.1"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "svelte": "^5.57.1"
39
39
  },
40
40
  "devDependencies": {
41
- "@happyvertical/smrt-vitest": "0.51.31",
41
+ "@happyvertical/smrt-vitest": "0.51.33",
42
42
  "@sveltejs/package": "^2.5.8",
43
43
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
44
44
  "@types/node": "24.13.6",
45
45
  "svelte": "^5.57.1",
46
46
  "svelte-check": "^4.7.6",
47
- "typescript": "5.9.3",
47
+ "typescript": "6.0.3",
48
48
  "vite": "8.1.4",
49
49
  "vitest": "4.1.10"
50
50
  },