@deliverd/sdk 0.39.0 → 0.40.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.
@@ -30,4 +30,6 @@ export { deliverdAllow, deliverdWebMcpAllow, describeStep, uiSdkApprovalRoute, U
30
30
  export type { DeliverdAllowOptions, UiSdkApprovalAnswer, UiSdkApprovalRouteOptions, UiSdkAskContext, UiSdkStep } from "./ui-sdk.js";
31
31
  export { defaultDescription, DEFAULT_TOOL_EXPIRY } from "./shared.js";
32
32
  export type { Approver, CallDescription, CallOutcome, ToolApprovalOptions } from "./shared.js";
33
+ export { FINANCE_ACTIONS, FINANCE_ACTION_IDS, LEDGERS, LEDGER_LABEL, classifyLedgerRequest, classifyLedgerTool, financeActionLabel, maskAccount, } from "../ledgers.js";
34
+ export type { FinanceActionId, Ledger, LedgerCall, LedgerInput } from "../ledgers.js";
33
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,+BAA+B,EAC/B,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,4BAA4B,EAC5B,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CA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MAAM,aAAa,CAAC;AACpI,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACtE,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC/F,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,OAAO,EACP,YAAY,EACZ,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -18,3 +18,4 @@ export { runMuseFunctionCalls, runMuseToolCalls } from "./muse-spark.js";
18
18
  export { answerPerplexityApprovals, runPerplexityFunctionCalls, runPerplexityWithDeliverd, } from "./perplexity.js";
19
19
  export { deliverdAllow, deliverdWebMcpAllow, describeStep, uiSdkApprovalRoute, UI_SDK_DEFAULT_TIMEOUT } from "./ui-sdk.js";
20
20
  export { defaultDescription, DEFAULT_TOOL_EXPIRY } from "./shared.js";
21
+ export { FINANCE_ACTIONS, FINANCE_ACTION_IDS, LEDGERS, LEDGER_LABEL, classifyLedgerRequest, classifyLedgerTool, financeActionLabel, maskAccount, } from "../ledgers.js";
@@ -75,6 +75,72 @@ export declare const DATA_KINDS: {
75
75
  readonly placeholder: "SSN";
76
76
  readonly redactable: true;
77
77
  };
78
+ readonly us_itin: {
79
+ readonly label: "US ITIN";
80
+ readonly category: "personal";
81
+ readonly placeholder: "ITIN";
82
+ readonly redactable: true;
83
+ };
84
+ readonly ca_sin: {
85
+ readonly label: "Canadian Social Insurance number";
86
+ readonly category: "personal";
87
+ readonly placeholder: "SIN";
88
+ readonly redactable: true;
89
+ };
90
+ readonly fr_nir: {
91
+ readonly label: "French social security number";
92
+ readonly category: "personal";
93
+ readonly placeholder: "NIR";
94
+ readonly redactable: true;
95
+ };
96
+ readonly es_dni: {
97
+ readonly label: "Spanish DNI or NIE";
98
+ readonly category: "personal";
99
+ readonly placeholder: "DNI";
100
+ readonly redactable: true;
101
+ };
102
+ readonly it_fiscal_code: {
103
+ readonly label: "Italian fiscal code";
104
+ readonly category: "personal";
105
+ readonly placeholder: "CF";
106
+ readonly redactable: true;
107
+ };
108
+ readonly nl_bsn: {
109
+ readonly label: "Dutch BSN";
110
+ readonly category: "personal";
111
+ readonly placeholder: "BSN";
112
+ readonly redactable: true;
113
+ };
114
+ readonly pl_pesel: {
115
+ readonly label: "Polish PESEL number";
116
+ readonly category: "personal";
117
+ readonly placeholder: "PESEL";
118
+ readonly redactable: true;
119
+ };
120
+ readonly de_tax_id: {
121
+ readonly label: "German tax ID";
122
+ readonly category: "personal";
123
+ readonly placeholder: "STEUERID";
124
+ readonly redactable: true;
125
+ };
126
+ readonly passport: {
127
+ readonly label: "Passport number";
128
+ readonly category: "personal";
129
+ readonly placeholder: "PASSPORT";
130
+ readonly redactable: true;
131
+ };
132
+ readonly vat_number: {
133
+ readonly label: "VAT number";
134
+ readonly category: "financial";
135
+ readonly placeholder: "VAT";
136
+ readonly redactable: true;
137
+ };
138
+ readonly bank_account: {
139
+ readonly label: "Bank account number";
140
+ readonly category: "financial";
141
+ readonly placeholder: "ACCOUNT";
142
+ readonly redactable: true;
143
+ };
78
144
  readonly ip_address: {
79
145
  readonly label: "IP address";
80
146
  readonly category: "personal";
@@ -1 +1 @@
1
- {"version":3,"file":"data-screen.d.ts","sourceRoot":"","sources":["../src/data-screen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,+DAAgE,CAAC;AACpG,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3E,eAAO,MAAM,iBAAiB,yEAA0E,CAAC;AACzG,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,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G;IACrG,aAAa,EAAE,KAAK,GAAG,MAAM,CAAC;IAC9B,8FAA8F;IAC9F,YAAY,EAAE;QAAE,sBAAsB,EAAE,oBAAoB,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE,CAAC;CACvF;AAED,eAAO,MAAM,qBAAqB,EAAE,YAKnC,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,aAAa,CAAC;IACvB,qEAAqE;IACrE,cAAc,EAAE,oBAAoB,CAAC;IACrC,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,+FAA+F;IAC/F,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,iEAAiE;IACjE,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAMD,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAe3D;AAOD,2EAA2E;AAC3E,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAkB3D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,YAAY,GAAG,IAAI,EAC3B,MAAM,GAAE,YAAoC,EAC5C,kBAAkB,GAAE,oBAAqC,GACxD,gBAAgB,CAiDlB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,WAAW,CAAC,GAAG,SAAS,GAAG,IAAI,CAIzJ;AAED,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,oBAAoB,CAE7F"}
@@ -35,6 +35,17 @@ export const DATA_KINDS = {
35
35
  uk_national_insurance: { label: "UK National Insurance number", category: "personal", placeholder: "NINO", redactable: true },
36
36
  ie_pps: { label: "Irish PPS number", category: "personal", placeholder: "PPS", redactable: true },
37
37
  us_ssn: { label: "US Social Security number", category: "personal", placeholder: "SSN", redactable: true },
38
+ us_itin: { label: "US ITIN", category: "personal", placeholder: "ITIN", redactable: true },
39
+ ca_sin: { label: "Canadian Social Insurance number", category: "personal", placeholder: "SIN", redactable: true },
40
+ fr_nir: { label: "French social security number", category: "personal", placeholder: "NIR", redactable: true },
41
+ es_dni: { label: "Spanish DNI or NIE", category: "personal", placeholder: "DNI", redactable: true },
42
+ it_fiscal_code: { label: "Italian fiscal code", category: "personal", placeholder: "CF", redactable: true },
43
+ nl_bsn: { label: "Dutch BSN", category: "personal", placeholder: "BSN", redactable: true },
44
+ pl_pesel: { label: "Polish PESEL number", category: "personal", placeholder: "PESEL", redactable: true },
45
+ de_tax_id: { label: "German tax ID", category: "personal", placeholder: "STEUERID", redactable: true },
46
+ passport: { label: "Passport number", category: "personal", placeholder: "PASSPORT", redactable: true },
47
+ vat_number: { label: "VAT number", category: "financial", placeholder: "VAT", redactable: true },
48
+ bank_account: { label: "Bank account number", category: "financial", placeholder: "ACCOUNT", redactable: true },
38
49
  ip_address: { label: "IP address", category: "personal", placeholder: "IP", redactable: true },
39
50
  date_of_birth: { label: "Date of birth", category: "personal", placeholder: "DOB", redactable: true },
40
51
  /** Never found by a pattern here: only by a model detector the caller plugs in (`spans`). */
@@ -114,6 +125,99 @@ function ipv6Valid(raw) {
114
125
  const groups = raw.split(":").filter(Boolean).length;
115
126
  return compressed === 0 ? groups === 8 : compressed === 1 && groups >= 3 && groups <= 7;
116
127
  }
128
+ /** An ITIN: 9XX-XX-XXXX with a middle group the IRS issues (50-65, 70-88, 90-92, 94-99). */
129
+ function itinValid(raw) {
130
+ const g = Number(raw.slice(4, 6));
131
+ return (g >= 50 && g <= 65) || (g >= 70 && g <= 88) || (g >= 90 && g <= 92) || (g >= 94 && g <= 99);
132
+ }
133
+ /** A Canadian SIN: nine digits, Luhn-checked; none is issued starting with 0 or 8. */
134
+ function sinValid(raw) {
135
+ const d = digitsOf(raw);
136
+ return d.length === 9 && d[0] !== "0" && d[0] !== "8" && luhn(d);
137
+ }
138
+ /** An ABA routing number: weights 3, 7, 1 repeating, a multiple of 10. */
139
+ function abaValid(raw) {
140
+ const d = digitsOf(raw);
141
+ if (d.length !== 9 || /^0+$/.test(d))
142
+ return false;
143
+ let sum = 0;
144
+ for (let i = 0; i < 9; i++)
145
+ sum += (d.charCodeAt(i) - 48) * [3, 7, 1][i % 3];
146
+ return sum % 10 === 0;
147
+ }
148
+ /** A French NIR: thirteen digits (2A and 2B for Corsica) and a key, 97 minus the number mod 97. */
149
+ function nirValid(raw) {
150
+ const s = raw.replace(/ /g, "").toUpperCase();
151
+ if (s.length !== 15)
152
+ return false;
153
+ const body = s.slice(0, 13).replace("2A", "19").replace("2B", "18");
154
+ if (!/^\d{13}$/.test(body))
155
+ return false;
156
+ let mod = 0;
157
+ for (const ch of body)
158
+ mod = (mod * 10 + (ch.charCodeAt(0) - 48)) % 97;
159
+ return 97 - mod === Number(s.slice(13));
160
+ }
161
+ /** A Spanish DNI (eight digits) or NIE (X, Y or Z and seven), and its check letter. */
162
+ function dniValid(raw) {
163
+ const s = raw.replace("-", "").toUpperCase();
164
+ const n = Number(s.slice(0, -1).replace(/^X/, "0").replace(/^Y/, "1").replace(/^Z/, "2"));
165
+ return "TRWAGMYFPDXBNJZSQVHLCKE"[n % 23] === s.at(-1);
166
+ }
167
+ const CF_ODD = [1, 0, 5, 7, 9, 13, 15, 17, 19, 21, 2, 4, 18, 20, 11, 3, 6, 8, 12, 14, 16, 10, 22, 25, 24, 23];
168
+ /** An Italian codice fiscale and its check letter. */
169
+ function fiscalCodeValid(raw) {
170
+ const s = raw.toUpperCase();
171
+ let sum = 0;
172
+ for (let i = 0; i < 15; i++) {
173
+ const c = s.charCodeAt(i);
174
+ const v = c >= 65 ? c - 65 : c - 48;
175
+ sum += i % 2 === 0 ? CF_ODD[v] : v;
176
+ }
177
+ return String.fromCharCode(65 + (sum % 26)) === s[15];
178
+ }
179
+ /** A Dutch BSN: the eleven test, weights 9 to 2 and -1 on the last digit. */
180
+ function bsnValid(raw) {
181
+ const d = digitsOf(raw);
182
+ if (d.length !== 9 || /^0+$/.test(d))
183
+ return false;
184
+ let sum = 0;
185
+ for (let i = 0; i < 8; i++)
186
+ sum += (d.charCodeAt(i) - 48) * (9 - i);
187
+ return (sum - (d.charCodeAt(8) - 48)) % 11 === 0;
188
+ }
189
+ /** A Polish PESEL: weights 1, 3, 7, 9 repeating, and a check digit. */
190
+ function peselValid(raw) {
191
+ if (!/^\d{11}$/.test(raw))
192
+ return false;
193
+ let sum = 0;
194
+ for (let i = 0; i < 10; i++)
195
+ sum += (raw.charCodeAt(i) - 48) * [1, 3, 7, 9][i % 4];
196
+ return (10 - (sum % 10)) % 10 === raw.charCodeAt(10) - 48;
197
+ }
198
+ /** A German Steuer-ID: eleven digits, not starting with 0, ISO 7064 MOD 11,10. */
199
+ function steuerIdValid(raw) {
200
+ const d = digitsOf(raw);
201
+ if (d.length !== 11 || d[0] === "0")
202
+ return false;
203
+ let product = 10;
204
+ for (let i = 0; i < 10; i++) {
205
+ let sum = (d.charCodeAt(i) - 48 + product) % 10;
206
+ if (sum === 0)
207
+ sum = 10;
208
+ product = (2 * sum) % 11;
209
+ }
210
+ const check = 11 - product;
211
+ return (check === 10 ? 0 : check) === d.charCodeAt(10) - 48;
212
+ }
213
+ /** A passport number after the word: some digits in it, so "passport holder" is not one. */
214
+ function passportValid(raw) {
215
+ return digitsOf(raw).length >= 4;
216
+ }
217
+ /** A VAT number after the word: written in capitals, as issued, with digits in it. */
218
+ function vatValid(raw) {
219
+ return raw === raw.toUpperCase() && digitsOf(raw).length >= 6;
220
+ }
117
221
  /** A value in a .env line that is a placeholder, not a credential. */
118
222
  function envSecretValid(value) {
119
223
  return !/^[<{%(]/.test(value) && !/your|example|placeholder|changeme|xxxx/i.test(value);
@@ -169,6 +273,33 @@ const DETECTORS = [
169
273
  pattern: /\b(?!BG|GB|NK|KN|TN|NT|ZZ)[A-CEGHJ-PR-TW-Z][A-CEGHJ-NPR-TW-Z] ?\d{2} ?\d{2} ?\d{2} ?[A-D]\b/g,
170
274
  },
171
275
  { kind: "ie_pps", pattern: /\b\d{7}[A-W][A-IW]?\b/g, valid: ppsValid },
276
+ { kind: "us_itin", pattern: /\b9\d{2}-\d{2}-\d{4}\b/g, valid: itinValid },
277
+ // Written in groups of three, or as nine digits after the words.
278
+ { kind: "ca_sin", pattern: /\b\d{3}[ -]\d{3}[ -]\d{3}\b/g, valid: sinValid },
279
+ { kind: "ca_sin", pattern: /\b(?:SIN|social insurance (?:number|no\.?))[ \t:#]*(\d{9})\b/gi, valid: sinValid, group: 1 },
280
+ { kind: "fr_nir", pattern: /\b[12] ?\d{2} ?\d{2} ?(?:\d{2}|2[AB]) ?\d{3} ?\d{3} ?\d{2}\b/g, valid: nirValid },
281
+ { kind: "es_dni", pattern: /\b(?:\d{8}|[XYZ]\d{7})-?[A-Z]\b/g, valid: dniValid },
282
+ { kind: "it_fiscal_code", pattern: /\b[A-Z]{6}\d{2}[A-EHLMPRST]\d{2}[A-Z]\d{3}[A-Z]\b/g, valid: fiscalCodeValid },
283
+ // Nine or eleven bare digits are too often something else: these need the word before them.
284
+ { kind: "nl_bsn", pattern: /\b(?:BSN|burgerservicenummer)(?:-?nummer)?[ \t:#.]*(\d{9}|\d{4}\.\d{2}\.\d{3}|\d{3}[ .]\d{3}[ .]\d{3})\b/gi, valid: bsnValid, group: 1 },
285
+ { kind: "pl_pesel", pattern: /\bPESEL[ \t:#.]*(\d{11})\b/gi, valid: peselValid, group: 1 },
286
+ {
287
+ kind: "de_tax_id",
288
+ pattern: /\b(?:steuer-?id(?:entifikationsnummer)?|steuerliche identifikationsnummer|idnr\.?|tax id)[ \t:#.]*(\d{2} ?\d{3} ?\d{3} ?\d{3})\b/gi,
289
+ valid: steuerIdValid,
290
+ group: 1,
291
+ },
292
+ { kind: "passport", pattern: /\bpassport(?: (?:no\.?|number|#))?[ \t:#]*([A-Z0-9]{6,9})\b/gi, valid: passportValid, group: 1 },
293
+ {
294
+ kind: "vat_number",
295
+ pattern: /\b(?:VAT|BTW|TVA|IVA|USt-?IdNr\.?)(?: (?:no\.?|number|reg(?:istration)?(?: no\.?| number)?|id))?[ \t:#.]*((?:AT|BE|BG|CY|CZ|DE|DK|EE|EL|ES|FI|FR|GB|HR|HU|IE|IT|LT|LU|LV|MT|NL|PL|PT|RO|SE|SI|SK|XI) ?[0-9A-Z]{8,12})\b/gi,
296
+ valid: vatValid,
297
+ group: 1,
298
+ },
299
+ // Bank details after the words: a US routing number, a UK sort code, an account number.
300
+ { kind: "bank_account", pattern: /\b(?:routing|ABA|RTN)(?: (?:no\.?|number|#))?[ \t:#]*(\d{9})\b/gi, valid: abaValid, group: 1 },
301
+ { kind: "bank_account", pattern: /\bsort code[ \t:#]*(\d{2}[- ]?\d{2}[- ]?\d{2})\b/gi, group: 1 },
302
+ { kind: "bank_account", pattern: /\b(?:account|acct|a\/c)(?: (?:no\.?|number|#))?[ \t:#]*(\d{8,17})\b/gi, group: 1 },
172
303
  { kind: "email", pattern: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}\b/g },
173
304
  {
174
305
  kind: "date_of_birth",
@@ -195,7 +326,7 @@ const DETECTORS = [
195
326
  { kind: "special_category", pattern: SPECIAL_PATTERN },
196
327
  ];
197
328
  /** Earlier wins an overlap: a card number is not also a phone number. */
198
- const PRIORITY = Object.fromEntries(["secret", "iban", "payment_card", "us_ssn", "uk_national_insurance", "ie_pps", "email", "date_of_birth", "phone", "ip_address", "term", "person_name", "special_category"].map((k, i) => [k, i]));
329
+ const PRIORITY = Object.fromEntries(["secret", "iban", "payment_card", "us_ssn", "uk_national_insurance", "ie_pps", "us_itin", "ca_sin", "fr_nir", "es_dni", "it_fiscal_code", "nl_bsn", "pl_pesel", "de_tax_id", "passport", "vat_number", "bank_account", "email", "date_of_birth", "phone", "ip_address", "term", "person_name", "special_category"].map((k, i) => [k, i]));
199
330
  const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
200
331
  /** Terms past this are ignored, so a pasted list cannot make every screen slow. */
201
332
  export const MAX_SCREEN_TERMS = 500;
@@ -327,6 +458,8 @@ export function readScreenPolicy(raw) {
327
458
  },
328
459
  };
329
460
  }
461
+ /** Labels that start with a proper name, so they keep their capitals in a sentence. */
462
+ const KEEP_CASE = new Set(["ca_sin", "fr_nir", "it_fiscal_code", "nl_bsn", "pl_pesel", "de_tax_id"]);
330
463
  const plural = (n, label) => `${n} ${label.toLowerCase()}${n === 1 ? "" : "s"}`;
331
464
  /** "2 email addresses and 1 IBAN", for a reason or an approval's title. */
332
465
  export function describeCounts(counts) {
@@ -349,6 +482,10 @@ export function describeCounts(counts) {
349
482
  return `${n} date${n === 1 ? "" : "s"} of birth`;
350
483
  if (k === "ie_pps")
351
484
  return `${n} Irish PPS number${n === 1 ? "" : "s"}`;
485
+ if (k === "es_dni")
486
+ return `${n} Spanish ${n === 1 ? "DNI or NIE" : "DNIs or NIEs"}`;
487
+ if (KEEP_CASE.has(k))
488
+ return `${n} ${label}${n === 1 ? "" : "s"}`;
352
489
  return /^[A-Z]{2,}/.test(label) ? `${n} ${label}${n === 1 ? "" : "s"}` : plural(n, label);
353
490
  });
354
491
  if (parts.length <= 1)
@@ -0,0 +1,192 @@
1
+ /**
2
+ * Accounting ledgers: what an agent's call to Xero or QuickBooks Online is,
3
+ * in the words a finance approver and a policy rule use.
4
+ *
5
+ * Agents now write to the books. Xero's remote MCP server and its open-source
6
+ * one (`@xeroapi/xero-mcp-server`), Intuit's open-source QuickBooks server
7
+ * (`intuit/quickbooks-online-mcp-server`), and plain calls to both REST APIs
8
+ * can create payments, post journals and change a supplier's bank details.
9
+ * None of them asks anybody first. This module turns any of those calls into
10
+ * one of a handful of finance actions (approve a bill, record a payment,
11
+ * change a supplier's bank details...) with the amount, currency and
12
+ * counterparty pulled out, so a rule can say "over 5,000 needs two people"
13
+ * and mean it, whichever door the agent came through.
14
+ *
15
+ * It also reads what the ledgers' webhooks say, and turns a record the ledger
16
+ * sends back into a change worth watching, so a bill authorised or a bank
17
+ * account swapped with no yes behind it shows on the Enforcement panel.
18
+ *
19
+ * Three lines are held throughout:
20
+ *
21
+ * - **Pure, no imports.** This file is copied verbatim into
22
+ * `packages/sdk/src/ledgers.ts`, and a test fails when they differ, so an
23
+ * agent classifies its own calls the same way the hosted gateway does. The
24
+ * local MCP hook carries a JavaScript copy of the tool map
25
+ * (`integrations/agent-hooks/deliverd/ledgers.mjs`), held to the same cases.
26
+ * - **Unknown writes are still asked about.** A tool or route this file does
27
+ * not recognise but that changes something is `finance.ledger_write`, never
28
+ * waved through. Reads are never asked about.
29
+ * - **Bank details never travel whole.** Only masked forms (`•••• 1234`) are
30
+ * put in front of an approver or stored.
31
+ */
32
+ export declare const LEDGERS: readonly ["xero", "quickbooks"];
33
+ export type Ledger = (typeof LEDGERS)[number];
34
+ export declare const LEDGER_LABEL: Record<Ledger, string>;
35
+ /** The finance actions, by the id policy keys on. `finance.*` in a rule catches every one. */
36
+ export declare const FINANCE_ACTIONS: {
37
+ readonly approveBill: "finance.approve_bill";
38
+ readonly recordPayment: "finance.record_payment";
39
+ readonly postJournal: "finance.post_journal";
40
+ readonly bankTransaction: "finance.bank_transaction";
41
+ readonly supplierBankDetails: "finance.change_supplier_bank_details";
42
+ readonly sendInvoice: "finance.send_invoice";
43
+ readonly creditNote: "finance.issue_credit_note";
44
+ readonly payroll: "finance.approve_payroll";
45
+ readonly voidRecord: "finance.void_record";
46
+ readonly ledgerWrite: "finance.ledger_write";
47
+ };
48
+ export type FinanceActionId = (typeof FINANCE_ACTIONS)[keyof typeof FINANCE_ACTIONS];
49
+ export declare const FINANCE_ACTION_IDS: readonly FinanceActionId[];
50
+ /**
51
+ * What every finance gate carries. One shape for all of them, so a rule
52
+ * written for one (`amount gte 5000`, `newCounterparty eq true`) reads the
53
+ * same on the others. Flat and primitive, because the action schema subset is.
54
+ */
55
+ export interface LedgerInput {
56
+ ledger: Ledger;
57
+ /** What was called: `create-payment`, `POST /Payments`. */
58
+ tool: string;
59
+ recordType?: string;
60
+ amount?: number;
61
+ currency?: string;
62
+ counterparty?: string;
63
+ reference?: string;
64
+ recordId?: string;
65
+ status?: string;
66
+ /** The ledger has no earlier bill or payment for this counterparty. Set only when Deliverd could look. */
67
+ newCounterparty?: boolean;
68
+ /** The record is dated inside a period the ledger has locked. Set only when Deliverd could look. */
69
+ closedPeriod?: boolean;
70
+ /** The call changes where a supplier is paid. */
71
+ bankDetailsChanged?: boolean;
72
+ previousBankDetails?: string;
73
+ newBankDetails?: string;
74
+ /** What the approver should know, one finding a line: duplicates, recent bills. */
75
+ checks?: string;
76
+ }
77
+ export interface LedgerCall {
78
+ actionId: FinanceActionId;
79
+ input: LedgerInput;
80
+ /** One line for the approval card and the agent: "Record a payment of 1,200.00 GBP to Acme". */
81
+ summary: string;
82
+ }
83
+ type Rec = Record<string, unknown>;
84
+ export declare function primaryRecord(args: unknown): Rec;
85
+ export declare function amountOf(record: Rec): number | undefined;
86
+ export declare function currencyOf(record: Rec): string | undefined;
87
+ /**
88
+ * Who a record is with: a name wherever one is given, and an id only when no
89
+ * name is. `self` is for a contact or vendor record, which names itself.
90
+ */
91
+ export declare function counterpartyOf(record: Rec, self?: boolean): string | undefined;
92
+ /** `YYYY-MM-DD` from an ISO date, a QuickBooks `TxnDate`, or Xero's `/Date(1731628800000+0000)/`. */
93
+ export declare function isoDay(v: unknown): string | undefined;
94
+ export declare function dateOf(record: Rec): string | undefined;
95
+ /** The bank details a call sets, flattened to one string, or undefined when it sets none. */
96
+ export declare function bankDetailsIn(record: Rec): string | undefined;
97
+ /** `•••• 1234`: enough for a person to recognise an account, not enough to pay into it. */
98
+ export declare function maskAccount(value: string | undefined | null): string;
99
+ /** `xero__create-payment`, `mcp__qbo__create_bill`, `create-payment` → `create_payment`. */
100
+ export declare function toolKey(tool: string): string;
101
+ export declare function financeActionLabel(actionId: string): string;
102
+ export declare function summarise(call: {
103
+ actionId: FinanceActionId;
104
+ input: LedgerInput;
105
+ }): string;
106
+ /**
107
+ * One MCP tool call (or an SDK tool call with the same name), as a finance
108
+ * action. Null for a read: listing invoices or running a report asks nobody.
109
+ */
110
+ export declare function classifyLedgerTool(ledger: Ledger, tool: string, args: unknown): LedgerCall | null;
111
+ /**
112
+ * One REST request to a ledger, as a finance action. `path` is relative to
113
+ * the ledger's API root: `/api.xro/2.0/Invoices/…` for Xero, `/bill?…` for
114
+ * QuickBooks (whose root already names the company). Null for a read.
115
+ */
116
+ export declare function classifyLedgerRequest(ledger: Ledger, method: string, path: string, body?: string | null): LedgerCall | null;
117
+ export interface LedgerEvent {
118
+ ledger: Ledger;
119
+ /** Xero's tenant id, or the QuickBooks company's realm id. */
120
+ tenantId: string;
121
+ /** `invoice`, `contact`, `bill`, `vendor`, `billpayment`, `journalentry`… lower case. */
122
+ entity: string;
123
+ entityId: string;
124
+ /** `create`, `update`, `delete`, `void`, `emailed`, `merge`. */
125
+ operation: string;
126
+ at: string;
127
+ /** Unique per event, for recording each once. */
128
+ eventId: string;
129
+ }
130
+ /** Xero's batch: `{ events: [ { resourceId, tenantId, eventCategory, eventType, eventDateUtc } ] }`. */
131
+ export declare function parseXeroWebhook(body: unknown): LedgerEvent[];
132
+ /**
133
+ * Intuit sends either format during its move to CloudEvents: a JSON array of
134
+ * CloudEvents (`type: "qbo.bill.created.v1"`, `intuitaccountid`,
135
+ * `intuitentityid`), or the older `{ eventNotifications: [ { realmId,
136
+ * dataChangeEvent: { entities: [ { name, id, operation, lastUpdated } ] } } ] }`.
137
+ */
138
+ export declare function parseQuickbooksWebhook(body: unknown): LedgerEvent[];
139
+ /** The record a ledger event names, as the ledger's API answers for it. Xero: `/Invoices/{id}`; QuickBooks: `/{entity}/{id}`. */
140
+ export declare function recordPath(event: Pick<LedgerEvent, "ledger" | "entity" | "entityId">): string | null;
141
+ /** The record out of the ledger's answer: Xero's `{ Invoices: [x] }`, QuickBooks' `{ Bill: x }`. */
142
+ export declare function unwrapRecord(answer: unknown): Rec;
143
+ /**
144
+ * A change worth watching, from an event and the record as it now stands.
145
+ * Null for one nobody needs to see: a draft saved, a contact's phone number.
146
+ *
147
+ * `previousBank` is the masked bank details Deliverd last saw on that
148
+ * contact (null the first time, which records a baseline and flags nothing).
149
+ */
150
+ export interface LedgerChange {
151
+ actionId: FinanceActionId;
152
+ summary: string;
153
+ /** What a covering gate's input must mention. */
154
+ subjectTerms: string[];
155
+ /** A contact's bank details, masked: store it as the next baseline. */
156
+ bankNow?: string;
157
+ /** Nothing to record: only the baseline changed hands (the first sight of a contact, or no bank change). */
158
+ baselineOnly?: boolean;
159
+ }
160
+ export declare function changeFrom(event: LedgerEvent, record: Rec, previousBank: string | null | undefined): LedgerChange | null;
161
+ /** Is this Xero record a bill waiting for someone to approve it? */
162
+ export declare function awaitingApproval(record: Rec): boolean;
163
+ export interface PastRecord {
164
+ id?: string;
165
+ reference?: string;
166
+ amount?: number;
167
+ date?: string;
168
+ status?: string;
169
+ }
170
+ export interface CheckInput {
171
+ amount?: number;
172
+ currency?: string;
173
+ reference?: string;
174
+ recordId?: string;
175
+ /** The counterparty's recent records of the same kind, newest first. */
176
+ recent?: PastRecord[];
177
+ /** The record's date, `YYYY-MM-DD`. */
178
+ date?: string;
179
+ /** The ledger's lock date, `YYYY-MM-DD`: nothing on or before it should change. */
180
+ lockDate?: string | null;
181
+ }
182
+ /**
183
+ * The findings an approver reads above Approve, and the flags rules key on.
184
+ * A duplicate is the same reference, or the same amount within 30 days.
185
+ */
186
+ export declare function ledgerChecks(c: CheckInput): {
187
+ checks: string[];
188
+ newCounterparty?: boolean;
189
+ closedPeriod?: boolean;
190
+ };
191
+ export {};
192
+ //# sourceMappingURL=ledgers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledgers.d.ts","sourceRoot":"","sources":["../src/ledgers.ts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