@kirjapro/mcp-server 0.7.0 → 0.8.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.md +46 -4
  3. package/dist/index.js +1278 -611
  4. package/package.json +1 -1
  5. package/server.json +5 -1
  6. package/tool-fingerprints.json +52 -52
  7. package/dist/accounts.d.ts +0 -40
  8. package/dist/accounts.js +0 -45
  9. package/dist/auth.d.ts +0 -17
  10. package/dist/auth.js +0 -245
  11. package/dist/compliance/rates.d.ts +0 -53
  12. package/dist/compliance/rates.js +0 -57
  13. package/dist/database.types.d.ts +0 -6525
  14. package/dist/database.types.js +0 -20
  15. package/dist/index.d.ts +0 -2
  16. package/dist/lib/incomeStatementSynthesis.d.ts +0 -47
  17. package/dist/lib/incomeStatementSynthesis.js +0 -140
  18. package/dist/resources/company.d.ts +0 -2
  19. package/dist/resources/company.js +0 -75
  20. package/dist/resources/compliance.d.ts +0 -2
  21. package/dist/resources/compliance.js +0 -338
  22. package/dist/resources/index.d.ts +0 -2
  23. package/dist/resources/index.js +0 -10
  24. package/dist/resources/schema.d.ts +0 -2
  25. package/dist/resources/schema.js +0 -63
  26. package/dist/resources/security.d.ts +0 -2
  27. package/dist/resources/security.js +0 -33
  28. package/dist/schemas.d.ts +0 -12
  29. package/dist/schemas.js +0 -12
  30. package/dist/tools/accounts.d.ts +0 -2
  31. package/dist/tools/accounts.js +0 -48
  32. package/dist/tools/banking.d.ts +0 -2
  33. package/dist/tools/banking.js +0 -196
  34. package/dist/tools/bookings.d.ts +0 -2
  35. package/dist/tools/bookings.js +0 -294
  36. package/dist/tools/customers.d.ts +0 -2
  37. package/dist/tools/customers.js +0 -320
  38. package/dist/tools/financialNotes.d.ts +0 -2
  39. package/dist/tools/financialNotes.js +0 -255
  40. package/dist/tools/fingerprints.d.ts +0 -6
  41. package/dist/tools/fingerprints.js +0 -28
  42. package/dist/tools/fiscal-years.d.ts +0 -2
  43. package/dist/tools/fiscal-years.js +0 -35
  44. package/dist/tools/index.d.ts +0 -9
  45. package/dist/tools/index.js +0 -105
  46. package/dist/tools/invoices.d.ts +0 -2
  47. package/dist/tools/invoices.js +0 -489
  48. package/dist/tools/offers.d.ts +0 -2
  49. package/dist/tools/offers.js +0 -443
  50. package/dist/tools/received-invoices.d.ts +0 -2
  51. package/dist/tools/received-invoices.js +0 -134
  52. package/dist/tools/recurring-invoices.d.ts +0 -2
  53. package/dist/tools/recurring-invoices.js +0 -348
  54. package/dist/tools/reports.d.ts +0 -2
  55. package/dist/tools/reports.js +0 -869
  56. package/dist/tools/templates.d.ts +0 -89
  57. package/dist/tools/templates.js +0 -636
  58. package/dist/tools/transactions.d.ts +0 -2
  59. package/dist/tools/transactions.js +0 -597
  60. package/dist/tools/validation.d.ts +0 -26
  61. package/dist/tools/validation.js +0 -127
  62. package/dist/types.d.ts +0 -388
  63. package/dist/types.js +0 -34
  64. package/dist/utils.d.ts +0 -276
  65. package/dist/utils.js +0 -637
  66. package/dist/version.d.ts +0 -1
  67. package/dist/version.js +0 -3
package/dist/index.js CHANGED
@@ -33,9 +33,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  mod
34
34
  ));
35
35
 
36
- // node_modules/ajv/dist/compile/codegen/code.js
36
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/codegen/code.js
37
37
  var require_code = __commonJS({
38
- "node_modules/ajv/dist/compile/codegen/code.js"(exports) {
38
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/codegen/code.js"(exports) {
39
39
  "use strict";
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
@@ -187,9 +187,9 @@ var require_code = __commonJS({
187
187
  }
188
188
  });
189
189
 
190
- // node_modules/ajv/dist/compile/codegen/scope.js
190
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/codegen/scope.js
191
191
  var require_scope = __commonJS({
192
- "node_modules/ajv/dist/compile/codegen/scope.js"(exports) {
192
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/codegen/scope.js"(exports) {
193
193
  "use strict";
194
194
  Object.defineProperty(exports, "__esModule", { value: true });
195
195
  exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0;
@@ -332,9 +332,9 @@ var require_scope = __commonJS({
332
332
  }
333
333
  });
334
334
 
335
- // node_modules/ajv/dist/compile/codegen/index.js
335
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/codegen/index.js
336
336
  var require_codegen = __commonJS({
337
- "node_modules/ajv/dist/compile/codegen/index.js"(exports) {
337
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/codegen/index.js"(exports) {
338
338
  "use strict";
339
339
  Object.defineProperty(exports, "__esModule", { value: true });
340
340
  exports.or = exports.and = exports.not = exports.CodeGen = exports.operators = exports.varKinds = exports.ValueScopeName = exports.ValueScope = exports.Scope = exports.Name = exports.regexpCode = exports.stringify = exports.getProperty = exports.nil = exports.strConcat = exports.str = exports._ = void 0;
@@ -1052,9 +1052,9 @@ var require_codegen = __commonJS({
1052
1052
  }
1053
1053
  });
1054
1054
 
1055
- // node_modules/ajv/dist/compile/util.js
1055
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/util.js
1056
1056
  var require_util = __commonJS({
1057
- "node_modules/ajv/dist/compile/util.js"(exports) {
1057
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/util.js"(exports) {
1058
1058
  "use strict";
1059
1059
  Object.defineProperty(exports, "__esModule", { value: true });
1060
1060
  exports.checkStrictMode = exports.getErrorPath = exports.Type = exports.useFunc = exports.setEvaluated = exports.evaluatedPropsToName = exports.mergeEvaluated = exports.eachItem = exports.unescapeJsonPointer = exports.escapeJsonPointer = exports.escapeFragment = exports.unescapeFragment = exports.schemaRefOrVal = exports.schemaHasRulesButRef = exports.schemaHasRules = exports.checkUnknownRules = exports.alwaysValidSchema = exports.toHash = void 0;
@@ -1219,9 +1219,9 @@ var require_util = __commonJS({
1219
1219
  }
1220
1220
  });
1221
1221
 
1222
- // node_modules/ajv/dist/compile/names.js
1222
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/names.js
1223
1223
  var require_names = __commonJS({
1224
- "node_modules/ajv/dist/compile/names.js"(exports) {
1224
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/names.js"(exports) {
1225
1225
  "use strict";
1226
1226
  Object.defineProperty(exports, "__esModule", { value: true });
1227
1227
  var codegen_1 = require_codegen();
@@ -1258,9 +1258,9 @@ var require_names = __commonJS({
1258
1258
  }
1259
1259
  });
1260
1260
 
1261
- // node_modules/ajv/dist/compile/errors.js
1261
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/errors.js
1262
1262
  var require_errors = __commonJS({
1263
- "node_modules/ajv/dist/compile/errors.js"(exports) {
1263
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/errors.js"(exports) {
1264
1264
  "use strict";
1265
1265
  Object.defineProperty(exports, "__esModule", { value: true });
1266
1266
  exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = void 0;
@@ -1380,9 +1380,9 @@ var require_errors = __commonJS({
1380
1380
  }
1381
1381
  });
1382
1382
 
1383
- // node_modules/ajv/dist/compile/validate/boolSchema.js
1383
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/boolSchema.js
1384
1384
  var require_boolSchema = __commonJS({
1385
- "node_modules/ajv/dist/compile/validate/boolSchema.js"(exports) {
1385
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/boolSchema.js"(exports) {
1386
1386
  "use strict";
1387
1387
  Object.defineProperty(exports, "__esModule", { value: true });
1388
1388
  exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = void 0;
@@ -1431,9 +1431,9 @@ var require_boolSchema = __commonJS({
1431
1431
  }
1432
1432
  });
1433
1433
 
1434
- // node_modules/ajv/dist/compile/rules.js
1434
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/rules.js
1435
1435
  var require_rules = __commonJS({
1436
- "node_modules/ajv/dist/compile/rules.js"(exports) {
1436
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/rules.js"(exports) {
1437
1437
  "use strict";
1438
1438
  Object.defineProperty(exports, "__esModule", { value: true });
1439
1439
  exports.getRules = exports.isJSONType = void 0;
@@ -1462,9 +1462,9 @@ var require_rules = __commonJS({
1462
1462
  }
1463
1463
  });
1464
1464
 
1465
- // node_modules/ajv/dist/compile/validate/applicability.js
1465
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/applicability.js
1466
1466
  var require_applicability = __commonJS({
1467
- "node_modules/ajv/dist/compile/validate/applicability.js"(exports) {
1467
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/applicability.js"(exports) {
1468
1468
  "use strict";
1469
1469
  Object.defineProperty(exports, "__esModule", { value: true });
1470
1470
  exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = void 0;
@@ -1485,9 +1485,9 @@ var require_applicability = __commonJS({
1485
1485
  }
1486
1486
  });
1487
1487
 
1488
- // node_modules/ajv/dist/compile/validate/dataType.js
1488
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/dataType.js
1489
1489
  var require_dataType = __commonJS({
1490
- "node_modules/ajv/dist/compile/validate/dataType.js"(exports) {
1490
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/dataType.js"(exports) {
1491
1491
  "use strict";
1492
1492
  Object.defineProperty(exports, "__esModule", { value: true });
1493
1493
  exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = void 0;
@@ -1669,9 +1669,9 @@ var require_dataType = __commonJS({
1669
1669
  }
1670
1670
  });
1671
1671
 
1672
- // node_modules/ajv/dist/compile/validate/defaults.js
1672
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/defaults.js
1673
1673
  var require_defaults = __commonJS({
1674
- "node_modules/ajv/dist/compile/validate/defaults.js"(exports) {
1674
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/defaults.js"(exports) {
1675
1675
  "use strict";
1676
1676
  Object.defineProperty(exports, "__esModule", { value: true });
1677
1677
  exports.assignDefaults = void 0;
@@ -1706,9 +1706,9 @@ var require_defaults = __commonJS({
1706
1706
  }
1707
1707
  });
1708
1708
 
1709
- // node_modules/ajv/dist/vocabularies/code.js
1709
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/code.js
1710
1710
  var require_code2 = __commonJS({
1711
- "node_modules/ajv/dist/vocabularies/code.js"(exports) {
1711
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/code.js"(exports) {
1712
1712
  "use strict";
1713
1713
  Object.defineProperty(exports, "__esModule", { value: true });
1714
1714
  exports.validateUnion = exports.validateArray = exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.isOwnProperty = exports.hasPropFunc = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = void 0;
@@ -1839,9 +1839,9 @@ var require_code2 = __commonJS({
1839
1839
  }
1840
1840
  });
1841
1841
 
1842
- // node_modules/ajv/dist/compile/validate/keyword.js
1842
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/keyword.js
1843
1843
  var require_keyword = __commonJS({
1844
- "node_modules/ajv/dist/compile/validate/keyword.js"(exports) {
1844
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/keyword.js"(exports) {
1845
1845
  "use strict";
1846
1846
  Object.defineProperty(exports, "__esModule", { value: true });
1847
1847
  exports.validateKeywordUsage = exports.validSchemaType = exports.funcKeywordCode = exports.macroKeywordCode = void 0;
@@ -1957,9 +1957,9 @@ var require_keyword = __commonJS({
1957
1957
  }
1958
1958
  });
1959
1959
 
1960
- // node_modules/ajv/dist/compile/validate/subschema.js
1960
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/subschema.js
1961
1961
  var require_subschema = __commonJS({
1962
- "node_modules/ajv/dist/compile/validate/subschema.js"(exports) {
1962
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/subschema.js"(exports) {
1963
1963
  "use strict";
1964
1964
  Object.defineProperty(exports, "__esModule", { value: true });
1965
1965
  exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = void 0;
@@ -2040,9 +2040,9 @@ var require_subschema = __commonJS({
2040
2040
  }
2041
2041
  });
2042
2042
 
2043
- // node_modules/fast-deep-equal/index.js
2043
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/fast-deep-equal/index.js
2044
2044
  var require_fast_deep_equal = __commonJS({
2045
- "node_modules/fast-deep-equal/index.js"(exports, module) {
2045
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/fast-deep-equal/index.js"(exports, module) {
2046
2046
  "use strict";
2047
2047
  module.exports = function equal(a, b) {
2048
2048
  if (a === b) return true;
@@ -2075,9 +2075,9 @@ var require_fast_deep_equal = __commonJS({
2075
2075
  }
2076
2076
  });
2077
2077
 
2078
- // node_modules/json-schema-traverse/index.js
2078
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/json-schema-traverse/index.js
2079
2079
  var require_json_schema_traverse = __commonJS({
2080
- "node_modules/json-schema-traverse/index.js"(exports, module) {
2080
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/json-schema-traverse/index.js"(exports, module) {
2081
2081
  "use strict";
2082
2082
  var traverse = module.exports = function(schema, opts, cb) {
2083
2083
  if (typeof opts == "function") {
@@ -2163,9 +2163,9 @@ var require_json_schema_traverse = __commonJS({
2163
2163
  }
2164
2164
  });
2165
2165
 
2166
- // node_modules/ajv/dist/compile/resolve.js
2166
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/resolve.js
2167
2167
  var require_resolve = __commonJS({
2168
- "node_modules/ajv/dist/compile/resolve.js"(exports) {
2168
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/resolve.js"(exports) {
2169
2169
  "use strict";
2170
2170
  Object.defineProperty(exports, "__esModule", { value: true });
2171
2171
  exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = void 0;
@@ -2319,9 +2319,9 @@ var require_resolve = __commonJS({
2319
2319
  }
2320
2320
  });
2321
2321
 
2322
- // node_modules/ajv/dist/compile/validate/index.js
2322
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/index.js
2323
2323
  var require_validate = __commonJS({
2324
- "node_modules/ajv/dist/compile/validate/index.js"(exports) {
2324
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/index.js"(exports) {
2325
2325
  "use strict";
2326
2326
  Object.defineProperty(exports, "__esModule", { value: true });
2327
2327
  exports.getData = exports.KeywordCxt = exports.validateFunctionCode = void 0;
@@ -2827,9 +2827,9 @@ var require_validate = __commonJS({
2827
2827
  }
2828
2828
  });
2829
2829
 
2830
- // node_modules/ajv/dist/runtime/validation_error.js
2830
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/validation_error.js
2831
2831
  var require_validation_error = __commonJS({
2832
- "node_modules/ajv/dist/runtime/validation_error.js"(exports) {
2832
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/validation_error.js"(exports) {
2833
2833
  "use strict";
2834
2834
  Object.defineProperty(exports, "__esModule", { value: true });
2835
2835
  var ValidationError = class extends Error {
@@ -2843,9 +2843,9 @@ var require_validation_error = __commonJS({
2843
2843
  }
2844
2844
  });
2845
2845
 
2846
- // node_modules/ajv/dist/compile/ref_error.js
2846
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/ref_error.js
2847
2847
  var require_ref_error = __commonJS({
2848
- "node_modules/ajv/dist/compile/ref_error.js"(exports) {
2848
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/ref_error.js"(exports) {
2849
2849
  "use strict";
2850
2850
  Object.defineProperty(exports, "__esModule", { value: true });
2851
2851
  var resolve_1 = require_resolve();
@@ -2860,9 +2860,9 @@ var require_ref_error = __commonJS({
2860
2860
  }
2861
2861
  });
2862
2862
 
2863
- // node_modules/ajv/dist/compile/index.js
2863
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/index.js
2864
2864
  var require_compile = __commonJS({
2865
- "node_modules/ajv/dist/compile/index.js"(exports) {
2865
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/index.js"(exports) {
2866
2866
  "use strict";
2867
2867
  Object.defineProperty(exports, "__esModule", { value: true });
2868
2868
  exports.resolveSchema = exports.getCompilingSchema = exports.resolveRef = exports.compileSchema = exports.SchemaEnv = void 0;
@@ -3084,9 +3084,9 @@ var require_compile = __commonJS({
3084
3084
  }
3085
3085
  });
3086
3086
 
3087
- // node_modules/ajv/dist/refs/data.json
3087
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/refs/data.json
3088
3088
  var require_data = __commonJS({
3089
- "node_modules/ajv/dist/refs/data.json"(exports, module) {
3089
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/refs/data.json"(exports, module) {
3090
3090
  module.exports = {
3091
3091
  $id: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
3092
3092
  description: "Meta-schema for $data reference (JSON AnySchema extension proposal)",
@@ -3103,9 +3103,9 @@ var require_data = __commonJS({
3103
3103
  }
3104
3104
  });
3105
3105
 
3106
- // node_modules/fast-uri/lib/utils.js
3106
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/fast-uri/lib/utils.js
3107
3107
  var require_utils = __commonJS({
3108
- "node_modules/fast-uri/lib/utils.js"(exports, module) {
3108
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/fast-uri/lib/utils.js"(exports, module) {
3109
3109
  "use strict";
3110
3110
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3111
3111
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
@@ -3416,9 +3416,9 @@ var require_utils = __commonJS({
3416
3416
  }
3417
3417
  });
3418
3418
 
3419
- // node_modules/fast-uri/lib/schemes.js
3419
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/fast-uri/lib/schemes.js
3420
3420
  var require_schemes = __commonJS({
3421
- "node_modules/fast-uri/lib/schemes.js"(exports, module) {
3421
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/fast-uri/lib/schemes.js"(exports, module) {
3422
3422
  "use strict";
3423
3423
  var { isUUID } = require_utils();
3424
3424
  var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
@@ -3626,9 +3626,9 @@ var require_schemes = __commonJS({
3626
3626
  }
3627
3627
  });
3628
3628
 
3629
- // node_modules/fast-uri/index.js
3629
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/fast-uri/index.js
3630
3630
  var require_fast_uri = __commonJS({
3631
- "node_modules/fast-uri/index.js"(exports, module) {
3631
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/fast-uri/index.js"(exports, module) {
3632
3632
  "use strict";
3633
3633
  var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3634
3634
  var { SCHEMES, getSchemeHandler } = require_schemes();
@@ -3918,9 +3918,9 @@ var require_fast_uri = __commonJS({
3918
3918
  }
3919
3919
  });
3920
3920
 
3921
- // node_modules/ajv/dist/runtime/uri.js
3921
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/uri.js
3922
3922
  var require_uri = __commonJS({
3923
- "node_modules/ajv/dist/runtime/uri.js"(exports) {
3923
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/uri.js"(exports) {
3924
3924
  "use strict";
3925
3925
  Object.defineProperty(exports, "__esModule", { value: true });
3926
3926
  var uri = require_fast_uri();
@@ -3929,9 +3929,9 @@ var require_uri = __commonJS({
3929
3929
  }
3930
3930
  });
3931
3931
 
3932
- // node_modules/ajv/dist/core.js
3932
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/core.js
3933
3933
  var require_core = __commonJS({
3934
- "node_modules/ajv/dist/core.js"(exports) {
3934
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/core.js"(exports) {
3935
3935
  "use strict";
3936
3936
  Object.defineProperty(exports, "__esModule", { value: true });
3937
3937
  exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
@@ -4540,9 +4540,9 @@ var require_core = __commonJS({
4540
4540
  }
4541
4541
  });
4542
4542
 
4543
- // node_modules/ajv/dist/vocabularies/core/id.js
4543
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/core/id.js
4544
4544
  var require_id = __commonJS({
4545
- "node_modules/ajv/dist/vocabularies/core/id.js"(exports) {
4545
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/core/id.js"(exports) {
4546
4546
  "use strict";
4547
4547
  Object.defineProperty(exports, "__esModule", { value: true });
4548
4548
  var def = {
@@ -4555,9 +4555,9 @@ var require_id = __commonJS({
4555
4555
  }
4556
4556
  });
4557
4557
 
4558
- // node_modules/ajv/dist/vocabularies/core/ref.js
4558
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/core/ref.js
4559
4559
  var require_ref = __commonJS({
4560
- "node_modules/ajv/dist/vocabularies/core/ref.js"(exports) {
4560
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/core/ref.js"(exports) {
4561
4561
  "use strict";
4562
4562
  Object.defineProperty(exports, "__esModule", { value: true });
4563
4563
  exports.callRef = exports.getValidate = void 0;
@@ -4677,9 +4677,9 @@ var require_ref = __commonJS({
4677
4677
  }
4678
4678
  });
4679
4679
 
4680
- // node_modules/ajv/dist/vocabularies/core/index.js
4680
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/core/index.js
4681
4681
  var require_core2 = __commonJS({
4682
- "node_modules/ajv/dist/vocabularies/core/index.js"(exports) {
4682
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/core/index.js"(exports) {
4683
4683
  "use strict";
4684
4684
  Object.defineProperty(exports, "__esModule", { value: true });
4685
4685
  var id_1 = require_id();
@@ -4698,9 +4698,9 @@ var require_core2 = __commonJS({
4698
4698
  }
4699
4699
  });
4700
4700
 
4701
- // node_modules/ajv/dist/vocabularies/validation/limitNumber.js
4701
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/limitNumber.js
4702
4702
  var require_limitNumber = __commonJS({
4703
- "node_modules/ajv/dist/vocabularies/validation/limitNumber.js"(exports) {
4703
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/limitNumber.js"(exports) {
4704
4704
  "use strict";
4705
4705
  Object.defineProperty(exports, "__esModule", { value: true });
4706
4706
  var codegen_1 = require_codegen();
@@ -4730,9 +4730,9 @@ var require_limitNumber = __commonJS({
4730
4730
  }
4731
4731
  });
4732
4732
 
4733
- // node_modules/ajv/dist/vocabularies/validation/multipleOf.js
4733
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/multipleOf.js
4734
4734
  var require_multipleOf = __commonJS({
4735
- "node_modules/ajv/dist/vocabularies/validation/multipleOf.js"(exports) {
4735
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/multipleOf.js"(exports) {
4736
4736
  "use strict";
4737
4737
  Object.defineProperty(exports, "__esModule", { value: true });
4738
4738
  var codegen_1 = require_codegen();
@@ -4758,9 +4758,9 @@ var require_multipleOf = __commonJS({
4758
4758
  }
4759
4759
  });
4760
4760
 
4761
- // node_modules/ajv/dist/runtime/ucs2length.js
4761
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/ucs2length.js
4762
4762
  var require_ucs2length = __commonJS({
4763
- "node_modules/ajv/dist/runtime/ucs2length.js"(exports) {
4763
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/ucs2length.js"(exports) {
4764
4764
  "use strict";
4765
4765
  Object.defineProperty(exports, "__esModule", { value: true });
4766
4766
  function ucs2length(str) {
@@ -4784,9 +4784,9 @@ var require_ucs2length = __commonJS({
4784
4784
  }
4785
4785
  });
4786
4786
 
4787
- // node_modules/ajv/dist/vocabularies/validation/limitLength.js
4787
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/limitLength.js
4788
4788
  var require_limitLength = __commonJS({
4789
- "node_modules/ajv/dist/vocabularies/validation/limitLength.js"(exports) {
4789
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/limitLength.js"(exports) {
4790
4790
  "use strict";
4791
4791
  Object.defineProperty(exports, "__esModule", { value: true });
4792
4792
  var codegen_1 = require_codegen();
@@ -4816,9 +4816,9 @@ var require_limitLength = __commonJS({
4816
4816
  }
4817
4817
  });
4818
4818
 
4819
- // node_modules/ajv/dist/vocabularies/validation/pattern.js
4819
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/pattern.js
4820
4820
  var require_pattern = __commonJS({
4821
- "node_modules/ajv/dist/vocabularies/validation/pattern.js"(exports) {
4821
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/pattern.js"(exports) {
4822
4822
  "use strict";
4823
4823
  Object.defineProperty(exports, "__esModule", { value: true });
4824
4824
  var code_1 = require_code2();
@@ -4853,9 +4853,9 @@ var require_pattern = __commonJS({
4853
4853
  }
4854
4854
  });
4855
4855
 
4856
- // node_modules/ajv/dist/vocabularies/validation/limitProperties.js
4856
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/limitProperties.js
4857
4857
  var require_limitProperties = __commonJS({
4858
- "node_modules/ajv/dist/vocabularies/validation/limitProperties.js"(exports) {
4858
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/limitProperties.js"(exports) {
4859
4859
  "use strict";
4860
4860
  Object.defineProperty(exports, "__esModule", { value: true });
4861
4861
  var codegen_1 = require_codegen();
@@ -4882,9 +4882,9 @@ var require_limitProperties = __commonJS({
4882
4882
  }
4883
4883
  });
4884
4884
 
4885
- // node_modules/ajv/dist/vocabularies/validation/required.js
4885
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/required.js
4886
4886
  var require_required = __commonJS({
4887
- "node_modules/ajv/dist/vocabularies/validation/required.js"(exports) {
4887
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/required.js"(exports) {
4888
4888
  "use strict";
4889
4889
  Object.defineProperty(exports, "__esModule", { value: true });
4890
4890
  var code_1 = require_code2();
@@ -4964,9 +4964,9 @@ var require_required = __commonJS({
4964
4964
  }
4965
4965
  });
4966
4966
 
4967
- // node_modules/ajv/dist/vocabularies/validation/limitItems.js
4967
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/limitItems.js
4968
4968
  var require_limitItems = __commonJS({
4969
- "node_modules/ajv/dist/vocabularies/validation/limitItems.js"(exports) {
4969
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/limitItems.js"(exports) {
4970
4970
  "use strict";
4971
4971
  Object.defineProperty(exports, "__esModule", { value: true });
4972
4972
  var codegen_1 = require_codegen();
@@ -4993,9 +4993,9 @@ var require_limitItems = __commonJS({
4993
4993
  }
4994
4994
  });
4995
4995
 
4996
- // node_modules/ajv/dist/runtime/equal.js
4996
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/equal.js
4997
4997
  var require_equal = __commonJS({
4998
- "node_modules/ajv/dist/runtime/equal.js"(exports) {
4998
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/equal.js"(exports) {
4999
4999
  "use strict";
5000
5000
  Object.defineProperty(exports, "__esModule", { value: true });
5001
5001
  var equal = require_fast_deep_equal();
@@ -5004,9 +5004,9 @@ var require_equal = __commonJS({
5004
5004
  }
5005
5005
  });
5006
5006
 
5007
- // node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
5007
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
5008
5008
  var require_uniqueItems = __commonJS({
5009
- "node_modules/ajv/dist/vocabularies/validation/uniqueItems.js"(exports) {
5009
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js"(exports) {
5010
5010
  "use strict";
5011
5011
  Object.defineProperty(exports, "__esModule", { value: true });
5012
5012
  var dataType_1 = require_dataType();
@@ -5071,9 +5071,9 @@ var require_uniqueItems = __commonJS({
5071
5071
  }
5072
5072
  });
5073
5073
 
5074
- // node_modules/ajv/dist/vocabularies/validation/const.js
5074
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/const.js
5075
5075
  var require_const = __commonJS({
5076
- "node_modules/ajv/dist/vocabularies/validation/const.js"(exports) {
5076
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/const.js"(exports) {
5077
5077
  "use strict";
5078
5078
  Object.defineProperty(exports, "__esModule", { value: true });
5079
5079
  var codegen_1 = require_codegen();
@@ -5100,9 +5100,9 @@ var require_const = __commonJS({
5100
5100
  }
5101
5101
  });
5102
5102
 
5103
- // node_modules/ajv/dist/vocabularies/validation/enum.js
5103
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/enum.js
5104
5104
  var require_enum = __commonJS({
5105
- "node_modules/ajv/dist/vocabularies/validation/enum.js"(exports) {
5105
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/enum.js"(exports) {
5106
5106
  "use strict";
5107
5107
  Object.defineProperty(exports, "__esModule", { value: true });
5108
5108
  var codegen_1 = require_codegen();
@@ -5149,9 +5149,9 @@ var require_enum = __commonJS({
5149
5149
  }
5150
5150
  });
5151
5151
 
5152
- // node_modules/ajv/dist/vocabularies/validation/index.js
5152
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/index.js
5153
5153
  var require_validation = __commonJS({
5154
- "node_modules/ajv/dist/vocabularies/validation/index.js"(exports) {
5154
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/index.js"(exports) {
5155
5155
  "use strict";
5156
5156
  Object.defineProperty(exports, "__esModule", { value: true });
5157
5157
  var limitNumber_1 = require_limitNumber();
@@ -5187,9 +5187,9 @@ var require_validation = __commonJS({
5187
5187
  }
5188
5188
  });
5189
5189
 
5190
- // node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
5190
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
5191
5191
  var require_additionalItems = __commonJS({
5192
- "node_modules/ajv/dist/vocabularies/applicator/additionalItems.js"(exports) {
5192
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js"(exports) {
5193
5193
  "use strict";
5194
5194
  Object.defineProperty(exports, "__esModule", { value: true });
5195
5195
  exports.validateAdditionalItems = void 0;
@@ -5240,9 +5240,9 @@ var require_additionalItems = __commonJS({
5240
5240
  }
5241
5241
  });
5242
5242
 
5243
- // node_modules/ajv/dist/vocabularies/applicator/items.js
5243
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/items.js
5244
5244
  var require_items = __commonJS({
5245
- "node_modules/ajv/dist/vocabularies/applicator/items.js"(exports) {
5245
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/items.js"(exports) {
5246
5246
  "use strict";
5247
5247
  Object.defineProperty(exports, "__esModule", { value: true });
5248
5248
  exports.validateTuple = void 0;
@@ -5297,9 +5297,9 @@ var require_items = __commonJS({
5297
5297
  }
5298
5298
  });
5299
5299
 
5300
- // node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
5300
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
5301
5301
  var require_prefixItems = __commonJS({
5302
- "node_modules/ajv/dist/vocabularies/applicator/prefixItems.js"(exports) {
5302
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js"(exports) {
5303
5303
  "use strict";
5304
5304
  Object.defineProperty(exports, "__esModule", { value: true });
5305
5305
  var items_1 = require_items();
@@ -5314,9 +5314,9 @@ var require_prefixItems = __commonJS({
5314
5314
  }
5315
5315
  });
5316
5316
 
5317
- // node_modules/ajv/dist/vocabularies/applicator/items2020.js
5317
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/items2020.js
5318
5318
  var require_items2020 = __commonJS({
5319
- "node_modules/ajv/dist/vocabularies/applicator/items2020.js"(exports) {
5319
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/items2020.js"(exports) {
5320
5320
  "use strict";
5321
5321
  Object.defineProperty(exports, "__esModule", { value: true });
5322
5322
  var codegen_1 = require_codegen();
@@ -5349,9 +5349,9 @@ var require_items2020 = __commonJS({
5349
5349
  }
5350
5350
  });
5351
5351
 
5352
- // node_modules/ajv/dist/vocabularies/applicator/contains.js
5352
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/contains.js
5353
5353
  var require_contains = __commonJS({
5354
- "node_modules/ajv/dist/vocabularies/applicator/contains.js"(exports) {
5354
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/contains.js"(exports) {
5355
5355
  "use strict";
5356
5356
  Object.defineProperty(exports, "__esModule", { value: true });
5357
5357
  var codegen_1 = require_codegen();
@@ -5443,9 +5443,9 @@ var require_contains = __commonJS({
5443
5443
  }
5444
5444
  });
5445
5445
 
5446
- // node_modules/ajv/dist/vocabularies/applicator/dependencies.js
5446
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/dependencies.js
5447
5447
  var require_dependencies = __commonJS({
5448
- "node_modules/ajv/dist/vocabularies/applicator/dependencies.js"(exports) {
5448
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/dependencies.js"(exports) {
5449
5449
  "use strict";
5450
5450
  Object.defineProperty(exports, "__esModule", { value: true });
5451
5451
  exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0;
@@ -5537,9 +5537,9 @@ var require_dependencies = __commonJS({
5537
5537
  }
5538
5538
  });
5539
5539
 
5540
- // node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
5540
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
5541
5541
  var require_propertyNames = __commonJS({
5542
- "node_modules/ajv/dist/vocabularies/applicator/propertyNames.js"(exports) {
5542
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js"(exports) {
5543
5543
  "use strict";
5544
5544
  Object.defineProperty(exports, "__esModule", { value: true });
5545
5545
  var codegen_1 = require_codegen();
@@ -5580,9 +5580,9 @@ var require_propertyNames = __commonJS({
5580
5580
  }
5581
5581
  });
5582
5582
 
5583
- // node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
5583
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
5584
5584
  var require_additionalProperties = __commonJS({
5585
- "node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js"(exports) {
5585
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js"(exports) {
5586
5586
  "use strict";
5587
5587
  Object.defineProperty(exports, "__esModule", { value: true });
5588
5588
  var code_1 = require_code2();
@@ -5686,9 +5686,9 @@ var require_additionalProperties = __commonJS({
5686
5686
  }
5687
5687
  });
5688
5688
 
5689
- // node_modules/ajv/dist/vocabularies/applicator/properties.js
5689
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/properties.js
5690
5690
  var require_properties = __commonJS({
5691
- "node_modules/ajv/dist/vocabularies/applicator/properties.js"(exports) {
5691
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/properties.js"(exports) {
5692
5692
  "use strict";
5693
5693
  Object.defineProperty(exports, "__esModule", { value: true });
5694
5694
  var validate_1 = require_validate();
@@ -5744,9 +5744,9 @@ var require_properties = __commonJS({
5744
5744
  }
5745
5745
  });
5746
5746
 
5747
- // node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
5747
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
5748
5748
  var require_patternProperties = __commonJS({
5749
- "node_modules/ajv/dist/vocabularies/applicator/patternProperties.js"(exports) {
5749
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js"(exports) {
5750
5750
  "use strict";
5751
5751
  Object.defineProperty(exports, "__esModule", { value: true });
5752
5752
  var code_1 = require_code2();
@@ -5818,9 +5818,9 @@ var require_patternProperties = __commonJS({
5818
5818
  }
5819
5819
  });
5820
5820
 
5821
- // node_modules/ajv/dist/vocabularies/applicator/not.js
5821
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/not.js
5822
5822
  var require_not = __commonJS({
5823
- "node_modules/ajv/dist/vocabularies/applicator/not.js"(exports) {
5823
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/not.js"(exports) {
5824
5824
  "use strict";
5825
5825
  Object.defineProperty(exports, "__esModule", { value: true });
5826
5826
  var util_1 = require_util();
@@ -5849,9 +5849,9 @@ var require_not = __commonJS({
5849
5849
  }
5850
5850
  });
5851
5851
 
5852
- // node_modules/ajv/dist/vocabularies/applicator/anyOf.js
5852
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/anyOf.js
5853
5853
  var require_anyOf = __commonJS({
5854
- "node_modules/ajv/dist/vocabularies/applicator/anyOf.js"(exports) {
5854
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/anyOf.js"(exports) {
5855
5855
  "use strict";
5856
5856
  Object.defineProperty(exports, "__esModule", { value: true });
5857
5857
  var code_1 = require_code2();
@@ -5866,9 +5866,9 @@ var require_anyOf = __commonJS({
5866
5866
  }
5867
5867
  });
5868
5868
 
5869
- // node_modules/ajv/dist/vocabularies/applicator/oneOf.js
5869
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/oneOf.js
5870
5870
  var require_oneOf = __commonJS({
5871
- "node_modules/ajv/dist/vocabularies/applicator/oneOf.js"(exports) {
5871
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/oneOf.js"(exports) {
5872
5872
  "use strict";
5873
5873
  Object.defineProperty(exports, "__esModule", { value: true });
5874
5874
  var codegen_1 = require_codegen();
@@ -5924,9 +5924,9 @@ var require_oneOf = __commonJS({
5924
5924
  }
5925
5925
  });
5926
5926
 
5927
- // node_modules/ajv/dist/vocabularies/applicator/allOf.js
5927
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/allOf.js
5928
5928
  var require_allOf = __commonJS({
5929
- "node_modules/ajv/dist/vocabularies/applicator/allOf.js"(exports) {
5929
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/allOf.js"(exports) {
5930
5930
  "use strict";
5931
5931
  Object.defineProperty(exports, "__esModule", { value: true });
5932
5932
  var util_1 = require_util();
@@ -5951,9 +5951,9 @@ var require_allOf = __commonJS({
5951
5951
  }
5952
5952
  });
5953
5953
 
5954
- // node_modules/ajv/dist/vocabularies/applicator/if.js
5954
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/if.js
5955
5955
  var require_if = __commonJS({
5956
- "node_modules/ajv/dist/vocabularies/applicator/if.js"(exports) {
5956
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/if.js"(exports) {
5957
5957
  "use strict";
5958
5958
  Object.defineProperty(exports, "__esModule", { value: true });
5959
5959
  var codegen_1 = require_codegen();
@@ -6020,9 +6020,9 @@ var require_if = __commonJS({
6020
6020
  }
6021
6021
  });
6022
6022
 
6023
- // node_modules/ajv/dist/vocabularies/applicator/thenElse.js
6023
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/thenElse.js
6024
6024
  var require_thenElse = __commonJS({
6025
- "node_modules/ajv/dist/vocabularies/applicator/thenElse.js"(exports) {
6025
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/thenElse.js"(exports) {
6026
6026
  "use strict";
6027
6027
  Object.defineProperty(exports, "__esModule", { value: true });
6028
6028
  var util_1 = require_util();
@@ -6038,9 +6038,9 @@ var require_thenElse = __commonJS({
6038
6038
  }
6039
6039
  });
6040
6040
 
6041
- // node_modules/ajv/dist/vocabularies/applicator/index.js
6041
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/index.js
6042
6042
  var require_applicator = __commonJS({
6043
- "node_modules/ajv/dist/vocabularies/applicator/index.js"(exports) {
6043
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/index.js"(exports) {
6044
6044
  "use strict";
6045
6045
  Object.defineProperty(exports, "__esModule", { value: true });
6046
6046
  var additionalItems_1 = require_additionalItems();
@@ -6086,9 +6086,9 @@ var require_applicator = __commonJS({
6086
6086
  }
6087
6087
  });
6088
6088
 
6089
- // node_modules/ajv/dist/vocabularies/format/format.js
6089
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/format/format.js
6090
6090
  var require_format = __commonJS({
6091
- "node_modules/ajv/dist/vocabularies/format/format.js"(exports) {
6091
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/format/format.js"(exports) {
6092
6092
  "use strict";
6093
6093
  Object.defineProperty(exports, "__esModule", { value: true });
6094
6094
  var codegen_1 = require_codegen();
@@ -6176,9 +6176,9 @@ var require_format = __commonJS({
6176
6176
  }
6177
6177
  });
6178
6178
 
6179
- // node_modules/ajv/dist/vocabularies/format/index.js
6179
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/format/index.js
6180
6180
  var require_format2 = __commonJS({
6181
- "node_modules/ajv/dist/vocabularies/format/index.js"(exports) {
6181
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/format/index.js"(exports) {
6182
6182
  "use strict";
6183
6183
  Object.defineProperty(exports, "__esModule", { value: true });
6184
6184
  var format_1 = require_format();
@@ -6187,9 +6187,9 @@ var require_format2 = __commonJS({
6187
6187
  }
6188
6188
  });
6189
6189
 
6190
- // node_modules/ajv/dist/vocabularies/metadata.js
6190
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/metadata.js
6191
6191
  var require_metadata = __commonJS({
6192
- "node_modules/ajv/dist/vocabularies/metadata.js"(exports) {
6192
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/metadata.js"(exports) {
6193
6193
  "use strict";
6194
6194
  Object.defineProperty(exports, "__esModule", { value: true });
6195
6195
  exports.contentVocabulary = exports.metadataVocabulary = void 0;
@@ -6210,9 +6210,9 @@ var require_metadata = __commonJS({
6210
6210
  }
6211
6211
  });
6212
6212
 
6213
- // node_modules/ajv/dist/vocabularies/draft7.js
6213
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/draft7.js
6214
6214
  var require_draft7 = __commonJS({
6215
- "node_modules/ajv/dist/vocabularies/draft7.js"(exports) {
6215
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/draft7.js"(exports) {
6216
6216
  "use strict";
6217
6217
  Object.defineProperty(exports, "__esModule", { value: true });
6218
6218
  var core_1 = require_core2();
@@ -6232,9 +6232,9 @@ var require_draft7 = __commonJS({
6232
6232
  }
6233
6233
  });
6234
6234
 
6235
- // node_modules/ajv/dist/vocabularies/discriminator/types.js
6235
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/discriminator/types.js
6236
6236
  var require_types = __commonJS({
6237
- "node_modules/ajv/dist/vocabularies/discriminator/types.js"(exports) {
6237
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/discriminator/types.js"(exports) {
6238
6238
  "use strict";
6239
6239
  Object.defineProperty(exports, "__esModule", { value: true });
6240
6240
  exports.DiscrError = void 0;
@@ -6246,9 +6246,9 @@ var require_types = __commonJS({
6246
6246
  }
6247
6247
  });
6248
6248
 
6249
- // node_modules/ajv/dist/vocabularies/discriminator/index.js
6249
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/discriminator/index.js
6250
6250
  var require_discriminator = __commonJS({
6251
- "node_modules/ajv/dist/vocabularies/discriminator/index.js"(exports) {
6251
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/discriminator/index.js"(exports) {
6252
6252
  "use strict";
6253
6253
  Object.defineProperty(exports, "__esModule", { value: true });
6254
6254
  var codegen_1 = require_codegen();
@@ -6351,9 +6351,9 @@ var require_discriminator = __commonJS({
6351
6351
  }
6352
6352
  });
6353
6353
 
6354
- // node_modules/ajv/dist/refs/json-schema-draft-07.json
6354
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/refs/json-schema-draft-07.json
6355
6355
  var require_json_schema_draft_07 = __commonJS({
6356
- "node_modules/ajv/dist/refs/json-schema-draft-07.json"(exports, module) {
6356
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/refs/json-schema-draft-07.json"(exports, module) {
6357
6357
  module.exports = {
6358
6358
  $schema: "http://json-schema.org/draft-07/schema#",
6359
6359
  $id: "http://json-schema.org/draft-07/schema#",
@@ -6508,9 +6508,9 @@ var require_json_schema_draft_07 = __commonJS({
6508
6508
  }
6509
6509
  });
6510
6510
 
6511
- // node_modules/ajv/dist/ajv.js
6511
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/ajv.js
6512
6512
  var require_ajv = __commonJS({
6513
- "node_modules/ajv/dist/ajv.js"(exports, module) {
6513
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/ajv.js"(exports, module) {
6514
6514
  "use strict";
6515
6515
  Object.defineProperty(exports, "__esModule", { value: true });
6516
6516
  exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv = void 0;
@@ -6578,9 +6578,9 @@ var require_ajv = __commonJS({
6578
6578
  }
6579
6579
  });
6580
6580
 
6581
- // node_modules/ajv-formats/dist/formats.js
6581
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv-formats/dist/formats.js
6582
6582
  var require_formats = __commonJS({
6583
- "node_modules/ajv-formats/dist/formats.js"(exports) {
6583
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv-formats/dist/formats.js"(exports) {
6584
6584
  "use strict";
6585
6585
  Object.defineProperty(exports, "__esModule", { value: true });
6586
6586
  exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
@@ -6781,9 +6781,9 @@ var require_formats = __commonJS({
6781
6781
  }
6782
6782
  });
6783
6783
 
6784
- // node_modules/ajv-formats/dist/limit.js
6784
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv-formats/dist/limit.js
6785
6785
  var require_limit = __commonJS({
6786
- "node_modules/ajv-formats/dist/limit.js"(exports) {
6786
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv-formats/dist/limit.js"(exports) {
6787
6787
  "use strict";
6788
6788
  Object.defineProperty(exports, "__esModule", { value: true });
6789
6789
  exports.formatLimitDefinition = void 0;
@@ -6853,9 +6853,9 @@ var require_limit = __commonJS({
6853
6853
  }
6854
6854
  });
6855
6855
 
6856
- // node_modules/ajv-formats/dist/index.js
6856
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv-formats/dist/index.js
6857
6857
  var require_dist = __commonJS({
6858
- "node_modules/ajv-formats/dist/index.js"(exports, module) {
6858
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv-formats/dist/index.js"(exports, module) {
6859
6859
  "use strict";
6860
6860
  Object.defineProperty(exports, "__esModule", { value: true });
6861
6861
  var formats_1 = require_formats();
@@ -6895,7 +6895,7 @@ var require_dist = __commonJS({
6895
6895
  }
6896
6896
  });
6897
6897
 
6898
- // node_modules/zod/v3/helpers/util.js
6898
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v3/helpers/util.js
6899
6899
  var util;
6900
6900
  (function(util2) {
6901
6901
  util2.assertEqual = (_) => {
@@ -7029,7 +7029,7 @@ var getParsedType = (data) => {
7029
7029
  }
7030
7030
  };
7031
7031
 
7032
- // node_modules/zod/v3/ZodError.js
7032
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v3/ZodError.js
7033
7033
  var ZodIssueCode = util.arrayToEnum([
7034
7034
  "invalid_type",
7035
7035
  "invalid_literal",
@@ -7143,7 +7143,7 @@ ZodError.create = (issues) => {
7143
7143
  return error51;
7144
7144
  };
7145
7145
 
7146
- // node_modules/zod/v3/locales/en.js
7146
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v3/locales/en.js
7147
7147
  var errorMap = (issue2, _ctx) => {
7148
7148
  let message;
7149
7149
  switch (issue2.code) {
@@ -7246,13 +7246,13 @@ var errorMap = (issue2, _ctx) => {
7246
7246
  };
7247
7247
  var en_default = errorMap;
7248
7248
 
7249
- // node_modules/zod/v3/errors.js
7249
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v3/errors.js
7250
7250
  var overrideErrorMap = en_default;
7251
7251
  function getErrorMap() {
7252
7252
  return overrideErrorMap;
7253
7253
  }
7254
7254
 
7255
- // node_modules/zod/v3/helpers/parseUtil.js
7255
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v3/helpers/parseUtil.js
7256
7256
  var makeIssue = (params) => {
7257
7257
  const { data, path, errorMaps, issueData } = params;
7258
7258
  const fullPath = [...path, ...issueData.path || []];
@@ -7361,14 +7361,14 @@ var isDirty = (x) => x.status === "dirty";
7361
7361
  var isValid = (x) => x.status === "valid";
7362
7362
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
7363
7363
 
7364
- // node_modules/zod/v3/helpers/errorUtil.js
7364
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v3/helpers/errorUtil.js
7365
7365
  var errorUtil;
7366
7366
  (function(errorUtil2) {
7367
7367
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
7368
7368
  errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
7369
7369
  })(errorUtil || (errorUtil = {}));
7370
7370
 
7371
- // node_modules/zod/v3/types.js
7371
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v3/types.js
7372
7372
  var ParseInputLazyPath = class {
7373
7373
  constructor(parent, value, path, key) {
7374
7374
  this._cachedPath = [];
@@ -10771,7 +10771,7 @@ var nullableType = ZodNullable.create;
10771
10771
  var preprocessType = ZodEffects.createWithPreprocess;
10772
10772
  var pipelineType = ZodPipeline.create;
10773
10773
 
10774
- // node_modules/zod/v4/core/index.js
10774
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/index.js
10775
10775
  var core_exports2 = {};
10776
10776
  __export(core_exports2, {
10777
10777
  $ZodAny: () => $ZodAny,
@@ -11050,7 +11050,7 @@ __export(core_exports2, {
11050
11050
  version: () => version
11051
11051
  });
11052
11052
 
11053
- // node_modules/zod/v4/core/core.js
11053
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/core.js
11054
11054
  var _a;
11055
11055
  var NEVER = /* @__PURE__ */ Object.freeze({
11056
11056
  status: "aborted"
@@ -11127,7 +11127,7 @@ function config(newConfig) {
11127
11127
  return globalConfig;
11128
11128
  }
11129
11129
 
11130
- // node_modules/zod/v4/core/util.js
11130
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/util.js
11131
11131
  var util_exports = {};
11132
11132
  __export(util_exports, {
11133
11133
  BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
@@ -11823,7 +11823,7 @@ var Class = class {
11823
11823
  }
11824
11824
  };
11825
11825
 
11826
- // node_modules/zod/v4/core/errors.js
11826
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/errors.js
11827
11827
  var initializer = (inst, def) => {
11828
11828
  inst.name = "$ZodError";
11829
11829
  Object.defineProperty(inst, "_zod", {
@@ -11962,7 +11962,7 @@ function prettifyError(error51) {
11962
11962
  return lines.join("\n");
11963
11963
  }
11964
11964
 
11965
- // node_modules/zod/v4/core/parse.js
11965
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/parse.js
11966
11966
  var _parse = (_Err) => (schema, value, _ctx, _params) => {
11967
11967
  const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
11968
11968
  const result = schema._zod.run({ value, issues: [] }, ctx);
@@ -12050,7 +12050,7 @@ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
12050
12050
  };
12051
12051
  var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
12052
12052
 
12053
- // node_modules/zod/v4/core/regexes.js
12053
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/regexes.js
12054
12054
  var regexes_exports = {};
12055
12055
  __export(regexes_exports, {
12056
12056
  base64: () => base64,
@@ -12209,7 +12209,7 @@ var sha512_hex = /^[0-9a-fA-F]{128}$/;
12209
12209
  var sha512_base64 = /* @__PURE__ */ fixedBase64(86, "==");
12210
12210
  var sha512_base64url = /* @__PURE__ */ fixedBase64url(86);
12211
12211
 
12212
- // node_modules/zod/v4/core/checks.js
12212
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/checks.js
12213
12213
  var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
12214
12214
  var _a3;
12215
12215
  inst._zod ?? (inst._zod = {});
@@ -12757,7 +12757,7 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
12757
12757
  };
12758
12758
  });
12759
12759
 
12760
- // node_modules/zod/v4/core/doc.js
12760
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/doc.js
12761
12761
  var Doc = class {
12762
12762
  constructor(args = []) {
12763
12763
  this.content = [];
@@ -12793,14 +12793,14 @@ var Doc = class {
12793
12793
  }
12794
12794
  };
12795
12795
 
12796
- // node_modules/zod/v4/core/versions.js
12796
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/versions.js
12797
12797
  var version = {
12798
12798
  major: 4,
12799
12799
  minor: 4,
12800
12800
  patch: 3
12801
12801
  };
12802
12802
 
12803
- // node_modules/zod/v4/core/schemas.js
12803
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/schemas.js
12804
12804
  var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
12805
12805
  var _a3;
12806
12806
  inst ?? (inst = {});
@@ -14893,7 +14893,7 @@ function handleRefineResult(result, payload, input, inst) {
14893
14893
  }
14894
14894
  }
14895
14895
 
14896
- // node_modules/zod/v4/locales/index.js
14896
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/index.js
14897
14897
  var locales_exports = {};
14898
14898
  __export(locales_exports, {
14899
14899
  ar: () => ar_default,
@@ -14950,7 +14950,7 @@ __export(locales_exports, {
14950
14950
  zhTW: () => zh_TW_default
14951
14951
  });
14952
14952
 
14953
- // node_modules/zod/v4/locales/ar.js
14953
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ar.js
14954
14954
  var error = () => {
14955
14955
  const Sizable = {
14956
14956
  string: { unit: "\u062D\u0631\u0641", verb: "\u0623\u0646 \u064A\u062D\u0648\u064A" },
@@ -15057,7 +15057,7 @@ function ar_default() {
15057
15057
  };
15058
15058
  }
15059
15059
 
15060
- // node_modules/zod/v4/locales/az.js
15060
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/az.js
15061
15061
  var error2 = () => {
15062
15062
  const Sizable = {
15063
15063
  string: { unit: "simvol", verb: "olmal\u0131d\u0131r" },
@@ -15163,7 +15163,7 @@ function az_default() {
15163
15163
  };
15164
15164
  }
15165
15165
 
15166
- // node_modules/zod/v4/locales/be.js
15166
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/be.js
15167
15167
  function getBelarusianPlural(count, one, few, many) {
15168
15168
  const absCount = Math.abs(count);
15169
15169
  const lastDigit = absCount % 10;
@@ -15320,7 +15320,7 @@ function be_default() {
15320
15320
  };
15321
15321
  }
15322
15322
 
15323
- // node_modules/zod/v4/locales/bg.js
15323
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/bg.js
15324
15324
  var error4 = () => {
15325
15325
  const Sizable = {
15326
15326
  string: { unit: "\u0441\u0438\u043C\u0432\u043E\u043B\u0430", verb: "\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430" },
@@ -15441,7 +15441,7 @@ function bg_default() {
15441
15441
  };
15442
15442
  }
15443
15443
 
15444
- // node_modules/zod/v4/locales/ca.js
15444
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ca.js
15445
15445
  var error5 = () => {
15446
15446
  const Sizable = {
15447
15447
  string: { unit: "car\xE0cters", verb: "contenir" },
@@ -15550,7 +15550,7 @@ function ca_default() {
15550
15550
  };
15551
15551
  }
15552
15552
 
15553
- // node_modules/zod/v4/locales/cs.js
15553
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/cs.js
15554
15554
  var error6 = () => {
15555
15555
  const Sizable = {
15556
15556
  string: { unit: "znak\u016F", verb: "m\xEDt" },
@@ -15662,7 +15662,7 @@ function cs_default() {
15662
15662
  };
15663
15663
  }
15664
15664
 
15665
- // node_modules/zod/v4/locales/da.js
15665
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/da.js
15666
15666
  var error7 = () => {
15667
15667
  const Sizable = {
15668
15668
  string: { unit: "tegn", verb: "havde" },
@@ -15778,7 +15778,7 @@ function da_default() {
15778
15778
  };
15779
15779
  }
15780
15780
 
15781
- // node_modules/zod/v4/locales/de.js
15781
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/de.js
15782
15782
  var error8 = () => {
15783
15783
  const Sizable = {
15784
15784
  string: { unit: "Zeichen", verb: "zu haben" },
@@ -15887,7 +15887,7 @@ function de_default() {
15887
15887
  };
15888
15888
  }
15889
15889
 
15890
- // node_modules/zod/v4/locales/el.js
15890
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/el.js
15891
15891
  var error9 = () => {
15892
15892
  const Sizable = {
15893
15893
  string: { unit: "\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2", verb: "\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9" },
@@ -15997,7 +15997,7 @@ function el_default() {
15997
15997
  };
15998
15998
  }
15999
15999
 
16000
- // node_modules/zod/v4/locales/en.js
16000
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/en.js
16001
16001
  var error10 = () => {
16002
16002
  const Sizable = {
16003
16003
  string: { unit: "characters", verb: "to have" },
@@ -16110,7 +16110,7 @@ function en_default2() {
16110
16110
  };
16111
16111
  }
16112
16112
 
16113
- // node_modules/zod/v4/locales/eo.js
16113
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/eo.js
16114
16114
  var error11 = () => {
16115
16115
  const Sizable = {
16116
16116
  string: { unit: "karaktrojn", verb: "havi" },
@@ -16220,7 +16220,7 @@ function eo_default() {
16220
16220
  };
16221
16221
  }
16222
16222
 
16223
- // node_modules/zod/v4/locales/es.js
16223
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/es.js
16224
16224
  var error12 = () => {
16225
16225
  const Sizable = {
16226
16226
  string: { unit: "caracteres", verb: "tener" },
@@ -16353,7 +16353,7 @@ function es_default() {
16353
16353
  };
16354
16354
  }
16355
16355
 
16356
- // node_modules/zod/v4/locales/fa.js
16356
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/fa.js
16357
16357
  var error13 = () => {
16358
16358
  const Sizable = {
16359
16359
  string: { unit: "\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631", verb: "\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F" },
@@ -16468,7 +16468,7 @@ function fa_default() {
16468
16468
  };
16469
16469
  }
16470
16470
 
16471
- // node_modules/zod/v4/locales/fi.js
16471
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/fi.js
16472
16472
  var error14 = () => {
16473
16473
  const Sizable = {
16474
16474
  string: { unit: "merkki\xE4", subject: "merkkijonon" },
@@ -16581,7 +16581,7 @@ function fi_default() {
16581
16581
  };
16582
16582
  }
16583
16583
 
16584
- // node_modules/zod/v4/locales/fr.js
16584
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/fr.js
16585
16585
  var error15 = () => {
16586
16586
  const Sizable = {
16587
16587
  string: { unit: "caract\xE8res", verb: "avoir" },
@@ -16707,7 +16707,7 @@ function fr_default() {
16707
16707
  };
16708
16708
  }
16709
16709
 
16710
- // node_modules/zod/v4/locales/fr-CA.js
16710
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/fr-CA.js
16711
16711
  var error16 = () => {
16712
16712
  const Sizable = {
16713
16713
  string: { unit: "caract\xE8res", verb: "avoir" },
@@ -16815,7 +16815,7 @@ function fr_CA_default() {
16815
16815
  };
16816
16816
  }
16817
16817
 
16818
- // node_modules/zod/v4/locales/he.js
16818
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/he.js
16819
16819
  var error17 = () => {
16820
16820
  const TypeNames = {
16821
16821
  string: { label: "\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA", gender: "f" },
@@ -17010,7 +17010,7 @@ function he_default() {
17010
17010
  };
17011
17011
  }
17012
17012
 
17013
- // node_modules/zod/v4/locales/hr.js
17013
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/hr.js
17014
17014
  var error18 = () => {
17015
17015
  const Sizable = {
17016
17016
  string: { unit: "znakova", verb: "imati" },
@@ -17133,7 +17133,7 @@ function hr_default() {
17133
17133
  };
17134
17134
  }
17135
17135
 
17136
- // node_modules/zod/v4/locales/hu.js
17136
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/hu.js
17137
17137
  var error19 = () => {
17138
17138
  const Sizable = {
17139
17139
  string: { unit: "karakter", verb: "legyen" },
@@ -17242,7 +17242,7 @@ function hu_default() {
17242
17242
  };
17243
17243
  }
17244
17244
 
17245
- // node_modules/zod/v4/locales/hy.js
17245
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/hy.js
17246
17246
  function getArmenianPlural(count, one, many) {
17247
17247
  return Math.abs(count) === 1 ? one : many;
17248
17248
  }
@@ -17390,7 +17390,7 @@ function hy_default() {
17390
17390
  };
17391
17391
  }
17392
17392
 
17393
- // node_modules/zod/v4/locales/id.js
17393
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/id.js
17394
17394
  var error21 = () => {
17395
17395
  const Sizable = {
17396
17396
  string: { unit: "karakter", verb: "memiliki" },
@@ -17497,7 +17497,7 @@ function id_default() {
17497
17497
  };
17498
17498
  }
17499
17499
 
17500
- // node_modules/zod/v4/locales/is.js
17500
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/is.js
17501
17501
  var error22 = () => {
17502
17502
  const Sizable = {
17503
17503
  string: { unit: "stafi", verb: "a\xF0 hafa" },
@@ -17607,7 +17607,7 @@ function is_default() {
17607
17607
  };
17608
17608
  }
17609
17609
 
17610
- // node_modules/zod/v4/locales/it.js
17610
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/it.js
17611
17611
  var error23 = () => {
17612
17612
  const Sizable = {
17613
17613
  string: { unit: "caratteri", verb: "avere" },
@@ -17716,7 +17716,7 @@ function it_default() {
17716
17716
  };
17717
17717
  }
17718
17718
 
17719
- // node_modules/zod/v4/locales/ja.js
17719
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ja.js
17720
17720
  var error24 = () => {
17721
17721
  const Sizable = {
17722
17722
  string: { unit: "\u6587\u5B57", verb: "\u3067\u3042\u308B" },
@@ -17824,7 +17824,7 @@ function ja_default() {
17824
17824
  };
17825
17825
  }
17826
17826
 
17827
- // node_modules/zod/v4/locales/ka.js
17827
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ka.js
17828
17828
  var error25 = () => {
17829
17829
  const Sizable = {
17830
17830
  string: { unit: "\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD", verb: "\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1" },
@@ -17937,7 +17937,7 @@ function ka_default() {
17937
17937
  };
17938
17938
  }
17939
17939
 
17940
- // node_modules/zod/v4/locales/km.js
17940
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/km.js
17941
17941
  var error26 = () => {
17942
17942
  const Sizable = {
17943
17943
  string: { unit: "\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A", verb: "\u1782\u17BD\u179A\u1798\u17B6\u1793" },
@@ -18048,12 +18048,12 @@ function km_default() {
18048
18048
  };
18049
18049
  }
18050
18050
 
18051
- // node_modules/zod/v4/locales/kh.js
18051
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/kh.js
18052
18052
  function kh_default() {
18053
18053
  return km_default();
18054
18054
  }
18055
18055
 
18056
- // node_modules/zod/v4/locales/ko.js
18056
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ko.js
18057
18057
  var error27 = () => {
18058
18058
  const Sizable = {
18059
18059
  string: { unit: "\uBB38\uC790", verb: "to have" },
@@ -18165,7 +18165,7 @@ function ko_default() {
18165
18165
  };
18166
18166
  }
18167
18167
 
18168
- // node_modules/zod/v4/locales/lt.js
18168
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/lt.js
18169
18169
  var capitalizeFirstCharacter = (text) => {
18170
18170
  return text.charAt(0).toUpperCase() + text.slice(1);
18171
18171
  };
@@ -18369,7 +18369,7 @@ function lt_default() {
18369
18369
  };
18370
18370
  }
18371
18371
 
18372
- // node_modules/zod/v4/locales/mk.js
18372
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/mk.js
18373
18373
  var error29 = () => {
18374
18374
  const Sizable = {
18375
18375
  string: { unit: "\u0437\u043D\u0430\u0446\u0438", verb: "\u0434\u0430 \u0438\u043C\u0430\u0430\u0442" },
@@ -18479,7 +18479,7 @@ function mk_default() {
18479
18479
  };
18480
18480
  }
18481
18481
 
18482
- // node_modules/zod/v4/locales/ms.js
18482
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ms.js
18483
18483
  var error30 = () => {
18484
18484
  const Sizable = {
18485
18485
  string: { unit: "aksara", verb: "mempunyai" },
@@ -18587,7 +18587,7 @@ function ms_default() {
18587
18587
  };
18588
18588
  }
18589
18589
 
18590
- // node_modules/zod/v4/locales/nl.js
18590
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/nl.js
18591
18591
  var error31 = () => {
18592
18592
  const Sizable = {
18593
18593
  string: { unit: "tekens", verb: "heeft" },
@@ -18698,7 +18698,7 @@ function nl_default() {
18698
18698
  };
18699
18699
  }
18700
18700
 
18701
- // node_modules/zod/v4/locales/no.js
18701
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/no.js
18702
18702
  var error32 = () => {
18703
18703
  const Sizable = {
18704
18704
  string: { unit: "tegn", verb: "\xE5 ha" },
@@ -18807,7 +18807,7 @@ function no_default() {
18807
18807
  };
18808
18808
  }
18809
18809
 
18810
- // node_modules/zod/v4/locales/ota.js
18810
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ota.js
18811
18811
  var error33 = () => {
18812
18812
  const Sizable = {
18813
18813
  string: { unit: "harf", verb: "olmal\u0131d\u0131r" },
@@ -18917,7 +18917,7 @@ function ota_default() {
18917
18917
  };
18918
18918
  }
18919
18919
 
18920
- // node_modules/zod/v4/locales/ps.js
18920
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ps.js
18921
18921
  var error34 = () => {
18922
18922
  const Sizable = {
18923
18923
  string: { unit: "\u062A\u0648\u06A9\u064A", verb: "\u0648\u0644\u0631\u064A" },
@@ -19032,7 +19032,7 @@ function ps_default() {
19032
19032
  };
19033
19033
  }
19034
19034
 
19035
- // node_modules/zod/v4/locales/pl.js
19035
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/pl.js
19036
19036
  var error35 = () => {
19037
19037
  const Sizable = {
19038
19038
  string: { unit: "znak\xF3w", verb: "mie\u0107" },
@@ -19142,7 +19142,7 @@ function pl_default() {
19142
19142
  };
19143
19143
  }
19144
19144
 
19145
- // node_modules/zod/v4/locales/pt.js
19145
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/pt.js
19146
19146
  var error36 = () => {
19147
19147
  const Sizable = {
19148
19148
  string: { unit: "caracteres", verb: "ter" },
@@ -19251,7 +19251,7 @@ function pt_default() {
19251
19251
  };
19252
19252
  }
19253
19253
 
19254
- // node_modules/zod/v4/locales/ro.js
19254
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ro.js
19255
19255
  var error37 = () => {
19256
19256
  const Sizable = {
19257
19257
  string: { unit: "caractere", verb: "s\u0103 aib\u0103" },
@@ -19371,7 +19371,7 @@ function ro_default() {
19371
19371
  };
19372
19372
  }
19373
19373
 
19374
- // node_modules/zod/v4/locales/ru.js
19374
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ru.js
19375
19375
  function getRussianPlural(count, one, few, many) {
19376
19376
  const absCount = Math.abs(count);
19377
19377
  const lastDigit = absCount % 10;
@@ -19528,7 +19528,7 @@ function ru_default() {
19528
19528
  };
19529
19529
  }
19530
19530
 
19531
- // node_modules/zod/v4/locales/sl.js
19531
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/sl.js
19532
19532
  var error39 = () => {
19533
19533
  const Sizable = {
19534
19534
  string: { unit: "znakov", verb: "imeti" },
@@ -19638,7 +19638,7 @@ function sl_default() {
19638
19638
  };
19639
19639
  }
19640
19640
 
19641
- // node_modules/zod/v4/locales/sv.js
19641
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/sv.js
19642
19642
  var error40 = () => {
19643
19643
  const Sizable = {
19644
19644
  string: { unit: "tecken", verb: "att ha" },
@@ -19749,7 +19749,7 @@ function sv_default() {
19749
19749
  };
19750
19750
  }
19751
19751
 
19752
- // node_modules/zod/v4/locales/ta.js
19752
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ta.js
19753
19753
  var error41 = () => {
19754
19754
  const Sizable = {
19755
19755
  string: { unit: "\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD", verb: "\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD" },
@@ -19860,7 +19860,7 @@ function ta_default() {
19860
19860
  };
19861
19861
  }
19862
19862
 
19863
- // node_modules/zod/v4/locales/th.js
19863
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/th.js
19864
19864
  var error42 = () => {
19865
19865
  const Sizable = {
19866
19866
  string: { unit: "\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23", verb: "\u0E04\u0E27\u0E23\u0E21\u0E35" },
@@ -19971,7 +19971,7 @@ function th_default() {
19971
19971
  };
19972
19972
  }
19973
19973
 
19974
- // node_modules/zod/v4/locales/tr.js
19974
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/tr.js
19975
19975
  var error43 = () => {
19976
19976
  const Sizable = {
19977
19977
  string: { unit: "karakter", verb: "olmal\u0131" },
@@ -20077,7 +20077,7 @@ function tr_default() {
20077
20077
  };
20078
20078
  }
20079
20079
 
20080
- // node_modules/zod/v4/locales/uk.js
20080
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/uk.js
20081
20081
  var error44 = () => {
20082
20082
  const Sizable = {
20083
20083
  string: { unit: "\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432", verb: "\u043C\u0430\u0442\u0438\u043C\u0435" },
@@ -20186,12 +20186,12 @@ function uk_default() {
20186
20186
  };
20187
20187
  }
20188
20188
 
20189
- // node_modules/zod/v4/locales/ua.js
20189
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ua.js
20190
20190
  function ua_default() {
20191
20191
  return uk_default();
20192
20192
  }
20193
20193
 
20194
- // node_modules/zod/v4/locales/ur.js
20194
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ur.js
20195
20195
  var error45 = () => {
20196
20196
  const Sizable = {
20197
20197
  string: { unit: "\u062D\u0631\u0648\u0641", verb: "\u06C1\u0648\u0646\u0627" },
@@ -20302,7 +20302,7 @@ function ur_default() {
20302
20302
  };
20303
20303
  }
20304
20304
 
20305
- // node_modules/zod/v4/locales/uz.js
20305
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/uz.js
20306
20306
  var error46 = () => {
20307
20307
  const Sizable = {
20308
20308
  string: { unit: "belgi", verb: "bo\u2018lishi kerak" },
@@ -20413,7 +20413,7 @@ function uz_default() {
20413
20413
  };
20414
20414
  }
20415
20415
 
20416
- // node_modules/zod/v4/locales/vi.js
20416
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/vi.js
20417
20417
  var error47 = () => {
20418
20418
  const Sizable = {
20419
20419
  string: { unit: "k\xFD t\u1EF1", verb: "c\xF3" },
@@ -20522,7 +20522,7 @@ function vi_default() {
20522
20522
  };
20523
20523
  }
20524
20524
 
20525
- // node_modules/zod/v4/locales/zh-CN.js
20525
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/zh-CN.js
20526
20526
  var error48 = () => {
20527
20527
  const Sizable = {
20528
20528
  string: { unit: "\u5B57\u7B26", verb: "\u5305\u542B" },
@@ -20632,7 +20632,7 @@ function zh_CN_default() {
20632
20632
  };
20633
20633
  }
20634
20634
 
20635
- // node_modules/zod/v4/locales/zh-TW.js
20635
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/zh-TW.js
20636
20636
  var error49 = () => {
20637
20637
  const Sizable = {
20638
20638
  string: { unit: "\u5B57\u5143", verb: "\u64C1\u6709" },
@@ -20740,7 +20740,7 @@ function zh_TW_default() {
20740
20740
  };
20741
20741
  }
20742
20742
 
20743
- // node_modules/zod/v4/locales/yo.js
20743
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/yo.js
20744
20744
  var error50 = () => {
20745
20745
  const Sizable = {
20746
20746
  string: { unit: "\xE0mi", verb: "n\xED" },
@@ -20848,7 +20848,7 @@ function yo_default() {
20848
20848
  };
20849
20849
  }
20850
20850
 
20851
- // node_modules/zod/v4/core/registries.js
20851
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/registries.js
20852
20852
  var _a2;
20853
20853
  var $output = /* @__PURE__ */ Symbol("ZodOutput");
20854
20854
  var $input = /* @__PURE__ */ Symbol("ZodInput");
@@ -20898,7 +20898,7 @@ function registry() {
20898
20898
  (_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
20899
20899
  var globalRegistry = globalThis.__zod_globalRegistry;
20900
20900
 
20901
- // node_modules/zod/v4/core/api.js
20901
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/api.js
20902
20902
  // @__NO_SIDE_EFFECTS__
20903
20903
  function _string(Class2, params) {
20904
20904
  return new Class2({
@@ -21937,7 +21937,7 @@ function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
21937
21937
  return inst;
21938
21938
  }
21939
21939
 
21940
- // node_modules/zod/v4/core/to-json-schema.js
21940
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/to-json-schema.js
21941
21941
  function initializeContext(params) {
21942
21942
  let target = params?.target ?? "draft-2020-12";
21943
21943
  if (target === "draft-4")
@@ -22296,7 +22296,7 @@ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) =
22296
22296
  return finalize(ctx, schema);
22297
22297
  };
22298
22298
 
22299
- // node_modules/zod/v4/core/json-schema-processors.js
22299
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/json-schema-processors.js
22300
22300
  var formatMap = {
22301
22301
  guid: "uuid",
22302
22302
  url: "uri",
@@ -22840,7 +22840,7 @@ function toJSONSchema(input, params) {
22840
22840
  return finalize(ctx, input);
22841
22841
  }
22842
22842
 
22843
- // node_modules/zod/v4/core/json-schema-generator.js
22843
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/json-schema-generator.js
22844
22844
  var JSONSchemaGenerator = class {
22845
22845
  /** @deprecated Access via ctx instead */
22846
22846
  get metadataRegistry() {
@@ -22915,10 +22915,10 @@ var JSONSchemaGenerator = class {
22915
22915
  }
22916
22916
  };
22917
22917
 
22918
- // node_modules/zod/v4/core/json-schema.js
22918
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/json-schema.js
22919
22919
  var json_schema_exports = {};
22920
22920
 
22921
- // node_modules/zod/v4/mini/schemas.js
22921
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/mini/schemas.js
22922
22922
  var ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
22923
22923
  if (!inst._zod)
22924
22924
  throw new Error("Uninitialized schema in ZodMiniType.");
@@ -22964,7 +22964,7 @@ function object(shape, params) {
22964
22964
  return new ZodMiniObject(def);
22965
22965
  }
22966
22966
 
22967
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
22967
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
22968
22968
  function isZ4Schema(s) {
22969
22969
  const schema = s;
22970
22970
  return !!schema._zod;
@@ -23108,7 +23108,7 @@ function getLiteralValue(schema) {
23108
23108
  return void 0;
23109
23109
  }
23110
23110
 
23111
- // node_modules/zod/v4/classic/external.js
23111
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/external.js
23112
23112
  var external_exports = {};
23113
23113
  __export(external_exports, {
23114
23114
  $brand: () => $brand,
@@ -23351,7 +23351,7 @@ __export(external_exports, {
23351
23351
  xor: () => xor
23352
23352
  });
23353
23353
 
23354
- // node_modules/zod/v4/classic/schemas.js
23354
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/schemas.js
23355
23355
  var schemas_exports2 = {};
23356
23356
  __export(schemas_exports2, {
23357
23357
  ZodAny: () => ZodAny2,
@@ -23522,7 +23522,7 @@ __export(schemas_exports2, {
23522
23522
  xor: () => xor
23523
23523
  });
23524
23524
 
23525
- // node_modules/zod/v4/classic/checks.js
23525
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/checks.js
23526
23526
  var checks_exports2 = {};
23527
23527
  __export(checks_exports2, {
23528
23528
  endsWith: () => _endsWith,
@@ -23556,7 +23556,7 @@ __export(checks_exports2, {
23556
23556
  uppercase: () => _uppercase
23557
23557
  });
23558
23558
 
23559
- // node_modules/zod/v4/classic/iso.js
23559
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/iso.js
23560
23560
  var iso_exports2 = {};
23561
23561
  __export(iso_exports2, {
23562
23562
  ZodISODate: () => ZodISODate,
@@ -23597,7 +23597,7 @@ function duration2(params) {
23597
23597
  return _isoDuration(ZodISODuration, params);
23598
23598
  }
23599
23599
 
23600
- // node_modules/zod/v4/classic/errors.js
23600
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/errors.js
23601
23601
  var initializer2 = (inst, issues) => {
23602
23602
  $ZodError.init(inst, issues);
23603
23603
  inst.name = "ZodError";
@@ -23637,7 +23637,7 @@ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, {
23637
23637
  Parent: Error
23638
23638
  });
23639
23639
 
23640
- // node_modules/zod/v4/classic/parse.js
23640
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/parse.js
23641
23641
  var parse2 = /* @__PURE__ */ _parse(ZodRealError);
23642
23642
  var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
23643
23643
  var safeParse3 = /* @__PURE__ */ _safeParse(ZodRealError);
@@ -23651,7 +23651,7 @@ var safeDecode2 = /* @__PURE__ */ _safeDecode(ZodRealError);
23651
23651
  var safeEncodeAsync2 = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
23652
23652
  var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
23653
23653
 
23654
- // node_modules/zod/v4/classic/schemas.js
23654
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/schemas.js
23655
23655
  var _installedGroups = /* @__PURE__ */ new WeakMap();
23656
23656
  function _installLazyMethods(inst, group, methods) {
23657
23657
  const proto = Object.getPrototypeOf(inst);
@@ -24941,7 +24941,7 @@ function preprocess(fn, schema) {
24941
24941
  });
24942
24942
  }
24943
24943
 
24944
- // node_modules/zod/v4/classic/compat.js
24944
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/compat.js
24945
24945
  var ZodIssueCode2 = {
24946
24946
  invalid_type: "invalid_type",
24947
24947
  too_big: "too_big",
@@ -24967,7 +24967,7 @@ var ZodFirstPartyTypeKind2;
24967
24967
  /* @__PURE__ */ (function(ZodFirstPartyTypeKind3) {
24968
24968
  })(ZodFirstPartyTypeKind2 || (ZodFirstPartyTypeKind2 = {}));
24969
24969
 
24970
- // node_modules/zod/v4/classic/from-json-schema.js
24970
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/from-json-schema.js
24971
24971
  var z = {
24972
24972
  ...schemas_exports2,
24973
24973
  ...checks_exports2,
@@ -25447,7 +25447,7 @@ function fromJSONSchema(schema, params) {
25447
25447
  return convertSchema(normalized, ctx);
25448
25448
  }
25449
25449
 
25450
- // node_modules/zod/v4/classic/coerce.js
25450
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/coerce.js
25451
25451
  var coerce_exports2 = {};
25452
25452
  __export(coerce_exports2, {
25453
25453
  bigint: () => bigint3,
@@ -25472,10 +25472,10 @@ function date4(params) {
25472
25472
  return _coercedDate(ZodDate2, params);
25473
25473
  }
25474
25474
 
25475
- // node_modules/zod/v4/classic/external.js
25475
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/external.js
25476
25476
  config(en_default2());
25477
25477
 
25478
- // node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
25478
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
25479
25479
  var LATEST_PROTOCOL_VERSION = "2025-11-25";
25480
25480
  var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
25481
25481
  var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
@@ -27006,12 +27006,12 @@ var UrlElicitationRequiredError = class extends McpError {
27006
27006
  }
27007
27007
  };
27008
27008
 
27009
- // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
27009
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
27010
27010
  function isTerminal(status) {
27011
27011
  return status === "completed" || status === "failed" || status === "cancelled";
27012
27012
  }
27013
27013
 
27014
- // node_modules/zod-to-json-schema/dist/esm/Options.js
27014
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/Options.js
27015
27015
  var ignoreOverride = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
27016
27016
  var defaultOptions = {
27017
27017
  name: void 0,
@@ -27045,7 +27045,7 @@ var getDefaultOptions = (options) => typeof options === "string" ? {
27045
27045
  ...options
27046
27046
  };
27047
27047
 
27048
- // node_modules/zod-to-json-schema/dist/esm/Refs.js
27048
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/Refs.js
27049
27049
  var getRefs = (options) => {
27050
27050
  const _options = getDefaultOptions(options);
27051
27051
  const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
@@ -27066,7 +27066,7 @@ var getRefs = (options) => {
27066
27066
  };
27067
27067
  };
27068
27068
 
27069
- // node_modules/zod-to-json-schema/dist/esm/errorMessages.js
27069
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
27070
27070
  function addErrorMessage(res, key, errorMessage, refs) {
27071
27071
  if (!refs?.errorMessages)
27072
27072
  return;
@@ -27082,7 +27082,7 @@ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
27082
27082
  addErrorMessage(res, key, errorMessage, refs);
27083
27083
  }
27084
27084
 
27085
- // node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
27085
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
27086
27086
  var getRelativePath = (pathA, pathB) => {
27087
27087
  let i = 0;
27088
27088
  for (; i < pathA.length && i < pathB.length; i++) {
@@ -27092,7 +27092,7 @@ var getRelativePath = (pathA, pathB) => {
27092
27092
  return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
27093
27093
  };
27094
27094
 
27095
- // node_modules/zod-to-json-schema/dist/esm/parsers/any.js
27095
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
27096
27096
  function parseAnyDef(refs) {
27097
27097
  if (refs.target !== "openAi") {
27098
27098
  return {};
@@ -27108,7 +27108,7 @@ function parseAnyDef(refs) {
27108
27108
  };
27109
27109
  }
27110
27110
 
27111
- // node_modules/zod-to-json-schema/dist/esm/parsers/array.js
27111
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
27112
27112
  function parseArrayDef(def, refs) {
27113
27113
  const res = {
27114
27114
  type: "array"
@@ -27132,7 +27132,7 @@ function parseArrayDef(def, refs) {
27132
27132
  return res;
27133
27133
  }
27134
27134
 
27135
- // node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
27135
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
27136
27136
  function parseBigintDef(def, refs) {
27137
27137
  const res = {
27138
27138
  type: "integer",
@@ -27178,24 +27178,24 @@ function parseBigintDef(def, refs) {
27178
27178
  return res;
27179
27179
  }
27180
27180
 
27181
- // node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
27181
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
27182
27182
  function parseBooleanDef() {
27183
27183
  return {
27184
27184
  type: "boolean"
27185
27185
  };
27186
27186
  }
27187
27187
 
27188
- // node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
27188
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
27189
27189
  function parseBrandedDef(_def, refs) {
27190
27190
  return parseDef(_def.type._def, refs);
27191
27191
  }
27192
27192
 
27193
- // node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
27193
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
27194
27194
  var parseCatchDef = (def, refs) => {
27195
27195
  return parseDef(def.innerType._def, refs);
27196
27196
  };
27197
27197
 
27198
- // node_modules/zod-to-json-schema/dist/esm/parsers/date.js
27198
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
27199
27199
  function parseDateDef(def, refs, overrideDateStrategy) {
27200
27200
  const strategy = overrideDateStrategy ?? refs.dateStrategy;
27201
27201
  if (Array.isArray(strategy)) {
@@ -27254,7 +27254,7 @@ var integerDateParser = (def, refs) => {
27254
27254
  return res;
27255
27255
  };
27256
27256
 
27257
- // node_modules/zod-to-json-schema/dist/esm/parsers/default.js
27257
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
27258
27258
  function parseDefaultDef(_def, refs) {
27259
27259
  return {
27260
27260
  ...parseDef(_def.innerType._def, refs),
@@ -27262,12 +27262,12 @@ function parseDefaultDef(_def, refs) {
27262
27262
  };
27263
27263
  }
27264
27264
 
27265
- // node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
27265
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
27266
27266
  function parseEffectsDef(_def, refs) {
27267
27267
  return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
27268
27268
  }
27269
27269
 
27270
- // node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
27270
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
27271
27271
  function parseEnumDef(def) {
27272
27272
  return {
27273
27273
  type: "string",
@@ -27275,7 +27275,7 @@ function parseEnumDef(def) {
27275
27275
  };
27276
27276
  }
27277
27277
 
27278
- // node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
27278
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
27279
27279
  var isJsonSchema7AllOfType = (type) => {
27280
27280
  if ("type" in type && type.type === "string")
27281
27281
  return false;
@@ -27317,7 +27317,7 @@ function parseIntersectionDef(def, refs) {
27317
27317
  } : void 0;
27318
27318
  }
27319
27319
 
27320
- // node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
27320
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
27321
27321
  function parseLiteralDef(def, refs) {
27322
27322
  const parsedType2 = typeof def.value;
27323
27323
  if (parsedType2 !== "bigint" && parsedType2 !== "number" && parsedType2 !== "boolean" && parsedType2 !== "string") {
@@ -27337,7 +27337,7 @@ function parseLiteralDef(def, refs) {
27337
27337
  };
27338
27338
  }
27339
27339
 
27340
- // node_modules/zod-to-json-schema/dist/esm/parsers/string.js
27340
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
27341
27341
  var emojiRegex2 = void 0;
27342
27342
  var zodPatterns = {
27343
27343
  /**
@@ -27662,7 +27662,7 @@ function stringifyRegExpWithFlags(regex, refs) {
27662
27662
  return pattern;
27663
27663
  }
27664
27664
 
27665
- // node_modules/zod-to-json-schema/dist/esm/parsers/record.js
27665
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
27666
27666
  function parseRecordDef(def, refs) {
27667
27667
  if (refs.target === "openAi") {
27668
27668
  console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
@@ -27714,7 +27714,7 @@ function parseRecordDef(def, refs) {
27714
27714
  return schema;
27715
27715
  }
27716
27716
 
27717
- // node_modules/zod-to-json-schema/dist/esm/parsers/map.js
27717
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
27718
27718
  function parseMapDef(def, refs) {
27719
27719
  if (refs.mapStrategy === "record") {
27720
27720
  return parseRecordDef(def, refs);
@@ -27739,7 +27739,7 @@ function parseMapDef(def, refs) {
27739
27739
  };
27740
27740
  }
27741
27741
 
27742
- // node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
27742
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
27743
27743
  function parseNativeEnumDef(def) {
27744
27744
  const object3 = def.values;
27745
27745
  const actualKeys = Object.keys(def.values).filter((key) => {
@@ -27753,7 +27753,7 @@ function parseNativeEnumDef(def) {
27753
27753
  };
27754
27754
  }
27755
27755
 
27756
- // node_modules/zod-to-json-schema/dist/esm/parsers/never.js
27756
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
27757
27757
  function parseNeverDef(refs) {
27758
27758
  return refs.target === "openAi" ? void 0 : {
27759
27759
  not: parseAnyDef({
@@ -27763,7 +27763,7 @@ function parseNeverDef(refs) {
27763
27763
  };
27764
27764
  }
27765
27765
 
27766
- // node_modules/zod-to-json-schema/dist/esm/parsers/null.js
27766
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
27767
27767
  function parseNullDef(refs) {
27768
27768
  return refs.target === "openApi3" ? {
27769
27769
  enum: ["null"],
@@ -27773,7 +27773,7 @@ function parseNullDef(refs) {
27773
27773
  };
27774
27774
  }
27775
27775
 
27776
- // node_modules/zod-to-json-schema/dist/esm/parsers/union.js
27776
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
27777
27777
  var primitiveMappings = {
27778
27778
  ZodString: "string",
27779
27779
  ZodNumber: "number",
@@ -27841,7 +27841,7 @@ var asAnyOf = (def, refs) => {
27841
27841
  return anyOf.length ? { anyOf } : void 0;
27842
27842
  };
27843
27843
 
27844
- // node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
27844
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
27845
27845
  function parseNullableDef(def, refs) {
27846
27846
  if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
27847
27847
  if (refs.target === "openApi3") {
@@ -27873,7 +27873,7 @@ function parseNullableDef(def, refs) {
27873
27873
  return base && { anyOf: [base, { type: "null" }] };
27874
27874
  }
27875
27875
 
27876
- // node_modules/zod-to-json-schema/dist/esm/parsers/number.js
27876
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
27877
27877
  function parseNumberDef(def, refs) {
27878
27878
  const res = {
27879
27879
  type: "number"
@@ -27922,7 +27922,7 @@ function parseNumberDef(def, refs) {
27922
27922
  return res;
27923
27923
  }
27924
27924
 
27925
- // node_modules/zod-to-json-schema/dist/esm/parsers/object.js
27925
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
27926
27926
  function parseObjectDef(def, refs) {
27927
27927
  const forceOptionalIntoNullable = refs.target === "openAi";
27928
27928
  const result = {
@@ -27992,7 +27992,7 @@ function safeIsOptional(schema) {
27992
27992
  }
27993
27993
  }
27994
27994
 
27995
- // node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
27995
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
27996
27996
  var parseOptionalDef = (def, refs) => {
27997
27997
  if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
27998
27998
  return parseDef(def.innerType._def, refs);
@@ -28011,7 +28011,7 @@ var parseOptionalDef = (def, refs) => {
28011
28011
  } : parseAnyDef(refs);
28012
28012
  };
28013
28013
 
28014
- // node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
28014
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
28015
28015
  var parsePipelineDef = (def, refs) => {
28016
28016
  if (refs.pipeStrategy === "input") {
28017
28017
  return parseDef(def.in._def, refs);
@@ -28031,12 +28031,12 @@ var parsePipelineDef = (def, refs) => {
28031
28031
  };
28032
28032
  };
28033
28033
 
28034
- // node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
28034
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
28035
28035
  function parsePromiseDef(def, refs) {
28036
28036
  return parseDef(def.type._def, refs);
28037
28037
  }
28038
28038
 
28039
- // node_modules/zod-to-json-schema/dist/esm/parsers/set.js
28039
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
28040
28040
  function parseSetDef(def, refs) {
28041
28041
  const items = parseDef(def.valueType._def, {
28042
28042
  ...refs,
@@ -28056,7 +28056,7 @@ function parseSetDef(def, refs) {
28056
28056
  return schema;
28057
28057
  }
28058
28058
 
28059
- // node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
28059
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
28060
28060
  function parseTupleDef(def, refs) {
28061
28061
  if (def.rest) {
28062
28062
  return {
@@ -28084,24 +28084,24 @@ function parseTupleDef(def, refs) {
28084
28084
  }
28085
28085
  }
28086
28086
 
28087
- // node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
28087
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
28088
28088
  function parseUndefinedDef(refs) {
28089
28089
  return {
28090
28090
  not: parseAnyDef(refs)
28091
28091
  };
28092
28092
  }
28093
28093
 
28094
- // node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
28094
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
28095
28095
  function parseUnknownDef(refs) {
28096
28096
  return parseAnyDef(refs);
28097
28097
  }
28098
28098
 
28099
- // node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
28099
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
28100
28100
  var parseReadonlyDef = (def, refs) => {
28101
28101
  return parseDef(def.innerType._def, refs);
28102
28102
  };
28103
28103
 
28104
- // node_modules/zod-to-json-schema/dist/esm/selectParser.js
28104
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/selectParser.js
28105
28105
  var selectParser = (def, typeName, refs) => {
28106
28106
  switch (typeName) {
28107
28107
  case ZodFirstPartyTypeKind.ZodString:
@@ -28177,7 +28177,7 @@ var selectParser = (def, typeName, refs) => {
28177
28177
  }
28178
28178
  };
28179
28179
 
28180
- // node_modules/zod-to-json-schema/dist/esm/parseDef.js
28180
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/parseDef.js
28181
28181
  function parseDef(def, refs, forceResolution = false) {
28182
28182
  const seenItem = refs.seen.get(def);
28183
28183
  if (refs.override) {
@@ -28233,7 +28233,7 @@ var addMeta = (def, refs, jsonSchema) => {
28233
28233
  return jsonSchema;
28234
28234
  };
28235
28235
 
28236
- // node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
28236
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
28237
28237
  var zodToJsonSchema = (schema, options) => {
28238
28238
  const refs = getRefs(options);
28239
28239
  let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => ({
@@ -28295,7 +28295,7 @@ var zodToJsonSchema = (schema, options) => {
28295
28295
  return combined;
28296
28296
  };
28297
28297
 
28298
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
28298
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
28299
28299
  function mapMiniTarget(t) {
28300
28300
  if (!t)
28301
28301
  return "draft-7";
@@ -28337,7 +28337,7 @@ function parseWithCompat(schema, data) {
28337
28337
  return result.data;
28338
28338
  }
28339
28339
 
28340
- // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
28340
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
28341
28341
  var DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
28342
28342
  var Protocol = class {
28343
28343
  constructor(_options) {
@@ -29291,7 +29291,7 @@ function mergeCapabilities(base, additional) {
29291
29291
  return result;
29292
29292
  }
29293
29293
 
29294
- // node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
29294
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
29295
29295
  var import_ajv = __toESM(require_ajv(), 1);
29296
29296
  var import_ajv_formats = __toESM(require_dist(), 1);
29297
29297
  function createDefaultAjvInstance() {
@@ -29359,7 +29359,7 @@ var AjvJsonSchemaValidator = class {
29359
29359
  }
29360
29360
  };
29361
29361
 
29362
- // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
29362
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
29363
29363
  var ExperimentalServerTasks = class {
29364
29364
  constructor(_server) {
29365
29365
  this._server = _server;
@@ -29572,7 +29572,7 @@ var ExperimentalServerTasks = class {
29572
29572
  }
29573
29573
  };
29574
29574
 
29575
- // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
29575
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
29576
29576
  function assertToolsCallTaskCapability(requests, method, entityName) {
29577
29577
  if (!requests) {
29578
29578
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
@@ -29607,7 +29607,7 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
29607
29607
  }
29608
29608
  }
29609
29609
 
29610
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
29610
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
29611
29611
  var Server = class extends Protocol {
29612
29612
  /**
29613
29613
  * Initializes this server with the given name and version information.
@@ -29987,7 +29987,7 @@ var Server = class extends Protocol {
29987
29987
  }
29988
29988
  };
29989
29989
 
29990
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
29990
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
29991
29991
  var COMPLETABLE_SYMBOL = /* @__PURE__ */ Symbol.for("mcp.completable");
29992
29992
  function isCompletable(schema) {
29993
29993
  return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
@@ -30001,7 +30001,7 @@ var McpZodTypeKind;
30001
30001
  McpZodTypeKind2["Completable"] = "McpCompletable";
30002
30002
  })(McpZodTypeKind || (McpZodTypeKind = {}));
30003
30003
 
30004
- // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
30004
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
30005
30005
  var TOOL_NAME_REGEX = /^[A-Za-z0-9._-]{1,128}$/;
30006
30006
  function validateToolName(name) {
30007
30007
  const warnings = [];
@@ -30059,7 +30059,7 @@ function validateAndWarnToolName(name) {
30059
30059
  return result.isValid;
30060
30060
  }
30061
30061
 
30062
- // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
30062
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
30063
30063
  var ExperimentalMcpServerTasks = class {
30064
30064
  constructor(_mcpServer) {
30065
30065
  this._mcpServer = _mcpServer;
@@ -30074,7 +30074,7 @@ var ExperimentalMcpServerTasks = class {
30074
30074
  }
30075
30075
  };
30076
30076
 
30077
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
30077
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
30078
30078
  var McpServer = class {
30079
30079
  constructor(serverInfo, options) {
30080
30080
  this._registeredResources = {};
@@ -30866,10 +30866,10 @@ var EMPTY_COMPLETION_RESULT = {
30866
30866
  }
30867
30867
  };
30868
30868
 
30869
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
30869
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
30870
30870
  import process3 from "node:process";
30871
30871
 
30872
- // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
30872
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
30873
30873
  var ReadBuffer = class {
30874
30874
  append(chunk) {
30875
30875
  this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
@@ -30897,7 +30897,7 @@ function serializeMessage(message) {
30897
30897
  return JSON.stringify(message) + "\n";
30898
30898
  }
30899
30899
 
30900
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
30900
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
30901
30901
  var StdioServerTransport = class {
30902
30902
  constructor(_stdin = process3.stdin, _stdout = process3.stdout) {
30903
30903
  this._stdin = _stdin;
@@ -30960,7 +30960,13 @@ var StdioServerTransport = class {
30960
30960
 
30961
30961
  // src/auth.ts
30962
30962
  import { createClient } from "@supabase/supabase-js";
30963
+
30964
+ // src/version.ts
30965
+ var VERSION = "0.8.0";
30966
+
30967
+ // src/auth.ts
30963
30968
  var SUPABASE_PROJECT_URL = "https://tifewzsimmyoiepblhld.supabase.co";
30969
+ var MCP_WRITE_PROTOCOL = 2;
30964
30970
  var supabase = null;
30965
30971
  var companyId = null;
30966
30972
  var refreshTimer = null;
@@ -30972,7 +30978,11 @@ async function authenticateWithApiKey(apiKey) {
30972
30978
  const response = await fetch(url2, {
30973
30979
  method: "POST",
30974
30980
  headers: { "Content-Type": "application/json" },
30975
- body: JSON.stringify({ api_key: apiKey }),
30981
+ body: JSON.stringify({
30982
+ api_key: apiKey,
30983
+ server_version: VERSION,
30984
+ write_protocol: MCP_WRITE_PROTOCOL
30985
+ }),
30976
30986
  signal: AbortSignal.timeout(1e4)
30977
30987
  });
30978
30988
  if (!response.ok) {
@@ -31174,7 +31184,322 @@ function getCompanyId() {
31174
31184
  }
31175
31185
 
31176
31186
  // src/utils.ts
31187
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
31177
31188
  import { createHash } from "node:crypto";
31189
+
31190
+ // src/response-budget.ts
31191
+ import { Buffer as Buffer2 } from "node:buffer";
31192
+ var SOFT_RESPONSE_BUDGET_BYTES = 50 * 1024;
31193
+ var HARD_RESPONSE_BUDGET_BYTES = 200 * 1024;
31194
+ var MAX_RECORDED_BYTES = 5 * 1024 * 1024;
31195
+ function measureJson(value) {
31196
+ try {
31197
+ return {
31198
+ bytes: Math.min(
31199
+ Buffer2.byteLength(JSON.stringify(value) ?? ""),
31200
+ MAX_RECORDED_BYTES
31201
+ ),
31202
+ serializable: true
31203
+ };
31204
+ } catch {
31205
+ return { bytes: MAX_RECORDED_BYTES, serializable: false };
31206
+ }
31207
+ }
31208
+ function measureJsonBytes(value) {
31209
+ return measureJson(value).bytes;
31210
+ }
31211
+ function applyResponseBudget(toolName, result, options = {}) {
31212
+ const measurement = measureJson(result);
31213
+ const responseBytes = measurement.bytes;
31214
+ if (responseBytes > HARD_RESPONSE_BUDGET_BYTES) {
31215
+ const guidance = options.writeBoundary ? "The bounded completion notice has been stored under this idempotencyKey. Do not repeat the write with a new key; reconcile with the matching read tool or the Kirjapro UI." : "Narrow the date range, reduce limit, or request the next page.";
31216
+ const reason = measurement.serializable ? `${toolName} produced ${responseBytes} bytes, above the ${HARD_RESPONSE_BUDGET_BYTES}-byte safety limit.` : `${toolName} produced a response that could not be serialized as JSON.`;
31217
+ return {
31218
+ result: {
31219
+ content: [{
31220
+ type: "text",
31221
+ text: `RESPONSE_BUDGET_EXCEEDED: ${reason} ${guidance}`
31222
+ }],
31223
+ isError: true
31224
+ },
31225
+ responseBytes,
31226
+ budgetOutcome: "rejected"
31227
+ };
31228
+ }
31229
+ return {
31230
+ result,
31231
+ responseBytes,
31232
+ budgetOutcome: responseBytes > SOFT_RESPONSE_BUDGET_BYTES ? "oversized" : "within"
31233
+ };
31234
+ }
31235
+
31236
+ // src/telemetry.ts
31237
+ import { AsyncLocalStorage } from "node:async_hooks";
31238
+ import { randomUUID } from "node:crypto";
31239
+ var callContext = new AsyncLocalStorage();
31240
+ var eventQueue = [];
31241
+ var FLUSH_BATCH_SIZE = 20;
31242
+ var FLUSH_DELAY_MS = 2e3;
31243
+ var MAX_QUEUED_EVENTS = 200;
31244
+ var SAFE_TOOL_ERROR_CODES = /* @__PURE__ */ new Set([
31245
+ "IDEMPOTENCY_KEY_REQUIRED",
31246
+ "IDEMPOTENCY_BODY_REQUIRED",
31247
+ "IDEMPOTENCY_BACKEND_UNAVAILABLE",
31248
+ "IDEMPOTENCY_INVALID_REPLAY",
31249
+ "IDEMPOTENCY_IN_FLIGHT",
31250
+ "IDEMPOTENCY_OUTCOME_UNKNOWN",
31251
+ "IDEMPOTENCY_BODY_MISMATCH",
31252
+ "IDEMPOTENCY_TOOL_MISMATCH",
31253
+ "IDEMPOTENCY_INVALID_CLAIM",
31254
+ "IDEMPOTENCY_COMPLETION_UNCERTAIN",
31255
+ "RESPONSE_BUDGET_EXCEEDED"
31256
+ ]);
31257
+ var flushTimer = null;
31258
+ var activeFlush = null;
31259
+ var telemetryFailureLogged = false;
31260
+ var telemetryDropLogged = false;
31261
+ function logTelemetryFailure(error51) {
31262
+ if (telemetryFailureLogged) return;
31263
+ console.error(
31264
+ "[kirjapro-mcp] telemetry delivery failed (tool result unaffected):",
31265
+ error51 instanceof Error ? error51.message : String(error51)
31266
+ );
31267
+ telemetryFailureLogged = true;
31268
+ }
31269
+ function telemetryEnabled(envValue = process.env.KIRJAPRO_TELEMETRY) {
31270
+ if (envValue === void 0) return true;
31271
+ return !["0", "false", "no", "off"].includes(envValue.trim().toLowerCase());
31272
+ }
31273
+ function setCallIdempotencyStatus(status) {
31274
+ const context = callContext.getStore();
31275
+ if (context) context.idempotencyStatus = status;
31276
+ }
31277
+ var BUDGET_OUTCOME_RANK = {
31278
+ within: 0,
31279
+ oversized: 1,
31280
+ rejected: 2
31281
+ };
31282
+ function setCallResponseBudget(responseBytes, budgetOutcome) {
31283
+ const context = callContext.getStore();
31284
+ if (!context) return;
31285
+ context.responseBytes = Math.max(context.responseBytes, responseBytes);
31286
+ if (BUDGET_OUTCOME_RANK[budgetOutcome] > BUDGET_OUTCOME_RANK[context.budgetOutcome]) {
31287
+ context.budgetOutcome = budgetOutcome;
31288
+ }
31289
+ }
31290
+ function boundedClientValue(value, maxLength, allowed) {
31291
+ if (!value) return void 0;
31292
+ const bounded = value.slice(0, maxLength);
31293
+ return allowed.test(bounded) ? bounded : void 0;
31294
+ }
31295
+ function resultErrorCode(result) {
31296
+ if (!result.isError) return void 0;
31297
+ const textPart = result.content.find(
31298
+ (part) => typeof part === "object" && part !== null && "type" in part && part.type === "text" && "text" in part && typeof part.text === "string"
31299
+ );
31300
+ const match = textPart?.text.match(/^([A-Z][A-Z0-9_]{1,63}):/);
31301
+ const candidate = match?.[1];
31302
+ if (candidate && SAFE_TOOL_ERROR_CODES.has(candidate)) return candidate;
31303
+ const text = (textPart?.text ?? "").replace(/^MCP error -?\d+: /, "");
31304
+ if (text.startsWith("Input validation error:")) return "INVALID_ARGUMENTS";
31305
+ if (text.startsWith("Output validation error:")) {
31306
+ return "OUTPUT_VALIDATION_ERROR";
31307
+ }
31308
+ if (text.startsWith("Tool ") && text.endsWith(" not found")) {
31309
+ return "UNKNOWN_TOOL";
31310
+ }
31311
+ if (text.startsWith("Tool ") && text.endsWith(" disabled")) {
31312
+ return "TOOL_DISABLED";
31313
+ }
31314
+ return "TOOL_ERROR";
31315
+ }
31316
+ function exceptionErrorCode(error51) {
31317
+ const message = error51 instanceof Error ? error51.message : String(error51);
31318
+ if (message.startsWith("Invalid tools/call request:")) {
31319
+ return "INVALID_TOOL_CALL_REQUEST";
31320
+ }
31321
+ if (message.startsWith("Invalid tools/call result:")) {
31322
+ return "INVALID_TOOL_CALL_RESULT";
31323
+ }
31324
+ return "UNHANDLED_EXCEPTION";
31325
+ }
31326
+ function isToolResponse(value) {
31327
+ return typeof value === "object" && value !== null && "content" in value && Array.isArray(value.content);
31328
+ }
31329
+ function batchSize(toolName, args) {
31330
+ if (toolName !== "kirjapro_create_transactions_batch" && toolName !== "kirjapro_create_from_template_batch") {
31331
+ return void 0;
31332
+ }
31333
+ if (typeof args !== "object" || args === null || !("transactions" in args)) {
31334
+ return void 0;
31335
+ }
31336
+ const transactions = args.transactions;
31337
+ return Array.isArray(transactions) ? transactions.length : void 0;
31338
+ }
31339
+ function scheduleFlush() {
31340
+ if (flushTimer || activeFlush) return;
31341
+ flushTimer = setTimeout(() => {
31342
+ flushTimer = null;
31343
+ void flushTelemetry();
31344
+ }, FLUSH_DELAY_MS);
31345
+ flushTimer.unref?.();
31346
+ }
31347
+ function enqueue(event) {
31348
+ if (eventQueue.length >= MAX_QUEUED_EVENTS) {
31349
+ eventQueue.shift();
31350
+ if (!telemetryDropLogged) {
31351
+ console.error(
31352
+ "[kirjapro-mcp] telemetry queue full; dropping oldest metadata events."
31353
+ );
31354
+ telemetryDropLogged = true;
31355
+ }
31356
+ }
31357
+ eventQueue.push(event);
31358
+ if (eventQueue.length >= FLUSH_BATCH_SIZE) {
31359
+ void flushTelemetry();
31360
+ } else {
31361
+ scheduleFlush();
31362
+ }
31363
+ }
31364
+ async function flushTelemetry() {
31365
+ if (!telemetryEnabled()) return;
31366
+ if (activeFlush) {
31367
+ await activeFlush;
31368
+ if (eventQueue.length > 0) await flushTelemetry();
31369
+ return;
31370
+ }
31371
+ if (eventQueue.length === 0) return;
31372
+ if (flushTimer) {
31373
+ clearTimeout(flushTimer);
31374
+ flushTimer = null;
31375
+ }
31376
+ const batch = eventQueue.splice(0, FLUSH_BATCH_SIZE);
31377
+ activeFlush = (async () => {
31378
+ try {
31379
+ const { error: error51 } = await getSupabase().rpc("record_mcp_tool_calls", {
31380
+ p_company_id: getCompanyId(),
31381
+ p_events: batch
31382
+ });
31383
+ if (error51) throw error51;
31384
+ telemetryFailureLogged = false;
31385
+ telemetryDropLogged = false;
31386
+ } catch (error51) {
31387
+ logTelemetryFailure(error51);
31388
+ }
31389
+ })();
31390
+ try {
31391
+ await activeFlush;
31392
+ } finally {
31393
+ activeFlush = null;
31394
+ if (eventQueue.length > 0) scheduleFlush();
31395
+ }
31396
+ }
31397
+ async function drainTelemetry() {
31398
+ if (!telemetryEnabled()) return;
31399
+ while (activeFlush || eventQueue.length > 0) {
31400
+ await flushTelemetry();
31401
+ }
31402
+ }
31403
+ function instrumentToolCalls(server2, options) {
31404
+ const collectTelemetry = telemetryEnabled();
31405
+ if (!collectTelemetry) {
31406
+ console.error("[kirjapro-mcp] Operational telemetry disabled by KIRJAPRO_TELEMETRY.");
31407
+ } else {
31408
+ console.error(
31409
+ "[kirjapro-mcp] Operational telemetry is enabled (company/API-key attributed metadata only; no arguments or results). Set KIRJAPRO_TELEMETRY=false to opt out: https://kirjapro.fi/tietosuoja"
31410
+ );
31411
+ }
31412
+ const registered = server2._registeredTools;
31413
+ const knownToolNames = new Set(
31414
+ options.knownToolNames ?? Object.keys(registered)
31415
+ );
31416
+ const requestHandlers = server2.server._requestHandlers;
31417
+ const original = requestHandlers.get("tools/call");
31418
+ if (!original) {
31419
+ throw new Error(
31420
+ "Cannot instrument tools/call before at least one MCP tool is registered."
31421
+ );
31422
+ }
31423
+ requestHandlers.set("tools/call", async (request, extra) => {
31424
+ const params = typeof request === "object" && request !== null && "params" in request ? request.params : void 0;
31425
+ const requestedName = typeof params === "object" && params !== null && "name" in params && typeof params.name === "string" ? params.name : void 0;
31426
+ const toolName = requestedName && knownToolNames.has(requestedName) ? requestedName : "kirjapro_unknown_tool";
31427
+ const args = typeof params === "object" && params !== null && "arguments" in params ? params.arguments : void 0;
31428
+ const tool = requestedName ? registered[requestedName] : void 0;
31429
+ const startedAt = performance.now();
31430
+ const requestBytes = measureJsonBytes(args);
31431
+ const dryRun = typeof args === "object" && args !== null && "dryRun" in args && typeof args.dryRun === "boolean" ? args.dryRun : void 0;
31432
+ const initialIdempotencyStatus = dryRun === true && tool?.annotations?.readOnlyHint === false ? "preview" : "not_applicable";
31433
+ const context = {
31434
+ idempotencyStatus: initialIdempotencyStatus,
31435
+ budgetOutcome: "within",
31436
+ responseBytes: 0
31437
+ };
31438
+ return callContext.run(context, async () => {
31439
+ let status = "success";
31440
+ let errorCode;
31441
+ try {
31442
+ const rawResult = await original(request, extra);
31443
+ if (!isToolResponse(rawResult)) return rawResult;
31444
+ const budgeted = applyResponseBudget(toolName, rawResult);
31445
+ setCallResponseBudget(
31446
+ budgeted.responseBytes,
31447
+ budgeted.budgetOutcome
31448
+ );
31449
+ const result = budgeted.result;
31450
+ status = result.isError ? "tool_error" : "success";
31451
+ errorCode = resultErrorCode(result);
31452
+ if (errorCode === "RESPONSE_BUDGET_EXCEEDED") {
31453
+ setCallResponseBudget(context.responseBytes, "rejected");
31454
+ }
31455
+ return result;
31456
+ } catch (error51) {
31457
+ status = "exception";
31458
+ errorCode = requestedName ? exceptionErrorCode(error51) : "INVALID_TOOL_CALL_REQUEST";
31459
+ throw error51;
31460
+ } finally {
31461
+ if (collectTelemetry) {
31462
+ try {
31463
+ const client = server2.server.getClientVersion();
31464
+ const durationMs = Math.min(
31465
+ Math.max(Math.round(performance.now() - startedAt), 0),
31466
+ 3e5
31467
+ );
31468
+ enqueue({
31469
+ event_id: randomUUID(),
31470
+ tool_name: toolName,
31471
+ server_version: VERSION,
31472
+ surface: options.surface,
31473
+ client_name: boundedClientValue(
31474
+ client?.name,
31475
+ 80,
31476
+ /^[A-Za-z0-9 ._/:+()-]+$/
31477
+ ),
31478
+ client_version: boundedClientValue(
31479
+ client?.version,
31480
+ 48,
31481
+ /^[A-Za-z0-9._/+()-]+$/
31482
+ ),
31483
+ duration_ms: durationMs,
31484
+ status,
31485
+ error_code: errorCode,
31486
+ request_bytes: requestBytes,
31487
+ response_bytes: context.responseBytes,
31488
+ batch_size: batchSize(toolName, args),
31489
+ dry_run: dryRun,
31490
+ idempotency_status: context.idempotencyStatus,
31491
+ budget_outcome: context.budgetOutcome
31492
+ });
31493
+ } catch (error51) {
31494
+ logTelemetryFailure(error51);
31495
+ }
31496
+ }
31497
+ }
31498
+ });
31499
+ });
31500
+ }
31501
+
31502
+ // src/utils.ts
31178
31503
  function formatCurrency(amount) {
31179
31504
  return new Intl.NumberFormat("fi-FI", {
31180
31505
  style: "currency",
@@ -31384,9 +31709,15 @@ function isValidCalendarDate(input) {
31384
31709
  return d.getUTCFullYear() === year && d.getUTCMonth() === month - 1 && d.getUTCDate() === day;
31385
31710
  }
31386
31711
  var ISO_DATE_SCHEMA = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Expected YYYY-MM-DD").refine(isValidCalendarDate, { message: "Invalid calendar date (e.g. 2026-02-31 does not exist)" });
31387
- var IDEMPOTENCY_KEY_SCHEMA = external_exports.string().min(8).max(128).optional().describe(
31388
- "Idempotency key (8-128 chars). Retries with the same key return the cached response without re-executing the write. Cache TTL: 24h. Scoped per company."
31712
+ var IDEMPOTENCY_KEY_SCHEMA = external_exports.string().regex(
31713
+ /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,
31714
+ "Expected a UUID v4"
31715
+ ).describe(
31716
+ "Required UUID v4 identifying this logical write. Retries with the same key and identical arguments replay the cached response for 24h. Never use a new key to retry an outcome-unknown operation."
31389
31717
  );
31718
+ var MAX_DOCUMENT_LINES = 100;
31719
+ var MAX_JOURNAL_ENTRIES = 100;
31720
+ var MAX_BATCH_JOURNAL_ENTRIES = 500;
31390
31721
  var DRY_RUN_SCHEMA = external_exports.boolean().default(false).describe(
31391
31722
  "If true, validate and return a preview of the change without writing to the database. Use before calling without dryRun to double-check."
31392
31723
  );
@@ -31414,108 +31745,122 @@ function hashIdempotencyBody(params) {
31414
31745
  const canonical = JSON.stringify(canonicalizeForHash(rest));
31415
31746
  return createHash("sha256").update(canonical).digest("hex");
31416
31747
  }
31748
+ var idempotencyExecution = new AsyncLocalStorage2();
31417
31749
  async function withIdempotency(supabase2, companyId2, toolName, key, params, fn) {
31418
- if (!key) return fn();
31419
- const CLAIM_STALE_MS = 6e4;
31420
- const CLAIM_WAIT_MS = 1500;
31750
+ if (idempotencyExecution.getStore() === true) return fn();
31751
+ if (!key) {
31752
+ setCallIdempotencyStatus("backend_unavailable");
31753
+ return toErrorContent(
31754
+ "IDEMPOTENCY_KEY_REQUIRED: every Kirjapro write requires a fresh UUID v4. Generate it once for the logical operation and reuse that same UUID only for exact retries."
31755
+ );
31756
+ }
31757
+ if (params?.dryRun === true) {
31758
+ setCallIdempotencyStatus("preview");
31759
+ return fn();
31760
+ }
31421
31761
  const currentBodyHash = hashIdempotencyBody(params);
31422
- const filter = () => supabase2.from("mcp_idempotency_keys").select("response_payload, created_at, body_sha256").eq("company_id", companyId2).eq("tool_name", toolName).eq("key", key).maybeSingle();
31762
+ if (!currentBodyHash) {
31763
+ setCallIdempotencyStatus("backend_unavailable");
31764
+ return toErrorContent(
31765
+ "IDEMPOTENCY_BODY_REQUIRED: the write arguments could not be hashed; the operation was not executed."
31766
+ );
31767
+ }
31768
+ let claimData;
31423
31769
  try {
31424
- const { data: existing } = await filter();
31425
- if (existing?.response_payload) {
31426
- const storedHash = existing.body_sha256;
31427
- if (currentBodyHash && storedHash && storedHash !== currentBodyHash) {
31770
+ const { data, error: error51 } = await supabase2.rpc("claim_mcp_idempotency", {
31771
+ p_company_id: companyId2,
31772
+ p_tool_name: toolName,
31773
+ p_key: key,
31774
+ p_body_sha256: currentBodyHash
31775
+ });
31776
+ if (error51) throw error51;
31777
+ claimData = data;
31778
+ } catch (error51) {
31779
+ setCallIdempotencyStatus("backend_unavailable");
31780
+ console.error("[kirjapro-mcp] idempotency claim unavailable:", {
31781
+ tool: toolName,
31782
+ error: error51 instanceof Error ? error51.message : String(error51)
31783
+ });
31784
+ return toErrorContent(
31785
+ "IDEMPOTENCY_BACKEND_UNAVAILABLE: the safety claim could not be confirmed, so the write was not executed. Retry later with the same idempotencyKey."
31786
+ );
31787
+ }
31788
+ const claim = claimData;
31789
+ switch (claim?.status) {
31790
+ case "replay":
31791
+ if (!claim.response_payload) {
31792
+ setCallIdempotencyStatus("backend_unavailable");
31428
31793
  return toErrorContent(
31429
- `IDEMPOTENCY_BODY_MISMATCH: idempotencyKey "${key.slice(0, 12)}\u2026" was previously used with a different payload. Use a fresh idempotencyKey for this request. If you intended to retry the earlier operation, resend the original payload verbatim.`
31794
+ "IDEMPOTENCY_INVALID_REPLAY: the cache returned no response; the write was not re-executed."
31430
31795
  );
31431
31796
  }
31432
- return existing.response_payload;
31433
- }
31434
- if (existing && !existing.response_payload) {
31435
- const initialAge = Date.now() - new Date(existing.created_at).getTime();
31436
- if (initialAge > CLAIM_STALE_MS) {
31437
- await supabase2.from("mcp_idempotency_keys").delete().eq("company_id", companyId2).eq("tool_name", toolName).eq("key", key);
31438
- } else {
31439
- const pollDeadline = Date.now() + (CLAIM_STALE_MS - initialAge);
31440
- while (Date.now() < pollDeadline) {
31441
- await new Promise((r) => setTimeout(r, CLAIM_WAIT_MS));
31442
- const { data: retried } = await filter();
31443
- if (retried?.response_payload) {
31444
- const storedHash = retried.body_sha256;
31445
- if (currentBodyHash && storedHash && storedHash !== currentBodyHash) {
31446
- return toErrorContent(
31447
- `IDEMPOTENCY_BODY_MISMATCH: idempotencyKey "${key.slice(0, 12)}\u2026" was previously used with a different payload. Use a fresh idempotencyKey for this request.`
31448
- );
31449
- }
31450
- return retried.response_payload;
31451
- }
31452
- if (!retried) {
31453
- break;
31454
- }
31455
- }
31456
- const { data: stillPending } = await filter();
31457
- if (stillPending && !stillPending.response_payload) {
31458
- const pendingAge = Date.now() - new Date(stillPending.created_at).getTime();
31459
- if (pendingAge <= CLAIM_STALE_MS) {
31460
- return toErrorContent(
31461
- `Idempotency claim for "${toolName}" key is still in-flight from another request. Retry with the same idempotencyKey in a few seconds \u2014 do not retry with a new key.`
31462
- );
31463
- }
31464
- }
31465
- }
31466
- }
31467
- } catch (err) {
31468
- console.error("[kirjapro-mcp] idempotency lookup failed:", {
31469
- tool: toolName,
31470
- err: err.message
31471
- });
31797
+ setCallIdempotencyStatus("replayed");
31798
+ return claim.response_payload;
31799
+ case "in_flight":
31800
+ setCallIdempotencyStatus("in_flight");
31801
+ return toErrorContent(
31802
+ "IDEMPOTENCY_IN_FLIGHT: this exact write is still running. Retry in a few seconds with the same idempotencyKey; do not create a new key."
31803
+ );
31804
+ case "outcome_unknown":
31805
+ setCallIdempotencyStatus("outcome_unknown");
31806
+ return toErrorContent(
31807
+ "IDEMPOTENCY_OUTCOME_UNKNOWN: the earlier write may have completed, but its response was not safely recorded. Do not retry with a new key. Reconcile using the corresponding read tool or the Kirjapro UI; this UUID remains blocked against duplicate execution."
31808
+ );
31809
+ case "body_mismatch":
31810
+ setCallIdempotencyStatus("body_mismatch");
31811
+ return toErrorContent(
31812
+ "IDEMPOTENCY_BODY_MISMATCH: this UUID v4 was already used with different arguments. Use the original arguments to inspect that operation, or a fresh UUID only for a genuinely new operation."
31813
+ );
31814
+ case "tool_mismatch":
31815
+ setCallIdempotencyStatus("tool_mismatch");
31816
+ return toErrorContent(
31817
+ "IDEMPOTENCY_TOOL_MISMATCH: this UUID v4 was already used by another write tool. Use a fresh UUID for this new operation."
31818
+ );
31819
+ case "claimed":
31820
+ setCallIdempotencyStatus("claimed");
31821
+ break;
31822
+ default:
31823
+ setCallIdempotencyStatus("backend_unavailable");
31824
+ return toErrorContent(
31825
+ "IDEMPOTENCY_INVALID_CLAIM: the safety service returned an unknown state, so the write was not executed."
31826
+ );
31472
31827
  }
31473
- let claimed = false;
31828
+ let result;
31474
31829
  try {
31475
- const { error: claimErr } = await supabase2.from("mcp_idempotency_keys").insert({
31476
- company_id: companyId2,
31477
- key,
31478
- tool_name: toolName,
31479
- response_payload: null,
31480
- body_sha256: currentBodyHash
31481
- });
31482
- claimed = !claimErr;
31483
- if (claimErr) {
31484
- await new Promise((r) => setTimeout(r, CLAIM_WAIT_MS));
31485
- const { data: retried } = await filter();
31486
- if (retried?.response_payload) {
31487
- const storedHash = retried.body_sha256;
31488
- if (currentBodyHash && storedHash && storedHash !== currentBodyHash) {
31489
- return toErrorContent(
31490
- `IDEMPOTENCY_BODY_MISMATCH: idempotencyKey "${key.slice(0, 12)}\u2026" was previously used with a different payload. Use a fresh idempotencyKey for this request.`
31491
- );
31492
- }
31493
- return retried.response_payload;
31830
+ result = await idempotencyExecution.run(true, fn);
31831
+ } catch (error51) {
31832
+ setCallIdempotencyStatus("outcome_unknown");
31833
+ throw error51;
31834
+ }
31835
+ const budgeted = applyResponseBudget(toolName, result, {
31836
+ writeBoundary: true
31837
+ });
31838
+ result = budgeted.result;
31839
+ setCallResponseBudget(
31840
+ budgeted.responseBytes,
31841
+ budgeted.budgetOutcome
31842
+ );
31843
+ try {
31844
+ const { data: completed, error: error51 } = await supabase2.rpc(
31845
+ "complete_mcp_idempotency",
31846
+ {
31847
+ p_company_id: companyId2,
31848
+ p_tool_name: toolName,
31849
+ p_key: key,
31850
+ p_body_sha256: currentBodyHash,
31851
+ p_response_payload: result
31494
31852
  }
31495
- }
31496
- } catch (err) {
31497
- console.error("[kirjapro-mcp] idempotency claim failed:", {
31853
+ );
31854
+ if (error51 || completed !== true) throw error51 ?? new Error("completion rejected");
31855
+ } catch (error51) {
31856
+ setCallIdempotencyStatus("completion_uncertain");
31857
+ console.error("[kirjapro-mcp] idempotency completion uncertain:", {
31498
31858
  tool: toolName,
31499
- err: err.message
31859
+ error: error51 instanceof Error ? error51.message : String(error51)
31500
31860
  });
31501
- }
31502
- const result = await fn();
31503
- if (!result.isError && claimed) {
31504
- try {
31505
- await supabase2.from("mcp_idempotency_keys").update({
31506
- response_payload: result
31507
- }).eq("company_id", companyId2).eq("tool_name", toolName).eq("key", key);
31508
- } catch (err) {
31509
- console.error("[kirjapro-mcp] idempotency cache update failed:", {
31510
- tool: toolName,
31511
- err: err.message
31512
- });
31513
- }
31514
- } else if (result.isError && claimed) {
31515
- try {
31516
- await supabase2.from("mcp_idempotency_keys").delete().eq("company_id", companyId2).eq("tool_name", toolName).eq("key", key);
31517
- } catch {
31518
- }
31861
+ return toErrorContent(
31862
+ "IDEMPOTENCY_COMPLETION_UNCERTAIN: the operation may have completed, but its replay record was not acknowledged. Do not use a new key. Reconcile with a read tool or the Kirjapro UI, then retry only this same UUID if instructed."
31863
+ );
31519
31864
  }
31520
31865
  return result;
31521
31866
  }
@@ -31808,7 +32153,7 @@ function registerTransactionTools(server2) {
31808
32153
  debitAmount: external_exports.number().finite().min(0).max(1e9).default(0).describe("Debit amount in EUR"),
31809
32154
  creditAmount: external_exports.number().finite().min(0).max(1e9).default(0).describe("Credit amount in EUR")
31810
32155
  })
31811
- ).min(2).describe("Journal entries (min 2, must balance)"),
32156
+ ).min(2).max(MAX_JOURNAL_ENTRIES).describe(`Journal entries (2-${MAX_JOURNAL_ENTRIES}, must balance)`),
31812
32157
  idempotencyKey: IDEMPOTENCY_KEY_SCHEMA
31813
32158
  },
31814
32159
  annotations: WRITE_ANNOTATIONS
@@ -31935,11 +32280,11 @@ function registerTransactionTools(server2) {
31935
32280
  server2.registerTool(
31936
32281
  "kirjapro_create_transactions_batch",
31937
32282
  {
31938
- description: 'Create multiple transactions in one call (up to 50). Default mode "atomic" rolls back ALL on any failure; "best_effort" collects per-row errors. Prefer kirjapro_create_from_template_batch for standard patterns.',
32283
+ description: "Preview or atomically create multiple transactions in one call (up to 50). dryRun defaults to true. Commit is always all-or-nothing; partial/best-effort writes are intentionally unavailable.",
31939
32284
  inputSchema: {
31940
32285
  fiscalYearId: external_exports.string().uuid().optional().describe("Fiscal year UUID (auto-resolved if omitted)"),
31941
- mode: external_exports.enum(["atomic", "best_effort"]).default("atomic").describe(
31942
- 'Batch mode. "atomic" (default): all-or-nothing, rolls back on any row failure. "best_effort": commits what it can, returns per-row errors.'
32286
+ dryRun: external_exports.boolean().default(true).describe(
32287
+ "Preview by default. Set false only after reviewing the complete batch; the commit is atomic."
31943
32288
  ),
31944
32289
  transactions: external_exports.array(
31945
32290
  external_exports.object({
@@ -31952,9 +32297,20 @@ function registerTransactionTools(server2) {
31952
32297
  debitAmount: external_exports.number().finite().min(0).max(1e9).default(0),
31953
32298
  creditAmount: external_exports.number().finite().min(0).max(1e9).default(0)
31954
32299
  })
31955
- ).min(2)
32300
+ ).min(2).max(MAX_JOURNAL_ENTRIES)
31956
32301
  })
31957
- ).min(1).max(50).describe("Array of transactions to create (max 50)"),
32302
+ ).min(1).max(50).superRefine((transactions, context) => {
32303
+ const totalEntries = transactions.reduce(
32304
+ (sum, transaction) => sum + transaction.entries.length,
32305
+ 0
32306
+ );
32307
+ if (totalEntries > MAX_BATCH_JOURNAL_ENTRIES) {
32308
+ context.addIssue({
32309
+ code: "custom",
32310
+ message: `Batch contains ${totalEntries} journal entries; maximum is ${MAX_BATCH_JOURNAL_ENTRIES}. Split it into smaller batches.`
32311
+ });
32312
+ }
32313
+ }).describe("Array of transactions to create (max 50)"),
31958
32314
  idempotencyKey: IDEMPOTENCY_KEY_SCHEMA
31959
32315
  },
31960
32316
  annotations: WRITE_ANNOTATIONS
@@ -32060,19 +32416,20 @@ function registerTransactionTools(server2) {
32060
32416
  }))
32061
32417
  });
32062
32418
  }
32063
- if (params.mode === "atomic" && preFailed.length > 0) {
32419
+ if (preFailed.length > 0) {
32064
32420
  return toErrorContent(
32065
- `Atomic batch aborted: ${preFailed.length} transaction(s) failed validation. Fix all errors or use mode "best_effort" for partial commits.
32421
+ `Atomic batch aborted: ${preFailed.length} transaction(s) failed validation. Fix every error and retry the complete batch.
32066
32422
  ` + preFailed.map((f) => ` [${f.index}] ${f.error}`).join("\n")
32067
32423
  );
32068
32424
  }
32069
32425
  if (preValidated.length === 0) {
32070
32426
  return toResult({
32071
- mode: params.mode,
32427
+ mode: "atomic",
32428
+ dry_run: params.dryRun,
32072
32429
  created_count: 0,
32073
- failed_count: preFailed.length,
32430
+ failed_count: 0,
32074
32431
  created: [],
32075
- failed: preFailed
32432
+ failed: []
32076
32433
  });
32077
32434
  }
32078
32435
  const rpcTransactions = preValidated.map((v) => ({
@@ -32081,13 +32438,32 @@ function registerTransactionTools(server2) {
32081
32438
  document_number: v.document_number,
32082
32439
  entries: v.entries
32083
32440
  }));
32441
+ if (params.dryRun) {
32442
+ return toDryRunResponse("kirjapro_create_transactions_batch", {
32443
+ mode: "atomic",
32444
+ transaction_count: rpcTransactions.length,
32445
+ transactions: rpcTransactions.map((transaction, index) => ({
32446
+ index,
32447
+ transaction_date: transaction.transaction_date,
32448
+ description: transaction.description,
32449
+ document_number: transaction.document_number,
32450
+ total_debit: roundCents(
32451
+ transaction.entries.reduce((sum, entry) => sum + entry.debit_amount, 0)
32452
+ ),
32453
+ total_credit: roundCents(
32454
+ transaction.entries.reduce((sum, entry) => sum + entry.credit_amount, 0)
32455
+ ),
32456
+ entries: transaction.entries
32457
+ }))
32458
+ });
32459
+ }
32084
32460
  const { data: rpcResult, error: rpcError } = await supabase2.rpc(
32085
32461
  "create_transactions_batch_atomic",
32086
32462
  {
32087
32463
  p_company_id: companyId2,
32088
32464
  p_fiscal_year_id: fiscalYearId,
32089
32465
  p_transactions: rpcTransactions,
32090
- p_mode: params.mode
32466
+ p_mode: "atomic"
32091
32467
  }
32092
32468
  );
32093
32469
  if (rpcError) {
@@ -32109,11 +32485,12 @@ function registerTransactionTools(server2) {
32109
32485
  })
32110
32486
  }));
32111
32487
  return toResult({
32112
- mode: params.mode,
32488
+ mode: "atomic",
32489
+ dry_run: false,
32113
32490
  created_count: created.length,
32114
- failed_count: preFailed.length + rpcFailed.length,
32491
+ failed_count: rpcFailed.length,
32115
32492
  created,
32116
- failed: [...preFailed, ...rpcFailed]
32493
+ failed: rpcFailed
32117
32494
  });
32118
32495
  }
32119
32496
  );
@@ -32189,6 +32566,81 @@ var VALID_TRANSITIONS = {
32189
32566
  cancelled: ["draft"]
32190
32567
  };
32191
32568
 
32569
+ // src/vat.ts
32570
+ var EU_COUNTRY_CODES = /* @__PURE__ */ new Set([
32571
+ "AT",
32572
+ "BE",
32573
+ "BG",
32574
+ "HR",
32575
+ "CY",
32576
+ "CZ",
32577
+ "DE",
32578
+ "DK",
32579
+ "EE",
32580
+ "ES",
32581
+ "FI",
32582
+ "FR",
32583
+ "GR",
32584
+ "HU",
32585
+ "IE",
32586
+ "IT",
32587
+ "LT",
32588
+ "LU",
32589
+ "LV",
32590
+ "MT",
32591
+ "NL",
32592
+ "PL",
32593
+ "PT",
32594
+ "RO",
32595
+ "SE",
32596
+ "SI",
32597
+ "SK"
32598
+ ]);
32599
+ function normalizedVatNumber(value) {
32600
+ return (value ?? "").toUpperCase().replace(/[^A-Z0-9]/g, "");
32601
+ }
32602
+ function validateVatTreatmentEligibility({
32603
+ code,
32604
+ sellerAlvRegistered,
32605
+ customer,
32606
+ documentDate
32607
+ }) {
32608
+ if (!sellerAlvRegistered && code !== "not_vat_registered") {
32609
+ return "A seller outside the VAT register can only use not_vat_registered.";
32610
+ }
32611
+ if (sellerAlvRegistered && code === "not_vat_registered") {
32612
+ return "A VAT-registered seller cannot use not_vat_registered.";
32613
+ }
32614
+ if (code === "standard_25_5" && documentDate < "2024-09-01") {
32615
+ return "standard_25_5 is not valid before 2024-09-01.";
32616
+ }
32617
+ if (code === "standard_13_5" && documentDate < "2026-01-01") {
32618
+ return "standard_13_5 is not valid before 2026-01-01.";
32619
+ }
32620
+ const requiresBusiness = code.startsWith("reverse_") || code === "intra_eu_goods";
32621
+ if (requiresBusiness && customer?.customer_kind !== "business") {
32622
+ return "The selected VAT treatment requires a business customer.";
32623
+ }
32624
+ if ((code === "reverse_construction" || code === "reverse_scrap") && !/^\d{7}-\d$/.test(customer?.business_id?.trim() ?? "")) {
32625
+ return "Domestic reverse charge requires a Finnish buyer business ID in the form 1234567-8.";
32626
+ }
32627
+ if (code === "reverse_eu_service" || code === "intra_eu_goods") {
32628
+ const country = (customer?.country ?? "").trim().toUpperCase();
32629
+ const vatNumber = normalizedVatNumber(customer?.vat_number);
32630
+ const expectedPrefix = country === "GR" ? "EL" : country;
32631
+ if (!EU_COUNTRY_CODES.has(country) || country === "FI" || !/^[A-Z]{2}[A-Z0-9]{2,12}$/.test(vatNumber) || !vatNumber.startsWith(expectedPrefix)) {
32632
+ return "EU sale requires a non-Finnish EU country and a matching buyer VAT number.";
32633
+ }
32634
+ }
32635
+ if (code === "export_outside_eu") {
32636
+ const country = (customer?.country ?? "").trim().toUpperCase();
32637
+ if (!country || EU_COUNTRY_CODES.has(country)) {
32638
+ return "Export outside the EU requires a buyer country outside the EU.";
32639
+ }
32640
+ }
32641
+ return null;
32642
+ }
32643
+
32192
32644
  // src/tools/invoices.ts
32193
32645
  function generateReferenceNumber(baseNumber) {
32194
32646
  const digits = baseNumber.replace(/\D/g, "");
@@ -32305,6 +32757,9 @@ function registerInvoiceTools(server2) {
32305
32757
  invoiceDate: ISO_DATE_SCHEMA.describe("Invoice date (YYYY-MM-DD)"),
32306
32758
  paymentTermDays: external_exports.number().min(0).max(365).default(14).describe("Payment term in days (default 14)"),
32307
32759
  notes: external_exports.string().max(2e3).optional().describe("Notes printed on the invoice"),
32760
+ priceEntryMode: external_exports.enum(["vat_exclusive", "vat_inclusive"]).default("vat_exclusive").describe("Whether entered unit prices exclude or include VAT"),
32761
+ reverseChargeConfirmed: external_exports.boolean().default(false).describe("Explicit document-level confirmation that the business buyer qualifies for the selected reverse-charge treatment"),
32762
+ euGoodsTransportConfirmed: external_exports.boolean().default(false).describe("Explicit confirmation that intra-EU goods are transported from Finland to another EU country"),
32308
32763
  lines: external_exports.array(
32309
32764
  external_exports.object({
32310
32765
  description: external_exports.string().min(1).max(500).describe("Line item description"),
@@ -32313,10 +32768,27 @@ function registerInvoiceTools(server2) {
32313
32768
  // opaque 23514 deep in create_invoice_with_lines.
32314
32769
  quantity: external_exports.number().finite().positive().max(1e6).describe("Quantity (must be > 0)"),
32315
32770
  unit: external_exports.string().max(20).default("kpl").describe("Unit (kpl, h, kk, etc.)"),
32316
- unitPrice: external_exports.number().finite().min(-1e9).max(1e9).describe("Unit price in EUR (excl. VAT). Can be negative for credit lines."),
32317
- vatRate: external_exports.enum(["25.5", "13.5", "10", "0"]).default("25.5").describe("VAT rate")
32771
+ unitPrice: external_exports.number().finite().min(0).max(1e9).describe("Entered unit price in EUR (must be >= 0)"),
32772
+ vatRate: external_exports.enum(["25.5", "13.5", "10", "0"]).default("25.5").describe("VAT rate"),
32773
+ vatTreatmentCode: external_exports.enum([
32774
+ "standard_25_5",
32775
+ "standard_13_5",
32776
+ "standard_10",
32777
+ "not_vat_registered",
32778
+ "reverse_construction",
32779
+ "reverse_scrap",
32780
+ "reverse_eu_service",
32781
+ "export_outside_eu",
32782
+ "intra_eu_goods",
32783
+ "exempt_healthcare",
32784
+ "exempt_social_welfare",
32785
+ "exempt_education",
32786
+ "exempt_financial",
32787
+ "exempt_insurance",
32788
+ "exempt_other"
32789
+ ]).optional().describe("Structured VAT treatment. Required when VAT rate is 0.")
32318
32790
  })
32319
- ).min(1).describe("Invoice line items"),
32791
+ ).min(1).max(MAX_DOCUMENT_LINES).describe(`Invoice line items (max ${MAX_DOCUMENT_LINES})`),
32320
32792
  idempotencyKey: IDEMPOTENCY_KEY_SCHEMA
32321
32793
  },
32322
32794
  annotations: WRITE_ANNOTATIONS
@@ -32331,12 +32803,16 @@ function registerInvoiceTools(server2) {
32331
32803
  params.idempotencyKey,
32332
32804
  params,
32333
32805
  async () => {
32334
- const { data: customer, error: custError } = await supabase2.from("customers").select("id, name").eq("id", params.customerId).eq("company_id", companyId2).single();
32806
+ const { data: customer, error: custError } = await supabase2.from("customers").select("id, name, customer_kind, business_id, vat_number, country").eq("id", params.customerId).eq("company_id", companyId2).single();
32335
32807
  if (custError || !customer) {
32336
32808
  return toErrorContent(
32337
32809
  `Customer ${params.customerId} not found. Use kirjapro_list_customers to find customer IDs.`
32338
32810
  );
32339
32811
  }
32812
+ const { data: company, error: companyError } = await supabase2.from("companies").select("alv_registered").eq("id", companyId2).single();
32813
+ if (companyError || !company) {
32814
+ return toErrorContent("Failed to verify the seller VAT registration status.");
32815
+ }
32340
32816
  const { data: invoiceNumber, error: numError } = await supabase2.rpc(
32341
32817
  "get_next_invoice_number",
32342
32818
  {
@@ -32355,18 +32831,64 @@ function registerInvoiceTools(server2) {
32355
32831
  params.invoiceDate,
32356
32832
  params.paymentTermDays
32357
32833
  );
32834
+ const treatmentRates = {
32835
+ standard_25_5: 25.5,
32836
+ standard_13_5: 13.5,
32837
+ standard_10: 10,
32838
+ not_vat_registered: 0,
32839
+ reverse_construction: 0,
32840
+ reverse_scrap: 0,
32841
+ reverse_eu_service: 0,
32842
+ export_outside_eu: 0,
32843
+ intra_eu_goods: 0,
32844
+ exempt_healthcare: 0,
32845
+ exempt_social_welfare: 0,
32846
+ exempt_education: 0,
32847
+ exempt_financial: 0,
32848
+ exempt_insurance: 0,
32849
+ exempt_other: 0
32850
+ };
32851
+ const resolvedTreatments = params.lines.map((line) => {
32852
+ const inputRate = parseFloat(line.vatRate);
32853
+ const code = line.vatTreatmentCode ?? (inputRate === 25.5 ? "standard_25_5" : inputRate === 13.5 ? "standard_13_5" : inputRate === 10 ? "standard_10" : null);
32854
+ if (!code) return { error: "0 % VAT requires a structured vatTreatmentCode." };
32855
+ const eligibilityError = validateVatTreatmentEligibility({
32856
+ code,
32857
+ sellerAlvRegistered: company.alv_registered,
32858
+ customer,
32859
+ documentDate: params.invoiceDate
32860
+ });
32861
+ if (eligibilityError) return { error: eligibilityError };
32862
+ return { code, rate: treatmentRates[code] ?? inputRate };
32863
+ });
32864
+ const treatmentError = resolvedTreatments.find((item) => "error" in item);
32865
+ if (treatmentError && "error" in treatmentError) {
32866
+ return toErrorContent(treatmentError.error);
32867
+ }
32358
32868
  const calculatedLines = params.lines.map((line, i) => {
32359
- const vatRate = parseFloat(line.vatRate);
32360
- const subtotal2 = roundCents(line.quantity * line.unitPrice);
32361
- const vatAmount = roundCents(subtotal2 * (vatRate / 100));
32362
- const total2 = roundCents(subtotal2 + vatAmount);
32869
+ const resolved = resolvedTreatments[i];
32870
+ if (!resolved || !("code" in resolved)) throw new Error("VAT treatment validation failed");
32871
+ const vatRate = resolved.rate;
32872
+ const vatTreatmentCode = resolved.code;
32873
+ const gross = roundCents(line.quantity * line.unitPrice);
32874
+ const vatAmount = params.priceEntryMode === "vat_inclusive" && vatRate > 0 ? roundCents(gross * vatRate / (100 + vatRate)) : roundCents(gross * (vatRate / 100));
32875
+ const subtotal2 = params.priceEntryMode === "vat_inclusive" && vatRate > 0 ? roundCents(gross - vatAmount) : gross;
32876
+ const total2 = params.priceEntryMode === "vat_inclusive" && vatRate > 0 ? gross : roundCents(subtotal2 + vatAmount);
32363
32877
  return {
32364
32878
  line_number: i + 1,
32365
32879
  description: line.description,
32366
32880
  quantity: line.quantity,
32367
32881
  unit: line.unit,
32368
32882
  unit_price: line.unitPrice,
32883
+ entered_unit_price: line.unitPrice,
32369
32884
  vat_rate: vatRate,
32885
+ vat_treatment_code: vatTreatmentCode,
32886
+ vat_treatment_overridden: true,
32887
+ price_entry_mode: params.priceEntryMode,
32888
+ default_vat_treatment_code: vatTreatmentCode,
32889
+ reverse_charge_confirmed: params.reverseChargeConfirmed,
32890
+ reverse_charge_confirmation_text: params.reverseChargeConfirmed ? "Buyer qualification explicitly confirmed through MCP invoice creation." : null,
32891
+ eu_goods_transport_confirmed: params.euGoodsTransportConfirmed,
32370
32892
  subtotal: subtotal2,
32371
32893
  vat_amount: vatAmount,
32372
32894
  total: total2
@@ -32770,6 +33292,9 @@ var CUSTOMER_DETAIL_OUTPUT_SHAPE = {
32770
33292
  customer_number: external_exports.number(),
32771
33293
  name: external_exports.string(),
32772
33294
  business_id: external_exports.string().nullable(),
33295
+ vat_number: external_exports.string().nullable(),
33296
+ customer_kind: external_exports.enum(["consumer", "business"]),
33297
+ country: external_exports.string().nullable(),
32773
33298
  email: external_exports.string().nullable(),
32774
33299
  payment_term_days: external_exports.number(),
32775
33300
  is_active: external_exports.boolean(),
@@ -32829,7 +33354,7 @@ function registerCustomerTools(server2) {
32829
33354
  const companyId2 = getCompanyId();
32830
33355
  const { limit, offset } = clampPagination(params.limit, params.offset);
32831
33356
  let query = supabase2.from("customers").select(
32832
- "id, customer_number, name, business_id, email, phone, address, postal_code, city, country, payment_term_days, is_active",
33357
+ "id, customer_number, name, business_id, vat_number, customer_kind, email, phone, address, postal_code, city, country, payment_term_days, is_active",
32833
33358
  { count: "exact" }
32834
33359
  ).eq("company_id", companyId2).eq("is_active", true).order("name").order("id", { ascending: true });
32835
33360
  if (params.search) {
@@ -32853,6 +33378,8 @@ function registerCustomerTools(server2) {
32853
33378
  inputSchema: {
32854
33379
  name: external_exports.string().min(1).max(200).describe("Customer name (company or person)"),
32855
33380
  businessId: external_exports.string().optional().describe('Finnish Y-tunnus (e.g. "1234567-8")'),
33381
+ vatNumber: external_exports.string().max(20).optional().describe("VAT identifier, e.g. DE123456789"),
33382
+ customerKind: external_exports.enum(["consumer", "business"]).optional().describe("Customer classification; defaults to business when a Y-tunnus is provided, otherwise consumer"),
32856
33383
  contactPerson: external_exports.string().optional().describe("Contact person name"),
32857
33384
  email: external_exports.string().email().optional().describe("Email address"),
32858
33385
  phone: external_exports.string().optional().describe("Phone number"),
@@ -32895,15 +33422,17 @@ function registerCustomerTools(server2) {
32895
33422
  customer_number: customerNumber,
32896
33423
  name: sanitizeText(params.name),
32897
33424
  business_id: params.businessId || null,
33425
+ vat_number: params.vatNumber?.toUpperCase().replace(/[^A-Z0-9]/g, "") || null,
33426
+ customer_kind: params.customerKind ?? (params.businessId || params.vatNumber ? "business" : "consumer"),
32898
33427
  contact_person: sanitizeText(params.contactPerson),
32899
33428
  email: params.email || null,
32900
33429
  phone: sanitizeText(params.phone),
32901
33430
  address: sanitizeText(params.address),
32902
33431
  postal_code: sanitizeText(params.postalCode),
32903
33432
  city: sanitizeText(params.city),
32904
- country: params.country,
33433
+ country: params.country.toUpperCase(),
32905
33434
  payment_term_days: params.paymentTermDays
32906
- }).select("id, customer_number, name, business_id, contact_person, email, phone, address, postal_code, city, country, payment_term_days, notes, created_at").single();
33435
+ }).select("id, customer_number, name, business_id, vat_number, customer_kind, contact_person, email, phone, address, postal_code, city, country, payment_term_days, notes, created_at").single();
32907
33436
  if (error51) {
32908
33437
  return toErrorContent(sanitizeDbError("Failed to create customer", error51));
32909
33438
  }
@@ -32928,7 +33457,7 @@ function registerCustomerTools(server2) {
32928
33457
  async (params) => {
32929
33458
  const supabase2 = getSupabase();
32930
33459
  const companyId2 = getCompanyId();
32931
- const { data: customer, error: error51 } = await supabase2.from("customers").select("id, customer_number, name, business_id, contact_person, email, phone, address, postal_code, city, country, payment_term_days, is_active, created_at").eq("id", params.customerId).eq("company_id", companyId2).single();
33460
+ const { data: customer, error: error51 } = await supabase2.from("customers").select("id, customer_number, name, business_id, vat_number, customer_kind, contact_person, email, phone, address, postal_code, city, country, payment_term_days, is_active, created_at").eq("id", params.customerId).eq("company_id", companyId2).single();
32932
33461
  if (error51 || !customer) {
32933
33462
  return toErrorContent(
32934
33463
  `Customer ${params.customerId} not found. Use kirjapro_list_customers to find customer IDs.`
@@ -32964,6 +33493,8 @@ function registerCustomerTools(server2) {
32964
33493
  customerId: external_exports.string().uuid().describe("Customer UUID"),
32965
33494
  name: external_exports.string().min(1).max(200).optional().describe("Customer name"),
32966
33495
  businessId: external_exports.string().optional().describe('Finnish Y-tunnus (e.g. "1234567-8")'),
33496
+ vatNumber: external_exports.string().max(20).optional().describe("VAT identifier"),
33497
+ customerKind: external_exports.enum(["consumer", "business"]).optional().describe("Customer classification"),
32967
33498
  contactPerson: external_exports.string().optional().describe("Contact person name"),
32968
33499
  email: external_exports.string().email().optional().describe("Email address"),
32969
33500
  phone: external_exports.string().optional().describe("Phone number"),
@@ -32993,13 +33524,17 @@ function registerCustomerTools(server2) {
32993
33524
  const updates = {};
32994
33525
  if (params.name !== void 0) updates.name = sanitizeText(params.name) ?? void 0;
32995
33526
  if (params.businessId !== void 0) updates.business_id = params.businessId || null;
33527
+ if (params.vatNumber !== void 0) {
33528
+ updates.vat_number = params.vatNumber.toUpperCase().replace(/[^A-Z0-9]/g, "") || null;
33529
+ }
33530
+ if (params.customerKind !== void 0) updates.customer_kind = params.customerKind;
32996
33531
  if (params.contactPerson !== void 0) updates.contact_person = sanitizeText(params.contactPerson);
32997
33532
  if (params.email !== void 0) updates.email = params.email || null;
32998
33533
  if (params.phone !== void 0) updates.phone = sanitizeText(params.phone);
32999
33534
  if (params.address !== void 0) updates.address = sanitizeText(params.address);
33000
33535
  if (params.postalCode !== void 0) updates.postal_code = sanitizeText(params.postalCode);
33001
33536
  if (params.city !== void 0) updates.city = sanitizeText(params.city);
33002
- if (params.country !== void 0) updates.country = params.country;
33537
+ if (params.country !== void 0) updates.country = params.country.toUpperCase();
33003
33538
  if (params.paymentTermDays !== void 0) updates.payment_term_days = params.paymentTermDays;
33004
33539
  if (Object.keys(updates).length === 0) {
33005
33540
  return toErrorContent("No fields to update. Provide at least one field to change.");
@@ -33011,7 +33546,7 @@ function registerCustomerTools(server2) {
33011
33546
  params.idempotencyKey,
33012
33547
  params,
33013
33548
  async () => {
33014
- const { data: updated, error: updateError } = await supabase2.from("customers").update(updates).eq("id", params.customerId).eq("company_id", companyId2).select("id, customer_number, name, business_id, contact_person, email, phone, address, postal_code, city, country, payment_term_days, notes, created_at, updated_at").single();
33549
+ const { data: updated, error: updateError } = await supabase2.from("customers").update(updates).eq("id", params.customerId).eq("company_id", companyId2).select("id, customer_number, name, business_id, vat_number, customer_kind, contact_person, email, phone, address, postal_code, city, country, payment_term_days, notes, created_at, updated_at").single();
33015
33550
  if (updateError) {
33016
33551
  return toErrorContent(sanitizeDbError("Failed to update customer", updateError));
33017
33552
  }
@@ -33220,7 +33755,12 @@ var ALV_SUMMARY_OUTPUT_SHAPE = {
33220
33755
  input_vat: external_exports.unknown().optional(),
33221
33756
  net_vat_payable: external_exports.number().optional(),
33222
33757
  net_vat_payable_formatted: external_exports.string().optional(),
33223
- omavero_fields: external_exports.unknown().optional(),
33758
+ omavero_fields: external_exports.record(external_exports.string(), external_exports.number()).optional(),
33759
+ zero_vat_turnover: external_exports.number().optional(),
33760
+ eu_goods_sales_base: external_exports.number().optional(),
33761
+ reverse_charge_sales_base: external_exports.number().optional(),
33762
+ eu_service_sales_base: external_exports.number().optional(),
33763
+ unclassified_legacy_reverse_charge_base: external_exports.number().optional(),
33224
33764
  warning: external_exports.string().optional(),
33225
33765
  message: external_exports.string().optional()
33226
33766
  };
@@ -33257,38 +33797,50 @@ var AGING_BUCKET_SHAPE = external_exports.object({
33257
33797
  label: external_exports.string(),
33258
33798
  count: external_exports.number(),
33259
33799
  total: external_exports.number(),
33260
- total_formatted: external_exports.string(),
33261
- invoices: external_exports.array(
33262
- external_exports.object({
33263
- invoice_number: external_exports.string(),
33264
- customer: external_exports.string().nullable().optional(),
33265
- total: external_exports.number().nullable(),
33266
- due_date: external_exports.string().nullable(),
33267
- days_overdue: external_exports.number()
33268
- }).passthrough()
33269
- )
33800
+ total_formatted: external_exports.string()
33270
33801
  });
33271
33802
  var AR_AGING_OUTPUT_SHAPE = {
33803
+ as_of_date: external_exports.string(),
33272
33804
  buckets: external_exports.array(AGING_BUCKET_SHAPE),
33273
33805
  no_due_date: external_exports.object({
33274
33806
  count: external_exports.number(),
33275
33807
  total: external_exports.number(),
33276
- invoices: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown()))
33808
+ total_formatted: external_exports.string()
33277
33809
  }).passthrough(),
33810
+ total_count: external_exports.number(),
33278
33811
  total_receivables: external_exports.number(),
33279
33812
  total_receivables_formatted: external_exports.string(),
33280
- days_sales_outstanding: external_exports.number()
33813
+ weighted_average_days_overdue: external_exports.number(),
33814
+ metric_note: external_exports.string()
33281
33815
  };
33816
+ var LEDGER_CURSOR_SHAPE = external_exports.object({
33817
+ after_transaction_date: ISO_DATE_SCHEMA,
33818
+ after_transaction_created_at: external_exports.string().datetime({ offset: true }),
33819
+ after_entry_id: external_exports.string().uuid(),
33820
+ snapshot_at: external_exports.string().datetime({ offset: true })
33821
+ });
33282
33822
  var GENERAL_LEDGER_OUTPUT_SHAPE = {
33283
33823
  account: external_exports.object({
33824
+ account_id: external_exports.string().uuid(),
33284
33825
  account_number: external_exports.string(),
33285
33826
  name: external_exports.string(),
33286
33827
  account_type: external_exports.string(),
33287
33828
  balance_type: external_exports.enum(["debit-normal", "credit-normal"])
33288
33829
  }),
33830
+ period: external_exports.object({ from: external_exports.string(), to: external_exports.string() }),
33831
+ summary: external_exports.object({
33832
+ opening_balance: external_exports.number(),
33833
+ total_debit: external_exports.number(),
33834
+ total_credit: external_exports.number(),
33835
+ closing_balance: external_exports.number(),
33836
+ closing_balance_formatted: external_exports.string(),
33837
+ entry_count: external_exports.number()
33838
+ }),
33289
33839
  entries: external_exports.array(
33290
33840
  external_exports.object({
33291
- date: external_exports.string(),
33841
+ entry_id: external_exports.string().uuid(),
33842
+ transaction_date: external_exports.string(),
33843
+ transaction_created_at: external_exports.string(),
33292
33844
  description: external_exports.string().nullable(),
33293
33845
  document_number: external_exports.string().nullable(),
33294
33846
  transaction_id: external_exports.string().uuid(),
@@ -33297,12 +33849,13 @@ var GENERAL_LEDGER_OUTPUT_SHAPE = {
33297
33849
  running_balance: external_exports.number()
33298
33850
  }).passthrough()
33299
33851
  ),
33300
- entry_count: external_exports.number(),
33301
- opening_balance: external_exports.number(),
33302
- closing_balance: external_exports.number(),
33303
- closing_balance_formatted: external_exports.string(),
33304
- capped: external_exports.boolean(),
33305
- capped_note: external_exports.string().nullable()
33852
+ page: external_exports.object({
33853
+ limit: external_exports.number(),
33854
+ returned: external_exports.number(),
33855
+ has_more: external_exports.boolean(),
33856
+ next_cursor: LEDGER_CURSOR_SHAPE.nullable(),
33857
+ snapshot_at: external_exports.string()
33858
+ })
33306
33859
  };
33307
33860
  function registerReportTools(server2) {
33308
33861
  server2.registerTool(
@@ -33608,7 +34161,7 @@ function registerReportTools(server2) {
33608
34161
  server2.registerTool(
33609
34162
  "kirjapro_get_ar_aging",
33610
34163
  {
33611
- description: "Get accounts receivable aging report. Shows unpaid invoices grouped by days overdue: 0-30, 31-60, 61-90, 90+ days. Includes Days Sales Outstanding (DSO).",
34164
+ description: "Get an exact, bounded accounts-receivable aging summary as of today in Europe/Helsinki. Outstanding amounts account for partial payments and sent credit notes. Returns aggregate 0-30, 31-60, 61-90, 90+ and missing-due-date buckets; it intentionally does not return an unbounded invoice list.",
33612
34165
  inputSchema: {},
33613
34166
  outputSchema: AR_AGING_OUTPUT_SHAPE,
33614
34167
  annotations: READ_ONLY_ANNOTATIONS
@@ -33616,92 +34169,51 @@ function registerReportTools(server2) {
33616
34169
  async () => {
33617
34170
  const supabase2 = getSupabase();
33618
34171
  const companyId2 = getCompanyId();
33619
- const { data: invoices, error: error51 } = await supabase2.from("invoices").select("id, invoice_number, total, due_date, invoice_date, customers(name)").eq("company_id", companyId2).in("status", ["sent", "overdue"]);
34172
+ const { data, error: error51 } = await supabase2.rpc("get_ar_aging", {
34173
+ p_company_id: companyId2
34174
+ });
33620
34175
  if (error51) {
33621
34176
  return toErrorContent(sanitizeDbError("Failed to get AR aging", error51));
33622
34177
  }
33623
- const todayStr = helsinkiDateString();
33624
- const todayMs = Date.parse(todayStr);
34178
+ const aging = data;
33625
34179
  const buckets = [
33626
- { label: "0-30 days", min: 0, max: 30, count: 0, total: 0, invoices: [] },
33627
- { label: "31-60 days", min: 31, max: 60, count: 0, total: 0, invoices: [] },
33628
- { label: "61-90 days", min: 61, max: 90, count: 0, total: 0, invoices: [] },
33629
- { label: "90+ days", min: 91, max: Infinity, count: 0, total: 0, invoices: [] }
34180
+ { label: "0-30 days", count: aging.bucket_0_30_count, total: aging.bucket_0_30_amount },
34181
+ { label: "31-60 days", count: aging.bucket_31_60_count, total: aging.bucket_31_60_amount },
34182
+ { label: "61-90 days", count: aging.bucket_61_90_count, total: aging.bucket_61_90_amount },
34183
+ { label: "90+ days", count: aging.bucket_90_plus_count, total: aging.bucket_90_plus_amount }
33630
34184
  ];
33631
- let totalReceivables = 0;
33632
- let weightedDays = 0;
33633
- const noDueDate = [];
33634
- for (const inv of invoices || []) {
33635
- if (!inv.due_date) {
33636
- noDueDate.push({
33637
- invoice_number: inv.invoice_number,
33638
- customer: tagUntrusted(inv.customers?.name),
33639
- total: inv.total || 0
33640
- });
33641
- totalReceivables += inv.total || 0;
33642
- continue;
33643
- }
33644
- const dueMs = Date.parse(inv.due_date);
33645
- if (Number.isNaN(dueMs)) {
33646
- noDueDate.push({
33647
- invoice_number: inv.invoice_number,
33648
- customer: tagUntrusted(inv.customers?.name),
33649
- total: inv.total || 0
33650
- });
33651
- totalReceivables += inv.total || 0;
33652
- continue;
33653
- }
33654
- const daysOverdue = Math.max(
33655
- 0,
33656
- Math.floor((todayMs - dueMs) / 864e5)
33657
- );
33658
- const bucket = buckets.find(
33659
- (b) => daysOverdue >= b.min && daysOverdue <= b.max
33660
- );
33661
- if (!bucket) continue;
33662
- bucket.count++;
33663
- bucket.total += inv.total || 0;
33664
- bucket.invoices.push({
33665
- invoice_number: inv.invoice_number,
33666
- customer: tagUntrusted(inv.customers?.name),
33667
- total: inv.total,
33668
- due_date: inv.due_date,
33669
- days_overdue: daysOverdue
33670
- });
33671
- totalReceivables += inv.total || 0;
33672
- weightedDays += daysOverdue * (inv.total || 0);
33673
- }
33674
- const dso = totalReceivables > 0 ? Math.round(weightedDays / totalReceivables) : 0;
33675
34185
  return toResult({
34186
+ as_of_date: aging.as_of_date,
33676
34187
  buckets: buckets.map((b) => ({
33677
34188
  label: b.label,
33678
34189
  count: b.count,
33679
34190
  total: roundCents(b.total),
33680
- total_formatted: formatCurrency(b.total),
33681
- invoices: b.invoices
34191
+ total_formatted: formatCurrency(b.total)
33682
34192
  })),
33683
34193
  no_due_date: {
33684
- count: noDueDate.length,
33685
- total: roundCents(
33686
- noDueDate.reduce((s, i) => s + (i.total || 0), 0)
33687
- ),
33688
- invoices: noDueDate
34194
+ count: aging.no_due_date_count,
34195
+ total: roundCents(aging.no_due_date_amount),
34196
+ total_formatted: formatCurrency(aging.no_due_date_amount)
33689
34197
  },
33690
- total_receivables: roundCents(totalReceivables),
33691
- total_receivables_formatted: formatCurrency(totalReceivables),
33692
- days_sales_outstanding: dso
34198
+ total_count: aging.total_count,
34199
+ total_receivables: roundCents(aging.total_receivables),
34200
+ total_receivables_formatted: formatCurrency(aging.total_receivables),
34201
+ weighted_average_days_overdue: aging.weighted_average_days_overdue,
34202
+ metric_note: "weighted_average_days_overdue is the amount-weighted age of currently outstanding receivables with a due date; it is not revenue-based DSO."
33693
34203
  });
33694
34204
  }
33695
34205
  );
33696
34206
  server2.registerTool(
33697
34207
  "kirjapro_get_general_ledger",
33698
34208
  {
33699
- description: "Get general ledger (p\xE4\xE4kirja) for a single account within a fiscal year. Shows all journal entries with running balance. Assets and expenses use debit-normal balance; liabilities, equity, and revenue use credit-normal. If fiscalYearId is omitted, the single open fiscal year is used.",
34209
+ description: "Get one exact, cursor-paginated general-ledger (p\xE4\xE4kirja) page for a single account. The first call pins a creation-time cutoff and returns next_cursor; pass that cursor unchanged so newly inserted rows cannot shift later pages. summary always covers the full selected period, while entries is bounded to 1-100 rows. If fiscalYearId is omitted, the single open fiscal year is used.",
33700
34210
  inputSchema: {
33701
34211
  accountNumber: external_exports.string().describe('Account number (e.g. "3000")'),
33702
34212
  fiscalYearId: external_exports.string().uuid().optional().describe("Fiscal year UUID (auto-resolved to the open fiscal year if omitted)"),
33703
34213
  dateFrom: ISO_DATE_SCHEMA.optional().describe("Start date filter (YYYY-MM-DD)"),
33704
- dateTo: ISO_DATE_SCHEMA.optional().describe("End date filter (YYYY-MM-DD)")
34214
+ dateTo: ISO_DATE_SCHEMA.optional().describe("End date filter (YYYY-MM-DD)"),
34215
+ limit: external_exports.number().int().min(1).max(100).default(50).describe("Entries per page (default 50, max 100)"),
34216
+ cursor: LEDGER_CURSOR_SHAPE.optional().describe("Opaque next_cursor from the previous page. Pass all fields unchanged.")
33705
34217
  },
33706
34218
  outputSchema: GENERAL_LEDGER_OUTPUT_SHAPE,
33707
34219
  annotations: READ_ONLY_ANNOTATIONS
@@ -33709,8 +34221,6 @@ function registerReportTools(server2) {
33709
34221
  async (params) => {
33710
34222
  const supabase2 = getSupabase();
33711
34223
  const companyId2 = getCompanyId();
33712
- const rangeError = assertDateRange(params.dateFrom, params.dateTo);
33713
- if (rangeError) return rangeError;
33714
34224
  let fiscalYearId;
33715
34225
  if (params.fiscalYearId) {
33716
34226
  fiscalYearId = params.fiscalYearId;
@@ -33719,82 +34229,55 @@ function registerReportTools(server2) {
33719
34229
  if ("isError" in resolved) return resolved;
33720
34230
  fiscalYearId = resolved.id;
33721
34231
  }
33722
- const { data: account, error: accError } = await supabase2.from("accounts").select("id, account_number, name, account_type").eq("company_id", companyId2).eq("account_number", params.accountNumber).single();
33723
- if (accError || !account) {
34232
+ const [accountResult, fiscalYearResult] = await Promise.all([
34233
+ supabase2.from("accounts").select("id").eq("company_id", companyId2).eq("account_number", params.accountNumber).single(),
34234
+ supabase2.from("fiscal_years").select("start_date, end_date").eq("company_id", companyId2).eq("id", fiscalYearId).single()
34235
+ ]);
34236
+ if (accountResult.error || !accountResult.data) {
33724
34237
  return toErrorContent(
33725
34238
  `Account "${params.accountNumber}" not found. Use kirjapro_list_accounts to see available accounts.`
33726
34239
  );
33727
34240
  }
33728
- const LEDGER_FETCH_LIMIT = 5e3;
33729
- let query = supabase2.from("journal_entries").select(`
33730
- debit_amount, credit_amount,
33731
- transaction:transactions!inner(id, transaction_date, description, document_number, fiscal_year_id, company_id)
33732
- `).eq("account_id", account.id).eq("transaction.fiscal_year_id", fiscalYearId).eq("transaction.company_id", companyId2).order("transaction(transaction_date)", { ascending: true }).order("id", { ascending: true }).range(0, LEDGER_FETCH_LIMIT);
33733
- if (params.dateFrom) {
33734
- query = query.gte("transaction.transaction_date", params.dateFrom);
33735
- }
33736
- if (params.dateTo) {
33737
- query = query.lte("transaction.transaction_date", params.dateTo);
33738
- }
33739
- const { data: entries, error: error51 } = await query;
33740
- if (error51) {
33741
- return toErrorContent(sanitizeDbError("Failed to get general ledger", error51));
34241
+ if (fiscalYearResult.error || !fiscalYearResult.data) {
34242
+ return toErrorContent(
34243
+ `Fiscal year ${fiscalYearId} not found. Read kirjapro://fiscal-years to find available fiscal years.`
34244
+ );
33742
34245
  }
33743
- const debitNormal = ["asset", "expense"];
33744
- const isDebitNormal = debitNormal.includes(account.account_type);
33745
- let openingBalance = 0;
33746
- if (params.dateFrom) {
33747
- const { data: priorEntries, error: priorErr } = await supabase2.from("journal_entries").select(`
33748
- debit_amount, credit_amount,
33749
- transaction:transactions!inner(fiscal_year_id, company_id, transaction_date)
33750
- `).eq("account_id", account.id).eq("transaction.fiscal_year_id", fiscalYearId).eq("transaction.company_id", companyId2).lt("transaction.transaction_date", params.dateFrom);
33751
- if (!priorErr && priorEntries) {
33752
- for (const e of priorEntries) {
33753
- const d = e.debit_amount || 0;
33754
- const c = e.credit_amount || 0;
33755
- openingBalance += isDebitNormal ? d - c : c - d;
33756
- }
33757
- openingBalance = roundCents(openingBalance);
34246
+ const dateFrom = params.dateFrom ?? fiscalYearResult.data.start_date;
34247
+ const dateTo = params.dateTo ?? fiscalYearResult.data.end_date;
34248
+ const rangeError = assertDateRange(dateFrom, dateTo);
34249
+ if (rangeError) return rangeError;
34250
+ const { data, error: error51 } = await supabase2.rpc("get_general_ledger_page", {
34251
+ p_company_id: companyId2,
34252
+ p_account_id: accountResult.data.id,
34253
+ p_fiscal_year_id: fiscalYearId,
34254
+ p_date_from: dateFrom,
34255
+ p_date_to: dateTo,
34256
+ p_limit: params.limit,
34257
+ p_after_transaction_date: params.cursor?.after_transaction_date,
34258
+ p_after_transaction_created_at: params.cursor?.after_transaction_created_at,
34259
+ p_after_entry_id: params.cursor?.after_entry_id,
34260
+ p_snapshot_at: params.cursor?.snapshot_at
34261
+ });
34262
+ if (error51 || !data) {
34263
+ if (!error51) {
34264
+ return toErrorContent("Failed to get general ledger page: empty response.");
33758
34265
  }
34266
+ return toErrorContent(
34267
+ sanitizeDbError("Failed to get general ledger page", error51)
34268
+ );
33759
34269
  }
33760
- const fetched = entries || [];
33761
- const capped = fetched.length > LEDGER_FETCH_LIMIT;
33762
- const consumed = capped ? fetched.slice(0, LEDGER_FETCH_LIMIT) : fetched;
33763
- let runningBalance = openingBalance;
33764
- const ledgerEntries = [];
33765
- for (const entry of consumed) {
33766
- const tx = entry.transaction;
33767
- const debit = entry.debit_amount || 0;
33768
- const credit = entry.credit_amount || 0;
33769
- if (isDebitNormal) {
33770
- runningBalance += debit - credit;
33771
- } else {
33772
- runningBalance += credit - debit;
33773
- }
33774
- ledgerEntries.push({
33775
- date: tx.transaction_date,
33776
- description: tx.description,
33777
- document_number: tx.document_number,
33778
- transaction_id: tx.id,
33779
- debit: roundCents(debit),
33780
- credit: roundCents(credit),
33781
- running_balance: roundCents(runningBalance)
33782
- });
33783
- }
34270
+ const ledger = data;
33784
34271
  return toResult({
33785
- account: {
33786
- account_number: account.account_number,
33787
- name: account.name,
33788
- account_type: account.account_type,
33789
- balance_type: isDebitNormal ? "debit-normal" : "credit-normal"
33790
- },
33791
- entries: ledgerEntries,
33792
- entry_count: ledgerEntries.length,
33793
- opening_balance: openingBalance,
33794
- closing_balance: roundCents(runningBalance),
33795
- closing_balance_formatted: formatCurrency(runningBalance),
33796
- capped,
33797
- capped_note: capped ? `Result truncated at ${LEDGER_FETCH_LIMIT} entries. Closing balance is computed from fetched rows only and may not reflect the full fiscal-year total. Narrow the date range with dateFrom/dateTo to see the remainder.` : null
34272
+ ...ledger,
34273
+ entries: ledger.entries.map((entry) => ({
34274
+ ...entry,
34275
+ description: typeof entry.description === "string" ? tagUntrusted(entry.description) : null
34276
+ })),
34277
+ summary: {
34278
+ ...ledger.summary,
34279
+ closing_balance_formatted: formatCurrency(ledger.summary.closing_balance)
34280
+ }
33798
34281
  });
33799
34282
  }
33800
34283
  );
@@ -33814,25 +34297,51 @@ function registerReportTools(server2) {
33814
34297
  const companyId2 = getCompanyId();
33815
34298
  const rangeError = assertDateRange(params.dateFrom, params.dateTo);
33816
34299
  if (rangeError) return rangeError;
33817
- const { data, error: error51 } = await supabase2.rpc("get_alv_summary", {
34300
+ const rpcParams = {
33818
34301
  p_company_id: companyId2,
33819
34302
  p_date_from: params.dateFrom,
33820
34303
  p_date_to: params.dateTo
33821
- });
33822
- if (error51) {
33823
- return toErrorContent(sanitizeDbError("Failed to get ALV summary", error51));
34304
+ };
34305
+ const [{ data, error: error51 }, { data: treatmentData, error: treatmentError }] = await Promise.all([
34306
+ supabase2.rpc("get_alv_summary", rpcParams),
34307
+ supabase2.rpc("get_sales_vat_treatment_summary", rpcParams)
34308
+ ]);
34309
+ if (error51 || treatmentError) {
34310
+ const summaryError = error51 ?? treatmentError;
34311
+ if (!summaryError) return toErrorContent("Failed to get ALV summary");
34312
+ return toErrorContent(
34313
+ sanitizeDbError("Failed to get ALV summary", summaryError)
34314
+ );
33824
34315
  }
33825
- const result = data;
34316
+ const result = data ? {
34317
+ ...data,
34318
+ ...treatmentData
34319
+ } : null;
33826
34320
  if (!result) {
33827
34321
  return toResult({
33828
34322
  period: { from: params.dateFrom, to: params.dateTo },
33829
34323
  message: "No VAT data found for this period."
33830
34324
  });
33831
34325
  }
34326
+ const raw = result;
34327
+ const {
34328
+ field_318: _legacyField318,
34329
+ field_319: _legacyField319,
34330
+ field_320: _legacyField320,
34331
+ ...safeResult
34332
+ } = raw;
33832
34333
  return toResult({
33833
- ...result,
34334
+ ...safeResult,
33834
34335
  period: { from: params.dateFrom, to: params.dateTo },
33835
- net_vat_payable_formatted: formatCurrency(result.net_vat_payable || 0)
34336
+ net_vat_payable_formatted: formatCurrency(result.net_vat_payable || 0),
34337
+ omavero_fields: {
34338
+ "309": Number(raw.zero_vat_turnover) || 0,
34339
+ "311": Number(raw.eu_goods_sales_base) || 0,
34340
+ "312": Number(raw.eu_service_sales_base) || 0,
34341
+ "318": Number(raw.output_vat_construction_scrap) || 0,
34342
+ "319": Number(raw.reverse_charge_sales_base) || 0,
34343
+ "320": (Number(raw.field_310_base) || 0) + (Number(raw.field_313_base) || 0)
34344
+ }
33836
34345
  });
33837
34346
  }
33838
34347
  );
@@ -34685,11 +35194,11 @@ function registerTemplateTools(server2) {
34685
35194
  server2.registerTool(
34686
35195
  "kirjapro_create_from_template_batch",
34687
35196
  {
34688
- description: 'Create multiple transactions from templates in one call (up to 50). Default mode "atomic" rolls back ALL on any failure; "best_effort" collects per-row errors.',
35197
+ description: "Preview or atomically create multiple template transactions in one call (up to 50). dryRun defaults to true. Commit is always all-or-nothing; partial/best-effort writes are intentionally unavailable.",
34689
35198
  inputSchema: {
34690
35199
  fiscalYearId: external_exports.string().uuid().optional().describe("Fiscal year UUID (auto-resolved if omitted)"),
34691
- mode: external_exports.enum(["atomic", "best_effort"]).default("atomic").describe(
34692
- 'Batch mode. "atomic" (default): all-or-nothing, rolls back on any row failure. "best_effort": commits what it can, returns per-row errors.'
35200
+ dryRun: external_exports.boolean().default(true).describe(
35201
+ "Preview by default. Set false only after reviewing the complete batch; the commit is atomic."
34693
35202
  ),
34694
35203
  transactions: external_exports.array(
34695
35204
  external_exports.object({
@@ -34788,19 +35297,20 @@ function registerTemplateTools(server2) {
34788
35297
  entries: result2.entries
34789
35298
  });
34790
35299
  }
34791
- if (params.mode === "atomic" && preFailed.length > 0) {
35300
+ if (preFailed.length > 0) {
34792
35301
  return toErrorContent(
34793
- `Atomic batch aborted: ${preFailed.length} transaction(s) failed validation. Fix all errors or use mode "best_effort" for partial commits.
35302
+ `Atomic batch aborted: ${preFailed.length} transaction(s) failed validation. Fix every error and retry the complete batch.
34794
35303
  ` + preFailed.map((f) => ` [${f.index}] ${f.error}`).join("\n")
34795
35304
  );
34796
35305
  }
34797
35306
  if (expanded.length === 0) {
34798
35307
  return toResult({
34799
- mode: params.mode,
35308
+ mode: "atomic",
35309
+ dry_run: params.dryRun,
34800
35310
  created_count: 0,
34801
- failed_count: preFailed.length,
35311
+ failed_count: 0,
34802
35312
  created: [],
34803
- failed: preFailed
35313
+ failed: []
34804
35314
  });
34805
35315
  }
34806
35316
  const allAccountNumbers = [
@@ -34817,13 +35327,41 @@ function registerTemplateTools(server2) {
34817
35327
  document_number: e.documentNumber,
34818
35328
  entries: toJournalEntries(e.entries, accountMap)
34819
35329
  }));
35330
+ const totalEntries = rpcTransactions.reduce(
35331
+ (sum, transaction) => sum + transaction.entries.length,
35332
+ 0
35333
+ );
35334
+ if (totalEntries > MAX_BATCH_JOURNAL_ENTRIES) {
35335
+ return toErrorContent(
35336
+ `BATCH_ENTRY_LIMIT_EXCEEDED: expanded templates contain ${totalEntries} journal entries; maximum is ${MAX_BATCH_JOURNAL_ENTRIES}. Split the request into smaller batches.`
35337
+ );
35338
+ }
35339
+ if (params.dryRun) {
35340
+ return toDryRunResponse("kirjapro_create_from_template_batch", {
35341
+ mode: "atomic",
35342
+ transaction_count: rpcTransactions.length,
35343
+ transactions: rpcTransactions.map((transaction, index) => ({
35344
+ index,
35345
+ transaction_date: transaction.transaction_date,
35346
+ description: transaction.description,
35347
+ document_number: transaction.document_number,
35348
+ total_debit: roundCents(
35349
+ transaction.entries.reduce((sum, entry) => sum + entry.debit_amount, 0)
35350
+ ),
35351
+ total_credit: roundCents(
35352
+ transaction.entries.reduce((sum, entry) => sum + entry.credit_amount, 0)
35353
+ ),
35354
+ entries: transaction.entries
35355
+ }))
35356
+ });
35357
+ }
34820
35358
  const { data: rpcResult, error: rpcError } = await supabase2.rpc(
34821
35359
  "create_transactions_batch_atomic",
34822
35360
  {
34823
35361
  p_company_id: companyId2,
34824
35362
  p_fiscal_year_id: fiscalYearId,
34825
35363
  p_transactions: rpcTransactions,
34826
- p_mode: params.mode
35364
+ p_mode: "atomic"
34827
35365
  }
34828
35366
  );
34829
35367
  if (rpcError) {
@@ -34845,11 +35383,12 @@ function registerTemplateTools(server2) {
34845
35383
  })
34846
35384
  }));
34847
35385
  return toResult({
34848
- mode: params.mode,
35386
+ mode: "atomic",
35387
+ dry_run: false,
34849
35388
  created_count: created.length,
34850
- failed_count: preFailed.length + rpcFailed.length,
35389
+ failed_count: rpcFailed.length,
34851
35390
  created,
34852
- failed: [...preFailed, ...rpcFailed]
35391
+ failed: rpcFailed
34853
35392
  });
34854
35393
  }
34855
35394
  );
@@ -35302,13 +35841,33 @@ function registerOfferTools(server2) {
35302
35841
  validFrom: ISO_DATE_SCHEMA.optional().describe("Valid from date (YYYY-MM-DD)"),
35303
35842
  validUntil: ISO_DATE_SCHEMA.optional().describe("Valid until date (YYYY-MM-DD)"),
35304
35843
  notes: external_exports.string().max(2e3).optional().describe("Internal notes (not visible to customer)"),
35844
+ priceEntryMode: external_exports.enum(["vat_exclusive", "vat_inclusive"]).default("vat_exclusive").describe("Whether entered unit prices exclude or include VAT"),
35845
+ reverseChargeConfirmed: external_exports.boolean().default(false).describe("Explicit document-level confirmation that the business buyer qualifies for construction reverse charge"),
35846
+ euGoodsTransportConfirmed: external_exports.boolean().default(false).describe("Explicit confirmation that intra-EU goods are transported from Finland to another EU country"),
35305
35847
  lines: external_exports.array(external_exports.object({
35306
35848
  description: external_exports.string().min(1).max(500).describe("Line item description"),
35307
35849
  quantity: external_exports.number().finite().positive().max(1e6).describe("Quantity (must be > 0)"),
35308
35850
  unit: external_exports.string().max(20).default("kpl").describe("Unit (kpl, h, kk, etc.)"),
35309
- unitPrice: external_exports.number().finite().min(-1e9).max(1e9).describe("Unit price in EUR (excl. VAT). Can be negative for credit lines."),
35310
- vatRate: external_exports.enum(["25.5", "13.5", "10", "0"]).default("25.5").describe("VAT rate")
35311
- })).min(1).describe("Line items"),
35851
+ unitPrice: external_exports.number().finite().min(0).max(1e9).describe("Entered unit price in EUR."),
35852
+ vatRate: external_exports.enum(["25.5", "13.5", "10", "0"]).default("25.5").describe("VAT rate"),
35853
+ vatTreatmentCode: external_exports.enum([
35854
+ "standard_25_5",
35855
+ "standard_13_5",
35856
+ "standard_10",
35857
+ "not_vat_registered",
35858
+ "reverse_construction",
35859
+ "reverse_scrap",
35860
+ "reverse_eu_service",
35861
+ "export_outside_eu",
35862
+ "intra_eu_goods",
35863
+ "exempt_healthcare",
35864
+ "exempt_social_welfare",
35865
+ "exempt_education",
35866
+ "exempt_financial",
35867
+ "exempt_insurance",
35868
+ "exempt_other"
35869
+ ]).optional().describe("Structured VAT treatment. Required when VAT rate is 0.")
35870
+ })).min(1).max(MAX_DOCUMENT_LINES).describe(`Line items (max ${MAX_DOCUMENT_LINES})`),
35312
35871
  idempotencyKey: IDEMPOTENCY_KEY_SCHEMA
35313
35872
  },
35314
35873
  annotations: WRITE_ANNOTATIONS
@@ -35323,13 +35882,19 @@ function registerOfferTools(server2) {
35323
35882
  params.idempotencyKey,
35324
35883
  params,
35325
35884
  async () => {
35885
+ let customer = null;
35326
35886
  if (params.customerId) {
35327
- const { data: customer, error: custError } = await supabase2.from("customers").select("id, name").eq("id", params.customerId).eq("company_id", companyId2).single();
35328
- if (custError || !customer) {
35887
+ const { data, error: custError } = await supabase2.from("customers").select("id, name, customer_kind, business_id, vat_number, country").eq("id", params.customerId).eq("company_id", companyId2).single();
35888
+ if (custError || !data) {
35329
35889
  return toErrorContent(
35330
35890
  `Customer ${params.customerId} not found. Use kirjapro_list_customers to find customer IDs.`
35331
35891
  );
35332
35892
  }
35893
+ customer = data;
35894
+ }
35895
+ const { data: company, error: companyError } = await supabase2.from("companies").select("alv_registered").eq("id", companyId2).single();
35896
+ if (companyError || !company) {
35897
+ return toErrorContent("Failed to verify the seller VAT registration status.");
35333
35898
  }
35334
35899
  if (params.validFrom && params.validUntil && params.validUntil < params.validFrom) {
35335
35900
  return toErrorContent(
@@ -35346,18 +35911,46 @@ function registerOfferTools(server2) {
35346
35911
  );
35347
35912
  }
35348
35913
  const offerNumber = offerNumberRaw;
35914
+ const resolveTreatment = (line) => {
35915
+ const inputRate = parseFloat(line.vatRate);
35916
+ return line.vatTreatmentCode ?? (inputRate === 25.5 ? "standard_25_5" : inputRate === 13.5 ? "standard_13_5" : inputRate === 10 ? "standard_10" : null);
35917
+ };
35918
+ if (params.lines.some((line) => resolveTreatment(line) === null)) {
35919
+ return toErrorContent("0 % VAT requires a structured vatTreatmentCode.");
35920
+ }
35921
+ for (const line of params.lines) {
35922
+ const code = resolveTreatment(line);
35923
+ if (!code) continue;
35924
+ const eligibilityError = validateVatTreatmentEligibility({
35925
+ code,
35926
+ sellerAlvRegistered: company.alv_registered,
35927
+ customer,
35928
+ documentDate: params.validFrom ?? helsinkiDateString()
35929
+ });
35930
+ if (eligibilityError) return toErrorContent(eligibilityError);
35931
+ }
35349
35932
  const calculatedLines = params.lines.map((line, i) => {
35350
- const vatRate = parseFloat(line.vatRate);
35351
- const subtotal2 = roundCents(line.quantity * line.unitPrice);
35352
- const vatAmount = roundCents(subtotal2 * (vatRate / 100));
35353
- const total2 = roundCents(subtotal2 + vatAmount);
35933
+ const vatTreatmentCode = resolveTreatment(line) ?? "exempt_other";
35934
+ const vatRate = vatTreatmentCode === "standard_25_5" ? 25.5 : vatTreatmentCode === "standard_13_5" ? 13.5 : vatTreatmentCode === "standard_10" ? 10 : 0;
35935
+ const enteredTotal = roundCents(line.quantity * line.unitPrice);
35936
+ const vatAmount = params.priceEntryMode === "vat_inclusive" && vatRate > 0 ? roundCents(enteredTotal * vatRate / (100 + vatRate)) : roundCents(enteredTotal * (vatRate / 100));
35937
+ const subtotal2 = params.priceEntryMode === "vat_inclusive" && vatRate > 0 ? roundCents(enteredTotal - vatAmount) : enteredTotal;
35938
+ const total2 = params.priceEntryMode === "vat_inclusive" && vatRate > 0 ? enteredTotal : roundCents(subtotal2 + vatAmount);
35354
35939
  return {
35355
35940
  line_number: i + 1,
35356
35941
  description: line.description,
35357
35942
  quantity: line.quantity,
35358
35943
  unit: line.unit,
35359
35944
  unit_price: line.unitPrice,
35945
+ entered_unit_price: line.unitPrice,
35360
35946
  vat_rate: vatRate,
35947
+ vat_treatment_code: vatTreatmentCode,
35948
+ vat_treatment_overridden: true,
35949
+ price_entry_mode: params.priceEntryMode,
35950
+ default_vat_treatment_code: vatTreatmentCode,
35951
+ reverse_charge_confirmed: params.reverseChargeConfirmed,
35952
+ reverse_charge_confirmation_text: params.reverseChargeConfirmed ? "Buyer qualification explicitly confirmed through MCP offer creation." : null,
35953
+ eu_goods_transport_confirmed: params.euGoodsTransportConfirmed,
35361
35954
  subtotal: subtotal2,
35362
35955
  vat_amount: vatAmount,
35363
35956
  total: total2
@@ -35765,7 +36358,7 @@ function registerRecurringInvoiceTools(server2) {
35765
36358
  unit: external_exports.string().max(20).default("kpl").describe('Unit (default "kpl")'),
35766
36359
  unitPrice: external_exports.number().finite().min(-1e9).max(1e9).describe("Unit price in EUR (excl. VAT). Can be negative for credit lines."),
35767
36360
  vatRate: external_exports.enum(["25.5", "13.5", "10", "0"]).describe("VAT rate")
35768
- })).min(1).describe("Invoice line items"),
36361
+ })).min(1).max(MAX_DOCUMENT_LINES).describe(`Invoice line items (max ${MAX_DOCUMENT_LINES})`),
35769
36362
  notes: external_exports.string().max(2e3).optional().describe("Invoice notes"),
35770
36363
  paymentTermDays: external_exports.number().min(0).max(365).default(14).describe("Payment term in days"),
35771
36364
  idempotencyKey: IDEMPOTENCY_KEY_SCHEMA
@@ -35845,7 +36438,7 @@ function registerRecurringInvoiceTools(server2) {
35845
36438
  unit: external_exports.string().max(20).default("kpl").describe("Unit"),
35846
36439
  unitPrice: external_exports.number().finite().min(-1e9).max(1e9).describe("Unit price in EUR (excl. VAT). Can be negative for credit lines."),
35847
36440
  vatRate: external_exports.enum(["25.5", "13.5", "10", "0"]).describe("VAT rate")
35848
- })).min(1).optional().describe("Replace all invoice lines"),
36441
+ })).min(1).max(MAX_DOCUMENT_LINES).optional().describe(`Replace all invoice lines (max ${MAX_DOCUMENT_LINES})`),
35849
36442
  notes: external_exports.string().max(2e3).optional().nullable().describe("Invoice notes (null to remove)"),
35850
36443
  paymentTermDays: external_exports.number().min(0).max(365).optional().describe("Payment term in days"),
35851
36444
  idempotencyKey: IDEMPOTENCY_KEY_SCHEMA
@@ -36269,8 +36862,9 @@ function registerFinancialNotesTools(server2) {
36269
36862
  }
36270
36863
 
36271
36864
  // src/tools/index.ts
36272
- var CORE_TOOL_NAMES = /* @__PURE__ */ new Set([
36273
- // Read everything
36865
+ var IDEMPOTENCY_BOUNDARY = /* @__PURE__ */ Symbol("kirjapro.idempotencyBoundary");
36866
+ var TOOL_REGISTRATION_ORDER = [
36867
+ // Core: read everything
36274
36868
  "kirjapro_list_fiscal_years",
36275
36869
  "kirjapro_list_accounts",
36276
36870
  "kirjapro_get_dashboard",
@@ -36302,8 +36896,38 @@ var CORE_TOOL_NAMES = /* @__PURE__ */ new Set([
36302
36896
  // Pure validators (zero database cost, useful for any agent flow)
36303
36897
  "kirjapro_validate_business_id",
36304
36898
  "kirjapro_validate_iban",
36305
- "kirjapro_generate_reference"
36306
- ]);
36899
+ "kirjapro_generate_reference",
36900
+ // Full-surface extensions, kept in a release-pinned order so adding or
36901
+ // moving module imports cannot churn clients' tools/list prompt caches.
36902
+ "kirjapro_search_transactions",
36903
+ "kirjapro_get_transaction",
36904
+ "kirjapro_create_transactions_batch",
36905
+ "kirjapro_list_templates",
36906
+ "kirjapro_create_from_template",
36907
+ "kirjapro_create_from_template_batch",
36908
+ "kirjapro_book_purchase",
36909
+ "kirjapro_book_sale",
36910
+ "kirjapro_book_vat_settlement",
36911
+ "kirjapro_delete_invoice",
36912
+ "kirjapro_update_customer",
36913
+ "kirjapro_list_offers",
36914
+ "kirjapro_get_offer",
36915
+ "kirjapro_update_offer_status",
36916
+ "kirjapro_delete_offer",
36917
+ "kirjapro_list_recurring_invoices",
36918
+ "kirjapro_get_recurring_invoice",
36919
+ "kirjapro_create_recurring_invoice",
36920
+ "kirjapro_update_recurring_invoice",
36921
+ "kirjapro_delete_recurring_invoice",
36922
+ "kirjapro_list_bank_accounts",
36923
+ "kirjapro_list_received_invoices",
36924
+ "kirjapro_get_received_invoice",
36925
+ "kirjapro_get_financial_notes",
36926
+ "kirjapro_get_general_ledger"
36927
+ ];
36928
+ var CORE_TOOL_NAMES = new Set(
36929
+ TOOL_REGISTRATION_ORDER.slice(0, 27)
36930
+ );
36307
36931
  function resolveSurface(explicit) {
36308
36932
  if (explicit) return explicit;
36309
36933
  const env = process.env.KIRJAPRO_MCP_SURFACE?.toLowerCase();
@@ -36332,8 +36956,39 @@ function registerTools(server2, options = {}) {
36332
36956
  registerRecurringInvoiceTools(server2);
36333
36957
  registerReceivedInvoiceTools(server2);
36334
36958
  registerFinancialNotesTools(server2);
36959
+ const internals = server2;
36960
+ const actualNames = Object.keys(internals._registeredTools);
36961
+ const expectedNames = new Set(TOOL_REGISTRATION_ORDER);
36962
+ const missing = TOOL_REGISTRATION_ORDER.filter(
36963
+ (name) => !(name in internals._registeredTools)
36964
+ );
36965
+ const unexpected = actualNames.filter((name) => !expectedNames.has(name));
36966
+ if (missing.length > 0 || unexpected.length > 0) {
36967
+ throw new Error(
36968
+ `TOOL_REGISTRATION_ORDER drift: missing=[${missing.join(", ")}], unexpected=[${unexpected.join(", ")}]`
36969
+ );
36970
+ }
36971
+ internals._registeredTools = Object.fromEntries(
36972
+ TOOL_REGISTRATION_ORDER.map((name) => [name, internals._registeredTools[name]])
36973
+ );
36974
+ for (const [name, tool] of Object.entries(internals._registeredTools)) {
36975
+ if (tool.annotations?.readOnlyHint !== false) continue;
36976
+ const original = tool.handler;
36977
+ tool.handler = async (...handlerArgs) => {
36978
+ const params = typeof handlerArgs[0] === "object" && handlerArgs[0] !== null ? handlerArgs[0] : {};
36979
+ const key = typeof params.idempotencyKey === "string" ? params.idempotencyKey : void 0;
36980
+ return withIdempotency(
36981
+ getSupabase(),
36982
+ getCompanyId(),
36983
+ name,
36984
+ key,
36985
+ params,
36986
+ () => original(...handlerArgs)
36987
+ );
36988
+ };
36989
+ tool[IDEMPOTENCY_BOUNDARY] = true;
36990
+ }
36335
36991
  if (surface === "core") {
36336
- const internals = server2;
36337
36992
  let removed = 0;
36338
36993
  for (const name of Object.keys(internals._registeredTools)) {
36339
36994
  if (!CORE_TOOL_NAMES.has(name)) {
@@ -36868,9 +37523,6 @@ function registerResources(server2) {
36868
37523
  registerSecurityResources(server2);
36869
37524
  }
36870
37525
 
36871
- // src/version.ts
36872
- var VERSION = "0.7.0";
36873
-
36874
37526
  // src/index.ts
36875
37527
  var INSTRUCTIONS_COMMON = `
36876
37528
  # Kirjapro \u2014 Finnish Accounting MCP Server
@@ -36916,16 +37568,23 @@ Do not invent a "closest match" tool for these tasks. A confidently wrong action
36916
37568
  \`kirjapro_list_bank_transactions\` (filter unreconciled) \u2192 \`kirjapro_match_bank_transaction\` (matches credit tx to invoice, records payment).
36917
37569
 
36918
37570
  ### Reports
36919
- \`kirjapro_get_dashboard\` (overview) | \`kirjapro_get_income_statement\` (tuloslaskelma) | \`kirjapro_get_balance_sheet\` (tase \u2014 \`equity.synthetic_tilikauden_tulos\` carries the mid-year P/L estimate for open fiscal years where account 3600 has no closing entry; surface it to the user as "Tilikauden tulos (kesken)" and never as the final tilikauden tulos, and never as legally distributable per OYL 13:5\xA7) | \`kirjapro_get_ar_aging\` (myyntisaamisten ik\xE4) | \`kirjapro_get_alv_summary\` (ALV-yhteenveto with OmaVero field codes 301-320).
37571
+ \`kirjapro_get_dashboard\` (overview) | \`kirjapro_get_income_statement\` (tuloslaskelma) | \`kirjapro_get_balance_sheet\` (tase \u2014 \`equity.synthetic_tilikauden_tulos\` carries the mid-year P/L estimate for open fiscal years where account 3600 has no closing entry; surface it to the user as "Tilikauden tulos (kesken)" and never as the final tilikauden tulos, and never as legally distributable per OYL 13:5\xA7) | \`kirjapro_get_ar_aging\` (bounded myyntisaamisten aggregate; weighted age is not revenue-based DSO) | \`kirjapro_get_alv_summary\` (ALV-yhteenveto with OmaVero field codes 301-320).
36920
37572
 
36921
37573
  ## Safety Rules
36922
37574
 
36923
37575
  ### dryRun (preview before committing)
36924
- Status changes support \`dryRun: true\`. Always use it before:
36925
- - \`kirjapro_update_invoice_status\` (state machine preview)
37576
+ Batch, booking, status-change, and delete tools support \`dryRun: true\`.
37577
+ The two batch tools default to preview; their \`dryRun: false\` commit is
37578
+ always all-or-nothing. A preview is not cached and does not consume its
37579
+ idempotency UUID. Review every resolved entry before committing.
37580
+
37581
+ ### idempotencyKey (required on every write)
37582
+ Every write tool requires a UUID-v4 \`idempotencyKey\`. Generate it once for the logical operation. An exact retry must reuse the same UUID and arguments; a genuinely new operation must use a new UUID. If the result says \`OUTCOME_UNKNOWN\` or \`COMPLETION_UNCERTAIN\`, do not switch keys and repeat the write \u2014 reconcile with a read tool or the Kirjapro UI first.
36926
37583
 
36927
- ### idempotencyKey (prevent duplicate writes)
36928
- Every write tool accepts an optional \`idempotencyKey\` (8-128 chars). Same key = cached response for 24h. Generate deterministic keys from the operation context, e.g. \`invoice-{customerId}-{date}\`.
37584
+ ### Response budget
37585
+ Tool results above 200 KiB are rejected before entering model context. Narrow
37586
+ the date/filter range, lower \`limit\`, or follow \`next_cursor\`. Never ask the
37587
+ tool to bypass the budget.
36929
37588
 
36930
37589
  ### Fiscal year auto-resolution
36931
37590
  When \`fiscalYearId\` is omitted, tools auto-resolve to the single open fiscal year. If multiple are open, the tool returns an error \u2014 specify explicitly.
@@ -37004,7 +37663,7 @@ Faster than composing journal entries via \`kirjapro_create_transaction\`:
37004
37663
  - \`kirjapro_list_offers\` / \`kirjapro_get_offer\` \u2014 query existing offers by status or ID
37005
37664
 
37006
37665
  ### Extended Reports
37007
- - \`kirjapro_get_general_ledger\` (p\xE4\xE4kirja) \u2014 full ledger for one account with running balance
37666
+ - \`kirjapro_get_general_ledger\` (p\xE4\xE4kirja) \u2014 exact full-period summary plus a creation-time-pinned seek-cursor page (max 100 entries); pass \`next_cursor\` unchanged while \`has_more\`
37008
37667
  - \`kirjapro_search_transactions\` \u2014 text + date + amount range search
37009
37668
  - \`kirjapro_get_transaction\` \u2014 single transaction with all journal entries
37010
37669
 
@@ -37143,6 +37802,10 @@ async function main() {
37143
37802
  process.exit(1);
37144
37803
  }
37145
37804
  registerTools(server, { surface: RESOLVED_SURFACE });
37805
+ instrumentToolCalls(server, {
37806
+ surface: RESOLVED_SURFACE,
37807
+ knownToolNames: TOOL_REGISTRATION_ORDER
37808
+ });
37146
37809
  registerResources(server);
37147
37810
  registerPrompts(server);
37148
37811
  const freshness = freshnessMeta(FINNISH_RATES_2026);
@@ -37156,19 +37819,23 @@ async function main() {
37156
37819
  );
37157
37820
  }
37158
37821
  const transport = new StdioServerTransport();
37159
- transport.onclose = () => {
37160
- stopTokenRefresh();
37161
- process.exit(0);
37162
- };
37822
+ transport.onclose = () => void shutdown();
37163
37823
  await server.connect(transport);
37164
37824
  console.error(`[kirjapro-mcp] Server v${VERSION} started on stdio`);
37165
37825
  }
37166
- function shutdown() {
37826
+ var shuttingDown = false;
37827
+ async function shutdown() {
37828
+ if (shuttingDown) return;
37829
+ shuttingDown = true;
37167
37830
  stopTokenRefresh();
37831
+ await Promise.race([
37832
+ drainTelemetry(),
37833
+ new Promise((resolve) => setTimeout(resolve, 2e3))
37834
+ ]);
37168
37835
  process.exit(0);
37169
37836
  }
37170
- process.on("SIGINT", shutdown);
37171
- process.on("SIGTERM", shutdown);
37837
+ process.on("SIGINT", () => void shutdown());
37838
+ process.on("SIGTERM", () => void shutdown());
37172
37839
  main().catch((error51) => {
37173
37840
  console.error("[kirjapro-mcp] Fatal error:", error51);
37174
37841
  process.exit(1);