@apotech-os/support-kit 3.0.2 → 3.2.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-AFOXQT22.js → chunk-SFOPXCD4.js} +5 -3
- package/dist/chunk-SFOPXCD4.js.map +1 -0
- package/dist/index.cjs +38 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +39 -4
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +1259 -313
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +1260 -315
- package/dist/ui/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-AFOXQT22.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1338,6 +1338,7 @@ var TRIAGE_DECISION_FIELD_STATUS_UID = "7583d228-4449-40ef-9e7e-44e34897e020";
|
|
|
1338
1338
|
var TRIAGE_DECISION_FIELD_ERROR_UID = "b271362b-a1b3-4110-a197-0b7a2ec6b152";
|
|
1339
1339
|
var TRIAGE_DECISION_FIELD_RUN_ID_UID = "a1e244d6-8f4f-4cd5-8794-14f6e419b64e";
|
|
1340
1340
|
var TRIAGE_DECISION_FIELD_SUBJECT_RENAMED_UID = "449f1960-be88-4e42-96ee-43cd90f36f4c";
|
|
1341
|
+
var TRIAGE_DECISION_FIELD_TICKET_URL_UID = "727a775a-ea93-460f-9d08-16b05424c453";
|
|
1341
1342
|
var TRIAGE_DECISION_INDEX_TICKET_ID_UID = "20433066-e029-4faf-8033-c205cf5de0fb";
|
|
1342
1343
|
var TRIAGE_DECISION_INDEX_DECIDED_AT_UID = "94040f6d-1d55-498f-8db8-abe5aed17c0a";
|
|
1343
1344
|
var TRIAGE_DECISION_INDEX_ESCALATED_UID = "1c0ac4c3-9a48-4858-bbbf-0c689bbb5be5";
|
|
@@ -1663,6 +1664,14 @@ function buildTriageDecisionRecord(slug) {
|
|
|
1663
1664
|
label: "Ticket id",
|
|
1664
1665
|
isNullable: false
|
|
1665
1666
|
},
|
|
1667
|
+
{
|
|
1668
|
+
universalIdentifier: TRIAGE_DECISION_FIELD_TICKET_URL_UID,
|
|
1669
|
+
name: "ticketUrl",
|
|
1670
|
+
type: appKit.FieldType.TEXT,
|
|
1671
|
+
label: "Ticket url",
|
|
1672
|
+
description: "Deep link to the ticket in the helpdesk, resolved once per batch and frozen on the decision. Null on a decision written before this field existed, or when the connection exposes no public url (mock).",
|
|
1673
|
+
isNullable: true
|
|
1674
|
+
},
|
|
1666
1675
|
{
|
|
1667
1676
|
universalIdentifier: TRIAGE_DECISION_FIELD_DECIDED_AT_UID,
|
|
1668
1677
|
name: "decidedAt",
|
|
@@ -3238,12 +3247,34 @@ async function triageTickHandler(ctx, config) {
|
|
|
3238
3247
|
}
|
|
3239
3248
|
await runTriageBatch(ctx, config, settings);
|
|
3240
3249
|
}
|
|
3250
|
+
async function resolveTicketUrlBase(ctx) {
|
|
3251
|
+
try {
|
|
3252
|
+
const connections = await ctx.api.integrations.list("gorgias");
|
|
3253
|
+
const connection = connections.find((candidate) => candidate.isDefault) ?? connections[0];
|
|
3254
|
+
const result = await ctx.api.integrations.run(
|
|
3255
|
+
"gorgias",
|
|
3256
|
+
"getTicketUrlBase",
|
|
3257
|
+
{},
|
|
3258
|
+
connection ? { connectionId: connection.id } : void 0
|
|
3259
|
+
);
|
|
3260
|
+
return typeof result?.base === "string" && result.base !== "" ? result.base : null;
|
|
3261
|
+
} catch (err) {
|
|
3262
|
+
ctx.logger.warn("triage-tick: could not resolve the Gorgias ticket url base, decisions will carry no deep link", {
|
|
3263
|
+
error: err instanceof Error ? err.message : String(err)
|
|
3264
|
+
});
|
|
3265
|
+
return null;
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
function ticketUrlFor(base, ticketId) {
|
|
3269
|
+
return base ? `${base}/${encodeURIComponent(ticketId)}` : null;
|
|
3270
|
+
}
|
|
3241
3271
|
async function runTriageBatch(ctx, config, settings) {
|
|
3242
3272
|
const dryRun = settings.dryRun === true;
|
|
3243
3273
|
const ports = dryRun ? withRecordingWritePorts(buildTicketPorts(ctx), ctx.api) : buildTicketPorts(ctx);
|
|
3244
3274
|
const categories = await listCategories(ctx.api);
|
|
3245
3275
|
const batchDefaultAgent = await resolveDraftAgent(ctx.api, null);
|
|
3246
3276
|
const profile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(batchDefaultAgent, config), settings.nodes));
|
|
3277
|
+
const ticketUrlBase = await resolveTicketUrlBase(ctx);
|
|
3247
3278
|
const refs = await ports.conversation.listPending({ viewOrTag: settings.sourceViewId }, settings.batchLimit);
|
|
3248
3279
|
const run = await ctx.api.runs.start({
|
|
3249
3280
|
kind: "triage-tick",
|
|
@@ -3258,7 +3289,8 @@ async function runTriageBatch(ctx, config, settings) {
|
|
|
3258
3289
|
profile,
|
|
3259
3290
|
categories,
|
|
3260
3291
|
ports,
|
|
3261
|
-
runId: run.id
|
|
3292
|
+
runId: run.id,
|
|
3293
|
+
ticketUrlBase
|
|
3262
3294
|
});
|
|
3263
3295
|
} catch (err) {
|
|
3264
3296
|
failureCount += 1;
|
|
@@ -3267,6 +3299,7 @@ async function runTriageBatch(ctx, config, settings) {
|
|
|
3267
3299
|
try {
|
|
3268
3300
|
await ctx.api.create("triage-decision", {
|
|
3269
3301
|
ticketId: ref.id,
|
|
3302
|
+
ticketUrl: ticketUrlFor(ticketUrlBase, ref.id),
|
|
3270
3303
|
decidedAt: ports.clock.now(),
|
|
3271
3304
|
status: "error",
|
|
3272
3305
|
error: message,
|
|
@@ -3291,7 +3324,7 @@ async function runTriageBatch(ctx, config, settings) {
|
|
|
3291
3324
|
return { ticketCount: refs.length, failureCount };
|
|
3292
3325
|
}
|
|
3293
3326
|
async function processOneTicket(ctx, ref, deps) {
|
|
3294
|
-
const { profile, categories, ports, runId } = deps;
|
|
3327
|
+
const { profile, categories, ports, runId, ticketUrlBase } = deps;
|
|
3295
3328
|
let subjectRenamed = false;
|
|
3296
3329
|
if (profile.rename) {
|
|
3297
3330
|
const conversation2 = await ports.conversation.read(ref);
|
|
@@ -3322,6 +3355,7 @@ async function processOneTicket(ctx, ref, deps) {
|
|
|
3322
3355
|
if (!state.classification) {
|
|
3323
3356
|
await ctx.api.create("triage-decision", {
|
|
3324
3357
|
ticketId: ref.id,
|
|
3358
|
+
ticketUrl: ticketUrlFor(ticketUrlBase, ref.id),
|
|
3325
3359
|
decidedAt: ports.clock.now(),
|
|
3326
3360
|
status: "error",
|
|
3327
3361
|
error: "triage produced no classification",
|
|
@@ -3335,6 +3369,7 @@ async function processOneTicket(ctx, ref, deps) {
|
|
|
3335
3369
|
const category = findCategoryByTag(categories, classification.category);
|
|
3336
3370
|
const decision = await ctx.api.create("triage-decision", {
|
|
3337
3371
|
ticketId: ref.id,
|
|
3372
|
+
ticketUrl: ticketUrlFor(ticketUrlBase, ref.id),
|
|
3338
3373
|
decidedAt: ports.clock.now(),
|
|
3339
3374
|
categoryId: category?.id ?? null,
|
|
3340
3375
|
tag: classification.category,
|
|
@@ -5628,6 +5663,7 @@ var SUPPORT_KIT_GORGIAS_ACTIONS = [
|
|
|
5628
5663
|
"buildTicketContext",
|
|
5629
5664
|
"fetchTicketsFromView",
|
|
5630
5665
|
"getRawTicket",
|
|
5666
|
+
"getTicketUrlBase",
|
|
5631
5667
|
"getTicketWithContext",
|
|
5632
5668
|
"listViews",
|
|
5633
5669
|
"postWhatsappNote",
|