Structured sales-agent config, version spine and outreach state

Featurekamo-shared-library
Shipped
July 19, 2026 at 1:25 AM UTC
Author
Kamo
Commit
6cf49b2

Replaces the single training-context blob with a structured, versionable agent model, and adds the per-contact spine an agent needs before it may initiate contact rather than only reply. - SalesAgent gains configJson (jsonb-as-String, matching WebChatIntegration .designConfig), hasConfig, publishedVersionId, audience and outboundEnabled. trainingContext is retained as the COMPILED OUTPUT so every existing consumer keeps working untouched. hasConfig is explicit rather than inferred from trainingContext being blank, because once it is compiled output it is never blank and any blankness test would be unreachable. - SalesAgentVersion freezes {configJson, compiledPrompt, compiledHash, modelId, providerId} per publish. The model is pinned alongside the prompt: freezing instructions while the model auto-routes would make the artifact a half-truth. - AiChatSession/AiUsageRecord gain salesAgentId + salesAgentVersionId. Previously "which agent handled this?" could only be answered by walking the mutable, nullable, non-FK WebChatIntegration.salesAgentId hop, so reassigning a channel silently re-attributed all history. - AiOrgSettings gains forcedPreamble/forcedFooter as NEW nullable columns rather than reusing defaultSystemPrompt, so concatenation is a no-op until an admin fills one in. Reusing the existing field would have changed behaviour for every org that already had one populated, on deploy day. - AgentContactState + AgentOutboundTouch: per-contact cross-channel suppression, explicit per-channel opt-out columns and timestamped consent. Opt-out is stored as real columns rather than JSON because "prove this number was suppressed on that date" must not depend on JSON path extraction. The touch log records REFUSALS as well as sends - a log of sends proves what you did, a log of decisions proves what you would not do. - Rights 168-173 split **************** off MANAGE_AI_SETTINGS(53), which previously gated none of this.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing