@apotech-os/support-kit 8.2.0 → 8.3.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/README.md +11 -4
- package/dist/{chunk-LXHPPWPM.js → chunk-WVKCRPMV.js} +51 -10
- package/dist/chunk-WVKCRPMV.js.map +1 -0
- package/dist/index.cjs +72 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +88 -16
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +48 -8
- package/dist/ui/index.js.map +1 -1
- package/package.json +11 -11
- package/dist/chunk-LXHPPWPM.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -747,9 +747,9 @@ async function draftWithTools(params) {
|
|
|
747
747
|
return finish(null, sources, messages, null);
|
|
748
748
|
}
|
|
749
749
|
function finish(text, sources, messages, attribution) {
|
|
750
|
-
const
|
|
751
|
-
if (!
|
|
752
|
-
return { text:
|
|
750
|
+
const trimmed2 = (text ?? "").trim();
|
|
751
|
+
if (!trimmed2) throw new Error("Provider returned empty response");
|
|
752
|
+
return { text: trimmed2, sources, messages, revised: false, ...attribution ? { attribution } : {} };
|
|
753
753
|
}
|
|
754
754
|
function attributionOf(result, promptRef) {
|
|
755
755
|
return {
|
|
@@ -896,9 +896,9 @@ function buildMessages(input) {
|
|
|
896
896
|
];
|
|
897
897
|
}
|
|
898
898
|
function section(title, body) {
|
|
899
|
-
const
|
|
900
|
-
return
|
|
901
|
-
${
|
|
899
|
+
const trimmed2 = body?.trim();
|
|
900
|
+
return trimmed2 ? `## ${title}
|
|
901
|
+
${trimmed2}` : null;
|
|
902
902
|
}
|
|
903
903
|
|
|
904
904
|
// src/graph/revise.ts
|
|
@@ -2578,6 +2578,15 @@ var SUPPORT_KIT_SETTINGS_FIELDS = [
|
|
|
2578
2578
|
{ key: "autoRepliedTag", type: "string", label: "Auto-replied tag", default: "wai/auto-replied" },
|
|
2579
2579
|
{ key: "needsReviewTag", type: "string", label: "Review-before-send tag", default: "wai/escalated" },
|
|
2580
2580
|
{ key: "followupTag", type: "string", label: "Followup tag", default: "wai/human-required" },
|
|
2581
|
+
// The app's OWNERSHIP mark: applied to every ticket its triage sees, in the
|
|
2582
|
+
// same call as the tags above (`adapters/gorgias-tags.ts`), so that a later
|
|
2583
|
+
// pass can tell this app's tickets from a neighbouring app's on a SHARED
|
|
2584
|
+
// Gorgias account. Every other audit tag here ships the same default in
|
|
2585
|
+
// every app — `handledTag` is `wai/triaged` everywhere — so none of them can
|
|
2586
|
+
// answer "whose ticket is this?". Empty by default for the same reason a
|
|
2587
|
+
// shared default would be useless: an ownership mark two apps have in common
|
|
2588
|
+
// marks nothing. Empty means "stamp nothing".
|
|
2589
|
+
{ key: "appScopeTag", type: "string", label: "App scope tag", default: "" },
|
|
2581
2590
|
// Follow-up webhook (spec-gorgias-followup-webhook-v1 D2)
|
|
2582
2591
|
// The tag a ticket must ALREADY carry for this app to answer a SUBSEQUENT
|
|
2583
2592
|
// customer message on it. Deliberately empty by default, twice over:
|
|
@@ -2701,6 +2710,37 @@ function isConfiguredNode(nodes) {
|
|
|
2701
2710
|
return typeof triage2 === "object" && triage2 !== null;
|
|
2702
2711
|
}
|
|
2703
2712
|
|
|
2713
|
+
// src/settings/warnings.ts
|
|
2714
|
+
var HUMAN_TAKEOVER_KEYS = ["escalationTag", "needsReviewTag", "followupTag"];
|
|
2715
|
+
var AUDIT_TAG_KEYS = ["unknownTag", "handledTag", "escalationTag", "autoRepliedTag", "needsReviewTag", "followupTag"];
|
|
2716
|
+
function settingsWarnings(settings) {
|
|
2717
|
+
const warnings = [];
|
|
2718
|
+
const appScopeTag = trimmed(settings.appScopeTag);
|
|
2719
|
+
const webhookScopeTag = trimmed(settings.webhookScopeTag);
|
|
2720
|
+
const collidesWith = (keys) => appScopeTag ? keys.filter((key) => trimmed(settings[key]) === appScopeTag) : [];
|
|
2721
|
+
if (collidesWith(HUMAN_TAKEOVER_KEYS).length > 0) {
|
|
2722
|
+
warnings.push({
|
|
2723
|
+
key: "appScopeTagVetoesFollowups",
|
|
2724
|
+
message: "Le tag d\u2019appartenance est l\u2019un des tags de reprise humaine (escalade, relecture, suivi) : le webhook de suivi consid\xE9rera que chaque ticket tri\xE9 a \xE9t\xE9 repris par un humain et ne r\xE9pondra plus \xE0 aucun message suivant."
|
|
2725
|
+
});
|
|
2726
|
+
} else if (collidesWith(AUDIT_TAG_KEYS).length > 0) {
|
|
2727
|
+
warnings.push({
|
|
2728
|
+
key: "appScopeTagCollision",
|
|
2729
|
+
message: "Le tag d\u2019appartenance est l\u2019un des autres tags d\u2019audit, que toutes les apps posent avec la m\xEAme valeur par d\xE9faut : il ne distingue donc pas cette app d\u2019une autre install\xE9e sur le m\xEAme compte Gorgias."
|
|
2730
|
+
});
|
|
2731
|
+
}
|
|
2732
|
+
if (appScopeTag && webhookScopeTag && appScopeTag !== webhookScopeTag) {
|
|
2733
|
+
warnings.push({
|
|
2734
|
+
key: "scopeTagMismatch",
|
|
2735
|
+
message: "Le tag de p\xE9rim\xE8tre du webhook de suivi n\u2019est pas celui que cette app pose sur ses tickets : le webhook ne r\xE9pondra sur aucun ticket tri\xE9 ici."
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
return warnings;
|
|
2739
|
+
}
|
|
2740
|
+
function trimmed(value) {
|
|
2741
|
+
return typeof value === "string" ? value.trim() : "";
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2704
2744
|
// src/settings/to-profile.ts
|
|
2705
2745
|
var DEFAULT_REASONING = "off";
|
|
2706
2746
|
var DEFAULT_MAX_TOOL_CALLS = 5;
|
|
@@ -2711,7 +2751,8 @@ function toAuditTags(settings) {
|
|
|
2711
2751
|
escalationTag: settings.escalationTag,
|
|
2712
2752
|
sentTag: settings.autoRepliedTag,
|
|
2713
2753
|
needsHumanTag: settings.needsReviewTag,
|
|
2714
|
-
followupTag: settings.followupTag
|
|
2754
|
+
followupTag: settings.followupTag,
|
|
2755
|
+
appScopeTag: settings.appScopeTag
|
|
2715
2756
|
};
|
|
2716
2757
|
}
|
|
2717
2758
|
var DEFAULT_MIN_CONFIDENCE = 0.8;
|
|
@@ -2881,10 +2922,10 @@ function dedupeTagNames(tags) {
|
|
|
2881
2922
|
const seen = /* @__PURE__ */ new Set();
|
|
2882
2923
|
const out = [];
|
|
2883
2924
|
for (const tag of tags) {
|
|
2884
|
-
const
|
|
2885
|
-
if (
|
|
2886
|
-
seen.add(
|
|
2887
|
-
out.push(
|
|
2925
|
+
const trimmed2 = (tag ?? "").trim();
|
|
2926
|
+
if (trimmed2 && !seen.has(trimmed2)) {
|
|
2927
|
+
seen.add(trimmed2);
|
|
2928
|
+
out.push(trimmed2);
|
|
2888
2929
|
}
|
|
2889
2930
|
}
|
|
2890
2931
|
return out;
|
|
@@ -2896,7 +2937,7 @@ async function extraTagsFor(api, tagName) {
|
|
|
2896
2937
|
}
|
|
2897
2938
|
async function resolveHandledTags(api, classification, audit) {
|
|
2898
2939
|
const extraTags = await extraTagsFor(api, classification.category);
|
|
2899
|
-
return dedupeTagNames([classification.category, ...extraTags, audit.handledTag]);
|
|
2940
|
+
return dedupeTagNames([classification.category, ...extraTags, audit.handledTag, audit.appScopeTag]);
|
|
2900
2941
|
}
|
|
2901
2942
|
|
|
2902
2943
|
// src/adapters/ctx-ports.ts
|
|
@@ -2954,9 +2995,9 @@ function createGorgiasStatePort(api) {
|
|
|
2954
2995
|
await api.integrations.run("gorgias", "renameTicket", { ticketId: ref.id, subject });
|
|
2955
2996
|
},
|
|
2956
2997
|
async flag(ref, tag) {
|
|
2957
|
-
const
|
|
2958
|
-
if (!
|
|
2959
|
-
await api.integrations.run("gorgias", "applyTags", { ticketId: ref.id, names: [
|
|
2998
|
+
const trimmed2 = tag.trim();
|
|
2999
|
+
if (!trimmed2) return;
|
|
3000
|
+
await api.integrations.run("gorgias", "applyTags", { ticketId: ref.id, names: [trimmed2] });
|
|
2960
3001
|
}
|
|
2961
3002
|
};
|
|
2962
3003
|
}
|
|
@@ -3063,8 +3104,8 @@ function createRecordingReplyPort() {
|
|
|
3063
3104
|
function createRecordingStatePort(api) {
|
|
3064
3105
|
const tagged = [];
|
|
3065
3106
|
const push = (tag) => {
|
|
3066
|
-
const
|
|
3067
|
-
if (
|
|
3107
|
+
const trimmed2 = tag.trim();
|
|
3108
|
+
if (trimmed2 && !tagged.includes(trimmed2)) tagged.push(trimmed2);
|
|
3068
3109
|
};
|
|
3069
3110
|
return {
|
|
3070
3111
|
port: {
|
|
@@ -3759,6 +3800,7 @@ async function handleTicketFailure(ctx, ref, err, deps) {
|
|
|
3759
3800
|
await finalizeFailedResponse(ctx, ref, err.generatedResponseId, message);
|
|
3760
3801
|
} else {
|
|
3761
3802
|
await writeErrorDecision(ctx, ref, message, deps);
|
|
3803
|
+
await stampAppScope(ctx, ref, deps.profile.audit.appScopeTag, deps.ports);
|
|
3762
3804
|
}
|
|
3763
3805
|
await escalateTicket(ctx, ref, deps);
|
|
3764
3806
|
}
|
|
@@ -3798,6 +3840,16 @@ async function writeErrorDecision(ctx, ref, message, deps) {
|
|
|
3798
3840
|
async function escalateTicket(ctx, ref, deps) {
|
|
3799
3841
|
await flagEscalation(ctx, ref, deps.profile.audit.escalationTag, deps.ports);
|
|
3800
3842
|
}
|
|
3843
|
+
async function stampAppScope(ctx, ref, tag, ports) {
|
|
3844
|
+
if (!tag) return;
|
|
3845
|
+
try {
|
|
3846
|
+
await ports.state.flag(ref, tag);
|
|
3847
|
+
} catch (err) {
|
|
3848
|
+
ctx.logger.error(`triage-tick: failed to stamp the app scope tag on ticket ${ref.id}`, {
|
|
3849
|
+
error: err instanceof Error ? err.message : String(err)
|
|
3850
|
+
});
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3801
3853
|
async function flagEscalation(ctx, ref, tag, ports) {
|
|
3802
3854
|
if (!tag) {
|
|
3803
3855
|
ctx.logger.warn(`triage-tick: ticket ${ref.id} is escalated but escalationTag is not configured \u2014 no tag applied`);
|
|
@@ -6106,8 +6158,8 @@ function parseTicketId(raw) {
|
|
|
6106
6158
|
}
|
|
6107
6159
|
function parseText(raw) {
|
|
6108
6160
|
if (typeof raw !== "string") return null;
|
|
6109
|
-
const
|
|
6110
|
-
return
|
|
6161
|
+
const trimmed2 = raw.trim();
|
|
6162
|
+
return trimmed2 === "" ? null : trimmed2;
|
|
6111
6163
|
}
|
|
6112
6164
|
function parseDate(raw) {
|
|
6113
6165
|
if (typeof raw !== "string") return null;
|
|
@@ -6812,6 +6864,7 @@ exports.resolvePromptName = resolvePromptName;
|
|
|
6812
6864
|
exports.runGuardrails = runGuardrails;
|
|
6813
6865
|
exports.runTicket = runTicket;
|
|
6814
6866
|
exports.settingsToProfile = settingsToProfile;
|
|
6867
|
+
exports.settingsWarnings = settingsWarnings;
|
|
6815
6868
|
exports.stopOptOut = stopOptOut;
|
|
6816
6869
|
exports.targetRefFor = targetRefFor;
|
|
6817
6870
|
exports.toDecisionOrigin = toDecisionOrigin;
|