@burdenoff/microfe-bigconsole 2026.1117.3 → 2026.1118.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/bigconsole/components/reconcile/reconcileAgentTool.d.ts +139 -0
- package/dist/bigconsole/components/reconcile/reconcileAgentTool.js +135 -0
- package/dist/bigconsole/components/reconcile/reconcileModel.d.ts +18 -3
- package/dist/bigconsole/components/reconcile/reconcileModel.js +69 -61
- package/dist/bigconsole/components/reconcile/useReconcileAgentTool.d.ts +10 -0
- package/dist/bigconsole/components/reconcile/useReconcileAgentTool.js +136 -0
- package/dist/bigconsole/pages/DashboardViewPage.js +231 -230
- package/dist/bigconsole/proactive/actions.js +10 -10
- package/dist/node_modules/zod/v4/classic/schemas.js +301 -229
- package/dist/node_modules/zod/v4/core/api.js +168 -106
- package/dist/node_modules/zod/v4/core/checks.js +145 -43
- package/dist/node_modules/zod/v4/core/json-schema-processors.js +36 -26
- package/dist/node_modules/zod/v4/core/regexes.js +2 -2
- package/dist/node_modules/zod/v4/core/schemas.js +172 -154
- package/dist/node_modules/zod/v4/core/util.js +94 -90
- package/package.json +4 -4
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AnyDefinedAgentTool } from '@burdenoff/fe-libs/shared/agent-tools';
|
|
3
|
+
/** The tool's name. Also the string the assistant's note points at. */
|
|
4
|
+
export declare const RECONCILE_TOOL_NAME = "bc_reconcile_kpi_cards";
|
|
5
|
+
/** The adjustment groups the server can report, in the order it reports them. */
|
|
6
|
+
export declare const RECONCILE_GROUPS: readonly ["REFUND", "CUTOFF_TIMING", "UNEXPLAINED", "MATCHED"];
|
|
7
|
+
export type ReconcileGroup = (typeof RECONCILE_GROUPS)[number];
|
|
8
|
+
/**
|
|
9
|
+
* How many records one call asks for when the caller does not say.
|
|
10
|
+
*
|
|
11
|
+
* ★ The agent's context is the real limit, not the server's page size: fe-libs
|
|
12
|
+
* caps a tool result at `AGENT_TOOL_OUTPUT_MAX_BYTES`, and a record with a
|
|
13
|
+
* reason costs roughly a hundred bytes. Asking for a sensible page and letting
|
|
14
|
+
* the answer say how much of it was delivered keeps the continuation honest.
|
|
15
|
+
*/
|
|
16
|
+
export declare const RECONCILE_DEFAULT_PAGE_SIZE = 10;
|
|
17
|
+
/** The most records one call may ask for. */
|
|
18
|
+
export declare const RECONCILE_MAX_PAGE_SIZE = 100;
|
|
19
|
+
declare const reconcileInput: z.ZodObject<{
|
|
20
|
+
left: z.ZodObject<{
|
|
21
|
+
widgetId: z.ZodString;
|
|
22
|
+
keyField: z.ZodString;
|
|
23
|
+
amountField: z.ZodString;
|
|
24
|
+
dateField: z.ZodString;
|
|
25
|
+
currency: z.ZodString;
|
|
26
|
+
refundEvidenceField: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
|
+
recordsPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
right: z.ZodObject<{
|
|
30
|
+
widgetId: z.ZodString;
|
|
31
|
+
keyField: z.ZodString;
|
|
32
|
+
amountField: z.ZodString;
|
|
33
|
+
dateField: z.ZodString;
|
|
34
|
+
currency: z.ZodString;
|
|
35
|
+
refundEvidenceField: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
36
|
+
recordsPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
37
|
+
}, z.core.$strict>;
|
|
38
|
+
periodStart: z.ZodString;
|
|
39
|
+
periodEnd: z.ZodString;
|
|
40
|
+
timezone: z.ZodString;
|
|
41
|
+
cutoffWindowDays: z.ZodNumber;
|
|
42
|
+
group: z.ZodOptional<z.ZodEnum<{
|
|
43
|
+
CUTOFF_TIMING: "CUTOFF_TIMING";
|
|
44
|
+
MATCHED: "MATCHED";
|
|
45
|
+
REFUND: "REFUND";
|
|
46
|
+
UNEXPLAINED: "UNEXPLAINED";
|
|
47
|
+
}>>;
|
|
48
|
+
first: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
50
|
+
}, z.core.$strict>;
|
|
51
|
+
export type ReconcileToolInput = z.output<typeof reconcileInput>;
|
|
52
|
+
/** One supporting record, in the compact shape an agent can afford. */
|
|
53
|
+
export interface ReconcileToolItem {
|
|
54
|
+
key: string | null;
|
|
55
|
+
/** The match status the server gave the record. */
|
|
56
|
+
status: string;
|
|
57
|
+
/** The record's signed contribution, as the page shows it. */
|
|
58
|
+
amount: string | null;
|
|
59
|
+
/**
|
|
60
|
+
* The reason the SERVER attributed to the record, or null when it
|
|
61
|
+
* established none. The agent must not invent one.
|
|
62
|
+
*/
|
|
63
|
+
why: string | null;
|
|
64
|
+
}
|
|
65
|
+
/** What the items query answered. */
|
|
66
|
+
export interface ReconcileToolItemsPage {
|
|
67
|
+
/** 'OK', 'RESTRICTED' or 'UNSUPPORTED'. */
|
|
68
|
+
status: string;
|
|
69
|
+
problems: {
|
|
70
|
+
code: string;
|
|
71
|
+
side: string | null;
|
|
72
|
+
message: string;
|
|
73
|
+
}[];
|
|
74
|
+
group: string | null;
|
|
75
|
+
totalCount: number;
|
|
76
|
+
offset: number;
|
|
77
|
+
hasMore: boolean;
|
|
78
|
+
items: ReconcileToolItem[];
|
|
79
|
+
}
|
|
80
|
+
/** What the tool reports back for the summary. */
|
|
81
|
+
export interface ReconcileToolSummary {
|
|
82
|
+
status: string;
|
|
83
|
+
direction: string;
|
|
84
|
+
currency: string | null;
|
|
85
|
+
period: {
|
|
86
|
+
start: string;
|
|
87
|
+
end: string;
|
|
88
|
+
timezone: string;
|
|
89
|
+
} | null;
|
|
90
|
+
left: {
|
|
91
|
+
title: string | null;
|
|
92
|
+
total: string | null;
|
|
93
|
+
records: number | null;
|
|
94
|
+
tiesToCard: boolean | null;
|
|
95
|
+
} | null;
|
|
96
|
+
right: {
|
|
97
|
+
title: string | null;
|
|
98
|
+
total: string | null;
|
|
99
|
+
records: number | null;
|
|
100
|
+
tiesToCard: boolean | null;
|
|
101
|
+
} | null;
|
|
102
|
+
gap: string | null;
|
|
103
|
+
explained: string | null;
|
|
104
|
+
unexplained: string | null;
|
|
105
|
+
groups: {
|
|
106
|
+
group: string;
|
|
107
|
+
label: string;
|
|
108
|
+
/** The group's total, as the page shows it. */
|
|
109
|
+
total: string | null;
|
|
110
|
+
/** The group's total in minor units, so a zero group can be told from a missing one. */
|
|
111
|
+
amount: string | null;
|
|
112
|
+
items: number;
|
|
113
|
+
}[];
|
|
114
|
+
problems: {
|
|
115
|
+
code: string;
|
|
116
|
+
side: string | null;
|
|
117
|
+
message: string;
|
|
118
|
+
}[];
|
|
119
|
+
limitations: string[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* What the tool needs from the page: the two GraphQL calls the dialog already
|
|
123
|
+
* makes, and the person's own session (the Apollo client carries it).
|
|
124
|
+
*/
|
|
125
|
+
export interface ReconcileToolDeps {
|
|
126
|
+
/** Run the comparison. */
|
|
127
|
+
reconcile(input: ReconcileToolInput): Promise<ReconcileToolSummary>;
|
|
128
|
+
/** One page of a group's supporting records. */
|
|
129
|
+
items(input: ReconcileToolInput, group: ReconcileGroup, page: {
|
|
130
|
+
first: number;
|
|
131
|
+
offset: number;
|
|
132
|
+
}): Promise<ReconcileToolItemsPage>;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Build the tool. The definition is checked once, when this runs, so a broken
|
|
136
|
+
* schema fails the page load rather than an agent's call.
|
|
137
|
+
*/
|
|
138
|
+
export declare function createReconcileAgentTool(getDeps: () => ReconcileToolDeps): AnyDefinedAgentTool;
|
|
139
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { enum as e, number as t, strictObject as n, string as r } from "../../../node_modules/zod/v4/classic/schemas.js";
|
|
2
|
+
import { AGENT_TOOL_OUTPUT_MAX_BYTES as i, AgentToolError as a, defineAgentTool as o, jsonByteLength as s } from "@burdenoff/fe-libs/shared/agent-tools";
|
|
3
|
+
// src/bigconsole/components/reconcile/reconcileAgentTool.ts
|
|
4
|
+
var c = "bc_reconcile_kpi_cards", l = [
|
|
5
|
+
"REFUND",
|
|
6
|
+
"CUTOFF_TIMING",
|
|
7
|
+
"UNEXPLAINED",
|
|
8
|
+
"MATCHED"
|
|
9
|
+
], u = n({
|
|
10
|
+
widgetId: r().min(1).max(120).describe("The id of the KPI card on this side."),
|
|
11
|
+
keyField: r().min(1).max(120).describe("The record field both sides are matched on, e.g. orderId."),
|
|
12
|
+
amountField: r().min(1).max(120).describe("The record field holding the amount, e.g. amount or netAmount."),
|
|
13
|
+
dateField: r().min(1).max(120).describe("The record field holding the date, e.g. orderDate or postingDate."),
|
|
14
|
+
currency: r().length(3).describe("The three-letter currency both cards are in, e.g. INR."),
|
|
15
|
+
refundEvidenceField: r().max(120).nullish().describe("The field holding a linked refund amount, when the card has one. Null or omitted when it has none."),
|
|
16
|
+
recordsPath: r().max(120).nullish().describe("The path to the records inside the card. Null or omitted when they sit at the root.")
|
|
17
|
+
}).describe("One card of the comparison and how its records are read."), d = n({
|
|
18
|
+
left: u.describe("The card subtracted FROM."),
|
|
19
|
+
right: u.describe("The card subtracted."),
|
|
20
|
+
periodStart: r().regex(/^\d{4}-\d{2}-\d{2}$/).describe("First day of the period, YYYY-MM-DD, inclusive."),
|
|
21
|
+
periodEnd: r().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Last day of the period, YYYY-MM-DD, inclusive."),
|
|
22
|
+
timezone: r().min(1).max(80).describe("The IANA timezone the period and record dates are read in, e.g. UTC."),
|
|
23
|
+
cutoffWindowDays: t().int().min(0).max(31).describe("Days after the period end a matching record may be posted in, 0 turns the rule off."),
|
|
24
|
+
group: e(l).optional().describe("Return the supporting records of this adjustment group instead of the summary."),
|
|
25
|
+
first: t().int().min(1).max(100).optional().describe("How many supporting records to ask for, 1 to 100."),
|
|
26
|
+
offset: t().int().min(0).optional().describe("Which supporting record to start at. Use nextOffset from the previous answer to continue.")
|
|
27
|
+
}).describe("The comparison to run, as the page confirmed it."), f = "Compare two KPI cards for one period and explain the difference between them. Use it when the user asks why two cards differ, what explains the gap, or which orders are behind it; the picked comparison gives this tool's parameters. Answer only from this tool's result: the server's totals, the signed difference, the groups and the supporting records. Never recompute totals or invent causes. Call it again with \"group\" for a group's records, and with \"nextOffset\" when the list is partial.";
|
|
28
|
+
function p(e) {
|
|
29
|
+
return {
|
|
30
|
+
first: Math.min(100, Math.max(1, e.first ?? 10)),
|
|
31
|
+
offset: Math.max(0, e.offset ?? 0)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
var m = 3, h = 120, g = 200;
|
|
35
|
+
function _(e) {
|
|
36
|
+
let t = (e, t) => e === null ? null : e.length > t ? `${e.slice(0, t - 1)}…` : e;
|
|
37
|
+
return {
|
|
38
|
+
key: t(e.key, h),
|
|
39
|
+
status: e.status,
|
|
40
|
+
amount: t(e.amount, 60),
|
|
41
|
+
why: t(e.why, g)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function v(e, t) {
|
|
45
|
+
let n = t.map((e) => `${e.code}: ${String(e.message ?? "").replace(/[\p{Cc}\u2028\u2029]/gu, " ").trim()}`).filter((e) => e.trim().length > 0).join(" ") || y(e);
|
|
46
|
+
return n.length > 300 ? `${n.slice(0, 299)}…` : n;
|
|
47
|
+
}
|
|
48
|
+
function y(e) {
|
|
49
|
+
return e === "RESTRICTED" ? "You cannot see the records for this comparison." : e === "UNSUPPORTED" ? "These cards cannot be reconciled." : "The comparison could not be completed.";
|
|
50
|
+
}
|
|
51
|
+
function b(e, t) {
|
|
52
|
+
if (e !== "OK") throw new a(e === "RESTRICTED" ? "FORBIDDEN" : "INVALID_INPUT", v(e, t), { retryable: !1 });
|
|
53
|
+
}
|
|
54
|
+
function x(e) {
|
|
55
|
+
let t = {
|
|
56
|
+
group: e.group,
|
|
57
|
+
totalCount: e.totalCount,
|
|
58
|
+
offset: e.offset,
|
|
59
|
+
delivered: e.items.length,
|
|
60
|
+
nextOffset: e.offset + e.items.length,
|
|
61
|
+
hasMore: e.offset + e.items.length < e.totalCount,
|
|
62
|
+
partial: e.offset + e.items.length < e.totalCount,
|
|
63
|
+
items: e.items.map(_)
|
|
64
|
+
};
|
|
65
|
+
for (; t.items.length > 0 && s(t) > i;) t.items = t.items.slice(0, -1), t.delivered = t.items.length, t.nextOffset = t.offset + t.delivered, t.hasMore = t.nextOffset < t.totalCount, t.partial = t.nextOffset < t.totalCount;
|
|
66
|
+
if (t.items.length === 0 && t.hasMore) throw new a("FAILED", "A supporting record is too large to return. Ask for the group with a smaller \"first\".", { retryable: !1 });
|
|
67
|
+
return t;
|
|
68
|
+
}
|
|
69
|
+
function S(e, t, n) {
|
|
70
|
+
return {
|
|
71
|
+
status: e.status,
|
|
72
|
+
direction: e.direction,
|
|
73
|
+
currency: e.currency,
|
|
74
|
+
period: e.period,
|
|
75
|
+
left: e.left,
|
|
76
|
+
right: e.right,
|
|
77
|
+
gap: e.gap,
|
|
78
|
+
explained: e.explained,
|
|
79
|
+
unexplained: e.unexplained,
|
|
80
|
+
groups: e.groups,
|
|
81
|
+
adjustments: t,
|
|
82
|
+
partialGroups: n,
|
|
83
|
+
limitations: e.limitations,
|
|
84
|
+
problems: e.problems
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function C(e) {
|
|
88
|
+
return o({
|
|
89
|
+
name: c,
|
|
90
|
+
title: "Reconcile two KPI cards",
|
|
91
|
+
description: f,
|
|
92
|
+
input: d,
|
|
93
|
+
annotations: {
|
|
94
|
+
readOnly: !0,
|
|
95
|
+
untrustedContent: !0
|
|
96
|
+
},
|
|
97
|
+
async execute(t) {
|
|
98
|
+
let n = e(), r = p(t);
|
|
99
|
+
if (t.group) {
|
|
100
|
+
let e = await n.items(t, t.group, r);
|
|
101
|
+
return b(e.status, e.problems), x(e);
|
|
102
|
+
}
|
|
103
|
+
let a = await n.reconcile(t);
|
|
104
|
+
b(a.status, a.problems);
|
|
105
|
+
let o = [], c = [];
|
|
106
|
+
for (let e of a.groups) {
|
|
107
|
+
if (!e.amount || e.amount === "0.00" || e.items === 0) continue;
|
|
108
|
+
let i = await n.items(t, e.group, {
|
|
109
|
+
first: Math.min(r.first, m),
|
|
110
|
+
offset: 0
|
|
111
|
+
});
|
|
112
|
+
b(i.status, i.problems), c.push({
|
|
113
|
+
group: e.group,
|
|
114
|
+
delivered: i.items.length,
|
|
115
|
+
totalCount: i.totalCount
|
|
116
|
+
});
|
|
117
|
+
for (let t of i.items) o.push({
|
|
118
|
+
group: e.group,
|
|
119
|
+
..._(t)
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
let l = () => c.filter((e) => e.delivered < e.totalCount).map((e) => ({
|
|
123
|
+
group: e.group,
|
|
124
|
+
nextOffset: e.delivered,
|
|
125
|
+
totalCount: e.totalCount
|
|
126
|
+
})), u = S(a, o, l());
|
|
127
|
+
for (; o.length > 0 && s(u) > i;) {
|
|
128
|
+
let e = o.pop(), t = e ? c.find((t) => t.group === e.group) : void 0;
|
|
129
|
+
t && (t.delivered = Math.max(0, t.delivered - 1)), u.adjustments = o, u.partialGroups = l();
|
|
130
|
+
}
|
|
131
|
+
return u;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
export { l as RECONCILE_GROUPS, c as RECONCILE_TOOL_NAME, C as createReconcileAgentTool };
|
|
@@ -90,9 +90,24 @@ export declare function loadSavedSide(widgetId: string, otherWidgetId: string, s
|
|
|
90
90
|
cutoffWindowDays: number;
|
|
91
91
|
} | null;
|
|
92
92
|
/**
|
|
93
|
-
* The note the assistant receives.
|
|
94
|
-
*
|
|
95
|
-
*
|
|
93
|
+
* The note the assistant receives.
|
|
94
|
+
*
|
|
95
|
+
* ★★ It carries DATA, never instructions — and that is the whole point.
|
|
96
|
+
*
|
|
97
|
+
* The note used to open with "How to answer: Run the read-only BigConsole query
|
|
98
|
+
* reconcileKpiCards(input) …". Two things were wrong with it. It was an
|
|
99
|
+
* instruction in the page-data channel, where the assistant is right to treat
|
|
100
|
+
* what it reads as data rather than as orders — so it refused to follow it. And
|
|
101
|
+
* it named a raw GraphQL operation the assistant's own operations catalogue does
|
|
102
|
+
* not list, so the assistant looked it up, did not find it, and told the person
|
|
103
|
+
* the feature did not exist.
|
|
104
|
+
*
|
|
105
|
+
* What it carries now is the comparison itself, under the SAME names the
|
|
106
|
+
* reconciliation tool's parameters have, plus the name of that tool. The tool
|
|
107
|
+
* is advertised to the assistant in the turn's `clientTools` manifest, which is
|
|
108
|
+
* the product's own trusted channel: the agent calls it, the page runs it with
|
|
109
|
+
* the person's session, and the answer comes from the server's result rather
|
|
110
|
+
* than from the agent recomputing totals out of raw rows.
|
|
96
111
|
*/
|
|
97
112
|
export declare function assistantFocus(input: ReconcileInputVars, labels: {
|
|
98
113
|
left: string;
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
+
import { RECONCILE_TOOL_NAME as e } from "./reconcileAgentTool.js";
|
|
1
2
|
// src/bigconsole/components/reconcile/reconcileModel.ts
|
|
2
|
-
function
|
|
3
|
+
function t(e, t) {
|
|
3
4
|
return !t && (e === "metric_card" || e === "kpi_card_comparison");
|
|
4
5
|
}
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
-
let
|
|
8
|
-
if (!
|
|
9
|
-
let r = Number(
|
|
6
|
+
var n = /^(\d{4})-(0[1-9]|1[0-2])$/;
|
|
7
|
+
function r(e) {
|
|
8
|
+
let t = n.exec(e);
|
|
9
|
+
if (!t) return null;
|
|
10
|
+
let r = Number(t[1]), i = Number(t[2]), a = new Date(Date.UTC(r, i, 0)).getUTCDate();
|
|
10
11
|
return {
|
|
11
|
-
start: `${
|
|
12
|
-
end: `${
|
|
12
|
+
start: `${t[1]}-${t[2]}-01`,
|
|
13
|
+
end: `${t[1]}-${t[2]}-${String(a).padStart(2, "0")}`
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
+
function i(e) {
|
|
16
17
|
let t = new Date(Date.UTC(e.getUTCFullYear(), e.getUTCMonth() - 1, 1));
|
|
17
18
|
return `${t.getUTCFullYear()}-${String(t.getUTCMonth() + 1).padStart(2, "0")}`;
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function a() {
|
|
20
21
|
try {
|
|
21
22
|
return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
|
22
23
|
} catch {
|
|
23
24
|
return "UTC";
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
+
function o(e) {
|
|
27
28
|
let t = typeof e?.prefix == "string" ? e.prefix.trim() : "", n = {
|
|
28
29
|
"₹": "INR",
|
|
29
30
|
$: "USD",
|
|
@@ -33,7 +34,7 @@ function a(e) {
|
|
|
33
34
|
};
|
|
34
35
|
return n[t] ? n[t] : /^[A-Za-z]{3}$/.test(t) ? t.toUpperCase() : "";
|
|
35
36
|
}
|
|
36
|
-
var
|
|
37
|
+
var s = [
|
|
37
38
|
"orderid",
|
|
38
39
|
"orderno",
|
|
39
40
|
"ordernumber",
|
|
@@ -43,7 +44,7 @@ var o = [
|
|
|
43
44
|
"key",
|
|
44
45
|
"reference",
|
|
45
46
|
"ref"
|
|
46
|
-
],
|
|
47
|
+
], c = [
|
|
47
48
|
"amount",
|
|
48
49
|
"netamount",
|
|
49
50
|
"revenue",
|
|
@@ -51,50 +52,50 @@ var o = [
|
|
|
51
52
|
"value",
|
|
52
53
|
"sales",
|
|
53
54
|
"gross"
|
|
54
|
-
],
|
|
55
|
+
], l = [
|
|
55
56
|
"postingdate",
|
|
56
57
|
"orderdate",
|
|
57
58
|
"date",
|
|
58
59
|
"createdat",
|
|
59
60
|
"bookedat",
|
|
60
61
|
"timestamp"
|
|
61
|
-
],
|
|
62
|
+
], u = [
|
|
62
63
|
"refundamount",
|
|
63
64
|
"refund",
|
|
64
65
|
"linkedrefund",
|
|
65
66
|
"refunded"
|
|
66
67
|
];
|
|
67
|
-
function
|
|
68
|
+
function d(e, t) {
|
|
68
69
|
let n = e.toLowerCase().replace(/[^a-z0-9]/g, ""), r = n.split(".").pop() ?? n, i = t.indexOf(r);
|
|
69
70
|
if (i >= 0) return i;
|
|
70
71
|
let a = t.findIndex((e) => r.includes(e));
|
|
71
72
|
return a >= 0 ? t.length + a : Infinity;
|
|
72
73
|
}
|
|
73
|
-
function
|
|
74
|
+
function f(e, t, n) {
|
|
74
75
|
return e.filter((e) => !e.restricted && n.includes(e.kind)).map((e) => ({
|
|
75
76
|
f: e,
|
|
76
|
-
r:
|
|
77
|
+
r: d(e.name, t)
|
|
77
78
|
})).filter((e) => Number.isFinite(e.r)).sort((e, t) => e.r - t.r || e.f.name.localeCompare(t.f.name))[0]?.f.name ?? "";
|
|
78
79
|
}
|
|
79
|
-
function
|
|
80
|
+
function p(e) {
|
|
80
81
|
return {
|
|
81
|
-
keyField:
|
|
82
|
+
keyField: f(e, s, [
|
|
82
83
|
"STRING",
|
|
83
84
|
"NUMBER",
|
|
84
85
|
"MIXED"
|
|
85
86
|
]),
|
|
86
|
-
amountField:
|
|
87
|
-
dateField:
|
|
87
|
+
amountField: f(e, c, ["NUMBER", "MIXED"]),
|
|
88
|
+
dateField: f(e, l, [
|
|
88
89
|
"DATE",
|
|
89
90
|
"STRING",
|
|
90
91
|
"NUMBER"
|
|
91
92
|
]),
|
|
92
|
-
refundEvidenceField:
|
|
93
|
+
refundEvidenceField: f(e, u, ["NUMBER", "MIXED"])
|
|
93
94
|
};
|
|
94
95
|
}
|
|
95
|
-
function
|
|
96
|
+
function m(e, t) {
|
|
96
97
|
if (e.mappingSettled || t.length === 0) return null;
|
|
97
|
-
let n =
|
|
98
|
+
let n = p(t);
|
|
98
99
|
return {
|
|
99
100
|
...e,
|
|
100
101
|
keyField: e.keyField || n.keyField,
|
|
@@ -104,24 +105,24 @@ function p(e, t) {
|
|
|
104
105
|
mappingSettled: !0
|
|
105
106
|
};
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
+
function h(e, t) {
|
|
108
109
|
return {
|
|
109
110
|
...e,
|
|
110
111
|
title: t,
|
|
111
112
|
mappingSettled: !0
|
|
112
113
|
};
|
|
113
114
|
}
|
|
114
|
-
function
|
|
115
|
+
function g(e) {
|
|
115
116
|
if (!e.left.widgetId || !e.right.widgetId) return "Choose a card to compare with.";
|
|
116
117
|
if (e.left.widgetId === e.right.widgetId) return "Choose two different cards.";
|
|
117
|
-
if (!
|
|
118
|
+
if (!r(e.month)) return "Choose a month.";
|
|
118
119
|
for (let t of [e.left, e.right]) {
|
|
119
120
|
if (!t.keyField || !t.amountField || !t.dateField) return `Confirm the key, amount and date fields for “${t.title}”.`;
|
|
120
121
|
if (!/^[A-Za-z]{3}$/.test(t.currency.trim())) return `Enter the currency of “${t.title}”, e.g. INR.`;
|
|
121
122
|
}
|
|
122
123
|
return null;
|
|
123
124
|
}
|
|
124
|
-
function
|
|
125
|
+
function _(e) {
|
|
125
126
|
return {
|
|
126
127
|
widgetId: e.widgetId,
|
|
127
128
|
keyField: e.keyField.trim(),
|
|
@@ -132,42 +133,42 @@ function g(e) {
|
|
|
132
133
|
recordsPath: e.recordsPath.trim() || null
|
|
133
134
|
};
|
|
134
135
|
}
|
|
135
|
-
function
|
|
136
|
-
let t =
|
|
137
|
-
return !t ||
|
|
138
|
-
left:
|
|
139
|
-
right:
|
|
136
|
+
function v(e) {
|
|
137
|
+
let t = r(e.month);
|
|
138
|
+
return !t || g(e) ? null : {
|
|
139
|
+
left: _(e.left),
|
|
140
|
+
right: _(e.right),
|
|
140
141
|
periodStart: t.start,
|
|
141
142
|
periodEnd: t.end,
|
|
142
143
|
timezone: e.timezone,
|
|
143
144
|
cutoffWindowDays: Math.max(0, Math.min(31, Math.floor(e.cutoffWindowDays) || 0))
|
|
144
145
|
};
|
|
145
146
|
}
|
|
146
|
-
function
|
|
147
|
+
function y(e) {
|
|
147
148
|
return {
|
|
148
149
|
...e,
|
|
149
150
|
left: e.right,
|
|
150
151
|
right: e.left
|
|
151
152
|
};
|
|
152
153
|
}
|
|
153
|
-
var
|
|
154
|
-
function b(e, t) {
|
|
155
|
-
return y + [e, t].sort((e, t) => e.localeCompare(t)).join("|");
|
|
156
|
-
}
|
|
154
|
+
var b = "bc-reconcile-v1:";
|
|
157
155
|
function x(e, t) {
|
|
156
|
+
return b + [e, t].sort((e, t) => e.localeCompare(t)).join("|");
|
|
157
|
+
}
|
|
158
|
+
function S(e, t) {
|
|
158
159
|
if (!t || !e.left.widgetId || !e.right.widgetId) return;
|
|
159
160
|
let n = ({ title: e, mappingSettled: t, ...n }) => n;
|
|
160
161
|
try {
|
|
161
|
-
t.setItem(
|
|
162
|
+
t.setItem(x(e.left.widgetId, e.right.widgetId), JSON.stringify({
|
|
162
163
|
sides: [n(e.left), n(e.right)],
|
|
163
164
|
cutoffWindowDays: e.cutoffWindowDays
|
|
164
165
|
}));
|
|
165
166
|
} catch {}
|
|
166
167
|
}
|
|
167
|
-
function
|
|
168
|
+
function C(e, t, n) {
|
|
168
169
|
if (!n) return null;
|
|
169
170
|
try {
|
|
170
|
-
let r = n.getItem(
|
|
171
|
+
let r = n.getItem(x(e, t));
|
|
171
172
|
if (!r) return null;
|
|
172
173
|
let i = JSON.parse(r), a = i.sides?.find((t) => t.widgetId === e);
|
|
173
174
|
return a ? {
|
|
@@ -178,38 +179,45 @@ function S(e, t, n) {
|
|
|
178
179
|
return null;
|
|
179
180
|
}
|
|
180
181
|
}
|
|
181
|
-
function
|
|
182
|
+
function w(e) {
|
|
182
183
|
return JSON.stringify(e);
|
|
183
184
|
}
|
|
184
|
-
function
|
|
185
|
+
function T(t, n, r) {
|
|
185
186
|
return {
|
|
186
187
|
kind: "KPI reconciliation",
|
|
187
|
-
label: `${
|
|
188
|
+
label: `${n.left} − ${n.right}`,
|
|
188
189
|
facts: [
|
|
189
190
|
{
|
|
190
|
-
label: "
|
|
191
|
-
value:
|
|
191
|
+
label: "Comparison tool",
|
|
192
|
+
value: e
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
label: "left",
|
|
196
|
+
value: w(t.left)
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
label: "right",
|
|
200
|
+
value: w(t.right)
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
label: "periodStart",
|
|
204
|
+
value: t.periodStart
|
|
192
205
|
},
|
|
193
206
|
{
|
|
194
|
-
label: "
|
|
195
|
-
value:
|
|
207
|
+
label: "periodEnd",
|
|
208
|
+
value: t.periodEnd
|
|
196
209
|
},
|
|
197
210
|
{
|
|
198
|
-
label: "
|
|
199
|
-
value:
|
|
211
|
+
label: "timezone",
|
|
212
|
+
value: t.timezone
|
|
200
213
|
},
|
|
201
214
|
{
|
|
202
|
-
label: "
|
|
203
|
-
value:
|
|
204
|
-
periodStart: e.periodStart,
|
|
205
|
-
periodEnd: e.periodEnd,
|
|
206
|
-
timezone: e.timezone,
|
|
207
|
-
cutoffWindowDays: e.cutoffWindowDays
|
|
208
|
-
})
|
|
215
|
+
label: "cutoffWindowDays",
|
|
216
|
+
value: String(t.cutoffWindowDays)
|
|
209
217
|
},
|
|
210
|
-
...
|
|
218
|
+
...r ? [{
|
|
211
219
|
label: "Gap shown on screen",
|
|
212
|
-
value:
|
|
220
|
+
value: r
|
|
213
221
|
}] : []
|
|
214
222
|
],
|
|
215
223
|
suggestions: [
|
|
@@ -219,4 +227,4 @@ function w(e, t, n) {
|
|
|
219
227
|
]
|
|
220
228
|
};
|
|
221
229
|
}
|
|
222
|
-
export {
|
|
230
|
+
export { m as applySuggestions, T as assistantFocus, a as browserTimezone, v as buildInput, t as canReconcileWidget, o as currencyFromConfig, p as guessMapping, C as loadSavedSide, g as missingForRun, r as monthPeriod, i as previousMonth, h as restoreSavedSide, S as saveDraft, y as swapSides };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RECONCILE_TOOL_NAME } from './reconcileAgentTool';
|
|
2
|
+
/**
|
|
3
|
+
* Offer the reconciliation to agents for as long as the caller is mounted.
|
|
4
|
+
*
|
|
5
|
+
* The Apollo client and the workspace are read through a ref, so the tool
|
|
6
|
+
* definition stays stable (one registration) and never acts on a stale client
|
|
7
|
+
* or workspace.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useReconcileAgentTool(): void;
|
|
10
|
+
export { RECONCILE_TOOL_NAME };
|