@apotech-os/support-kit 3.0.0 → 3.0.2
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-KCPVWKUY.js → chunk-AFOXQT22.js} +13 -8
- package/dist/chunk-AFOXQT22.js.map +1 -0
- package/dist/index.cjs +124 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -11
- package/dist/index.d.ts +7 -11
- package/dist/index.js +116 -25
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +1459 -88
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +3 -1
- package/dist/ui/index.d.ts +3 -1
- package/dist/ui/index.js +1461 -91
- package/dist/ui/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-KCPVWKUY.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -2439,12 +2439,11 @@ var SUPPORT_KIT_SETTINGS_FIELDS = [
|
|
|
2439
2439
|
// `validateSettings` refuses to run until `nodes.triage` is configured.
|
|
2440
2440
|
{ key: "nodes", type: "json", label: "Graph node overrides" },
|
|
2441
2441
|
// Audit tags
|
|
2442
|
-
{ key: "unknownTag", type: "string", label: "Unknown tag", default: "wai
|
|
2443
|
-
{ key: "handledTag", type: "string", label: "Handled tag", default: "wai
|
|
2444
|
-
{ key: "escalationTag", type: "string", label: "Escalation tag", default: "wai/
|
|
2445
|
-
{ key: "needsHumanTag", type: "string", label: "Needs-human tag", default: "wai/needs-human" },
|
|
2442
|
+
{ key: "unknownTag", type: "string", label: "Unknown tag", default: "wai/unknown" },
|
|
2443
|
+
{ key: "handledTag", type: "string", label: "Handled tag", default: "wai/triaged" },
|
|
2444
|
+
{ key: "escalationTag", type: "string", label: "Escalation tag", default: "wai/escalated" },
|
|
2446
2445
|
{ key: "autoRepliedTag", type: "string", label: "Auto-replied tag", default: "wai/auto-replied" },
|
|
2447
|
-
{ key: "needsReviewTag", type: "string", label: "
|
|
2446
|
+
{ key: "needsReviewTag", type: "string", label: "Review-before-send tag", default: "wai/escalated" },
|
|
2448
2447
|
{ key: "followupTag", type: "string", label: "Followup tag", default: "wai/followup-required" },
|
|
2449
2448
|
// Sending
|
|
2450
2449
|
{ key: "autoSendEnabled", type: "boolean", label: "Auto-send enabled", default: false },
|
|
@@ -3042,9 +3041,26 @@ async function readPipelineState(api) {
|
|
|
3042
3041
|
return page.items[0] ?? null;
|
|
3043
3042
|
}
|
|
3044
3043
|
async function upsertPipelineState(api, patch) {
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3044
|
+
const current = await readPipelineState(api);
|
|
3045
|
+
if (current) {
|
|
3046
|
+
await api.update("pipeline-state", current.id, patch);
|
|
3047
|
+
return;
|
|
3048
|
+
}
|
|
3049
|
+
await api.upsert(
|
|
3050
|
+
"pipeline-state",
|
|
3051
|
+
[
|
|
3052
|
+
{
|
|
3053
|
+
data: {
|
|
3054
|
+
singletonKey: PIPELINE_STATE_SINGLETON_KEY,
|
|
3055
|
+
sourceViewId: null,
|
|
3056
|
+
lastTriageAt: null,
|
|
3057
|
+
lastSweepAt: null,
|
|
3058
|
+
...patch
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
],
|
|
3062
|
+
{ uniqueBy: ["singletonKey"] }
|
|
3063
|
+
);
|
|
3048
3064
|
}
|
|
3049
3065
|
|
|
3050
3066
|
// src/functions/records.ts
|
|
@@ -3158,6 +3174,12 @@ function draftPromptRefFor(agent, config) {
|
|
|
3158
3174
|
...agent.systemPromptSnapshot ? { fallback: agent.systemPromptSnapshot } : {}
|
|
3159
3175
|
};
|
|
3160
3176
|
}
|
|
3177
|
+
function draftRebinder(api, categories, config) {
|
|
3178
|
+
return async (classification) => {
|
|
3179
|
+
const category = classification ? findCategoryByTag(categories, classification.category) : null;
|
|
3180
|
+
return draftPromptRefFor(await resolveDraftAgent(api, category?.agentId ?? null), config);
|
|
3181
|
+
};
|
|
3182
|
+
}
|
|
3161
3183
|
function buildPromptsTable(config, draft2, nodes) {
|
|
3162
3184
|
const DEFAULT_LABEL = "production";
|
|
3163
3185
|
const refFor = (node, derivedName, fallback2) => ({
|
|
@@ -4024,7 +4046,15 @@ async function previewTriageHandler(ctx, config, input) {
|
|
|
4024
4046
|
|
|
4025
4047
|
// src/functions/graph-dry-run-core.ts
|
|
4026
4048
|
var DRY_RUN_DEADLINE_MS = 3 * 60 * 1e3;
|
|
4027
|
-
async function
|
|
4049
|
+
async function runFromTriage(deps, rebindDraft) {
|
|
4050
|
+
if (!rebindDraft) return runTicket(deps);
|
|
4051
|
+
const triaged = await runTicket(deps, { until: "triage" });
|
|
4052
|
+
if (triaged.outcome) return triaged;
|
|
4053
|
+
const draft2 = await rebindDraft(triaged.classification);
|
|
4054
|
+
const rebound = { ...deps, profile: { ...deps.profile, prompts: { ...deps.profile.prompts, draft: draft2 } } };
|
|
4055
|
+
return runTicket(rebound, { resume: { classification: triaged.classification, escalated: triaged.escalated } });
|
|
4056
|
+
}
|
|
4057
|
+
async function runGraphDryRun({ base, api, resume, rebindDraft }) {
|
|
4028
4058
|
const recordingReply = createRecordingReplyPort();
|
|
4029
4059
|
const recordingState = createRecordingStatePort(api);
|
|
4030
4060
|
const recordingSend = createRecordingSendPort();
|
|
@@ -4046,7 +4076,7 @@ async function runGraphDryRun({ base, api, resume }) {
|
|
|
4046
4076
|
let result = null;
|
|
4047
4077
|
let error;
|
|
4048
4078
|
try {
|
|
4049
|
-
result = await runTicket(deps,
|
|
4079
|
+
result = resume ? await runTicket(deps, { resume }) : await runFromTriage(deps, rebindDraft);
|
|
4050
4080
|
} catch (err) {
|
|
4051
4081
|
error = err instanceof Error ? err.message : String(err);
|
|
4052
4082
|
}
|
|
@@ -4214,7 +4244,8 @@ async function graphDryRunHandler(ctx, config, input) {
|
|
|
4214
4244
|
// overridden unconditionally by `runGraphDryRun`
|
|
4215
4245
|
};
|
|
4216
4246
|
const resume = forcedCategory ? { classification: forcedClassification(forcedCategory.tagName), escalated: false } : void 0;
|
|
4217
|
-
|
|
4247
|
+
const rebindDraft = input.agentId || forcedCategory ? void 0 : draftRebinder(ctx.api, categories, config);
|
|
4248
|
+
return runGraphDryRun({ base, api: ctx.api, resume, ...rebindDraft ? { rebindDraft } : {} });
|
|
4218
4249
|
}
|
|
4219
4250
|
var DEFAULT_LIMIT = 20;
|
|
4220
4251
|
var MAX_LIMIT = 100;
|
|
@@ -4249,6 +4280,7 @@ async function testAgentsHandler(ctx, config, input) {
|
|
|
4249
4280
|
const categories = await listCategories(ctx.api);
|
|
4250
4281
|
const agent = input.agentId ? toAgent(await ctx.api.get("agent", input.agentId)) : await resolveDraftAgent(ctx.api, null);
|
|
4251
4282
|
const profile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(agent, config), settings.nodes));
|
|
4283
|
+
const rebindDraft = input.agentId ? void 0 : draftRebinder(ctx.api, categories, config);
|
|
4252
4284
|
const realPorts = buildTicketPorts(ctx);
|
|
4253
4285
|
const refs = explicitIds.length ? explicitIds.slice(0, limit).map((id) => ({ id, channel: "gorgias" })) : await realPorts.conversation.listPending({ viewOrTag: viewId }, limit);
|
|
4254
4286
|
const deadline = AbortSignal.timeout(DRY_RUN_DEADLINE_MS);
|
|
@@ -4275,7 +4307,7 @@ async function testAgentsHandler(ctx, config, input) {
|
|
|
4275
4307
|
send: { mode: "none" }
|
|
4276
4308
|
// overridden unconditionally by `runGraphDryRun`
|
|
4277
4309
|
};
|
|
4278
|
-
results.push(await runGraphDryRun({ base, api: ctx.api }));
|
|
4310
|
+
results.push(await runGraphDryRun({ base, api: ctx.api, ...rebindDraft ? { rebindDraft } : {} }));
|
|
4279
4311
|
}
|
|
4280
4312
|
return { results, autoReplyForced: true };
|
|
4281
4313
|
}
|
|
@@ -5602,7 +5634,13 @@ var SUPPORT_KIT_GORGIAS_ACTIONS = [
|
|
|
5602
5634
|
"renameTicket",
|
|
5603
5635
|
"replyEmail"
|
|
5604
5636
|
];
|
|
5605
|
-
var SUPPORT_KIT_CAPABILITIES = [
|
|
5637
|
+
var SUPPORT_KIT_CAPABILITIES = [
|
|
5638
|
+
"runs",
|
|
5639
|
+
"inbox",
|
|
5640
|
+
"approvals",
|
|
5641
|
+
"prompts",
|
|
5642
|
+
"langfuse"
|
|
5643
|
+
];
|
|
5606
5644
|
var SUPPORT_KIT_ACTIONS = [
|
|
5607
5645
|
...SUPPORT_KIT_GORGIAS_ACTIONS.map((action) => ({ provider: "gorgias", action })),
|
|
5608
5646
|
{ provider: "llm", action: "complete" }
|
|
@@ -5610,18 +5648,58 @@ var SUPPORT_KIT_ACTIONS = [
|
|
|
5610
5648
|
var SUPPORT_KIT_EMITS = [TRIAGE_RUN_REQUESTED_EVENT];
|
|
5611
5649
|
var FUNCTION_ASSEMBLY = [
|
|
5612
5650
|
{ key: "triage-tick", build: buildTriageTickFunctionDef, createHandler: createTriageTickHandler },
|
|
5613
|
-
{
|
|
5651
|
+
{
|
|
5652
|
+
key: "process-response",
|
|
5653
|
+
build: buildProcessResponseFunctionDef,
|
|
5654
|
+
createHandler: createProcessResponseHandler
|
|
5655
|
+
},
|
|
5614
5656
|
{ key: "sweep", build: buildSweepFunctionDef, createHandler: () => createSweepHandler() },
|
|
5615
|
-
{
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5657
|
+
{
|
|
5658
|
+
key: "handle-approval",
|
|
5659
|
+
build: buildHandleApprovalFunctionDef,
|
|
5660
|
+
createHandler: createHandleApprovalHandler
|
|
5661
|
+
},
|
|
5662
|
+
{
|
|
5663
|
+
key: "run-triage-now",
|
|
5664
|
+
build: buildRunTriageNowFunctionDef,
|
|
5665
|
+
createHandler: createRunTriageNowHandler
|
|
5666
|
+
},
|
|
5667
|
+
{
|
|
5668
|
+
key: "run-triage-batch",
|
|
5669
|
+
build: buildRunTriageBatchFunctionDef,
|
|
5670
|
+
createHandler: createRunTriageBatchHandler
|
|
5671
|
+
},
|
|
5672
|
+
{
|
|
5673
|
+
key: "preview-triage",
|
|
5674
|
+
build: buildPreviewTriageFunctionDef,
|
|
5675
|
+
createHandler: createPreviewTriageHandler
|
|
5676
|
+
},
|
|
5677
|
+
{
|
|
5678
|
+
key: "graph-dry-run",
|
|
5679
|
+
build: buildGraphDryRunFunctionDef,
|
|
5680
|
+
createHandler: createGraphDryRunHandler
|
|
5681
|
+
},
|
|
5620
5682
|
{ key: "test-agents", build: buildTestAgentsFunctionDef, createHandler: createTestAgentsHandler },
|
|
5621
|
-
{
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5683
|
+
{
|
|
5684
|
+
key: "suggest-prompt",
|
|
5685
|
+
build: buildSuggestPromptFunctionDef,
|
|
5686
|
+
createHandler: createSuggestPromptHandler
|
|
5687
|
+
},
|
|
5688
|
+
{
|
|
5689
|
+
key: "run-diff-analysis",
|
|
5690
|
+
build: buildRunDiffAnalysisFunctionDef,
|
|
5691
|
+
createHandler: createRunDiffAnalysisHandler
|
|
5692
|
+
},
|
|
5693
|
+
{
|
|
5694
|
+
key: "list-gorgias-views",
|
|
5695
|
+
build: buildListGorgiasViewsFunctionDef,
|
|
5696
|
+
createHandler: createListGorgiasViewsHandler
|
|
5697
|
+
},
|
|
5698
|
+
{
|
|
5699
|
+
key: "create-agent",
|
|
5700
|
+
build: buildCreateAgentFunctionDef,
|
|
5701
|
+
createHandler: () => createCreateAgentHandler()
|
|
5702
|
+
},
|
|
5625
5703
|
{
|
|
5626
5704
|
key: "set-default-agent",
|
|
5627
5705
|
build: buildSetDefaultAgentFunctionDef,
|
|
@@ -5637,15 +5715,27 @@ var FUNCTION_ASSEMBLY = [
|
|
|
5637
5715
|
build: buildSyncAgentPromptSnapshotFunctionDef,
|
|
5638
5716
|
createHandler: () => createSyncAgentPromptSnapshotHandler()
|
|
5639
5717
|
},
|
|
5640
|
-
{
|
|
5641
|
-
|
|
5718
|
+
{
|
|
5719
|
+
key: "ext-models",
|
|
5720
|
+
build: buildExtModelsFunctionDef,
|
|
5721
|
+
createHandler: () => createExtModelsHandler()
|
|
5722
|
+
},
|
|
5723
|
+
{
|
|
5724
|
+
key: "ext-categories",
|
|
5725
|
+
build: buildExtCategoriesFunctionDef,
|
|
5726
|
+
createHandler: () => createExtCategoriesHandler()
|
|
5727
|
+
},
|
|
5642
5728
|
{ key: "ext-chat", build: buildExtChatFunctionDef, createHandler: () => createExtChatHandler() },
|
|
5643
5729
|
{
|
|
5644
5730
|
key: "ext-fast-response-check",
|
|
5645
5731
|
build: buildExtFastResponseCheckFunctionDef,
|
|
5646
5732
|
createHandler: () => createExtFastResponseCheckHandler()
|
|
5647
5733
|
},
|
|
5648
|
-
{
|
|
5734
|
+
{
|
|
5735
|
+
key: "ext-evaluation",
|
|
5736
|
+
build: buildExtEvaluationFunctionDef,
|
|
5737
|
+
createHandler: () => createExtEvaluationHandler()
|
|
5738
|
+
},
|
|
5649
5739
|
{
|
|
5650
5740
|
key: "ext-response-comparison",
|
|
5651
5741
|
build: buildExtResponseComparisonFunctionDef,
|
|
@@ -5689,8 +5779,14 @@ var KIT_PAGES = [
|
|
|
5689
5779
|
{ key: "escalations-page", path: "escalations", title: "Escalades", icon: "alert-triangle" },
|
|
5690
5780
|
{ key: "corrections-page", path: "corrections", title: "Corrections", icon: "git-compare" },
|
|
5691
5781
|
{ key: "graph-canvas-page", path: "graph-canvas", title: "Graphe", icon: "workflow" },
|
|
5692
|
-
{
|
|
5693
|
-
|
|
5782
|
+
{
|
|
5783
|
+
key: "shared-prompts-page",
|
|
5784
|
+
path: "shared-prompts",
|
|
5785
|
+
title: "Prompts partag\xE9s",
|
|
5786
|
+
icon: "library"
|
|
5787
|
+
},
|
|
5788
|
+
{ key: "test-page", path: "test", title: "Banc de test", icon: "flask-conical" },
|
|
5789
|
+
{ key: "quality-page", path: "quality", title: "Qualit\xE9", icon: "flask-conical" }
|
|
5694
5790
|
];
|
|
5695
5791
|
function buildPages(config) {
|
|
5696
5792
|
return KIT_PAGES.map(({ key, path, title, icon }) => ({
|