@apotech-os/support-kit 10.4.0 → 10.5.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/dist/index.d.cts CHANGED
@@ -940,6 +940,57 @@ declare function isDecisionOrigin(value: unknown): value is DecisionOrigin;
940
940
  /** Reads an untrusted stored value, falling back to the least-privileged origin. */
941
941
  declare function toDecisionOrigin(value: unknown): DecisionOrigin;
942
942
 
943
+ declare const GENERATION_MODES: readonly ["auto", "operator"];
944
+ type GenerationMode = (typeof GENERATION_MODES)[number];
945
+ declare const PROMPT_USAGES: readonly ["always", "auto", "operator"];
946
+ type PromptUsage = (typeof PROMPT_USAGES)[number];
947
+ declare const DEFAULT_PROMPT_USAGE: PromptUsage;
948
+ /** Prompt name → usage. A name that is absent is `always`. */
949
+ type SharedPromptUsages = Record<string, PromptUsage>;
950
+ declare function isPromptUsage(value: unknown): value is PromptUsage;
951
+ /**
952
+ * Reads the stored setting. Anything that is not a known usage is dropped,
953
+ * which makes that prompt `always`: an unreadable entry must never silently
954
+ * remove a block from every reply.
955
+ */
956
+ declare function toSharedPromptUsages(value: unknown): SharedPromptUsages;
957
+ /** A system prompt's usage is fixed by the code: the stored setting never overrides it. */
958
+ declare function promptUsageOf(name: string, usages: SharedPromptUsages): PromptUsage;
959
+ declare function isPromptUsedIn(mode: GenerationMode, usage: PromptUsage): boolean;
960
+
961
+ /**
962
+ * Shared prompts the kit itself reads, by name.
963
+ *
964
+ * Every other `shared/*` prompt exists because an agent prompt references it.
965
+ * These exist because the code asks for them: the name is fixed here, and the
966
+ * text written here is what is served until a version is published (and
967
+ * whenever the published one cannot be read). The team edits the text like
968
+ * any other shared prompt; it cannot rename it or make it disappear.
969
+ */
970
+
971
+ interface SystemPrompt {
972
+ name: string;
973
+ /** What it is for, in the team's words. */
974
+ description: string;
975
+ /** Fixed: the code decides when it is read, not the usage setting. */
976
+ usage: PromptUsage;
977
+ defaultContent: string;
978
+ }
979
+ declare const OPERATOR_MODE_PROMPT_NAME = "shared/mode-operateur";
980
+ /**
981
+ * Tells the model who it is writing for. The agent prompts are written for
982
+ * the pipeline answering alone, and their limits ("jamais plus de 5 % sans
983
+ * validation humaine", "un agent reviendra vers vous") turned an operator's
984
+ * own instruction into a hand-off to the very person asking.
985
+ *
986
+ * The extension sends what the operator typed as a last message worded
987
+ * "Merci d'utiliser le contexte suivant…": the text names it so the model
988
+ * reads it as an instruction and not as background.
989
+ */
990
+ declare const DEFAULT_OPERATOR_MODE_PROMPT: string;
991
+ declare const SYSTEM_PROMPTS: readonly SystemPrompt[];
992
+ declare function systemPromptOf(name: string): SystemPrompt | undefined;
993
+
943
994
  /**
944
995
  * Run budget: bounds a run in TOOL CALLS and TIME only, never in money —
945
996
  * cost is measured (`charge`, I15) and watched separately, not capped here.
@@ -1853,6 +1904,25 @@ interface PromptResolverDeps {
1853
1904
  now?: () => number;
1854
1905
  /** Fires at every silent-degradation point in the ladder (post-review E). */
1855
1906
  onDegraded?: (event: PromptDegradedEvent) => void;
1907
+ /**
1908
+ * Which composition targets this resolver composes, asked once per
1909
+ * resolution. A target `isActive` answers `false` for resolves to nothing,
1910
+ * as if its tag were not there: this is how a shared prompt restricted to
1911
+ * one generation mode stays out of the other (`domain/prompt-usage.ts`).
1912
+ * Absent, every target is composed.
1913
+ *
1914
+ * `cacheScope` keeps the `prompt-cache` mirror entries of one filter apart
1915
+ * from every other's. It must change whenever the filter's answers do: the
1916
+ * mirror holds COMPOSED text, so an entry written under one set of
1917
+ * restrictions would otherwise be served, on a Langfuse outage, to a
1918
+ * resolution that has since been told to leave a block out. Absent, the
1919
+ * historical unscoped key is used.
1920
+ */
1921
+ referenceFilter?: () => Promise<ReferenceFilter>;
1922
+ }
1923
+ interface ReferenceFilter {
1924
+ isActive: (name: string) => boolean;
1925
+ cacheScope?: string;
1856
1926
  }
1857
1927
  /** Builds a `PromptPort` implementing §3.7's three-level fallback ladder. */
1858
1928
  declare function createPromptResolver(deps: PromptResolverDeps): PromptPort;
@@ -2279,6 +2349,8 @@ interface SupportKitSettings {
2279
2349
  noreplySenders: string[];
2280
2350
  channelPromptEmail: string;
2281
2351
  channelPromptWhatsapp: string;
2352
+ /** Optional: apps deployed before the field existed store none, read as every shared prompt `always`. */
2353
+ sharedPromptUsages?: SharedPromptUsages;
2282
2354
  renameEnabled: boolean;
2283
2355
  renameFrom: string;
2284
2356
  renameTo: string;
@@ -2509,4 +2581,4 @@ interface SupportPipelineFragments {
2509
2581
  }
2510
2582
  declare function buildSupportPipeline(config: SupportPipelineConfig): SupportPipelineFragments;
2511
2583
 
2512
- export { AGENT_GUARDRAILS, AGENT_STATUSES, AGENT_TOOLS, ATTACHMENT_MARKER_ONLY, type ActionDecision, type AgentProfile, type AgentStatus, type AuditTags, type AutoReplyGuardSettings, type AwaitingSince, type Budget, CANDIDATE_MIN_LENGTH, COLLISION_GUARDRAILS, CONVERSATION_END_ACTIONS, type CatalogueTool, type CategoryPolicy, type CategoryReferentialEntry, type ChannelKind, type ChatMessage, type Classification, type ClockPort, type CollisionGuardrailId, type CompletionRequest, type CompletionResult, type Conversation, type ConversationEndAction, type ConversationEndConfig, type ConversationEndSettings, type ConversationPort, type ConversationRef, type CostLedger, type CustomerInfo, DECISION_ORIGINS, DEFAULT_AUTO_SEND_CHANNELS, DEFAULT_CHANNEL_PROMPT_EMAIL, DEFAULT_CHANNEL_PROMPT_WHATSAPP, DEFAULT_CONVERSATION_END_TAG, DEFAULT_DECISION_ORIGIN, DEFAULT_LLM_PROVIDER, DEFAULT_PROFILE_KEY, DEFAULT_WHATSAPP_MODE, type DecisionOrigin, type Draft, type DraftAttribution, type DraftNodeConfig, EVALUATION_VERDICTS, type EscalateNodeConfig, type EvaluateNodeConfig, type EvaluationVerdict, GENERATED_RESPONSE_STATUSES, type GeneratedResponseStatus, type GuardrailId, type IneligibleReason, InvalidStatusTransitionError, type JsonSchema, type JudgedReply, type KnowledgeHit, type LlmPort, type Message, MissingPromptError, NODE_NAMES, type Node, type NodeCost, type NodeDeps, type NodeKey, type NodeName, type NodeStep, ORIGIN_DESCRIPTION, OUTCOMES, type OrderSummary, type OutboundReply, type Outcome, PROMPT_SLOTS, type PlatformPromptReader, type PortName, type PromptCacheEntry, type PromptCachePort, type PromptDegradedEvent, type PromptNameConfig, type PromptPort, type PromptRef, type PromptReference, type PromptResolverDeps, type PromptSlot, type PromptTableKey, type ProposedAction, type PublicationMode, REASONING_MAX_LEN, type RawPrompt, type RawPromptConfig, type RawTicket, type RawTicketFactsAt, type ReasoningEffort, type ReconstructHoldInput, type RecordDef, type ReplyPort, type ResolvedPrompt, type ResumeFrom, type ReviseNodeConfig, type RunGuardrailsInput, type RunStamp, type RunTicketOptions, type RunUntil, STOP_PHRASES, SUPPORT_CHANNELS, SUPPORT_KIT_SETTINGS_FIELDS, type SettingsIssueKey, type SettingsValidationIssue, type SettingsWarning, type SettingsWarningKey, type SimilarTicket, type SourceDescriptor, type StatePort, type SupportChannel, type SupportKitNodeSettings, type SupportKitSettings, type SupportPipelineConfig, type SupportPipelineFragments, type TicketRunState, type ToolCallRecord, type ToolCallRequest, type ToolContext, type ToolPolicy, type ToolSpec, type TrackingSummary, type TriageNodeConfig, UNCERTAINTY_MARKERS, type Usage, type Verdict, type VerifyReplyInput, type VerifyReplyResult, WHATSAPP_MODES, WHATSAPP_NOTE_CHEVRON, type WhatsappMode, accountChannelAddress, agentRecord, answerableChannels, assertTransition, buildCategoryRecord, buildDiffAnalysisRecord, buildEvaluationRecord, buildGeneratedResponseRecord, buildReplyTimingRecord, buildResponseComparisonRecord, buildSupportKitRecords, buildSupportPipeline, buildTriageDecisionRecord, canTransition, categoryGroupRecord, channelPreGates, conversationEndEffects, createBudget, createPromptResolver, customerChannelAddress, diffAnalysisUniqueKey, firstCustomerMessage, guardrailBucket, hasCustomerAttachment, hasReferences, initialState, isAutoSendEligible, isAutomatedSenderEmail, isAutomatedSenderTicket, isCustomerTurnWithWords, isDecisionOrigin, isEvaluationVerdict, isGeneratedResponseStatus, isJudgemeConversation, isJudgemeTicket, isOutcome, isSendable, isSendableVerdict, isTerminalStatus, isTicketClosed, isWhatsappChevronNote, isWhatsappTicket, lastCustomerMessage, needsRevision, openTicketKeyFor, parseReferences, pipelineStateRecord, promptCacheRecord, publicationMode, rawTicketFactsAt, readConversationEnd, reclaimStalledSend, reconstructGuardrailHits, requiresFollowup, resolvePromptName, runGuardrails, runTicket, settingsToProfile, settingsWarnings, stopOptOut, targetRefFor, toConversationEnd, toDecisionOrigin, validateSettings, verifyReply, whatsappModeFromLegacyBoolean };
2584
+ export { AGENT_GUARDRAILS, AGENT_STATUSES, AGENT_TOOLS, ATTACHMENT_MARKER_ONLY, type ActionDecision, type AgentProfile, type AgentStatus, type AuditTags, type AutoReplyGuardSettings, type AwaitingSince, type Budget, CANDIDATE_MIN_LENGTH, COLLISION_GUARDRAILS, CONVERSATION_END_ACTIONS, type CatalogueTool, type CategoryPolicy, type CategoryReferentialEntry, type ChannelKind, type ChatMessage, type Classification, type ClockPort, type CollisionGuardrailId, type CompletionRequest, type CompletionResult, type Conversation, type ConversationEndAction, type ConversationEndConfig, type ConversationEndSettings, type ConversationPort, type ConversationRef, type CostLedger, type CustomerInfo, DECISION_ORIGINS, DEFAULT_AUTO_SEND_CHANNELS, DEFAULT_CHANNEL_PROMPT_EMAIL, DEFAULT_CHANNEL_PROMPT_WHATSAPP, DEFAULT_CONVERSATION_END_TAG, DEFAULT_DECISION_ORIGIN, DEFAULT_LLM_PROVIDER, DEFAULT_OPERATOR_MODE_PROMPT, DEFAULT_PROFILE_KEY, DEFAULT_PROMPT_USAGE, DEFAULT_WHATSAPP_MODE, type DecisionOrigin, type Draft, type DraftAttribution, type DraftNodeConfig, EVALUATION_VERDICTS, type EscalateNodeConfig, type EvaluateNodeConfig, type EvaluationVerdict, GENERATED_RESPONSE_STATUSES, GENERATION_MODES, type GeneratedResponseStatus, type GenerationMode, type GuardrailId, type IneligibleReason, InvalidStatusTransitionError, type JsonSchema, type JudgedReply, type KnowledgeHit, type LlmPort, type Message, MissingPromptError, NODE_NAMES, type Node, type NodeCost, type NodeDeps, type NodeKey, type NodeName, type NodeStep, OPERATOR_MODE_PROMPT_NAME, ORIGIN_DESCRIPTION, OUTCOMES, type OrderSummary, type OutboundReply, type Outcome, PROMPT_SLOTS, PROMPT_USAGES, type PlatformPromptReader, type PortName, type PromptCacheEntry, type PromptCachePort, type PromptDegradedEvent, type PromptNameConfig, type PromptPort, type PromptRef, type PromptReference, type PromptResolverDeps, type PromptSlot, type PromptTableKey, type PromptUsage, type ProposedAction, type PublicationMode, REASONING_MAX_LEN, type RawPrompt, type RawPromptConfig, type RawTicket, type RawTicketFactsAt, type ReasoningEffort, type ReconstructHoldInput, type RecordDef, type ReplyPort, type ResolvedPrompt, type ResumeFrom, type ReviseNodeConfig, type RunGuardrailsInput, type RunStamp, type RunTicketOptions, type RunUntil, STOP_PHRASES, SUPPORT_CHANNELS, SUPPORT_KIT_SETTINGS_FIELDS, SYSTEM_PROMPTS, type SettingsIssueKey, type SettingsValidationIssue, type SettingsWarning, type SettingsWarningKey, type SharedPromptUsages, type SimilarTicket, type SourceDescriptor, type StatePort, type SupportChannel, type SupportKitNodeSettings, type SupportKitSettings, type SupportPipelineConfig, type SupportPipelineFragments, type SystemPrompt, type TicketRunState, type ToolCallRecord, type ToolCallRequest, type ToolContext, type ToolPolicy, type ToolSpec, type TrackingSummary, type TriageNodeConfig, UNCERTAINTY_MARKERS, type Usage, type Verdict, type VerifyReplyInput, type VerifyReplyResult, WHATSAPP_MODES, WHATSAPP_NOTE_CHEVRON, type WhatsappMode, accountChannelAddress, agentRecord, answerableChannels, assertTransition, buildCategoryRecord, buildDiffAnalysisRecord, buildEvaluationRecord, buildGeneratedResponseRecord, buildReplyTimingRecord, buildResponseComparisonRecord, buildSupportKitRecords, buildSupportPipeline, buildTriageDecisionRecord, canTransition, categoryGroupRecord, channelPreGates, conversationEndEffects, createBudget, createPromptResolver, customerChannelAddress, diffAnalysisUniqueKey, firstCustomerMessage, guardrailBucket, hasCustomerAttachment, hasReferences, initialState, isAutoSendEligible, isAutomatedSenderEmail, isAutomatedSenderTicket, isCustomerTurnWithWords, isDecisionOrigin, isEvaluationVerdict, isGeneratedResponseStatus, isJudgemeConversation, isJudgemeTicket, isOutcome, isPromptUsage, isPromptUsedIn, isSendable, isSendableVerdict, isTerminalStatus, isTicketClosed, isWhatsappChevronNote, isWhatsappTicket, lastCustomerMessage, needsRevision, openTicketKeyFor, parseReferences, pipelineStateRecord, promptCacheRecord, promptUsageOf, publicationMode, rawTicketFactsAt, readConversationEnd, reclaimStalledSend, reconstructGuardrailHits, requiresFollowup, resolvePromptName, runGuardrails, runTicket, settingsToProfile, settingsWarnings, stopOptOut, systemPromptOf, targetRefFor, toConversationEnd, toDecisionOrigin, toSharedPromptUsages, validateSettings, verifyReply, whatsappModeFromLegacyBoolean };
package/dist/index.d.ts CHANGED
@@ -940,6 +940,57 @@ declare function isDecisionOrigin(value: unknown): value is DecisionOrigin;
940
940
  /** Reads an untrusted stored value, falling back to the least-privileged origin. */
941
941
  declare function toDecisionOrigin(value: unknown): DecisionOrigin;
942
942
 
943
+ declare const GENERATION_MODES: readonly ["auto", "operator"];
944
+ type GenerationMode = (typeof GENERATION_MODES)[number];
945
+ declare const PROMPT_USAGES: readonly ["always", "auto", "operator"];
946
+ type PromptUsage = (typeof PROMPT_USAGES)[number];
947
+ declare const DEFAULT_PROMPT_USAGE: PromptUsage;
948
+ /** Prompt name → usage. A name that is absent is `always`. */
949
+ type SharedPromptUsages = Record<string, PromptUsage>;
950
+ declare function isPromptUsage(value: unknown): value is PromptUsage;
951
+ /**
952
+ * Reads the stored setting. Anything that is not a known usage is dropped,
953
+ * which makes that prompt `always`: an unreadable entry must never silently
954
+ * remove a block from every reply.
955
+ */
956
+ declare function toSharedPromptUsages(value: unknown): SharedPromptUsages;
957
+ /** A system prompt's usage is fixed by the code: the stored setting never overrides it. */
958
+ declare function promptUsageOf(name: string, usages: SharedPromptUsages): PromptUsage;
959
+ declare function isPromptUsedIn(mode: GenerationMode, usage: PromptUsage): boolean;
960
+
961
+ /**
962
+ * Shared prompts the kit itself reads, by name.
963
+ *
964
+ * Every other `shared/*` prompt exists because an agent prompt references it.
965
+ * These exist because the code asks for them: the name is fixed here, and the
966
+ * text written here is what is served until a version is published (and
967
+ * whenever the published one cannot be read). The team edits the text like
968
+ * any other shared prompt; it cannot rename it or make it disappear.
969
+ */
970
+
971
+ interface SystemPrompt {
972
+ name: string;
973
+ /** What it is for, in the team's words. */
974
+ description: string;
975
+ /** Fixed: the code decides when it is read, not the usage setting. */
976
+ usage: PromptUsage;
977
+ defaultContent: string;
978
+ }
979
+ declare const OPERATOR_MODE_PROMPT_NAME = "shared/mode-operateur";
980
+ /**
981
+ * Tells the model who it is writing for. The agent prompts are written for
982
+ * the pipeline answering alone, and their limits ("jamais plus de 5 % sans
983
+ * validation humaine", "un agent reviendra vers vous") turned an operator's
984
+ * own instruction into a hand-off to the very person asking.
985
+ *
986
+ * The extension sends what the operator typed as a last message worded
987
+ * "Merci d'utiliser le contexte suivant…": the text names it so the model
988
+ * reads it as an instruction and not as background.
989
+ */
990
+ declare const DEFAULT_OPERATOR_MODE_PROMPT: string;
991
+ declare const SYSTEM_PROMPTS: readonly SystemPrompt[];
992
+ declare function systemPromptOf(name: string): SystemPrompt | undefined;
993
+
943
994
  /**
944
995
  * Run budget: bounds a run in TOOL CALLS and TIME only, never in money —
945
996
  * cost is measured (`charge`, I15) and watched separately, not capped here.
@@ -1853,6 +1904,25 @@ interface PromptResolverDeps {
1853
1904
  now?: () => number;
1854
1905
  /** Fires at every silent-degradation point in the ladder (post-review E). */
1855
1906
  onDegraded?: (event: PromptDegradedEvent) => void;
1907
+ /**
1908
+ * Which composition targets this resolver composes, asked once per
1909
+ * resolution. A target `isActive` answers `false` for resolves to nothing,
1910
+ * as if its tag were not there: this is how a shared prompt restricted to
1911
+ * one generation mode stays out of the other (`domain/prompt-usage.ts`).
1912
+ * Absent, every target is composed.
1913
+ *
1914
+ * `cacheScope` keeps the `prompt-cache` mirror entries of one filter apart
1915
+ * from every other's. It must change whenever the filter's answers do: the
1916
+ * mirror holds COMPOSED text, so an entry written under one set of
1917
+ * restrictions would otherwise be served, on a Langfuse outage, to a
1918
+ * resolution that has since been told to leave a block out. Absent, the
1919
+ * historical unscoped key is used.
1920
+ */
1921
+ referenceFilter?: () => Promise<ReferenceFilter>;
1922
+ }
1923
+ interface ReferenceFilter {
1924
+ isActive: (name: string) => boolean;
1925
+ cacheScope?: string;
1856
1926
  }
1857
1927
  /** Builds a `PromptPort` implementing §3.7's three-level fallback ladder. */
1858
1928
  declare function createPromptResolver(deps: PromptResolverDeps): PromptPort;
@@ -2279,6 +2349,8 @@ interface SupportKitSettings {
2279
2349
  noreplySenders: string[];
2280
2350
  channelPromptEmail: string;
2281
2351
  channelPromptWhatsapp: string;
2352
+ /** Optional: apps deployed before the field existed store none, read as every shared prompt `always`. */
2353
+ sharedPromptUsages?: SharedPromptUsages;
2282
2354
  renameEnabled: boolean;
2283
2355
  renameFrom: string;
2284
2356
  renameTo: string;
@@ -2509,4 +2581,4 @@ interface SupportPipelineFragments {
2509
2581
  }
2510
2582
  declare function buildSupportPipeline(config: SupportPipelineConfig): SupportPipelineFragments;
2511
2583
 
2512
- export { AGENT_GUARDRAILS, AGENT_STATUSES, AGENT_TOOLS, ATTACHMENT_MARKER_ONLY, type ActionDecision, type AgentProfile, type AgentStatus, type AuditTags, type AutoReplyGuardSettings, type AwaitingSince, type Budget, CANDIDATE_MIN_LENGTH, COLLISION_GUARDRAILS, CONVERSATION_END_ACTIONS, type CatalogueTool, type CategoryPolicy, type CategoryReferentialEntry, type ChannelKind, type ChatMessage, type Classification, type ClockPort, type CollisionGuardrailId, type CompletionRequest, type CompletionResult, type Conversation, type ConversationEndAction, type ConversationEndConfig, type ConversationEndSettings, type ConversationPort, type ConversationRef, type CostLedger, type CustomerInfo, DECISION_ORIGINS, DEFAULT_AUTO_SEND_CHANNELS, DEFAULT_CHANNEL_PROMPT_EMAIL, DEFAULT_CHANNEL_PROMPT_WHATSAPP, DEFAULT_CONVERSATION_END_TAG, DEFAULT_DECISION_ORIGIN, DEFAULT_LLM_PROVIDER, DEFAULT_PROFILE_KEY, DEFAULT_WHATSAPP_MODE, type DecisionOrigin, type Draft, type DraftAttribution, type DraftNodeConfig, EVALUATION_VERDICTS, type EscalateNodeConfig, type EvaluateNodeConfig, type EvaluationVerdict, GENERATED_RESPONSE_STATUSES, type GeneratedResponseStatus, type GuardrailId, type IneligibleReason, InvalidStatusTransitionError, type JsonSchema, type JudgedReply, type KnowledgeHit, type LlmPort, type Message, MissingPromptError, NODE_NAMES, type Node, type NodeCost, type NodeDeps, type NodeKey, type NodeName, type NodeStep, ORIGIN_DESCRIPTION, OUTCOMES, type OrderSummary, type OutboundReply, type Outcome, PROMPT_SLOTS, type PlatformPromptReader, type PortName, type PromptCacheEntry, type PromptCachePort, type PromptDegradedEvent, type PromptNameConfig, type PromptPort, type PromptRef, type PromptReference, type PromptResolverDeps, type PromptSlot, type PromptTableKey, type ProposedAction, type PublicationMode, REASONING_MAX_LEN, type RawPrompt, type RawPromptConfig, type RawTicket, type RawTicketFactsAt, type ReasoningEffort, type ReconstructHoldInput, type RecordDef, type ReplyPort, type ResolvedPrompt, type ResumeFrom, type ReviseNodeConfig, type RunGuardrailsInput, type RunStamp, type RunTicketOptions, type RunUntil, STOP_PHRASES, SUPPORT_CHANNELS, SUPPORT_KIT_SETTINGS_FIELDS, type SettingsIssueKey, type SettingsValidationIssue, type SettingsWarning, type SettingsWarningKey, type SimilarTicket, type SourceDescriptor, type StatePort, type SupportChannel, type SupportKitNodeSettings, type SupportKitSettings, type SupportPipelineConfig, type SupportPipelineFragments, type TicketRunState, type ToolCallRecord, type ToolCallRequest, type ToolContext, type ToolPolicy, type ToolSpec, type TrackingSummary, type TriageNodeConfig, UNCERTAINTY_MARKERS, type Usage, type Verdict, type VerifyReplyInput, type VerifyReplyResult, WHATSAPP_MODES, WHATSAPP_NOTE_CHEVRON, type WhatsappMode, accountChannelAddress, agentRecord, answerableChannels, assertTransition, buildCategoryRecord, buildDiffAnalysisRecord, buildEvaluationRecord, buildGeneratedResponseRecord, buildReplyTimingRecord, buildResponseComparisonRecord, buildSupportKitRecords, buildSupportPipeline, buildTriageDecisionRecord, canTransition, categoryGroupRecord, channelPreGates, conversationEndEffects, createBudget, createPromptResolver, customerChannelAddress, diffAnalysisUniqueKey, firstCustomerMessage, guardrailBucket, hasCustomerAttachment, hasReferences, initialState, isAutoSendEligible, isAutomatedSenderEmail, isAutomatedSenderTicket, isCustomerTurnWithWords, isDecisionOrigin, isEvaluationVerdict, isGeneratedResponseStatus, isJudgemeConversation, isJudgemeTicket, isOutcome, isSendable, isSendableVerdict, isTerminalStatus, isTicketClosed, isWhatsappChevronNote, isWhatsappTicket, lastCustomerMessage, needsRevision, openTicketKeyFor, parseReferences, pipelineStateRecord, promptCacheRecord, publicationMode, rawTicketFactsAt, readConversationEnd, reclaimStalledSend, reconstructGuardrailHits, requiresFollowup, resolvePromptName, runGuardrails, runTicket, settingsToProfile, settingsWarnings, stopOptOut, targetRefFor, toConversationEnd, toDecisionOrigin, validateSettings, verifyReply, whatsappModeFromLegacyBoolean };
2584
+ export { AGENT_GUARDRAILS, AGENT_STATUSES, AGENT_TOOLS, ATTACHMENT_MARKER_ONLY, type ActionDecision, type AgentProfile, type AgentStatus, type AuditTags, type AutoReplyGuardSettings, type AwaitingSince, type Budget, CANDIDATE_MIN_LENGTH, COLLISION_GUARDRAILS, CONVERSATION_END_ACTIONS, type CatalogueTool, type CategoryPolicy, type CategoryReferentialEntry, type ChannelKind, type ChatMessage, type Classification, type ClockPort, type CollisionGuardrailId, type CompletionRequest, type CompletionResult, type Conversation, type ConversationEndAction, type ConversationEndConfig, type ConversationEndSettings, type ConversationPort, type ConversationRef, type CostLedger, type CustomerInfo, DECISION_ORIGINS, DEFAULT_AUTO_SEND_CHANNELS, DEFAULT_CHANNEL_PROMPT_EMAIL, DEFAULT_CHANNEL_PROMPT_WHATSAPP, DEFAULT_CONVERSATION_END_TAG, DEFAULT_DECISION_ORIGIN, DEFAULT_LLM_PROVIDER, DEFAULT_OPERATOR_MODE_PROMPT, DEFAULT_PROFILE_KEY, DEFAULT_PROMPT_USAGE, DEFAULT_WHATSAPP_MODE, type DecisionOrigin, type Draft, type DraftAttribution, type DraftNodeConfig, EVALUATION_VERDICTS, type EscalateNodeConfig, type EvaluateNodeConfig, type EvaluationVerdict, GENERATED_RESPONSE_STATUSES, GENERATION_MODES, type GeneratedResponseStatus, type GenerationMode, type GuardrailId, type IneligibleReason, InvalidStatusTransitionError, type JsonSchema, type JudgedReply, type KnowledgeHit, type LlmPort, type Message, MissingPromptError, NODE_NAMES, type Node, type NodeCost, type NodeDeps, type NodeKey, type NodeName, type NodeStep, OPERATOR_MODE_PROMPT_NAME, ORIGIN_DESCRIPTION, OUTCOMES, type OrderSummary, type OutboundReply, type Outcome, PROMPT_SLOTS, PROMPT_USAGES, type PlatformPromptReader, type PortName, type PromptCacheEntry, type PromptCachePort, type PromptDegradedEvent, type PromptNameConfig, type PromptPort, type PromptRef, type PromptReference, type PromptResolverDeps, type PromptSlot, type PromptTableKey, type PromptUsage, type ProposedAction, type PublicationMode, REASONING_MAX_LEN, type RawPrompt, type RawPromptConfig, type RawTicket, type RawTicketFactsAt, type ReasoningEffort, type ReconstructHoldInput, type RecordDef, type ReplyPort, type ResolvedPrompt, type ResumeFrom, type ReviseNodeConfig, type RunGuardrailsInput, type RunStamp, type RunTicketOptions, type RunUntil, STOP_PHRASES, SUPPORT_CHANNELS, SUPPORT_KIT_SETTINGS_FIELDS, SYSTEM_PROMPTS, type SettingsIssueKey, type SettingsValidationIssue, type SettingsWarning, type SettingsWarningKey, type SharedPromptUsages, type SimilarTicket, type SourceDescriptor, type StatePort, type SupportChannel, type SupportKitNodeSettings, type SupportKitSettings, type SupportPipelineConfig, type SupportPipelineFragments, type SystemPrompt, type TicketRunState, type ToolCallRecord, type ToolCallRequest, type ToolContext, type ToolPolicy, type ToolSpec, type TrackingSummary, type TriageNodeConfig, UNCERTAINTY_MARKERS, type Usage, type Verdict, type VerifyReplyInput, type VerifyReplyResult, WHATSAPP_MODES, WHATSAPP_NOTE_CHEVRON, type WhatsappMode, accountChannelAddress, agentRecord, answerableChannels, assertTransition, buildCategoryRecord, buildDiffAnalysisRecord, buildEvaluationRecord, buildGeneratedResponseRecord, buildReplyTimingRecord, buildResponseComparisonRecord, buildSupportKitRecords, buildSupportPipeline, buildTriageDecisionRecord, canTransition, categoryGroupRecord, channelPreGates, conversationEndEffects, createBudget, createPromptResolver, customerChannelAddress, diffAnalysisUniqueKey, firstCustomerMessage, guardrailBucket, hasCustomerAttachment, hasReferences, initialState, isAutoSendEligible, isAutomatedSenderEmail, isAutomatedSenderTicket, isCustomerTurnWithWords, isDecisionOrigin, isEvaluationVerdict, isGeneratedResponseStatus, isJudgemeConversation, isJudgemeTicket, isOutcome, isPromptUsage, isPromptUsedIn, isSendable, isSendableVerdict, isTerminalStatus, isTicketClosed, isWhatsappChevronNote, isWhatsappTicket, lastCustomerMessage, needsRevision, openTicketKeyFor, parseReferences, pipelineStateRecord, promptCacheRecord, promptUsageOf, publicationMode, rawTicketFactsAt, readConversationEnd, reclaimStalledSend, reconstructGuardrailHits, requiresFollowup, resolvePromptName, runGuardrails, runTicket, settingsToProfile, settingsWarnings, stopOptOut, systemPromptOf, targetRefFor, toConversationEnd, toDecisionOrigin, toSharedPromptUsages, validateSettings, verifyReply, whatsappModeFromLegacyBoolean };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { CATEGORY_GROUP_FIELD_NAME_UID, CATEGORY_GROUP_FIELD_ORDER_UID, PIPELINE_STATE_FIELD_SINGLETON_KEY_UID, PIPELINE_STATE_FIELD_SOURCE_VIEW_ID_UID, PIPELINE_STATE_FIELD_LAST_TRIAGE_AT_UID, PIPELINE_STATE_FIELD_LAST_SWEEP_AT_UID, PROMPT_CACHE_FIELD_PROMPT_KEY_UID, PROMPT_CACHE_FIELD_CONTENT_UID, PROMPT_CACHE_FIELD_VERSION_UID, PROMPT_CACHE_FIELD_LABEL_UID, PROMPT_CACHE_FIELD_CONFIG_UID, OUTCOMES, CATEGORY_GROUP_INDEX_NAME_UID, CATEGORY_GROUP_OBJECT_UID, PIPELINE_STATE_INDEX_SINGLETON_KEY_UID, PIPELINE_STATE_OBJECT_UID, PROMPT_CACHE_INDEX_PROMPT_KEY_UID, PROMPT_CACHE_OBJECT_UID, CATEGORY_INDEX_TAG_NAME_UID, CATEGORY_INDEX_NAME_UID, CATEGORY_INDEX_ORDER_UID, CATEGORY_FIELD_NAME_UID, CATEGORY_FIELD_TAG_NAME_UID, CATEGORY_FIELD_ORDER_UID, CATEGORY_FIELD_GROUP_ID_UID, CATEGORY_FIELD_AGENT_ID_UID, CATEGORY_FIELD_EXTRA_TAGS_UID, CATEGORY_FIELD_DESCRIPTION_UID, CATEGORY_FIELD_EXAMPLES_UID, CATEGORY_FIELD_FAST_RESPONSE_ENABLED_UID, CATEGORY_FIELD_AUTO_REPLY_ENABLED_UID, CATEGORY_FIELD_FOLLOWUP_FAST_RESPONSE_ENABLED_UID, CATEGORY_FIELD_FOLLOWUP_AUTO_REPLY_ENABLED_UID, CATEGORY_OBJECT_UID, TRIAGE_DECISION_INDEX_TICKET_ID_UID, TRIAGE_DECISION_INDEX_DECIDED_AT_UID, TRIAGE_DECISION_INDEX_ESCALATED_UID, TRIAGE_DECISION_FIELD_TICKET_ID_UID, TRIAGE_DECISION_FIELD_TICKET_URL_UID, TRIAGE_DECISION_FIELD_DECIDED_AT_UID, TRIAGE_DECISION_FIELD_CATEGORY_ID_UID, TRIAGE_DECISION_FIELD_TAG_UID, TRIAGE_DECISION_FIELD_CONFIDENCE_UID, TRIAGE_DECISION_FIELD_REASONING_UID, TRIAGE_DECISION_FIELD_CONVERSATION_OVER_UID, TRIAGE_DECISION_FIELD_ESCALATED_UID, TRIAGE_DECISION_FIELD_ESCALATION_CONFIDENCE_UID, TRIAGE_DECISION_FIELD_ESCALATION_REASONING_UID, TRIAGE_DECISION_FIELD_STATUS_UID, TRIAGE_DECISION_FIELD_ERROR_UID, TRIAGE_DECISION_FIELD_RUN_ID_UID, TRIAGE_DECISION_FIELD_SUBJECT_RENAMED_UID, DEFAULT_DECISION_ORIGIN, ORIGIN_DESCRIPTION, TRIAGE_DECISION_FIELD_ORIGIN_UID, TRIAGE_DECISION_FIELD_LANGFUSE_TRACE_ID_UID, TRIAGE_DECISION_FIELD_LANGFUSE_OBSERVATION_IDS_UID, TRIAGE_DECISION_OBJECT_UID, GENERATED_RESPONSE_INDEX_TICKET_ID_UID, GENERATED_RESPONSE_INDEX_OPEN_TICKET_KEY_UID, GENERATED_RESPONSE_INDEX_STATUS_UID, GENERATED_RESPONSE_INDEX_TRIAGE_DECISION_ID_UID, GENERATED_RESPONSE_INDEX_GENERATED_AT_UID, GENERATED_RESPONSE_INDEX_EXPIRES_AT_UID, GENERATED_RESPONSE_FIELD_TICKET_ID_UID, GENERATED_RESPONSE_FIELD_OPEN_TICKET_KEY_UID, GENERATED_RESPONSE_STATUSES, GENERATED_RESPONSE_FIELD_STATUS_UID, GENERATED_RESPONSE_FIELD_TRIAGE_DECISION_ID_UID, GENERATED_RESPONSE_FIELD_CATEGORY_ID_UID, GENERATED_RESPONSE_FIELD_AGENT_ID_UID, GENERATED_RESPONSE_FIELD_CHANNEL_UID, GENERATED_RESPONSE_FIELD_INELIGIBLE_REASON_UID, GENERATED_RESPONSE_FIELD_SOURCE_CHANNEL_UID, GENERATED_RESPONSE_FIELD_RESPONSE_TEXT_UID, GENERATED_RESPONSE_FIELD_SOURCES_UID, GENERATED_RESPONSE_FIELD_TRACED_INPUT_UID, GENERATED_RESPONSE_FIELD_VERDICT_UID, GENERATED_RESPONSE_FIELD_GUARDRAIL_HITS_UID, GENERATED_RESPONSE_FIELD_GUARDRAIL_HITS_RECONSTRUCTED_AT_UID, GENERATED_RESPONSE_FIELD_OUTCOME_UID, GENERATED_RESPONSE_FIELD_AUTO_SEND_DECISION_UID, GENERATED_RESPONSE_FIELD_FOLLOWUP_REQUIRED_UID, GENERATED_RESPONSE_FIELD_SERVED_COUNT_UID, GENERATED_RESPONSE_FIELD_SERVED_TO_UID, GENERATED_RESPONSE_FIELD_GENERATED_AT_UID, GENERATED_RESPONSE_FIELD_EXPIRES_AT_UID, GENERATED_RESPONSE_FIELD_SENT_AT_UID, GENERATED_RESPONSE_FIELD_SENT_MESSAGE_ID_UID, GENERATED_RESPONSE_FIELD_LANGFUSE_TRACE_ID_UID, GENERATED_RESPONSE_FIELD_LANGFUSE_OBSERVATION_ID_UID, GENERATED_RESPONSE_FIELD_PROMPT_NAME_UID, GENERATED_RESPONSE_FIELD_PROMPT_VERSION_UID, GENERATED_RESPONSE_FIELD_ERROR_UID, GENERATED_RESPONSE_FIELD_GENERATED_MESSAGE_COUNT_UID, GENERATED_RESPONSE_FIELD_GENERATED_LAST_MESSAGE_AT_UID, GENERATED_RESPONSE_FIELD_SENDING_AT_UID, GENERATED_RESPONSE_FIELD_RUN_ID_UID, GENERATED_RESPONSE_FIELD_ORIGIN_UID, GENERATED_RESPONSE_OBJECT_UID, RESPONSE_COMPARISON_INDEX_CAPTURED_AT_UID, RESPONSE_COMPARISON_INDEX_TICKET_ID_UID, RESPONSE_COMPARISON_FIELD_GENERATED_TEXT_UID, RESPONSE_COMPARISON_FIELD_SENT_TEXT_UID, RESPONSE_COMPARISON_FIELD_CAPTURED_AT_UID, RESPONSE_COMPARISON_FIELD_TICKET_ID_UID, RESPONSE_COMPARISON_FIELD_TICKET_URL_UID, RESPONSE_COMPARISON_FIELD_AGENT_ID_UID, RESPONSE_COMPARISON_FIELD_LANGFUSE_TRACE_ID_UID, RESPONSE_COMPARISON_FIELD_LANGFUSE_OBSERVATION_ID_UID, RESPONSE_COMPARISON_FIELD_PROMPT_NAME_UID, RESPONSE_COMPARISON_FIELD_PROMPT_VERSION_UID, RESPONSE_COMPARISON_FIELD_CONVERSATION_MESSAGES_UID, RESPONSE_COMPARISON_FIELD_DIFF_UID, RESPONSE_COMPARISON_OBJECT_UID, EVALUATION_FIELD_AGENT_ID_UID, EVALUATION_FIELD_SATISFIED_UID, EVALUATION_FIELD_MESSAGES_UID, EVALUATION_FIELD_TICKET_URL_UID, EVALUATION_FIELD_LANGFUSE_TRACE_ID_UID, EVALUATION_FIELD_LANGFUSE_OBSERVATION_ID_UID, EVALUATION_FIELD_SUPPORT_USER_KEY_ID_UID, EVALUATION_OBJECT_UID, DIFF_ANALYSIS_INDEX_UNIQUE_KEY_UID, DIFF_ANALYSIS_FIELD_AGENT_ID_UID, DIFF_ANALYSIS_FIELD_PROMPT_NAME_UID, DIFF_ANALYSIS_FIELD_PROMPT_VERSION_UID, DIFF_ANALYSIS_FIELD_POINTS_UID, DIFF_ANALYSIS_FIELD_UNIQUE_KEY_UID, DIFF_ANALYSIS_OBJECT_UID, REPLY_TIMING_INDEX_TURN_KEY_UID, REPLY_TIMING_INDEX_TICKET_ID_UID, REPLY_TIMING_INDEX_CUSTOMER_MESSAGE_AT_UID, REPLY_TIMING_INDEX_RESPONDER_UID, REPLY_TIMING_INDEX_NEXT_CHECK_AT_UID, REPLY_TIMING_FIELD_TICKET_ID_UID, REPLY_TIMING_FIELD_TURN_KEY_UID, REPLY_TIMING_FIELD_CUSTOMER_MESSAGE_AT_UID, REPLY_TIMING_FIELD_REPLIED_AT_UID, RESPONDERS, REPLY_TIMING_FIELD_RESPONDER_UID, REPLY_TIMING_FIELD_RESPONDER_VIA_UID, REPLY_TIMING_FIELD_DELAY_SECONDS_UID, DELAY_BUCKETS, REPLY_TIMING_FIELD_DELAY_BUCKET_UID, REPLY_TIMING_FIELD_CATEGORY_ID_UID, REPLY_TIMING_FIELD_SOURCE_CHANNEL_UID, REPLY_TIMING_FIELD_GENERATED_RESPONSE_ID_UID, REPLY_TIMING_FIELD_NEXT_CHECK_AT_UID, REPLY_TIMING_FIELD_BACKFILLED_UID, REPLY_TIMING_FIELD_ORIGIN_UID, REPLY_TIMING_OBJECT_UID, agentRecord, SUPPORT_KIT_SETTINGS_FIELDS, MissingPromptError, validateSettings, settingsToProfile, buildPromptsTable, draftPromptRefFor, assertTransition, openTicketKeyFor, act, initialState, applyOutcomeTags, listCategories, resolveDraftAgent, runTicket, toCategoryReferential, toAgent, draftRebinder, resolvePromptName, listAgents, PROMPT_SLOTS, isGeneratedResponseStatus, isInvalidatableStatus, DEFAULT_LLM_PROVIDER, AGENT_PAGE_SIZE, CATEGORY_PAGE_SIZE, toCategoryGroup, toCategory, compareByGroupThenCategory, toGeneratedResponse, NODE_NAMES, toConversation, readConversationEnd, endConfigOf, stopOptOut, ToolInputError, DEFAULT_CHANNEL_PROMPT_EMAIL, DEFAULT_CHANNEL_PROMPT_WHATSAPP, reclaimStalledSend, applySignature, snapshotConversation, isEvaluationVerdict, requiresFollowup, computeWordDiff, closingFields, turnKeyFor, findCategoryByTag, REASONING_MAX_LEN, isTerminalStatus, canTransition, toDecisionOrigin, TRIAGE_LABEL, ESCALATION_LABEL, isFallbackClassification, hasNoDraftNode, isCustomerTurnWithWords, FIRST_CHECK_DELAY_MS, conversationEndEffects, dayRangeOf, assertOptionalBoolean, readCategoryNames, periodBoundsOf, WEEKLY_BUCKET_FROM_DAYS, CATEGORY_TOP_N, previousRangeOf, DEFAULT_STATS_TIMEZONE, OUTCOME_GROUP_BY, OUTCOME_METRICS, TRIAGE_HANDOFF_GROUP_BY, CATEGORY_TRIAGE_GROUP_BY, CATEGORY_OUTCOME_GROUP_BY, toTriageDecision, latestResponsesByTicket, newestPerTicket, NEWEST_DECISION_FIRST, isUnautomatedTriage, listTicketResponses, buildTimelineSteps, toDeliveryPolicy, toResponseComparison, foldOutcomes, foldDailyOutcomes, dashboardSignals, countFailed, fillMissingDays, foldCategoryOutcomes, foldHumanReasons, autonomyRate, sumCounts, isOutcome, promptRefFor, countOf } from './chunk-ZKFQ3DIY.js';
2
- export { AGENT_GUARDRAILS, AGENT_STATUSES, AGENT_TOOLS, ATTACHMENT_MARKER_ONLY, CANDIDATE_MIN_LENGTH, COLLISION_GUARDRAILS, CONVERSATION_END_ACTIONS, DECISION_ORIGINS, DEFAULT_AUTO_SEND_CHANNELS, DEFAULT_CHANNEL_PROMPT_EMAIL, DEFAULT_CHANNEL_PROMPT_WHATSAPP, DEFAULT_CONVERSATION_END_TAG, DEFAULT_DECISION_ORIGIN, DEFAULT_LLM_PROVIDER, DEFAULT_PROFILE_KEY, DEFAULT_WHATSAPP_MODE, EVALUATION_VERDICTS, GENERATED_RESPONSE_STATUSES, InvalidStatusTransitionError, MissingPromptError, NODE_NAMES, ORIGIN_DESCRIPTION, OUTCOMES, PROMPT_SLOTS, REASONING_MAX_LEN, STOP_PHRASES, SUPPORT_CHANNELS, SUPPORT_KIT_SETTINGS_FIELDS, UNCERTAINTY_MARKERS, WHATSAPP_MODES, WHATSAPP_NOTE_CHEVRON, accountChannelAddress, agentRecord, answerableChannels, assertTransition, canTransition, channelPreGates, conversationEndEffects, customerChannelAddress, firstCustomerMessage, guardrailBucket, hasCustomerAttachment, initialState, isAutoSendEligible, isAutomatedSenderEmail, isAutomatedSenderTicket, isCustomerTurnWithWords, isDecisionOrigin, isEvaluationVerdict, isGeneratedResponseStatus, isJudgemeConversation, isJudgemeTicket, isOutcome, isSendable, isSendableVerdict, isTerminalStatus, isTicketClosed, isWhatsappChevronNote, isWhatsappTicket, lastCustomerMessage, needsRevision, openTicketKeyFor, publicationMode, rawTicketFactsAt, readConversationEnd, reclaimStalledSend, reconstructGuardrailHits, requiresFollowup, resolvePromptName, runGuardrails, runTicket, settingsToProfile, settingsWarnings, stopOptOut, toConversationEnd, toDecisionOrigin, validateSettings, verifyReply, whatsappModeFromLegacyBoolean } from './chunk-ZKFQ3DIY.js';
1
+ import { CATEGORY_GROUP_FIELD_NAME_UID, CATEGORY_GROUP_FIELD_ORDER_UID, PIPELINE_STATE_FIELD_SINGLETON_KEY_UID, PIPELINE_STATE_FIELD_SOURCE_VIEW_ID_UID, PIPELINE_STATE_FIELD_LAST_TRIAGE_AT_UID, PIPELINE_STATE_FIELD_LAST_SWEEP_AT_UID, PROMPT_CACHE_FIELD_PROMPT_KEY_UID, PROMPT_CACHE_FIELD_CONTENT_UID, PROMPT_CACHE_FIELD_VERSION_UID, PROMPT_CACHE_FIELD_LABEL_UID, PROMPT_CACHE_FIELD_CONFIG_UID, OUTCOMES, CATEGORY_GROUP_INDEX_NAME_UID, CATEGORY_GROUP_OBJECT_UID, PIPELINE_STATE_INDEX_SINGLETON_KEY_UID, PIPELINE_STATE_OBJECT_UID, PROMPT_CACHE_INDEX_PROMPT_KEY_UID, PROMPT_CACHE_OBJECT_UID, hasReferences, CATEGORY_INDEX_TAG_NAME_UID, CATEGORY_INDEX_NAME_UID, CATEGORY_INDEX_ORDER_UID, CATEGORY_FIELD_NAME_UID, CATEGORY_FIELD_TAG_NAME_UID, CATEGORY_FIELD_ORDER_UID, CATEGORY_FIELD_GROUP_ID_UID, CATEGORY_FIELD_AGENT_ID_UID, CATEGORY_FIELD_EXTRA_TAGS_UID, CATEGORY_FIELD_DESCRIPTION_UID, CATEGORY_FIELD_EXAMPLES_UID, CATEGORY_FIELD_FAST_RESPONSE_ENABLED_UID, CATEGORY_FIELD_AUTO_REPLY_ENABLED_UID, CATEGORY_FIELD_FOLLOWUP_FAST_RESPONSE_ENABLED_UID, CATEGORY_FIELD_FOLLOWUP_AUTO_REPLY_ENABLED_UID, CATEGORY_OBJECT_UID, TRIAGE_DECISION_INDEX_TICKET_ID_UID, TRIAGE_DECISION_INDEX_DECIDED_AT_UID, TRIAGE_DECISION_INDEX_ESCALATED_UID, TRIAGE_DECISION_FIELD_TICKET_ID_UID, TRIAGE_DECISION_FIELD_TICKET_URL_UID, TRIAGE_DECISION_FIELD_DECIDED_AT_UID, TRIAGE_DECISION_FIELD_CATEGORY_ID_UID, TRIAGE_DECISION_FIELD_TAG_UID, TRIAGE_DECISION_FIELD_CONFIDENCE_UID, TRIAGE_DECISION_FIELD_REASONING_UID, TRIAGE_DECISION_FIELD_CONVERSATION_OVER_UID, TRIAGE_DECISION_FIELD_ESCALATED_UID, TRIAGE_DECISION_FIELD_ESCALATION_CONFIDENCE_UID, TRIAGE_DECISION_FIELD_ESCALATION_REASONING_UID, TRIAGE_DECISION_FIELD_STATUS_UID, TRIAGE_DECISION_FIELD_ERROR_UID, TRIAGE_DECISION_FIELD_RUN_ID_UID, TRIAGE_DECISION_FIELD_SUBJECT_RENAMED_UID, DEFAULT_DECISION_ORIGIN, ORIGIN_DESCRIPTION, TRIAGE_DECISION_FIELD_ORIGIN_UID, TRIAGE_DECISION_FIELD_LANGFUSE_TRACE_ID_UID, TRIAGE_DECISION_FIELD_LANGFUSE_OBSERVATION_IDS_UID, TRIAGE_DECISION_OBJECT_UID, GENERATED_RESPONSE_INDEX_TICKET_ID_UID, GENERATED_RESPONSE_INDEX_OPEN_TICKET_KEY_UID, GENERATED_RESPONSE_INDEX_STATUS_UID, GENERATED_RESPONSE_INDEX_TRIAGE_DECISION_ID_UID, GENERATED_RESPONSE_INDEX_GENERATED_AT_UID, GENERATED_RESPONSE_INDEX_EXPIRES_AT_UID, GENERATED_RESPONSE_FIELD_TICKET_ID_UID, GENERATED_RESPONSE_FIELD_OPEN_TICKET_KEY_UID, GENERATED_RESPONSE_STATUSES, GENERATED_RESPONSE_FIELD_STATUS_UID, GENERATED_RESPONSE_FIELD_TRIAGE_DECISION_ID_UID, GENERATED_RESPONSE_FIELD_CATEGORY_ID_UID, GENERATED_RESPONSE_FIELD_AGENT_ID_UID, GENERATED_RESPONSE_FIELD_CHANNEL_UID, GENERATED_RESPONSE_FIELD_INELIGIBLE_REASON_UID, GENERATED_RESPONSE_FIELD_SOURCE_CHANNEL_UID, GENERATED_RESPONSE_FIELD_RESPONSE_TEXT_UID, GENERATED_RESPONSE_FIELD_SOURCES_UID, GENERATED_RESPONSE_FIELD_TRACED_INPUT_UID, GENERATED_RESPONSE_FIELD_VERDICT_UID, GENERATED_RESPONSE_FIELD_GUARDRAIL_HITS_UID, GENERATED_RESPONSE_FIELD_GUARDRAIL_HITS_RECONSTRUCTED_AT_UID, GENERATED_RESPONSE_FIELD_OUTCOME_UID, GENERATED_RESPONSE_FIELD_AUTO_SEND_DECISION_UID, GENERATED_RESPONSE_FIELD_FOLLOWUP_REQUIRED_UID, GENERATED_RESPONSE_FIELD_SERVED_COUNT_UID, GENERATED_RESPONSE_FIELD_SERVED_TO_UID, GENERATED_RESPONSE_FIELD_GENERATED_AT_UID, GENERATED_RESPONSE_FIELD_EXPIRES_AT_UID, GENERATED_RESPONSE_FIELD_SENT_AT_UID, GENERATED_RESPONSE_FIELD_SENT_MESSAGE_ID_UID, GENERATED_RESPONSE_FIELD_LANGFUSE_TRACE_ID_UID, GENERATED_RESPONSE_FIELD_LANGFUSE_OBSERVATION_ID_UID, GENERATED_RESPONSE_FIELD_PROMPT_NAME_UID, GENERATED_RESPONSE_FIELD_PROMPT_VERSION_UID, GENERATED_RESPONSE_FIELD_ERROR_UID, GENERATED_RESPONSE_FIELD_GENERATED_MESSAGE_COUNT_UID, GENERATED_RESPONSE_FIELD_GENERATED_LAST_MESSAGE_AT_UID, GENERATED_RESPONSE_FIELD_SENDING_AT_UID, GENERATED_RESPONSE_FIELD_RUN_ID_UID, GENERATED_RESPONSE_FIELD_ORIGIN_UID, GENERATED_RESPONSE_OBJECT_UID, RESPONSE_COMPARISON_INDEX_CAPTURED_AT_UID, RESPONSE_COMPARISON_INDEX_TICKET_ID_UID, RESPONSE_COMPARISON_FIELD_GENERATED_TEXT_UID, RESPONSE_COMPARISON_FIELD_SENT_TEXT_UID, RESPONSE_COMPARISON_FIELD_CAPTURED_AT_UID, RESPONSE_COMPARISON_FIELD_TICKET_ID_UID, RESPONSE_COMPARISON_FIELD_TICKET_URL_UID, RESPONSE_COMPARISON_FIELD_AGENT_ID_UID, RESPONSE_COMPARISON_FIELD_LANGFUSE_TRACE_ID_UID, RESPONSE_COMPARISON_FIELD_LANGFUSE_OBSERVATION_ID_UID, RESPONSE_COMPARISON_FIELD_PROMPT_NAME_UID, RESPONSE_COMPARISON_FIELD_PROMPT_VERSION_UID, RESPONSE_COMPARISON_FIELD_CONVERSATION_MESSAGES_UID, RESPONSE_COMPARISON_FIELD_DIFF_UID, RESPONSE_COMPARISON_OBJECT_UID, EVALUATION_FIELD_AGENT_ID_UID, EVALUATION_FIELD_SATISFIED_UID, EVALUATION_FIELD_MESSAGES_UID, EVALUATION_FIELD_TICKET_URL_UID, EVALUATION_FIELD_LANGFUSE_TRACE_ID_UID, EVALUATION_FIELD_LANGFUSE_OBSERVATION_ID_UID, EVALUATION_FIELD_SUPPORT_USER_KEY_ID_UID, EVALUATION_OBJECT_UID, DIFF_ANALYSIS_INDEX_UNIQUE_KEY_UID, DIFF_ANALYSIS_FIELD_AGENT_ID_UID, DIFF_ANALYSIS_FIELD_PROMPT_NAME_UID, DIFF_ANALYSIS_FIELD_PROMPT_VERSION_UID, DIFF_ANALYSIS_FIELD_POINTS_UID, DIFF_ANALYSIS_FIELD_UNIQUE_KEY_UID, DIFF_ANALYSIS_OBJECT_UID, REPLY_TIMING_INDEX_TURN_KEY_UID, REPLY_TIMING_INDEX_TICKET_ID_UID, REPLY_TIMING_INDEX_CUSTOMER_MESSAGE_AT_UID, REPLY_TIMING_INDEX_RESPONDER_UID, REPLY_TIMING_INDEX_NEXT_CHECK_AT_UID, REPLY_TIMING_FIELD_TICKET_ID_UID, REPLY_TIMING_FIELD_TURN_KEY_UID, REPLY_TIMING_FIELD_CUSTOMER_MESSAGE_AT_UID, REPLY_TIMING_FIELD_REPLIED_AT_UID, RESPONDERS, REPLY_TIMING_FIELD_RESPONDER_UID, REPLY_TIMING_FIELD_RESPONDER_VIA_UID, REPLY_TIMING_FIELD_DELAY_SECONDS_UID, DELAY_BUCKETS, REPLY_TIMING_FIELD_DELAY_BUCKET_UID, REPLY_TIMING_FIELD_CATEGORY_ID_UID, REPLY_TIMING_FIELD_SOURCE_CHANNEL_UID, REPLY_TIMING_FIELD_GENERATED_RESPONSE_ID_UID, REPLY_TIMING_FIELD_NEXT_CHECK_AT_UID, REPLY_TIMING_FIELD_BACKFILLED_UID, REPLY_TIMING_FIELD_ORIGIN_UID, REPLY_TIMING_OBJECT_UID, agentRecord, SUPPORT_KIT_SETTINGS_FIELDS, MissingPromptError, parseReferences, validateSettings, settingsToProfile, buildPromptsTable, draftPromptRefFor, assertTransition, openTicketKeyFor, act, initialState, applyOutcomeTags, listCategories, resolveDraftAgent, runTicket, toCategoryReferential, toAgent, draftRebinder, resolvePromptName, listAgents, PROMPT_SLOTS, isGeneratedResponseStatus, isInvalidatableStatus, DEFAULT_LLM_PROVIDER, AGENT_PAGE_SIZE, CATEGORY_PAGE_SIZE, toCategoryGroup, toCategory, compareByGroupThenCategory, toGeneratedResponse, NODE_NAMES, toConversation, readConversationEnd, endConfigOf, stopOptOut, ToolInputError, DEFAULT_CHANNEL_PROMPT_EMAIL, DEFAULT_CHANNEL_PROMPT_WHATSAPP, reclaimStalledSend, applySignature, snapshotConversation, isEvaluationVerdict, requiresFollowup, computeWordDiff, closingFields, turnKeyFor, findCategoryByTag, REASONING_MAX_LEN, isPromptUsedIn, promptUsageOf, isTerminalStatus, canTransition, toDecisionOrigin, DEFAULT_OPERATOR_MODE_PROMPT, OPERATOR_MODE_PROMPT_NAME, TRIAGE_LABEL, ESCALATION_LABEL, isFallbackClassification, hasNoDraftNode, toSharedPromptUsages, REFERENCE_TAG_SOURCE, isCustomerTurnWithWords, FIRST_CHECK_DELAY_MS, conversationEndEffects, dayRangeOf, assertOptionalBoolean, readCategoryNames, periodBoundsOf, WEEKLY_BUCKET_FROM_DAYS, CATEGORY_TOP_N, previousRangeOf, DEFAULT_STATS_TIMEZONE, OUTCOME_GROUP_BY, OUTCOME_METRICS, TRIAGE_HANDOFF_GROUP_BY, CATEGORY_TRIAGE_GROUP_BY, CATEGORY_OUTCOME_GROUP_BY, toTriageDecision, latestResponsesByTicket, newestPerTicket, NEWEST_DECISION_FIRST, isUnautomatedTriage, listTicketResponses, buildTimelineSteps, toDeliveryPolicy, toResponseComparison, foldOutcomes, foldDailyOutcomes, dashboardSignals, countFailed, fillMissingDays, foldCategoryOutcomes, foldHumanReasons, autonomyRate, sumCounts, isOutcome, promptRefFor, countOf } from './chunk-CHOOLNZW.js';
2
+ export { AGENT_GUARDRAILS, AGENT_STATUSES, AGENT_TOOLS, ATTACHMENT_MARKER_ONLY, CANDIDATE_MIN_LENGTH, COLLISION_GUARDRAILS, CONVERSATION_END_ACTIONS, DECISION_ORIGINS, DEFAULT_AUTO_SEND_CHANNELS, DEFAULT_CHANNEL_PROMPT_EMAIL, DEFAULT_CHANNEL_PROMPT_WHATSAPP, DEFAULT_CONVERSATION_END_TAG, DEFAULT_DECISION_ORIGIN, DEFAULT_LLM_PROVIDER, DEFAULT_OPERATOR_MODE_PROMPT, DEFAULT_PROFILE_KEY, DEFAULT_PROMPT_USAGE, DEFAULT_WHATSAPP_MODE, EVALUATION_VERDICTS, GENERATED_RESPONSE_STATUSES, GENERATION_MODES, InvalidStatusTransitionError, MissingPromptError, NODE_NAMES, OPERATOR_MODE_PROMPT_NAME, ORIGIN_DESCRIPTION, OUTCOMES, PROMPT_SLOTS, PROMPT_USAGES, REASONING_MAX_LEN, STOP_PHRASES, SUPPORT_CHANNELS, SUPPORT_KIT_SETTINGS_FIELDS, SYSTEM_PROMPTS, UNCERTAINTY_MARKERS, WHATSAPP_MODES, WHATSAPP_NOTE_CHEVRON, accountChannelAddress, agentRecord, answerableChannels, assertTransition, canTransition, channelPreGates, conversationEndEffects, customerChannelAddress, firstCustomerMessage, guardrailBucket, hasCustomerAttachment, hasReferences, initialState, isAutoSendEligible, isAutomatedSenderEmail, isAutomatedSenderTicket, isCustomerTurnWithWords, isDecisionOrigin, isEvaluationVerdict, isGeneratedResponseStatus, isJudgemeConversation, isJudgemeTicket, isOutcome, isPromptUsage, isPromptUsedIn, isSendable, isSendableVerdict, isTerminalStatus, isTicketClosed, isWhatsappChevronNote, isWhatsappTicket, lastCustomerMessage, needsRevision, openTicketKeyFor, parseReferences, promptUsageOf, publicationMode, rawTicketFactsAt, readConversationEnd, reclaimStalledSend, reconstructGuardrailHits, requiresFollowup, resolvePromptName, runGuardrails, runTicket, settingsToProfile, settingsWarnings, stopOptOut, systemPromptOf, toConversationEnd, toDecisionOrigin, toSharedPromptUsages, validateSettings, verifyReply, whatsappModeFromLegacyBoolean } from './chunk-CHOOLNZW.js';
3
3
  import { FieldType, APPROVAL_DECIDED_EVENT, AppApiError } from '@apotech-os/app-kit';
4
4
  import { createHash } from 'node:crypto';
5
5
 
@@ -42,22 +42,6 @@ function createBudget({ signal, maxToolCalls }) {
42
42
  }
43
43
  };
44
44
  }
45
-
46
- // src/prompts/references.ts
47
- var REF_RE = /@@@langfusePrompt:name=([^|@]+)\|(?:version=(\d+)|label=([^@]+))@@@/g;
48
- var REFERENCE_TAG_SOURCE = REF_RE.source;
49
- function parseReferences(content) {
50
- const refs = [];
51
- for (const [raw, name, version, label] of content.matchAll(REF_RE)) {
52
- refs.push(version !== void 0 ? { name, version: Number(version), raw } : { name, label, raw });
53
- }
54
- return refs;
55
- }
56
- function hasReferences(content) {
57
- return new RegExp(REF_RE.source).test(content);
58
- }
59
-
60
- // src/prompts/resolver.ts
61
45
  var PRODUCTION_LABEL = "production";
62
46
  var DEFAULT_TTL_MS = 6e4;
63
47
  var MAX_COMPOSITION_DEPTH = 5;
@@ -99,6 +83,7 @@ async function readComposed(name, opts, ctx, visited, depth) {
99
83
  return entry;
100
84
  }
101
85
  async function resolveOneReference(ref, ctx, visited, depth) {
86
+ if (!ctx.isActive(ref.name)) return "";
102
87
  if (visited.has(ref.name)) {
103
88
  ctx.onDegraded?.({ stage: "composition-cycle", name: ref.name, reason: "cyclic composition reference" });
104
89
  return "";
@@ -145,9 +130,29 @@ function createPromptResolver(deps) {
145
130
  const ttlMs = deps.ttlMs ?? DEFAULT_TTL_MS;
146
131
  const now = deps.now ?? Date.now;
147
132
  const memory = /* @__PURE__ */ new Map();
148
- const composeCtx = { platform: deps.platform, memory, ttlMs, now, onDegraded: deps.onDegraded };
133
+ const composeCtx = {
134
+ platform: deps.platform,
135
+ memory,
136
+ ttlMs,
137
+ now,
138
+ onDegraded: deps.onDegraded,
139
+ isActive: () => true
140
+ };
141
+ let cacheScope;
142
+ let filterLoad = null;
143
+ function loadFilter() {
144
+ if (!deps.referenceFilter) return Promise.resolve();
145
+ filterLoad ??= deps.referenceFilter().then((filter) => {
146
+ composeCtx.isActive = filter.isActive;
147
+ cacheScope = filter.cacheScope;
148
+ });
149
+ return filterLoad;
150
+ }
151
+ function persistKeyFor(name, label) {
152
+ return cacheScope ? `${name}${label}${cacheScope}` : cacheKey(name, label);
153
+ }
149
154
  async function resolveFromCacheOrFallback(name, label, ref, vars) {
150
- const cached = await deps.cache.read(cacheKey(name, label)).catch((err) => {
155
+ const cached = await deps.cache.read(persistKeyFor(name, label)).catch((err) => {
151
156
  deps.onDegraded?.({ stage: "cache-unavailable", name, reason: reasonOf(err) });
152
157
  return null;
153
158
  });
@@ -170,7 +175,8 @@ function createPromptResolver(deps) {
170
175
  return {
171
176
  async resolve(ref, vars) {
172
177
  const label = ref.label?.trim() || PRODUCTION_LABEL;
173
- const persistKey = cacheKey(ref.name, label);
178
+ await loadFilter();
179
+ const persistKey = persistKeyFor(ref.name, label);
174
180
  let resolved;
175
181
  try {
176
182
  resolved = await readComposed(ref.name, { label }, composeCtx, /* @__PURE__ */ new Set([ref.name]), 0);
@@ -1523,13 +1529,37 @@ function createRecordPromptCachePort(api) {
1523
1529
  }
1524
1530
  };
1525
1531
  }
1526
- function createPlatformPromptPort(api, log) {
1532
+ function createPlatformPromptPort(api, log, mode = "auto") {
1527
1533
  return createPromptResolver({
1528
1534
  platform: createPlatformPromptReader(api),
1529
1535
  cache: createRecordPromptCachePort(api),
1530
- onDegraded: (event) => log(`prompt resolution degraded [${event.stage}] ${event.name}: ${event.reason}`)
1536
+ onDegraded: (event) => log(`prompt resolution degraded [${event.stage}] ${event.name}: ${event.reason}`),
1537
+ referenceFilter: async () => {
1538
+ const usages = await readSharedPromptUsages(api, log);
1539
+ const left = Object.keys(usages).filter((name) => !isPromptUsedIn(mode, promptUsageOf(name, usages))).sort();
1540
+ return {
1541
+ // Asked per name, not read off `left`: a system prompt has a usage
1542
+ // without being listed in the setting. Its usage never changes, so it
1543
+ // has no place in the cache scope either.
1544
+ isActive: (name) => isPromptUsedIn(mode, promptUsageOf(name, usages)),
1545
+ // Names the prompts left out, so a change of usage reads a different
1546
+ // mirror entry instead of the text composed before it. `auto` with
1547
+ // nothing left out keeps the historical keys: it composes exactly
1548
+ // what this port always composed.
1549
+ cacheScope: mode === "auto" && left.length === 0 ? void 0 : `${mode}:${left.join(",")}`
1550
+ };
1551
+ }
1531
1552
  });
1532
1553
  }
1554
+ async function readSharedPromptUsages(api, log) {
1555
+ try {
1556
+ const settings = await api.settings.get();
1557
+ return toSharedPromptUsages(settings?.sharedPromptUsages);
1558
+ } catch (err) {
1559
+ log(`shared prompt usages unreadable, composing every shared prompt: ${err instanceof Error ? err.message : String(err)}`);
1560
+ return {};
1561
+ }
1562
+ }
1533
1563
  function createRealClock() {
1534
1564
  return { now: () => /* @__PURE__ */ new Date() };
1535
1565
  }
@@ -3361,7 +3391,7 @@ async function testAgentsHandler(ctx, config, input) {
3361
3391
  var LITERAL_PREFIX = "@@@langfusePrompt:";
3362
3392
  var MALFORMED_SNIPPET_MAX_LEN = 60;
3363
3393
  var MAX_CYCLE_DEPTH = 10;
3364
- var REF_RE2 = new RegExp(REFERENCE_TAG_SOURCE, "g");
3394
+ var REF_RE = new RegExp(REFERENCE_TAG_SOURCE, "g");
3365
3395
  function snippetAt(content, index) {
3366
3396
  const rest = content.slice(index);
3367
3397
  const closingIdx = rest.indexOf("@@@", LITERAL_PREFIX.length);
@@ -3370,7 +3400,7 @@ function snippetAt(content, index) {
3370
3400
  }
3371
3401
  function findMalformedTags(content) {
3372
3402
  if (!content.includes(LITERAL_PREFIX)) return [];
3373
- const validStarts = new Set([...content.matchAll(REF_RE2)].map((m) => m.index ?? -1));
3403
+ const validStarts = new Set([...content.matchAll(REF_RE)].map((m) => m.index ?? -1));
3374
3404
  const malformed = [];
3375
3405
  for (const m of content.matchAll(new RegExp(LITERAL_PREFIX, "g"))) {
3376
3406
  const index = m.index ?? -1;
@@ -4116,10 +4146,17 @@ async function probeChatOwnership(ctx, modelId) {
4116
4146
  async function executeChat(ctx, userId, input) {
4117
4147
  const contextMessages = await resolveMessages(ctx, input);
4118
4148
  const agent = await resolveAgent(ctx, input.modelId ?? null);
4119
- const promptPort = createPlatformPromptPort(ctx.api, (message) => ctx.logger.warn(message));
4149
+ const promptPort = createPlatformPromptPort(ctx.api, (message) => ctx.logger.warn(message), "operator");
4120
4150
  const promptRef = draftPromptRefFor(agent, { promptPrefix: "" });
4121
- const resolvedPrompt = await promptPort.resolve(promptRef);
4122
- const systemContent = applySignature(resolvedPrompt.text, input.agentName ?? void 0);
4151
+ const [resolvedPrompt, operatorMode] = await Promise.all([
4152
+ promptPort.resolve(promptRef),
4153
+ resolveOperatorMode(promptPort, (message) => ctx.logger.warn(message))
4154
+ ]);
4155
+ const systemContent = withOperatorMode(
4156
+ applySignature(resolvedPrompt.text, input.agentName ?? void 0),
4157
+ operatorMode,
4158
+ input.agentName ?? null
4159
+ );
4123
4160
  const chatMessages = systemContent ? [{ role: "system", content: systemContent }, ...contextMessages] : contextMessages;
4124
4161
  const result = await ctx.api.llm.complete({
4125
4162
  messages: chatMessages,
@@ -4166,6 +4203,28 @@ async function executeChat(ctx, userId, input) {
4166
4203
  prompt_version: resolvedPrompt.version
4167
4204
  };
4168
4205
  }
4206
+ async function resolveOperatorMode(promptPort, warn) {
4207
+ try {
4208
+ const resolved = await promptPort.resolve({
4209
+ name: OPERATOR_MODE_PROMPT_NAME,
4210
+ label: "production",
4211
+ fallback: DEFAULT_OPERATOR_MODE_PROMPT
4212
+ });
4213
+ return resolved.text.trim() || DEFAULT_OPERATOR_MODE_PROMPT;
4214
+ } catch (err) {
4215
+ warn(`ext-chat: ${OPERATOR_MODE_PROMPT_NAME} could not be read, serving the default text (${err instanceof Error ? err.message : String(err)})`);
4216
+ return DEFAULT_OPERATOR_MODE_PROMPT;
4217
+ }
4218
+ }
4219
+ function withOperatorMode(systemPrompt, operatorMode, agentName) {
4220
+ const name = agentName?.trim().slice(0, 200);
4221
+ const signature = name ? `
4222
+ * Signe la r\xE9ponse du pr\xE9nom de l'op\xE9rateur, \xAB ${name} \xBB, jamais au nom de l'\xE9quipe.` : "";
4223
+ const block = `${operatorMode}${signature}`;
4224
+ return systemPrompt ? `${systemPrompt}
4225
+
4226
+ ${block}` : block;
4227
+ }
4169
4228
  async function resolveMessages(ctx, input) {
4170
4229
  if (input.gorgiasTicketId) {
4171
4230
  const raw = await runBuildTicketContext(ctx, input.gorgiasTicketId);
@@ -6497,6 +6556,6 @@ function buildSupportPipeline(config) {
6497
6556
  };
6498
6557
  }
6499
6558
 
6500
- export { buildCategoryRecord, buildDiffAnalysisRecord, buildEvaluationRecord, buildGeneratedResponseRecord, buildReplyTimingRecord, buildResponseComparisonRecord, buildSupportKitRecords, buildSupportPipeline, buildTriageDecisionRecord, categoryGroupRecord, createBudget, createPromptResolver, diffAnalysisUniqueKey, hasReferences, parseReferences, pipelineStateRecord, promptCacheRecord, targetRefFor };
6559
+ export { buildCategoryRecord, buildDiffAnalysisRecord, buildEvaluationRecord, buildGeneratedResponseRecord, buildReplyTimingRecord, buildResponseComparisonRecord, buildSupportKitRecords, buildSupportPipeline, buildTriageDecisionRecord, categoryGroupRecord, createBudget, createPromptResolver, diffAnalysisUniqueKey, pipelineStateRecord, promptCacheRecord, targetRefFor };
6501
6560
  //# sourceMappingURL=index.js.map
6502
6561
  //# sourceMappingURL=index.js.map