@mgsoftwarebv/mcp-server-bridge 3.5.21 → 3.5.22
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.js +130 -47
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -105607,8 +105607,86 @@ var Server = class extends Protocol {
|
|
|
105607
105607
|
};
|
|
105608
105608
|
|
|
105609
105609
|
// src/telemetry.ts
|
|
105610
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
105611
|
+
function isUuid(value) {
|
|
105612
|
+
return UUID_RE.test(value);
|
|
105613
|
+
}
|
|
105610
105614
|
var MCP_TELEMETRY_CATEGORY = "mcp_tool_call";
|
|
105611
105615
|
var MCP_TELEMETRY_SOURCE = "mcp";
|
|
105616
|
+
function assignTicketRef(refs, value) {
|
|
105617
|
+
const trimmed = value.trim();
|
|
105618
|
+
if (!trimmed) return;
|
|
105619
|
+
if (isUuid(trimmed)) {
|
|
105620
|
+
refs.ticketId = trimmed;
|
|
105621
|
+
return;
|
|
105622
|
+
}
|
|
105623
|
+
refs.ticketNumber = trimmed;
|
|
105624
|
+
}
|
|
105625
|
+
function collectTicketRefsFromEntity(entity) {
|
|
105626
|
+
const refs = [];
|
|
105627
|
+
if (entity.ticketId) refs.push(entity.ticketId);
|
|
105628
|
+
if (entity.ticketNumber) refs.push(entity.ticketNumber);
|
|
105629
|
+
return refs;
|
|
105630
|
+
}
|
|
105631
|
+
async function resolveTicketRefMap(params) {
|
|
105632
|
+
const uuidRefs = /* @__PURE__ */ new Set();
|
|
105633
|
+
const numberRefs = /* @__PURE__ */ new Set();
|
|
105634
|
+
const allRefs = /* @__PURE__ */ new Set();
|
|
105635
|
+
for (const ref of params.refs) {
|
|
105636
|
+
const trimmed = ref.trim();
|
|
105637
|
+
if (!trimmed) continue;
|
|
105638
|
+
allRefs.add(trimmed);
|
|
105639
|
+
if (isUuid(trimmed)) uuidRefs.add(trimmed);
|
|
105640
|
+
else numberRefs.add(trimmed);
|
|
105641
|
+
}
|
|
105642
|
+
if (allRefs.size === 0) {
|
|
105643
|
+
return { byRef: /* @__PURE__ */ new Map(), unresolved: [] };
|
|
105644
|
+
}
|
|
105645
|
+
const lookup = [];
|
|
105646
|
+
if (uuidRefs.size > 0) {
|
|
105647
|
+
lookup.push(inArray(schema_exports.tickets.id, [...uuidRefs]));
|
|
105648
|
+
}
|
|
105649
|
+
for (const num of numberRefs) {
|
|
105650
|
+
lookup.push(sql`lower(${schema_exports.tickets.ticketNumber}) = lower(${num})`);
|
|
105651
|
+
}
|
|
105652
|
+
const ticketRows = await db.select({
|
|
105653
|
+
id: schema_exports.tickets.id,
|
|
105654
|
+
ticketNumber: schema_exports.tickets.ticketNumber,
|
|
105655
|
+
title: schema_exports.tickets.title,
|
|
105656
|
+
projectId: schema_exports.tickets.projectId
|
|
105657
|
+
}).from(schema_exports.tickets).where(
|
|
105658
|
+
and(
|
|
105659
|
+
inArray(schema_exports.tickets.teamId, params.teamIds),
|
|
105660
|
+
eq(schema_exports.tickets.isDeleted, false),
|
|
105661
|
+
or(...lookup)
|
|
105662
|
+
)
|
|
105663
|
+
);
|
|
105664
|
+
const byRef = /* @__PURE__ */ new Map();
|
|
105665
|
+
for (const t9 of ticketRows) {
|
|
105666
|
+
const info = {
|
|
105667
|
+
id: t9.id,
|
|
105668
|
+
ticketNumber: t9.ticketNumber,
|
|
105669
|
+
title: t9.title,
|
|
105670
|
+
projectId: t9.projectId
|
|
105671
|
+
};
|
|
105672
|
+
byRef.set(t9.id, info);
|
|
105673
|
+
if (t9.ticketNumber) {
|
|
105674
|
+
byRef.set(t9.ticketNumber, info);
|
|
105675
|
+
byRef.set(t9.ticketNumber.toLowerCase(), info);
|
|
105676
|
+
}
|
|
105677
|
+
}
|
|
105678
|
+
const unresolved = [...allRefs].filter(
|
|
105679
|
+
(ref) => !byRef.has(ref) && !byRef.has(ref.toLowerCase())
|
|
105680
|
+
);
|
|
105681
|
+
return { byRef, unresolved };
|
|
105682
|
+
}
|
|
105683
|
+
function lookupResolvedTicket(byRef, entity) {
|
|
105684
|
+
for (const ref of collectTicketRefsFromEntity(entity)) {
|
|
105685
|
+
const hit = byRef.get(ref) ?? byRef.get(ref.toLowerCase());
|
|
105686
|
+
if (hit) return hit;
|
|
105687
|
+
}
|
|
105688
|
+
return void 0;
|
|
105689
|
+
}
|
|
105612
105690
|
var ENTITY_ID_FIELDS = [
|
|
105613
105691
|
"ticketId",
|
|
105614
105692
|
"projectId",
|
|
@@ -105647,15 +105725,20 @@ function extractSafeEntityRefs(toolName, args2) {
|
|
|
105647
105725
|
if (!args2 || typeof args2 !== "object") return refs;
|
|
105648
105726
|
for (const field of ENTITY_ID_FIELDS) {
|
|
105649
105727
|
const value = args2[field];
|
|
105650
|
-
if (typeof value
|
|
105651
|
-
|
|
105728
|
+
if (typeof value !== "string" || !value.trim()) continue;
|
|
105729
|
+
const trimmed = value.trim();
|
|
105730
|
+
if (field === "ticketId") {
|
|
105731
|
+
assignTicketRef(refs, trimmed);
|
|
105732
|
+
continue;
|
|
105652
105733
|
}
|
|
105734
|
+
refs[field] = trimmed;
|
|
105653
105735
|
}
|
|
105654
105736
|
const rawId = typeof args2.id === "string" ? args2.id.trim() : "";
|
|
105655
105737
|
if (rawId) {
|
|
105656
105738
|
const n3 = toolName.toLowerCase();
|
|
105657
|
-
if (!refs.ticketId && n3.includes("ticket"))
|
|
105658
|
-
|
|
105739
|
+
if (!refs.ticketId && !refs.ticketNumber && n3.includes("ticket")) {
|
|
105740
|
+
assignTicketRef(refs, rawId);
|
|
105741
|
+
} else if (!refs.projectId && n3.includes("project")) refs.projectId = rawId;
|
|
105659
105742
|
else if (!refs.customerId && n3.includes("customer")) refs.customerId = rawId;
|
|
105660
105743
|
else if (!refs.invoiceId && n3.includes("invoice")) refs.invoiceId = rawId;
|
|
105661
105744
|
else if (!refs.documentId && n3.includes("document")) refs.documentId = rawId;
|
|
@@ -105744,6 +105827,7 @@ async function queryMcpActivityRows(params) {
|
|
|
105744
105827
|
durationMs: row.durationMs ?? null,
|
|
105745
105828
|
entity: {
|
|
105746
105829
|
ticketId: readString(meta5, "ticketId"),
|
|
105830
|
+
ticketNumber: readString(meta5, "ticketNumber"),
|
|
105747
105831
|
projectId: readString(meta5, "projectId"),
|
|
105748
105832
|
customerId: readString(meta5, "customerId"),
|
|
105749
105833
|
invoiceId: readString(meta5, "invoiceId"),
|
|
@@ -108559,7 +108643,7 @@ async function resolveTeamScope(requestedTeamId) {
|
|
|
108559
108643
|
|
|
108560
108644
|
// src/tools/ticket-access.ts
|
|
108561
108645
|
var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
108562
|
-
function
|
|
108646
|
+
function isUuid2(value) {
|
|
108563
108647
|
return UUID_REGEX.test(value);
|
|
108564
108648
|
}
|
|
108565
108649
|
function notFoundResponse(identifier) {
|
|
@@ -108592,7 +108676,7 @@ var ticketLookupFields = {
|
|
|
108592
108676
|
title: schema_exports.tickets.title
|
|
108593
108677
|
};
|
|
108594
108678
|
async function resolveTicketIdentifier(requestedTeamId, identifier) {
|
|
108595
|
-
if (
|
|
108679
|
+
if (isUuid2(identifier)) {
|
|
108596
108680
|
return { ok: true, id: identifier };
|
|
108597
108681
|
}
|
|
108598
108682
|
const scope = await resolveTeamScope(requestedTeamId);
|
|
@@ -121962,7 +122046,7 @@ var INVOICE_STATUSES = [
|
|
|
121962
122046
|
"scheduled",
|
|
121963
122047
|
"refunded"
|
|
121964
122048
|
];
|
|
121965
|
-
var
|
|
122049
|
+
var UUID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
121966
122050
|
function textResponse4(text3) {
|
|
121967
122051
|
return { content: [{ type: "text", text: text3 }] };
|
|
121968
122052
|
}
|
|
@@ -122023,7 +122107,7 @@ function parseStoredLineItems(value) {
|
|
|
122023
122107
|
}
|
|
122024
122108
|
async function loadInvoiceByIdentifier(identifier, teamIds) {
|
|
122025
122109
|
if (teamIds.length === 0) return null;
|
|
122026
|
-
const byId =
|
|
122110
|
+
const byId = UUID_RE2.test(identifier);
|
|
122027
122111
|
const filters = [inArray(schema_exports.invoices.teamId, teamIds)];
|
|
122028
122112
|
filters.push(
|
|
122029
122113
|
byId ? eq(schema_exports.invoices.id, identifier) : eq(schema_exports.invoices.invoiceNumber, identifier)
|
|
@@ -128969,11 +129053,13 @@ async function handleGetRefrontMcpActivity(input) {
|
|
|
128969
129053
|
);
|
|
128970
129054
|
}
|
|
128971
129055
|
const userIds = /* @__PURE__ */ new Set();
|
|
128972
|
-
const
|
|
129056
|
+
const ticketRefs = /* @__PURE__ */ new Set();
|
|
128973
129057
|
const projectIds = /* @__PURE__ */ new Set();
|
|
128974
129058
|
for (const r6 of rows) {
|
|
128975
129059
|
if (r6.userId) userIds.add(r6.userId);
|
|
128976
|
-
|
|
129060
|
+
for (const ref of collectTicketRefsFromEntity(r6.entity)) {
|
|
129061
|
+
ticketRefs.add(ref);
|
|
129062
|
+
}
|
|
128977
129063
|
if (r6.entity.projectId) projectIds.add(r6.entity.projectId);
|
|
128978
129064
|
}
|
|
128979
129065
|
const usersById = /* @__PURE__ */ new Map();
|
|
@@ -128981,34 +129067,27 @@ async function handleGetRefrontMcpActivity(input) {
|
|
|
128981
129067
|
const userRows = await db.select({ id: schema_exports.users.id, name: schema_exports.users.fullName }).from(schema_exports.users).where(inArray(schema_exports.users.id, [...userIds]));
|
|
128982
129068
|
for (const u2 of userRows) usersById.set(u2.id, u2.name);
|
|
128983
129069
|
}
|
|
128984
|
-
const
|
|
128985
|
-
if (
|
|
128986
|
-
const
|
|
128987
|
-
|
|
128988
|
-
|
|
128989
|
-
|
|
128990
|
-
projectId: schema_exports.tickets.projectId
|
|
128991
|
-
}).from(schema_exports.tickets).where(
|
|
128992
|
-
and(
|
|
128993
|
-
inArray(schema_exports.tickets.id, [...ticketIds]),
|
|
128994
|
-
inArray(schema_exports.tickets.teamId, scope.teamIds)
|
|
128995
|
-
)
|
|
129070
|
+
const { byRef: ticketsByRef, unresolved: unresolvedTicketRefs } = await resolveTicketRefMap({ refs: ticketRefs, teamIds: scope.teamIds });
|
|
129071
|
+
if (unresolvedTicketRefs.length > 0) {
|
|
129072
|
+
const preview = unresolvedTicketRefs.slice(0, 5).join(", ");
|
|
129073
|
+
const suffix = unresolvedTicketRefs.length > 5 ? ` (+${unresolvedTicketRefs.length - 5} more)` : "";
|
|
129074
|
+
limitations.push(
|
|
129075
|
+
`${unresolvedTicketRefs.length} ticket ref(s) could not be resolved: ${preview}${suffix}.`
|
|
128996
129076
|
);
|
|
128997
|
-
|
|
128998
|
-
|
|
128999
|
-
|
|
129000
|
-
title: t9.title,
|
|
129001
|
-
projectId: t9.projectId
|
|
129002
|
-
});
|
|
129003
|
-
if (t9.projectId) projectIds.add(t9.projectId);
|
|
129004
|
-
}
|
|
129077
|
+
}
|
|
129078
|
+
for (const info of ticketsByRef.values()) {
|
|
129079
|
+
if (info.projectId) projectIds.add(info.projectId);
|
|
129005
129080
|
}
|
|
129006
129081
|
const projectsById = /* @__PURE__ */ new Map();
|
|
129007
129082
|
if (projectIds.size > 0) {
|
|
129008
129083
|
const projectRows = await db.select({ id: schema_exports.projects.id, name: schema_exports.projects.name }).from(schema_exports.projects).where(inArray(schema_exports.projects.id, [...projectIds]));
|
|
129009
129084
|
for (const p3 of projectRows) projectsById.set(p3.id, p3.name);
|
|
129010
129085
|
}
|
|
129011
|
-
const projectOf = (r6) =>
|
|
129086
|
+
const projectOf = (r6) => {
|
|
129087
|
+
const ticket = lookupResolvedTicket(ticketsByRef, r6.entity);
|
|
129088
|
+
return r6.entity.projectId ?? ticket?.projectId ?? null;
|
|
129089
|
+
};
|
|
129090
|
+
const canonicalTicketId = (r6) => lookupResolvedTicket(ticketsByRef, r6.entity)?.id ?? r6.entity.ticketId ?? r6.entity.ticketNumber ?? null;
|
|
129012
129091
|
const byAction = {};
|
|
129013
129092
|
const byToolMap = /* @__PURE__ */ new Map();
|
|
129014
129093
|
const byTicketMap = /* @__PURE__ */ new Map();
|
|
@@ -129036,11 +129115,9 @@ async function handleGetRefrontMcpActivity(input) {
|
|
|
129036
129115
|
tool2.durationSamples += 1;
|
|
129037
129116
|
}
|
|
129038
129117
|
byToolMap.set(r6.toolName, tool2);
|
|
129039
|
-
if (r6
|
|
129040
|
-
|
|
129041
|
-
|
|
129042
|
-
(byTicketMap.get(r6.entity.ticketId) ?? 0) + 1
|
|
129043
|
-
);
|
|
129118
|
+
if (canonicalTicketId(r6)) {
|
|
129119
|
+
const key = canonicalTicketId(r6);
|
|
129120
|
+
byTicketMap.set(key, (byTicketMap.get(key) ?? 0) + 1);
|
|
129044
129121
|
}
|
|
129045
129122
|
const projectId = projectOf(r6);
|
|
129046
129123
|
if (projectId) {
|
|
@@ -129053,12 +129130,15 @@ async function handleGetRefrontMcpActivity(input) {
|
|
|
129053
129130
|
failures: v2.failures,
|
|
129054
129131
|
avgDurationMs: v2.durationSamples > 0 ? Math.round(v2.durationMsTotal / v2.durationSamples) : null
|
|
129055
129132
|
})).sort((a6, b7) => b7.count - a6.count).slice(0, TOP_ENTITIES);
|
|
129056
|
-
const byTicket = [...byTicketMap.entries()].map(([ticketId, count2]) =>
|
|
129057
|
-
ticketId
|
|
129058
|
-
|
|
129059
|
-
|
|
129060
|
-
|
|
129061
|
-
|
|
129133
|
+
const byTicket = [...byTicketMap.entries()].map(([ticketId, count2]) => {
|
|
129134
|
+
const ticket = ticketsByRef.get(ticketId) ?? ticketsByRef.get(ticketId.toLowerCase());
|
|
129135
|
+
return {
|
|
129136
|
+
ticketId: ticket?.id ?? ticketId,
|
|
129137
|
+
ticketNumber: ticket?.ticketNumber ?? null,
|
|
129138
|
+
ticketTitle: ticket?.title ?? null,
|
|
129139
|
+
count: count2
|
|
129140
|
+
};
|
|
129141
|
+
}).sort((a6, b7) => b7.count - a6.count).slice(0, TOP_ENTITIES);
|
|
129062
129142
|
const byProject = [...byProjectMap.entries()].map(([projectId, count2]) => ({
|
|
129063
129143
|
projectId,
|
|
129064
129144
|
projectName: projectsById.get(projectId) ?? null,
|
|
@@ -129070,6 +129150,9 @@ async function handleGetRefrontMcpActivity(input) {
|
|
|
129070
129150
|
);
|
|
129071
129151
|
const timeline = rows.slice(0, pageSize).map((r6) => {
|
|
129072
129152
|
const projectId = projectOf(r6);
|
|
129153
|
+
const ticket = lookupResolvedTicket(ticketsByRef, r6.entity);
|
|
129154
|
+
const ticketId = ticket?.id ?? r6.entity.ticketId ?? null;
|
|
129155
|
+
const ticketNumber = ticket?.ticketNumber ?? r6.entity.ticketNumber ?? null;
|
|
129073
129156
|
return {
|
|
129074
129157
|
timestamp: formatIsoWithOffset(new Date(r6.tsUtc), timezone),
|
|
129075
129158
|
timestampUtc: r6.tsUtc,
|
|
@@ -129078,8 +129161,8 @@ async function handleGetRefrontMcpActivity(input) {
|
|
|
129078
129161
|
success: r6.success,
|
|
129079
129162
|
durationMs: r6.durationMs,
|
|
129080
129163
|
actor: { id: r6.userId, name: r6.userId ? usersById.get(r6.userId) ?? null : null },
|
|
129081
|
-
ticketId
|
|
129082
|
-
ticketNumber
|
|
129164
|
+
ticketId,
|
|
129165
|
+
ticketNumber,
|
|
129083
129166
|
project: projectId ? { id: projectId, name: projectsById.get(projectId) ?? null } : null,
|
|
129084
129167
|
entity: r6.entity,
|
|
129085
129168
|
...r6.error ? { error: r6.error } : {}
|
|
@@ -129409,7 +129492,7 @@ var DEFAULT_PAGE_SIZE4 = 200;
|
|
|
129409
129492
|
var MAX_PAGE_SIZE4 = 500;
|
|
129410
129493
|
var MAX_TIMELINE_SOURCE = 2e3;
|
|
129411
129494
|
var COMMENT_PREVIEW_LENGTH2 = 140;
|
|
129412
|
-
var
|
|
129495
|
+
var UUID_RE3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
129413
129496
|
var STATUS_TRANSITION_TYPES = /* @__PURE__ */ new Set(["status_changed", "status_change"]);
|
|
129414
129497
|
var DISCLAIMER3 = "Cycle-time and interaction signals are supporting context, not an exact measure of worked time. Time-in-status includes nights/weekends and idle waiting; interpret with ticket complexity, blockers, reviews and dependencies.";
|
|
129415
129498
|
function textResponse17(text3) {
|
|
@@ -129449,9 +129532,9 @@ async function handleGetTicketInteractionTimeline(input) {
|
|
|
129449
129532
|
if (scope.teamIds.length === 0) {
|
|
129450
129533
|
return textResponse17("No accessible teams found.");
|
|
129451
129534
|
}
|
|
129452
|
-
const
|
|
129535
|
+
const isUuid3 = UUID_RE3.test(rawTicket);
|
|
129453
129536
|
const idBranches = [eq(schema_exports.tickets.ticketNumber, rawTicket)];
|
|
129454
|
-
if (
|
|
129537
|
+
if (isUuid3) idBranches.push(eq(schema_exports.tickets.id, rawTicket));
|
|
129455
129538
|
const [ticket] = await db.select({
|
|
129456
129539
|
id: schema_exports.tickets.id,
|
|
129457
129540
|
teamId: schema_exports.tickets.teamId,
|