@integrity-labs/agt-cli 0.28.1264 → 0.28.1265
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/{api-client-Q2FXLBH5.js → api-client-LPV5RUCO.js} +3 -3
- package/dist/bin/agt.js +7 -7
- package/dist/{chunk-GZMUGH6X.js → chunk-6ENTMJ5T.js} +3 -3
- package/dist/{chunk-5BXIXSSH.js → chunk-BMO6GCK2.js} +2 -2
- package/dist/{chunk-GSMGU2QA.js → chunk-DRP3J4CV.js} +5 -5
- package/dist/{chunk-KJ5OCCSJ.js → chunk-W2GHPRPZ.js} +2 -2
- package/dist/{chunk-KJ5OCCSJ.js.map → chunk-W2GHPRPZ.js.map} +1 -1
- package/dist/{chunk-HJWOXFJM.js → chunk-X2FBQPNR.js} +2 -2
- package/dist/{chunk-C3PSUSJ2.js → chunk-ZIAXGM6I.js} +3 -3
- package/dist/{claude-code-updater-JQLNRK25.js → claude-code-updater-XISTQTZX.js} +3 -3
- package/dist/{claude-pair-runtime-M6VJ3KZ3.js → claude-pair-runtime-2EOLNZEY.js} +3 -3
- package/dist/lib/manager-worker.js +21 -21
- package/dist/mcp/direct-chat-channel.js +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/origami.js +1 -1
- package/dist/mcp/slack-channel.js +1 -1
- package/dist/mcp/telegram-channel.js +1 -1
- package/dist/mcp/xero.js +727 -169
- package/dist/{persistent-session-3OES5QXZ.js → persistent-session-C7UKT4EE.js} +4 -4
- package/dist/{responsiveness-probe-BSSNRCPM.js → responsiveness-probe-NV3LXAWL.js} +4 -4
- package/dist/{session-auth-dead-A3TO2N63.js → session-auth-dead-U62KZ342.js} +3 -3
- package/package.json +1 -1
- /package/dist/{api-client-Q2FXLBH5.js.map → api-client-LPV5RUCO.js.map} +0 -0
- /package/dist/{chunk-GZMUGH6X.js.map → chunk-6ENTMJ5T.js.map} +0 -0
- /package/dist/{chunk-5BXIXSSH.js.map → chunk-BMO6GCK2.js.map} +0 -0
- /package/dist/{chunk-GSMGU2QA.js.map → chunk-DRP3J4CV.js.map} +0 -0
- /package/dist/{chunk-HJWOXFJM.js.map → chunk-X2FBQPNR.js.map} +0 -0
- /package/dist/{chunk-C3PSUSJ2.js.map → chunk-ZIAXGM6I.js.map} +0 -0
- /package/dist/{claude-code-updater-JQLNRK25.js.map → claude-code-updater-XISTQTZX.js.map} +0 -0
- /package/dist/{claude-pair-runtime-M6VJ3KZ3.js.map → claude-pair-runtime-2EOLNZEY.js.map} +0 -0
- /package/dist/{persistent-session-3OES5QXZ.js.map → persistent-session-C7UKT4EE.js.map} +0 -0
- /package/dist/{responsiveness-probe-BSSNRCPM.js.map → responsiveness-probe-NV3LXAWL.js.map} +0 -0
- /package/dist/{session-auth-dead-A3TO2N63.js.map → session-auth-dead-U62KZ342.js.map} +0 -0
package/dist/mcp/xero.js
CHANGED
|
@@ -4232,7 +4232,7 @@ var require_core = __commonJS({
|
|
|
4232
4232
|
errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
|
|
4233
4233
|
if (!errors || errors.length === 0)
|
|
4234
4234
|
return "No errors";
|
|
4235
|
-
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((
|
|
4235
|
+
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text2, msg) => text2 + separator + msg);
|
|
4236
4236
|
}
|
|
4237
4237
|
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
|
4238
4238
|
const rules = this.RULES.all;
|
|
@@ -18704,7 +18704,7 @@ var require_follow_redirects = __commonJS({
|
|
|
18704
18704
|
}
|
|
18705
18705
|
this._performRequest();
|
|
18706
18706
|
};
|
|
18707
|
-
function
|
|
18707
|
+
function wrap2(protocols) {
|
|
18708
18708
|
var exports2 = {
|
|
18709
18709
|
maxRedirects: 21,
|
|
18710
18710
|
maxBodyLength: 10 * 1024 * 1024
|
|
@@ -18854,8 +18854,8 @@ var require_follow_redirects = __commonJS({
|
|
|
18854
18854
|
function escapeRegex2(regex) {
|
|
18855
18855
|
return regex.replace(/[[\]\\/()*+?.^$|]/g, "\\$&");
|
|
18856
18856
|
}
|
|
18857
|
-
module.exports =
|
|
18858
|
-
module.exports.wrap =
|
|
18857
|
+
module.exports = wrap2({ http: http3, https: https2 });
|
|
18858
|
+
module.exports.wrap = wrap2;
|
|
18859
18859
|
}
|
|
18860
18860
|
});
|
|
18861
18861
|
|
|
@@ -27828,7 +27828,7 @@ var require_axios = __commonJS({
|
|
|
27828
27828
|
var stream4 = __require("stream");
|
|
27829
27829
|
var events = __require("events");
|
|
27830
27830
|
function bind2(fn, thisArg) {
|
|
27831
|
-
return function
|
|
27831
|
+
return function wrap2() {
|
|
27832
27832
|
return fn.apply(thisArg, arguments);
|
|
27833
27833
|
};
|
|
27834
27834
|
}
|
|
@@ -30059,20 +30059,20 @@ var require_axios = __commonJS({
|
|
|
30059
30059
|
if (parts[0] !== "127") return false;
|
|
30060
30060
|
return parts.every((p) => /^\d+$/.test(p) && Number(p) >= 0 && Number(p) <= 255);
|
|
30061
30061
|
};
|
|
30062
|
-
var parseIPv4Octet2 = (
|
|
30063
|
-
if (/^0[xX][0-9a-fA-F]+$/.test(
|
|
30064
|
-
const n = parseInt(
|
|
30062
|
+
var parseIPv4Octet2 = (text2) => {
|
|
30063
|
+
if (/^0[xX][0-9a-fA-F]+$/.test(text2)) {
|
|
30064
|
+
const n = parseInt(text2.slice(2), 16);
|
|
30065
30065
|
return Number.isFinite(n) ? n : null;
|
|
30066
30066
|
}
|
|
30067
|
-
if (
|
|
30068
|
-
const n = parseInt(
|
|
30067
|
+
if (text2.length > 1 && /^0[0-7]+$/.test(text2)) {
|
|
30068
|
+
const n = parseInt(text2, 8);
|
|
30069
30069
|
return Number.isFinite(n) ? n : null;
|
|
30070
30070
|
}
|
|
30071
|
-
if (
|
|
30071
|
+
if (text2.length > 1 && /^0[0-9]+$/.test(text2)) {
|
|
30072
30072
|
return null;
|
|
30073
30073
|
}
|
|
30074
|
-
if (/^[0-9]+$/.test(
|
|
30075
|
-
const n = parseInt(
|
|
30074
|
+
if (/^[0-9]+$/.test(text2)) {
|
|
30075
|
+
const n = parseInt(text2, 10);
|
|
30076
30076
|
return Number.isFinite(n) ? n : null;
|
|
30077
30077
|
}
|
|
30078
30078
|
return null;
|
|
@@ -32842,7 +32842,7 @@ var require_axios = __commonJS({
|
|
|
32842
32842
|
}
|
|
32843
32843
|
};
|
|
32844
32844
|
function spread3(callback) {
|
|
32845
|
-
return function
|
|
32845
|
+
return function wrap2(arr) {
|
|
32846
32846
|
return callback.apply(null, arr);
|
|
32847
32847
|
};
|
|
32848
32848
|
}
|
|
@@ -89825,7 +89825,7 @@ var require_aeskw = __commonJS({
|
|
|
89825
89825
|
}
|
|
89826
89826
|
throw new TypeError((0, invalid_key_input_js_1.default)(key, ...is_key_like_js_1.types, "Uint8Array"));
|
|
89827
89827
|
}
|
|
89828
|
-
var
|
|
89828
|
+
var wrap2 = (alg, key, cek) => {
|
|
89829
89829
|
const size = parseInt(alg.slice(1, 4), 10);
|
|
89830
89830
|
const algorithm = `aes${size}-wrap`;
|
|
89831
89831
|
if (!(0, ciphers_js_1.default)(algorithm)) {
|
|
@@ -89836,7 +89836,7 @@ var require_aeskw = __commonJS({
|
|
|
89836
89836
|
const cipher = (0, crypto_1.createCipheriv)(algorithm, keyObject, buffer_1.Buffer.alloc(8, 166));
|
|
89837
89837
|
return (0, buffer_utils_js_1.concat)(cipher.update(cek), cipher.final());
|
|
89838
89838
|
};
|
|
89839
|
-
exports.wrap =
|
|
89839
|
+
exports.wrap = wrap2;
|
|
89840
89840
|
var unwrap = (alg, key, encryptedKey) => {
|
|
89841
89841
|
const size = parseInt(alg.slice(1, 4), 10);
|
|
89842
89842
|
const algorithm = `aes${size}-wrap`;
|
|
@@ -90735,13 +90735,13 @@ var require_aesgcmkw = __commonJS({
|
|
|
90735
90735
|
var decrypt_js_1 = require_decrypt();
|
|
90736
90736
|
var iv_js_1 = require_iv();
|
|
90737
90737
|
var base64url_js_1 = require_base64url();
|
|
90738
|
-
async function
|
|
90738
|
+
async function wrap2(alg, key, cek, iv) {
|
|
90739
90739
|
const jweAlgorithm = alg.slice(0, 7);
|
|
90740
90740
|
iv || (iv = (0, iv_js_1.default)(jweAlgorithm));
|
|
90741
90741
|
const { ciphertext: encryptedKey, tag } = await (0, encrypt_js_1.default)(jweAlgorithm, cek, key, iv, new Uint8Array(0));
|
|
90742
90742
|
return { encryptedKey, iv: (0, base64url_js_1.encode)(iv), tag: (0, base64url_js_1.encode)(tag) };
|
|
90743
90743
|
}
|
|
90744
|
-
exports.wrap =
|
|
90744
|
+
exports.wrap = wrap2;
|
|
90745
90745
|
async function unwrap(alg, key, encryptedKey, iv, tag) {
|
|
90746
90746
|
const jweAlgorithm = alg.slice(0, 7);
|
|
90747
90747
|
return (0, decrypt_js_1.default)(jweAlgorithm, key, encryptedKey, iv, tag, new Uint8Array(0));
|
|
@@ -93902,7 +93902,7 @@ var require_assert = __commonJS({
|
|
|
93902
93902
|
var require_pick = __commonJS({
|
|
93903
93903
|
"../../node_modules/.pnpm/openid-client@5.7.1/node_modules/openid-client/lib/helpers/pick.js"(exports, module) {
|
|
93904
93904
|
"use strict";
|
|
93905
|
-
module.exports = function
|
|
93905
|
+
module.exports = function pick3(object3, ...paths) {
|
|
93906
93906
|
const obj = {};
|
|
93907
93907
|
for (const path of paths) {
|
|
93908
93908
|
if (object3[path] !== void 0) {
|
|
@@ -94831,7 +94831,7 @@ var require_request = __commonJS({
|
|
|
94831
94831
|
var LRU = require_lru_cache();
|
|
94832
94832
|
var pkg = require_package2();
|
|
94833
94833
|
var { RPError } = require_errors2();
|
|
94834
|
-
var
|
|
94834
|
+
var pick3 = require_pick();
|
|
94835
94835
|
var { deep: defaultsDeep } = require_defaults2();
|
|
94836
94836
|
var { HTTP_OPTIONS } = require_consts();
|
|
94837
94837
|
var DEFAULT_HTTP_OPTIONS;
|
|
@@ -94851,7 +94851,7 @@ var require_request = __commonJS({
|
|
|
94851
94851
|
var setDefaults = (props, options) => {
|
|
94852
94852
|
DEFAULT_HTTP_OPTIONS = defaultsDeep(
|
|
94853
94853
|
{},
|
|
94854
|
-
props.length ?
|
|
94854
|
+
props.length ? pick3(options, ...props) : options,
|
|
94855
94855
|
DEFAULT_HTTP_OPTIONS
|
|
94856
94856
|
);
|
|
94857
94857
|
};
|
|
@@ -94901,7 +94901,7 @@ var require_request = __commonJS({
|
|
|
94901
94901
|
}
|
|
94902
94902
|
let userOptions;
|
|
94903
94903
|
if (optsFn) {
|
|
94904
|
-
userOptions =
|
|
94904
|
+
userOptions = pick3(
|
|
94905
94905
|
optsFn.call(this, url2, defaultsDeep({}, opts, DEFAULT_HTTP_OPTIONS)),
|
|
94906
94906
|
...allowed
|
|
94907
94907
|
);
|
|
@@ -96050,7 +96050,7 @@ var require_client2 = __commonJS({
|
|
|
96050
96050
|
var defaults2 = require_defaults2();
|
|
96051
96051
|
var parseWwwAuthenticate = require_www_authenticate_parser();
|
|
96052
96052
|
var { assertSigningAlgValuesSupport, assertIssuerConfiguration } = require_assert();
|
|
96053
|
-
var
|
|
96053
|
+
var pick3 = require_pick();
|
|
96054
96054
|
var isPlainObject4 = require_is_plain_object();
|
|
96055
96055
|
var processResponse = require_process_response();
|
|
96056
96056
|
var TokenSet2 = require_token_set();
|
|
@@ -96071,7 +96071,7 @@ var require_client2 = __commonJS({
|
|
|
96071
96071
|
var skipNonceCheck = /* @__PURE__ */ Symbol();
|
|
96072
96072
|
var skipMaxAgeCheck = /* @__PURE__ */ Symbol();
|
|
96073
96073
|
function pickCb(input) {
|
|
96074
|
-
return
|
|
96074
|
+
return pick3(
|
|
96075
96075
|
input,
|
|
96076
96076
|
"access_token",
|
|
96077
96077
|
// OAuth 2.0
|
|
@@ -97563,12 +97563,12 @@ var require_client2 = __commonJS({
|
|
|
97563
97563
|
var jwkCache = /* @__PURE__ */ new WeakMap();
|
|
97564
97564
|
async function getJwk(keyObject, privateKeyInput) {
|
|
97565
97565
|
if (jose.cryptoRuntime === "node:crypto" && typeof privateKeyInput === "object" && typeof privateKeyInput.key === "object" && privateKeyInput.format === "jwk") {
|
|
97566
|
-
return
|
|
97566
|
+
return pick3(privateKeyInput.key, "kty", "crv", "x", "y", "e", "n");
|
|
97567
97567
|
}
|
|
97568
97568
|
if (jwkCache.has(privateKeyInput)) {
|
|
97569
97569
|
return jwkCache.get(privateKeyInput);
|
|
97570
97570
|
}
|
|
97571
|
-
const jwk =
|
|
97571
|
+
const jwk = pick3(await jose.exportJWK(keyObject), "kty", "crv", "x", "y", "e", "n");
|
|
97572
97572
|
if (isKeyObject(privateKeyInput) || jose.cryptoRuntime === "WebCryptoAPI") {
|
|
97573
97573
|
jwkCache.set(privateKeyInput, jwk);
|
|
97574
97574
|
}
|
|
@@ -97811,7 +97811,7 @@ var require_passport_strategy = __commonJS({
|
|
|
97811
97811
|
var { RPError, OPError } = require_errors2();
|
|
97812
97812
|
var { BaseClient } = require_client2();
|
|
97813
97813
|
var { random, codeChallenge } = require_generators();
|
|
97814
|
-
var
|
|
97814
|
+
var pick3 = require_pick();
|
|
97815
97815
|
var { resolveResponseType, resolveRedirectUri } = require_client();
|
|
97816
97816
|
function verified(err, user, info = {}) {
|
|
97817
97817
|
if (err) {
|
|
@@ -97881,7 +97881,7 @@ var require_passport_strategy = __commonJS({
|
|
|
97881
97881
|
if (!params.nonce && params.response_type.includes("id_token")) {
|
|
97882
97882
|
params.nonce = random();
|
|
97883
97883
|
}
|
|
97884
|
-
req.session[sessionKey] =
|
|
97884
|
+
req.session[sessionKey] = pick3(params, "nonce", "state", "max_age", "response_type");
|
|
97885
97885
|
if (this._usePKCE && params.response_type.includes("code")) {
|
|
97886
97886
|
const verifier = random();
|
|
97887
97887
|
req.session[sessionKey].code_verifier = verifier;
|
|
@@ -98258,13 +98258,13 @@ var require_XeroClient = __commonJS({
|
|
|
98258
98258
|
const result = yield this.queryApi("GET", "https://api.xero.com/connections");
|
|
98259
98259
|
let tenants = result.body.map((connection) => connection);
|
|
98260
98260
|
if (fullOrgDetails) {
|
|
98261
|
-
const getOrgsForAll = tenants.map((
|
|
98262
|
-
const result2 = yield this.accountingApi.getOrganisations(
|
|
98261
|
+
const getOrgsForAll = tenants.map((tenant2) => __awaiter(this, void 0, void 0, function* () {
|
|
98262
|
+
const result2 = yield this.accountingApi.getOrganisations(tenant2.tenantId);
|
|
98263
98263
|
return result2.body.organisations[0];
|
|
98264
98264
|
}));
|
|
98265
98265
|
const orgData = yield Promise.all(getOrgsForAll);
|
|
98266
|
-
tenants.map((
|
|
98267
|
-
|
|
98266
|
+
tenants.map((tenant2) => {
|
|
98267
|
+
tenant2.orgData = orgData.filter((el) => el.organisationID == tenant2.tenantId)[0];
|
|
98268
98268
|
});
|
|
98269
98269
|
}
|
|
98270
98270
|
tenants.sort((a, b) => new Date(b.updatedDateUtc) - new Date(a.updatedDateUtc));
|
|
@@ -112656,7 +112656,7 @@ var XeroMcpServer = class _XeroMcpServer {
|
|
|
112656
112656
|
|
|
112657
112657
|
// ../../node_modules/.pnpm/axios@1.20.0/node_modules/axios/lib/helpers/bind.js
|
|
112658
112658
|
function bind(fn, thisArg) {
|
|
112659
|
-
return function
|
|
112659
|
+
return function wrap2() {
|
|
112660
112660
|
return fn.apply(thisArg, arguments);
|
|
112661
112661
|
};
|
|
112662
112662
|
}
|
|
@@ -115068,20 +115068,20 @@ var isIPv4Loopback = (host) => {
|
|
|
115068
115068
|
if (parts[0] !== "127") return false;
|
|
115069
115069
|
return parts.every((p) => /^\d+$/.test(p) && Number(p) >= 0 && Number(p) <= 255);
|
|
115070
115070
|
};
|
|
115071
|
-
var parseIPv4Octet = (
|
|
115072
|
-
if (/^0[xX][0-9a-fA-F]+$/.test(
|
|
115073
|
-
const n = parseInt(
|
|
115071
|
+
var parseIPv4Octet = (text2) => {
|
|
115072
|
+
if (/^0[xX][0-9a-fA-F]+$/.test(text2)) {
|
|
115073
|
+
const n = parseInt(text2.slice(2), 16);
|
|
115074
115074
|
return Number.isFinite(n) ? n : null;
|
|
115075
115075
|
}
|
|
115076
|
-
if (
|
|
115077
|
-
const n = parseInt(
|
|
115076
|
+
if (text2.length > 1 && /^0[0-7]+$/.test(text2)) {
|
|
115077
|
+
const n = parseInt(text2, 8);
|
|
115078
115078
|
return Number.isFinite(n) ? n : null;
|
|
115079
115079
|
}
|
|
115080
|
-
if (
|
|
115080
|
+
if (text2.length > 1 && /^0[0-9]+$/.test(text2)) {
|
|
115081
115081
|
return null;
|
|
115082
115082
|
}
|
|
115083
|
-
if (/^[0-9]+$/.test(
|
|
115084
|
-
const n = parseInt(
|
|
115083
|
+
if (/^[0-9]+$/.test(text2)) {
|
|
115084
|
+
const n = parseInt(text2, 10);
|
|
115085
115085
|
return Number.isFinite(n) ? n : null;
|
|
115086
115086
|
}
|
|
115087
115087
|
return null;
|
|
@@ -118124,7 +118124,7 @@ var CancelToken_default = CancelToken;
|
|
|
118124
118124
|
|
|
118125
118125
|
// ../../node_modules/.pnpm/axios@1.20.0/node_modules/axios/lib/helpers/spread.js
|
|
118126
118126
|
function spread(callback) {
|
|
118127
|
-
return function
|
|
118127
|
+
return function wrap2(arr) {
|
|
118128
118128
|
return callback.apply(null, arr);
|
|
118129
118129
|
};
|
|
118130
118130
|
}
|
|
@@ -118276,9 +118276,60 @@ var {
|
|
|
118276
118276
|
create
|
|
118277
118277
|
} = axios_default;
|
|
118278
118278
|
|
|
118279
|
-
// src/
|
|
118280
|
-
var
|
|
118281
|
-
|
|
118279
|
+
// src/errors/xero-errors.ts
|
|
118280
|
+
var XeroScopeMissingError = class extends Error {
|
|
118281
|
+
status;
|
|
118282
|
+
xeroDetail;
|
|
118283
|
+
constructor(message, status, xeroDetail) {
|
|
118284
|
+
super(message);
|
|
118285
|
+
this.name = "XeroScopeMissingError";
|
|
118286
|
+
this.status = status;
|
|
118287
|
+
this.xeroDetail = xeroDetail;
|
|
118288
|
+
}
|
|
118289
|
+
};
|
|
118290
|
+
function classifyXeroError(error2) {
|
|
118291
|
+
const rejection = parseXeroApiRejection(error2);
|
|
118292
|
+
const status = rejection ? rejection.statusCode : axiosStatus(error2);
|
|
118293
|
+
if (status !== 401) return null;
|
|
118294
|
+
const detail = readXeroDetail(
|
|
118295
|
+
rejection ? rejection.body : error2.response?.data
|
|
118296
|
+
);
|
|
118297
|
+
if (detail !== "AuthorizationUnsuccessful") return null;
|
|
118298
|
+
return new XeroScopeMissingError(
|
|
118299
|
+
`Xero rejected this call as scope-missing \u2014 the OAuth consent did not grant the scope this endpoint requires. Token refresh will not help: refresh tokens cannot widen scope. Ask the user to click "Reconnect" on the Xero card in the Augmented console so the consent screen requests the scopes the agent's installed skills need.`,
|
|
118300
|
+
401,
|
|
118301
|
+
detail
|
|
118302
|
+
);
|
|
118303
|
+
}
|
|
118304
|
+
function axiosStatus(error2) {
|
|
118305
|
+
return error2 instanceof AxiosError2 ? error2.response?.status : void 0;
|
|
118306
|
+
}
|
|
118307
|
+
function parseXeroApiRejection(error2) {
|
|
118308
|
+
if (typeof error2 !== "string") return null;
|
|
118309
|
+
if (!error2.startsWith("{")) return null;
|
|
118310
|
+
let parsed;
|
|
118311
|
+
try {
|
|
118312
|
+
parsed = JSON.parse(error2);
|
|
118313
|
+
} catch {
|
|
118314
|
+
return null;
|
|
118315
|
+
}
|
|
118316
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
118317
|
+
const response = parsed.response;
|
|
118318
|
+
if (!response || typeof response !== "object") return null;
|
|
118319
|
+
const statusCode = response.statusCode;
|
|
118320
|
+
if (typeof statusCode !== "number") return null;
|
|
118321
|
+
return { statusCode, body: response.body };
|
|
118322
|
+
}
|
|
118323
|
+
function readXeroDetail(data) {
|
|
118324
|
+
if (data && typeof data === "object" && "Detail" in data) {
|
|
118325
|
+
const d = data.Detail;
|
|
118326
|
+
return typeof d === "string" ? d : null;
|
|
118327
|
+
}
|
|
118328
|
+
if (typeof data === "string") {
|
|
118329
|
+
return data.includes("AuthorizationUnsuccessful") ? "AuthorizationUnsuccessful" : null;
|
|
118330
|
+
}
|
|
118331
|
+
return null;
|
|
118332
|
+
}
|
|
118282
118333
|
|
|
118283
118334
|
// src/helpers/redact-sensitive.ts
|
|
118284
118335
|
var SENSITIVE_HEADER_NAMES = [
|
|
@@ -118307,6 +118358,115 @@ function redactSensitiveText(input) {
|
|
|
118307
118358
|
return input.replace(JSON_PAIR_RE, (_m, key) => `${key}"${REDACTED2}"`).replace(HEADER_LINE_RE, (_m, name) => `${name}: ${REDACTED2}`).replace(BEARER_VALUE_RE, (_m, scheme) => `${scheme} ${REDACTED2}`);
|
|
118308
118359
|
}
|
|
118309
118360
|
|
|
118361
|
+
// src/helpers/format-error.ts
|
|
118362
|
+
function formatError2(error2) {
|
|
118363
|
+
const scopeMissing = classifyXeroError(error2);
|
|
118364
|
+
if (scopeMissing) return scopeMissing.message;
|
|
118365
|
+
const rejection = parseXeroApiRejection(error2);
|
|
118366
|
+
if (rejection) {
|
|
118367
|
+
return messageForStatus(rejection.statusCode, readDetail(rejection.body));
|
|
118368
|
+
}
|
|
118369
|
+
if (error2 instanceof AxiosError2) {
|
|
118370
|
+
return messageForStatus(error2.response?.status, readDetail(error2.response?.data));
|
|
118371
|
+
}
|
|
118372
|
+
if (error2 instanceof Error) return redactSensitiveText(error2.message);
|
|
118373
|
+
return "An unexpected error occurred while communicating with Xero.";
|
|
118374
|
+
}
|
|
118375
|
+
function messageForStatus(status, detail) {
|
|
118376
|
+
switch (status) {
|
|
118377
|
+
case 401:
|
|
118378
|
+
return "Authentication failed. Please check your Xero credentials.";
|
|
118379
|
+
case 403:
|
|
118380
|
+
return "You don't have permission to access this resource in Xero.";
|
|
118381
|
+
case 404:
|
|
118382
|
+
return "The requested resource was not found in Xero.";
|
|
118383
|
+
case 429:
|
|
118384
|
+
return "Too many requests to Xero. Please try again in a moment.";
|
|
118385
|
+
default:
|
|
118386
|
+
return detail ? redactSensitiveText(detail) : "An error occurred while communicating with Xero.";
|
|
118387
|
+
}
|
|
118388
|
+
}
|
|
118389
|
+
var MAX_VALIDATION_MESSAGES = 5;
|
|
118390
|
+
function readDetail(body) {
|
|
118391
|
+
if (!body || typeof body !== "object") return null;
|
|
118392
|
+
const b = body;
|
|
118393
|
+
if (typeof b.Detail === "string" && b.Detail.trim() !== "") return b.Detail;
|
|
118394
|
+
const messages = [];
|
|
118395
|
+
if (Array.isArray(b.Elements)) {
|
|
118396
|
+
for (const element of b.Elements) {
|
|
118397
|
+
const errors = element?.ValidationErrors;
|
|
118398
|
+
if (!Array.isArray(errors)) continue;
|
|
118399
|
+
for (const e of errors) {
|
|
118400
|
+
const m = e?.Message;
|
|
118401
|
+
if (typeof m === "string" && m.trim() !== "" && !messages.includes(m.trim())) messages.push(m.trim());
|
|
118402
|
+
}
|
|
118403
|
+
}
|
|
118404
|
+
}
|
|
118405
|
+
if (messages.length > 0) {
|
|
118406
|
+
const shown = messages.slice(0, MAX_VALIDATION_MESSAGES);
|
|
118407
|
+
const more = messages.length - shown.length;
|
|
118408
|
+
return `Xero rejected the request: ${shown.join("; ")}${more > 0 ? ` (and ${more} more)` : ""}`;
|
|
118409
|
+
}
|
|
118410
|
+
if (typeof b.Message === "string" && b.Message.trim() !== "") return b.Message;
|
|
118411
|
+
return null;
|
|
118412
|
+
}
|
|
118413
|
+
|
|
118414
|
+
// src/helpers/payroll-region.ts
|
|
118415
|
+
var PayrollRegionError = class extends Error {
|
|
118416
|
+
constructor(message) {
|
|
118417
|
+
super(message);
|
|
118418
|
+
this.name = "PayrollRegionError";
|
|
118419
|
+
}
|
|
118420
|
+
};
|
|
118421
|
+
var PayrollRegionUnreadableError = class extends PayrollRegionError {
|
|
118422
|
+
constructor(message) {
|
|
118423
|
+
super(message);
|
|
118424
|
+
this.name = "PayrollRegionUnreadableError";
|
|
118425
|
+
}
|
|
118426
|
+
};
|
|
118427
|
+
var PAYROLL_REGION_BY_COUNTRY = {
|
|
118428
|
+
AU: "AU",
|
|
118429
|
+
NZ: "NZ"
|
|
118430
|
+
};
|
|
118431
|
+
function payrollRegionFromCountryCode(countryCode) {
|
|
118432
|
+
const code = typeof countryCode === "string" ? countryCode.trim().toUpperCase() : "";
|
|
118433
|
+
if (!code) {
|
|
118434
|
+
throw new PayrollRegionUnreadableError(
|
|
118435
|
+
"This organisation's country could not be read, so its payroll API cannot be chosen. Nothing was fetched."
|
|
118436
|
+
);
|
|
118437
|
+
}
|
|
118438
|
+
const region = PAYROLL_REGION_BY_COUNTRY[code];
|
|
118439
|
+
if (!region) {
|
|
118440
|
+
throw new PayrollRegionError(
|
|
118441
|
+
`Payroll is not available here for an organisation in ${code}: only Australian (AU) and New Zealand (NZ) payroll are supported. Nothing was fetched.`
|
|
118442
|
+
);
|
|
118443
|
+
}
|
|
118444
|
+
return region;
|
|
118445
|
+
}
|
|
118446
|
+
function notAvailableForRegion(toolName, region, hint) {
|
|
118447
|
+
const label = region === "AU" ? "Australian (AU)" : "New Zealand (NZ)";
|
|
118448
|
+
return `${toolName} is not available for ${label} payroll. Nothing was fetched or changed.` + (hint ? ` ${hint}` : "");
|
|
118449
|
+
}
|
|
118450
|
+
async function resolvePayrollRegion(client) {
|
|
118451
|
+
try {
|
|
118452
|
+
await client.authenticate();
|
|
118453
|
+
} catch (error2) {
|
|
118454
|
+
return { ok: false, message: formatError2(error2), unreadable: false };
|
|
118455
|
+
}
|
|
118456
|
+
try {
|
|
118457
|
+
return { ok: true, region: await client.getPayrollRegion() };
|
|
118458
|
+
} catch (error2) {
|
|
118459
|
+
if (error2 instanceof PayrollRegionError) {
|
|
118460
|
+
return { ok: false, message: error2.message, unreadable: error2 instanceof PayrollRegionUnreadableError };
|
|
118461
|
+
}
|
|
118462
|
+
return { ok: false, message: formatError2(error2), unreadable: true };
|
|
118463
|
+
}
|
|
118464
|
+
}
|
|
118465
|
+
|
|
118466
|
+
// src/clients/xero-client.ts
|
|
118467
|
+
var import_dotenv = __toESM(require_main(), 1);
|
|
118468
|
+
var import_xero_node = __toESM(require_dist3(), 1);
|
|
118469
|
+
|
|
118310
118470
|
// src/helpers/ensure-error.ts
|
|
118311
118471
|
function ensureError(value) {
|
|
118312
118472
|
if (value instanceof Error) return value;
|
|
@@ -118562,6 +118722,7 @@ var MCPXeroClient = class extends import_xero_node.XeroClient {
|
|
|
118562
118722
|
// CS-1739: one short code per organisation, since a call can now target any
|
|
118563
118723
|
// allowed organisation and a deep link must point at the right one.
|
|
118564
118724
|
shortCodes = /* @__PURE__ */ new Map();
|
|
118725
|
+
payrollRegions = /* @__PURE__ */ new Map();
|
|
118565
118726
|
/** CS-1739: the organisations the platform allows for this login (broker mode). */
|
|
118566
118727
|
/**
|
|
118567
118728
|
* CS-1739: the operator's organisation list from the broker.
|
|
@@ -118621,6 +118782,33 @@ var MCPXeroClient = class extends import_xero_node.XeroClient {
|
|
|
118621
118782
|
}
|
|
118622
118783
|
return organisation;
|
|
118623
118784
|
}
|
|
118785
|
+
/**
|
|
118786
|
+
* CS-2548 / ENG-12096: which Xero payroll API serves this tenant. Xero runs
|
|
118787
|
+
* separate payroll APIs per region (AU `/payroll.xro/1.0`, NZ and UK
|
|
118788
|
+
* `/payroll.xro/2.0`), and every payroll handler used to call the NZ one, so
|
|
118789
|
+
* an Australian organisation got nothing back. Decided from the
|
|
118790
|
+
* Organisation's CountryCode and cached per tenant. Only a SUCCESSFUL read is
|
|
118791
|
+
* cached: a failed read is retried next call, never remembered as a region.
|
|
118792
|
+
* Throws `PayrollRegionError` for an unreadable or unsupported country, so a
|
|
118793
|
+
* caller fails closed instead of guessing an API.
|
|
118794
|
+
*/
|
|
118795
|
+
async getPayrollRegion() {
|
|
118796
|
+
const key = this.tenantId;
|
|
118797
|
+
const cached2 = this.payrollRegions.get(key);
|
|
118798
|
+
if (cached2) return cached2;
|
|
118799
|
+
let countryCode;
|
|
118800
|
+
try {
|
|
118801
|
+
const organisation = await this.getOrganisation();
|
|
118802
|
+
countryCode = organisation.countryCode;
|
|
118803
|
+
} catch (error2) {
|
|
118804
|
+
throw new PayrollRegionUnreadableError(
|
|
118805
|
+
`Could not read this organisation's country to choose its payroll API: ${ensureError(error2).message}`
|
|
118806
|
+
);
|
|
118807
|
+
}
|
|
118808
|
+
const region = payrollRegionFromCountryCode(countryCode);
|
|
118809
|
+
this.payrollRegions.set(key, region);
|
|
118810
|
+
return region;
|
|
118811
|
+
}
|
|
118624
118812
|
async getShortCode() {
|
|
118625
118813
|
const key = this.tenantId;
|
|
118626
118814
|
if (!this.shortCodes.has(key)) {
|
|
@@ -118791,114 +118979,6 @@ var xeroClient = broker_mode ? new BrokerBearerTokenXeroClient({
|
|
|
118791
118979
|
grantType: grant_type
|
|
118792
118980
|
});
|
|
118793
118981
|
|
|
118794
|
-
// src/errors/xero-errors.ts
|
|
118795
|
-
var XeroScopeMissingError = class extends Error {
|
|
118796
|
-
status;
|
|
118797
|
-
xeroDetail;
|
|
118798
|
-
constructor(message, status, xeroDetail) {
|
|
118799
|
-
super(message);
|
|
118800
|
-
this.name = "XeroScopeMissingError";
|
|
118801
|
-
this.status = status;
|
|
118802
|
-
this.xeroDetail = xeroDetail;
|
|
118803
|
-
}
|
|
118804
|
-
};
|
|
118805
|
-
function classifyXeroError(error2) {
|
|
118806
|
-
const rejection = parseXeroApiRejection(error2);
|
|
118807
|
-
const status = rejection ? rejection.statusCode : axiosStatus(error2);
|
|
118808
|
-
if (status !== 401) return null;
|
|
118809
|
-
const detail = readXeroDetail(
|
|
118810
|
-
rejection ? rejection.body : error2.response?.data
|
|
118811
|
-
);
|
|
118812
|
-
if (detail !== "AuthorizationUnsuccessful") return null;
|
|
118813
|
-
return new XeroScopeMissingError(
|
|
118814
|
-
`Xero rejected this call as scope-missing \u2014 the OAuth consent did not grant the scope this endpoint requires. Token refresh will not help: refresh tokens cannot widen scope. Ask the user to click "Reconnect" on the Xero card in the Augmented console so the consent screen requests the scopes the agent's installed skills need.`,
|
|
118815
|
-
401,
|
|
118816
|
-
detail
|
|
118817
|
-
);
|
|
118818
|
-
}
|
|
118819
|
-
function axiosStatus(error2) {
|
|
118820
|
-
return error2 instanceof AxiosError2 ? error2.response?.status : void 0;
|
|
118821
|
-
}
|
|
118822
|
-
function parseXeroApiRejection(error2) {
|
|
118823
|
-
if (typeof error2 !== "string") return null;
|
|
118824
|
-
if (!error2.startsWith("{")) return null;
|
|
118825
|
-
let parsed;
|
|
118826
|
-
try {
|
|
118827
|
-
parsed = JSON.parse(error2);
|
|
118828
|
-
} catch {
|
|
118829
|
-
return null;
|
|
118830
|
-
}
|
|
118831
|
-
if (!parsed || typeof parsed !== "object") return null;
|
|
118832
|
-
const response = parsed.response;
|
|
118833
|
-
if (!response || typeof response !== "object") return null;
|
|
118834
|
-
const statusCode = response.statusCode;
|
|
118835
|
-
if (typeof statusCode !== "number") return null;
|
|
118836
|
-
return { statusCode, body: response.body };
|
|
118837
|
-
}
|
|
118838
|
-
function readXeroDetail(data) {
|
|
118839
|
-
if (data && typeof data === "object" && "Detail" in data) {
|
|
118840
|
-
const d = data.Detail;
|
|
118841
|
-
return typeof d === "string" ? d : null;
|
|
118842
|
-
}
|
|
118843
|
-
if (typeof data === "string") {
|
|
118844
|
-
return data.includes("AuthorizationUnsuccessful") ? "AuthorizationUnsuccessful" : null;
|
|
118845
|
-
}
|
|
118846
|
-
return null;
|
|
118847
|
-
}
|
|
118848
|
-
|
|
118849
|
-
// src/helpers/format-error.ts
|
|
118850
|
-
function formatError2(error2) {
|
|
118851
|
-
const scopeMissing = classifyXeroError(error2);
|
|
118852
|
-
if (scopeMissing) return scopeMissing.message;
|
|
118853
|
-
const rejection = parseXeroApiRejection(error2);
|
|
118854
|
-
if (rejection) {
|
|
118855
|
-
return messageForStatus(rejection.statusCode, readDetail(rejection.body));
|
|
118856
|
-
}
|
|
118857
|
-
if (error2 instanceof AxiosError2) {
|
|
118858
|
-
return messageForStatus(error2.response?.status, readDetail(error2.response?.data));
|
|
118859
|
-
}
|
|
118860
|
-
if (error2 instanceof Error) return redactSensitiveText(error2.message);
|
|
118861
|
-
return "An unexpected error occurred while communicating with Xero.";
|
|
118862
|
-
}
|
|
118863
|
-
function messageForStatus(status, detail) {
|
|
118864
|
-
switch (status) {
|
|
118865
|
-
case 401:
|
|
118866
|
-
return "Authentication failed. Please check your Xero credentials.";
|
|
118867
|
-
case 403:
|
|
118868
|
-
return "You don't have permission to access this resource in Xero.";
|
|
118869
|
-
case 404:
|
|
118870
|
-
return "The requested resource was not found in Xero.";
|
|
118871
|
-
case 429:
|
|
118872
|
-
return "Too many requests to Xero. Please try again in a moment.";
|
|
118873
|
-
default:
|
|
118874
|
-
return detail ? redactSensitiveText(detail) : "An error occurred while communicating with Xero.";
|
|
118875
|
-
}
|
|
118876
|
-
}
|
|
118877
|
-
var MAX_VALIDATION_MESSAGES = 5;
|
|
118878
|
-
function readDetail(body) {
|
|
118879
|
-
if (!body || typeof body !== "object") return null;
|
|
118880
|
-
const b = body;
|
|
118881
|
-
if (typeof b.Detail === "string" && b.Detail.trim() !== "") return b.Detail;
|
|
118882
|
-
const messages = [];
|
|
118883
|
-
if (Array.isArray(b.Elements)) {
|
|
118884
|
-
for (const element of b.Elements) {
|
|
118885
|
-
const errors = element?.ValidationErrors;
|
|
118886
|
-
if (!Array.isArray(errors)) continue;
|
|
118887
|
-
for (const e of errors) {
|
|
118888
|
-
const m = e?.Message;
|
|
118889
|
-
if (typeof m === "string" && m.trim() !== "" && !messages.includes(m.trim())) messages.push(m.trim());
|
|
118890
|
-
}
|
|
118891
|
-
}
|
|
118892
|
-
}
|
|
118893
|
-
if (messages.length > 0) {
|
|
118894
|
-
const shown = messages.slice(0, MAX_VALIDATION_MESSAGES);
|
|
118895
|
-
const more = messages.length - shown.length;
|
|
118896
|
-
return `Xero rejected the request: ${shown.join("; ")}${more > 0 ? ` (and ${more} more)` : ""}`;
|
|
118897
|
-
}
|
|
118898
|
-
if (typeof b.Message === "string" && b.Message.trim() !== "") return b.Message;
|
|
118899
|
-
return null;
|
|
118900
|
-
}
|
|
118901
|
-
|
|
118902
118982
|
// src/helpers/get-package-version.ts
|
|
118903
118983
|
import { readFileSync } from "fs";
|
|
118904
118984
|
import { fileURLToPath } from "url";
|
|
@@ -120060,6 +120140,38 @@ async function createXeroPayrollTimesheet(timesheet) {
|
|
|
120060
120140
|
}
|
|
120061
120141
|
}
|
|
120062
120142
|
|
|
120143
|
+
// src/helpers/payroll-tool.ts
|
|
120144
|
+
function text(message) {
|
|
120145
|
+
return { content: [{ type: "text", text: message }] };
|
|
120146
|
+
}
|
|
120147
|
+
function jsonText(heading, data) {
|
|
120148
|
+
return {
|
|
120149
|
+
content: [
|
|
120150
|
+
{ type: "text", text: heading },
|
|
120151
|
+
{ type: "text", text: JSON.stringify(data, null, 2) }
|
|
120152
|
+
]
|
|
120153
|
+
};
|
|
120154
|
+
}
|
|
120155
|
+
function renderResult(errorPrefix, heading, response) {
|
|
120156
|
+
if (response.isError) return text(`${errorPrefix}: ${response.error}`);
|
|
120157
|
+
return jsonText(heading(response.result), response.result);
|
|
120158
|
+
}
|
|
120159
|
+
function withPayrollRegion(factory2, existing, other) {
|
|
120160
|
+
return (() => {
|
|
120161
|
+
const def = factory2();
|
|
120162
|
+
const original = def.handler;
|
|
120163
|
+
const handler = async (args, extra) => {
|
|
120164
|
+
const resolved = await resolvePayrollRegion(xeroClient);
|
|
120165
|
+
if (!resolved.ok && resolved.unreadable && existing === "NZ") return original(args, extra);
|
|
120166
|
+
if (!resolved.ok) return text(`Error: ${resolved.message}`);
|
|
120167
|
+
if (resolved.region === existing) return original(args, extra);
|
|
120168
|
+
if (typeof other === "function") return other(args);
|
|
120169
|
+
return text(notAvailableForRegion(def.name, resolved.region, other.unavailable));
|
|
120170
|
+
};
|
|
120171
|
+
return { ...def, handler };
|
|
120172
|
+
});
|
|
120173
|
+
}
|
|
120174
|
+
|
|
120063
120175
|
// src/tools/create/create-payroll-timesheet.tool.ts
|
|
120064
120176
|
var CreatePayrollTimesheetTool = CreateXeroTool(
|
|
120065
120177
|
"create-timesheet",
|
|
@@ -120101,7 +120213,9 @@ This allows you to specify details such as the employee ID, payroll calendar ID,
|
|
|
120101
120213
|
};
|
|
120102
120214
|
}
|
|
120103
120215
|
);
|
|
120104
|
-
var create_payroll_timesheet_tool_default = CreatePayrollTimesheetTool
|
|
120216
|
+
var create_payroll_timesheet_tool_default = withPayrollRegion(CreatePayrollTimesheetTool, "NZ", {
|
|
120217
|
+
unavailable: "Australian timesheet changes are not supported by this server yet: make them in Xero (Payroll > Timesheets)."
|
|
120218
|
+
});
|
|
120105
120219
|
|
|
120106
120220
|
// src/handlers/create-xero-quote.handler.ts
|
|
120107
120221
|
var import_xero_node7 = __toESM(require_dist3(), 1);
|
|
@@ -120451,13 +120565,376 @@ var DeletePayrollTimesheetTool = CreateXeroTool(
|
|
|
120451
120565
|
};
|
|
120452
120566
|
}
|
|
120453
120567
|
);
|
|
120454
|
-
var delete_payroll_timesheet_tool_default = DeletePayrollTimesheetTool
|
|
120568
|
+
var delete_payroll_timesheet_tool_default = withPayrollRegion(DeletePayrollTimesheetTool, "NZ", {
|
|
120569
|
+
unavailable: "Australian timesheet changes are not supported by this server yet: make them in Xero (Payroll > Timesheets)."
|
|
120570
|
+
});
|
|
120455
120571
|
|
|
120456
120572
|
// src/tools/delete/index.ts
|
|
120457
120573
|
var DeleteTools = [
|
|
120458
120574
|
delete_payroll_timesheet_tool_default
|
|
120459
120575
|
];
|
|
120460
120576
|
|
|
120577
|
+
// src/handlers/payroll-au.handler.ts
|
|
120578
|
+
var SENSITIVE_PAYROLL_KEYS = [
|
|
120579
|
+
"dateOfBirth",
|
|
120580
|
+
"homeAddress",
|
|
120581
|
+
"bankAccounts",
|
|
120582
|
+
"taxDeclaration",
|
|
120583
|
+
"taxFileNumber",
|
|
120584
|
+
"superMemberships",
|
|
120585
|
+
"superMembershipID",
|
|
120586
|
+
"employeeNumber",
|
|
120587
|
+
"phone",
|
|
120588
|
+
"mobile",
|
|
120589
|
+
"email",
|
|
120590
|
+
"twitterUserName",
|
|
120591
|
+
"gender"
|
|
120592
|
+
];
|
|
120593
|
+
var SENSITIVE = new Set(SENSITIVE_PAYROLL_KEYS);
|
|
120594
|
+
function stripSensitive(value) {
|
|
120595
|
+
if (Array.isArray(value)) return value.map(stripSensitive);
|
|
120596
|
+
if (value instanceof Date) return value;
|
|
120597
|
+
if (value && typeof value === "object") {
|
|
120598
|
+
const out = {};
|
|
120599
|
+
for (const [k, v] of Object.entries(value)) {
|
|
120600
|
+
if (SENSITIVE.has(k)) continue;
|
|
120601
|
+
out[k] = stripSensitive(v);
|
|
120602
|
+
}
|
|
120603
|
+
return out;
|
|
120604
|
+
}
|
|
120605
|
+
return value;
|
|
120606
|
+
}
|
|
120607
|
+
function pick2(source, keys) {
|
|
120608
|
+
const src = source ?? {};
|
|
120609
|
+
const out = {};
|
|
120610
|
+
for (const k of keys) {
|
|
120611
|
+
if (src[k] !== void 0 && src[k] !== null) out[k] = stripSensitive(src[k]);
|
|
120612
|
+
}
|
|
120613
|
+
return out;
|
|
120614
|
+
}
|
|
120615
|
+
var EMPLOYEE_FIELDS = [
|
|
120616
|
+
"employeeID",
|
|
120617
|
+
"firstName",
|
|
120618
|
+
"lastName",
|
|
120619
|
+
"status",
|
|
120620
|
+
"startDate",
|
|
120621
|
+
"terminationDate",
|
|
120622
|
+
"jobTitle",
|
|
120623
|
+
"employmentType",
|
|
120624
|
+
"incomeType",
|
|
120625
|
+
"employeeGroupName",
|
|
120626
|
+
"payrollCalendarID",
|
|
120627
|
+
"ordinaryEarningsRateID",
|
|
120628
|
+
"updatedDateUTC"
|
|
120629
|
+
];
|
|
120630
|
+
var TIMESHEET_FIELDS = [
|
|
120631
|
+
"timesheetID",
|
|
120632
|
+
"employeeID",
|
|
120633
|
+
"startDate",
|
|
120634
|
+
"endDate",
|
|
120635
|
+
"status",
|
|
120636
|
+
"hours",
|
|
120637
|
+
"timesheetLines",
|
|
120638
|
+
"updatedDateUTC"
|
|
120639
|
+
];
|
|
120640
|
+
var LEAVE_APPLICATION_FIELDS = [
|
|
120641
|
+
"leaveApplicationID",
|
|
120642
|
+
"employeeID",
|
|
120643
|
+
"leaveTypeID",
|
|
120644
|
+
"title",
|
|
120645
|
+
"startDate",
|
|
120646
|
+
"endDate",
|
|
120647
|
+
"payOutType",
|
|
120648
|
+
"leavePeriods",
|
|
120649
|
+
"updatedDateUTC"
|
|
120650
|
+
];
|
|
120651
|
+
var PAY_RUN_FIELDS = [
|
|
120652
|
+
"payRunID",
|
|
120653
|
+
"payrollCalendarID",
|
|
120654
|
+
"payRunPeriodStartDate",
|
|
120655
|
+
"payRunPeriodEndDate",
|
|
120656
|
+
"payRunStatus",
|
|
120657
|
+
"paymentDate",
|
|
120658
|
+
"wages",
|
|
120659
|
+
"deductions",
|
|
120660
|
+
"tax",
|
|
120661
|
+
"reimbursement",
|
|
120662
|
+
"netPay",
|
|
120663
|
+
"updatedDateUTC"
|
|
120664
|
+
];
|
|
120665
|
+
var PAYSLIP_SUMMARY_FIELDS = [
|
|
120666
|
+
"payslipID",
|
|
120667
|
+
"employeeID",
|
|
120668
|
+
"firstName",
|
|
120669
|
+
"lastName",
|
|
120670
|
+
"employeeGroup",
|
|
120671
|
+
"wages",
|
|
120672
|
+
"deductions",
|
|
120673
|
+
"tax",
|
|
120674
|
+
"_super",
|
|
120675
|
+
"reimbursements",
|
|
120676
|
+
"netPay"
|
|
120677
|
+
];
|
|
120678
|
+
var PAYSLIP_FIELDS = [
|
|
120679
|
+
"payslipID",
|
|
120680
|
+
"employeeID",
|
|
120681
|
+
"firstName",
|
|
120682
|
+
"lastName",
|
|
120683
|
+
"wages",
|
|
120684
|
+
"deductions",
|
|
120685
|
+
"tax",
|
|
120686
|
+
"reimbursements",
|
|
120687
|
+
"netPay",
|
|
120688
|
+
"earningsLines",
|
|
120689
|
+
"leaveEarningsLines",
|
|
120690
|
+
"timesheetEarningsLines",
|
|
120691
|
+
"deductionLines",
|
|
120692
|
+
"reimbursementLines",
|
|
120693
|
+
"superannuationLines",
|
|
120694
|
+
"leaveAccrualLines",
|
|
120695
|
+
"taxLines",
|
|
120696
|
+
"updatedDateUTC"
|
|
120697
|
+
];
|
|
120698
|
+
var PAY_TEMPLATE_FIELDS = [
|
|
120699
|
+
"earningsLines",
|
|
120700
|
+
"deductionLines",
|
|
120701
|
+
"superLines",
|
|
120702
|
+
"reimbursementLines",
|
|
120703
|
+
"leaveLines"
|
|
120704
|
+
];
|
|
120705
|
+
var CALENDAR_FIELDS = [
|
|
120706
|
+
"payrollCalendarID",
|
|
120707
|
+
"name",
|
|
120708
|
+
"calendarType",
|
|
120709
|
+
"startDate",
|
|
120710
|
+
"paymentDate",
|
|
120711
|
+
"updatedDateUTC"
|
|
120712
|
+
];
|
|
120713
|
+
var PAY_ITEM_GROUPS = ["earningsRates", "deductionTypes", "leaveTypes", "reimbursementTypes"];
|
|
120714
|
+
var AU_PAGE_SIZE = 100;
|
|
120715
|
+
var AU_MAX_PAGES = 20;
|
|
120716
|
+
var GUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
120717
|
+
function assertGuid(value, label) {
|
|
120718
|
+
const v = (value ?? "").trim();
|
|
120719
|
+
if (!GUID.test(v)) throw new Error(`${label} must be a Xero ID (a GUID), got "${value}".`);
|
|
120720
|
+
return v;
|
|
120721
|
+
}
|
|
120722
|
+
async function wrap(fn) {
|
|
120723
|
+
try {
|
|
120724
|
+
return { result: await fn(), isError: false, error: null };
|
|
120725
|
+
} catch (error2) {
|
|
120726
|
+
return { result: null, isError: true, error: formatError2(error2) };
|
|
120727
|
+
}
|
|
120728
|
+
}
|
|
120729
|
+
async function readAllPages(read) {
|
|
120730
|
+
const records = [];
|
|
120731
|
+
for (let page = 1; page <= AU_MAX_PAGES; page++) {
|
|
120732
|
+
const batch = await read(page) ?? [];
|
|
120733
|
+
records.push(...batch);
|
|
120734
|
+
if (batch.length < AU_PAGE_SIZE) return { records, truncated: false };
|
|
120735
|
+
}
|
|
120736
|
+
return { records, truncated: true };
|
|
120737
|
+
}
|
|
120738
|
+
function payItemKey(item) {
|
|
120739
|
+
for (const k of ["earningsRateID", "deductionTypeID", "leaveTypeID", "reimbursementTypeID"]) {
|
|
120740
|
+
if (typeof item[k] === "string") return item[k];
|
|
120741
|
+
}
|
|
120742
|
+
return item;
|
|
120743
|
+
}
|
|
120744
|
+
var api = () => xeroClient.payrollAUApi;
|
|
120745
|
+
var tenant = () => xeroClient.tenantId;
|
|
120746
|
+
async function listAuPayrollEmployees() {
|
|
120747
|
+
return wrap(async () => {
|
|
120748
|
+
await xeroClient.authenticate();
|
|
120749
|
+
const { records, truncated } = await readAllPages(
|
|
120750
|
+
async (page) => (await api().getEmployees(tenant(), void 0, void 0, "EmployeeID ASC", page, getClientHeaders())).body.employees
|
|
120751
|
+
);
|
|
120752
|
+
return { employees: records.map((e) => pick2(e, EMPLOYEE_FIELDS)), truncated };
|
|
120753
|
+
});
|
|
120754
|
+
}
|
|
120755
|
+
async function listAuPayrollTimesheets() {
|
|
120756
|
+
return wrap(async () => {
|
|
120757
|
+
await xeroClient.authenticate();
|
|
120758
|
+
const { records, truncated } = await readAllPages(
|
|
120759
|
+
async (page) => (await api().getTimesheets(tenant(), void 0, void 0, "TimesheetID ASC", page, getClientHeaders())).body.timesheets
|
|
120760
|
+
);
|
|
120761
|
+
return { timesheets: records.map((t) => pick2(t, TIMESHEET_FIELDS)), truncated };
|
|
120762
|
+
});
|
|
120763
|
+
}
|
|
120764
|
+
async function getAuPayrollTimesheet(timesheetID) {
|
|
120765
|
+
return wrap(async () => {
|
|
120766
|
+
const id = assertGuid(timesheetID, "timesheetID");
|
|
120767
|
+
await xeroClient.authenticate();
|
|
120768
|
+
const res = await api().getTimesheet(tenant(), id, getClientHeaders());
|
|
120769
|
+
const timesheet = res.body.timesheet;
|
|
120770
|
+
if (!timesheet) throw new Error(`No timesheet ${id} was returned.`);
|
|
120771
|
+
return pick2(timesheet, TIMESHEET_FIELDS);
|
|
120772
|
+
});
|
|
120773
|
+
}
|
|
120774
|
+
async function listAuEmployeeLeaveApplications(employeeID) {
|
|
120775
|
+
return wrap(async () => {
|
|
120776
|
+
const id = assertGuid(employeeID, "employeeId");
|
|
120777
|
+
await xeroClient.authenticate();
|
|
120778
|
+
const where = `EmployeeID==Guid("${id}")`;
|
|
120779
|
+
const { records, truncated } = await readAllPages(
|
|
120780
|
+
async (page) => (
|
|
120781
|
+
// CodeRabbit on #7615: V2, because V1 returns only SCHEDULED and PROCESSED
|
|
120782
|
+
// periods, so leave still REQUESTED (pending) would never be listed.
|
|
120783
|
+
(await api().getLeaveApplicationsV2(tenant(), void 0, where, "LeaveApplicationID ASC", page, getClientHeaders())).body.leaveApplications
|
|
120784
|
+
)
|
|
120785
|
+
);
|
|
120786
|
+
return { leaveApplications: records.map((l) => pick2(l, LEAVE_APPLICATION_FIELDS)), truncated };
|
|
120787
|
+
});
|
|
120788
|
+
}
|
|
120789
|
+
async function readAuEmployee(employeeID) {
|
|
120790
|
+
const id = assertGuid(employeeID, "employeeId");
|
|
120791
|
+
await xeroClient.authenticate();
|
|
120792
|
+
const res = await api().getEmployee(tenant(), id, getClientHeaders());
|
|
120793
|
+
const employee = res.body.employees?.[0];
|
|
120794
|
+
if (!employee) throw new Error(`No employee ${id} was returned.`);
|
|
120795
|
+
return employee;
|
|
120796
|
+
}
|
|
120797
|
+
async function listAuEmployeeLeaveBalances(employeeID) {
|
|
120798
|
+
return wrap(async () => {
|
|
120799
|
+
const employee = await readAuEmployee(employeeID);
|
|
120800
|
+
return {
|
|
120801
|
+
employee: pick2(employee, ["employeeID", "firstName", "lastName"]),
|
|
120802
|
+
leaveBalances: stripSensitive(employee["leaveBalances"] ?? [])
|
|
120803
|
+
};
|
|
120804
|
+
});
|
|
120805
|
+
}
|
|
120806
|
+
async function getAuEmployeePayTemplate(employeeID) {
|
|
120807
|
+
return wrap(async () => {
|
|
120808
|
+
const employee = await readAuEmployee(employeeID);
|
|
120809
|
+
return {
|
|
120810
|
+
employee: pick2(employee, [
|
|
120811
|
+
"employeeID",
|
|
120812
|
+
"firstName",
|
|
120813
|
+
"lastName",
|
|
120814
|
+
"payrollCalendarID",
|
|
120815
|
+
"ordinaryEarningsRateID",
|
|
120816
|
+
"employmentType",
|
|
120817
|
+
"status"
|
|
120818
|
+
]),
|
|
120819
|
+
payTemplate: pick2(employee["payTemplate"], PAY_TEMPLATE_FIELDS)
|
|
120820
|
+
};
|
|
120821
|
+
});
|
|
120822
|
+
}
|
|
120823
|
+
async function listAuPayItems() {
|
|
120824
|
+
return wrap(async () => {
|
|
120825
|
+
await xeroClient.authenticate();
|
|
120826
|
+
const groups = Object.fromEntries(PAY_ITEM_GROUPS.map((g) => [g, []]));
|
|
120827
|
+
const seen = Object.fromEntries(PAY_ITEM_GROUPS.map((g) => [g, /* @__PURE__ */ new Set()]));
|
|
120828
|
+
for (let page = 1; page <= AU_MAX_PAGES; page++) {
|
|
120829
|
+
const res = await api().getPayItems(tenant(), void 0, void 0, void 0, page, getClientHeaders());
|
|
120830
|
+
const env = res.body.payItems ?? {};
|
|
120831
|
+
let added = 0;
|
|
120832
|
+
let anyFull = false;
|
|
120833
|
+
for (const g of PAY_ITEM_GROUPS) {
|
|
120834
|
+
const batch = Array.isArray(env[g]) ? env[g] : [];
|
|
120835
|
+
if (batch.length >= AU_PAGE_SIZE) anyFull = true;
|
|
120836
|
+
for (const item of batch) {
|
|
120837
|
+
const key = JSON.stringify(payItemKey(item));
|
|
120838
|
+
if (seen[g].has(key)) continue;
|
|
120839
|
+
seen[g].add(key);
|
|
120840
|
+
groups[g].push(item);
|
|
120841
|
+
added += 1;
|
|
120842
|
+
}
|
|
120843
|
+
}
|
|
120844
|
+
if (!anyFull) return { ...pick2(groups, PAY_ITEM_GROUPS), truncated: false };
|
|
120845
|
+
if (added === 0) return { ...pick2(groups, PAY_ITEM_GROUPS), truncated: true };
|
|
120846
|
+
}
|
|
120847
|
+
return { ...pick2(groups, PAY_ITEM_GROUPS), truncated: true };
|
|
120848
|
+
});
|
|
120849
|
+
}
|
|
120850
|
+
async function listAuPayrollCalendars() {
|
|
120851
|
+
return wrap(async () => {
|
|
120852
|
+
await xeroClient.authenticate();
|
|
120853
|
+
const { records, truncated } = await readAllPages(
|
|
120854
|
+
async (page) => (await api().getPayrollCalendars(tenant(), void 0, void 0, "PayrollCalendarID ASC", page, getClientHeaders())).body.payrollCalendars
|
|
120855
|
+
);
|
|
120856
|
+
return { payrollCalendars: records.map((c) => pick2(c, CALENDAR_FIELDS)), truncated };
|
|
120857
|
+
});
|
|
120858
|
+
}
|
|
120859
|
+
var PAY_RUN_STATUSES = ["DRAFT", "POSTED"];
|
|
120860
|
+
async function listAuPayRuns(status, page = 1) {
|
|
120861
|
+
return wrap(async () => {
|
|
120862
|
+
await xeroClient.authenticate();
|
|
120863
|
+
if (status !== void 0 && !PAY_RUN_STATUSES.includes(status)) {
|
|
120864
|
+
throw new Error(`status must be one of ${PAY_RUN_STATUSES.join(", ")}.`);
|
|
120865
|
+
}
|
|
120866
|
+
if (!Number.isInteger(page) || page < 1) throw new Error("page must be a whole number from 1.");
|
|
120867
|
+
const where = status ? `PayRunStatus=="${status}"` : void 0;
|
|
120868
|
+
const res = await api().getPayRuns(tenant(), void 0, where, "PayRunPeriodEndDate DESC", page, getClientHeaders());
|
|
120869
|
+
const payRuns = res.body.payRuns ?? [];
|
|
120870
|
+
return {
|
|
120871
|
+
payRuns: payRuns.map((r) => pick2(r, PAY_RUN_FIELDS)),
|
|
120872
|
+
page,
|
|
120873
|
+
morePages: payRuns.length >= AU_PAGE_SIZE
|
|
120874
|
+
};
|
|
120875
|
+
});
|
|
120876
|
+
}
|
|
120877
|
+
async function getAuPayRun(payRunID) {
|
|
120878
|
+
return wrap(async () => {
|
|
120879
|
+
const id = assertGuid(payRunID, "payRunID");
|
|
120880
|
+
await xeroClient.authenticate();
|
|
120881
|
+
const res = await api().getPayRun(tenant(), id, getClientHeaders());
|
|
120882
|
+
const run = res.body.payRuns?.[0];
|
|
120883
|
+
if (!run) throw new Error(`No pay run ${id} was returned.`);
|
|
120884
|
+
const payslips = run["payslips"] ?? [];
|
|
120885
|
+
return { ...pick2(run, PAY_RUN_FIELDS), payslips: payslips.map((p) => pick2(p, PAYSLIP_SUMMARY_FIELDS)) };
|
|
120886
|
+
});
|
|
120887
|
+
}
|
|
120888
|
+
async function getAuPayslip(payslipID) {
|
|
120889
|
+
return wrap(async () => {
|
|
120890
|
+
const id = assertGuid(payslipID, "payslipID");
|
|
120891
|
+
await xeroClient.authenticate();
|
|
120892
|
+
const res = await api().getPayslip(tenant(), id, getClientHeaders());
|
|
120893
|
+
const payslip = res.body.payslip;
|
|
120894
|
+
if (!payslip) throw new Error(`No payslip ${id} was returned.`);
|
|
120895
|
+
return pick2(payslip, PAYSLIP_FIELDS);
|
|
120896
|
+
});
|
|
120897
|
+
}
|
|
120898
|
+
|
|
120899
|
+
// src/tools/get/get-payroll-payslip.tool.ts
|
|
120900
|
+
var GetPayrollPayslipTool = CreateXeroTool(
|
|
120901
|
+
"get-payroll-payslip",
|
|
120902
|
+
"Get one Australian payslip's lines: earnings (by earnings rate, units and rate), leave and timesheet earnings, deductions, reimbursements, super, leave accrual and tax lines, with totals. Australian (AU) payroll only.",
|
|
120903
|
+
{
|
|
120904
|
+
payslipID: external_exports.string().describe("The payslip ID (a GUID), from get-payroll-pay-run.")
|
|
120905
|
+
},
|
|
120906
|
+
async (args) => renderResult("Error in get-payroll-payslip", () => "AU payslip:", await getAuPayslip(args.payslipID))
|
|
120907
|
+
);
|
|
120908
|
+
var get_payroll_payslip_tool_default = withPayrollRegion(GetPayrollPayslipTool, "AU", {
|
|
120909
|
+
unavailable: "New Zealand payroll has no equivalent in this server yet."
|
|
120910
|
+
});
|
|
120911
|
+
|
|
120912
|
+
// src/tools/get/get-payroll-pay-run.tool.ts
|
|
120913
|
+
var GetPayrollPayRunTool = CreateXeroTool(
|
|
120914
|
+
"get-payroll-pay-run",
|
|
120915
|
+
"Get one Australian pay run: its period, payment date, status and totals, and a summary of each payslip in it (employee, wages, tax, super, deductions, net pay, payslip ID). Use get-payroll-payslip for a payslip's lines. Australian (AU) payroll only.",
|
|
120916
|
+
{
|
|
120917
|
+
payRunID: external_exports.string().describe("The pay run ID (a GUID).")
|
|
120918
|
+
},
|
|
120919
|
+
async (args) => renderResult("Error in get-payroll-pay-run", () => "AU pay run:", await getAuPayRun(args.payRunID))
|
|
120920
|
+
);
|
|
120921
|
+
var get_payroll_pay_run_tool_default = withPayrollRegion(GetPayrollPayRunTool, "AU", {
|
|
120922
|
+
unavailable: "New Zealand payroll has no equivalent in this server yet."
|
|
120923
|
+
});
|
|
120924
|
+
|
|
120925
|
+
// src/tools/get/get-payroll-employee-pay-template.tool.ts
|
|
120926
|
+
var GetPayrollEmployeePayTemplateTool = CreateXeroTool(
|
|
120927
|
+
"get-payroll-employee-pay-template",
|
|
120928
|
+
"Get one employee's Australian pay template: their standard earnings lines (earnings rate, units, rate), deductions, super and reimbursement lines, plus their payroll calendar and ordinary earnings rate. Personal details (date of birth, address, bank, tax file number) are never returned. Australian (AU) payroll only.",
|
|
120929
|
+
{
|
|
120930
|
+
employeeId: external_exports.string().describe("The Xero payroll employee ID (a GUID).")
|
|
120931
|
+
},
|
|
120932
|
+
async (args) => renderResult("Error in get-payroll-employee-pay-template", () => "AU employee pay template:", await getAuEmployeePayTemplate(args.employeeId))
|
|
120933
|
+
);
|
|
120934
|
+
var get_payroll_employee_pay_template_tool_default = withPayrollRegion(GetPayrollEmployeePayTemplateTool, "AU", {
|
|
120935
|
+
unavailable: "New Zealand payroll has no equivalent in this server yet."
|
|
120936
|
+
});
|
|
120937
|
+
|
|
120461
120938
|
// src/helpers/resolve-export-file.ts
|
|
120462
120939
|
import { promises as fs2 } from "fs";
|
|
120463
120940
|
import { basename as basename2, extname as extname2, resolve as resolve2, sep as sep2 } from "path";
|
|
@@ -120687,7 +121164,11 @@ This provides details such as the timesheet ID, employee ID, start and end dates
|
|
|
120687
121164
|
};
|
|
120688
121165
|
}
|
|
120689
121166
|
);
|
|
120690
|
-
var get_payroll_timesheet_tool_default =
|
|
121167
|
+
var get_payroll_timesheet_tool_default = withPayrollRegion(
|
|
121168
|
+
GetPayrollTimesheetTool,
|
|
121169
|
+
"NZ",
|
|
121170
|
+
async (args) => renderResult("Error retrieving timesheet", () => "AU timesheet:", await getAuPayrollTimesheet(args.timesheetID))
|
|
121171
|
+
);
|
|
120691
121172
|
|
|
120692
121173
|
// src/handlers/get-xero-repeating-invoice.handler.ts
|
|
120693
121174
|
async function getRepeatingInvoice(repeatingInvoiceID) {
|
|
@@ -120854,11 +121335,50 @@ var get_repeating_invoice_tool_default = GetRepeatingInvoiceTool;
|
|
|
120854
121335
|
|
|
120855
121336
|
// src/tools/get/index.ts
|
|
120856
121337
|
var GetTools = [
|
|
121338
|
+
get_payroll_payslip_tool_default,
|
|
121339
|
+
get_payroll_pay_run_tool_default,
|
|
121340
|
+
get_payroll_employee_pay_template_tool_default,
|
|
120857
121341
|
get_invoice_pdf_tool_default,
|
|
120858
121342
|
get_payroll_timesheet_tool_default,
|
|
120859
121343
|
get_repeating_invoice_tool_default
|
|
120860
121344
|
];
|
|
120861
121345
|
|
|
121346
|
+
// src/tools/list/list-payroll-pay-runs.tool.ts
|
|
121347
|
+
var ListPayrollPayRunsTool = CreateXeroTool(
|
|
121348
|
+
"list-payroll-pay-runs",
|
|
121349
|
+
"List Australian pay runs, newest period first, 100 per page: period start and end, payment date, status (DRAFT or POSTED) and totals (wages, tax, deductions, net pay). Filter by status to find drafts. Australian (AU) payroll only.",
|
|
121350
|
+
{
|
|
121351
|
+
status: external_exports.enum(["DRAFT", "POSTED"]).optional().describe("Only pay runs with this status."),
|
|
121352
|
+
page: external_exports.number().int().min(1).optional().describe("Page number, from 1. 100 pay runs a page.")
|
|
121353
|
+
},
|
|
121354
|
+
async (args) => renderResult("Error in list-payroll-pay-runs", (r) => `Found ${r.payRuns.length} AU pay runs on page ${r.page}${r.morePages ? " (there may be more pages)" : ""}:`, await listAuPayRuns(args.status, args.page ?? 1))
|
|
121355
|
+
);
|
|
121356
|
+
var list_payroll_pay_runs_tool_default = withPayrollRegion(ListPayrollPayRunsTool, "AU", {
|
|
121357
|
+
unavailable: "New Zealand payroll has no equivalent in this server yet."
|
|
121358
|
+
});
|
|
121359
|
+
|
|
121360
|
+
// src/tools/list/list-payroll-calendars.tool.ts
|
|
121361
|
+
var ListPayrollCalendarsTool = CreateXeroTool(
|
|
121362
|
+
"list-payroll-calendars",
|
|
121363
|
+
"List the organisation's Australian payroll calendars (weekly, fortnightly, monthly), with each calendar's ID, type, start date and next payment date. A pay run belongs to one calendar. Australian (AU) payroll only.",
|
|
121364
|
+
{},
|
|
121365
|
+
async () => renderResult("Error in list-payroll-calendars", (r) => `Found ${r.payrollCalendars.length} AU payroll calendars:`, await listAuPayrollCalendars())
|
|
121366
|
+
);
|
|
121367
|
+
var list_payroll_calendars_tool_default = withPayrollRegion(ListPayrollCalendarsTool, "AU", {
|
|
121368
|
+
unavailable: "New Zealand payroll has no equivalent in this server yet."
|
|
121369
|
+
});
|
|
121370
|
+
|
|
121371
|
+
// src/tools/list/list-payroll-pay-items.tool.ts
|
|
121372
|
+
var ListPayrollPayItemsTool = CreateXeroTool(
|
|
121373
|
+
"list-payroll-pay-items",
|
|
121374
|
+
"List the organisation's Australian payroll pay items: earnings rates (ordinary hours, overtime, public holiday, allowances, bonus), deduction types, leave types and reimbursement types, with their IDs. Use the earnings rate IDs when drafting earnings lines for a pay run. Australian (AU) payroll only.",
|
|
121375
|
+
{},
|
|
121376
|
+
async () => renderResult("Error in list-payroll-pay-items", () => "AU pay items:", await listAuPayItems())
|
|
121377
|
+
);
|
|
121378
|
+
var list_payroll_pay_items_tool_default = withPayrollRegion(ListPayrollPayItemsTool, "AU", {
|
|
121379
|
+
unavailable: "New Zealand payroll has no equivalent in this server yet."
|
|
121380
|
+
});
|
|
121381
|
+
|
|
120862
121382
|
// src/handlers/list-xero-accounts.handler.ts
|
|
120863
121383
|
async function listAccounts() {
|
|
120864
121384
|
await xeroClient.authenticate();
|
|
@@ -122114,7 +122634,11 @@ var ListPayrollEmployeeLeaveBalancesTool = CreateXeroTool(
|
|
|
122114
122634
|
};
|
|
122115
122635
|
}
|
|
122116
122636
|
);
|
|
122117
|
-
var list_payroll_employee_leave_balances_tool_default =
|
|
122637
|
+
var list_payroll_employee_leave_balances_tool_default = withPayrollRegion(
|
|
122638
|
+
ListPayrollEmployeeLeaveBalancesTool,
|
|
122639
|
+
"NZ",
|
|
122640
|
+
async (args) => renderResult("Error listing employee leave balances", () => `AU leave balances for employee ${args.employeeId}:`, await listAuEmployeeLeaveBalances(args.employeeId))
|
|
122641
|
+
);
|
|
122118
122642
|
|
|
122119
122643
|
// src/handlers/list-xero-payroll-employee-leave-types.handler.ts
|
|
122120
122644
|
async function fetchEmployeeLeaveTypes(employeeId) {
|
|
@@ -122196,7 +122720,9 @@ var ListPayrollEmployeeLeaveTypesTool = CreateXeroTool(
|
|
|
122196
122720
|
};
|
|
122197
122721
|
}
|
|
122198
122722
|
);
|
|
122199
|
-
var list_payroll_employee_leave_types_tool_default = ListPayrollEmployeeLeaveTypesTool
|
|
122723
|
+
var list_payroll_employee_leave_types_tool_default = withPayrollRegion(ListPayrollEmployeeLeaveTypesTool, "NZ", {
|
|
122724
|
+
unavailable: "For Australian payroll, use list-payroll-employee-leave-balances, which lists each leave type the employee holds with its balance."
|
|
122725
|
+
});
|
|
122200
122726
|
|
|
122201
122727
|
// src/handlers/list-xero-payroll-employee-leave.handler.ts
|
|
122202
122728
|
async function fetchEmployeeLeave({ employeeId }) {
|
|
@@ -122279,7 +122805,11 @@ var ListPayrollEmployeeLeaveTool = CreateXeroTool(
|
|
|
122279
122805
|
};
|
|
122280
122806
|
}
|
|
122281
122807
|
);
|
|
122282
|
-
var list_payroll_employee_leave_tool_default =
|
|
122808
|
+
var list_payroll_employee_leave_tool_default = withPayrollRegion(
|
|
122809
|
+
ListPayrollEmployeeLeaveTool,
|
|
122810
|
+
"NZ",
|
|
122811
|
+
async (args) => renderResult("Error listing employee leave", (r) => `Found ${r.leaveApplications.length} AU leave applications for employee ${args.employeeId}:`, await listAuEmployeeLeaveApplications(args.employeeId))
|
|
122812
|
+
);
|
|
122283
122813
|
|
|
122284
122814
|
// src/handlers/list-xero-payroll-employees.handler.ts
|
|
122285
122815
|
async function getPayrollEmployees() {
|
|
@@ -122357,7 +122887,11 @@ The response presents a complete overview of all staff currently registered in y
|
|
|
122357
122887
|
};
|
|
122358
122888
|
}
|
|
122359
122889
|
);
|
|
122360
|
-
var list_payroll_employees_tool_default =
|
|
122890
|
+
var list_payroll_employees_tool_default = withPayrollRegion(
|
|
122891
|
+
ListPayrollEmployeesTool,
|
|
122892
|
+
"NZ",
|
|
122893
|
+
async () => renderResult("Error listing payroll employees", (r) => `Found ${r.employees.length} AU payroll employees${r.truncated ? " (stopped at the page limit; there are more)" : ""}:`, await listAuPayrollEmployees())
|
|
122894
|
+
);
|
|
122361
122895
|
|
|
122362
122896
|
// src/handlers/list-xero-payroll-leave-periods.handler.ts
|
|
122363
122897
|
async function fetchLeavePeriods({
|
|
@@ -122446,7 +122980,9 @@ var ListPayrollLeavePeriodsToolTool = CreateXeroTool(
|
|
|
122446
122980
|
};
|
|
122447
122981
|
}
|
|
122448
122982
|
);
|
|
122449
|
-
var list_payroll_leave_periods_tool_default = ListPayrollLeavePeriodsToolTool
|
|
122983
|
+
var list_payroll_leave_periods_tool_default = withPayrollRegion(ListPayrollLeavePeriodsToolTool, "NZ", {
|
|
122984
|
+
unavailable: "Australian leave periods are part of each leave application: use list-payroll-employee-leave."
|
|
122985
|
+
});
|
|
122450
122986
|
|
|
122451
122987
|
// src/handlers/list-xero-payroll-leave-types.handler.ts
|
|
122452
122988
|
async function fetchLeaveTypes() {
|
|
@@ -122526,7 +123062,14 @@ var ListPayrollLeaveTypesTool = CreateXeroTool(
|
|
|
122526
123062
|
};
|
|
122527
123063
|
}
|
|
122528
123064
|
);
|
|
122529
|
-
var list_payroll_leave_types_tool_default =
|
|
123065
|
+
var list_payroll_leave_types_tool_default = withPayrollRegion(
|
|
123066
|
+
ListPayrollLeaveTypesTool,
|
|
123067
|
+
"NZ",
|
|
123068
|
+
async () => {
|
|
123069
|
+
const res = await listAuPayItems();
|
|
123070
|
+
return renderResult("Error listing leave types", () => "AU leave types (from pay items):", res.isError ? res : { ...res, result: { leaveTypes: res.result?.leaveTypes ?? [] } });
|
|
123071
|
+
}
|
|
123072
|
+
);
|
|
122530
123073
|
|
|
122531
123074
|
// src/handlers/list-xero-timesheets.handler.ts
|
|
122532
123075
|
async function getTimesheets() {
|
|
@@ -122597,7 +123140,11 @@ This retrieves comprehensive timesheet details including timesheet IDs, employee
|
|
|
122597
123140
|
};
|
|
122598
123141
|
}
|
|
122599
123142
|
);
|
|
122600
|
-
var list_payroll_timesheets_tool_default =
|
|
123143
|
+
var list_payroll_timesheets_tool_default = withPayrollRegion(
|
|
123144
|
+
ListPayrollTimesheetsTool,
|
|
123145
|
+
"NZ",
|
|
123146
|
+
async () => renderResult("Error listing timesheets", (r) => `Found ${r.timesheets.length} AU timesheets${r.truncated ? " (stopped at the page limit; there are more)" : ""}:`, await listAuPayrollTimesheets())
|
|
123147
|
+
);
|
|
122601
123148
|
|
|
122602
123149
|
// src/handlers/list-xero-profit-and-loss.handler.ts
|
|
122603
123150
|
async function fetchProfitAndLoss(fromDate, toDate, periods, timeframe, standardLayout, paymentsOnly, trackingCategoryID, trackingOptionID, trackingCategoryID2, trackingOptionID2) {
|
|
@@ -123322,6 +123869,9 @@ var list_repeating_invoices_tool_default = ListRepeatingInvoicesTool;
|
|
|
123322
123869
|
|
|
123323
123870
|
// src/tools/list/index.ts
|
|
123324
123871
|
var ListTools = [
|
|
123872
|
+
list_payroll_pay_runs_tool_default,
|
|
123873
|
+
list_payroll_calendars_tool_default,
|
|
123874
|
+
list_payroll_pay_items_tool_default,
|
|
123325
123875
|
list_accounts_tool_default,
|
|
123326
123876
|
list_contacts_tool_default,
|
|
123327
123877
|
list_credit_notes_tool_default,
|
|
@@ -123407,7 +123957,9 @@ var ApprovePayrollTimesheetTool = CreateXeroTool(
|
|
|
123407
123957
|
};
|
|
123408
123958
|
}
|
|
123409
123959
|
);
|
|
123410
|
-
var approve_payroll_timesheet_tool_default = ApprovePayrollTimesheetTool
|
|
123960
|
+
var approve_payroll_timesheet_tool_default = withPayrollRegion(ApprovePayrollTimesheetTool, "NZ", {
|
|
123961
|
+
unavailable: "Australian timesheet changes are not supported by this server yet: make them in Xero (Payroll > Timesheets)."
|
|
123962
|
+
});
|
|
123411
123963
|
|
|
123412
123964
|
// src/handlers/revert-xero-payroll-timesheet.handler.ts
|
|
123413
123965
|
async function revertTimesheet(timesheetID) {
|
|
@@ -123466,7 +124018,9 @@ var RevertPayrollTimesheetTool = CreateXeroTool(
|
|
|
123466
124018
|
};
|
|
123467
124019
|
}
|
|
123468
124020
|
);
|
|
123469
|
-
var revert_payroll_timesheet_tool_default = RevertPayrollTimesheetTool
|
|
124021
|
+
var revert_payroll_timesheet_tool_default = withPayrollRegion(RevertPayrollTimesheetTool, "NZ", {
|
|
124022
|
+
unavailable: "Australian timesheet changes are not supported by this server yet: make them in Xero (Payroll > Timesheets)."
|
|
124023
|
+
});
|
|
123470
124024
|
|
|
123471
124025
|
// src/handlers/update-xero-bank-transaction.handler.ts
|
|
123472
124026
|
var import_xero_node8 = __toESM(require_dist3(), 1);
|
|
@@ -124237,7 +124791,9 @@ var AddTimesheetLineTool = CreateXeroTool(
|
|
|
124237
124791
|
};
|
|
124238
124792
|
}
|
|
124239
124793
|
);
|
|
124240
|
-
var update_payroll_timesheet_add_line_tool_default = AddTimesheetLineTool
|
|
124794
|
+
var update_payroll_timesheet_add_line_tool_default = withPayrollRegion(AddTimesheetLineTool, "NZ", {
|
|
124795
|
+
unavailable: "Australian timesheet changes are not supported by this server yet: make them in Xero (Payroll > Timesheets)."
|
|
124796
|
+
});
|
|
124241
124797
|
|
|
124242
124798
|
// src/handlers/update-xero-payroll-timesheet-update-line.handler.ts
|
|
124243
124799
|
async function updateTimesheetLine(timesheetID, timesheetLineID, timesheetLine) {
|
|
@@ -124304,7 +124860,9 @@ var UpdatePayrollTimesheetLineTool = CreateXeroTool(
|
|
|
124304
124860
|
};
|
|
124305
124861
|
}
|
|
124306
124862
|
);
|
|
124307
|
-
var update_payroll_timesheet_update_line_tool_default = UpdatePayrollTimesheetLineTool
|
|
124863
|
+
var update_payroll_timesheet_update_line_tool_default = withPayrollRegion(UpdatePayrollTimesheetLineTool, "NZ", {
|
|
124864
|
+
unavailable: "Australian timesheet changes are not supported by this server yet: make them in Xero (Payroll > Timesheets)."
|
|
124865
|
+
});
|
|
124308
124866
|
|
|
124309
124867
|
// src/handlers/update-xero-manual-journal.handler.ts
|
|
124310
124868
|
async function updateManualJournal(narration, manualJournalID, manualJournalLines, date3, lineAmountTypes, status, url2, showOnCashBasisReports) {
|
|
@@ -125014,8 +125572,8 @@ var list_organisations_tool_default = ListOrganisationsTool;
|
|
|
125014
125572
|
|
|
125015
125573
|
// src/tools/tenant-scope.ts
|
|
125016
125574
|
var TENANT_ID_ARG_DESCRIPTION = "Optional. The Xero organisation id (tenant) to use. Needed only when this agent can use more than one Xero organisation; call list-organisations to see them. Defaults to the only allowed organisation.";
|
|
125017
|
-
function errorResult(
|
|
125018
|
-
return { content: [{ type: "text", text }], isError: true };
|
|
125575
|
+
function errorResult(text2) {
|
|
125576
|
+
return { content: [{ type: "text", text: text2 }], isError: true };
|
|
125019
125577
|
}
|
|
125020
125578
|
function withTenantScope(tool) {
|
|
125021
125579
|
const schema = tool.schema ?? {};
|