@casys/mcp-erpnext 0.1.8 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/mcp-erpnext.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -6808,13 +6809,13 @@ var require_dist = __commonJS({
6808
6809
  var require_identity = __commonJS({
6809
6810
  "node_modules/yaml/dist/nodes/identity.js"(exports) {
6810
6811
  "use strict";
6811
- var ALIAS = /* @__PURE__ */ Symbol.for("yaml.alias");
6812
- var DOC = /* @__PURE__ */ Symbol.for("yaml.document");
6813
- var MAP = /* @__PURE__ */ Symbol.for("yaml.map");
6814
- var PAIR = /* @__PURE__ */ Symbol.for("yaml.pair");
6815
- var SCALAR = /* @__PURE__ */ Symbol.for("yaml.scalar");
6816
- var SEQ = /* @__PURE__ */ Symbol.for("yaml.seq");
6817
- var NODE_TYPE = /* @__PURE__ */ Symbol.for("yaml.node.type");
6812
+ var ALIAS = Symbol.for("yaml.alias");
6813
+ var DOC = Symbol.for("yaml.document");
6814
+ var MAP = Symbol.for("yaml.map");
6815
+ var PAIR = Symbol.for("yaml.pair");
6816
+ var SCALAR = Symbol.for("yaml.scalar");
6817
+ var SEQ = Symbol.for("yaml.seq");
6818
+ var NODE_TYPE = Symbol.for("yaml.node.type");
6818
6819
  var isAlias = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === ALIAS;
6819
6820
  var isDocument = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === DOC;
6820
6821
  var isMap = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === MAP;
@@ -6866,9 +6867,9 @@ var require_visit = __commonJS({
6866
6867
  "node_modules/yaml/dist/visit.js"(exports) {
6867
6868
  "use strict";
6868
6869
  var identity = require_identity();
6869
- var BREAK = /* @__PURE__ */ Symbol("break visit");
6870
- var SKIP = /* @__PURE__ */ Symbol("skip children");
6871
- var REMOVE = /* @__PURE__ */ Symbol("remove node");
6870
+ var BREAK = Symbol("break visit");
6871
+ var SKIP = Symbol("skip children");
6872
+ var REMOVE = Symbol("remove node");
6872
6873
  function visit(node, visitor) {
6873
6874
  const visitor_ = initVisitor(visitor);
6874
6875
  if (identity.isDocument(node)) {
@@ -11412,12 +11413,12 @@ var require_resolve_flow_scalar = __commonJS({
11412
11413
  };
11413
11414
  }
11414
11415
  const valueEnd = offset + source.length;
11415
- const re = resolveEnd.resolveEnd(end, valueEnd, strict, onError);
11416
+ const re2 = resolveEnd.resolveEnd(end, valueEnd, strict, onError);
11416
11417
  return {
11417
11418
  value,
11418
11419
  type: _type,
11419
- comment: re.comment,
11420
- range: [offset, valueEnd, re.offset]
11420
+ comment: re2.comment,
11421
+ range: [offset, valueEnd, re2.offset]
11421
11422
  };
11422
11423
  }
11423
11424
  function plainValue(source, onError) {
@@ -11797,10 +11798,10 @@ var require_compose_node = __commonJS({
11797
11798
  if (alias.source.endsWith(":"))
11798
11799
  onError(offset + source.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", true);
11799
11800
  const valueEnd = offset + source.length;
11800
- const re = resolveEnd.resolveEnd(end, valueEnd, options.strict, onError);
11801
- alias.range = [offset, valueEnd, re.offset];
11802
- if (re.comment)
11803
- alias.comment = re.comment;
11801
+ const re2 = resolveEnd.resolveEnd(end, valueEnd, options.strict, onError);
11802
+ alias.range = [offset, valueEnd, re2.offset];
11803
+ if (re2.comment)
11804
+ alias.comment = re2.comment;
11804
11805
  return alias;
11805
11806
  }
11806
11807
  exports.composeEmptyNode = composeEmptyNode;
@@ -11841,10 +11842,10 @@ var require_compose_doc = __commonJS({
11841
11842
  }
11842
11843
  doc.contents = value ? composeNode.composeNode(ctx, value, props, onError) : composeNode.composeEmptyNode(ctx, props.end, start, null, props, onError);
11843
11844
  const contentEnd = doc.contents.range[2];
11844
- const re = resolveEnd.resolveEnd(end, contentEnd, false, onError);
11845
- if (re.comment)
11846
- doc.comment = re.comment;
11847
- doc.range = [offset, contentEnd, re.offset];
11845
+ const re2 = resolveEnd.resolveEnd(end, contentEnd, false, onError);
11846
+ if (re2.comment)
11847
+ doc.comment = re2.comment;
11848
+ doc.range = [offset, contentEnd, re2.offset];
11848
11849
  return doc;
11849
11850
  }
11850
11851
  exports.composeDoc = composeDoc;
@@ -12307,9 +12308,9 @@ var require_cst_stringify = __commonJS({
12307
12308
  var require_cst_visit = __commonJS({
12308
12309
  "node_modules/yaml/dist/parse/cst-visit.js"(exports) {
12309
12310
  "use strict";
12310
- var BREAK = /* @__PURE__ */ Symbol("break visit");
12311
- var SKIP = /* @__PURE__ */ Symbol("skip children");
12312
- var REMOVE = /* @__PURE__ */ Symbol("remove item");
12311
+ var BREAK = Symbol("break visit");
12312
+ var SKIP = Symbol("skip children");
12313
+ var REMOVE = Symbol("remove item");
12313
12314
  function visit(cst, visitor) {
12314
12315
  if ("type" in cst && cst.type === "document")
12315
12316
  cst = { start: cst.start, value: cst.value };
@@ -17801,6 +17802,7 @@ ZodNaN.create = (params) => {
17801
17802
  ...processCreateParams(params)
17802
17803
  });
17803
17804
  };
17805
+ var BRAND = Symbol("zod_brand");
17804
17806
  var ZodBranded = class extends ZodType {
17805
17807
  _parse(input) {
17806
17808
  const { ctx } = this._processInputParams(input);
@@ -18025,6 +18027,7 @@ function $constructor(name, initializer3, params) {
18025
18027
  Object.defineProperty(_, "name", { value: name });
18026
18028
  return _;
18027
18029
  }
18030
+ var $brand = Symbol("zod_brand");
18028
18031
  var $ZodAsyncError = class extends Error {
18029
18032
  constructor() {
18030
18033
  super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
@@ -18171,7 +18174,7 @@ function floatSafeRemainder2(val, step) {
18171
18174
  const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
18172
18175
  return valInt % stepInt / 10 ** decCount;
18173
18176
  }
18174
- var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
18177
+ var EVALUATING = Symbol("evaluating");
18175
18178
  function defineLazy(object3, key, getter) {
18176
18179
  let value = void 0;
18177
18180
  Object.defineProperty(object3, key, {
@@ -21698,6 +21701,8 @@ function en_default2() {
21698
21701
 
21699
21702
  // node_modules/zod/v4/core/registries.js
21700
21703
  var _a;
21704
+ var $output = Symbol("ZodOutput");
21705
+ var $input = Symbol("ZodInput");
21701
21706
  var $ZodRegistry = class {
21702
21707
  constructor() {
21703
21708
  this._map = /* @__PURE__ */ new WeakMap();
@@ -26555,7 +26560,7 @@ function isTerminal(status) {
26555
26560
  }
26556
26561
 
26557
26562
  // node_modules/zod-to-json-schema/dist/esm/Options.js
26558
- var ignoreOverride = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
26563
+ var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
26559
26564
  var defaultOptions = {
26560
26565
  name: void 0,
26561
26566
  $refStrategy: "root",
@@ -29525,7 +29530,7 @@ var Server = class extends Protocol {
29525
29530
  };
29526
29531
 
29527
29532
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
29528
- var COMPLETABLE_SYMBOL = /* @__PURE__ */ Symbol.for("mcp.completable");
29533
+ var COMPLETABLE_SYMBOL = Symbol.for("mcp.completable");
29529
29534
  function isCompletable(schema) {
29530
29535
  return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
29531
29536
  }
@@ -30591,6 +30596,9 @@ var handleParsingAllValues = (form, key, value) => {
30591
30596
  }
30592
30597
  };
30593
30598
  var handleParsingNestedValues = (form, key, value) => {
30599
+ if (/(?:^|\.)__proto__\./.test(key)) {
30600
+ return;
30601
+ }
30594
30602
  let nestedForm = form;
30595
30603
  const keys = key.split(".");
30596
30604
  keys.forEach((key2, index) => {
@@ -32203,7 +32211,7 @@ var RegExpRouter = class {
32203
32211
  }
32204
32212
  const paramCount = (path.match(/\/:/g) || []).length;
32205
32213
  if (/\*$/.test(path)) {
32206
- const re = buildWildcardRegExp(path);
32214
+ const re2 = buildWildcardRegExp(path);
32207
32215
  if (method === METHOD_NAME_ALL) {
32208
32216
  Object.keys(middleware).forEach((m) => {
32209
32217
  middleware[m][path] ||= findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
@@ -32214,14 +32222,14 @@ var RegExpRouter = class {
32214
32222
  Object.keys(middleware).forEach((m) => {
32215
32223
  if (method === METHOD_NAME_ALL || method === m) {
32216
32224
  Object.keys(middleware[m]).forEach((p) => {
32217
- re.test(p) && middleware[m][p].push([handler, paramCount]);
32225
+ re2.test(p) && middleware[m][p].push([handler, paramCount]);
32218
32226
  });
32219
32227
  }
32220
32228
  });
32221
32229
  Object.keys(routes).forEach((m) => {
32222
32230
  if (method === METHOD_NAME_ALL || method === m) {
32223
32231
  Object.keys(routes[m]).forEach(
32224
- (p) => re.test(p) && routes[m][p].push([handler, paramCount])
32232
+ (p) => re2.test(p) && routes[m][p].push([handler, paramCount])
32225
32233
  );
32226
32234
  }
32227
32235
  });
@@ -33319,11 +33327,758 @@ function collectBody(req, maxBytes) {
33319
33327
  });
33320
33328
  }
33321
33329
 
33330
+ // node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js
33331
+ var _globalThis = typeof globalThis === "object" ? globalThis : global;
33332
+
33333
+ // node_modules/@opentelemetry/api/build/esm/version.js
33334
+ var VERSION = "1.9.0";
33335
+
33336
+ // node_modules/@opentelemetry/api/build/esm/internal/semver.js
33337
+ var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
33338
+ function _makeCompatibilityCheck(ownVersion) {
33339
+ var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
33340
+ var rejectedVersions = /* @__PURE__ */ new Set();
33341
+ var myVersionMatch = ownVersion.match(re);
33342
+ if (!myVersionMatch) {
33343
+ return function() {
33344
+ return false;
33345
+ };
33346
+ }
33347
+ var ownVersionParsed = {
33348
+ major: +myVersionMatch[1],
33349
+ minor: +myVersionMatch[2],
33350
+ patch: +myVersionMatch[3],
33351
+ prerelease: myVersionMatch[4]
33352
+ };
33353
+ if (ownVersionParsed.prerelease != null) {
33354
+ return function isExactmatch(globalVersion) {
33355
+ return globalVersion === ownVersion;
33356
+ };
33357
+ }
33358
+ function _reject(v) {
33359
+ rejectedVersions.add(v);
33360
+ return false;
33361
+ }
33362
+ function _accept(v) {
33363
+ acceptedVersions.add(v);
33364
+ return true;
33365
+ }
33366
+ return function isCompatible2(globalVersion) {
33367
+ if (acceptedVersions.has(globalVersion)) {
33368
+ return true;
33369
+ }
33370
+ if (rejectedVersions.has(globalVersion)) {
33371
+ return false;
33372
+ }
33373
+ var globalVersionMatch = globalVersion.match(re);
33374
+ if (!globalVersionMatch) {
33375
+ return _reject(globalVersion);
33376
+ }
33377
+ var globalVersionParsed = {
33378
+ major: +globalVersionMatch[1],
33379
+ minor: +globalVersionMatch[2],
33380
+ patch: +globalVersionMatch[3],
33381
+ prerelease: globalVersionMatch[4]
33382
+ };
33383
+ if (globalVersionParsed.prerelease != null) {
33384
+ return _reject(globalVersion);
33385
+ }
33386
+ if (ownVersionParsed.major !== globalVersionParsed.major) {
33387
+ return _reject(globalVersion);
33388
+ }
33389
+ if (ownVersionParsed.major === 0) {
33390
+ if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
33391
+ return _accept(globalVersion);
33392
+ }
33393
+ return _reject(globalVersion);
33394
+ }
33395
+ if (ownVersionParsed.minor <= globalVersionParsed.minor) {
33396
+ return _accept(globalVersion);
33397
+ }
33398
+ return _reject(globalVersion);
33399
+ };
33400
+ }
33401
+ var isCompatible = _makeCompatibilityCheck(VERSION);
33402
+
33403
+ // node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
33404
+ var major = VERSION.split(".")[0];
33405
+ var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
33406
+ var _global = _globalThis;
33407
+ function registerGlobal(type, instance, diag, allowOverride) {
33408
+ var _a2;
33409
+ if (allowOverride === void 0) {
33410
+ allowOverride = false;
33411
+ }
33412
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a2 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a2 !== void 0 ? _a2 : {
33413
+ version: VERSION
33414
+ };
33415
+ if (!allowOverride && api[type]) {
33416
+ var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
33417
+ diag.error(err.stack || err.message);
33418
+ return false;
33419
+ }
33420
+ if (api.version !== VERSION) {
33421
+ var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
33422
+ diag.error(err.stack || err.message);
33423
+ return false;
33424
+ }
33425
+ api[type] = instance;
33426
+ diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
33427
+ return true;
33428
+ }
33429
+ function getGlobal(type) {
33430
+ var _a2, _b;
33431
+ var globalVersion = (_a2 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a2 === void 0 ? void 0 : _a2.version;
33432
+ if (!globalVersion || !isCompatible(globalVersion)) {
33433
+ return;
33434
+ }
33435
+ return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
33436
+ }
33437
+ function unregisterGlobal(type, diag) {
33438
+ diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
33439
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
33440
+ if (api) {
33441
+ delete api[type];
33442
+ }
33443
+ }
33444
+
33445
+ // node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
33446
+ var __read = function(o, n) {
33447
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
33448
+ if (!m) return o;
33449
+ var i = m.call(o), r, ar = [], e;
33450
+ try {
33451
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
33452
+ } catch (error2) {
33453
+ e = { error: error2 };
33454
+ } finally {
33455
+ try {
33456
+ if (r && !r.done && (m = i["return"])) m.call(i);
33457
+ } finally {
33458
+ if (e) throw e.error;
33459
+ }
33460
+ }
33461
+ return ar;
33462
+ };
33463
+ var __spreadArray = function(to, from, pack) {
33464
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
33465
+ if (ar || !(i in from)) {
33466
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
33467
+ ar[i] = from[i];
33468
+ }
33469
+ }
33470
+ return to.concat(ar || Array.prototype.slice.call(from));
33471
+ };
33472
+ var DiagComponentLogger = (
33473
+ /** @class */
33474
+ (function() {
33475
+ function DiagComponentLogger2(props) {
33476
+ this._namespace = props.namespace || "DiagComponentLogger";
33477
+ }
33478
+ DiagComponentLogger2.prototype.debug = function() {
33479
+ var args = [];
33480
+ for (var _i = 0; _i < arguments.length; _i++) {
33481
+ args[_i] = arguments[_i];
33482
+ }
33483
+ return logProxy("debug", this._namespace, args);
33484
+ };
33485
+ DiagComponentLogger2.prototype.error = function() {
33486
+ var args = [];
33487
+ for (var _i = 0; _i < arguments.length; _i++) {
33488
+ args[_i] = arguments[_i];
33489
+ }
33490
+ return logProxy("error", this._namespace, args);
33491
+ };
33492
+ DiagComponentLogger2.prototype.info = function() {
33493
+ var args = [];
33494
+ for (var _i = 0; _i < arguments.length; _i++) {
33495
+ args[_i] = arguments[_i];
33496
+ }
33497
+ return logProxy("info", this._namespace, args);
33498
+ };
33499
+ DiagComponentLogger2.prototype.warn = function() {
33500
+ var args = [];
33501
+ for (var _i = 0; _i < arguments.length; _i++) {
33502
+ args[_i] = arguments[_i];
33503
+ }
33504
+ return logProxy("warn", this._namespace, args);
33505
+ };
33506
+ DiagComponentLogger2.prototype.verbose = function() {
33507
+ var args = [];
33508
+ for (var _i = 0; _i < arguments.length; _i++) {
33509
+ args[_i] = arguments[_i];
33510
+ }
33511
+ return logProxy("verbose", this._namespace, args);
33512
+ };
33513
+ return DiagComponentLogger2;
33514
+ })()
33515
+ );
33516
+ function logProxy(funcName, namespace, args) {
33517
+ var logger = getGlobal("diag");
33518
+ if (!logger) {
33519
+ return;
33520
+ }
33521
+ args.unshift(namespace);
33522
+ return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
33523
+ }
33524
+
33525
+ // node_modules/@opentelemetry/api/build/esm/diag/types.js
33526
+ var DiagLogLevel;
33527
+ (function(DiagLogLevel2) {
33528
+ DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
33529
+ DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
33530
+ DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
33531
+ DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
33532
+ DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
33533
+ DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
33534
+ DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
33535
+ })(DiagLogLevel || (DiagLogLevel = {}));
33536
+
33537
+ // node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
33538
+ function createLogLevelDiagLogger(maxLevel, logger) {
33539
+ if (maxLevel < DiagLogLevel.NONE) {
33540
+ maxLevel = DiagLogLevel.NONE;
33541
+ } else if (maxLevel > DiagLogLevel.ALL) {
33542
+ maxLevel = DiagLogLevel.ALL;
33543
+ }
33544
+ logger = logger || {};
33545
+ function _filterFunc(funcName, theLevel) {
33546
+ var theFunc = logger[funcName];
33547
+ if (typeof theFunc === "function" && maxLevel >= theLevel) {
33548
+ return theFunc.bind(logger);
33549
+ }
33550
+ return function() {
33551
+ };
33552
+ }
33553
+ return {
33554
+ error: _filterFunc("error", DiagLogLevel.ERROR),
33555
+ warn: _filterFunc("warn", DiagLogLevel.WARN),
33556
+ info: _filterFunc("info", DiagLogLevel.INFO),
33557
+ debug: _filterFunc("debug", DiagLogLevel.DEBUG),
33558
+ verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
33559
+ };
33560
+ }
33561
+
33562
+ // node_modules/@opentelemetry/api/build/esm/api/diag.js
33563
+ var __read2 = function(o, n) {
33564
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
33565
+ if (!m) return o;
33566
+ var i = m.call(o), r, ar = [], e;
33567
+ try {
33568
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
33569
+ } catch (error2) {
33570
+ e = { error: error2 };
33571
+ } finally {
33572
+ try {
33573
+ if (r && !r.done && (m = i["return"])) m.call(i);
33574
+ } finally {
33575
+ if (e) throw e.error;
33576
+ }
33577
+ }
33578
+ return ar;
33579
+ };
33580
+ var __spreadArray2 = function(to, from, pack) {
33581
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
33582
+ if (ar || !(i in from)) {
33583
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
33584
+ ar[i] = from[i];
33585
+ }
33586
+ }
33587
+ return to.concat(ar || Array.prototype.slice.call(from));
33588
+ };
33589
+ var API_NAME = "diag";
33590
+ var DiagAPI = (
33591
+ /** @class */
33592
+ (function() {
33593
+ function DiagAPI2() {
33594
+ function _logProxy(funcName) {
33595
+ return function() {
33596
+ var args = [];
33597
+ for (var _i = 0; _i < arguments.length; _i++) {
33598
+ args[_i] = arguments[_i];
33599
+ }
33600
+ var logger = getGlobal("diag");
33601
+ if (!logger)
33602
+ return;
33603
+ return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
33604
+ };
33605
+ }
33606
+ var self = this;
33607
+ var setLogger = function(logger, optionsOrLogLevel) {
33608
+ var _a2, _b, _c;
33609
+ if (optionsOrLogLevel === void 0) {
33610
+ optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
33611
+ }
33612
+ if (logger === self) {
33613
+ var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
33614
+ self.error((_a2 = err.stack) !== null && _a2 !== void 0 ? _a2 : err.message);
33615
+ return false;
33616
+ }
33617
+ if (typeof optionsOrLogLevel === "number") {
33618
+ optionsOrLogLevel = {
33619
+ logLevel: optionsOrLogLevel
33620
+ };
33621
+ }
33622
+ var oldLogger = getGlobal("diag");
33623
+ var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
33624
+ if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
33625
+ var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
33626
+ oldLogger.warn("Current logger will be overwritten from " + stack);
33627
+ newLogger.warn("Current logger will overwrite one already registered from " + stack);
33628
+ }
33629
+ return registerGlobal("diag", newLogger, self, true);
33630
+ };
33631
+ self.setLogger = setLogger;
33632
+ self.disable = function() {
33633
+ unregisterGlobal(API_NAME, self);
33634
+ };
33635
+ self.createComponentLogger = function(options) {
33636
+ return new DiagComponentLogger(options);
33637
+ };
33638
+ self.verbose = _logProxy("verbose");
33639
+ self.debug = _logProxy("debug");
33640
+ self.info = _logProxy("info");
33641
+ self.warn = _logProxy("warn");
33642
+ self.error = _logProxy("error");
33643
+ }
33644
+ DiagAPI2.instance = function() {
33645
+ if (!this._instance) {
33646
+ this._instance = new DiagAPI2();
33647
+ }
33648
+ return this._instance;
33649
+ };
33650
+ return DiagAPI2;
33651
+ })()
33652
+ );
33653
+
33654
+ // node_modules/@opentelemetry/api/build/esm/context/context.js
33655
+ function createContextKey(description) {
33656
+ return Symbol.for(description);
33657
+ }
33658
+ var BaseContext = (
33659
+ /** @class */
33660
+ /* @__PURE__ */ (function() {
33661
+ function BaseContext2(parentContext) {
33662
+ var self = this;
33663
+ self._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
33664
+ self.getValue = function(key) {
33665
+ return self._currentContext.get(key);
33666
+ };
33667
+ self.setValue = function(key, value) {
33668
+ var context = new BaseContext2(self._currentContext);
33669
+ context._currentContext.set(key, value);
33670
+ return context;
33671
+ };
33672
+ self.deleteValue = function(key) {
33673
+ var context = new BaseContext2(self._currentContext);
33674
+ context._currentContext.delete(key);
33675
+ return context;
33676
+ };
33677
+ }
33678
+ return BaseContext2;
33679
+ })()
33680
+ );
33681
+ var ROOT_CONTEXT = new BaseContext();
33682
+
33683
+ // node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js
33684
+ var __read3 = function(o, n) {
33685
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
33686
+ if (!m) return o;
33687
+ var i = m.call(o), r, ar = [], e;
33688
+ try {
33689
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
33690
+ } catch (error2) {
33691
+ e = { error: error2 };
33692
+ } finally {
33693
+ try {
33694
+ if (r && !r.done && (m = i["return"])) m.call(i);
33695
+ } finally {
33696
+ if (e) throw e.error;
33697
+ }
33698
+ }
33699
+ return ar;
33700
+ };
33701
+ var __spreadArray3 = function(to, from, pack) {
33702
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
33703
+ if (ar || !(i in from)) {
33704
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
33705
+ ar[i] = from[i];
33706
+ }
33707
+ }
33708
+ return to.concat(ar || Array.prototype.slice.call(from));
33709
+ };
33710
+ var NoopContextManager = (
33711
+ /** @class */
33712
+ (function() {
33713
+ function NoopContextManager2() {
33714
+ }
33715
+ NoopContextManager2.prototype.active = function() {
33716
+ return ROOT_CONTEXT;
33717
+ };
33718
+ NoopContextManager2.prototype.with = function(_context, fn, thisArg) {
33719
+ var args = [];
33720
+ for (var _i = 3; _i < arguments.length; _i++) {
33721
+ args[_i - 3] = arguments[_i];
33722
+ }
33723
+ return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
33724
+ };
33725
+ NoopContextManager2.prototype.bind = function(_context, target) {
33726
+ return target;
33727
+ };
33728
+ NoopContextManager2.prototype.enable = function() {
33729
+ return this;
33730
+ };
33731
+ NoopContextManager2.prototype.disable = function() {
33732
+ return this;
33733
+ };
33734
+ return NoopContextManager2;
33735
+ })()
33736
+ );
33737
+
33738
+ // node_modules/@opentelemetry/api/build/esm/api/context.js
33739
+ var __read4 = function(o, n) {
33740
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
33741
+ if (!m) return o;
33742
+ var i = m.call(o), r, ar = [], e;
33743
+ try {
33744
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
33745
+ } catch (error2) {
33746
+ e = { error: error2 };
33747
+ } finally {
33748
+ try {
33749
+ if (r && !r.done && (m = i["return"])) m.call(i);
33750
+ } finally {
33751
+ if (e) throw e.error;
33752
+ }
33753
+ }
33754
+ return ar;
33755
+ };
33756
+ var __spreadArray4 = function(to, from, pack) {
33757
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
33758
+ if (ar || !(i in from)) {
33759
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
33760
+ ar[i] = from[i];
33761
+ }
33762
+ }
33763
+ return to.concat(ar || Array.prototype.slice.call(from));
33764
+ };
33765
+ var API_NAME2 = "context";
33766
+ var NOOP_CONTEXT_MANAGER = new NoopContextManager();
33767
+ var ContextAPI = (
33768
+ /** @class */
33769
+ (function() {
33770
+ function ContextAPI2() {
33771
+ }
33772
+ ContextAPI2.getInstance = function() {
33773
+ if (!this._instance) {
33774
+ this._instance = new ContextAPI2();
33775
+ }
33776
+ return this._instance;
33777
+ };
33778
+ ContextAPI2.prototype.setGlobalContextManager = function(contextManager) {
33779
+ return registerGlobal(API_NAME2, contextManager, DiagAPI.instance());
33780
+ };
33781
+ ContextAPI2.prototype.active = function() {
33782
+ return this._getContextManager().active();
33783
+ };
33784
+ ContextAPI2.prototype.with = function(context, fn, thisArg) {
33785
+ var _a2;
33786
+ var args = [];
33787
+ for (var _i = 3; _i < arguments.length; _i++) {
33788
+ args[_i - 3] = arguments[_i];
33789
+ }
33790
+ return (_a2 = this._getContextManager()).with.apply(_a2, __spreadArray4([context, fn, thisArg], __read4(args), false));
33791
+ };
33792
+ ContextAPI2.prototype.bind = function(context, target) {
33793
+ return this._getContextManager().bind(context, target);
33794
+ };
33795
+ ContextAPI2.prototype._getContextManager = function() {
33796
+ return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
33797
+ };
33798
+ ContextAPI2.prototype.disable = function() {
33799
+ this._getContextManager().disable();
33800
+ unregisterGlobal(API_NAME2, DiagAPI.instance());
33801
+ };
33802
+ return ContextAPI2;
33803
+ })()
33804
+ );
33805
+
33806
+ // node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js
33807
+ var TraceFlags;
33808
+ (function(TraceFlags2) {
33809
+ TraceFlags2[TraceFlags2["NONE"] = 0] = "NONE";
33810
+ TraceFlags2[TraceFlags2["SAMPLED"] = 1] = "SAMPLED";
33811
+ })(TraceFlags || (TraceFlags = {}));
33812
+
33813
+ // node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js
33814
+ var INVALID_SPANID = "0000000000000000";
33815
+ var INVALID_TRACEID = "00000000000000000000000000000000";
33816
+ var INVALID_SPAN_CONTEXT = {
33817
+ traceId: INVALID_TRACEID,
33818
+ spanId: INVALID_SPANID,
33819
+ traceFlags: TraceFlags.NONE
33820
+ };
33821
+
33822
+ // node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js
33823
+ var NonRecordingSpan = (
33824
+ /** @class */
33825
+ (function() {
33826
+ function NonRecordingSpan2(_spanContext) {
33827
+ if (_spanContext === void 0) {
33828
+ _spanContext = INVALID_SPAN_CONTEXT;
33829
+ }
33830
+ this._spanContext = _spanContext;
33831
+ }
33832
+ NonRecordingSpan2.prototype.spanContext = function() {
33833
+ return this._spanContext;
33834
+ };
33835
+ NonRecordingSpan2.prototype.setAttribute = function(_key, _value) {
33836
+ return this;
33837
+ };
33838
+ NonRecordingSpan2.prototype.setAttributes = function(_attributes) {
33839
+ return this;
33840
+ };
33841
+ NonRecordingSpan2.prototype.addEvent = function(_name, _attributes) {
33842
+ return this;
33843
+ };
33844
+ NonRecordingSpan2.prototype.addLink = function(_link) {
33845
+ return this;
33846
+ };
33847
+ NonRecordingSpan2.prototype.addLinks = function(_links) {
33848
+ return this;
33849
+ };
33850
+ NonRecordingSpan2.prototype.setStatus = function(_status) {
33851
+ return this;
33852
+ };
33853
+ NonRecordingSpan2.prototype.updateName = function(_name) {
33854
+ return this;
33855
+ };
33856
+ NonRecordingSpan2.prototype.end = function(_endTime) {
33857
+ };
33858
+ NonRecordingSpan2.prototype.isRecording = function() {
33859
+ return false;
33860
+ };
33861
+ NonRecordingSpan2.prototype.recordException = function(_exception, _time) {
33862
+ };
33863
+ return NonRecordingSpan2;
33864
+ })()
33865
+ );
33866
+
33867
+ // node_modules/@opentelemetry/api/build/esm/trace/context-utils.js
33868
+ var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
33869
+ function getSpan(context) {
33870
+ return context.getValue(SPAN_KEY) || void 0;
33871
+ }
33872
+ function getActiveSpan() {
33873
+ return getSpan(ContextAPI.getInstance().active());
33874
+ }
33875
+ function setSpan(context, span) {
33876
+ return context.setValue(SPAN_KEY, span);
33877
+ }
33878
+ function deleteSpan(context) {
33879
+ return context.deleteValue(SPAN_KEY);
33880
+ }
33881
+ function setSpanContext(context, spanContext) {
33882
+ return setSpan(context, new NonRecordingSpan(spanContext));
33883
+ }
33884
+ function getSpanContext(context) {
33885
+ var _a2;
33886
+ return (_a2 = getSpan(context)) === null || _a2 === void 0 ? void 0 : _a2.spanContext();
33887
+ }
33888
+
33889
+ // node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
33890
+ var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
33891
+ var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
33892
+ function isValidTraceId(traceId) {
33893
+ return VALID_TRACEID_REGEX.test(traceId) && traceId !== INVALID_TRACEID;
33894
+ }
33895
+ function isValidSpanId(spanId) {
33896
+ return VALID_SPANID_REGEX.test(spanId) && spanId !== INVALID_SPANID;
33897
+ }
33898
+ function isSpanContextValid(spanContext) {
33899
+ return isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);
33900
+ }
33901
+ function wrapSpanContext(spanContext) {
33902
+ return new NonRecordingSpan(spanContext);
33903
+ }
33904
+
33905
+ // node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js
33906
+ var contextApi = ContextAPI.getInstance();
33907
+ var NoopTracer = (
33908
+ /** @class */
33909
+ (function() {
33910
+ function NoopTracer2() {
33911
+ }
33912
+ NoopTracer2.prototype.startSpan = function(name, options, context) {
33913
+ if (context === void 0) {
33914
+ context = contextApi.active();
33915
+ }
33916
+ var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
33917
+ if (root) {
33918
+ return new NonRecordingSpan();
33919
+ }
33920
+ var parentFromContext = context && getSpanContext(context);
33921
+ if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
33922
+ return new NonRecordingSpan(parentFromContext);
33923
+ } else {
33924
+ return new NonRecordingSpan();
33925
+ }
33926
+ };
33927
+ NoopTracer2.prototype.startActiveSpan = function(name, arg2, arg3, arg4) {
33928
+ var opts;
33929
+ var ctx;
33930
+ var fn;
33931
+ if (arguments.length < 2) {
33932
+ return;
33933
+ } else if (arguments.length === 2) {
33934
+ fn = arg2;
33935
+ } else if (arguments.length === 3) {
33936
+ opts = arg2;
33937
+ fn = arg3;
33938
+ } else {
33939
+ opts = arg2;
33940
+ ctx = arg3;
33941
+ fn = arg4;
33942
+ }
33943
+ var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
33944
+ var span = this.startSpan(name, opts, parentContext);
33945
+ var contextWithSpanSet = setSpan(parentContext, span);
33946
+ return contextApi.with(contextWithSpanSet, fn, void 0, span);
33947
+ };
33948
+ return NoopTracer2;
33949
+ })()
33950
+ );
33951
+ function isSpanContext(spanContext) {
33952
+ return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
33953
+ }
33954
+
33955
+ // node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js
33956
+ var NOOP_TRACER = new NoopTracer();
33957
+ var ProxyTracer = (
33958
+ /** @class */
33959
+ (function() {
33960
+ function ProxyTracer2(_provider, name, version2, options) {
33961
+ this._provider = _provider;
33962
+ this.name = name;
33963
+ this.version = version2;
33964
+ this.options = options;
33965
+ }
33966
+ ProxyTracer2.prototype.startSpan = function(name, options, context) {
33967
+ return this._getTracer().startSpan(name, options, context);
33968
+ };
33969
+ ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
33970
+ var tracer = this._getTracer();
33971
+ return Reflect.apply(tracer.startActiveSpan, tracer, arguments);
33972
+ };
33973
+ ProxyTracer2.prototype._getTracer = function() {
33974
+ if (this._delegate) {
33975
+ return this._delegate;
33976
+ }
33977
+ var tracer = this._provider.getDelegateTracer(this.name, this.version, this.options);
33978
+ if (!tracer) {
33979
+ return NOOP_TRACER;
33980
+ }
33981
+ this._delegate = tracer;
33982
+ return this._delegate;
33983
+ };
33984
+ return ProxyTracer2;
33985
+ })()
33986
+ );
33987
+
33988
+ // node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js
33989
+ var NoopTracerProvider = (
33990
+ /** @class */
33991
+ (function() {
33992
+ function NoopTracerProvider2() {
33993
+ }
33994
+ NoopTracerProvider2.prototype.getTracer = function(_name, _version, _options) {
33995
+ return new NoopTracer();
33996
+ };
33997
+ return NoopTracerProvider2;
33998
+ })()
33999
+ );
34000
+
34001
+ // node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js
34002
+ var NOOP_TRACER_PROVIDER = new NoopTracerProvider();
34003
+ var ProxyTracerProvider = (
34004
+ /** @class */
34005
+ (function() {
34006
+ function ProxyTracerProvider2() {
34007
+ }
34008
+ ProxyTracerProvider2.prototype.getTracer = function(name, version2, options) {
34009
+ var _a2;
34010
+ return (_a2 = this.getDelegateTracer(name, version2, options)) !== null && _a2 !== void 0 ? _a2 : new ProxyTracer(this, name, version2, options);
34011
+ };
34012
+ ProxyTracerProvider2.prototype.getDelegate = function() {
34013
+ var _a2;
34014
+ return (_a2 = this._delegate) !== null && _a2 !== void 0 ? _a2 : NOOP_TRACER_PROVIDER;
34015
+ };
34016
+ ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
34017
+ this._delegate = delegate;
34018
+ };
34019
+ ProxyTracerProvider2.prototype.getDelegateTracer = function(name, version2, options) {
34020
+ var _a2;
34021
+ return (_a2 = this._delegate) === null || _a2 === void 0 ? void 0 : _a2.getTracer(name, version2, options);
34022
+ };
34023
+ return ProxyTracerProvider2;
34024
+ })()
34025
+ );
34026
+
34027
+ // node_modules/@opentelemetry/api/build/esm/trace/status.js
34028
+ var SpanStatusCode;
34029
+ (function(SpanStatusCode2) {
34030
+ SpanStatusCode2[SpanStatusCode2["UNSET"] = 0] = "UNSET";
34031
+ SpanStatusCode2[SpanStatusCode2["OK"] = 1] = "OK";
34032
+ SpanStatusCode2[SpanStatusCode2["ERROR"] = 2] = "ERROR";
34033
+ })(SpanStatusCode || (SpanStatusCode = {}));
34034
+
34035
+ // node_modules/@opentelemetry/api/build/esm/api/trace.js
34036
+ var API_NAME3 = "trace";
34037
+ var TraceAPI = (
34038
+ /** @class */
34039
+ (function() {
34040
+ function TraceAPI2() {
34041
+ this._proxyTracerProvider = new ProxyTracerProvider();
34042
+ this.wrapSpanContext = wrapSpanContext;
34043
+ this.isSpanContextValid = isSpanContextValid;
34044
+ this.deleteSpan = deleteSpan;
34045
+ this.getSpan = getSpan;
34046
+ this.getActiveSpan = getActiveSpan;
34047
+ this.getSpanContext = getSpanContext;
34048
+ this.setSpan = setSpan;
34049
+ this.setSpanContext = setSpanContext;
34050
+ }
34051
+ TraceAPI2.getInstance = function() {
34052
+ if (!this._instance) {
34053
+ this._instance = new TraceAPI2();
34054
+ }
34055
+ return this._instance;
34056
+ };
34057
+ TraceAPI2.prototype.setGlobalTracerProvider = function(provider) {
34058
+ var success2 = registerGlobal(API_NAME3, this._proxyTracerProvider, DiagAPI.instance());
34059
+ if (success2) {
34060
+ this._proxyTracerProvider.setDelegate(provider);
34061
+ }
34062
+ return success2;
34063
+ };
34064
+ TraceAPI2.prototype.getTracerProvider = function() {
34065
+ return getGlobal(API_NAME3) || this._proxyTracerProvider;
34066
+ };
34067
+ TraceAPI2.prototype.getTracer = function(name, version2) {
34068
+ return this.getTracerProvider().getTracer(name, version2);
34069
+ };
34070
+ TraceAPI2.prototype.disable = function() {
34071
+ unregisterGlobal(API_NAME3, DiagAPI.instance());
34072
+ this._proxyTracerProvider = new ProxyTracerProvider();
34073
+ };
34074
+ return TraceAPI2;
34075
+ })()
34076
+ );
34077
+
34078
+ // node_modules/@opentelemetry/api/build/esm/trace-api.js
34079
+ var trace = TraceAPI.getInstance();
34080
+
33322
34081
  // node_modules/@casys/mcp-server/src/observability/otel.ts
33323
- import {
33324
- SpanStatusCode,
33325
- trace
33326
- } from "@opentelemetry/api";
33327
34082
  var serverTracer = null;
33328
34083
  function getServerTracer() {
33329
34084
  if (!serverTracer) {
@@ -33549,98 +34304,17 @@ function decode3(input) {
33549
34304
  }
33550
34305
  }
33551
34306
 
33552
- // node_modules/jose/dist/webapi/util/errors.js
33553
- var JOSEError = class extends Error {
33554
- static code = "ERR_JOSE_GENERIC";
33555
- code = "ERR_JOSE_GENERIC";
33556
- constructor(message2, options) {
33557
- super(message2, options);
33558
- this.name = this.constructor.name;
33559
- Error.captureStackTrace?.(this, this.constructor);
33560
- }
33561
- };
33562
- var JWTClaimValidationFailed = class extends JOSEError {
33563
- static code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
33564
- code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
33565
- claim;
33566
- reason;
33567
- payload;
33568
- constructor(message2, payload, claim = "unspecified", reason = "unspecified") {
33569
- super(message2, { cause: { claim, reason, payload } });
33570
- this.claim = claim;
33571
- this.reason = reason;
33572
- this.payload = payload;
33573
- }
33574
- };
33575
- var JWTExpired = class extends JOSEError {
33576
- static code = "ERR_JWT_EXPIRED";
33577
- code = "ERR_JWT_EXPIRED";
33578
- claim;
33579
- reason;
33580
- payload;
33581
- constructor(message2, payload, claim = "unspecified", reason = "unspecified") {
33582
- super(message2, { cause: { claim, reason, payload } });
33583
- this.claim = claim;
33584
- this.reason = reason;
33585
- this.payload = payload;
33586
- }
33587
- };
33588
- var JOSEAlgNotAllowed = class extends JOSEError {
33589
- static code = "ERR_JOSE_ALG_NOT_ALLOWED";
33590
- code = "ERR_JOSE_ALG_NOT_ALLOWED";
33591
- };
33592
- var JOSENotSupported = class extends JOSEError {
33593
- static code = "ERR_JOSE_NOT_SUPPORTED";
33594
- code = "ERR_JOSE_NOT_SUPPORTED";
33595
- };
33596
- var JWSInvalid = class extends JOSEError {
33597
- static code = "ERR_JWS_INVALID";
33598
- code = "ERR_JWS_INVALID";
33599
- };
33600
- var JWTInvalid = class extends JOSEError {
33601
- static code = "ERR_JWT_INVALID";
33602
- code = "ERR_JWT_INVALID";
33603
- };
33604
- var JWKSInvalid = class extends JOSEError {
33605
- static code = "ERR_JWKS_INVALID";
33606
- code = "ERR_JWKS_INVALID";
33607
- };
33608
- var JWKSNoMatchingKey = class extends JOSEError {
33609
- static code = "ERR_JWKS_NO_MATCHING_KEY";
33610
- code = "ERR_JWKS_NO_MATCHING_KEY";
33611
- constructor(message2 = "no applicable key found in the JSON Web Key Set", options) {
33612
- super(message2, options);
33613
- }
33614
- };
33615
- var JWKSMultipleMatchingKeys = class extends JOSEError {
33616
- [Symbol.asyncIterator];
33617
- static code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
33618
- code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
33619
- constructor(message2 = "multiple matching keys found in the JSON Web Key Set", options) {
33620
- super(message2, options);
33621
- }
33622
- };
33623
- var JWKSTimeout = class extends JOSEError {
33624
- static code = "ERR_JWKS_TIMEOUT";
33625
- code = "ERR_JWKS_TIMEOUT";
33626
- constructor(message2 = "request timed out", options) {
33627
- super(message2, options);
33628
- }
33629
- };
33630
- var JWSSignatureVerificationFailed = class extends JOSEError {
33631
- static code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
33632
- code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
33633
- constructor(message2 = "signature verification failed", options) {
33634
- super(message2, options);
33635
- }
33636
- };
33637
-
33638
34307
  // node_modules/jose/dist/webapi/lib/crypto_key.js
33639
34308
  var unusable = (name, prop = "algorithm.name") => new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
33640
34309
  var isAlgorithm = (algorithm, name) => algorithm.name === name;
33641
34310
  function getHashLength(hash2) {
33642
34311
  return parseInt(hash2.name.slice(4), 10);
33643
34312
  }
34313
+ function checkHashLength(algorithm, expected) {
34314
+ const actual = getHashLength(algorithm.hash);
34315
+ if (actual !== expected)
34316
+ throw unusable(`SHA-${expected}`, "algorithm.hash");
34317
+ }
33644
34318
  function getNamedCurve(alg) {
33645
34319
  switch (alg) {
33646
34320
  case "ES256":
@@ -33665,10 +34339,7 @@ function checkSigCryptoKey(key, alg, usage) {
33665
34339
  case "HS512": {
33666
34340
  if (!isAlgorithm(key.algorithm, "HMAC"))
33667
34341
  throw unusable("HMAC");
33668
- const expected = parseInt(alg.slice(2), 10);
33669
- const actual = getHashLength(key.algorithm.hash);
33670
- if (actual !== expected)
33671
- throw unusable(`SHA-${expected}`, "algorithm.hash");
34342
+ checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
33672
34343
  break;
33673
34344
  }
33674
34345
  case "RS256":
@@ -33676,10 +34347,7 @@ function checkSigCryptoKey(key, alg, usage) {
33676
34347
  case "RS512": {
33677
34348
  if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5"))
33678
34349
  throw unusable("RSASSA-PKCS1-v1_5");
33679
- const expected = parseInt(alg.slice(2), 10);
33680
- const actual = getHashLength(key.algorithm.hash);
33681
- if (actual !== expected)
33682
- throw unusable(`SHA-${expected}`, "algorithm.hash");
34350
+ checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
33683
34351
  break;
33684
34352
  }
33685
34353
  case "PS256":
@@ -33687,10 +34355,7 @@ function checkSigCryptoKey(key, alg, usage) {
33687
34355
  case "PS512": {
33688
34356
  if (!isAlgorithm(key.algorithm, "RSA-PSS"))
33689
34357
  throw unusable("RSA-PSS");
33690
- const expected = parseInt(alg.slice(2), 10);
33691
- const actual = getHashLength(key.algorithm.hash);
33692
- if (actual !== expected)
33693
- throw unusable(`SHA-${expected}`, "algorithm.hash");
34358
+ checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
33694
34359
  break;
33695
34360
  }
33696
34361
  case "Ed25519":
@@ -33748,6 +34413,92 @@ function message(msg, actual, ...types) {
33748
34413
  var invalidKeyInput = (actual, ...types) => message("Key must be ", actual, ...types);
33749
34414
  var withAlg = (alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types);
33750
34415
 
34416
+ // node_modules/jose/dist/webapi/util/errors.js
34417
+ var JOSEError = class extends Error {
34418
+ static code = "ERR_JOSE_GENERIC";
34419
+ code = "ERR_JOSE_GENERIC";
34420
+ constructor(message2, options) {
34421
+ super(message2, options);
34422
+ this.name = this.constructor.name;
34423
+ Error.captureStackTrace?.(this, this.constructor);
34424
+ }
34425
+ };
34426
+ var JWTClaimValidationFailed = class extends JOSEError {
34427
+ static code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
34428
+ code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
34429
+ claim;
34430
+ reason;
34431
+ payload;
34432
+ constructor(message2, payload, claim = "unspecified", reason = "unspecified") {
34433
+ super(message2, { cause: { claim, reason, payload } });
34434
+ this.claim = claim;
34435
+ this.reason = reason;
34436
+ this.payload = payload;
34437
+ }
34438
+ };
34439
+ var JWTExpired = class extends JOSEError {
34440
+ static code = "ERR_JWT_EXPIRED";
34441
+ code = "ERR_JWT_EXPIRED";
34442
+ claim;
34443
+ reason;
34444
+ payload;
34445
+ constructor(message2, payload, claim = "unspecified", reason = "unspecified") {
34446
+ super(message2, { cause: { claim, reason, payload } });
34447
+ this.claim = claim;
34448
+ this.reason = reason;
34449
+ this.payload = payload;
34450
+ }
34451
+ };
34452
+ var JOSEAlgNotAllowed = class extends JOSEError {
34453
+ static code = "ERR_JOSE_ALG_NOT_ALLOWED";
34454
+ code = "ERR_JOSE_ALG_NOT_ALLOWED";
34455
+ };
34456
+ var JOSENotSupported = class extends JOSEError {
34457
+ static code = "ERR_JOSE_NOT_SUPPORTED";
34458
+ code = "ERR_JOSE_NOT_SUPPORTED";
34459
+ };
34460
+ var JWSInvalid = class extends JOSEError {
34461
+ static code = "ERR_JWS_INVALID";
34462
+ code = "ERR_JWS_INVALID";
34463
+ };
34464
+ var JWTInvalid = class extends JOSEError {
34465
+ static code = "ERR_JWT_INVALID";
34466
+ code = "ERR_JWT_INVALID";
34467
+ };
34468
+ var JWKSInvalid = class extends JOSEError {
34469
+ static code = "ERR_JWKS_INVALID";
34470
+ code = "ERR_JWKS_INVALID";
34471
+ };
34472
+ var JWKSNoMatchingKey = class extends JOSEError {
34473
+ static code = "ERR_JWKS_NO_MATCHING_KEY";
34474
+ code = "ERR_JWKS_NO_MATCHING_KEY";
34475
+ constructor(message2 = "no applicable key found in the JSON Web Key Set", options) {
34476
+ super(message2, options);
34477
+ }
34478
+ };
34479
+ var JWKSMultipleMatchingKeys = class extends JOSEError {
34480
+ [Symbol.asyncIterator];
34481
+ static code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
34482
+ code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
34483
+ constructor(message2 = "multiple matching keys found in the JSON Web Key Set", options) {
34484
+ super(message2, options);
34485
+ }
34486
+ };
34487
+ var JWKSTimeout = class extends JOSEError {
34488
+ static code = "ERR_JWKS_TIMEOUT";
34489
+ code = "ERR_JWKS_TIMEOUT";
34490
+ constructor(message2 = "request timed out", options) {
34491
+ super(message2, options);
34492
+ }
34493
+ };
34494
+ var JWSSignatureVerificationFailed = class extends JOSEError {
34495
+ static code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
34496
+ code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
34497
+ constructor(message2 = "signature verification failed", options) {
34498
+ super(message2, options);
34499
+ }
34500
+ };
34501
+
33751
34502
  // node_modules/jose/dist/webapi/lib/is_key_like.js
33752
34503
  var isCryptoKey = (key) => {
33753
34504
  if (key?.[Symbol.toStringTag] === "CryptoKey")
@@ -33761,7 +34512,31 @@ var isCryptoKey = (key) => {
33761
34512
  var isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject";
33762
34513
  var isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
33763
34514
 
33764
- // node_modules/jose/dist/webapi/lib/is_disjoint.js
34515
+ // node_modules/jose/dist/webapi/lib/helpers.js
34516
+ var unprotected = Symbol();
34517
+ function decodeBase64url(value, label, ErrorClass) {
34518
+ try {
34519
+ return decode3(value);
34520
+ } catch {
34521
+ throw new ErrorClass(`Failed to base64url decode the ${label}`);
34522
+ }
34523
+ }
34524
+
34525
+ // node_modules/jose/dist/webapi/lib/type_checks.js
34526
+ var isObjectLike = (value) => typeof value === "object" && value !== null;
34527
+ function isObject2(input) {
34528
+ if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") {
34529
+ return false;
34530
+ }
34531
+ if (Object.getPrototypeOf(input) === null) {
34532
+ return true;
34533
+ }
34534
+ let proto = input;
34535
+ while (Object.getPrototypeOf(proto) !== null) {
34536
+ proto = Object.getPrototypeOf(proto);
34537
+ }
34538
+ return Object.getPrototypeOf(input) === proto;
34539
+ }
33765
34540
  function isDisjoint(...headers) {
33766
34541
  const sources = headers.filter(Boolean);
33767
34542
  if (sources.length === 0 || sources.length === 1) {
@@ -33783,24 +34558,12 @@ function isDisjoint(...headers) {
33783
34558
  }
33784
34559
  return true;
33785
34560
  }
34561
+ var isJWK = (key) => isObject2(key) && typeof key.kty === "string";
34562
+ var isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
34563
+ var isPublicJWK = (key) => key.kty !== "oct" && key.d === void 0 && key.priv === void 0;
34564
+ var isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
33786
34565
 
33787
- // node_modules/jose/dist/webapi/lib/is_object.js
33788
- var isObjectLike = (value) => typeof value === "object" && value !== null;
33789
- function isObject2(input) {
33790
- if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") {
33791
- return false;
33792
- }
33793
- if (Object.getPrototypeOf(input) === null) {
33794
- return true;
33795
- }
33796
- let proto = input;
33797
- while (Object.getPrototypeOf(proto) !== null) {
33798
- proto = Object.getPrototypeOf(proto);
33799
- }
33800
- return Object.getPrototypeOf(input) === proto;
33801
- }
33802
-
33803
- // node_modules/jose/dist/webapi/lib/check_key_length.js
34566
+ // node_modules/jose/dist/webapi/lib/signing.js
33804
34567
  function checkKeyLength(alg, key) {
33805
34568
  if (alg.startsWith("RS") || alg.startsWith("PS")) {
33806
34569
  const { modulusLength } = key.algorithm;
@@ -33809,8 +34572,59 @@ function checkKeyLength(alg, key) {
33809
34572
  }
33810
34573
  }
33811
34574
  }
34575
+ function subtleAlgorithm(alg, algorithm) {
34576
+ const hash2 = `SHA-${alg.slice(-3)}`;
34577
+ switch (alg) {
34578
+ case "HS256":
34579
+ case "HS384":
34580
+ case "HS512":
34581
+ return { hash: hash2, name: "HMAC" };
34582
+ case "PS256":
34583
+ case "PS384":
34584
+ case "PS512":
34585
+ return { hash: hash2, name: "RSA-PSS", saltLength: parseInt(alg.slice(-3), 10) >> 3 };
34586
+ case "RS256":
34587
+ case "RS384":
34588
+ case "RS512":
34589
+ return { hash: hash2, name: "RSASSA-PKCS1-v1_5" };
34590
+ case "ES256":
34591
+ case "ES384":
34592
+ case "ES512":
34593
+ return { hash: hash2, name: "ECDSA", namedCurve: algorithm.namedCurve };
34594
+ case "Ed25519":
34595
+ case "EdDSA":
34596
+ return { name: "Ed25519" };
34597
+ case "ML-DSA-44":
34598
+ case "ML-DSA-65":
34599
+ case "ML-DSA-87":
34600
+ return { name: alg };
34601
+ default:
34602
+ throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
34603
+ }
34604
+ }
34605
+ async function getSigKey(alg, key, usage) {
34606
+ if (key instanceof Uint8Array) {
34607
+ if (!alg.startsWith("HS")) {
34608
+ throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
34609
+ }
34610
+ return crypto.subtle.importKey("raw", key, { hash: `SHA-${alg.slice(-3)}`, name: "HMAC" }, false, [usage]);
34611
+ }
34612
+ checkSigCryptoKey(key, alg, usage);
34613
+ return key;
34614
+ }
34615
+ async function verify(alg, key, signature, data) {
34616
+ const cryptoKey = await getSigKey(alg, key, "verify");
34617
+ checkKeyLength(alg, cryptoKey);
34618
+ const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);
34619
+ try {
34620
+ return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
34621
+ } catch {
34622
+ return false;
34623
+ }
34624
+ }
33812
34625
 
33813
34626
  // node_modules/jose/dist/webapi/lib/jwk_to_key.js
34627
+ var unsupportedAlg = 'Invalid or unsupported JWK "alg" (Algorithm) Parameter value';
33814
34628
  function subtleMapping(jwk) {
33815
34629
  let algorithm;
33816
34630
  let keyUsages;
@@ -33824,7 +34638,7 @@ function subtleMapping(jwk) {
33824
34638
  keyUsages = jwk.priv ? ["sign"] : ["verify"];
33825
34639
  break;
33826
34640
  default:
33827
- throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
34641
+ throw new JOSENotSupported(unsupportedAlg);
33828
34642
  }
33829
34643
  break;
33830
34644
  }
@@ -33853,22 +34667,19 @@ function subtleMapping(jwk) {
33853
34667
  keyUsages = jwk.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
33854
34668
  break;
33855
34669
  default:
33856
- throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
34670
+ throw new JOSENotSupported(unsupportedAlg);
33857
34671
  }
33858
34672
  break;
33859
34673
  }
33860
34674
  case "EC": {
33861
34675
  switch (jwk.alg) {
33862
34676
  case "ES256":
33863
- algorithm = { name: "ECDSA", namedCurve: "P-256" };
33864
- keyUsages = jwk.d ? ["sign"] : ["verify"];
33865
- break;
33866
34677
  case "ES384":
33867
- algorithm = { name: "ECDSA", namedCurve: "P-384" };
33868
- keyUsages = jwk.d ? ["sign"] : ["verify"];
33869
- break;
33870
34678
  case "ES512":
33871
- algorithm = { name: "ECDSA", namedCurve: "P-521" };
34679
+ algorithm = {
34680
+ name: "ECDSA",
34681
+ namedCurve: { ES256: "P-256", ES384: "P-384", ES512: "P-521" }[jwk.alg]
34682
+ };
33872
34683
  keyUsages = jwk.d ? ["sign"] : ["verify"];
33873
34684
  break;
33874
34685
  case "ECDH-ES":
@@ -33879,7 +34690,7 @@ function subtleMapping(jwk) {
33879
34690
  keyUsages = jwk.d ? ["deriveBits"] : [];
33880
34691
  break;
33881
34692
  default:
33882
- throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
34693
+ throw new JOSENotSupported(unsupportedAlg);
33883
34694
  }
33884
34695
  break;
33885
34696
  }
@@ -33898,7 +34709,7 @@ function subtleMapping(jwk) {
33898
34709
  keyUsages = jwk.d ? ["deriveBits"] : [];
33899
34710
  break;
33900
34711
  default:
33901
- throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
34712
+ throw new JOSENotSupported(unsupportedAlg);
33902
34713
  }
33903
34714
  break;
33904
34715
  }
@@ -33920,91 +34731,8 @@ async function jwkToKey(jwk) {
33920
34731
  return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
33921
34732
  }
33922
34733
 
33923
- // node_modules/jose/dist/webapi/key/import.js
33924
- async function importJWK(jwk, alg, options) {
33925
- if (!isObject2(jwk)) {
33926
- throw new TypeError("JWK must be an object");
33927
- }
33928
- let ext;
33929
- alg ??= jwk.alg;
33930
- ext ??= options?.extractable ?? jwk.ext;
33931
- switch (jwk.kty) {
33932
- case "oct":
33933
- if (typeof jwk.k !== "string" || !jwk.k) {
33934
- throw new TypeError('missing "k" (Key Value) Parameter value');
33935
- }
33936
- return decode3(jwk.k);
33937
- case "RSA":
33938
- if ("oth" in jwk && jwk.oth !== void 0) {
33939
- throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
33940
- }
33941
- return jwkToKey({ ...jwk, alg, ext });
33942
- case "AKP": {
33943
- if (typeof jwk.alg !== "string" || !jwk.alg) {
33944
- throw new TypeError('missing "alg" (Algorithm) Parameter value');
33945
- }
33946
- if (alg !== void 0 && alg !== jwk.alg) {
33947
- throw new TypeError("JWK alg and alg option value mismatch");
33948
- }
33949
- return jwkToKey({ ...jwk, ext });
33950
- }
33951
- case "EC":
33952
- case "OKP":
33953
- return jwkToKey({ ...jwk, alg, ext });
33954
- default:
33955
- throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
33956
- }
33957
- }
33958
-
33959
- // node_modules/jose/dist/webapi/lib/validate_crit.js
33960
- function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
33961
- if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) {
33962
- throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
33963
- }
33964
- if (!protectedHeader || protectedHeader.crit === void 0) {
33965
- return /* @__PURE__ */ new Set();
33966
- }
33967
- if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) {
33968
- throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
33969
- }
33970
- let recognized;
33971
- if (recognizedOption !== void 0) {
33972
- recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
33973
- } else {
33974
- recognized = recognizedDefault;
33975
- }
33976
- for (const parameter of protectedHeader.crit) {
33977
- if (!recognized.has(parameter)) {
33978
- throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
33979
- }
33980
- if (joseHeader[parameter] === void 0) {
33981
- throw new Err(`Extension Header Parameter "${parameter}" is missing`);
33982
- }
33983
- if (recognized.get(parameter) && protectedHeader[parameter] === void 0) {
33984
- throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
33985
- }
33986
- }
33987
- return new Set(protectedHeader.crit);
33988
- }
33989
-
33990
- // node_modules/jose/dist/webapi/lib/validate_algorithms.js
33991
- function validateAlgorithms(option, algorithms) {
33992
- if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) {
33993
- throw new TypeError(`"${option}" option must be an array of strings`);
33994
- }
33995
- if (!algorithms) {
33996
- return void 0;
33997
- }
33998
- return new Set(algorithms);
33999
- }
34000
-
34001
- // node_modules/jose/dist/webapi/lib/is_jwk.js
34002
- var isJWK = (key) => isObject2(key) && typeof key.kty === "string";
34003
- var isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
34004
- var isPublicJWK = (key) => key.kty !== "oct" && key.d === void 0 && key.priv === void 0;
34005
- var isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
34006
-
34007
34734
  // node_modules/jose/dist/webapi/lib/normalize_key.js
34735
+ var unusableForAlg = "given KeyObject instance cannot be used for this algorithm";
34008
34736
  var cache;
34009
34737
  var handleJWK = async (key, jwk, alg, freeze = false) => {
34010
34738
  cache ||= /* @__PURE__ */ new WeakMap();
@@ -34039,13 +34767,13 @@ var handleKeyObject = (keyObject, alg) => {
34039
34767
  case "ECDH-ES+A256KW":
34040
34768
  break;
34041
34769
  default:
34042
- throw new TypeError("given KeyObject instance cannot be used for this algorithm");
34770
+ throw new TypeError(unusableForAlg);
34043
34771
  }
34044
34772
  cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ["deriveBits"]);
34045
34773
  }
34046
34774
  if (keyObject.asymmetricKeyType === "ed25519") {
34047
34775
  if (alg !== "EdDSA" && alg !== "Ed25519") {
34048
- throw new TypeError("given KeyObject instance cannot be used for this algorithm");
34776
+ throw new TypeError(unusableForAlg);
34049
34777
  }
34050
34778
  cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
34051
34779
  isPublic ? "verify" : "sign"
@@ -34056,7 +34784,7 @@ var handleKeyObject = (keyObject, alg) => {
34056
34784
  case "ml-dsa-65":
34057
34785
  case "ml-dsa-87": {
34058
34786
  if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {
34059
- throw new TypeError("given KeyObject instance cannot be used for this algorithm");
34787
+ throw new TypeError(unusableForAlg);
34060
34788
  }
34061
34789
  cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
34062
34790
  isPublic ? "verify" : "sign"
@@ -34085,7 +34813,7 @@ var handleKeyObject = (keyObject, alg) => {
34085
34813
  hash2 = "SHA-512";
34086
34814
  break;
34087
34815
  default:
34088
- throw new TypeError("given KeyObject instance cannot be used for this algorithm");
34816
+ throw new TypeError(unusableForAlg);
34089
34817
  }
34090
34818
  if (alg.startsWith("RSA-OAEP")) {
34091
34819
  return keyObject.toCryptoKey({
@@ -34106,21 +34834,10 @@ var handleKeyObject = (keyObject, alg) => {
34106
34834
  ]);
34107
34835
  const namedCurve = nist.get(keyObject.asymmetricKeyDetails?.namedCurve);
34108
34836
  if (!namedCurve) {
34109
- throw new TypeError("given KeyObject instance cannot be used for this algorithm");
34110
- }
34111
- if (alg === "ES256" && namedCurve === "P-256") {
34112
- cryptoKey = keyObject.toCryptoKey({
34113
- name: "ECDSA",
34114
- namedCurve
34115
- }, extractable, [isPublic ? "verify" : "sign"]);
34837
+ throw new TypeError(unusableForAlg);
34116
34838
  }
34117
- if (alg === "ES384" && namedCurve === "P-384") {
34118
- cryptoKey = keyObject.toCryptoKey({
34119
- name: "ECDSA",
34120
- namedCurve
34121
- }, extractable, [isPublic ? "verify" : "sign"]);
34122
- }
34123
- if (alg === "ES512" && namedCurve === "P-521") {
34839
+ const expectedCurve = { ES256: "P-256", ES384: "P-384", ES512: "P-521" };
34840
+ if (expectedCurve[alg] && namedCurve === expectedCurve[alg]) {
34124
34841
  cryptoKey = keyObject.toCryptoKey({
34125
34842
  name: "ECDSA",
34126
34843
  namedCurve
@@ -34134,7 +34851,7 @@ var handleKeyObject = (keyObject, alg) => {
34134
34851
  }
34135
34852
  }
34136
34853
  if (!cryptoKey) {
34137
- throw new TypeError("given KeyObject instance cannot be used for this algorithm");
34854
+ throw new TypeError(unusableForAlg);
34138
34855
  }
34139
34856
  if (!cached2) {
34140
34857
  cache.set(keyObject, { [alg]: cryptoKey });
@@ -34175,6 +34892,84 @@ async function normalizeKey(key, alg) {
34175
34892
  throw new Error("unreachable");
34176
34893
  }
34177
34894
 
34895
+ // node_modules/jose/dist/webapi/key/import.js
34896
+ async function importJWK(jwk, alg, options) {
34897
+ if (!isObject2(jwk)) {
34898
+ throw new TypeError("JWK must be an object");
34899
+ }
34900
+ let ext;
34901
+ alg ??= jwk.alg;
34902
+ ext ??= options?.extractable ?? jwk.ext;
34903
+ switch (jwk.kty) {
34904
+ case "oct":
34905
+ if (typeof jwk.k !== "string" || !jwk.k) {
34906
+ throw new TypeError('missing "k" (Key Value) Parameter value');
34907
+ }
34908
+ return decode3(jwk.k);
34909
+ case "RSA":
34910
+ if ("oth" in jwk && jwk.oth !== void 0) {
34911
+ throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
34912
+ }
34913
+ return jwkToKey({ ...jwk, alg, ext });
34914
+ case "AKP": {
34915
+ if (typeof jwk.alg !== "string" || !jwk.alg) {
34916
+ throw new TypeError('missing "alg" (Algorithm) Parameter value');
34917
+ }
34918
+ if (alg !== void 0 && alg !== jwk.alg) {
34919
+ throw new TypeError("JWK alg and alg option value mismatch");
34920
+ }
34921
+ return jwkToKey({ ...jwk, ext });
34922
+ }
34923
+ case "EC":
34924
+ case "OKP":
34925
+ return jwkToKey({ ...jwk, alg, ext });
34926
+ default:
34927
+ throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
34928
+ }
34929
+ }
34930
+
34931
+ // node_modules/jose/dist/webapi/lib/validate_crit.js
34932
+ function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
34933
+ if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) {
34934
+ throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
34935
+ }
34936
+ if (!protectedHeader || protectedHeader.crit === void 0) {
34937
+ return /* @__PURE__ */ new Set();
34938
+ }
34939
+ if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) {
34940
+ throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
34941
+ }
34942
+ let recognized;
34943
+ if (recognizedOption !== void 0) {
34944
+ recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
34945
+ } else {
34946
+ recognized = recognizedDefault;
34947
+ }
34948
+ for (const parameter of protectedHeader.crit) {
34949
+ if (!recognized.has(parameter)) {
34950
+ throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
34951
+ }
34952
+ if (joseHeader[parameter] === void 0) {
34953
+ throw new Err(`Extension Header Parameter "${parameter}" is missing`);
34954
+ }
34955
+ if (recognized.get(parameter) && protectedHeader[parameter] === void 0) {
34956
+ throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
34957
+ }
34958
+ }
34959
+ return new Set(protectedHeader.crit);
34960
+ }
34961
+
34962
+ // node_modules/jose/dist/webapi/lib/validate_algorithms.js
34963
+ function validateAlgorithms(option, algorithms) {
34964
+ if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) {
34965
+ throw new TypeError(`"${option}" option must be an array of strings`);
34966
+ }
34967
+ if (!algorithms) {
34968
+ return void 0;
34969
+ }
34970
+ return new Set(algorithms);
34971
+ }
34972
+
34178
34973
  // node_modules/jose/dist/webapi/lib/check_key_type.js
34179
34974
  var tag = (key) => key?.[Symbol.toStringTag];
34180
34975
  var jwkMatchesOp = (alg, key, usage) => {
@@ -34295,62 +35090,6 @@ function checkKeyType(alg, key, usage) {
34295
35090
  }
34296
35091
  }
34297
35092
 
34298
- // node_modules/jose/dist/webapi/lib/subtle_dsa.js
34299
- function subtleAlgorithm(alg, algorithm) {
34300
- const hash2 = `SHA-${alg.slice(-3)}`;
34301
- switch (alg) {
34302
- case "HS256":
34303
- case "HS384":
34304
- case "HS512":
34305
- return { hash: hash2, name: "HMAC" };
34306
- case "PS256":
34307
- case "PS384":
34308
- case "PS512":
34309
- return { hash: hash2, name: "RSA-PSS", saltLength: parseInt(alg.slice(-3), 10) >> 3 };
34310
- case "RS256":
34311
- case "RS384":
34312
- case "RS512":
34313
- return { hash: hash2, name: "RSASSA-PKCS1-v1_5" };
34314
- case "ES256":
34315
- case "ES384":
34316
- case "ES512":
34317
- return { hash: hash2, name: "ECDSA", namedCurve: algorithm.namedCurve };
34318
- case "Ed25519":
34319
- case "EdDSA":
34320
- return { name: "Ed25519" };
34321
- case "ML-DSA-44":
34322
- case "ML-DSA-65":
34323
- case "ML-DSA-87":
34324
- return { name: alg };
34325
- default:
34326
- throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
34327
- }
34328
- }
34329
-
34330
- // node_modules/jose/dist/webapi/lib/get_sign_verify_key.js
34331
- async function getSigKey(alg, key, usage) {
34332
- if (key instanceof Uint8Array) {
34333
- if (!alg.startsWith("HS")) {
34334
- throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
34335
- }
34336
- return crypto.subtle.importKey("raw", key, { hash: `SHA-${alg.slice(-3)}`, name: "HMAC" }, false, [usage]);
34337
- }
34338
- checkSigCryptoKey(key, alg, usage);
34339
- return key;
34340
- }
34341
-
34342
- // node_modules/jose/dist/webapi/lib/verify.js
34343
- async function verify(alg, key, signature, data) {
34344
- const cryptoKey = await getSigKey(alg, key, "verify");
34345
- checkKeyLength(alg, cryptoKey);
34346
- const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);
34347
- try {
34348
- return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
34349
- } catch {
34350
- return false;
34351
- }
34352
- }
34353
-
34354
35093
  // node_modules/jose/dist/webapi/jws/flattened/verify.js
34355
35094
  async function flattenedVerify(jws, key, options) {
34356
35095
  if (!isObject2(jws)) {
@@ -34417,12 +35156,7 @@ async function flattenedVerify(jws, key, options) {
34417
35156
  }
34418
35157
  checkKeyType(alg, key, "verify");
34419
35158
  const data = concat(jws.protected !== void 0 ? encode3(jws.protected) : new Uint8Array(), encode3("."), typeof jws.payload === "string" ? b64 ? encode3(jws.payload) : encoder.encode(jws.payload) : jws.payload);
34420
- let signature;
34421
- try {
34422
- signature = decode3(jws.signature);
34423
- } catch {
34424
- throw new JWSInvalid("Failed to base64url decode the signature");
34425
- }
35159
+ const signature = decodeBase64url(jws.signature, "signature", JWSInvalid);
34426
35160
  const k = await normalizeKey(key, alg);
34427
35161
  const verified = await verify(alg, k, signature, data);
34428
35162
  if (!verified) {
@@ -34430,11 +35164,7 @@ async function flattenedVerify(jws, key, options) {
34430
35164
  }
34431
35165
  let payload;
34432
35166
  if (b64) {
34433
- try {
34434
- payload = decode3(jws.payload);
34435
- } catch {
34436
- throw new JWSInvalid("Failed to base64url decode the payload");
34437
- }
35167
+ payload = decodeBase64url(jws.payload, "payload", JWSInvalid);
34438
35168
  } else if (typeof jws.payload === "string") {
34439
35169
  payload = encoder.encode(jws.payload);
34440
35170
  } else {
@@ -34766,10 +35496,10 @@ function isCloudflareWorkers() {
34766
35496
  var USER_AGENT;
34767
35497
  if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
34768
35498
  const NAME = "jose";
34769
- const VERSION = "v6.1.3";
34770
- USER_AGENT = `${NAME}/${VERSION}`;
35499
+ const VERSION2 = "v6.2.1";
35500
+ USER_AGENT = `${NAME}/${VERSION2}`;
34771
35501
  }
34772
- var customFetch = /* @__PURE__ */ Symbol();
35502
+ var customFetch = Symbol();
34773
35503
  async function fetchJwks(url2, headers, signal, fetchImpl = fetch) {
34774
35504
  const response = await fetchImpl(url2, {
34775
35505
  method: "GET",
@@ -34791,7 +35521,7 @@ async function fetchJwks(url2, headers, signal, fetchImpl = fetch) {
34791
35521
  throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON");
34792
35522
  }
34793
35523
  }
34794
- var jwksCache = /* @__PURE__ */ Symbol();
35524
+ var jwksCache = Symbol();
34795
35525
  function isFreshJwksCache(input, cacheMaxAge) {
34796
35526
  if (typeof input !== "object" || input === null) {
34797
35527
  return false;
@@ -36585,22 +37315,6 @@ var ConcurrentMCPServer = class _ConcurrentMCPServer {
36585
37315
  });
36586
37316
  }
36587
37317
  }
36588
- if (method === "ping") {
36589
- return c.json({ jsonrpc: "2.0", id, result: {} });
36590
- }
36591
- if (method === "prompts/list") {
36592
- return c.json({ jsonrpc: "2.0", id, result: { prompts: [] } });
36593
- }
36594
- if (method === "logging/setLevel") {
36595
- return c.json({ jsonrpc: "2.0", id, result: {} });
36596
- }
36597
- if (method === "completion/complete") {
36598
- return c.json({
36599
- jsonrpc: "2.0",
36600
- id,
36601
- result: { completion: { values: [] } }
36602
- });
36603
- }
36604
37318
  if (method && !id) {
36605
37319
  return new Response(null, { status: 202 });
36606
37320
  }
@@ -40967,89 +41681,8 @@ var setupTools = [
40967
41681
  // src/tools/analytics.ts
40968
41682
  var CHART_UI = { ui: { resourceUri: "ui://mcp-erpnext/chart-viewer" } };
40969
41683
  var KPI_UI = { ui: { resourceUri: "ui://mcp-erpnext/kpi-viewer" } };
40970
- var PIPELINE_UI = { ui: { resourceUri: "ui://mcp-erpnext/order-pipeline-viewer" } };
40971
41684
  var FUNNEL_UI = { ui: { resourceUri: "ui://mcp-erpnext/funnel-viewer" } };
40972
41685
  var analyticsTools = [
40973
- // ── Order Pipeline ────────────────────────────────────────────────────────
40974
- {
40975
- name: "erpnext_order_pipeline",
40976
- _meta: PIPELINE_UI,
40977
- description: "Get sales orders grouped by workflow status as a kanban pipeline. Returns columns (Draft, Open, To Deliver, To Bill, Completed, Cancelled) with order count, total value, and individual order cards. Ideal for seeing the current state of your sales pipeline at a glance.",
40978
- category: "analytics",
40979
- inputSchema: {
40980
- type: "object",
40981
- properties: {
40982
- limit: { type: "number", description: "Max total orders to fetch (default 200)" },
40983
- customer: { type: "string", description: "Filter by customer name" },
40984
- exclude_cancelled: {
40985
- type: "boolean",
40986
- description: "Exclude cancelled orders from results (default false)"
40987
- }
40988
- }
40989
- },
40990
- handler: async (input, ctx) => {
40991
- const limit = input.limit ?? 200;
40992
- const filters = [];
40993
- if (input.customer) {
40994
- filters.push(["customer", "=", input.customer]);
40995
- }
40996
- if (input.exclude_cancelled) {
40997
- filters.push(["status", "!=", "Cancelled"]);
40998
- }
40999
- const orders = await ctx.client.list("Sales Order", {
41000
- fields: [
41001
- "name",
41002
- "customer",
41003
- "customer_name",
41004
- "status",
41005
- "grand_total",
41006
- "transaction_date",
41007
- "delivery_date"
41008
- ],
41009
- filters,
41010
- limit,
41011
- order_by: "modified desc"
41012
- });
41013
- const STATUS_MAP = {
41014
- "Draft": { label: "Draft", color: "#78716c" },
41015
- "Open": { label: "Open", color: "#fbbf24" },
41016
- "To Deliver and Bill": { label: "To Deliver", color: "#60a5fa" },
41017
- "To Bill": { label: "To Bill", color: "#c084fc" },
41018
- "Completed": { label: "Completed", color: "#4ade80" },
41019
- "Cancelled": { label: "Cancelled", color: "#f87171" }
41020
- };
41021
- const grouped = {};
41022
- for (const order of orders) {
41023
- const status = order.status ?? "Draft";
41024
- if (!grouped[status]) grouped[status] = [];
41025
- grouped[status].push(order);
41026
- }
41027
- const columns = Object.entries(STATUS_MAP).filter(([status]) => grouped[status]?.length > 0).map(([status, { label, color }]) => {
41028
- const statusOrders = grouped[status] ?? [];
41029
- return {
41030
- status,
41031
- label,
41032
- color,
41033
- count: statusOrders.length,
41034
- total: statusOrders.reduce((sum, o) => sum + (Number(o.grand_total) || 0), 0),
41035
- orders: statusOrders.map((o) => ({
41036
- name: o.name,
41037
- customer: o.customer_name ?? o.customer,
41038
- amount: Number(o.grand_total) || 0,
41039
- date: o.transaction_date,
41040
- delivery_date: o.delivery_date
41041
- }))
41042
- };
41043
- });
41044
- return {
41045
- title: "Sales Order Pipeline",
41046
- currency: "EUR",
41047
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
41048
- columns,
41049
- _meta: PIPELINE_UI
41050
- };
41051
- }
41052
- },
41053
41686
  // ── Stock Chart ───────────────────────────────────────────────────────────
41054
41687
  {
41055
41688
  name: "erpnext_stock_chart",
@@ -42232,79 +42865,625 @@ var analyticsTools = [
42232
42865
  _meta: CHART_UI
42233
42866
  };
42234
42867
  }
42868
+ }
42869
+ ];
42870
+
42871
+ // src/kanban/definitions.ts
42872
+ var KANBAN_BOARD_DEFINITIONS = [
42873
+ {
42874
+ doctype: "Task",
42875
+ title: "Task Board",
42876
+ adapterKey: "task",
42877
+ moveToolName: "erpnext_kanban_move_card"
42235
42878
  },
42236
- // ── Purchase Pipeline ─────────────────────────────────────────────────────
42237
42879
  {
42238
- name: "erpnext_purchase_pipeline",
42239
- _meta: PIPELINE_UI,
42240
- description: "Purchase Orders grouped by status as a kanban pipeline. Shows columns (Draft, To Receive, To Bill, Completed, Cancelled) with order count, total value, and individual order cards.",
42241
- category: "analytics",
42880
+ doctype: "Opportunity",
42881
+ title: "Opportunity Board",
42882
+ adapterKey: "opportunity",
42883
+ moveToolName: "erpnext_kanban_move_card"
42884
+ },
42885
+ {
42886
+ doctype: "Issue",
42887
+ title: "Issue Board",
42888
+ adapterKey: "issue",
42889
+ moveToolName: "erpnext_kanban_move_card"
42890
+ }
42891
+ ];
42892
+ function getKanbanBoardDefinition(doctype) {
42893
+ return KANBAN_BOARD_DEFINITIONS.find((definition) => definition.doctype === doctype);
42894
+ }
42895
+
42896
+ // src/kanban/adapters/task.ts
42897
+ var TASK_COLUMNS = [
42898
+ { id: "open", label: "Open", color: "#60a5fa", status: "Open" },
42899
+ { id: "working", label: "Working", color: "#f59e0b", status: "Working" },
42900
+ { id: "pending-review", label: "Pending Review", color: "#a78bfa", status: "Pending Review" },
42901
+ { id: "overdue", label: "Overdue", color: "#ef4444", status: "Overdue" },
42902
+ { id: "completed", label: "Completed", color: "#22c55e", status: "Completed" },
42903
+ { id: "cancelled", label: "Cancelled", color: "#78716c", status: "Cancelled" }
42904
+ ];
42905
+ var STATUS_BY_COLUMN = new Map(TASK_COLUMNS.map((column) => [column.id, column.status]));
42906
+ var COLUMN_BY_STATUS = new Map(TASK_COLUMNS.map((column) => [column.status, column.id]));
42907
+ var TASK_LIST_FIELDS = [
42908
+ "name",
42909
+ "subject",
42910
+ "project",
42911
+ "status",
42912
+ "priority",
42913
+ "progress"
42914
+ ];
42915
+ var TASK_ALLOWED_TRANSITIONS = [
42916
+ { fromColumn: "open", toColumn: "working", allowed: true, label: "Start work" },
42917
+ { fromColumn: "open", toColumn: "pending-review", allowed: true },
42918
+ { fromColumn: "open", toColumn: "completed", allowed: true },
42919
+ { fromColumn: "open", toColumn: "cancelled", allowed: true },
42920
+ { fromColumn: "working", toColumn: "open", allowed: true },
42921
+ { fromColumn: "working", toColumn: "pending-review", allowed: true, label: "Request review" },
42922
+ { fromColumn: "working", toColumn: "completed", allowed: true },
42923
+ { fromColumn: "working", toColumn: "cancelled", allowed: true },
42924
+ { fromColumn: "pending-review", toColumn: "working", allowed: true, label: "Resume work" },
42925
+ { fromColumn: "pending-review", toColumn: "completed", allowed: true, label: "Approve" },
42926
+ { fromColumn: "pending-review", toColumn: "open", allowed: true },
42927
+ { fromColumn: "pending-review", toColumn: "cancelled", allowed: true },
42928
+ { fromColumn: "completed", toColumn: "working", allowed: true, label: "Reopen" },
42929
+ { fromColumn: "completed", toColumn: "open", allowed: true },
42930
+ { fromColumn: "cancelled", toColumn: "open", allowed: true, label: "Reopen" }
42931
+ ];
42932
+ function buildTaskCard(row) {
42933
+ const status = String(row.status ?? "Open");
42934
+ const columnId = columnIdForTaskStatus(status);
42935
+ const priority = typeof row.priority === "string" ? row.priority : void 0;
42936
+ const progress = typeof row.progress === "number" ? row.progress : Number.isFinite(Number(row.progress)) ? Number(row.progress) : void 0;
42937
+ return {
42938
+ id: String(row.name ?? ""),
42939
+ title: String(row.subject ?? row.name ?? "Untitled task"),
42940
+ subtitle: typeof row.project === "string" ? row.project : void 0,
42941
+ columnId,
42942
+ accent: TASK_COLUMNS.find((column) => column.id === columnId)?.color,
42943
+ badges: priority ? [{ label: priority, tone: priorityTone(priority) }] : [],
42944
+ metrics: progress === void 0 ? [] : [{ label: "Progress", value: `${progress}%` }]
42945
+ };
42946
+ }
42947
+ function priorityTone(priority) {
42948
+ if (priority === "Urgent") return "error";
42949
+ if (priority === "High") return "warning";
42950
+ return "neutral";
42951
+ }
42952
+ function columnIdForTaskStatus(status) {
42953
+ return COLUMN_BY_STATUS.get(String(status ?? "Open")) ?? "open";
42954
+ }
42955
+ var taskKanbanAdapter = {
42956
+ doctype: "Task",
42957
+ getColumns() {
42958
+ return TASK_COLUMNS.map((column) => ({
42959
+ id: column.id,
42960
+ label: column.label,
42961
+ color: column.color,
42962
+ count: 0
42963
+ }));
42964
+ },
42965
+ getAllowedTransitions() {
42966
+ return TASK_ALLOWED_TRANSITIONS;
42967
+ },
42968
+ getListFields() {
42969
+ return TASK_LIST_FIELDS;
42970
+ },
42971
+ buildListFilters(input) {
42972
+ const filters = [];
42973
+ if (typeof input.project === "string" && input.project.length > 0) {
42974
+ filters.push(["project", "=", input.project]);
42975
+ }
42976
+ if (typeof input.priority === "string" && input.priority.length > 0) {
42977
+ filters.push(["priority", "=", input.priority]);
42978
+ }
42979
+ return filters;
42980
+ },
42981
+ buildCards(rows) {
42982
+ return rows.map(buildTaskCard);
42983
+ },
42984
+ validateTransition(move) {
42985
+ if (move.toColumn === "overdue") {
42986
+ return { allowed: false, reason: "Overdue is system-managed" };
42987
+ }
42988
+ const match2 = TASK_ALLOWED_TRANSITIONS.find(
42989
+ (transition) => transition.fromColumn === move.fromColumn && transition.toColumn === move.toColumn && transition.allowed
42990
+ );
42991
+ if (!match2) {
42992
+ return { allowed: false, reason: "Task transition is not allowed" };
42993
+ }
42994
+ return { allowed: true };
42995
+ },
42996
+ async executeMove(move, ctx) {
42997
+ const currentTask = await ctx.client.get("Task", move.cardId);
42998
+ const serverColumn = columnIdForTaskStatus(currentTask.status);
42999
+ if (serverColumn !== move.fromColumn) {
43000
+ return {
43001
+ ok: false,
43002
+ cardId: move.cardId,
43003
+ fromColumn: serverColumn,
43004
+ toColumn: move.toColumn,
43005
+ errorMessage: `Task moved on the server from ${move.fromColumn} to ${serverColumn}. Refresh the board and try again.`
43006
+ };
43007
+ }
43008
+ const validation = this.validateTransition(move);
43009
+ if (!validation.allowed) {
43010
+ return {
43011
+ ok: false,
43012
+ cardId: move.cardId,
43013
+ fromColumn: move.fromColumn,
43014
+ toColumn: move.toColumn,
43015
+ errorMessage: validation.reason
43016
+ };
43017
+ }
43018
+ const status = STATUS_BY_COLUMN.get(move.toColumn);
43019
+ if (!status) {
43020
+ return {
43021
+ ok: false,
43022
+ cardId: move.cardId,
43023
+ fromColumn: move.fromColumn,
43024
+ toColumn: move.toColumn,
43025
+ errorMessage: "Unknown Task column"
43026
+ };
43027
+ }
43028
+ const serverTask = await ctx.client.update("Task", move.cardId, { status });
43029
+ return {
43030
+ ok: true,
43031
+ cardId: move.cardId,
43032
+ fromColumn: serverColumn,
43033
+ toColumn: move.toColumn,
43034
+ serverCard: buildTaskCard(serverTask)
43035
+ };
43036
+ }
43037
+ };
43038
+
43039
+ // src/kanban/adapters/opportunity.ts
43040
+ var OPPORTUNITY_COLUMNS = [
43041
+ { id: "open", label: "Open", color: "#60a5fa", status: "Open" },
43042
+ { id: "replied", label: "Replied", color: "#f59e0b", status: "Replied" },
43043
+ { id: "quotation", label: "Quotation", color: "#a78bfa", status: "Quotation" },
43044
+ { id: "converted", label: "Converted", color: "#22c55e", status: "Converted" },
43045
+ { id: "closed", label: "Closed", color: "#64748b", status: "Closed" },
43046
+ { id: "lost", label: "Lost", color: "#ef4444", status: "Lost" }
43047
+ ];
43048
+ var STATUS_BY_COLUMN2 = new Map(OPPORTUNITY_COLUMNS.map((column) => [column.id, column.status]));
43049
+ var COLUMN_BY_STATUS2 = new Map(OPPORTUNITY_COLUMNS.map((column) => [column.status, column.id]));
43050
+ var OPPORTUNITY_LIST_FIELDS = [
43051
+ "name",
43052
+ "title",
43053
+ "opportunity_from",
43054
+ "party_name",
43055
+ "status",
43056
+ "opportunity_amount",
43057
+ "currency",
43058
+ "probability",
43059
+ "opportunity_owner"
43060
+ ];
43061
+ var OPPORTUNITY_ALLOWED_TRANSITIONS = [
43062
+ { fromColumn: "open", toColumn: "replied", allowed: true, label: "Reply" },
43063
+ { fromColumn: "open", toColumn: "quotation", allowed: true, label: "Send quotation" },
43064
+ { fromColumn: "open", toColumn: "converted", allowed: true, label: "Convert" },
43065
+ { fromColumn: "open", toColumn: "closed", allowed: true, label: "Close" },
43066
+ { fromColumn: "open", toColumn: "lost", allowed: true, label: "Mark lost" },
43067
+ { fromColumn: "replied", toColumn: "open", allowed: true, label: "Reopen" },
43068
+ { fromColumn: "replied", toColumn: "quotation", allowed: true, label: "Send quotation" },
43069
+ { fromColumn: "replied", toColumn: "converted", allowed: true, label: "Convert" },
43070
+ { fromColumn: "replied", toColumn: "closed", allowed: true, label: "Close" },
43071
+ { fromColumn: "replied", toColumn: "lost", allowed: true, label: "Mark lost" },
43072
+ { fromColumn: "quotation", toColumn: "open", allowed: true, label: "Reopen" },
43073
+ { fromColumn: "quotation", toColumn: "replied", allowed: true, label: "Resume conversation" },
43074
+ { fromColumn: "quotation", toColumn: "converted", allowed: true, label: "Convert" },
43075
+ { fromColumn: "quotation", toColumn: "closed", allowed: true, label: "Close" },
43076
+ { fromColumn: "quotation", toColumn: "lost", allowed: true, label: "Mark lost" },
43077
+ { fromColumn: "converted", toColumn: "open", allowed: true, label: "Reopen" },
43078
+ { fromColumn: "converted", toColumn: "closed", allowed: true, label: "Close" },
43079
+ { fromColumn: "closed", toColumn: "open", allowed: true, label: "Reopen" },
43080
+ { fromColumn: "closed", toColumn: "replied", allowed: true, label: "Resume" },
43081
+ { fromColumn: "lost", toColumn: "open", allowed: true, label: "Reopen" },
43082
+ { fromColumn: "lost", toColumn: "replied", allowed: true, label: "Resume" }
43083
+ ];
43084
+ function columnIdForOpportunityStatus(status) {
43085
+ return COLUMN_BY_STATUS2.get(String(status ?? "Open")) ?? "open";
43086
+ }
43087
+ function formatOpportunityAmount(amount, currency) {
43088
+ const numeric = Number(amount);
43089
+ if (!Number.isFinite(numeric)) return null;
43090
+ const currencyCode = typeof currency === "string" && currency.length > 0 ? currency : "Amount";
43091
+ return `${currencyCode} ${numeric}`;
43092
+ }
43093
+ function buildOpportunityCard(row) {
43094
+ const status = String(row.status ?? "Open");
43095
+ const columnId = columnIdForOpportunityStatus(status);
43096
+ const amountValue = formatOpportunityAmount(row.opportunity_amount, row.currency);
43097
+ const probability = Number(row.probability);
43098
+ const probabilityValue = Number.isFinite(probability) ? `${probability}%` : null;
43099
+ const title = typeof row.title === "string" && row.title.length > 0 ? row.title : typeof row.party_name === "string" && row.party_name.length > 0 ? row.party_name : String(row.name ?? "Untitled opportunity");
43100
+ return {
43101
+ id: String(row.name ?? ""),
43102
+ title,
43103
+ subtitle: typeof row.party_name === "string" ? row.party_name : void 0,
43104
+ columnId,
43105
+ accent: OPPORTUNITY_COLUMNS.find((column) => column.id === columnId)?.color,
43106
+ badges: typeof row.opportunity_from === "string" && row.opportunity_from.length > 0 ? [{ label: row.opportunity_from, tone: "neutral" }] : [],
43107
+ metrics: [
43108
+ ...amountValue ? [{ label: "Amount", value: amountValue }] : [],
43109
+ ...probabilityValue ? [{ label: "Probability", value: probabilityValue }] : []
43110
+ ]
43111
+ };
43112
+ }
43113
+ var opportunityKanbanAdapter = {
43114
+ doctype: "Opportunity",
43115
+ getColumns() {
43116
+ return OPPORTUNITY_COLUMNS.map((column) => ({
43117
+ id: column.id,
43118
+ label: column.label,
43119
+ color: column.color,
43120
+ count: 0
43121
+ }));
43122
+ },
43123
+ getAllowedTransitions() {
43124
+ return OPPORTUNITY_ALLOWED_TRANSITIONS;
43125
+ },
43126
+ getListFields() {
43127
+ return OPPORTUNITY_LIST_FIELDS;
43128
+ },
43129
+ buildListFilters(input) {
43130
+ const filters = [];
43131
+ if (typeof input.status === "string" && input.status.length > 0) {
43132
+ filters.push(["status", "=", input.status]);
43133
+ }
43134
+ if (typeof input.opportunity_owner === "string" && input.opportunity_owner.length > 0) {
43135
+ filters.push(["opportunity_owner", "=", input.opportunity_owner]);
43136
+ }
43137
+ if (typeof input.party_name === "string" && input.party_name.length > 0) {
43138
+ filters.push(["party_name", "=", input.party_name]);
43139
+ }
43140
+ return filters;
43141
+ },
43142
+ buildCards(rows) {
43143
+ return rows.map(buildOpportunityCard);
43144
+ },
43145
+ validateTransition(move) {
43146
+ const match2 = OPPORTUNITY_ALLOWED_TRANSITIONS.find(
43147
+ (transition) => transition.fromColumn === move.fromColumn && transition.toColumn === move.toColumn && transition.allowed
43148
+ );
43149
+ if (!match2) {
43150
+ return { allowed: false, reason: "Opportunity transition is not allowed" };
43151
+ }
43152
+ return { allowed: true };
43153
+ },
43154
+ async executeMove(move, ctx) {
43155
+ const currentOpportunity = await ctx.client.get("Opportunity", move.cardId);
43156
+ const serverColumn = columnIdForOpportunityStatus(currentOpportunity.status);
43157
+ if (serverColumn !== move.fromColumn) {
43158
+ return {
43159
+ ok: false,
43160
+ cardId: move.cardId,
43161
+ fromColumn: serverColumn,
43162
+ toColumn: move.toColumn,
43163
+ errorMessage: `Opportunity moved on the server from ${move.fromColumn} to ${serverColumn}. Refresh the board and try again.`
43164
+ };
43165
+ }
43166
+ const validation = this.validateTransition(move);
43167
+ if (!validation.allowed) {
43168
+ return {
43169
+ ok: false,
43170
+ cardId: move.cardId,
43171
+ fromColumn: move.fromColumn,
43172
+ toColumn: move.toColumn,
43173
+ errorMessage: validation.reason
43174
+ };
43175
+ }
43176
+ const status = STATUS_BY_COLUMN2.get(move.toColumn);
43177
+ if (!status) {
43178
+ return {
43179
+ ok: false,
43180
+ cardId: move.cardId,
43181
+ fromColumn: move.fromColumn,
43182
+ toColumn: move.toColumn,
43183
+ errorMessage: "Unknown Opportunity column"
43184
+ };
43185
+ }
43186
+ const serverOpportunity = await ctx.client.update("Opportunity", move.cardId, {
43187
+ status
43188
+ });
43189
+ return {
43190
+ ok: true,
43191
+ cardId: move.cardId,
43192
+ fromColumn: serverColumn,
43193
+ toColumn: move.toColumn,
43194
+ serverCard: buildOpportunityCard(serverOpportunity)
43195
+ };
43196
+ }
43197
+ };
43198
+
43199
+ // src/kanban/adapters/issue.ts
43200
+ var ISSUE_COLUMNS = [
43201
+ { id: "open", label: "Open", color: "#60a5fa", status: "Open" },
43202
+ { id: "replied", label: "Replied", color: "#f59e0b", status: "Replied" },
43203
+ { id: "on-hold", label: "On Hold", color: "#a78bfa", status: "On Hold" },
43204
+ { id: "resolved", label: "Resolved", color: "#22c55e", status: "Resolved" },
43205
+ { id: "closed", label: "Closed", color: "#64748b", status: "Closed" }
43206
+ ];
43207
+ var STATUS_BY_COLUMN3 = new Map(ISSUE_COLUMNS.map((column) => [column.id, column.status]));
43208
+ var COLUMN_BY_STATUS3 = new Map(ISSUE_COLUMNS.map((column) => [column.status, column.id]));
43209
+ var ISSUE_LIST_FIELDS = [
43210
+ "name",
43211
+ "subject",
43212
+ "status",
43213
+ "priority",
43214
+ "customer",
43215
+ "raised_by"
43216
+ ];
43217
+ var ISSUE_ALLOWED_TRANSITIONS = [
43218
+ { fromColumn: "open", toColumn: "replied", allowed: true, label: "Reply" },
43219
+ { fromColumn: "open", toColumn: "on-hold", allowed: true, label: "Put on hold" },
43220
+ { fromColumn: "open", toColumn: "resolved", allowed: true, label: "Resolve" },
43221
+ { fromColumn: "open", toColumn: "closed", allowed: true, label: "Close" },
43222
+ { fromColumn: "replied", toColumn: "open", allowed: true, label: "Reopen" },
43223
+ { fromColumn: "replied", toColumn: "on-hold", allowed: true, label: "Put on hold" },
43224
+ { fromColumn: "replied", toColumn: "resolved", allowed: true, label: "Resolve" },
43225
+ { fromColumn: "replied", toColumn: "closed", allowed: true, label: "Close" },
43226
+ { fromColumn: "on-hold", toColumn: "open", allowed: true, label: "Resume" },
43227
+ { fromColumn: "on-hold", toColumn: "replied", allowed: true, label: "Reply" },
43228
+ { fromColumn: "on-hold", toColumn: "resolved", allowed: true, label: "Resolve" },
43229
+ { fromColumn: "on-hold", toColumn: "closed", allowed: true, label: "Close" },
43230
+ { fromColumn: "resolved", toColumn: "open", allowed: true, label: "Reopen" },
43231
+ { fromColumn: "resolved", toColumn: "replied", allowed: true, label: "Reply" },
43232
+ { fromColumn: "resolved", toColumn: "closed", allowed: true, label: "Close" },
43233
+ { fromColumn: "closed", toColumn: "open", allowed: true, label: "Reopen" },
43234
+ { fromColumn: "closed", toColumn: "replied", allowed: true, label: "Reply" }
43235
+ ];
43236
+ function columnIdForIssueStatus(status) {
43237
+ return COLUMN_BY_STATUS3.get(String(status ?? "Open")) ?? "open";
43238
+ }
43239
+ function priorityTone2(priority) {
43240
+ if (priority === "Urgent") return "error";
43241
+ if (priority === "High") return "warning";
43242
+ return "neutral";
43243
+ }
43244
+ function buildIssueCard(row) {
43245
+ const status = String(row.status ?? "Open");
43246
+ const columnId = columnIdForIssueStatus(status);
43247
+ const priority = typeof row.priority === "string" ? row.priority : void 0;
43248
+ const subtitle = typeof row.customer === "string" && row.customer.length > 0 ? row.customer : typeof row.raised_by === "string" && row.raised_by.length > 0 ? row.raised_by : void 0;
43249
+ return {
43250
+ id: String(row.name ?? ""),
43251
+ title: String(row.subject ?? row.name ?? "Untitled issue"),
43252
+ subtitle,
43253
+ columnId,
43254
+ accent: ISSUE_COLUMNS.find((column) => column.id === columnId)?.color,
43255
+ badges: priority ? [{ label: priority, tone: priorityTone2(priority) }] : [],
43256
+ metrics: typeof row.raised_by === "string" && row.raised_by.length > 0 ? [{ label: "Raised By", value: row.raised_by }] : []
43257
+ };
43258
+ }
43259
+ var issueKanbanAdapter = {
43260
+ doctype: "Issue",
43261
+ getColumns() {
43262
+ return ISSUE_COLUMNS.map((column) => ({
43263
+ id: column.id,
43264
+ label: column.label,
43265
+ color: column.color,
43266
+ count: 0
43267
+ }));
43268
+ },
43269
+ getAllowedTransitions() {
43270
+ return ISSUE_ALLOWED_TRANSITIONS;
43271
+ },
43272
+ getListFields() {
43273
+ return ISSUE_LIST_FIELDS;
43274
+ },
43275
+ buildListFilters(input) {
43276
+ const filters = [];
43277
+ if (typeof input.status === "string" && input.status.length > 0) {
43278
+ filters.push(["status", "=", input.status]);
43279
+ }
43280
+ if (typeof input.priority === "string" && input.priority.length > 0) {
43281
+ filters.push(["priority", "=", input.priority]);
43282
+ }
43283
+ if (typeof input.customer === "string" && input.customer.length > 0) {
43284
+ filters.push(["customer", "=", input.customer]);
43285
+ }
43286
+ if (typeof input.raised_by === "string" && input.raised_by.length > 0) {
43287
+ filters.push(["raised_by", "=", input.raised_by]);
43288
+ }
43289
+ return filters;
43290
+ },
43291
+ buildCards(rows) {
43292
+ return rows.map(buildIssueCard);
43293
+ },
43294
+ validateTransition(move) {
43295
+ const match2 = ISSUE_ALLOWED_TRANSITIONS.find(
43296
+ (transition) => transition.fromColumn === move.fromColumn && transition.toColumn === move.toColumn && transition.allowed
43297
+ );
43298
+ if (!match2) {
43299
+ return { allowed: false, reason: "Issue transition is not allowed" };
43300
+ }
43301
+ return { allowed: true };
43302
+ },
43303
+ async executeMove(move, ctx) {
43304
+ const currentIssue = await ctx.client.get("Issue", move.cardId);
43305
+ const serverColumn = columnIdForIssueStatus(currentIssue.status);
43306
+ if (serverColumn !== move.fromColumn) {
43307
+ return {
43308
+ ok: false,
43309
+ cardId: move.cardId,
43310
+ fromColumn: serverColumn,
43311
+ toColumn: move.toColumn,
43312
+ errorMessage: `Issue moved on the server from ${move.fromColumn} to ${serverColumn}. Refresh the board and try again.`
43313
+ };
43314
+ }
43315
+ const validation = this.validateTransition(move);
43316
+ if (!validation.allowed) {
43317
+ return {
43318
+ ok: false,
43319
+ cardId: move.cardId,
43320
+ fromColumn: move.fromColumn,
43321
+ toColumn: move.toColumn,
43322
+ errorMessage: validation.reason
43323
+ };
43324
+ }
43325
+ const status = STATUS_BY_COLUMN3.get(move.toColumn);
43326
+ if (!status) {
43327
+ return {
43328
+ ok: false,
43329
+ cardId: move.cardId,
43330
+ fromColumn: move.fromColumn,
43331
+ toColumn: move.toColumn,
43332
+ errorMessage: "Unknown Issue column"
43333
+ };
43334
+ }
43335
+ const serverIssue = await ctx.client.update("Issue", move.cardId, { status });
43336
+ return {
43337
+ ok: true,
43338
+ cardId: move.cardId,
43339
+ fromColumn: serverColumn,
43340
+ toColumn: move.toColumn,
43341
+ serverCard: buildIssueCard(serverIssue)
43342
+ };
43343
+ }
43344
+ };
43345
+
43346
+ // src/tools/kanban.ts
43347
+ var KANBAN_UI = { ui: { resourceUri: "ui://mcp-erpnext/kanban-viewer" } };
43348
+ var ADAPTERS = {
43349
+ task: taskKanbanAdapter,
43350
+ opportunity: opportunityKanbanAdapter,
43351
+ issue: issueKanbanAdapter
43352
+ };
43353
+ function getAdapter(doctype) {
43354
+ const definition = getKanbanBoardDefinition(doctype);
43355
+ if (!definition) {
43356
+ throw new Error(`[erpnext_kanban] Unsupported kanban doctype: ${doctype}`);
43357
+ }
43358
+ const adapter = ADAPTERS[definition.adapterKey];
43359
+ if (!adapter) {
43360
+ throw new Error(`[erpnext_kanban] No adapter registered for ${doctype}`);
43361
+ }
43362
+ return { definition, adapter };
43363
+ }
43364
+ function withColumnCounts(columns, cards) {
43365
+ const counts = /* @__PURE__ */ new Map();
43366
+ for (const card of cards) {
43367
+ counts.set(card.columnId, (counts.get(card.columnId) ?? 0) + 1);
43368
+ }
43369
+ return columns.map((column) => ({
43370
+ ...column,
43371
+ count: counts.get(column.id) ?? 0
43372
+ }));
43373
+ }
43374
+ var kanbanTools = [
43375
+ {
43376
+ name: "erpnext_kanban_get_board",
43377
+ category: "kanban",
43378
+ _meta: KANBAN_UI,
43379
+ description: "Get a normalized kanban board for a supported ERPNext DocType. Supports Task, Opportunity, and Issue, with pagination and MCP App metadata.",
42242
43380
  inputSchema: {
42243
43381
  type: "object",
42244
43382
  properties: {
42245
- limit: { type: "number", description: "Max POs (default 200)" },
42246
- supplier: { type: "string", description: "Filter by supplier name" }
42247
- }
43383
+ doctype: {
43384
+ type: "string",
43385
+ description: "Kanban-enabled ERPNext DocType",
43386
+ enum: ["Task", "Opportunity", "Issue"]
43387
+ },
43388
+ limit: { type: "number", description: "Page size (default 50)" },
43389
+ offset: { type: "number", description: "Pagination offset (default 0)" },
43390
+ project: { type: "string", description: "Optional Task project filter" },
43391
+ priority: {
43392
+ type: "string",
43393
+ description: "Optional Task priority filter",
43394
+ enum: ["Low", "Medium", "High", "Urgent"]
43395
+ },
43396
+ status: {
43397
+ type: "string",
43398
+ description: "Optional Opportunity status filter",
43399
+ enum: ["Open", "Replied", "Quotation", "Converted", "Closed", "Lost"]
43400
+ },
43401
+ opportunity_owner: {
43402
+ type: "string",
43403
+ description: "Optional Opportunity owner filter"
43404
+ },
43405
+ party_name: {
43406
+ type: "string",
43407
+ description: "Optional Opportunity party filter"
43408
+ },
43409
+ customer: {
43410
+ type: "string",
43411
+ description: "Optional Issue customer filter"
43412
+ },
43413
+ raised_by: {
43414
+ type: "string",
43415
+ description: "Optional Issue reporter email filter"
43416
+ }
43417
+ },
43418
+ required: ["doctype"]
42248
43419
  },
42249
43420
  handler: async (input, ctx) => {
42250
- const limit = input.limit ?? 200;
42251
- const filters = [];
42252
- if (input.supplier) {
42253
- filters.push(["supplier_name", "=", input.supplier]);
42254
- }
42255
- const orders = await ctx.client.list("Purchase Order", {
42256
- fields: [
42257
- "name",
42258
- "supplier",
42259
- "supplier_name",
42260
- "status",
42261
- "grand_total",
42262
- "transaction_date",
42263
- "schedule_date"
42264
- ],
42265
- filters,
42266
- limit,
43421
+ const doctype = String(input.doctype ?? "");
43422
+ const { definition, adapter } = getAdapter(doctype);
43423
+ const limit = Math.max(1, Number(input.limit ?? 50));
43424
+ const offset = Math.max(0, Number(input.offset ?? 0));
43425
+ const rows = await ctx.client.list(doctype, {
43426
+ fields: adapter.getListFields(),
43427
+ filters: adapter.buildListFilters(input),
43428
+ limit: limit + 1,
43429
+ limit_start: offset,
42267
43430
  order_by: "modified desc"
42268
43431
  });
42269
- const STATUS_MAP = {
42270
- "Draft": { label: "Draft", color: "#78716c" },
42271
- "To Receive and Bill": { label: "To Receive", color: "#60a5fa" },
42272
- "To Receive": { label: "To Receive Only", color: "#fbbf24" },
42273
- "To Bill": { label: "To Bill", color: "#c084fc" },
42274
- "Completed": { label: "Completed", color: "#4ade80" },
42275
- "Cancelled": { label: "Cancelled", color: "#f87171" }
43432
+ const hasMore = rows.length > limit;
43433
+ const visibleRows = rows.slice(0, limit);
43434
+ const cards = adapter.buildCards(visibleRows);
43435
+ const board = {
43436
+ boardId: `${doctype.toLowerCase()}-board`,
43437
+ title: definition.title,
43438
+ doctype,
43439
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
43440
+ moveToolName: definition.moveToolName,
43441
+ refreshArguments: { ...input, doctype, limit, offset },
43442
+ columns: withColumnCounts(adapter.getColumns(), cards),
43443
+ cards,
43444
+ allowedTransitions: adapter.getAllowedTransitions(),
43445
+ capabilities: { canMoveCards: true },
43446
+ pagination: {
43447
+ limit,
43448
+ offset,
43449
+ loadedCount: offset + visibleRows.length,
43450
+ hasMore
43451
+ }
42276
43452
  };
42277
- const grouped = {};
42278
- for (const order of orders) {
42279
- const status = order.status ?? "Draft";
42280
- if (!grouped[status]) grouped[status] = [];
42281
- grouped[status].push(order);
42282
- }
42283
- const columns = Object.entries(STATUS_MAP).filter(([status]) => grouped[status]?.length > 0).map(([status, { label, color }]) => {
42284
- const statusOrders = grouped[status] ?? [];
42285
- return {
42286
- status,
42287
- label,
42288
- color,
42289
- count: statusOrders.length,
42290
- total: statusOrders.reduce((sum, o) => sum + (Number(o.grand_total) || 0), 0),
42291
- orders: statusOrders.map((o) => ({
42292
- name: o.name,
42293
- customer: o.supplier_name ?? o.supplier,
42294
- amount: Number(o.grand_total) || 0,
42295
- date: o.transaction_date,
42296
- delivery_date: o.schedule_date
42297
- }))
42298
- };
42299
- });
42300
43453
  return {
42301
- title: "Purchase Order Pipeline",
42302
- currency: "EUR",
42303
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
42304
- columns,
42305
- _meta: PIPELINE_UI
43454
+ ...board,
43455
+ _meta: KANBAN_UI
42306
43456
  };
42307
43457
  }
43458
+ },
43459
+ {
43460
+ name: "erpnext_kanban_move_card",
43461
+ category: "kanban",
43462
+ description: "Move a kanban card for a supported ERPNext DocType. Returns structured success or business error details for MCP App reconciliation.",
43463
+ inputSchema: {
43464
+ type: "object",
43465
+ properties: {
43466
+ doctype: {
43467
+ type: "string",
43468
+ description: "Kanban-enabled ERPNext DocType",
43469
+ enum: ["Task", "Opportunity", "Issue"]
43470
+ },
43471
+ card_id: { type: "string", description: "Card/document identifier" },
43472
+ from_column: { type: "string", description: "Source column identifier" },
43473
+ to_column: { type: "string", description: "Destination column identifier" }
43474
+ },
43475
+ required: ["doctype", "card_id", "from_column", "to_column"]
43476
+ },
43477
+ handler: async (input, ctx) => {
43478
+ const doctype = String(input.doctype ?? "");
43479
+ const { adapter } = getAdapter(doctype);
43480
+ return await adapter.executeMove({
43481
+ doctype,
43482
+ cardId: String(input.card_id ?? ""),
43483
+ fromColumn: String(input.from_column ?? ""),
43484
+ toColumn: String(input.to_column ?? "")
43485
+ }, ctx);
43486
+ }
42308
43487
  }
42309
43488
  ];
42310
43489
 
@@ -42322,7 +43501,8 @@ var toolsByCategory = {
42322
43501
  assets: assetsTools,
42323
43502
  operations: operationsTools,
42324
43503
  setup: setupTools,
42325
- analytics: analyticsTools
43504
+ analytics: analyticsTools,
43505
+ kanban: kanbanTools
42326
43506
  };
42327
43507
  var allTools = [
42328
43508
  ...salesTools,
@@ -42337,7 +43517,8 @@ var allTools = [
42337
43517
  ...assetsTools,
42338
43518
  ...operationsTools,
42339
43519
  ...setupTools,
42340
- ...analyticsTools
43520
+ ...analyticsTools,
43521
+ ...kanbanTools
42341
43522
  ];
42342
43523
  function getToolsByCategory(category) {
42343
43524
  return toolsByCategory[category] ?? [];
@@ -42584,6 +43765,34 @@ function getFrappeClient() {
42584
43765
  return _client;
42585
43766
  }
42586
43767
 
43768
+ // src/tools/ui-refresh.ts
43769
+ function isRecord(value) {
43770
+ return typeof value === "object" && value !== null;
43771
+ }
43772
+ function hasUiResource(result) {
43773
+ const meta3 = result._meta;
43774
+ if (!isRecord(meta3)) return false;
43775
+ const ui = meta3.ui;
43776
+ if (!isRecord(ui)) return false;
43777
+ return typeof ui.resourceUri === "string" && ui.resourceUri.length > 0;
43778
+ }
43779
+ function withUiRefreshRequest(result, toolName, args) {
43780
+ if (!isRecord(result) || !hasUiResource(result)) {
43781
+ return result;
43782
+ }
43783
+ const refreshable = result;
43784
+ if (refreshable.refreshRequest) {
43785
+ return result;
43786
+ }
43787
+ return {
43788
+ ...refreshable,
43789
+ refreshRequest: {
43790
+ toolName,
43791
+ arguments: { ...args }
43792
+ }
43793
+ };
43794
+ }
43795
+
42587
43796
  // src/client.ts
42588
43797
  var ErpNextToolsClient = class {
42589
43798
  tools;
@@ -42617,9 +43826,10 @@ var ErpNextToolsClient = class {
42617
43826
  buildHandlersMap() {
42618
43827
  const handlers = /* @__PURE__ */ new Map();
42619
43828
  for (const tool of this.tools) {
42620
- handlers.set(tool.name, (args) => {
43829
+ handlers.set(tool.name, async (args) => {
42621
43830
  const client = getFrappeClient();
42622
- return tool.handler(args, { client });
43831
+ const result = await tool.handler(args, { client });
43832
+ return withUiRefreshRequest(result, tool.name, args);
42623
43833
  });
42624
43834
  }
42625
43835
  return handlers;
@@ -42633,7 +43843,8 @@ var ErpNextToolsClient = class {
42633
43843
  );
42634
43844
  }
42635
43845
  const client = getFrappeClient();
42636
- return await tool.handler(args, { client });
43846
+ const result = await tool.handler(args, { client });
43847
+ return withUiRefreshRequest(result, tool.name, args);
42637
43848
  }
42638
43849
  /** Get tool count */
42639
43850
  get count() {
@@ -42642,17 +43853,43 @@ var ErpNextToolsClient = class {
42642
43853
  };
42643
43854
  var defaultClient = new ErpNextToolsClient();
42644
43855
 
42645
- // server.ts
42646
- var DEFAULT_HTTP_PORT = 3012;
43856
+ // src/ui/viewers.ts
42647
43857
  var UI_VIEWERS = [
42648
43858
  "invoice-viewer",
42649
43859
  "stock-viewer",
42650
43860
  "doclist-viewer",
42651
- "order-pipeline-viewer",
42652
43861
  "chart-viewer",
42653
43862
  "kpi-viewer",
42654
- "funnel-viewer"
43863
+ "funnel-viewer",
43864
+ "kanban-viewer"
42655
43865
  ];
43866
+
43867
+ // src/ui/viewer-resource-paths.ts
43868
+ function fileUrlToPath(url2) {
43869
+ const decodedPath = decodeURIComponent(url2.pathname);
43870
+ if (/^\/[A-Za-z]:\//.test(decodedPath)) {
43871
+ return decodedPath.slice(1);
43872
+ }
43873
+ if (url2.host.length > 0) {
43874
+ return `//${url2.host}${decodedPath}`;
43875
+ }
43876
+ return decodedPath;
43877
+ }
43878
+ function resolveViewerDistPath(moduleUrl, viewerName, exists) {
43879
+ const candidates = [
43880
+ fileUrlToPath(new URL(`./src/ui/dist/${viewerName}/index.html`, moduleUrl)),
43881
+ fileUrlToPath(new URL(`./ui-dist/${viewerName}/index.html`, moduleUrl))
43882
+ ];
43883
+ for (const candidate of candidates) {
43884
+ if (exists(candidate)) {
43885
+ return candidate;
43886
+ }
43887
+ }
43888
+ return null;
43889
+ }
43890
+
43891
+ // server.ts
43892
+ var DEFAULT_HTTP_PORT = 3012;
42656
43893
  async function main() {
42657
43894
  const args = getArgs();
42658
43895
  const categoriesArg = args.find((arg) => arg.startsWith("--categories="));
@@ -42667,7 +43904,7 @@ async function main() {
42667
43904
  );
42668
43905
  const server = new ConcurrentMCPServer({
42669
43906
  name: "mcp-erpnext",
42670
- version: "0.1.0",
43907
+ version: "0.1.9",
42671
43908
  maxConcurrent: 10,
42672
43909
  backpressureStrategy: "queue",
42673
43910
  validateSchema: true,
@@ -42677,13 +43914,10 @@ async function main() {
42677
43914
  const handlers = toolsClient.buildHandlersMap();
42678
43915
  server.registerTools(mcpTools, handlers);
42679
43916
  for (const viewerName of UI_VIEWERS) {
42680
- const distPath = new URL(
42681
- `./src/ui/dist/${viewerName}/index.html`,
42682
- import.meta.url
42683
- ).pathname;
43917
+ const distPath = resolveViewerDistPath(import.meta.url, viewerName, statSync);
42684
43918
  const resourceUri = `ui://mcp-erpnext/${viewerName}`;
42685
43919
  const humanName = viewerName.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
42686
- if (statSync(distPath)) {
43920
+ if (distPath) {
42687
43921
  server.registerResource(
42688
43922
  {
42689
43923
  uri: resourceUri,
@@ -42699,7 +43933,7 @@ async function main() {
42699
43933
  console.error(`[mcp-erpnext] Registered UI resource: ${resourceUri}`);
42700
43934
  } else {
42701
43935
  console.error(
42702
- `[mcp-erpnext] Warning: UI not built for ${resourceUri}. Run 'cd lib/erpnext/src/ui && node build-all.mjs' first.`
43936
+ `[mcp-erpnext] Warning: UI not built for ${resourceUri}. Run 'cd lib/erpnext/src/ui && node build-all.mjs' first or package ui-dist with the npm bundle.`
42703
43937
  );
42704
43938
  }
42705
43939
  }