@apotech-os/support-kit 2.8.0 → 2.9.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/{chunk-47QWWJBP.js → chunk-CVYJU4SV.js} +47 -15
- package/dist/chunk-CVYJU4SV.js.map +1 -0
- package/dist/index.cjs +74 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -19
- package/dist/index.d.ts +80 -19
- package/dist/index.js +31 -50
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +165 -2
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +145 -3
- package/dist/ui/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-47QWWJBP.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -626,20 +626,42 @@ interface ResolvedPrompt {
|
|
|
626
626
|
* LLM (T19's stated guarantee): the one place substitution happens is also
|
|
627
627
|
* the one place the composition tag gets resolved.
|
|
628
628
|
*
|
|
629
|
-
* Contract (C5): `resolve`
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
629
|
+
* Contract (C5, amended): `resolve` rejects with `MissingPromptError` — and
|
|
630
|
+
* ONLY with that — when every level of the ladder comes up empty. It used to
|
|
631
|
+
* never reject at all, returning empty text at version 0; that made a step
|
|
632
|
+
* with no usable prompt indistinguishable from a step whose prompt happened
|
|
633
|
+
* to say nothing, and let a run reach the model with an empty system
|
|
634
|
+
* message. A step with no prompt is a broken install, not a degraded one.
|
|
635
|
+
*
|
|
636
|
+
* The reason the old contract existed still stands, and is now the caller's
|
|
637
|
+
* duty instead of this port's: resolution happens INSIDE the node, so a
|
|
638
|
+
* rejection would otherwise be absorbed by that node's own error policy —
|
|
639
|
+
* `escalate`'s fail-open would read it as "nothing to escalate",
|
|
640
|
+
* `evaluate`'s fail-safe as a hold, both silently. Every node therefore
|
|
641
|
+
* resolves OUTSIDE its own try/catch, so a missing prompt fails the run
|
|
642
|
+
* instead of quietly changing its outcome.
|
|
643
|
+
*
|
|
644
|
+
* Levels 1-2 failing on their own still degrade rather than reject: a
|
|
645
|
+
* Langfuse outage served from the `prompt-cache` mirror, or from the ref's
|
|
646
|
+
* in-code fallback, is a real prompt and a legitimate run.
|
|
639
647
|
*/
|
|
640
648
|
interface PromptPort {
|
|
641
649
|
resolve(ref: PromptRef, vars?: Record<string, string>): Promise<ResolvedPrompt>;
|
|
642
650
|
}
|
|
651
|
+
/**
|
|
652
|
+
* Thrown by `PromptPort.resolve` when no level of the ladder yields any
|
|
653
|
+
* prompt text: the name resolves to nothing in Langfuse, the `prompt-cache`
|
|
654
|
+
* mirror holds nothing for it, and the ref carries no in-code fallback.
|
|
655
|
+
*
|
|
656
|
+
* Carries the ref that failed so the run's error names the step's prompt
|
|
657
|
+
* rather than reporting an empty system message that an operator would have
|
|
658
|
+
* to go looking for.
|
|
659
|
+
*/
|
|
660
|
+
declare class MissingPromptError extends Error {
|
|
661
|
+
readonly promptName: string;
|
|
662
|
+
readonly label: string;
|
|
663
|
+
constructor(promptName: string, label: string);
|
|
664
|
+
}
|
|
643
665
|
/**
|
|
644
666
|
* Tag names used to materialise pipeline decisions on the channel (I20).
|
|
645
667
|
* "Tag" does not exist in the domain — it is the channel's rendering of a
|
|
@@ -1442,7 +1464,15 @@ interface PromptCachePort {
|
|
|
1442
1464
|
* logger).
|
|
1443
1465
|
*/
|
|
1444
1466
|
interface PromptDegradedEvent {
|
|
1445
|
-
stage: 'platform-unavailable' | 'cache-unavailable' | 'composition-target-missing' | 'composition-target-forbidden' | 'composition-cycle' | 'composition-depth-exceeded'
|
|
1467
|
+
stage: 'platform-unavailable' | 'cache-unavailable' | 'composition-target-missing' | 'composition-target-forbidden' | 'composition-cycle' | 'composition-depth-exceeded'
|
|
1468
|
+
/**
|
|
1469
|
+
* Not a degradation but its terminus: the ladder resolved no text at any
|
|
1470
|
+
* level and the run is about to fail on `MissingPromptError`. Emitted
|
|
1471
|
+
* here anyway so an operator reading the degradation log sees the whole
|
|
1472
|
+
* ladder's story, ending in the reason, rather than the exception alone
|
|
1473
|
+
* with no trace of what was tried.
|
|
1474
|
+
*/
|
|
1475
|
+
| 'prompt-missing';
|
|
1446
1476
|
name: string;
|
|
1447
1477
|
reason: string;
|
|
1448
1478
|
}
|
|
@@ -1762,7 +1792,7 @@ declare const SUPPORT_KIT_SETTINGS_FIELDS: SettingsField[];
|
|
|
1762
1792
|
* French translation is now a COMPILE ERROR in that map, not a silent
|
|
1763
1793
|
* English leak an operator discovers on a live settings page.
|
|
1764
1794
|
*/
|
|
1765
|
-
type SettingsIssueKey = 'sourceViewId' | 'nodes' | 'senderEmail';
|
|
1795
|
+
type SettingsIssueKey = 'sourceViewId' | 'nodes' | 'nodePrompt' | 'senderEmail';
|
|
1766
1796
|
interface SettingsValidationIssue {
|
|
1767
1797
|
/** The offending settings key. */
|
|
1768
1798
|
key: SettingsIssueKey;
|
|
@@ -1807,16 +1837,39 @@ declare function validateSettings(settings: Record<string, unknown>): SettingsVa
|
|
|
1807
1837
|
* `statsTimezone` (a §3.8 rendering concern) and `needsHumanTag` (above). `to-profile.spec.ts` pins that list, so a new
|
|
1808
1838
|
* settings field cannot be forgotten here.
|
|
1809
1839
|
*
|
|
1810
|
-
* `prompts` is a PARAMETER, not derived
|
|
1811
|
-
*
|
|
1812
|
-
*
|
|
1813
|
-
*
|
|
1814
|
-
*
|
|
1840
|
+
* `prompts` is a PARAMETER, not derived here: `prompts.draft` is the agent
|
|
1841
|
+
* record's own Langfuse binding (§3.4), which a settings blob cannot know.
|
|
1842
|
+
* The other slots ARE operator-chosen (`nodes.<step>.prompt`), but the ref
|
|
1843
|
+
* they become is assembled by `buildPromptsTable`, alongside `draft` — one
|
|
1844
|
+
* place builds the table, this mapper consumes it.
|
|
1815
1845
|
*/
|
|
1816
1846
|
|
|
1847
|
+
/**
|
|
1848
|
+
* The Langfuse prompt an operator bound to one graph step, chosen from the
|
|
1849
|
+
* catalogue the app's `role.prompts` allowlist exposes (`ui/settings/
|
|
1850
|
+
* pipeline-nodes-form.tsx`).
|
|
1851
|
+
*
|
|
1852
|
+
* Required on every configured step, and NOT defaulted: the prompt is what
|
|
1853
|
+
* the step actually says to the model, so a step that names none has no
|
|
1854
|
+
* honest behaviour to fall back on. `validateSettings` refuses to run a
|
|
1855
|
+
* pipeline missing one, and `prompts/resolver.ts` fails the run rather than
|
|
1856
|
+
* serving empty text — the same "state it or it does not run" rule
|
|
1857
|
+
* `sourceViewId` already follows.
|
|
1858
|
+
*
|
|
1859
|
+
* `label` floats with Langfuse promotions (`production` unless an operator
|
|
1860
|
+
* picks another); no version pin, deliberately — a pinned run stops
|
|
1861
|
+
* following the promotions the operator makes in Langfuse.
|
|
1862
|
+
*/
|
|
1863
|
+
interface NodePromptSettings {
|
|
1864
|
+
name: string;
|
|
1865
|
+
/** Defaults to `production`, the label every promotion targets. */
|
|
1866
|
+
label?: string;
|
|
1867
|
+
}
|
|
1817
1868
|
/** One entry of the `nodes` settings json (§3.6); `null` disables the step. */
|
|
1818
1869
|
interface SupportKitNodeSettings {
|
|
1819
1870
|
model: string;
|
|
1871
|
+
/** The Langfuse prompt this step sends as its system message. */
|
|
1872
|
+
prompt: NodePromptSettings;
|
|
1820
1873
|
/** Falls back to the same provider the `agent` record defaults to. */
|
|
1821
1874
|
provider?: string;
|
|
1822
1875
|
reasoning?: ReasoningEffort;
|
|
@@ -1827,6 +1880,14 @@ interface SupportKitNodeSettings {
|
|
|
1827
1880
|
/** `evaluate` only. */
|
|
1828
1881
|
escalationEnabled?: boolean;
|
|
1829
1882
|
}
|
|
1883
|
+
/**
|
|
1884
|
+
* `draft` is the one step with no `prompt` of its own: it speaks with the
|
|
1885
|
+
* resolved agent's voice, so its Langfuse binding lives on the `agent`
|
|
1886
|
+
* record (§3.4, `functions/records.ts`'s `draftPromptRefFor`) and is chosen
|
|
1887
|
+
* per agent on the AgentsPage, not per install on the SettingsPage. A
|
|
1888
|
+
* `prompt` key here would be written by an operator and read by nobody.
|
|
1889
|
+
*/
|
|
1890
|
+
type SupportKitDraftNodeSettings = Omit<SupportKitNodeSettings, 'prompt'>;
|
|
1830
1891
|
/**
|
|
1831
1892
|
* The settings a consuming app stores, typed. The platform hands them over
|
|
1832
1893
|
* as a `Record<string, unknown>` JSONB blob: a caller narrows it to this
|
|
@@ -1842,7 +1903,7 @@ interface SupportKitSettings {
|
|
|
1842
1903
|
nodes: {
|
|
1843
1904
|
triage: SupportKitNodeSettings;
|
|
1844
1905
|
escalate?: SupportKitNodeSettings | null;
|
|
1845
|
-
draft?:
|
|
1906
|
+
draft?: SupportKitDraftNodeSettings | null;
|
|
1846
1907
|
evaluate?: SupportKitNodeSettings | null;
|
|
1847
1908
|
revise?: SupportKitNodeSettings | null;
|
|
1848
1909
|
};
|
|
@@ -2005,4 +2066,4 @@ interface SupportPipelineFragments {
|
|
|
2005
2066
|
}
|
|
2006
2067
|
declare function buildSupportPipeline(config: SupportPipelineConfig): SupportPipelineFragments;
|
|
2007
2068
|
|
|
2008
|
-
export { AGENT_GUARDRAILS, AGENT_STATUSES, AGENT_TOOLS, type ActionDecision, type AgentProfile, type AgentStatus, type AuditTags, type AutoReplyGuardSettings, type Budget, CANDIDATE_MIN_LENGTH, type CatalogueTool, type CategoryPolicy, type CategoryReferentialEntry, type ChannelKind, type ChatMessage, type Classification, type ClockPort, type CompletionRequest, type CompletionResult, type Conversation, type ConversationPort, type ConversationRef, type CostLedger, type CustomerInfo, DEFAULT_CHANNEL_PROMPT_EMAIL, DEFAULT_CHANNEL_PROMPT_WHATSAPP, DEFAULT_LLM_PROVIDER, DEFAULT_PROFILE_KEY, DEFAULT_WHATSAPP_MODE, type Draft, type DraftAttribution, type DraftNodeConfig, EVALUATION_VERDICTS, type EscalateNodeConfig, type EvaluateNodeConfig, type EvaluationVerdict, GENERATED_RESPONSE_STATUSES, type GeneratedResponseStatus, type GuardrailId, InvalidStatusTransitionError, type JsonSchema, type JudgedReply, type KnowledgeHit, type LlmPort, type Message, NODE_NAMES, type Node, type NodeCost, type NodeDeps, type NodeKey, type NodeName, type NodeStep, 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 ProposedAction, REASONING_MAX_LEN, type RawPrompt, type RawPromptConfig, type RawTicket, type ReasoningEffort, type RecordDef, type ReplyPort, type ResolvedPrompt, type ResumeFrom, type ReviseNodeConfig, type RunGuardrailsInput, type RunStamp, type RunTicketOptions, type RunUntil, STOP_PHRASES, SUPPORT_KIT_SETTINGS_FIELDS, type SettingsIssueKey, type SettingsValidationIssue, type SimilarTicket, type SourceDescriptor, type StatePort, 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, agentRecord, assertTransition, buildCategoryRecord, buildDiffAnalysisRecord, buildEvaluationRecord, buildGeneratedResponseRecord, buildResponseComparisonRecord, buildSupportKitRecords, buildSupportPipeline, buildTriageDecisionRecord, canTransition, categoryGroupRecord, channelPreGates, createBudget, createPromptResolver, diffAnalysisUniqueKey, firstCustomerMessage, guardrailBucket, hasCustomerAttachment, hasReferences, initialState, isAutoSendEligible, isAutomatedSenderEmail, isAutomatedSenderTicket, isEvaluationVerdict, isGeneratedResponseStatus, isJudgemeConversation, isJudgemeTicket, isSendable, isSendableVerdict, isTerminalStatus, isTicketClosed, isWhatsappChevronNote, isWhatsappTicket, lastCustomerMessage, needsRevision, openTicketKeyFor, parseReferences, pipelineStateRecord, promptCacheRecord, reclaimStalledSend, requiresFollowup, resolvePromptName, resolveReviseName, runGuardrails, runTicket, settingsToProfile, stopOptOut, targetRefFor, validateSettings, verifyReply, whatsappModeFromLegacyBoolean };
|
|
2069
|
+
export { AGENT_GUARDRAILS, AGENT_STATUSES, AGENT_TOOLS, type ActionDecision, type AgentProfile, type AgentStatus, type AuditTags, type AutoReplyGuardSettings, type Budget, CANDIDATE_MIN_LENGTH, type CatalogueTool, type CategoryPolicy, type CategoryReferentialEntry, type ChannelKind, type ChatMessage, type Classification, type ClockPort, type CompletionRequest, type CompletionResult, type Conversation, type ConversationPort, type ConversationRef, type CostLedger, type CustomerInfo, DEFAULT_CHANNEL_PROMPT_EMAIL, DEFAULT_CHANNEL_PROMPT_WHATSAPP, DEFAULT_LLM_PROVIDER, DEFAULT_PROFILE_KEY, DEFAULT_WHATSAPP_MODE, type Draft, type DraftAttribution, type DraftNodeConfig, EVALUATION_VERDICTS, type EscalateNodeConfig, type EvaluateNodeConfig, type EvaluationVerdict, GENERATED_RESPONSE_STATUSES, type GeneratedResponseStatus, type GuardrailId, 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, 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 ProposedAction, REASONING_MAX_LEN, type RawPrompt, type RawPromptConfig, type RawTicket, type ReasoningEffort, type RecordDef, type ReplyPort, type ResolvedPrompt, type ResumeFrom, type ReviseNodeConfig, type RunGuardrailsInput, type RunStamp, type RunTicketOptions, type RunUntil, STOP_PHRASES, SUPPORT_KIT_SETTINGS_FIELDS, type SettingsIssueKey, type SettingsValidationIssue, type SimilarTicket, type SourceDescriptor, type StatePort, 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, agentRecord, assertTransition, buildCategoryRecord, buildDiffAnalysisRecord, buildEvaluationRecord, buildGeneratedResponseRecord, buildResponseComparisonRecord, buildSupportKitRecords, buildSupportPipeline, buildTriageDecisionRecord, canTransition, categoryGroupRecord, channelPreGates, createBudget, createPromptResolver, diffAnalysisUniqueKey, firstCustomerMessage, guardrailBucket, hasCustomerAttachment, hasReferences, initialState, isAutoSendEligible, isAutomatedSenderEmail, isAutomatedSenderTicket, isEvaluationVerdict, isGeneratedResponseStatus, isJudgemeConversation, isJudgemeTicket, isSendable, isSendableVerdict, isTerminalStatus, isTicketClosed, isWhatsappChevronNote, isWhatsappTicket, lastCustomerMessage, needsRevision, openTicketKeyFor, parseReferences, pipelineStateRecord, promptCacheRecord, reclaimStalledSend, requiresFollowup, resolvePromptName, resolveReviseName, runGuardrails, runTicket, settingsToProfile, stopOptOut, targetRefFor, validateSettings, verifyReply, whatsappModeFromLegacyBoolean };
|
package/dist/index.d.ts
CHANGED
|
@@ -626,20 +626,42 @@ interface ResolvedPrompt {
|
|
|
626
626
|
* LLM (T19's stated guarantee): the one place substitution happens is also
|
|
627
627
|
* the one place the composition tag gets resolved.
|
|
628
628
|
*
|
|
629
|
-
* Contract (C5): `resolve`
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
629
|
+
* Contract (C5, amended): `resolve` rejects with `MissingPromptError` — and
|
|
630
|
+
* ONLY with that — when every level of the ladder comes up empty. It used to
|
|
631
|
+
* never reject at all, returning empty text at version 0; that made a step
|
|
632
|
+
* with no usable prompt indistinguishable from a step whose prompt happened
|
|
633
|
+
* to say nothing, and let a run reach the model with an empty system
|
|
634
|
+
* message. A step with no prompt is a broken install, not a degraded one.
|
|
635
|
+
*
|
|
636
|
+
* The reason the old contract existed still stands, and is now the caller's
|
|
637
|
+
* duty instead of this port's: resolution happens INSIDE the node, so a
|
|
638
|
+
* rejection would otherwise be absorbed by that node's own error policy —
|
|
639
|
+
* `escalate`'s fail-open would read it as "nothing to escalate",
|
|
640
|
+
* `evaluate`'s fail-safe as a hold, both silently. Every node therefore
|
|
641
|
+
* resolves OUTSIDE its own try/catch, so a missing prompt fails the run
|
|
642
|
+
* instead of quietly changing its outcome.
|
|
643
|
+
*
|
|
644
|
+
* Levels 1-2 failing on their own still degrade rather than reject: a
|
|
645
|
+
* Langfuse outage served from the `prompt-cache` mirror, or from the ref's
|
|
646
|
+
* in-code fallback, is a real prompt and a legitimate run.
|
|
639
647
|
*/
|
|
640
648
|
interface PromptPort {
|
|
641
649
|
resolve(ref: PromptRef, vars?: Record<string, string>): Promise<ResolvedPrompt>;
|
|
642
650
|
}
|
|
651
|
+
/**
|
|
652
|
+
* Thrown by `PromptPort.resolve` when no level of the ladder yields any
|
|
653
|
+
* prompt text: the name resolves to nothing in Langfuse, the `prompt-cache`
|
|
654
|
+
* mirror holds nothing for it, and the ref carries no in-code fallback.
|
|
655
|
+
*
|
|
656
|
+
* Carries the ref that failed so the run's error names the step's prompt
|
|
657
|
+
* rather than reporting an empty system message that an operator would have
|
|
658
|
+
* to go looking for.
|
|
659
|
+
*/
|
|
660
|
+
declare class MissingPromptError extends Error {
|
|
661
|
+
readonly promptName: string;
|
|
662
|
+
readonly label: string;
|
|
663
|
+
constructor(promptName: string, label: string);
|
|
664
|
+
}
|
|
643
665
|
/**
|
|
644
666
|
* Tag names used to materialise pipeline decisions on the channel (I20).
|
|
645
667
|
* "Tag" does not exist in the domain — it is the channel's rendering of a
|
|
@@ -1442,7 +1464,15 @@ interface PromptCachePort {
|
|
|
1442
1464
|
* logger).
|
|
1443
1465
|
*/
|
|
1444
1466
|
interface PromptDegradedEvent {
|
|
1445
|
-
stage: 'platform-unavailable' | 'cache-unavailable' | 'composition-target-missing' | 'composition-target-forbidden' | 'composition-cycle' | 'composition-depth-exceeded'
|
|
1467
|
+
stage: 'platform-unavailable' | 'cache-unavailable' | 'composition-target-missing' | 'composition-target-forbidden' | 'composition-cycle' | 'composition-depth-exceeded'
|
|
1468
|
+
/**
|
|
1469
|
+
* Not a degradation but its terminus: the ladder resolved no text at any
|
|
1470
|
+
* level and the run is about to fail on `MissingPromptError`. Emitted
|
|
1471
|
+
* here anyway so an operator reading the degradation log sees the whole
|
|
1472
|
+
* ladder's story, ending in the reason, rather than the exception alone
|
|
1473
|
+
* with no trace of what was tried.
|
|
1474
|
+
*/
|
|
1475
|
+
| 'prompt-missing';
|
|
1446
1476
|
name: string;
|
|
1447
1477
|
reason: string;
|
|
1448
1478
|
}
|
|
@@ -1762,7 +1792,7 @@ declare const SUPPORT_KIT_SETTINGS_FIELDS: SettingsField[];
|
|
|
1762
1792
|
* French translation is now a COMPILE ERROR in that map, not a silent
|
|
1763
1793
|
* English leak an operator discovers on a live settings page.
|
|
1764
1794
|
*/
|
|
1765
|
-
type SettingsIssueKey = 'sourceViewId' | 'nodes' | 'senderEmail';
|
|
1795
|
+
type SettingsIssueKey = 'sourceViewId' | 'nodes' | 'nodePrompt' | 'senderEmail';
|
|
1766
1796
|
interface SettingsValidationIssue {
|
|
1767
1797
|
/** The offending settings key. */
|
|
1768
1798
|
key: SettingsIssueKey;
|
|
@@ -1807,16 +1837,39 @@ declare function validateSettings(settings: Record<string, unknown>): SettingsVa
|
|
|
1807
1837
|
* `statsTimezone` (a §3.8 rendering concern) and `needsHumanTag` (above). `to-profile.spec.ts` pins that list, so a new
|
|
1808
1838
|
* settings field cannot be forgotten here.
|
|
1809
1839
|
*
|
|
1810
|
-
* `prompts` is a PARAMETER, not derived
|
|
1811
|
-
*
|
|
1812
|
-
*
|
|
1813
|
-
*
|
|
1814
|
-
*
|
|
1840
|
+
* `prompts` is a PARAMETER, not derived here: `prompts.draft` is the agent
|
|
1841
|
+
* record's own Langfuse binding (§3.4), which a settings blob cannot know.
|
|
1842
|
+
* The other slots ARE operator-chosen (`nodes.<step>.prompt`), but the ref
|
|
1843
|
+
* they become is assembled by `buildPromptsTable`, alongside `draft` — one
|
|
1844
|
+
* place builds the table, this mapper consumes it.
|
|
1815
1845
|
*/
|
|
1816
1846
|
|
|
1847
|
+
/**
|
|
1848
|
+
* The Langfuse prompt an operator bound to one graph step, chosen from the
|
|
1849
|
+
* catalogue the app's `role.prompts` allowlist exposes (`ui/settings/
|
|
1850
|
+
* pipeline-nodes-form.tsx`).
|
|
1851
|
+
*
|
|
1852
|
+
* Required on every configured step, and NOT defaulted: the prompt is what
|
|
1853
|
+
* the step actually says to the model, so a step that names none has no
|
|
1854
|
+
* honest behaviour to fall back on. `validateSettings` refuses to run a
|
|
1855
|
+
* pipeline missing one, and `prompts/resolver.ts` fails the run rather than
|
|
1856
|
+
* serving empty text — the same "state it or it does not run" rule
|
|
1857
|
+
* `sourceViewId` already follows.
|
|
1858
|
+
*
|
|
1859
|
+
* `label` floats with Langfuse promotions (`production` unless an operator
|
|
1860
|
+
* picks another); no version pin, deliberately — a pinned run stops
|
|
1861
|
+
* following the promotions the operator makes in Langfuse.
|
|
1862
|
+
*/
|
|
1863
|
+
interface NodePromptSettings {
|
|
1864
|
+
name: string;
|
|
1865
|
+
/** Defaults to `production`, the label every promotion targets. */
|
|
1866
|
+
label?: string;
|
|
1867
|
+
}
|
|
1817
1868
|
/** One entry of the `nodes` settings json (§3.6); `null` disables the step. */
|
|
1818
1869
|
interface SupportKitNodeSettings {
|
|
1819
1870
|
model: string;
|
|
1871
|
+
/** The Langfuse prompt this step sends as its system message. */
|
|
1872
|
+
prompt: NodePromptSettings;
|
|
1820
1873
|
/** Falls back to the same provider the `agent` record defaults to. */
|
|
1821
1874
|
provider?: string;
|
|
1822
1875
|
reasoning?: ReasoningEffort;
|
|
@@ -1827,6 +1880,14 @@ interface SupportKitNodeSettings {
|
|
|
1827
1880
|
/** `evaluate` only. */
|
|
1828
1881
|
escalationEnabled?: boolean;
|
|
1829
1882
|
}
|
|
1883
|
+
/**
|
|
1884
|
+
* `draft` is the one step with no `prompt` of its own: it speaks with the
|
|
1885
|
+
* resolved agent's voice, so its Langfuse binding lives on the `agent`
|
|
1886
|
+
* record (§3.4, `functions/records.ts`'s `draftPromptRefFor`) and is chosen
|
|
1887
|
+
* per agent on the AgentsPage, not per install on the SettingsPage. A
|
|
1888
|
+
* `prompt` key here would be written by an operator and read by nobody.
|
|
1889
|
+
*/
|
|
1890
|
+
type SupportKitDraftNodeSettings = Omit<SupportKitNodeSettings, 'prompt'>;
|
|
1830
1891
|
/**
|
|
1831
1892
|
* The settings a consuming app stores, typed. The platform hands them over
|
|
1832
1893
|
* as a `Record<string, unknown>` JSONB blob: a caller narrows it to this
|
|
@@ -1842,7 +1903,7 @@ interface SupportKitSettings {
|
|
|
1842
1903
|
nodes: {
|
|
1843
1904
|
triage: SupportKitNodeSettings;
|
|
1844
1905
|
escalate?: SupportKitNodeSettings | null;
|
|
1845
|
-
draft?:
|
|
1906
|
+
draft?: SupportKitDraftNodeSettings | null;
|
|
1846
1907
|
evaluate?: SupportKitNodeSettings | null;
|
|
1847
1908
|
revise?: SupportKitNodeSettings | null;
|
|
1848
1909
|
};
|
|
@@ -2005,4 +2066,4 @@ interface SupportPipelineFragments {
|
|
|
2005
2066
|
}
|
|
2006
2067
|
declare function buildSupportPipeline(config: SupportPipelineConfig): SupportPipelineFragments;
|
|
2007
2068
|
|
|
2008
|
-
export { AGENT_GUARDRAILS, AGENT_STATUSES, AGENT_TOOLS, type ActionDecision, type AgentProfile, type AgentStatus, type AuditTags, type AutoReplyGuardSettings, type Budget, CANDIDATE_MIN_LENGTH, type CatalogueTool, type CategoryPolicy, type CategoryReferentialEntry, type ChannelKind, type ChatMessage, type Classification, type ClockPort, type CompletionRequest, type CompletionResult, type Conversation, type ConversationPort, type ConversationRef, type CostLedger, type CustomerInfo, DEFAULT_CHANNEL_PROMPT_EMAIL, DEFAULT_CHANNEL_PROMPT_WHATSAPP, DEFAULT_LLM_PROVIDER, DEFAULT_PROFILE_KEY, DEFAULT_WHATSAPP_MODE, type Draft, type DraftAttribution, type DraftNodeConfig, EVALUATION_VERDICTS, type EscalateNodeConfig, type EvaluateNodeConfig, type EvaluationVerdict, GENERATED_RESPONSE_STATUSES, type GeneratedResponseStatus, type GuardrailId, InvalidStatusTransitionError, type JsonSchema, type JudgedReply, type KnowledgeHit, type LlmPort, type Message, NODE_NAMES, type Node, type NodeCost, type NodeDeps, type NodeKey, type NodeName, type NodeStep, 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 ProposedAction, REASONING_MAX_LEN, type RawPrompt, type RawPromptConfig, type RawTicket, type ReasoningEffort, type RecordDef, type ReplyPort, type ResolvedPrompt, type ResumeFrom, type ReviseNodeConfig, type RunGuardrailsInput, type RunStamp, type RunTicketOptions, type RunUntil, STOP_PHRASES, SUPPORT_KIT_SETTINGS_FIELDS, type SettingsIssueKey, type SettingsValidationIssue, type SimilarTicket, type SourceDescriptor, type StatePort, 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, agentRecord, assertTransition, buildCategoryRecord, buildDiffAnalysisRecord, buildEvaluationRecord, buildGeneratedResponseRecord, buildResponseComparisonRecord, buildSupportKitRecords, buildSupportPipeline, buildTriageDecisionRecord, canTransition, categoryGroupRecord, channelPreGates, createBudget, createPromptResolver, diffAnalysisUniqueKey, firstCustomerMessage, guardrailBucket, hasCustomerAttachment, hasReferences, initialState, isAutoSendEligible, isAutomatedSenderEmail, isAutomatedSenderTicket, isEvaluationVerdict, isGeneratedResponseStatus, isJudgemeConversation, isJudgemeTicket, isSendable, isSendableVerdict, isTerminalStatus, isTicketClosed, isWhatsappChevronNote, isWhatsappTicket, lastCustomerMessage, needsRevision, openTicketKeyFor, parseReferences, pipelineStateRecord, promptCacheRecord, reclaimStalledSend, requiresFollowup, resolvePromptName, resolveReviseName, runGuardrails, runTicket, settingsToProfile, stopOptOut, targetRefFor, validateSettings, verifyReply, whatsappModeFromLegacyBoolean };
|
|
2069
|
+
export { AGENT_GUARDRAILS, AGENT_STATUSES, AGENT_TOOLS, type ActionDecision, type AgentProfile, type AgentStatus, type AuditTags, type AutoReplyGuardSettings, type Budget, CANDIDATE_MIN_LENGTH, type CatalogueTool, type CategoryPolicy, type CategoryReferentialEntry, type ChannelKind, type ChatMessage, type Classification, type ClockPort, type CompletionRequest, type CompletionResult, type Conversation, type ConversationPort, type ConversationRef, type CostLedger, type CustomerInfo, DEFAULT_CHANNEL_PROMPT_EMAIL, DEFAULT_CHANNEL_PROMPT_WHATSAPP, DEFAULT_LLM_PROVIDER, DEFAULT_PROFILE_KEY, DEFAULT_WHATSAPP_MODE, type Draft, type DraftAttribution, type DraftNodeConfig, EVALUATION_VERDICTS, type EscalateNodeConfig, type EvaluateNodeConfig, type EvaluationVerdict, GENERATED_RESPONSE_STATUSES, type GeneratedResponseStatus, type GuardrailId, 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, 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 ProposedAction, REASONING_MAX_LEN, type RawPrompt, type RawPromptConfig, type RawTicket, type ReasoningEffort, type RecordDef, type ReplyPort, type ResolvedPrompt, type ResumeFrom, type ReviseNodeConfig, type RunGuardrailsInput, type RunStamp, type RunTicketOptions, type RunUntil, STOP_PHRASES, SUPPORT_KIT_SETTINGS_FIELDS, type SettingsIssueKey, type SettingsValidationIssue, type SimilarTicket, type SourceDescriptor, type StatePort, 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, agentRecord, assertTransition, buildCategoryRecord, buildDiffAnalysisRecord, buildEvaluationRecord, buildGeneratedResponseRecord, buildResponseComparisonRecord, buildSupportKitRecords, buildSupportPipeline, buildTriageDecisionRecord, canTransition, categoryGroupRecord, channelPreGates, createBudget, createPromptResolver, diffAnalysisUniqueKey, firstCustomerMessage, guardrailBucket, hasCustomerAttachment, hasReferences, initialState, isAutoSendEligible, isAutomatedSenderEmail, isAutomatedSenderTicket, isEvaluationVerdict, isGeneratedResponseStatus, isJudgemeConversation, isJudgemeTicket, isSendable, isSendableVerdict, isTerminalStatus, isTicketClosed, isWhatsappChevronNote, isWhatsappTicket, lastCustomerMessage, needsRevision, openTicketKeyFor, parseReferences, pipelineStateRecord, promptCacheRecord, reclaimStalledSend, requiresFollowup, resolvePromptName, resolveReviseName, runGuardrails, runTicket, settingsToProfile, stopOptOut, targetRefFor, 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, 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_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_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, 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_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_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_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, agentRecord, SUPPORT_KIT_SETTINGS_FIELDS, validateSettings, toCategory, toAgent, resolveDraftAgent, settingsToProfile, buildPromptsTable, draftPromptRefFor, runTicket, assertTransition, openTicketKeyFor, act, initialState, applyOutcomeTags, listCategories, toCategoryReferential, resolvePromptName,
|
|
2
|
-
export { AGENT_GUARDRAILS, AGENT_STATUSES, AGENT_TOOLS, CANDIDATE_MIN_LENGTH, DEFAULT_CHANNEL_PROMPT_EMAIL, DEFAULT_CHANNEL_PROMPT_WHATSAPP, DEFAULT_LLM_PROVIDER, DEFAULT_PROFILE_KEY, DEFAULT_WHATSAPP_MODE, EVALUATION_VERDICTS, GENERATED_RESPONSE_STATUSES, InvalidStatusTransitionError, NODE_NAMES, PROMPT_SLOTS, REASONING_MAX_LEN, STOP_PHRASES, SUPPORT_KIT_SETTINGS_FIELDS, UNCERTAINTY_MARKERS, WHATSAPP_MODES, WHATSAPP_NOTE_CHEVRON, agentRecord, assertTransition, canTransition, channelPreGates, firstCustomerMessage, guardrailBucket, hasCustomerAttachment, initialState, isAutoSendEligible, isAutomatedSenderEmail, isAutomatedSenderTicket, isEvaluationVerdict, isGeneratedResponseStatus, isJudgemeConversation, isJudgemeTicket, isSendable, isSendableVerdict, isTerminalStatus, isTicketClosed, isWhatsappChevronNote, isWhatsappTicket, lastCustomerMessage, needsRevision, openTicketKeyFor, reclaimStalledSend, requiresFollowup, resolvePromptName, resolveReviseName, runGuardrails, runTicket, settingsToProfile, stopOptOut, validateSettings, verifyReply, whatsappModeFromLegacyBoolean } from './chunk-
|
|
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, 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_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_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, 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_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_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_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, agentRecord, SUPPORT_KIT_SETTINGS_FIELDS, MissingPromptError, validateSettings, toCategory, toAgent, resolveDraftAgent, settingsToProfile, buildPromptsTable, draftPromptRefFor, runTicket, assertTransition, openTicketKeyFor, act, initialState, applyOutcomeTags, listCategories, toCategoryReferential, resolvePromptName, DEFAULT_LLM_PROVIDER, toCategoryGroup, toGeneratedResponse, NODE_NAMES, reclaimStalledSend, applySignature, isGeneratedResponseStatus, isEvaluationVerdict, requiresFollowup, computeWordDiff, findCategoryByTag, isWhatsappTicket, isConversationOver, isFallbackClassification, hasNoDraftNode, hasCustomerAttachment, isTicketClosed, isWhatsappChevronNote } from './chunk-CVYJU4SV.js';
|
|
2
|
+
export { AGENT_GUARDRAILS, AGENT_STATUSES, AGENT_TOOLS, CANDIDATE_MIN_LENGTH, DEFAULT_CHANNEL_PROMPT_EMAIL, DEFAULT_CHANNEL_PROMPT_WHATSAPP, DEFAULT_LLM_PROVIDER, DEFAULT_PROFILE_KEY, DEFAULT_WHATSAPP_MODE, EVALUATION_VERDICTS, GENERATED_RESPONSE_STATUSES, InvalidStatusTransitionError, MissingPromptError, NODE_NAMES, PROMPT_SLOTS, REASONING_MAX_LEN, STOP_PHRASES, SUPPORT_KIT_SETTINGS_FIELDS, UNCERTAINTY_MARKERS, WHATSAPP_MODES, WHATSAPP_NOTE_CHEVRON, agentRecord, assertTransition, canTransition, channelPreGates, firstCustomerMessage, guardrailBucket, hasCustomerAttachment, initialState, isAutoSendEligible, isAutomatedSenderEmail, isAutomatedSenderTicket, isEvaluationVerdict, isGeneratedResponseStatus, isJudgemeConversation, isJudgemeTicket, isSendable, isSendableVerdict, isTerminalStatus, isTicketClosed, isWhatsappChevronNote, isWhatsappTicket, lastCustomerMessage, needsRevision, openTicketKeyFor, reclaimStalledSend, requiresFollowup, resolvePromptName, resolveReviseName, runGuardrails, runTicket, settingsToProfile, stopOptOut, validateSettings, verifyReply, whatsappModeFromLegacyBoolean } from './chunk-CVYJU4SV.js';
|
|
3
3
|
import { FieldType, APPROVAL_DECIDED_EVENT, AppApiError } from '@apotech-os/app-kit';
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
5
|
|
|
@@ -152,11 +152,18 @@ function createPromptResolver(deps) {
|
|
|
152
152
|
return null;
|
|
153
153
|
});
|
|
154
154
|
if (cached) {
|
|
155
|
-
return { name, text: substituteVars(cached.content, vars), version: cached.version, config: null };
|
|
155
|
+
return served({ name, text: substituteVars(cached.content, vars), version: cached.version, config: null }, label);
|
|
156
156
|
}
|
|
157
157
|
const rawFallback = ref.fallback ?? "";
|
|
158
158
|
const text = hasReferences(rawFallback) ? await composeReferences(rawFallback, composeCtx, /* @__PURE__ */ new Set([name]), 0) : rawFallback;
|
|
159
|
-
return { name, text: substituteVars(text, vars), version: 0, config: null };
|
|
159
|
+
return served({ name, text: substituteVars(text, vars), version: 0, config: null }, label);
|
|
160
|
+
}
|
|
161
|
+
function served(resolved, label) {
|
|
162
|
+
if (resolved.text.trim() === "") {
|
|
163
|
+
deps.onDegraded?.({ stage: "prompt-missing", name: resolved.name, reason: "no prompt content at any level" });
|
|
164
|
+
throw new MissingPromptError(resolved.name, label);
|
|
165
|
+
}
|
|
166
|
+
return resolved;
|
|
160
167
|
}
|
|
161
168
|
return {
|
|
162
169
|
async resolve(ref, vars) {
|
|
@@ -172,12 +179,15 @@ function createPromptResolver(deps) {
|
|
|
172
179
|
if (!hasReferences(resolved.content)) {
|
|
173
180
|
await deps.cache.write(persistKey, { content: resolved.content, version: resolved.version }).catch(() => void 0);
|
|
174
181
|
}
|
|
175
|
-
return
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
182
|
+
return served(
|
|
183
|
+
{
|
|
184
|
+
name: ref.name,
|
|
185
|
+
text: substituteVars(resolved.content, vars),
|
|
186
|
+
version: resolved.version,
|
|
187
|
+
config: toResolvedConfig(resolved.config)
|
|
188
|
+
},
|
|
189
|
+
label
|
|
190
|
+
);
|
|
181
191
|
}
|
|
182
192
|
};
|
|
183
193
|
}
|
|
@@ -1507,7 +1517,7 @@ async function runTriageBatch(ctx, config, settings) {
|
|
|
1507
1517
|
const ports = dryRun ? withRecordingWritePorts(buildTicketPorts(ctx), ctx.api) : buildTicketPorts(ctx);
|
|
1508
1518
|
const categories = await listCategories(ctx.api);
|
|
1509
1519
|
const batchDefaultAgent = await resolveDraftAgent(ctx.api, null);
|
|
1510
|
-
const profile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(batchDefaultAgent, config)));
|
|
1520
|
+
const profile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(batchDefaultAgent, config), settings.nodes));
|
|
1511
1521
|
const refs = await ports.conversation.listPending({ viewOrTag: settings.sourceViewId }, settings.batchLimit);
|
|
1512
1522
|
const run = await ctx.api.runs.start({
|
|
1513
1523
|
kind: "triage-tick",
|
|
@@ -1782,7 +1792,7 @@ async function processResponseHandler(ctx, config) {
|
|
|
1782
1792
|
const category = categoryRecord ? toCategory(categoryRecord) : null;
|
|
1783
1793
|
const agentRecord2 = data.agentId ? await getOptional(ctx, "agent", data.agentId) : null;
|
|
1784
1794
|
const agent = agentRecord2 ? toAgent(agentRecord2) : await resolveDraftAgent(ctx.api, null);
|
|
1785
|
-
const profile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(agent, config)));
|
|
1795
|
+
const profile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(agent, config), settings.nodes));
|
|
1786
1796
|
const dryRun = settings.dryRun === true;
|
|
1787
1797
|
const trace = { sessionId: ticketId, tags: [`app:${config.slug}`] };
|
|
1788
1798
|
const ports = dryRun ? withRecordingWritePorts(buildTicketPorts(ctx, trace), ctx.api) : buildTicketPorts(ctx, trace);
|
|
@@ -2037,7 +2047,7 @@ async function handleApprovalHandler(ctx, config) {
|
|
|
2037
2047
|
ctx.logger.info("handle-approval: settings invalid, skipping", { issues });
|
|
2038
2048
|
return;
|
|
2039
2049
|
}
|
|
2040
|
-
const profile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(null, config)));
|
|
2050
|
+
const profile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(null, config), settings.nodes));
|
|
2041
2051
|
const responseText = data.responseText ?? "";
|
|
2042
2052
|
if (responseText.trim().length === 0) {
|
|
2043
2053
|
ctx.logger.error(`handle-approval: generated-response ${id} has no responseText, refusing to send an empty reply`);
|
|
@@ -2274,7 +2284,7 @@ async function previewTriageHandler(ctx, config, input) {
|
|
|
2274
2284
|
}
|
|
2275
2285
|
const categories = await listCategories(ctx.api);
|
|
2276
2286
|
const agent = await resolveDraftAgent(ctx.api, null);
|
|
2277
|
-
const profile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(agent, config)));
|
|
2287
|
+
const profile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(agent, config), settings.nodes));
|
|
2278
2288
|
const realPorts = buildTicketPorts(ctx);
|
|
2279
2289
|
const recordingState = createRecordingStatePort(ctx.api);
|
|
2280
2290
|
const recordingReply = createRecordingReplyPort();
|
|
@@ -2473,7 +2483,7 @@ async function graphDryRunHandler(ctx, config, input) {
|
|
|
2473
2483
|
const forcedCategory = input.categoryId ? categories.find((c) => c.id === input.categoryId) ?? null : null;
|
|
2474
2484
|
if (input.categoryId && !forcedCategory) throw new ctx.NonRetriableError(`Category "${input.categoryId}" not found`);
|
|
2475
2485
|
const agent = input.agentId ? toAgent(await ctx.api.get("agent", input.agentId)) : await resolveDraftAgent(ctx.api, forcedCategory?.agentId ?? null);
|
|
2476
|
-
const baseProfile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(agent, config)));
|
|
2486
|
+
const baseProfile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(agent, config), settings.nodes));
|
|
2477
2487
|
const profile = applyOverrides(baseProfile, input.overrides ?? {});
|
|
2478
2488
|
const realPorts = buildTicketPorts(ctx);
|
|
2479
2489
|
const ref = { id: inlineTicket ? INLINE_TICKET_ID : ticketId, channel: "gorgias" };
|
|
@@ -2536,7 +2546,7 @@ async function testAgentsHandler(ctx, config, input) {
|
|
|
2536
2546
|
const limit = Math.min(input?.limit ?? DEFAULT_LIMIT, MAX_LIMIT);
|
|
2537
2547
|
const categories = await listCategories(ctx.api);
|
|
2538
2548
|
const agent = input.agentId ? toAgent(await ctx.api.get("agent", input.agentId)) : await resolveDraftAgent(ctx.api, null);
|
|
2539
|
-
const profile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(agent, config)));
|
|
2549
|
+
const profile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(agent, config), settings.nodes));
|
|
2540
2550
|
const realPorts = buildTicketPorts(ctx);
|
|
2541
2551
|
const refs = explicitIds.length ? explicitIds.slice(0, limit).map((id) => ({ id, channel: "gorgias" })) : await realPorts.conversation.listPending({ viewOrTag: viewId }, limit);
|
|
2542
2552
|
const deadline = AbortSignal.timeout(DRY_RUN_DEADLINE_MS);
|
|
@@ -3885,42 +3895,13 @@ var FUNCTION_ASSEMBLY = [
|
|
|
3885
3895
|
}
|
|
3886
3896
|
];
|
|
3887
3897
|
function buildPromptsAllowlist(config) {
|
|
3888
|
-
const prefixedSlots = PROMPT_SLOTS.filter((slot) => !slot.startsWith("shared/"));
|
|
3889
3898
|
return [
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
//
|
|
3893
|
-
// `draftPromptRefFor`) — scoped by promptPrefix like every other name
|
|
3894
|
-
// above, so resolving it degrades cleanly instead of a guaranteed 403.
|
|
3895
|
-
`${config.promptPrefix}no-agent-configured`,
|
|
3896
|
-
// Agent prompts (`agent.promptName`) are free text, conventionally
|
|
3897
|
-
// `agent/<recordId>` (§3.7) — never promptPrefix-prefixed, so this is a
|
|
3898
|
-
// glob, not a `resolvePromptName` call.
|
|
3899
|
-
//
|
|
3900
|
-
// ACCEPTED RISK (owner decision, T25 review H1 — recorded, not fixed):
|
|
3901
|
-
// this glob is UNPREFIXED, so it matches `agent/<any-id>` regardless of
|
|
3902
|
-
// which audience app created that agent — under D-LF's single shared
|
|
3903
|
-
// Langfuse project there is no per-app namespace, and `*` matches `/`,
|
|
3904
|
-
// so `agent/*` cannot be scoped narrower than "every agent prompt, any
|
|
3905
|
-
// app" without inventing a real per-app agent-prompt namespace (which
|
|
3906
|
-
// would contradict §3.7's documented bare `agent/<recordId>` convention
|
|
3907
|
-
// outright). `app-prompts.controller.ts` applies this SAME allowlist to
|
|
3908
|
-
// WRITES too (`requirePromptAllowed` at `createVersion`/`promote`/
|
|
3909
|
-
// `deleteVersion`) for app-token callers — so one audience's app token
|
|
3910
|
-
// can read AND version-write another audience's `agent/<id>` prompt.
|
|
3911
|
-
// This is the documented cost of D-LF's single shared Langfuse
|
|
3912
|
-
// namespace, accepted explicitly by the repo owner rather than fixed
|
|
3913
|
-
// here (option (c) of the two open items this migration deferred — see
|
|
3914
|
-
// the migration progress journal's T25 entry). The mitigation NOT taken:
|
|
3915
|
-
// validating `agent.promptName` against the calling app's own agent
|
|
3916
|
-
// records at write time, which would need a DB read `app-prompts
|
|
3917
|
-
// .controller.ts` does not currently do and was not built.
|
|
3899
|
+
`${config.promptPrefix}*`,
|
|
3900
|
+
// Agent prompts are free text, conventionally `agent/<recordId>` (§3.7)
|
|
3901
|
+
// — never promptPrefix-prefixed, so they need their own glob.
|
|
3918
3902
|
"agent/*",
|
|
3919
|
-
//
|
|
3920
|
-
//
|
|
3921
|
-
// bare defaults, never through `resolvePromptName` — prefixing them
|
|
3922
|
-
// here would allowlist a name nothing ever requests. One glob covers
|
|
3923
|
-
// both today and any future `shared/*` prompt.
|
|
3903
|
+
// Company-wide by design (§3.8), resolved by bare NAME off the settings
|
|
3904
|
+
// fields' own defaults — outside every audience prefix.
|
|
3924
3905
|
"shared/*"
|
|
3925
3906
|
];
|
|
3926
3907
|
}
|