@kirjapro/mcp-server 0.6.3 → 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 +115 -0
  2. package/README.md +73 -9
  3. package/dist/index.js +1472 -657
  4. package/package.json +10 -4
  5. package/server.json +6 -2
  6. package/tool-fingerprints.json +55 -51
  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
@@ -6,7 +6,11 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ try {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ } catch (e) {
12
+ throw mod = 0, e;
13
+ }
10
14
  };
11
15
  var __export = (target, all) => {
12
16
  for (var name in all)
@@ -29,9 +33,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
33
  mod
30
34
  ));
31
35
 
32
- // node_modules/ajv/dist/compile/codegen/code.js
36
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/codegen/code.js
33
37
  var require_code = __commonJS({
34
- "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) {
35
39
  "use strict";
36
40
  Object.defineProperty(exports, "__esModule", { value: true });
37
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;
@@ -183,9 +187,9 @@ var require_code = __commonJS({
183
187
  }
184
188
  });
185
189
 
186
- // node_modules/ajv/dist/compile/codegen/scope.js
190
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/codegen/scope.js
187
191
  var require_scope = __commonJS({
188
- "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) {
189
193
  "use strict";
190
194
  Object.defineProperty(exports, "__esModule", { value: true });
191
195
  exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0;
@@ -328,9 +332,9 @@ var require_scope = __commonJS({
328
332
  }
329
333
  });
330
334
 
331
- // node_modules/ajv/dist/compile/codegen/index.js
335
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/codegen/index.js
332
336
  var require_codegen = __commonJS({
333
- "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) {
334
338
  "use strict";
335
339
  Object.defineProperty(exports, "__esModule", { value: true });
336
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;
@@ -1048,9 +1052,9 @@ var require_codegen = __commonJS({
1048
1052
  }
1049
1053
  });
1050
1054
 
1051
- // node_modules/ajv/dist/compile/util.js
1055
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/util.js
1052
1056
  var require_util = __commonJS({
1053
- "node_modules/ajv/dist/compile/util.js"(exports) {
1057
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/util.js"(exports) {
1054
1058
  "use strict";
1055
1059
  Object.defineProperty(exports, "__esModule", { value: true });
1056
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;
@@ -1215,9 +1219,9 @@ var require_util = __commonJS({
1215
1219
  }
1216
1220
  });
1217
1221
 
1218
- // node_modules/ajv/dist/compile/names.js
1222
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/names.js
1219
1223
  var require_names = __commonJS({
1220
- "node_modules/ajv/dist/compile/names.js"(exports) {
1224
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/names.js"(exports) {
1221
1225
  "use strict";
1222
1226
  Object.defineProperty(exports, "__esModule", { value: true });
1223
1227
  var codegen_1 = require_codegen();
@@ -1254,9 +1258,9 @@ var require_names = __commonJS({
1254
1258
  }
1255
1259
  });
1256
1260
 
1257
- // node_modules/ajv/dist/compile/errors.js
1261
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/errors.js
1258
1262
  var require_errors = __commonJS({
1259
- "node_modules/ajv/dist/compile/errors.js"(exports) {
1263
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/errors.js"(exports) {
1260
1264
  "use strict";
1261
1265
  Object.defineProperty(exports, "__esModule", { value: true });
1262
1266
  exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = void 0;
@@ -1376,9 +1380,9 @@ var require_errors = __commonJS({
1376
1380
  }
1377
1381
  });
1378
1382
 
1379
- // node_modules/ajv/dist/compile/validate/boolSchema.js
1383
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/boolSchema.js
1380
1384
  var require_boolSchema = __commonJS({
1381
- "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) {
1382
1386
  "use strict";
1383
1387
  Object.defineProperty(exports, "__esModule", { value: true });
1384
1388
  exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = void 0;
@@ -1427,9 +1431,9 @@ var require_boolSchema = __commonJS({
1427
1431
  }
1428
1432
  });
1429
1433
 
1430
- // node_modules/ajv/dist/compile/rules.js
1434
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/rules.js
1431
1435
  var require_rules = __commonJS({
1432
- "node_modules/ajv/dist/compile/rules.js"(exports) {
1436
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/rules.js"(exports) {
1433
1437
  "use strict";
1434
1438
  Object.defineProperty(exports, "__esModule", { value: true });
1435
1439
  exports.getRules = exports.isJSONType = void 0;
@@ -1458,9 +1462,9 @@ var require_rules = __commonJS({
1458
1462
  }
1459
1463
  });
1460
1464
 
1461
- // node_modules/ajv/dist/compile/validate/applicability.js
1465
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/applicability.js
1462
1466
  var require_applicability = __commonJS({
1463
- "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) {
1464
1468
  "use strict";
1465
1469
  Object.defineProperty(exports, "__esModule", { value: true });
1466
1470
  exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = void 0;
@@ -1481,9 +1485,9 @@ var require_applicability = __commonJS({
1481
1485
  }
1482
1486
  });
1483
1487
 
1484
- // node_modules/ajv/dist/compile/validate/dataType.js
1488
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/dataType.js
1485
1489
  var require_dataType = __commonJS({
1486
- "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) {
1487
1491
  "use strict";
1488
1492
  Object.defineProperty(exports, "__esModule", { value: true });
1489
1493
  exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = void 0;
@@ -1665,9 +1669,9 @@ var require_dataType = __commonJS({
1665
1669
  }
1666
1670
  });
1667
1671
 
1668
- // node_modules/ajv/dist/compile/validate/defaults.js
1672
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/defaults.js
1669
1673
  var require_defaults = __commonJS({
1670
- "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) {
1671
1675
  "use strict";
1672
1676
  Object.defineProperty(exports, "__esModule", { value: true });
1673
1677
  exports.assignDefaults = void 0;
@@ -1702,9 +1706,9 @@ var require_defaults = __commonJS({
1702
1706
  }
1703
1707
  });
1704
1708
 
1705
- // node_modules/ajv/dist/vocabularies/code.js
1709
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/code.js
1706
1710
  var require_code2 = __commonJS({
1707
- "node_modules/ajv/dist/vocabularies/code.js"(exports) {
1711
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/code.js"(exports) {
1708
1712
  "use strict";
1709
1713
  Object.defineProperty(exports, "__esModule", { value: true });
1710
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;
@@ -1835,9 +1839,9 @@ var require_code2 = __commonJS({
1835
1839
  }
1836
1840
  });
1837
1841
 
1838
- // node_modules/ajv/dist/compile/validate/keyword.js
1842
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/keyword.js
1839
1843
  var require_keyword = __commonJS({
1840
- "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) {
1841
1845
  "use strict";
1842
1846
  Object.defineProperty(exports, "__esModule", { value: true });
1843
1847
  exports.validateKeywordUsage = exports.validSchemaType = exports.funcKeywordCode = exports.macroKeywordCode = void 0;
@@ -1953,9 +1957,9 @@ var require_keyword = __commonJS({
1953
1957
  }
1954
1958
  });
1955
1959
 
1956
- // node_modules/ajv/dist/compile/validate/subschema.js
1960
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/subschema.js
1957
1961
  var require_subschema = __commonJS({
1958
- "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) {
1959
1963
  "use strict";
1960
1964
  Object.defineProperty(exports, "__esModule", { value: true });
1961
1965
  exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = void 0;
@@ -2036,9 +2040,9 @@ var require_subschema = __commonJS({
2036
2040
  }
2037
2041
  });
2038
2042
 
2039
- // node_modules/fast-deep-equal/index.js
2043
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/fast-deep-equal/index.js
2040
2044
  var require_fast_deep_equal = __commonJS({
2041
- "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) {
2042
2046
  "use strict";
2043
2047
  module.exports = function equal(a, b) {
2044
2048
  if (a === b) return true;
@@ -2071,9 +2075,9 @@ var require_fast_deep_equal = __commonJS({
2071
2075
  }
2072
2076
  });
2073
2077
 
2074
- // node_modules/json-schema-traverse/index.js
2078
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/json-schema-traverse/index.js
2075
2079
  var require_json_schema_traverse = __commonJS({
2076
- "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) {
2077
2081
  "use strict";
2078
2082
  var traverse = module.exports = function(schema, opts, cb) {
2079
2083
  if (typeof opts == "function") {
@@ -2159,9 +2163,9 @@ var require_json_schema_traverse = __commonJS({
2159
2163
  }
2160
2164
  });
2161
2165
 
2162
- // node_modules/ajv/dist/compile/resolve.js
2166
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/resolve.js
2163
2167
  var require_resolve = __commonJS({
2164
- "node_modules/ajv/dist/compile/resolve.js"(exports) {
2168
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/resolve.js"(exports) {
2165
2169
  "use strict";
2166
2170
  Object.defineProperty(exports, "__esModule", { value: true });
2167
2171
  exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = void 0;
@@ -2315,9 +2319,9 @@ var require_resolve = __commonJS({
2315
2319
  }
2316
2320
  });
2317
2321
 
2318
- // node_modules/ajv/dist/compile/validate/index.js
2322
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/validate/index.js
2319
2323
  var require_validate = __commonJS({
2320
- "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) {
2321
2325
  "use strict";
2322
2326
  Object.defineProperty(exports, "__esModule", { value: true });
2323
2327
  exports.getData = exports.KeywordCxt = exports.validateFunctionCode = void 0;
@@ -2823,9 +2827,9 @@ var require_validate = __commonJS({
2823
2827
  }
2824
2828
  });
2825
2829
 
2826
- // node_modules/ajv/dist/runtime/validation_error.js
2830
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/validation_error.js
2827
2831
  var require_validation_error = __commonJS({
2828
- "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) {
2829
2833
  "use strict";
2830
2834
  Object.defineProperty(exports, "__esModule", { value: true });
2831
2835
  var ValidationError = class extends Error {
@@ -2839,9 +2843,9 @@ var require_validation_error = __commonJS({
2839
2843
  }
2840
2844
  });
2841
2845
 
2842
- // node_modules/ajv/dist/compile/ref_error.js
2846
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/ref_error.js
2843
2847
  var require_ref_error = __commonJS({
2844
- "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) {
2845
2849
  "use strict";
2846
2850
  Object.defineProperty(exports, "__esModule", { value: true });
2847
2851
  var resolve_1 = require_resolve();
@@ -2856,9 +2860,9 @@ var require_ref_error = __commonJS({
2856
2860
  }
2857
2861
  });
2858
2862
 
2859
- // node_modules/ajv/dist/compile/index.js
2863
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/index.js
2860
2864
  var require_compile = __commonJS({
2861
- "node_modules/ajv/dist/compile/index.js"(exports) {
2865
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/compile/index.js"(exports) {
2862
2866
  "use strict";
2863
2867
  Object.defineProperty(exports, "__esModule", { value: true });
2864
2868
  exports.resolveSchema = exports.getCompilingSchema = exports.resolveRef = exports.compileSchema = exports.SchemaEnv = void 0;
@@ -3080,9 +3084,9 @@ var require_compile = __commonJS({
3080
3084
  }
3081
3085
  });
3082
3086
 
3083
- // node_modules/ajv/dist/refs/data.json
3087
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/refs/data.json
3084
3088
  var require_data = __commonJS({
3085
- "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) {
3086
3090
  module.exports = {
3087
3091
  $id: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
3088
3092
  description: "Meta-schema for $data reference (JSON AnySchema extension proposal)",
@@ -3099,12 +3103,15 @@ var require_data = __commonJS({
3099
3103
  }
3100
3104
  });
3101
3105
 
3102
- // node_modules/fast-uri/lib/utils.js
3106
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/fast-uri/lib/utils.js
3103
3107
  var require_utils = __commonJS({
3104
- "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) {
3105
3109
  "use strict";
3106
3110
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3107
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);
3112
+ var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
3113
+ var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
3114
+ var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
3108
3115
  function stringArrayToHexStripped(input) {
3109
3116
  let acc = "";
3110
3117
  let code = 0;
@@ -3297,27 +3304,77 @@ var require_utils = __commonJS({
3297
3304
  }
3298
3305
  return output.join("");
3299
3306
  }
3300
- function normalizeComponentEncoding(component, esc2) {
3301
- const func = esc2 !== true ? escape : unescape;
3302
- if (component.scheme !== void 0) {
3303
- component.scheme = func(component.scheme);
3304
- }
3305
- if (component.userinfo !== void 0) {
3306
- component.userinfo = func(component.userinfo);
3307
- }
3308
- if (component.host !== void 0) {
3309
- component.host = func(component.host);
3307
+ var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
3308
+ var HOST_DELIM_RE = /[@/?#:]/g;
3309
+ var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
3310
+ function reescapeHostDelimiters(host, isIP) {
3311
+ const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
3312
+ re.lastIndex = 0;
3313
+ return host.replace(re, (ch) => HOST_DELIMS[ch]);
3314
+ }
3315
+ function normalizePercentEncoding(input, decodeUnreserved = false) {
3316
+ if (input.indexOf("%") === -1) {
3317
+ return input;
3310
3318
  }
3311
- if (component.path !== void 0) {
3312
- component.path = func(component.path);
3319
+ let output = "";
3320
+ for (let i = 0; i < input.length; i++) {
3321
+ if (input[i] === "%" && i + 2 < input.length) {
3322
+ const hex3 = input.slice(i + 1, i + 3);
3323
+ if (isHexPair(hex3)) {
3324
+ const normalizedHex = hex3.toUpperCase();
3325
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3326
+ if (decodeUnreserved && isUnreserved(decoded)) {
3327
+ output += decoded;
3328
+ } else {
3329
+ output += "%" + normalizedHex;
3330
+ }
3331
+ i += 2;
3332
+ continue;
3333
+ }
3334
+ }
3335
+ output += input[i];
3313
3336
  }
3314
- if (component.query !== void 0) {
3315
- component.query = func(component.query);
3337
+ return output;
3338
+ }
3339
+ function normalizePathEncoding(input) {
3340
+ let output = "";
3341
+ for (let i = 0; i < input.length; i++) {
3342
+ if (input[i] === "%" && i + 2 < input.length) {
3343
+ const hex3 = input.slice(i + 1, i + 3);
3344
+ if (isHexPair(hex3)) {
3345
+ const normalizedHex = hex3.toUpperCase();
3346
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3347
+ if (decoded !== "." && isUnreserved(decoded)) {
3348
+ output += decoded;
3349
+ } else {
3350
+ output += "%" + normalizedHex;
3351
+ }
3352
+ i += 2;
3353
+ continue;
3354
+ }
3355
+ }
3356
+ if (isPathCharacter(input[i])) {
3357
+ output += input[i];
3358
+ } else {
3359
+ output += escape(input[i]);
3360
+ }
3316
3361
  }
3317
- if (component.fragment !== void 0) {
3318
- component.fragment = func(component.fragment);
3362
+ return output;
3363
+ }
3364
+ function escapePreservingEscapes(input) {
3365
+ let output = "";
3366
+ for (let i = 0; i < input.length; i++) {
3367
+ if (input[i] === "%" && i + 2 < input.length) {
3368
+ const hex3 = input.slice(i + 1, i + 3);
3369
+ if (isHexPair(hex3)) {
3370
+ output += "%" + hex3.toUpperCase();
3371
+ i += 2;
3372
+ continue;
3373
+ }
3374
+ }
3375
+ output += escape(input[i]);
3319
3376
  }
3320
- return component;
3377
+ return output;
3321
3378
  }
3322
3379
  function recomposeAuthority(component) {
3323
3380
  const uriTokens = [];
@@ -3332,7 +3389,7 @@ var require_utils = __commonJS({
3332
3389
  if (ipV6res.isIPV6 === true) {
3333
3390
  host = `[${ipV6res.escapedHost}]`;
3334
3391
  } else {
3335
- host = component.host;
3392
+ host = reescapeHostDelimiters(host, false);
3336
3393
  }
3337
3394
  }
3338
3395
  uriTokens.push(host);
@@ -3346,7 +3403,10 @@ var require_utils = __commonJS({
3346
3403
  module.exports = {
3347
3404
  nonSimpleDomain,
3348
3405
  recomposeAuthority,
3349
- normalizeComponentEncoding,
3406
+ reescapeHostDelimiters,
3407
+ normalizePercentEncoding,
3408
+ normalizePathEncoding,
3409
+ escapePreservingEscapes,
3350
3410
  removeDotSegments,
3351
3411
  isIPv4,
3352
3412
  isUUID,
@@ -3356,9 +3416,9 @@ var require_utils = __commonJS({
3356
3416
  }
3357
3417
  });
3358
3418
 
3359
- // node_modules/fast-uri/lib/schemes.js
3419
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/fast-uri/lib/schemes.js
3360
3420
  var require_schemes = __commonJS({
3361
- "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) {
3362
3422
  "use strict";
3363
3423
  var { isUUID } = require_utils();
3364
3424
  var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
@@ -3566,16 +3626,16 @@ var require_schemes = __commonJS({
3566
3626
  }
3567
3627
  });
3568
3628
 
3569
- // node_modules/fast-uri/index.js
3629
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/fast-uri/index.js
3570
3630
  var require_fast_uri = __commonJS({
3571
- "node_modules/fast-uri/index.js"(exports, module) {
3631
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/fast-uri/index.js"(exports, module) {
3572
3632
  "use strict";
3573
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
3633
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3574
3634
  var { SCHEMES, getSchemeHandler } = require_schemes();
3575
3635
  function normalize(uri, options) {
3576
3636
  if (typeof uri === "string") {
3577
3637
  uri = /** @type {T} */
3578
- serialize(parse3(uri, options), options);
3638
+ normalizeString(uri, options);
3579
3639
  } else if (typeof uri === "object") {
3580
3640
  uri = /** @type {T} */
3581
3641
  parse3(serialize(uri, options), options);
@@ -3642,19 +3702,9 @@ var require_fast_uri = __commonJS({
3642
3702
  return target;
3643
3703
  }
3644
3704
  function equal(uriA, uriB, options) {
3645
- if (typeof uriA === "string") {
3646
- uriA = unescape(uriA);
3647
- uriA = serialize(normalizeComponentEncoding(parse3(uriA, options), true), { ...options, skipEscape: true });
3648
- } else if (typeof uriA === "object") {
3649
- uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true });
3650
- }
3651
- if (typeof uriB === "string") {
3652
- uriB = unescape(uriB);
3653
- uriB = serialize(normalizeComponentEncoding(parse3(uriB, options), true), { ...options, skipEscape: true });
3654
- } else if (typeof uriB === "object") {
3655
- uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true });
3656
- }
3657
- return uriA.toLowerCase() === uriB.toLowerCase();
3705
+ const normalizedA = normalizeComparableURI(uriA, options);
3706
+ const normalizedB = normalizeComparableURI(uriB, options);
3707
+ return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
3658
3708
  }
3659
3709
  function serialize(cmpts, opts) {
3660
3710
  const component = {
@@ -3679,12 +3729,12 @@ var require_fast_uri = __commonJS({
3679
3729
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
3680
3730
  if (component.path !== void 0) {
3681
3731
  if (!options.skipEscape) {
3682
- component.path = escape(component.path);
3732
+ component.path = escapePreservingEscapes(component.path);
3683
3733
  if (component.scheme !== void 0) {
3684
3734
  component.path = component.path.split("%3A").join(":");
3685
3735
  }
3686
3736
  } else {
3687
- component.path = unescape(component.path);
3737
+ component.path = normalizePercentEncoding(component.path);
3688
3738
  }
3689
3739
  }
3690
3740
  if (options.reference !== "suffix" && component.scheme) {
@@ -3719,7 +3769,17 @@ var require_fast_uri = __commonJS({
3719
3769
  return uriTokens.join("");
3720
3770
  }
3721
3771
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
3722
- function parse3(uri, opts) {
3772
+ var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
3773
+ function getParseError(parsed, matches) {
3774
+ if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
3775
+ return 'URI path must start with "/" when authority is present.';
3776
+ }
3777
+ if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) {
3778
+ return "URI port is malformed.";
3779
+ }
3780
+ return void 0;
3781
+ }
3782
+ function parseWithStatus(uri, opts) {
3723
3783
  const options = Object.assign({}, opts);
3724
3784
  const parsed = {
3725
3785
  scheme: void 0,
@@ -3730,6 +3790,7 @@ var require_fast_uri = __commonJS({
3730
3790
  query: void 0,
3731
3791
  fragment: void 0
3732
3792
  };
3793
+ let malformedAuthorityOrPort = false;
3733
3794
  let isIP = false;
3734
3795
  if (options.reference === "suffix") {
3735
3796
  if (options.scheme) {
@@ -3738,6 +3799,11 @@ var require_fast_uri = __commonJS({
3738
3799
  uri = "//" + uri;
3739
3800
  }
3740
3801
  }
3802
+ const authorityMatch = uri.match(AUTHORITY_PREFIX);
3803
+ if (authorityMatch !== null && authorityMatch[1].indexOf("\\") !== -1) {
3804
+ parsed.error = "URI authority must not contain a literal backslash.";
3805
+ malformedAuthorityOrPort = true;
3806
+ }
3741
3807
  const matches = uri.match(URI_PARSE);
3742
3808
  if (matches) {
3743
3809
  parsed.scheme = matches[1];
@@ -3750,6 +3816,11 @@ var require_fast_uri = __commonJS({
3750
3816
  if (isNaN(parsed.port)) {
3751
3817
  parsed.port = matches[5];
3752
3818
  }
3819
+ const parseError = getParseError(parsed, matches);
3820
+ if (parseError !== void 0) {
3821
+ parsed.error = parsed.error || parseError;
3822
+ malformedAuthorityOrPort = true;
3823
+ }
3753
3824
  if (parsed.host) {
3754
3825
  const ipv4result = isIPv4(parsed.host);
3755
3826
  if (ipv4result === false) {
@@ -3776,7 +3847,7 @@ var require_fast_uri = __commonJS({
3776
3847
  if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
3777
3848
  if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
3778
3849
  try {
3779
- parsed.host = URL.domainToASCII(parsed.host.toLowerCase());
3850
+ parsed.host = new URL("http://" + parsed.host).hostname;
3780
3851
  } catch (e) {
3781
3852
  parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
3782
3853
  }
@@ -3788,14 +3859,18 @@ var require_fast_uri = __commonJS({
3788
3859
  parsed.scheme = unescape(parsed.scheme);
3789
3860
  }
3790
3861
  if (parsed.host !== void 0) {
3791
- parsed.host = unescape(parsed.host);
3862
+ parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
3792
3863
  }
3793
3864
  }
3794
3865
  if (parsed.path) {
3795
- parsed.path = escape(unescape(parsed.path));
3866
+ parsed.path = normalizePathEncoding(parsed.path);
3796
3867
  }
3797
3868
  if (parsed.fragment) {
3798
- parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
3869
+ try {
3870
+ parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
3871
+ } catch {
3872
+ parsed.error = parsed.error || "URI malformed";
3873
+ }
3799
3874
  }
3800
3875
  }
3801
3876
  if (schemeHandler && schemeHandler.parse) {
@@ -3804,7 +3879,29 @@ var require_fast_uri = __commonJS({
3804
3879
  } else {
3805
3880
  parsed.error = parsed.error || "URI can not be parsed.";
3806
3881
  }
3807
- return parsed;
3882
+ return { parsed, malformedAuthorityOrPort };
3883
+ }
3884
+ function parse3(uri, opts) {
3885
+ return parseWithStatus(uri, opts).parsed;
3886
+ }
3887
+ function normalizeString(uri, opts) {
3888
+ return normalizeStringWithStatus(uri, opts).normalized;
3889
+ }
3890
+ function normalizeStringWithStatus(uri, opts) {
3891
+ const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
3892
+ return {
3893
+ normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
3894
+ malformedAuthorityOrPort
3895
+ };
3896
+ }
3897
+ function normalizeComparableURI(uri, opts) {
3898
+ if (typeof uri === "string") {
3899
+ const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
3900
+ return malformedAuthorityOrPort ? void 0 : normalized;
3901
+ }
3902
+ if (typeof uri === "object") {
3903
+ return serialize(uri, opts);
3904
+ }
3808
3905
  }
3809
3906
  var fastUri = {
3810
3907
  SCHEMES,
@@ -3821,9 +3918,9 @@ var require_fast_uri = __commonJS({
3821
3918
  }
3822
3919
  });
3823
3920
 
3824
- // node_modules/ajv/dist/runtime/uri.js
3921
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/uri.js
3825
3922
  var require_uri = __commonJS({
3826
- "node_modules/ajv/dist/runtime/uri.js"(exports) {
3923
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/uri.js"(exports) {
3827
3924
  "use strict";
3828
3925
  Object.defineProperty(exports, "__esModule", { value: true });
3829
3926
  var uri = require_fast_uri();
@@ -3832,9 +3929,9 @@ var require_uri = __commonJS({
3832
3929
  }
3833
3930
  });
3834
3931
 
3835
- // node_modules/ajv/dist/core.js
3932
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/core.js
3836
3933
  var require_core = __commonJS({
3837
- "node_modules/ajv/dist/core.js"(exports) {
3934
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/core.js"(exports) {
3838
3935
  "use strict";
3839
3936
  Object.defineProperty(exports, "__esModule", { value: true });
3840
3937
  exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
@@ -4443,9 +4540,9 @@ var require_core = __commonJS({
4443
4540
  }
4444
4541
  });
4445
4542
 
4446
- // node_modules/ajv/dist/vocabularies/core/id.js
4543
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/core/id.js
4447
4544
  var require_id = __commonJS({
4448
- "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) {
4449
4546
  "use strict";
4450
4547
  Object.defineProperty(exports, "__esModule", { value: true });
4451
4548
  var def = {
@@ -4458,9 +4555,9 @@ var require_id = __commonJS({
4458
4555
  }
4459
4556
  });
4460
4557
 
4461
- // node_modules/ajv/dist/vocabularies/core/ref.js
4558
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/core/ref.js
4462
4559
  var require_ref = __commonJS({
4463
- "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) {
4464
4561
  "use strict";
4465
4562
  Object.defineProperty(exports, "__esModule", { value: true });
4466
4563
  exports.callRef = exports.getValidate = void 0;
@@ -4580,9 +4677,9 @@ var require_ref = __commonJS({
4580
4677
  }
4581
4678
  });
4582
4679
 
4583
- // node_modules/ajv/dist/vocabularies/core/index.js
4680
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/core/index.js
4584
4681
  var require_core2 = __commonJS({
4585
- "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) {
4586
4683
  "use strict";
4587
4684
  Object.defineProperty(exports, "__esModule", { value: true });
4588
4685
  var id_1 = require_id();
@@ -4601,9 +4698,9 @@ var require_core2 = __commonJS({
4601
4698
  }
4602
4699
  });
4603
4700
 
4604
- // node_modules/ajv/dist/vocabularies/validation/limitNumber.js
4701
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/limitNumber.js
4605
4702
  var require_limitNumber = __commonJS({
4606
- "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) {
4607
4704
  "use strict";
4608
4705
  Object.defineProperty(exports, "__esModule", { value: true });
4609
4706
  var codegen_1 = require_codegen();
@@ -4633,9 +4730,9 @@ var require_limitNumber = __commonJS({
4633
4730
  }
4634
4731
  });
4635
4732
 
4636
- // node_modules/ajv/dist/vocabularies/validation/multipleOf.js
4733
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/multipleOf.js
4637
4734
  var require_multipleOf = __commonJS({
4638
- "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) {
4639
4736
  "use strict";
4640
4737
  Object.defineProperty(exports, "__esModule", { value: true });
4641
4738
  var codegen_1 = require_codegen();
@@ -4661,9 +4758,9 @@ var require_multipleOf = __commonJS({
4661
4758
  }
4662
4759
  });
4663
4760
 
4664
- // node_modules/ajv/dist/runtime/ucs2length.js
4761
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/ucs2length.js
4665
4762
  var require_ucs2length = __commonJS({
4666
- "node_modules/ajv/dist/runtime/ucs2length.js"(exports) {
4763
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/ucs2length.js"(exports) {
4667
4764
  "use strict";
4668
4765
  Object.defineProperty(exports, "__esModule", { value: true });
4669
4766
  function ucs2length(str) {
@@ -4687,9 +4784,9 @@ var require_ucs2length = __commonJS({
4687
4784
  }
4688
4785
  });
4689
4786
 
4690
- // node_modules/ajv/dist/vocabularies/validation/limitLength.js
4787
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/limitLength.js
4691
4788
  var require_limitLength = __commonJS({
4692
- "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) {
4693
4790
  "use strict";
4694
4791
  Object.defineProperty(exports, "__esModule", { value: true });
4695
4792
  var codegen_1 = require_codegen();
@@ -4719,9 +4816,9 @@ var require_limitLength = __commonJS({
4719
4816
  }
4720
4817
  });
4721
4818
 
4722
- // node_modules/ajv/dist/vocabularies/validation/pattern.js
4819
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/pattern.js
4723
4820
  var require_pattern = __commonJS({
4724
- "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) {
4725
4822
  "use strict";
4726
4823
  Object.defineProperty(exports, "__esModule", { value: true });
4727
4824
  var code_1 = require_code2();
@@ -4756,9 +4853,9 @@ var require_pattern = __commonJS({
4756
4853
  }
4757
4854
  });
4758
4855
 
4759
- // node_modules/ajv/dist/vocabularies/validation/limitProperties.js
4856
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/limitProperties.js
4760
4857
  var require_limitProperties = __commonJS({
4761
- "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) {
4762
4859
  "use strict";
4763
4860
  Object.defineProperty(exports, "__esModule", { value: true });
4764
4861
  var codegen_1 = require_codegen();
@@ -4785,9 +4882,9 @@ var require_limitProperties = __commonJS({
4785
4882
  }
4786
4883
  });
4787
4884
 
4788
- // node_modules/ajv/dist/vocabularies/validation/required.js
4885
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/required.js
4789
4886
  var require_required = __commonJS({
4790
- "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) {
4791
4888
  "use strict";
4792
4889
  Object.defineProperty(exports, "__esModule", { value: true });
4793
4890
  var code_1 = require_code2();
@@ -4867,9 +4964,9 @@ var require_required = __commonJS({
4867
4964
  }
4868
4965
  });
4869
4966
 
4870
- // node_modules/ajv/dist/vocabularies/validation/limitItems.js
4967
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/limitItems.js
4871
4968
  var require_limitItems = __commonJS({
4872
- "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) {
4873
4970
  "use strict";
4874
4971
  Object.defineProperty(exports, "__esModule", { value: true });
4875
4972
  var codegen_1 = require_codegen();
@@ -4896,9 +4993,9 @@ var require_limitItems = __commonJS({
4896
4993
  }
4897
4994
  });
4898
4995
 
4899
- // node_modules/ajv/dist/runtime/equal.js
4996
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/equal.js
4900
4997
  var require_equal = __commonJS({
4901
- "node_modules/ajv/dist/runtime/equal.js"(exports) {
4998
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/runtime/equal.js"(exports) {
4902
4999
  "use strict";
4903
5000
  Object.defineProperty(exports, "__esModule", { value: true });
4904
5001
  var equal = require_fast_deep_equal();
@@ -4907,9 +5004,9 @@ var require_equal = __commonJS({
4907
5004
  }
4908
5005
  });
4909
5006
 
4910
- // node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
5007
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
4911
5008
  var require_uniqueItems = __commonJS({
4912
- "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) {
4913
5010
  "use strict";
4914
5011
  Object.defineProperty(exports, "__esModule", { value: true });
4915
5012
  var dataType_1 = require_dataType();
@@ -4974,9 +5071,9 @@ var require_uniqueItems = __commonJS({
4974
5071
  }
4975
5072
  });
4976
5073
 
4977
- // node_modules/ajv/dist/vocabularies/validation/const.js
5074
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/const.js
4978
5075
  var require_const = __commonJS({
4979
- "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) {
4980
5077
  "use strict";
4981
5078
  Object.defineProperty(exports, "__esModule", { value: true });
4982
5079
  var codegen_1 = require_codegen();
@@ -5003,9 +5100,9 @@ var require_const = __commonJS({
5003
5100
  }
5004
5101
  });
5005
5102
 
5006
- // node_modules/ajv/dist/vocabularies/validation/enum.js
5103
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/enum.js
5007
5104
  var require_enum = __commonJS({
5008
- "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) {
5009
5106
  "use strict";
5010
5107
  Object.defineProperty(exports, "__esModule", { value: true });
5011
5108
  var codegen_1 = require_codegen();
@@ -5052,9 +5149,9 @@ var require_enum = __commonJS({
5052
5149
  }
5053
5150
  });
5054
5151
 
5055
- // node_modules/ajv/dist/vocabularies/validation/index.js
5152
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/validation/index.js
5056
5153
  var require_validation = __commonJS({
5057
- "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) {
5058
5155
  "use strict";
5059
5156
  Object.defineProperty(exports, "__esModule", { value: true });
5060
5157
  var limitNumber_1 = require_limitNumber();
@@ -5090,9 +5187,9 @@ var require_validation = __commonJS({
5090
5187
  }
5091
5188
  });
5092
5189
 
5093
- // node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
5190
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
5094
5191
  var require_additionalItems = __commonJS({
5095
- "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) {
5096
5193
  "use strict";
5097
5194
  Object.defineProperty(exports, "__esModule", { value: true });
5098
5195
  exports.validateAdditionalItems = void 0;
@@ -5143,9 +5240,9 @@ var require_additionalItems = __commonJS({
5143
5240
  }
5144
5241
  });
5145
5242
 
5146
- // node_modules/ajv/dist/vocabularies/applicator/items.js
5243
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/items.js
5147
5244
  var require_items = __commonJS({
5148
- "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) {
5149
5246
  "use strict";
5150
5247
  Object.defineProperty(exports, "__esModule", { value: true });
5151
5248
  exports.validateTuple = void 0;
@@ -5200,9 +5297,9 @@ var require_items = __commonJS({
5200
5297
  }
5201
5298
  });
5202
5299
 
5203
- // node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
5300
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
5204
5301
  var require_prefixItems = __commonJS({
5205
- "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) {
5206
5303
  "use strict";
5207
5304
  Object.defineProperty(exports, "__esModule", { value: true });
5208
5305
  var items_1 = require_items();
@@ -5217,9 +5314,9 @@ var require_prefixItems = __commonJS({
5217
5314
  }
5218
5315
  });
5219
5316
 
5220
- // node_modules/ajv/dist/vocabularies/applicator/items2020.js
5317
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/items2020.js
5221
5318
  var require_items2020 = __commonJS({
5222
- "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) {
5223
5320
  "use strict";
5224
5321
  Object.defineProperty(exports, "__esModule", { value: true });
5225
5322
  var codegen_1 = require_codegen();
@@ -5252,9 +5349,9 @@ var require_items2020 = __commonJS({
5252
5349
  }
5253
5350
  });
5254
5351
 
5255
- // node_modules/ajv/dist/vocabularies/applicator/contains.js
5352
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/contains.js
5256
5353
  var require_contains = __commonJS({
5257
- "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) {
5258
5355
  "use strict";
5259
5356
  Object.defineProperty(exports, "__esModule", { value: true });
5260
5357
  var codegen_1 = require_codegen();
@@ -5346,9 +5443,9 @@ var require_contains = __commonJS({
5346
5443
  }
5347
5444
  });
5348
5445
 
5349
- // node_modules/ajv/dist/vocabularies/applicator/dependencies.js
5446
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/dependencies.js
5350
5447
  var require_dependencies = __commonJS({
5351
- "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) {
5352
5449
  "use strict";
5353
5450
  Object.defineProperty(exports, "__esModule", { value: true });
5354
5451
  exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0;
@@ -5440,9 +5537,9 @@ var require_dependencies = __commonJS({
5440
5537
  }
5441
5538
  });
5442
5539
 
5443
- // node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
5540
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
5444
5541
  var require_propertyNames = __commonJS({
5445
- "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) {
5446
5543
  "use strict";
5447
5544
  Object.defineProperty(exports, "__esModule", { value: true });
5448
5545
  var codegen_1 = require_codegen();
@@ -5483,9 +5580,9 @@ var require_propertyNames = __commonJS({
5483
5580
  }
5484
5581
  });
5485
5582
 
5486
- // node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
5583
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
5487
5584
  var require_additionalProperties = __commonJS({
5488
- "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) {
5489
5586
  "use strict";
5490
5587
  Object.defineProperty(exports, "__esModule", { value: true });
5491
5588
  var code_1 = require_code2();
@@ -5589,9 +5686,9 @@ var require_additionalProperties = __commonJS({
5589
5686
  }
5590
5687
  });
5591
5688
 
5592
- // node_modules/ajv/dist/vocabularies/applicator/properties.js
5689
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/properties.js
5593
5690
  var require_properties = __commonJS({
5594
- "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) {
5595
5692
  "use strict";
5596
5693
  Object.defineProperty(exports, "__esModule", { value: true });
5597
5694
  var validate_1 = require_validate();
@@ -5647,9 +5744,9 @@ var require_properties = __commonJS({
5647
5744
  }
5648
5745
  });
5649
5746
 
5650
- // node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
5747
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
5651
5748
  var require_patternProperties = __commonJS({
5652
- "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) {
5653
5750
  "use strict";
5654
5751
  Object.defineProperty(exports, "__esModule", { value: true });
5655
5752
  var code_1 = require_code2();
@@ -5721,9 +5818,9 @@ var require_patternProperties = __commonJS({
5721
5818
  }
5722
5819
  });
5723
5820
 
5724
- // node_modules/ajv/dist/vocabularies/applicator/not.js
5821
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/not.js
5725
5822
  var require_not = __commonJS({
5726
- "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) {
5727
5824
  "use strict";
5728
5825
  Object.defineProperty(exports, "__esModule", { value: true });
5729
5826
  var util_1 = require_util();
@@ -5752,9 +5849,9 @@ var require_not = __commonJS({
5752
5849
  }
5753
5850
  });
5754
5851
 
5755
- // node_modules/ajv/dist/vocabularies/applicator/anyOf.js
5852
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/anyOf.js
5756
5853
  var require_anyOf = __commonJS({
5757
- "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) {
5758
5855
  "use strict";
5759
5856
  Object.defineProperty(exports, "__esModule", { value: true });
5760
5857
  var code_1 = require_code2();
@@ -5769,9 +5866,9 @@ var require_anyOf = __commonJS({
5769
5866
  }
5770
5867
  });
5771
5868
 
5772
- // node_modules/ajv/dist/vocabularies/applicator/oneOf.js
5869
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/oneOf.js
5773
5870
  var require_oneOf = __commonJS({
5774
- "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) {
5775
5872
  "use strict";
5776
5873
  Object.defineProperty(exports, "__esModule", { value: true });
5777
5874
  var codegen_1 = require_codegen();
@@ -5827,9 +5924,9 @@ var require_oneOf = __commonJS({
5827
5924
  }
5828
5925
  });
5829
5926
 
5830
- // node_modules/ajv/dist/vocabularies/applicator/allOf.js
5927
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/allOf.js
5831
5928
  var require_allOf = __commonJS({
5832
- "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) {
5833
5930
  "use strict";
5834
5931
  Object.defineProperty(exports, "__esModule", { value: true });
5835
5932
  var util_1 = require_util();
@@ -5854,9 +5951,9 @@ var require_allOf = __commonJS({
5854
5951
  }
5855
5952
  });
5856
5953
 
5857
- // node_modules/ajv/dist/vocabularies/applicator/if.js
5954
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/if.js
5858
5955
  var require_if = __commonJS({
5859
- "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) {
5860
5957
  "use strict";
5861
5958
  Object.defineProperty(exports, "__esModule", { value: true });
5862
5959
  var codegen_1 = require_codegen();
@@ -5923,9 +6020,9 @@ var require_if = __commonJS({
5923
6020
  }
5924
6021
  });
5925
6022
 
5926
- // node_modules/ajv/dist/vocabularies/applicator/thenElse.js
6023
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/thenElse.js
5927
6024
  var require_thenElse = __commonJS({
5928
- "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) {
5929
6026
  "use strict";
5930
6027
  Object.defineProperty(exports, "__esModule", { value: true });
5931
6028
  var util_1 = require_util();
@@ -5941,9 +6038,9 @@ var require_thenElse = __commonJS({
5941
6038
  }
5942
6039
  });
5943
6040
 
5944
- // node_modules/ajv/dist/vocabularies/applicator/index.js
6041
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/applicator/index.js
5945
6042
  var require_applicator = __commonJS({
5946
- "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) {
5947
6044
  "use strict";
5948
6045
  Object.defineProperty(exports, "__esModule", { value: true });
5949
6046
  var additionalItems_1 = require_additionalItems();
@@ -5989,9 +6086,9 @@ var require_applicator = __commonJS({
5989
6086
  }
5990
6087
  });
5991
6088
 
5992
- // node_modules/ajv/dist/vocabularies/format/format.js
6089
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/format/format.js
5993
6090
  var require_format = __commonJS({
5994
- "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) {
5995
6092
  "use strict";
5996
6093
  Object.defineProperty(exports, "__esModule", { value: true });
5997
6094
  var codegen_1 = require_codegen();
@@ -6079,9 +6176,9 @@ var require_format = __commonJS({
6079
6176
  }
6080
6177
  });
6081
6178
 
6082
- // node_modules/ajv/dist/vocabularies/format/index.js
6179
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/format/index.js
6083
6180
  var require_format2 = __commonJS({
6084
- "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) {
6085
6182
  "use strict";
6086
6183
  Object.defineProperty(exports, "__esModule", { value: true });
6087
6184
  var format_1 = require_format();
@@ -6090,9 +6187,9 @@ var require_format2 = __commonJS({
6090
6187
  }
6091
6188
  });
6092
6189
 
6093
- // node_modules/ajv/dist/vocabularies/metadata.js
6190
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/metadata.js
6094
6191
  var require_metadata = __commonJS({
6095
- "node_modules/ajv/dist/vocabularies/metadata.js"(exports) {
6192
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/metadata.js"(exports) {
6096
6193
  "use strict";
6097
6194
  Object.defineProperty(exports, "__esModule", { value: true });
6098
6195
  exports.contentVocabulary = exports.metadataVocabulary = void 0;
@@ -6113,9 +6210,9 @@ var require_metadata = __commonJS({
6113
6210
  }
6114
6211
  });
6115
6212
 
6116
- // node_modules/ajv/dist/vocabularies/draft7.js
6213
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/draft7.js
6117
6214
  var require_draft7 = __commonJS({
6118
- "node_modules/ajv/dist/vocabularies/draft7.js"(exports) {
6215
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/draft7.js"(exports) {
6119
6216
  "use strict";
6120
6217
  Object.defineProperty(exports, "__esModule", { value: true });
6121
6218
  var core_1 = require_core2();
@@ -6135,9 +6232,9 @@ var require_draft7 = __commonJS({
6135
6232
  }
6136
6233
  });
6137
6234
 
6138
- // node_modules/ajv/dist/vocabularies/discriminator/types.js
6235
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/discriminator/types.js
6139
6236
  var require_types = __commonJS({
6140
- "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) {
6141
6238
  "use strict";
6142
6239
  Object.defineProperty(exports, "__esModule", { value: true });
6143
6240
  exports.DiscrError = void 0;
@@ -6149,9 +6246,9 @@ var require_types = __commonJS({
6149
6246
  }
6150
6247
  });
6151
6248
 
6152
- // node_modules/ajv/dist/vocabularies/discriminator/index.js
6249
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/vocabularies/discriminator/index.js
6153
6250
  var require_discriminator = __commonJS({
6154
- "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) {
6155
6252
  "use strict";
6156
6253
  Object.defineProperty(exports, "__esModule", { value: true });
6157
6254
  var codegen_1 = require_codegen();
@@ -6254,9 +6351,9 @@ var require_discriminator = __commonJS({
6254
6351
  }
6255
6352
  });
6256
6353
 
6257
- // 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
6258
6355
  var require_json_schema_draft_07 = __commonJS({
6259
- "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) {
6260
6357
  module.exports = {
6261
6358
  $schema: "http://json-schema.org/draft-07/schema#",
6262
6359
  $id: "http://json-schema.org/draft-07/schema#",
@@ -6411,9 +6508,9 @@ var require_json_schema_draft_07 = __commonJS({
6411
6508
  }
6412
6509
  });
6413
6510
 
6414
- // node_modules/ajv/dist/ajv.js
6511
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/ajv.js
6415
6512
  var require_ajv = __commonJS({
6416
- "node_modules/ajv/dist/ajv.js"(exports, module) {
6513
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv/dist/ajv.js"(exports, module) {
6417
6514
  "use strict";
6418
6515
  Object.defineProperty(exports, "__esModule", { value: true });
6419
6516
  exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv = void 0;
@@ -6481,9 +6578,9 @@ var require_ajv = __commonJS({
6481
6578
  }
6482
6579
  });
6483
6580
 
6484
- // node_modules/ajv-formats/dist/formats.js
6581
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv-formats/dist/formats.js
6485
6582
  var require_formats = __commonJS({
6486
- "node_modules/ajv-formats/dist/formats.js"(exports) {
6583
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv-formats/dist/formats.js"(exports) {
6487
6584
  "use strict";
6488
6585
  Object.defineProperty(exports, "__esModule", { value: true });
6489
6586
  exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
@@ -6684,9 +6781,9 @@ var require_formats = __commonJS({
6684
6781
  }
6685
6782
  });
6686
6783
 
6687
- // node_modules/ajv-formats/dist/limit.js
6784
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv-formats/dist/limit.js
6688
6785
  var require_limit = __commonJS({
6689
- "node_modules/ajv-formats/dist/limit.js"(exports) {
6786
+ "../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv-formats/dist/limit.js"(exports) {
6690
6787
  "use strict";
6691
6788
  Object.defineProperty(exports, "__esModule", { value: true });
6692
6789
  exports.formatLimitDefinition = void 0;
@@ -6756,9 +6853,9 @@ var require_limit = __commonJS({
6756
6853
  }
6757
6854
  });
6758
6855
 
6759
- // node_modules/ajv-formats/dist/index.js
6856
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/ajv-formats/dist/index.js
6760
6857
  var require_dist = __commonJS({
6761
- "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) {
6762
6859
  "use strict";
6763
6860
  Object.defineProperty(exports, "__esModule", { value: true });
6764
6861
  var formats_1 = require_formats();
@@ -6798,7 +6895,7 @@ var require_dist = __commonJS({
6798
6895
  }
6799
6896
  });
6800
6897
 
6801
- // node_modules/zod/v3/helpers/util.js
6898
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v3/helpers/util.js
6802
6899
  var util;
6803
6900
  (function(util2) {
6804
6901
  util2.assertEqual = (_) => {
@@ -6932,7 +7029,7 @@ var getParsedType = (data) => {
6932
7029
  }
6933
7030
  };
6934
7031
 
6935
- // node_modules/zod/v3/ZodError.js
7032
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v3/ZodError.js
6936
7033
  var ZodIssueCode = util.arrayToEnum([
6937
7034
  "invalid_type",
6938
7035
  "invalid_literal",
@@ -7046,7 +7143,7 @@ ZodError.create = (issues) => {
7046
7143
  return error51;
7047
7144
  };
7048
7145
 
7049
- // node_modules/zod/v3/locales/en.js
7146
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v3/locales/en.js
7050
7147
  var errorMap = (issue2, _ctx) => {
7051
7148
  let message;
7052
7149
  switch (issue2.code) {
@@ -7149,13 +7246,13 @@ var errorMap = (issue2, _ctx) => {
7149
7246
  };
7150
7247
  var en_default = errorMap;
7151
7248
 
7152
- // node_modules/zod/v3/errors.js
7249
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v3/errors.js
7153
7250
  var overrideErrorMap = en_default;
7154
7251
  function getErrorMap() {
7155
7252
  return overrideErrorMap;
7156
7253
  }
7157
7254
 
7158
- // node_modules/zod/v3/helpers/parseUtil.js
7255
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v3/helpers/parseUtil.js
7159
7256
  var makeIssue = (params) => {
7160
7257
  const { data, path, errorMaps, issueData } = params;
7161
7258
  const fullPath = [...path, ...issueData.path || []];
@@ -7264,14 +7361,14 @@ var isDirty = (x) => x.status === "dirty";
7264
7361
  var isValid = (x) => x.status === "valid";
7265
7362
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
7266
7363
 
7267
- // node_modules/zod/v3/helpers/errorUtil.js
7364
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v3/helpers/errorUtil.js
7268
7365
  var errorUtil;
7269
7366
  (function(errorUtil2) {
7270
7367
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
7271
7368
  errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
7272
7369
  })(errorUtil || (errorUtil = {}));
7273
7370
 
7274
- // node_modules/zod/v3/types.js
7371
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v3/types.js
7275
7372
  var ParseInputLazyPath = class {
7276
7373
  constructor(parent, value, path, key) {
7277
7374
  this._cachedPath = [];
@@ -10674,7 +10771,7 @@ var nullableType = ZodNullable.create;
10674
10771
  var preprocessType = ZodEffects.createWithPreprocess;
10675
10772
  var pipelineType = ZodPipeline.create;
10676
10773
 
10677
- // node_modules/zod/v4/core/index.js
10774
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/index.js
10678
10775
  var core_exports2 = {};
10679
10776
  __export(core_exports2, {
10680
10777
  $ZodAny: () => $ZodAny,
@@ -10953,7 +11050,7 @@ __export(core_exports2, {
10953
11050
  version: () => version
10954
11051
  });
10955
11052
 
10956
- // node_modules/zod/v4/core/core.js
11053
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/core.js
10957
11054
  var _a;
10958
11055
  var NEVER = /* @__PURE__ */ Object.freeze({
10959
11056
  status: "aborted"
@@ -11030,7 +11127,7 @@ function config(newConfig) {
11030
11127
  return globalConfig;
11031
11128
  }
11032
11129
 
11033
- // node_modules/zod/v4/core/util.js
11130
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/util.js
11034
11131
  var util_exports = {};
11035
11132
  __export(util_exports, {
11036
11133
  BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
@@ -11726,7 +11823,7 @@ var Class = class {
11726
11823
  }
11727
11824
  };
11728
11825
 
11729
- // node_modules/zod/v4/core/errors.js
11826
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/errors.js
11730
11827
  var initializer = (inst, def) => {
11731
11828
  inst.name = "$ZodError";
11732
11829
  Object.defineProperty(inst, "_zod", {
@@ -11865,7 +11962,7 @@ function prettifyError(error51) {
11865
11962
  return lines.join("\n");
11866
11963
  }
11867
11964
 
11868
- // node_modules/zod/v4/core/parse.js
11965
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/parse.js
11869
11966
  var _parse = (_Err) => (schema, value, _ctx, _params) => {
11870
11967
  const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
11871
11968
  const result = schema._zod.run({ value, issues: [] }, ctx);
@@ -11953,7 +12050,7 @@ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
11953
12050
  };
11954
12051
  var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
11955
12052
 
11956
- // node_modules/zod/v4/core/regexes.js
12053
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/regexes.js
11957
12054
  var regexes_exports = {};
11958
12055
  __export(regexes_exports, {
11959
12056
  base64: () => base64,
@@ -12112,7 +12209,7 @@ var sha512_hex = /^[0-9a-fA-F]{128}$/;
12112
12209
  var sha512_base64 = /* @__PURE__ */ fixedBase64(86, "==");
12113
12210
  var sha512_base64url = /* @__PURE__ */ fixedBase64url(86);
12114
12211
 
12115
- // node_modules/zod/v4/core/checks.js
12212
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/checks.js
12116
12213
  var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
12117
12214
  var _a3;
12118
12215
  inst._zod ?? (inst._zod = {});
@@ -12660,7 +12757,7 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
12660
12757
  };
12661
12758
  });
12662
12759
 
12663
- // node_modules/zod/v4/core/doc.js
12760
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/doc.js
12664
12761
  var Doc = class {
12665
12762
  constructor(args = []) {
12666
12763
  this.content = [];
@@ -12696,14 +12793,14 @@ var Doc = class {
12696
12793
  }
12697
12794
  };
12698
12795
 
12699
- // node_modules/zod/v4/core/versions.js
12796
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/versions.js
12700
12797
  var version = {
12701
12798
  major: 4,
12702
12799
  minor: 4,
12703
12800
  patch: 3
12704
12801
  };
12705
12802
 
12706
- // node_modules/zod/v4/core/schemas.js
12803
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/schemas.js
12707
12804
  var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
12708
12805
  var _a3;
12709
12806
  inst ?? (inst = {});
@@ -14796,7 +14893,7 @@ function handleRefineResult(result, payload, input, inst) {
14796
14893
  }
14797
14894
  }
14798
14895
 
14799
- // node_modules/zod/v4/locales/index.js
14896
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/index.js
14800
14897
  var locales_exports = {};
14801
14898
  __export(locales_exports, {
14802
14899
  ar: () => ar_default,
@@ -14853,7 +14950,7 @@ __export(locales_exports, {
14853
14950
  zhTW: () => zh_TW_default
14854
14951
  });
14855
14952
 
14856
- // node_modules/zod/v4/locales/ar.js
14953
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ar.js
14857
14954
  var error = () => {
14858
14955
  const Sizable = {
14859
14956
  string: { unit: "\u062D\u0631\u0641", verb: "\u0623\u0646 \u064A\u062D\u0648\u064A" },
@@ -14960,7 +15057,7 @@ function ar_default() {
14960
15057
  };
14961
15058
  }
14962
15059
 
14963
- // node_modules/zod/v4/locales/az.js
15060
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/az.js
14964
15061
  var error2 = () => {
14965
15062
  const Sizable = {
14966
15063
  string: { unit: "simvol", verb: "olmal\u0131d\u0131r" },
@@ -15066,7 +15163,7 @@ function az_default() {
15066
15163
  };
15067
15164
  }
15068
15165
 
15069
- // node_modules/zod/v4/locales/be.js
15166
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/be.js
15070
15167
  function getBelarusianPlural(count, one, few, many) {
15071
15168
  const absCount = Math.abs(count);
15072
15169
  const lastDigit = absCount % 10;
@@ -15223,7 +15320,7 @@ function be_default() {
15223
15320
  };
15224
15321
  }
15225
15322
 
15226
- // node_modules/zod/v4/locales/bg.js
15323
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/bg.js
15227
15324
  var error4 = () => {
15228
15325
  const Sizable = {
15229
15326
  string: { unit: "\u0441\u0438\u043C\u0432\u043E\u043B\u0430", verb: "\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430" },
@@ -15344,7 +15441,7 @@ function bg_default() {
15344
15441
  };
15345
15442
  }
15346
15443
 
15347
- // node_modules/zod/v4/locales/ca.js
15444
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ca.js
15348
15445
  var error5 = () => {
15349
15446
  const Sizable = {
15350
15447
  string: { unit: "car\xE0cters", verb: "contenir" },
@@ -15453,7 +15550,7 @@ function ca_default() {
15453
15550
  };
15454
15551
  }
15455
15552
 
15456
- // node_modules/zod/v4/locales/cs.js
15553
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/cs.js
15457
15554
  var error6 = () => {
15458
15555
  const Sizable = {
15459
15556
  string: { unit: "znak\u016F", verb: "m\xEDt" },
@@ -15565,7 +15662,7 @@ function cs_default() {
15565
15662
  };
15566
15663
  }
15567
15664
 
15568
- // node_modules/zod/v4/locales/da.js
15665
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/da.js
15569
15666
  var error7 = () => {
15570
15667
  const Sizable = {
15571
15668
  string: { unit: "tegn", verb: "havde" },
@@ -15681,7 +15778,7 @@ function da_default() {
15681
15778
  };
15682
15779
  }
15683
15780
 
15684
- // node_modules/zod/v4/locales/de.js
15781
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/de.js
15685
15782
  var error8 = () => {
15686
15783
  const Sizable = {
15687
15784
  string: { unit: "Zeichen", verb: "zu haben" },
@@ -15790,7 +15887,7 @@ function de_default() {
15790
15887
  };
15791
15888
  }
15792
15889
 
15793
- // node_modules/zod/v4/locales/el.js
15890
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/el.js
15794
15891
  var error9 = () => {
15795
15892
  const Sizable = {
15796
15893
  string: { unit: "\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2", verb: "\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9" },
@@ -15900,7 +15997,7 @@ function el_default() {
15900
15997
  };
15901
15998
  }
15902
15999
 
15903
- // node_modules/zod/v4/locales/en.js
16000
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/en.js
15904
16001
  var error10 = () => {
15905
16002
  const Sizable = {
15906
16003
  string: { unit: "characters", verb: "to have" },
@@ -16013,7 +16110,7 @@ function en_default2() {
16013
16110
  };
16014
16111
  }
16015
16112
 
16016
- // node_modules/zod/v4/locales/eo.js
16113
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/eo.js
16017
16114
  var error11 = () => {
16018
16115
  const Sizable = {
16019
16116
  string: { unit: "karaktrojn", verb: "havi" },
@@ -16123,7 +16220,7 @@ function eo_default() {
16123
16220
  };
16124
16221
  }
16125
16222
 
16126
- // node_modules/zod/v4/locales/es.js
16223
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/es.js
16127
16224
  var error12 = () => {
16128
16225
  const Sizable = {
16129
16226
  string: { unit: "caracteres", verb: "tener" },
@@ -16256,7 +16353,7 @@ function es_default() {
16256
16353
  };
16257
16354
  }
16258
16355
 
16259
- // node_modules/zod/v4/locales/fa.js
16356
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/fa.js
16260
16357
  var error13 = () => {
16261
16358
  const Sizable = {
16262
16359
  string: { unit: "\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631", verb: "\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F" },
@@ -16371,7 +16468,7 @@ function fa_default() {
16371
16468
  };
16372
16469
  }
16373
16470
 
16374
- // node_modules/zod/v4/locales/fi.js
16471
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/fi.js
16375
16472
  var error14 = () => {
16376
16473
  const Sizable = {
16377
16474
  string: { unit: "merkki\xE4", subject: "merkkijonon" },
@@ -16484,7 +16581,7 @@ function fi_default() {
16484
16581
  };
16485
16582
  }
16486
16583
 
16487
- // node_modules/zod/v4/locales/fr.js
16584
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/fr.js
16488
16585
  var error15 = () => {
16489
16586
  const Sizable = {
16490
16587
  string: { unit: "caract\xE8res", verb: "avoir" },
@@ -16610,7 +16707,7 @@ function fr_default() {
16610
16707
  };
16611
16708
  }
16612
16709
 
16613
- // node_modules/zod/v4/locales/fr-CA.js
16710
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/fr-CA.js
16614
16711
  var error16 = () => {
16615
16712
  const Sizable = {
16616
16713
  string: { unit: "caract\xE8res", verb: "avoir" },
@@ -16718,7 +16815,7 @@ function fr_CA_default() {
16718
16815
  };
16719
16816
  }
16720
16817
 
16721
- // node_modules/zod/v4/locales/he.js
16818
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/he.js
16722
16819
  var error17 = () => {
16723
16820
  const TypeNames = {
16724
16821
  string: { label: "\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA", gender: "f" },
@@ -16913,7 +17010,7 @@ function he_default() {
16913
17010
  };
16914
17011
  }
16915
17012
 
16916
- // node_modules/zod/v4/locales/hr.js
17013
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/hr.js
16917
17014
  var error18 = () => {
16918
17015
  const Sizable = {
16919
17016
  string: { unit: "znakova", verb: "imati" },
@@ -17036,7 +17133,7 @@ function hr_default() {
17036
17133
  };
17037
17134
  }
17038
17135
 
17039
- // node_modules/zod/v4/locales/hu.js
17136
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/hu.js
17040
17137
  var error19 = () => {
17041
17138
  const Sizable = {
17042
17139
  string: { unit: "karakter", verb: "legyen" },
@@ -17145,7 +17242,7 @@ function hu_default() {
17145
17242
  };
17146
17243
  }
17147
17244
 
17148
- // node_modules/zod/v4/locales/hy.js
17245
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/hy.js
17149
17246
  function getArmenianPlural(count, one, many) {
17150
17247
  return Math.abs(count) === 1 ? one : many;
17151
17248
  }
@@ -17293,7 +17390,7 @@ function hy_default() {
17293
17390
  };
17294
17391
  }
17295
17392
 
17296
- // node_modules/zod/v4/locales/id.js
17393
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/id.js
17297
17394
  var error21 = () => {
17298
17395
  const Sizable = {
17299
17396
  string: { unit: "karakter", verb: "memiliki" },
@@ -17400,7 +17497,7 @@ function id_default() {
17400
17497
  };
17401
17498
  }
17402
17499
 
17403
- // node_modules/zod/v4/locales/is.js
17500
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/is.js
17404
17501
  var error22 = () => {
17405
17502
  const Sizable = {
17406
17503
  string: { unit: "stafi", verb: "a\xF0 hafa" },
@@ -17510,7 +17607,7 @@ function is_default() {
17510
17607
  };
17511
17608
  }
17512
17609
 
17513
- // node_modules/zod/v4/locales/it.js
17610
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/it.js
17514
17611
  var error23 = () => {
17515
17612
  const Sizable = {
17516
17613
  string: { unit: "caratteri", verb: "avere" },
@@ -17619,7 +17716,7 @@ function it_default() {
17619
17716
  };
17620
17717
  }
17621
17718
 
17622
- // node_modules/zod/v4/locales/ja.js
17719
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ja.js
17623
17720
  var error24 = () => {
17624
17721
  const Sizable = {
17625
17722
  string: { unit: "\u6587\u5B57", verb: "\u3067\u3042\u308B" },
@@ -17727,7 +17824,7 @@ function ja_default() {
17727
17824
  };
17728
17825
  }
17729
17826
 
17730
- // node_modules/zod/v4/locales/ka.js
17827
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ka.js
17731
17828
  var error25 = () => {
17732
17829
  const Sizable = {
17733
17830
  string: { unit: "\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD", verb: "\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1" },
@@ -17840,7 +17937,7 @@ function ka_default() {
17840
17937
  };
17841
17938
  }
17842
17939
 
17843
- // node_modules/zod/v4/locales/km.js
17940
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/km.js
17844
17941
  var error26 = () => {
17845
17942
  const Sizable = {
17846
17943
  string: { unit: "\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A", verb: "\u1782\u17BD\u179A\u1798\u17B6\u1793" },
@@ -17951,12 +18048,12 @@ function km_default() {
17951
18048
  };
17952
18049
  }
17953
18050
 
17954
- // node_modules/zod/v4/locales/kh.js
18051
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/kh.js
17955
18052
  function kh_default() {
17956
18053
  return km_default();
17957
18054
  }
17958
18055
 
17959
- // node_modules/zod/v4/locales/ko.js
18056
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ko.js
17960
18057
  var error27 = () => {
17961
18058
  const Sizable = {
17962
18059
  string: { unit: "\uBB38\uC790", verb: "to have" },
@@ -18068,7 +18165,7 @@ function ko_default() {
18068
18165
  };
18069
18166
  }
18070
18167
 
18071
- // node_modules/zod/v4/locales/lt.js
18168
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/lt.js
18072
18169
  var capitalizeFirstCharacter = (text) => {
18073
18170
  return text.charAt(0).toUpperCase() + text.slice(1);
18074
18171
  };
@@ -18272,7 +18369,7 @@ function lt_default() {
18272
18369
  };
18273
18370
  }
18274
18371
 
18275
- // node_modules/zod/v4/locales/mk.js
18372
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/mk.js
18276
18373
  var error29 = () => {
18277
18374
  const Sizable = {
18278
18375
  string: { unit: "\u0437\u043D\u0430\u0446\u0438", verb: "\u0434\u0430 \u0438\u043C\u0430\u0430\u0442" },
@@ -18382,7 +18479,7 @@ function mk_default() {
18382
18479
  };
18383
18480
  }
18384
18481
 
18385
- // node_modules/zod/v4/locales/ms.js
18482
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ms.js
18386
18483
  var error30 = () => {
18387
18484
  const Sizable = {
18388
18485
  string: { unit: "aksara", verb: "mempunyai" },
@@ -18490,7 +18587,7 @@ function ms_default() {
18490
18587
  };
18491
18588
  }
18492
18589
 
18493
- // node_modules/zod/v4/locales/nl.js
18590
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/nl.js
18494
18591
  var error31 = () => {
18495
18592
  const Sizable = {
18496
18593
  string: { unit: "tekens", verb: "heeft" },
@@ -18601,7 +18698,7 @@ function nl_default() {
18601
18698
  };
18602
18699
  }
18603
18700
 
18604
- // node_modules/zod/v4/locales/no.js
18701
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/no.js
18605
18702
  var error32 = () => {
18606
18703
  const Sizable = {
18607
18704
  string: { unit: "tegn", verb: "\xE5 ha" },
@@ -18710,7 +18807,7 @@ function no_default() {
18710
18807
  };
18711
18808
  }
18712
18809
 
18713
- // node_modules/zod/v4/locales/ota.js
18810
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ota.js
18714
18811
  var error33 = () => {
18715
18812
  const Sizable = {
18716
18813
  string: { unit: "harf", verb: "olmal\u0131d\u0131r" },
@@ -18820,7 +18917,7 @@ function ota_default() {
18820
18917
  };
18821
18918
  }
18822
18919
 
18823
- // node_modules/zod/v4/locales/ps.js
18920
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ps.js
18824
18921
  var error34 = () => {
18825
18922
  const Sizable = {
18826
18923
  string: { unit: "\u062A\u0648\u06A9\u064A", verb: "\u0648\u0644\u0631\u064A" },
@@ -18935,7 +19032,7 @@ function ps_default() {
18935
19032
  };
18936
19033
  }
18937
19034
 
18938
- // node_modules/zod/v4/locales/pl.js
19035
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/pl.js
18939
19036
  var error35 = () => {
18940
19037
  const Sizable = {
18941
19038
  string: { unit: "znak\xF3w", verb: "mie\u0107" },
@@ -19045,7 +19142,7 @@ function pl_default() {
19045
19142
  };
19046
19143
  }
19047
19144
 
19048
- // node_modules/zod/v4/locales/pt.js
19145
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/pt.js
19049
19146
  var error36 = () => {
19050
19147
  const Sizable = {
19051
19148
  string: { unit: "caracteres", verb: "ter" },
@@ -19154,7 +19251,7 @@ function pt_default() {
19154
19251
  };
19155
19252
  }
19156
19253
 
19157
- // node_modules/zod/v4/locales/ro.js
19254
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ro.js
19158
19255
  var error37 = () => {
19159
19256
  const Sizable = {
19160
19257
  string: { unit: "caractere", verb: "s\u0103 aib\u0103" },
@@ -19274,7 +19371,7 @@ function ro_default() {
19274
19371
  };
19275
19372
  }
19276
19373
 
19277
- // node_modules/zod/v4/locales/ru.js
19374
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ru.js
19278
19375
  function getRussianPlural(count, one, few, many) {
19279
19376
  const absCount = Math.abs(count);
19280
19377
  const lastDigit = absCount % 10;
@@ -19431,7 +19528,7 @@ function ru_default() {
19431
19528
  };
19432
19529
  }
19433
19530
 
19434
- // node_modules/zod/v4/locales/sl.js
19531
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/sl.js
19435
19532
  var error39 = () => {
19436
19533
  const Sizable = {
19437
19534
  string: { unit: "znakov", verb: "imeti" },
@@ -19541,7 +19638,7 @@ function sl_default() {
19541
19638
  };
19542
19639
  }
19543
19640
 
19544
- // node_modules/zod/v4/locales/sv.js
19641
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/sv.js
19545
19642
  var error40 = () => {
19546
19643
  const Sizable = {
19547
19644
  string: { unit: "tecken", verb: "att ha" },
@@ -19652,7 +19749,7 @@ function sv_default() {
19652
19749
  };
19653
19750
  }
19654
19751
 
19655
- // node_modules/zod/v4/locales/ta.js
19752
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ta.js
19656
19753
  var error41 = () => {
19657
19754
  const Sizable = {
19658
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" },
@@ -19763,7 +19860,7 @@ function ta_default() {
19763
19860
  };
19764
19861
  }
19765
19862
 
19766
- // node_modules/zod/v4/locales/th.js
19863
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/th.js
19767
19864
  var error42 = () => {
19768
19865
  const Sizable = {
19769
19866
  string: { unit: "\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23", verb: "\u0E04\u0E27\u0E23\u0E21\u0E35" },
@@ -19874,7 +19971,7 @@ function th_default() {
19874
19971
  };
19875
19972
  }
19876
19973
 
19877
- // node_modules/zod/v4/locales/tr.js
19974
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/tr.js
19878
19975
  var error43 = () => {
19879
19976
  const Sizable = {
19880
19977
  string: { unit: "karakter", verb: "olmal\u0131" },
@@ -19980,7 +20077,7 @@ function tr_default() {
19980
20077
  };
19981
20078
  }
19982
20079
 
19983
- // node_modules/zod/v4/locales/uk.js
20080
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/uk.js
19984
20081
  var error44 = () => {
19985
20082
  const Sizable = {
19986
20083
  string: { unit: "\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432", verb: "\u043C\u0430\u0442\u0438\u043C\u0435" },
@@ -20089,12 +20186,12 @@ function uk_default() {
20089
20186
  };
20090
20187
  }
20091
20188
 
20092
- // node_modules/zod/v4/locales/ua.js
20189
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ua.js
20093
20190
  function ua_default() {
20094
20191
  return uk_default();
20095
20192
  }
20096
20193
 
20097
- // node_modules/zod/v4/locales/ur.js
20194
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/ur.js
20098
20195
  var error45 = () => {
20099
20196
  const Sizable = {
20100
20197
  string: { unit: "\u062D\u0631\u0648\u0641", verb: "\u06C1\u0648\u0646\u0627" },
@@ -20205,7 +20302,7 @@ function ur_default() {
20205
20302
  };
20206
20303
  }
20207
20304
 
20208
- // node_modules/zod/v4/locales/uz.js
20305
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/uz.js
20209
20306
  var error46 = () => {
20210
20307
  const Sizable = {
20211
20308
  string: { unit: "belgi", verb: "bo\u2018lishi kerak" },
@@ -20316,7 +20413,7 @@ function uz_default() {
20316
20413
  };
20317
20414
  }
20318
20415
 
20319
- // node_modules/zod/v4/locales/vi.js
20416
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/vi.js
20320
20417
  var error47 = () => {
20321
20418
  const Sizable = {
20322
20419
  string: { unit: "k\xFD t\u1EF1", verb: "c\xF3" },
@@ -20425,7 +20522,7 @@ function vi_default() {
20425
20522
  };
20426
20523
  }
20427
20524
 
20428
- // node_modules/zod/v4/locales/zh-CN.js
20525
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/zh-CN.js
20429
20526
  var error48 = () => {
20430
20527
  const Sizable = {
20431
20528
  string: { unit: "\u5B57\u7B26", verb: "\u5305\u542B" },
@@ -20535,7 +20632,7 @@ function zh_CN_default() {
20535
20632
  };
20536
20633
  }
20537
20634
 
20538
- // node_modules/zod/v4/locales/zh-TW.js
20635
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/zh-TW.js
20539
20636
  var error49 = () => {
20540
20637
  const Sizable = {
20541
20638
  string: { unit: "\u5B57\u5143", verb: "\u64C1\u6709" },
@@ -20643,7 +20740,7 @@ function zh_TW_default() {
20643
20740
  };
20644
20741
  }
20645
20742
 
20646
- // node_modules/zod/v4/locales/yo.js
20743
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/locales/yo.js
20647
20744
  var error50 = () => {
20648
20745
  const Sizable = {
20649
20746
  string: { unit: "\xE0mi", verb: "n\xED" },
@@ -20751,7 +20848,7 @@ function yo_default() {
20751
20848
  };
20752
20849
  }
20753
20850
 
20754
- // node_modules/zod/v4/core/registries.js
20851
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/registries.js
20755
20852
  var _a2;
20756
20853
  var $output = /* @__PURE__ */ Symbol("ZodOutput");
20757
20854
  var $input = /* @__PURE__ */ Symbol("ZodInput");
@@ -20801,7 +20898,7 @@ function registry() {
20801
20898
  (_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
20802
20899
  var globalRegistry = globalThis.__zod_globalRegistry;
20803
20900
 
20804
- // node_modules/zod/v4/core/api.js
20901
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/api.js
20805
20902
  // @__NO_SIDE_EFFECTS__
20806
20903
  function _string(Class2, params) {
20807
20904
  return new Class2({
@@ -21840,7 +21937,7 @@ function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
21840
21937
  return inst;
21841
21938
  }
21842
21939
 
21843
- // 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
21844
21941
  function initializeContext(params) {
21845
21942
  let target = params?.target ?? "draft-2020-12";
21846
21943
  if (target === "draft-4")
@@ -22199,7 +22296,7 @@ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) =
22199
22296
  return finalize(ctx, schema);
22200
22297
  };
22201
22298
 
22202
- // 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
22203
22300
  var formatMap = {
22204
22301
  guid: "uuid",
22205
22302
  url: "uri",
@@ -22743,7 +22840,7 @@ function toJSONSchema(input, params) {
22743
22840
  return finalize(ctx, input);
22744
22841
  }
22745
22842
 
22746
- // 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
22747
22844
  var JSONSchemaGenerator = class {
22748
22845
  /** @deprecated Access via ctx instead */
22749
22846
  get metadataRegistry() {
@@ -22818,10 +22915,10 @@ var JSONSchemaGenerator = class {
22818
22915
  }
22819
22916
  };
22820
22917
 
22821
- // node_modules/zod/v4/core/json-schema.js
22918
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/core/json-schema.js
22822
22919
  var json_schema_exports = {};
22823
22920
 
22824
- // node_modules/zod/v4/mini/schemas.js
22921
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/mini/schemas.js
22825
22922
  var ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
22826
22923
  if (!inst._zod)
22827
22924
  throw new Error("Uninitialized schema in ZodMiniType.");
@@ -22867,7 +22964,7 @@ function object(shape, params) {
22867
22964
  return new ZodMiniObject(def);
22868
22965
  }
22869
22966
 
22870
- // 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
22871
22968
  function isZ4Schema(s) {
22872
22969
  const schema = s;
22873
22970
  return !!schema._zod;
@@ -23011,7 +23108,7 @@ function getLiteralValue(schema) {
23011
23108
  return void 0;
23012
23109
  }
23013
23110
 
23014
- // node_modules/zod/v4/classic/external.js
23111
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/external.js
23015
23112
  var external_exports = {};
23016
23113
  __export(external_exports, {
23017
23114
  $brand: () => $brand,
@@ -23254,7 +23351,7 @@ __export(external_exports, {
23254
23351
  xor: () => xor
23255
23352
  });
23256
23353
 
23257
- // node_modules/zod/v4/classic/schemas.js
23354
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/schemas.js
23258
23355
  var schemas_exports2 = {};
23259
23356
  __export(schemas_exports2, {
23260
23357
  ZodAny: () => ZodAny2,
@@ -23425,7 +23522,7 @@ __export(schemas_exports2, {
23425
23522
  xor: () => xor
23426
23523
  });
23427
23524
 
23428
- // node_modules/zod/v4/classic/checks.js
23525
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/checks.js
23429
23526
  var checks_exports2 = {};
23430
23527
  __export(checks_exports2, {
23431
23528
  endsWith: () => _endsWith,
@@ -23459,7 +23556,7 @@ __export(checks_exports2, {
23459
23556
  uppercase: () => _uppercase
23460
23557
  });
23461
23558
 
23462
- // node_modules/zod/v4/classic/iso.js
23559
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/iso.js
23463
23560
  var iso_exports2 = {};
23464
23561
  __export(iso_exports2, {
23465
23562
  ZodISODate: () => ZodISODate,
@@ -23500,7 +23597,7 @@ function duration2(params) {
23500
23597
  return _isoDuration(ZodISODuration, params);
23501
23598
  }
23502
23599
 
23503
- // node_modules/zod/v4/classic/errors.js
23600
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/errors.js
23504
23601
  var initializer2 = (inst, issues) => {
23505
23602
  $ZodError.init(inst, issues);
23506
23603
  inst.name = "ZodError";
@@ -23540,7 +23637,7 @@ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, {
23540
23637
  Parent: Error
23541
23638
  });
23542
23639
 
23543
- // node_modules/zod/v4/classic/parse.js
23640
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/parse.js
23544
23641
  var parse2 = /* @__PURE__ */ _parse(ZodRealError);
23545
23642
  var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
23546
23643
  var safeParse3 = /* @__PURE__ */ _safeParse(ZodRealError);
@@ -23554,7 +23651,7 @@ var safeDecode2 = /* @__PURE__ */ _safeDecode(ZodRealError);
23554
23651
  var safeEncodeAsync2 = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
23555
23652
  var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
23556
23653
 
23557
- // node_modules/zod/v4/classic/schemas.js
23654
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/schemas.js
23558
23655
  var _installedGroups = /* @__PURE__ */ new WeakMap();
23559
23656
  function _installLazyMethods(inst, group, methods) {
23560
23657
  const proto = Object.getPrototypeOf(inst);
@@ -24844,7 +24941,7 @@ function preprocess(fn, schema) {
24844
24941
  });
24845
24942
  }
24846
24943
 
24847
- // node_modules/zod/v4/classic/compat.js
24944
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/compat.js
24848
24945
  var ZodIssueCode2 = {
24849
24946
  invalid_type: "invalid_type",
24850
24947
  too_big: "too_big",
@@ -24870,7 +24967,7 @@ var ZodFirstPartyTypeKind2;
24870
24967
  /* @__PURE__ */ (function(ZodFirstPartyTypeKind3) {
24871
24968
  })(ZodFirstPartyTypeKind2 || (ZodFirstPartyTypeKind2 = {}));
24872
24969
 
24873
- // 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
24874
24971
  var z = {
24875
24972
  ...schemas_exports2,
24876
24973
  ...checks_exports2,
@@ -25350,7 +25447,7 @@ function fromJSONSchema(schema, params) {
25350
25447
  return convertSchema(normalized, ctx);
25351
25448
  }
25352
25449
 
25353
- // node_modules/zod/v4/classic/coerce.js
25450
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/coerce.js
25354
25451
  var coerce_exports2 = {};
25355
25452
  __export(coerce_exports2, {
25356
25453
  bigint: () => bigint3,
@@ -25375,10 +25472,10 @@ function date4(params) {
25375
25472
  return _coercedDate(ZodDate2, params);
25376
25473
  }
25377
25474
 
25378
- // node_modules/zod/v4/classic/external.js
25475
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/zod/v4/classic/external.js
25379
25476
  config(en_default2());
25380
25477
 
25381
- // node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
25478
+ // ../../../../home/genezon/projects/kirja-pro/mcp-server/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
25382
25479
  var LATEST_PROTOCOL_VERSION = "2025-11-25";
25383
25480
  var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
25384
25481
  var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
@@ -26909,12 +27006,12 @@ var UrlElicitationRequiredError = class extends McpError {
26909
27006
  }
26910
27007
  };
26911
27008
 
26912
- // 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
26913
27010
  function isTerminal(status) {
26914
27011
  return status === "completed" || status === "failed" || status === "cancelled";
26915
27012
  }
26916
27013
 
26917
- // 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
26918
27015
  var ignoreOverride = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
26919
27016
  var defaultOptions = {
26920
27017
  name: void 0,
@@ -26948,7 +27045,7 @@ var getDefaultOptions = (options) => typeof options === "string" ? {
26948
27045
  ...options
26949
27046
  };
26950
27047
 
26951
- // 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
26952
27049
  var getRefs = (options) => {
26953
27050
  const _options = getDefaultOptions(options);
26954
27051
  const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
@@ -26969,7 +27066,7 @@ var getRefs = (options) => {
26969
27066
  };
26970
27067
  };
26971
27068
 
26972
- // 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
26973
27070
  function addErrorMessage(res, key, errorMessage, refs) {
26974
27071
  if (!refs?.errorMessages)
26975
27072
  return;
@@ -26985,7 +27082,7 @@ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
26985
27082
  addErrorMessage(res, key, errorMessage, refs);
26986
27083
  }
26987
27084
 
26988
- // 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
26989
27086
  var getRelativePath = (pathA, pathB) => {
26990
27087
  let i = 0;
26991
27088
  for (; i < pathA.length && i < pathB.length; i++) {
@@ -26995,7 +27092,7 @@ var getRelativePath = (pathA, pathB) => {
26995
27092
  return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
26996
27093
  };
26997
27094
 
26998
- // 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
26999
27096
  function parseAnyDef(refs) {
27000
27097
  if (refs.target !== "openAi") {
27001
27098
  return {};
@@ -27011,7 +27108,7 @@ function parseAnyDef(refs) {
27011
27108
  };
27012
27109
  }
27013
27110
 
27014
- // 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
27015
27112
  function parseArrayDef(def, refs) {
27016
27113
  const res = {
27017
27114
  type: "array"
@@ -27035,7 +27132,7 @@ function parseArrayDef(def, refs) {
27035
27132
  return res;
27036
27133
  }
27037
27134
 
27038
- // 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
27039
27136
  function parseBigintDef(def, refs) {
27040
27137
  const res = {
27041
27138
  type: "integer",
@@ -27081,24 +27178,24 @@ function parseBigintDef(def, refs) {
27081
27178
  return res;
27082
27179
  }
27083
27180
 
27084
- // 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
27085
27182
  function parseBooleanDef() {
27086
27183
  return {
27087
27184
  type: "boolean"
27088
27185
  };
27089
27186
  }
27090
27187
 
27091
- // 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
27092
27189
  function parseBrandedDef(_def, refs) {
27093
27190
  return parseDef(_def.type._def, refs);
27094
27191
  }
27095
27192
 
27096
- // 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
27097
27194
  var parseCatchDef = (def, refs) => {
27098
27195
  return parseDef(def.innerType._def, refs);
27099
27196
  };
27100
27197
 
27101
- // 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
27102
27199
  function parseDateDef(def, refs, overrideDateStrategy) {
27103
27200
  const strategy = overrideDateStrategy ?? refs.dateStrategy;
27104
27201
  if (Array.isArray(strategy)) {
@@ -27157,7 +27254,7 @@ var integerDateParser = (def, refs) => {
27157
27254
  return res;
27158
27255
  };
27159
27256
 
27160
- // 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
27161
27258
  function parseDefaultDef(_def, refs) {
27162
27259
  return {
27163
27260
  ...parseDef(_def.innerType._def, refs),
@@ -27165,12 +27262,12 @@ function parseDefaultDef(_def, refs) {
27165
27262
  };
27166
27263
  }
27167
27264
 
27168
- // 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
27169
27266
  function parseEffectsDef(_def, refs) {
27170
27267
  return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
27171
27268
  }
27172
27269
 
27173
- // 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
27174
27271
  function parseEnumDef(def) {
27175
27272
  return {
27176
27273
  type: "string",
@@ -27178,7 +27275,7 @@ function parseEnumDef(def) {
27178
27275
  };
27179
27276
  }
27180
27277
 
27181
- // 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
27182
27279
  var isJsonSchema7AllOfType = (type) => {
27183
27280
  if ("type" in type && type.type === "string")
27184
27281
  return false;
@@ -27220,7 +27317,7 @@ function parseIntersectionDef(def, refs) {
27220
27317
  } : void 0;
27221
27318
  }
27222
27319
 
27223
- // 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
27224
27321
  function parseLiteralDef(def, refs) {
27225
27322
  const parsedType2 = typeof def.value;
27226
27323
  if (parsedType2 !== "bigint" && parsedType2 !== "number" && parsedType2 !== "boolean" && parsedType2 !== "string") {
@@ -27240,7 +27337,7 @@ function parseLiteralDef(def, refs) {
27240
27337
  };
27241
27338
  }
27242
27339
 
27243
- // 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
27244
27341
  var emojiRegex2 = void 0;
27245
27342
  var zodPatterns = {
27246
27343
  /**
@@ -27565,7 +27662,7 @@ function stringifyRegExpWithFlags(regex, refs) {
27565
27662
  return pattern;
27566
27663
  }
27567
27664
 
27568
- // 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
27569
27666
  function parseRecordDef(def, refs) {
27570
27667
  if (refs.target === "openAi") {
27571
27668
  console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
@@ -27617,7 +27714,7 @@ function parseRecordDef(def, refs) {
27617
27714
  return schema;
27618
27715
  }
27619
27716
 
27620
- // 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
27621
27718
  function parseMapDef(def, refs) {
27622
27719
  if (refs.mapStrategy === "record") {
27623
27720
  return parseRecordDef(def, refs);
@@ -27642,7 +27739,7 @@ function parseMapDef(def, refs) {
27642
27739
  };
27643
27740
  }
27644
27741
 
27645
- // 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
27646
27743
  function parseNativeEnumDef(def) {
27647
27744
  const object3 = def.values;
27648
27745
  const actualKeys = Object.keys(def.values).filter((key) => {
@@ -27656,7 +27753,7 @@ function parseNativeEnumDef(def) {
27656
27753
  };
27657
27754
  }
27658
27755
 
27659
- // 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
27660
27757
  function parseNeverDef(refs) {
27661
27758
  return refs.target === "openAi" ? void 0 : {
27662
27759
  not: parseAnyDef({
@@ -27666,7 +27763,7 @@ function parseNeverDef(refs) {
27666
27763
  };
27667
27764
  }
27668
27765
 
27669
- // 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
27670
27767
  function parseNullDef(refs) {
27671
27768
  return refs.target === "openApi3" ? {
27672
27769
  enum: ["null"],
@@ -27676,7 +27773,7 @@ function parseNullDef(refs) {
27676
27773
  };
27677
27774
  }
27678
27775
 
27679
- // 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
27680
27777
  var primitiveMappings = {
27681
27778
  ZodString: "string",
27682
27779
  ZodNumber: "number",
@@ -27744,7 +27841,7 @@ var asAnyOf = (def, refs) => {
27744
27841
  return anyOf.length ? { anyOf } : void 0;
27745
27842
  };
27746
27843
 
27747
- // 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
27748
27845
  function parseNullableDef(def, refs) {
27749
27846
  if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
27750
27847
  if (refs.target === "openApi3") {
@@ -27776,7 +27873,7 @@ function parseNullableDef(def, refs) {
27776
27873
  return base && { anyOf: [base, { type: "null" }] };
27777
27874
  }
27778
27875
 
27779
- // 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
27780
27877
  function parseNumberDef(def, refs) {
27781
27878
  const res = {
27782
27879
  type: "number"
@@ -27825,7 +27922,7 @@ function parseNumberDef(def, refs) {
27825
27922
  return res;
27826
27923
  }
27827
27924
 
27828
- // 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
27829
27926
  function parseObjectDef(def, refs) {
27830
27927
  const forceOptionalIntoNullable = refs.target === "openAi";
27831
27928
  const result = {
@@ -27895,7 +27992,7 @@ function safeIsOptional(schema) {
27895
27992
  }
27896
27993
  }
27897
27994
 
27898
- // 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
27899
27996
  var parseOptionalDef = (def, refs) => {
27900
27997
  if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
27901
27998
  return parseDef(def.innerType._def, refs);
@@ -27914,7 +28011,7 @@ var parseOptionalDef = (def, refs) => {
27914
28011
  } : parseAnyDef(refs);
27915
28012
  };
27916
28013
 
27917
- // 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
27918
28015
  var parsePipelineDef = (def, refs) => {
27919
28016
  if (refs.pipeStrategy === "input") {
27920
28017
  return parseDef(def.in._def, refs);
@@ -27934,12 +28031,12 @@ var parsePipelineDef = (def, refs) => {
27934
28031
  };
27935
28032
  };
27936
28033
 
27937
- // 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
27938
28035
  function parsePromiseDef(def, refs) {
27939
28036
  return parseDef(def.type._def, refs);
27940
28037
  }
27941
28038
 
27942
- // 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
27943
28040
  function parseSetDef(def, refs) {
27944
28041
  const items = parseDef(def.valueType._def, {
27945
28042
  ...refs,
@@ -27959,7 +28056,7 @@ function parseSetDef(def, refs) {
27959
28056
  return schema;
27960
28057
  }
27961
28058
 
27962
- // 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
27963
28060
  function parseTupleDef(def, refs) {
27964
28061
  if (def.rest) {
27965
28062
  return {
@@ -27987,24 +28084,24 @@ function parseTupleDef(def, refs) {
27987
28084
  }
27988
28085
  }
27989
28086
 
27990
- // 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
27991
28088
  function parseUndefinedDef(refs) {
27992
28089
  return {
27993
28090
  not: parseAnyDef(refs)
27994
28091
  };
27995
28092
  }
27996
28093
 
27997
- // 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
27998
28095
  function parseUnknownDef(refs) {
27999
28096
  return parseAnyDef(refs);
28000
28097
  }
28001
28098
 
28002
- // 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
28003
28100
  var parseReadonlyDef = (def, refs) => {
28004
28101
  return parseDef(def.innerType._def, refs);
28005
28102
  };
28006
28103
 
28007
- // 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
28008
28105
  var selectParser = (def, typeName, refs) => {
28009
28106
  switch (typeName) {
28010
28107
  case ZodFirstPartyTypeKind.ZodString:
@@ -28080,7 +28177,7 @@ var selectParser = (def, typeName, refs) => {
28080
28177
  }
28081
28178
  };
28082
28179
 
28083
- // 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
28084
28181
  function parseDef(def, refs, forceResolution = false) {
28085
28182
  const seenItem = refs.seen.get(def);
28086
28183
  if (refs.override) {
@@ -28136,7 +28233,7 @@ var addMeta = (def, refs, jsonSchema) => {
28136
28233
  return jsonSchema;
28137
28234
  };
28138
28235
 
28139
- // 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
28140
28237
  var zodToJsonSchema = (schema, options) => {
28141
28238
  const refs = getRefs(options);
28142
28239
  let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => ({
@@ -28198,7 +28295,7 @@ var zodToJsonSchema = (schema, options) => {
28198
28295
  return combined;
28199
28296
  };
28200
28297
 
28201
- // 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
28202
28299
  function mapMiniTarget(t) {
28203
28300
  if (!t)
28204
28301
  return "draft-7";
@@ -28240,7 +28337,7 @@ function parseWithCompat(schema, data) {
28240
28337
  return result.data;
28241
28338
  }
28242
28339
 
28243
- // 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
28244
28341
  var DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
28245
28342
  var Protocol = class {
28246
28343
  constructor(_options) {
@@ -29194,7 +29291,7 @@ function mergeCapabilities(base, additional) {
29194
29291
  return result;
29195
29292
  }
29196
29293
 
29197
- // 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
29198
29295
  var import_ajv = __toESM(require_ajv(), 1);
29199
29296
  var import_ajv_formats = __toESM(require_dist(), 1);
29200
29297
  function createDefaultAjvInstance() {
@@ -29262,7 +29359,7 @@ var AjvJsonSchemaValidator = class {
29262
29359
  }
29263
29360
  };
29264
29361
 
29265
- // 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
29266
29363
  var ExperimentalServerTasks = class {
29267
29364
  constructor(_server) {
29268
29365
  this._server = _server;
@@ -29475,7 +29572,7 @@ var ExperimentalServerTasks = class {
29475
29572
  }
29476
29573
  };
29477
29574
 
29478
- // 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
29479
29576
  function assertToolsCallTaskCapability(requests, method, entityName) {
29480
29577
  if (!requests) {
29481
29578
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
@@ -29510,7 +29607,7 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
29510
29607
  }
29511
29608
  }
29512
29609
 
29513
- // 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
29514
29611
  var Server = class extends Protocol {
29515
29612
  /**
29516
29613
  * Initializes this server with the given name and version information.
@@ -29890,7 +29987,7 @@ var Server = class extends Protocol {
29890
29987
  }
29891
29988
  };
29892
29989
 
29893
- // 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
29894
29991
  var COMPLETABLE_SYMBOL = /* @__PURE__ */ Symbol.for("mcp.completable");
29895
29992
  function isCompletable(schema) {
29896
29993
  return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
@@ -29904,7 +30001,7 @@ var McpZodTypeKind;
29904
30001
  McpZodTypeKind2["Completable"] = "McpCompletable";
29905
30002
  })(McpZodTypeKind || (McpZodTypeKind = {}));
29906
30003
 
29907
- // 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
29908
30005
  var TOOL_NAME_REGEX = /^[A-Za-z0-9._-]{1,128}$/;
29909
30006
  function validateToolName(name) {
29910
30007
  const warnings = [];
@@ -29962,7 +30059,7 @@ function validateAndWarnToolName(name) {
29962
30059
  return result.isValid;
29963
30060
  }
29964
30061
 
29965
- // 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
29966
30063
  var ExperimentalMcpServerTasks = class {
29967
30064
  constructor(_mcpServer) {
29968
30065
  this._mcpServer = _mcpServer;
@@ -29977,7 +30074,7 @@ var ExperimentalMcpServerTasks = class {
29977
30074
  }
29978
30075
  };
29979
30076
 
29980
- // 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
29981
30078
  var McpServer = class {
29982
30079
  constructor(serverInfo, options) {
29983
30080
  this._registeredResources = {};
@@ -30769,10 +30866,10 @@ var EMPTY_COMPLETION_RESULT = {
30769
30866
  }
30770
30867
  };
30771
30868
 
30772
- // 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
30773
30870
  import process3 from "node:process";
30774
30871
 
30775
- // 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
30776
30873
  var ReadBuffer = class {
30777
30874
  append(chunk) {
30778
30875
  this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
@@ -30800,7 +30897,7 @@ function serializeMessage(message) {
30800
30897
  return JSON.stringify(message) + "\n";
30801
30898
  }
30802
30899
 
30803
- // 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
30804
30901
  var StdioServerTransport = class {
30805
30902
  constructor(_stdin = process3.stdin, _stdout = process3.stdout) {
30806
30903
  this._stdin = _stdin;
@@ -30863,7 +30960,13 @@ var StdioServerTransport = class {
30863
30960
 
30864
30961
  // src/auth.ts
30865
30962
  import { createClient } from "@supabase/supabase-js";
30963
+
30964
+ // src/version.ts
30965
+ var VERSION = "0.8.0";
30966
+
30967
+ // src/auth.ts
30866
30968
  var SUPABASE_PROJECT_URL = "https://tifewzsimmyoiepblhld.supabase.co";
30969
+ var MCP_WRITE_PROTOCOL = 2;
30867
30970
  var supabase = null;
30868
30971
  var companyId = null;
30869
30972
  var refreshTimer = null;
@@ -30875,7 +30978,11 @@ async function authenticateWithApiKey(apiKey) {
30875
30978
  const response = await fetch(url2, {
30876
30979
  method: "POST",
30877
30980
  headers: { "Content-Type": "application/json" },
30878
- 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
+ }),
30879
30986
  signal: AbortSignal.timeout(1e4)
30880
30987
  });
30881
30988
  if (!response.ok) {
@@ -31077,7 +31184,322 @@ function getCompanyId() {
31077
31184
  }
31078
31185
 
31079
31186
  // src/utils.ts
31187
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
31080
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
31081
31503
  function formatCurrency(amount) {
31082
31504
  return new Intl.NumberFormat("fi-FI", {
31083
31505
  style: "currency",
@@ -31287,9 +31709,15 @@ function isValidCalendarDate(input) {
31287
31709
  return d.getUTCFullYear() === year && d.getUTCMonth() === month - 1 && d.getUTCDate() === day;
31288
31710
  }
31289
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)" });
31290
- var IDEMPOTENCY_KEY_SCHEMA = external_exports.string().min(8).max(128).optional().describe(
31291
- "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."
31292
31717
  );
31718
+ var MAX_DOCUMENT_LINES = 100;
31719
+ var MAX_JOURNAL_ENTRIES = 100;
31720
+ var MAX_BATCH_JOURNAL_ENTRIES = 500;
31293
31721
  var DRY_RUN_SCHEMA = external_exports.boolean().default(false).describe(
31294
31722
  "If true, validate and return a preview of the change without writing to the database. Use before calling without dryRun to double-check."
31295
31723
  );
@@ -31317,108 +31745,122 @@ function hashIdempotencyBody(params) {
31317
31745
  const canonical = JSON.stringify(canonicalizeForHash(rest));
31318
31746
  return createHash("sha256").update(canonical).digest("hex");
31319
31747
  }
31748
+ var idempotencyExecution = new AsyncLocalStorage2();
31320
31749
  async function withIdempotency(supabase2, companyId2, toolName, key, params, fn) {
31321
- if (!key) return fn();
31322
- const CLAIM_STALE_MS = 6e4;
31323
- 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
+ }
31324
31761
  const currentBodyHash = hashIdempotencyBody(params);
31325
- 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;
31326
31769
  try {
31327
- const { data: existing } = await filter();
31328
- if (existing?.response_payload) {
31329
- const storedHash = existing.body_sha256;
31330
- 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");
31331
31793
  return toErrorContent(
31332
- `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."
31333
31795
  );
31334
31796
  }
31335
- return existing.response_payload;
31336
- }
31337
- if (existing && !existing.response_payload) {
31338
- const initialAge = Date.now() - new Date(existing.created_at).getTime();
31339
- if (initialAge > CLAIM_STALE_MS) {
31340
- await supabase2.from("mcp_idempotency_keys").delete().eq("company_id", companyId2).eq("tool_name", toolName).eq("key", key);
31341
- } else {
31342
- const pollDeadline = Date.now() + (CLAIM_STALE_MS - initialAge);
31343
- while (Date.now() < pollDeadline) {
31344
- await new Promise((r) => setTimeout(r, CLAIM_WAIT_MS));
31345
- const { data: retried } = await filter();
31346
- if (retried?.response_payload) {
31347
- const storedHash = retried.body_sha256;
31348
- if (currentBodyHash && storedHash && storedHash !== currentBodyHash) {
31349
- return toErrorContent(
31350
- `IDEMPOTENCY_BODY_MISMATCH: idempotencyKey "${key.slice(0, 12)}\u2026" was previously used with a different payload. Use a fresh idempotencyKey for this request.`
31351
- );
31352
- }
31353
- return retried.response_payload;
31354
- }
31355
- if (!retried) {
31356
- break;
31357
- }
31358
- }
31359
- const { data: stillPending } = await filter();
31360
- if (stillPending && !stillPending.response_payload) {
31361
- const pendingAge = Date.now() - new Date(stillPending.created_at).getTime();
31362
- if (pendingAge <= CLAIM_STALE_MS) {
31363
- return toErrorContent(
31364
- `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.`
31365
- );
31366
- }
31367
- }
31368
- }
31369
- }
31370
- } catch (err) {
31371
- console.error("[kirjapro-mcp] idempotency lookup failed:", {
31372
- tool: toolName,
31373
- err: err.message
31374
- });
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
+ );
31375
31827
  }
31376
- let claimed = false;
31828
+ let result;
31377
31829
  try {
31378
- const { error: claimErr } = await supabase2.from("mcp_idempotency_keys").insert({
31379
- company_id: companyId2,
31380
- key,
31381
- tool_name: toolName,
31382
- response_payload: null,
31383
- body_sha256: currentBodyHash
31384
- });
31385
- claimed = !claimErr;
31386
- if (claimErr) {
31387
- await new Promise((r) => setTimeout(r, CLAIM_WAIT_MS));
31388
- const { data: retried } = await filter();
31389
- if (retried?.response_payload) {
31390
- const storedHash = retried.body_sha256;
31391
- if (currentBodyHash && storedHash && storedHash !== currentBodyHash) {
31392
- return toErrorContent(
31393
- `IDEMPOTENCY_BODY_MISMATCH: idempotencyKey "${key.slice(0, 12)}\u2026" was previously used with a different payload. Use a fresh idempotencyKey for this request.`
31394
- );
31395
- }
31396
- 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
31397
31852
  }
31398
- }
31399
- } catch (err) {
31400
- 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:", {
31401
31858
  tool: toolName,
31402
- err: err.message
31859
+ error: error51 instanceof Error ? error51.message : String(error51)
31403
31860
  });
31404
- }
31405
- const result = await fn();
31406
- if (!result.isError && claimed) {
31407
- try {
31408
- await supabase2.from("mcp_idempotency_keys").update({
31409
- response_payload: result
31410
- }).eq("company_id", companyId2).eq("tool_name", toolName).eq("key", key);
31411
- } catch (err) {
31412
- console.error("[kirjapro-mcp] idempotency cache update failed:", {
31413
- tool: toolName,
31414
- err: err.message
31415
- });
31416
- }
31417
- } else if (result.isError && claimed) {
31418
- try {
31419
- await supabase2.from("mcp_idempotency_keys").delete().eq("company_id", companyId2).eq("tool_name", toolName).eq("key", key);
31420
- } catch {
31421
- }
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
+ );
31422
31864
  }
31423
31865
  return result;
31424
31866
  }
@@ -31711,7 +32153,7 @@ function registerTransactionTools(server2) {
31711
32153
  debitAmount: external_exports.number().finite().min(0).max(1e9).default(0).describe("Debit amount in EUR"),
31712
32154
  creditAmount: external_exports.number().finite().min(0).max(1e9).default(0).describe("Credit amount in EUR")
31713
32155
  })
31714
- ).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)`),
31715
32157
  idempotencyKey: IDEMPOTENCY_KEY_SCHEMA
31716
32158
  },
31717
32159
  annotations: WRITE_ANNOTATIONS
@@ -31838,11 +32280,11 @@ function registerTransactionTools(server2) {
31838
32280
  server2.registerTool(
31839
32281
  "kirjapro_create_transactions_batch",
31840
32282
  {
31841
- 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.",
31842
32284
  inputSchema: {
31843
32285
  fiscalYearId: external_exports.string().uuid().optional().describe("Fiscal year UUID (auto-resolved if omitted)"),
31844
- mode: external_exports.enum(["atomic", "best_effort"]).default("atomic").describe(
31845
- '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."
31846
32288
  ),
31847
32289
  transactions: external_exports.array(
31848
32290
  external_exports.object({
@@ -31855,9 +32297,20 @@ function registerTransactionTools(server2) {
31855
32297
  debitAmount: external_exports.number().finite().min(0).max(1e9).default(0),
31856
32298
  creditAmount: external_exports.number().finite().min(0).max(1e9).default(0)
31857
32299
  })
31858
- ).min(2)
32300
+ ).min(2).max(MAX_JOURNAL_ENTRIES)
31859
32301
  })
31860
- ).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)"),
31861
32314
  idempotencyKey: IDEMPOTENCY_KEY_SCHEMA
31862
32315
  },
31863
32316
  annotations: WRITE_ANNOTATIONS
@@ -31963,19 +32416,20 @@ function registerTransactionTools(server2) {
31963
32416
  }))
31964
32417
  });
31965
32418
  }
31966
- if (params.mode === "atomic" && preFailed.length > 0) {
32419
+ if (preFailed.length > 0) {
31967
32420
  return toErrorContent(
31968
- `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.
31969
32422
  ` + preFailed.map((f) => ` [${f.index}] ${f.error}`).join("\n")
31970
32423
  );
31971
32424
  }
31972
32425
  if (preValidated.length === 0) {
31973
32426
  return toResult({
31974
- mode: params.mode,
32427
+ mode: "atomic",
32428
+ dry_run: params.dryRun,
31975
32429
  created_count: 0,
31976
- failed_count: preFailed.length,
32430
+ failed_count: 0,
31977
32431
  created: [],
31978
- failed: preFailed
32432
+ failed: []
31979
32433
  });
31980
32434
  }
31981
32435
  const rpcTransactions = preValidated.map((v) => ({
@@ -31984,13 +32438,32 @@ function registerTransactionTools(server2) {
31984
32438
  document_number: v.document_number,
31985
32439
  entries: v.entries
31986
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
+ }
31987
32460
  const { data: rpcResult, error: rpcError } = await supabase2.rpc(
31988
32461
  "create_transactions_batch_atomic",
31989
32462
  {
31990
32463
  p_company_id: companyId2,
31991
32464
  p_fiscal_year_id: fiscalYearId,
31992
32465
  p_transactions: rpcTransactions,
31993
- p_mode: params.mode
32466
+ p_mode: "atomic"
31994
32467
  }
31995
32468
  );
31996
32469
  if (rpcError) {
@@ -32012,11 +32485,12 @@ function registerTransactionTools(server2) {
32012
32485
  })
32013
32486
  }));
32014
32487
  return toResult({
32015
- mode: params.mode,
32488
+ mode: "atomic",
32489
+ dry_run: false,
32016
32490
  created_count: created.length,
32017
- failed_count: preFailed.length + rpcFailed.length,
32491
+ failed_count: rpcFailed.length,
32018
32492
  created,
32019
- failed: [...preFailed, ...rpcFailed]
32493
+ failed: rpcFailed
32020
32494
  });
32021
32495
  }
32022
32496
  );
@@ -32092,6 +32566,81 @@ var VALID_TRANSITIONS = {
32092
32566
  cancelled: ["draft"]
32093
32567
  };
32094
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
+
32095
32644
  // src/tools/invoices.ts
32096
32645
  function generateReferenceNumber(baseNumber) {
32097
32646
  const digits = baseNumber.replace(/\D/g, "");
@@ -32208,6 +32757,9 @@ function registerInvoiceTools(server2) {
32208
32757
  invoiceDate: ISO_DATE_SCHEMA.describe("Invoice date (YYYY-MM-DD)"),
32209
32758
  paymentTermDays: external_exports.number().min(0).max(365).default(14).describe("Payment term in days (default 14)"),
32210
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"),
32211
32763
  lines: external_exports.array(
32212
32764
  external_exports.object({
32213
32765
  description: external_exports.string().min(1).max(500).describe("Line item description"),
@@ -32216,10 +32768,27 @@ function registerInvoiceTools(server2) {
32216
32768
  // opaque 23514 deep in create_invoice_with_lines.
32217
32769
  quantity: external_exports.number().finite().positive().max(1e6).describe("Quantity (must be > 0)"),
32218
32770
  unit: external_exports.string().max(20).default("kpl").describe("Unit (kpl, h, kk, etc.)"),
32219
- unitPrice: external_exports.number().finite().min(-1e9).max(1e9).describe("Unit price in EUR (excl. VAT). Can be negative for credit lines."),
32220
- 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.")
32221
32790
  })
32222
- ).min(1).describe("Invoice line items"),
32791
+ ).min(1).max(MAX_DOCUMENT_LINES).describe(`Invoice line items (max ${MAX_DOCUMENT_LINES})`),
32223
32792
  idempotencyKey: IDEMPOTENCY_KEY_SCHEMA
32224
32793
  },
32225
32794
  annotations: WRITE_ANNOTATIONS
@@ -32234,12 +32803,16 @@ function registerInvoiceTools(server2) {
32234
32803
  params.idempotencyKey,
32235
32804
  params,
32236
32805
  async () => {
32237
- 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();
32238
32807
  if (custError || !customer) {
32239
32808
  return toErrorContent(
32240
32809
  `Customer ${params.customerId} not found. Use kirjapro_list_customers to find customer IDs.`
32241
32810
  );
32242
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
+ }
32243
32816
  const { data: invoiceNumber, error: numError } = await supabase2.rpc(
32244
32817
  "get_next_invoice_number",
32245
32818
  {
@@ -32258,18 +32831,64 @@ function registerInvoiceTools(server2) {
32258
32831
  params.invoiceDate,
32259
32832
  params.paymentTermDays
32260
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
+ }
32261
32868
  const calculatedLines = params.lines.map((line, i) => {
32262
- const vatRate = parseFloat(line.vatRate);
32263
- const subtotal2 = roundCents(line.quantity * line.unitPrice);
32264
- const vatAmount = roundCents(subtotal2 * (vatRate / 100));
32265
- 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);
32266
32877
  return {
32267
32878
  line_number: i + 1,
32268
32879
  description: line.description,
32269
32880
  quantity: line.quantity,
32270
32881
  unit: line.unit,
32271
32882
  unit_price: line.unitPrice,
32883
+ entered_unit_price: line.unitPrice,
32272
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,
32273
32892
  subtotal: subtotal2,
32274
32893
  vat_amount: vatAmount,
32275
32894
  total: total2
@@ -32324,6 +32943,57 @@ function registerInvoiceTools(server2) {
32324
32943
  );
32325
32944
  }
32326
32945
  );
32946
+ server2.registerTool(
32947
+ "kirjapro_send_invoice",
32948
+ {
32949
+ description: "Deliver a draft sales invoice through email or Finnish e-invoice. The server generates the branded PDF/Finvoice payload, performs idempotency checks, finalizes the invoice as sent, and books the sales journal entry. Use email when the customer has an email address; use einvoice only when Maventa and the customer's e-invoice address are configured.",
32950
+ inputSchema: {
32951
+ invoiceId: external_exports.string().uuid().describe("Draft invoice UUID"),
32952
+ channel: external_exports.enum(["email", "einvoice"]).describe("Delivery channel: email or einvoice"),
32953
+ idempotencyKey: IDEMPOTENCY_KEY_SCHEMA
32954
+ },
32955
+ annotations: WRITE_ANNOTATIONS
32956
+ },
32957
+ async (params) => {
32958
+ const supabase2 = getSupabase();
32959
+ const companyId2 = getCompanyId();
32960
+ return withIdempotency(
32961
+ supabase2,
32962
+ companyId2,
32963
+ "kirjapro_send_invoice",
32964
+ params.idempotencyKey,
32965
+ params,
32966
+ async () => {
32967
+ const { data: invoice, error: invoiceError } = await supabase2.from("invoices").select("id, invoice_number, status").eq("id", params.invoiceId).eq("company_id", companyId2).maybeSingle();
32968
+ if (invoiceError || !invoice) {
32969
+ return toErrorContent(`Invoice ${params.invoiceId} not found.`);
32970
+ }
32971
+ if (invoice.status !== "draft") {
32972
+ return toErrorContent(
32973
+ `Invoice ${invoice.invoice_number} cannot be delivered from status "${invoice.status}". Only draft invoices can be sent.`
32974
+ );
32975
+ }
32976
+ const { data, error: error51 } = await supabase2.functions.invoke("dispatch-invoice", {
32977
+ body: { invoiceId: invoice.id, channel: params.channel }
32978
+ });
32979
+ if (error51 || !data?.success) {
32980
+ return toErrorContent(
32981
+ data?.error || error51?.message || `Failed to deliver invoice ${invoice.invoice_number}.`
32982
+ );
32983
+ }
32984
+ return toResult({
32985
+ message: `Invoice ${invoice.invoice_number} delivered via ${params.channel}`,
32986
+ invoice_id: invoice.id,
32987
+ invoice_number: invoice.invoice_number,
32988
+ channel: data.channel,
32989
+ transmission_id: data.transmissionId ?? null,
32990
+ message_id: data.messageId ?? null,
32991
+ status: "sent"
32992
+ });
32993
+ }
32994
+ );
32995
+ }
32996
+ );
32327
32997
  server2.registerTool(
32328
32998
  "kirjapro_record_payment",
32329
32999
  {
@@ -32622,6 +33292,9 @@ var CUSTOMER_DETAIL_OUTPUT_SHAPE = {
32622
33292
  customer_number: external_exports.number(),
32623
33293
  name: external_exports.string(),
32624
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(),
32625
33298
  email: external_exports.string().nullable(),
32626
33299
  payment_term_days: external_exports.number(),
32627
33300
  is_active: external_exports.boolean(),
@@ -32681,7 +33354,7 @@ function registerCustomerTools(server2) {
32681
33354
  const companyId2 = getCompanyId();
32682
33355
  const { limit, offset } = clampPagination(params.limit, params.offset);
32683
33356
  let query = supabase2.from("customers").select(
32684
- "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",
32685
33358
  { count: "exact" }
32686
33359
  ).eq("company_id", companyId2).eq("is_active", true).order("name").order("id", { ascending: true });
32687
33360
  if (params.search) {
@@ -32705,6 +33378,8 @@ function registerCustomerTools(server2) {
32705
33378
  inputSchema: {
32706
33379
  name: external_exports.string().min(1).max(200).describe("Customer name (company or person)"),
32707
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"),
32708
33383
  contactPerson: external_exports.string().optional().describe("Contact person name"),
32709
33384
  email: external_exports.string().email().optional().describe("Email address"),
32710
33385
  phone: external_exports.string().optional().describe("Phone number"),
@@ -32747,15 +33422,17 @@ function registerCustomerTools(server2) {
32747
33422
  customer_number: customerNumber,
32748
33423
  name: sanitizeText(params.name),
32749
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"),
32750
33427
  contact_person: sanitizeText(params.contactPerson),
32751
33428
  email: params.email || null,
32752
33429
  phone: sanitizeText(params.phone),
32753
33430
  address: sanitizeText(params.address),
32754
33431
  postal_code: sanitizeText(params.postalCode),
32755
33432
  city: sanitizeText(params.city),
32756
- country: params.country,
33433
+ country: params.country.toUpperCase(),
32757
33434
  payment_term_days: params.paymentTermDays
32758
- }).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();
32759
33436
  if (error51) {
32760
33437
  return toErrorContent(sanitizeDbError("Failed to create customer", error51));
32761
33438
  }
@@ -32780,7 +33457,7 @@ function registerCustomerTools(server2) {
32780
33457
  async (params) => {
32781
33458
  const supabase2 = getSupabase();
32782
33459
  const companyId2 = getCompanyId();
32783
- 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();
32784
33461
  if (error51 || !customer) {
32785
33462
  return toErrorContent(
32786
33463
  `Customer ${params.customerId} not found. Use kirjapro_list_customers to find customer IDs.`
@@ -32816,6 +33493,8 @@ function registerCustomerTools(server2) {
32816
33493
  customerId: external_exports.string().uuid().describe("Customer UUID"),
32817
33494
  name: external_exports.string().min(1).max(200).optional().describe("Customer name"),
32818
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"),
32819
33498
  contactPerson: external_exports.string().optional().describe("Contact person name"),
32820
33499
  email: external_exports.string().email().optional().describe("Email address"),
32821
33500
  phone: external_exports.string().optional().describe("Phone number"),
@@ -32845,13 +33524,17 @@ function registerCustomerTools(server2) {
32845
33524
  const updates = {};
32846
33525
  if (params.name !== void 0) updates.name = sanitizeText(params.name) ?? void 0;
32847
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;
32848
33531
  if (params.contactPerson !== void 0) updates.contact_person = sanitizeText(params.contactPerson);
32849
33532
  if (params.email !== void 0) updates.email = params.email || null;
32850
33533
  if (params.phone !== void 0) updates.phone = sanitizeText(params.phone);
32851
33534
  if (params.address !== void 0) updates.address = sanitizeText(params.address);
32852
33535
  if (params.postalCode !== void 0) updates.postal_code = sanitizeText(params.postalCode);
32853
33536
  if (params.city !== void 0) updates.city = sanitizeText(params.city);
32854
- if (params.country !== void 0) updates.country = params.country;
33537
+ if (params.country !== void 0) updates.country = params.country.toUpperCase();
32855
33538
  if (params.paymentTermDays !== void 0) updates.payment_term_days = params.paymentTermDays;
32856
33539
  if (Object.keys(updates).length === 0) {
32857
33540
  return toErrorContent("No fields to update. Provide at least one field to change.");
@@ -32863,7 +33546,7 @@ function registerCustomerTools(server2) {
32863
33546
  params.idempotencyKey,
32864
33547
  params,
32865
33548
  async () => {
32866
- 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();
32867
33550
  if (updateError) {
32868
33551
  return toErrorContent(sanitizeDbError("Failed to update customer", updateError));
32869
33552
  }
@@ -33072,7 +33755,12 @@ var ALV_SUMMARY_OUTPUT_SHAPE = {
33072
33755
  input_vat: external_exports.unknown().optional(),
33073
33756
  net_vat_payable: external_exports.number().optional(),
33074
33757
  net_vat_payable_formatted: external_exports.string().optional(),
33075
- 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(),
33076
33764
  warning: external_exports.string().optional(),
33077
33765
  message: external_exports.string().optional()
33078
33766
  };
@@ -33109,38 +33797,50 @@ var AGING_BUCKET_SHAPE = external_exports.object({
33109
33797
  label: external_exports.string(),
33110
33798
  count: external_exports.number(),
33111
33799
  total: external_exports.number(),
33112
- total_formatted: external_exports.string(),
33113
- invoices: external_exports.array(
33114
- external_exports.object({
33115
- invoice_number: external_exports.string(),
33116
- customer: external_exports.string().nullable().optional(),
33117
- total: external_exports.number().nullable(),
33118
- due_date: external_exports.string().nullable(),
33119
- days_overdue: external_exports.number()
33120
- }).passthrough()
33121
- )
33800
+ total_formatted: external_exports.string()
33122
33801
  });
33123
33802
  var AR_AGING_OUTPUT_SHAPE = {
33803
+ as_of_date: external_exports.string(),
33124
33804
  buckets: external_exports.array(AGING_BUCKET_SHAPE),
33125
33805
  no_due_date: external_exports.object({
33126
33806
  count: external_exports.number(),
33127
33807
  total: external_exports.number(),
33128
- invoices: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown()))
33808
+ total_formatted: external_exports.string()
33129
33809
  }).passthrough(),
33810
+ total_count: external_exports.number(),
33130
33811
  total_receivables: external_exports.number(),
33131
33812
  total_receivables_formatted: external_exports.string(),
33132
- days_sales_outstanding: external_exports.number()
33813
+ weighted_average_days_overdue: external_exports.number(),
33814
+ metric_note: external_exports.string()
33133
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
+ });
33134
33822
  var GENERAL_LEDGER_OUTPUT_SHAPE = {
33135
33823
  account: external_exports.object({
33824
+ account_id: external_exports.string().uuid(),
33136
33825
  account_number: external_exports.string(),
33137
33826
  name: external_exports.string(),
33138
33827
  account_type: external_exports.string(),
33139
33828
  balance_type: external_exports.enum(["debit-normal", "credit-normal"])
33140
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
+ }),
33141
33839
  entries: external_exports.array(
33142
33840
  external_exports.object({
33143
- date: external_exports.string(),
33841
+ entry_id: external_exports.string().uuid(),
33842
+ transaction_date: external_exports.string(),
33843
+ transaction_created_at: external_exports.string(),
33144
33844
  description: external_exports.string().nullable(),
33145
33845
  document_number: external_exports.string().nullable(),
33146
33846
  transaction_id: external_exports.string().uuid(),
@@ -33149,12 +33849,13 @@ var GENERAL_LEDGER_OUTPUT_SHAPE = {
33149
33849
  running_balance: external_exports.number()
33150
33850
  }).passthrough()
33151
33851
  ),
33152
- entry_count: external_exports.number(),
33153
- opening_balance: external_exports.number(),
33154
- closing_balance: external_exports.number(),
33155
- closing_balance_formatted: external_exports.string(),
33156
- capped: external_exports.boolean(),
33157
- 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
+ })
33158
33859
  };
33159
33860
  function registerReportTools(server2) {
33160
33861
  server2.registerTool(
@@ -33460,7 +34161,7 @@ function registerReportTools(server2) {
33460
34161
  server2.registerTool(
33461
34162
  "kirjapro_get_ar_aging",
33462
34163
  {
33463
- 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.",
33464
34165
  inputSchema: {},
33465
34166
  outputSchema: AR_AGING_OUTPUT_SHAPE,
33466
34167
  annotations: READ_ONLY_ANNOTATIONS
@@ -33468,92 +34169,51 @@ function registerReportTools(server2) {
33468
34169
  async () => {
33469
34170
  const supabase2 = getSupabase();
33470
34171
  const companyId2 = getCompanyId();
33471
- 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
+ });
33472
34175
  if (error51) {
33473
34176
  return toErrorContent(sanitizeDbError("Failed to get AR aging", error51));
33474
34177
  }
33475
- const todayStr = helsinkiDateString();
33476
- const todayMs = Date.parse(todayStr);
34178
+ const aging = data;
33477
34179
  const buckets = [
33478
- { label: "0-30 days", min: 0, max: 30, count: 0, total: 0, invoices: [] },
33479
- { label: "31-60 days", min: 31, max: 60, count: 0, total: 0, invoices: [] },
33480
- { label: "61-90 days", min: 61, max: 90, count: 0, total: 0, invoices: [] },
33481
- { 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 }
33482
34184
  ];
33483
- let totalReceivables = 0;
33484
- let weightedDays = 0;
33485
- const noDueDate = [];
33486
- for (const inv of invoices || []) {
33487
- if (!inv.due_date) {
33488
- noDueDate.push({
33489
- invoice_number: inv.invoice_number,
33490
- customer: tagUntrusted(inv.customers?.name),
33491
- total: inv.total || 0
33492
- });
33493
- totalReceivables += inv.total || 0;
33494
- continue;
33495
- }
33496
- const dueMs = Date.parse(inv.due_date);
33497
- if (Number.isNaN(dueMs)) {
33498
- noDueDate.push({
33499
- invoice_number: inv.invoice_number,
33500
- customer: tagUntrusted(inv.customers?.name),
33501
- total: inv.total || 0
33502
- });
33503
- totalReceivables += inv.total || 0;
33504
- continue;
33505
- }
33506
- const daysOverdue = Math.max(
33507
- 0,
33508
- Math.floor((todayMs - dueMs) / 864e5)
33509
- );
33510
- const bucket = buckets.find(
33511
- (b) => daysOverdue >= b.min && daysOverdue <= b.max
33512
- );
33513
- if (!bucket) continue;
33514
- bucket.count++;
33515
- bucket.total += inv.total || 0;
33516
- bucket.invoices.push({
33517
- invoice_number: inv.invoice_number,
33518
- customer: tagUntrusted(inv.customers?.name),
33519
- total: inv.total,
33520
- due_date: inv.due_date,
33521
- days_overdue: daysOverdue
33522
- });
33523
- totalReceivables += inv.total || 0;
33524
- weightedDays += daysOverdue * (inv.total || 0);
33525
- }
33526
- const dso = totalReceivables > 0 ? Math.round(weightedDays / totalReceivables) : 0;
33527
34185
  return toResult({
34186
+ as_of_date: aging.as_of_date,
33528
34187
  buckets: buckets.map((b) => ({
33529
34188
  label: b.label,
33530
34189
  count: b.count,
33531
34190
  total: roundCents(b.total),
33532
- total_formatted: formatCurrency(b.total),
33533
- invoices: b.invoices
34191
+ total_formatted: formatCurrency(b.total)
33534
34192
  })),
33535
34193
  no_due_date: {
33536
- count: noDueDate.length,
33537
- total: roundCents(
33538
- noDueDate.reduce((s, i) => s + (i.total || 0), 0)
33539
- ),
33540
- 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)
33541
34197
  },
33542
- total_receivables: roundCents(totalReceivables),
33543
- total_receivables_formatted: formatCurrency(totalReceivables),
33544
- 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."
33545
34203
  });
33546
34204
  }
33547
34205
  );
33548
34206
  server2.registerTool(
33549
34207
  "kirjapro_get_general_ledger",
33550
34208
  {
33551
- 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.",
33552
34210
  inputSchema: {
33553
34211
  accountNumber: external_exports.string().describe('Account number (e.g. "3000")'),
33554
34212
  fiscalYearId: external_exports.string().uuid().optional().describe("Fiscal year UUID (auto-resolved to the open fiscal year if omitted)"),
33555
34213
  dateFrom: ISO_DATE_SCHEMA.optional().describe("Start date filter (YYYY-MM-DD)"),
33556
- 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.")
33557
34217
  },
33558
34218
  outputSchema: GENERAL_LEDGER_OUTPUT_SHAPE,
33559
34219
  annotations: READ_ONLY_ANNOTATIONS
@@ -33561,8 +34221,6 @@ function registerReportTools(server2) {
33561
34221
  async (params) => {
33562
34222
  const supabase2 = getSupabase();
33563
34223
  const companyId2 = getCompanyId();
33564
- const rangeError = assertDateRange(params.dateFrom, params.dateTo);
33565
- if (rangeError) return rangeError;
33566
34224
  let fiscalYearId;
33567
34225
  if (params.fiscalYearId) {
33568
34226
  fiscalYearId = params.fiscalYearId;
@@ -33571,82 +34229,55 @@ function registerReportTools(server2) {
33571
34229
  if ("isError" in resolved) return resolved;
33572
34230
  fiscalYearId = resolved.id;
33573
34231
  }
33574
- 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();
33575
- 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) {
33576
34237
  return toErrorContent(
33577
34238
  `Account "${params.accountNumber}" not found. Use kirjapro_list_accounts to see available accounts.`
33578
34239
  );
33579
34240
  }
33580
- const LEDGER_FETCH_LIMIT = 5e3;
33581
- let query = supabase2.from("journal_entries").select(`
33582
- debit_amount, credit_amount,
33583
- transaction:transactions!inner(id, transaction_date, description, document_number, fiscal_year_id, company_id)
33584
- `).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);
33585
- if (params.dateFrom) {
33586
- query = query.gte("transaction.transaction_date", params.dateFrom);
33587
- }
33588
- if (params.dateTo) {
33589
- query = query.lte("transaction.transaction_date", params.dateTo);
33590
- }
33591
- const { data: entries, error: error51 } = await query;
33592
- if (error51) {
33593
- 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
+ );
33594
34245
  }
33595
- const debitNormal = ["asset", "expense"];
33596
- const isDebitNormal = debitNormal.includes(account.account_type);
33597
- let openingBalance = 0;
33598
- if (params.dateFrom) {
33599
- const { data: priorEntries, error: priorErr } = await supabase2.from("journal_entries").select(`
33600
- debit_amount, credit_amount,
33601
- transaction:transactions!inner(fiscal_year_id, company_id, transaction_date)
33602
- `).eq("account_id", account.id).eq("transaction.fiscal_year_id", fiscalYearId).eq("transaction.company_id", companyId2).lt("transaction.transaction_date", params.dateFrom);
33603
- if (!priorErr && priorEntries) {
33604
- for (const e of priorEntries) {
33605
- const d = e.debit_amount || 0;
33606
- const c = e.credit_amount || 0;
33607
- openingBalance += isDebitNormal ? d - c : c - d;
33608
- }
33609
- 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.");
33610
34265
  }
34266
+ return toErrorContent(
34267
+ sanitizeDbError("Failed to get general ledger page", error51)
34268
+ );
33611
34269
  }
33612
- const fetched = entries || [];
33613
- const capped = fetched.length > LEDGER_FETCH_LIMIT;
33614
- const consumed = capped ? fetched.slice(0, LEDGER_FETCH_LIMIT) : fetched;
33615
- let runningBalance = openingBalance;
33616
- const ledgerEntries = [];
33617
- for (const entry of consumed) {
33618
- const tx = entry.transaction;
33619
- const debit = entry.debit_amount || 0;
33620
- const credit = entry.credit_amount || 0;
33621
- if (isDebitNormal) {
33622
- runningBalance += debit - credit;
33623
- } else {
33624
- runningBalance += credit - debit;
33625
- }
33626
- ledgerEntries.push({
33627
- date: tx.transaction_date,
33628
- description: tx.description,
33629
- document_number: tx.document_number,
33630
- transaction_id: tx.id,
33631
- debit: roundCents(debit),
33632
- credit: roundCents(credit),
33633
- running_balance: roundCents(runningBalance)
33634
- });
33635
- }
34270
+ const ledger = data;
33636
34271
  return toResult({
33637
- account: {
33638
- account_number: account.account_number,
33639
- name: account.name,
33640
- account_type: account.account_type,
33641
- balance_type: isDebitNormal ? "debit-normal" : "credit-normal"
33642
- },
33643
- entries: ledgerEntries,
33644
- entry_count: ledgerEntries.length,
33645
- opening_balance: openingBalance,
33646
- closing_balance: roundCents(runningBalance),
33647
- closing_balance_formatted: formatCurrency(runningBalance),
33648
- capped,
33649
- 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
+ }
33650
34281
  });
33651
34282
  }
33652
34283
  );
@@ -33666,25 +34297,51 @@ function registerReportTools(server2) {
33666
34297
  const companyId2 = getCompanyId();
33667
34298
  const rangeError = assertDateRange(params.dateFrom, params.dateTo);
33668
34299
  if (rangeError) return rangeError;
33669
- const { data, error: error51 } = await supabase2.rpc("get_alv_summary", {
34300
+ const rpcParams = {
33670
34301
  p_company_id: companyId2,
33671
34302
  p_date_from: params.dateFrom,
33672
34303
  p_date_to: params.dateTo
33673
- });
33674
- if (error51) {
33675
- 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
+ );
33676
34315
  }
33677
- const result = data;
34316
+ const result = data ? {
34317
+ ...data,
34318
+ ...treatmentData
34319
+ } : null;
33678
34320
  if (!result) {
33679
34321
  return toResult({
33680
34322
  period: { from: params.dateFrom, to: params.dateTo },
33681
34323
  message: "No VAT data found for this period."
33682
34324
  });
33683
34325
  }
34326
+ const raw = result;
34327
+ const {
34328
+ field_318: _legacyField318,
34329
+ field_319: _legacyField319,
34330
+ field_320: _legacyField320,
34331
+ ...safeResult
34332
+ } = raw;
33684
34333
  return toResult({
33685
- ...result,
34334
+ ...safeResult,
33686
34335
  period: { from: params.dateFrom, to: params.dateTo },
33687
- 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
+ }
33688
34345
  });
33689
34346
  }
33690
34347
  );
@@ -34537,11 +35194,11 @@ function registerTemplateTools(server2) {
34537
35194
  server2.registerTool(
34538
35195
  "kirjapro_create_from_template_batch",
34539
35196
  {
34540
- 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.",
34541
35198
  inputSchema: {
34542
35199
  fiscalYearId: external_exports.string().uuid().optional().describe("Fiscal year UUID (auto-resolved if omitted)"),
34543
- mode: external_exports.enum(["atomic", "best_effort"]).default("atomic").describe(
34544
- '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."
34545
35202
  ),
34546
35203
  transactions: external_exports.array(
34547
35204
  external_exports.object({
@@ -34640,19 +35297,20 @@ function registerTemplateTools(server2) {
34640
35297
  entries: result2.entries
34641
35298
  });
34642
35299
  }
34643
- if (params.mode === "atomic" && preFailed.length > 0) {
35300
+ if (preFailed.length > 0) {
34644
35301
  return toErrorContent(
34645
- `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.
34646
35303
  ` + preFailed.map((f) => ` [${f.index}] ${f.error}`).join("\n")
34647
35304
  );
34648
35305
  }
34649
35306
  if (expanded.length === 0) {
34650
35307
  return toResult({
34651
- mode: params.mode,
35308
+ mode: "atomic",
35309
+ dry_run: params.dryRun,
34652
35310
  created_count: 0,
34653
- failed_count: preFailed.length,
35311
+ failed_count: 0,
34654
35312
  created: [],
34655
- failed: preFailed
35313
+ failed: []
34656
35314
  });
34657
35315
  }
34658
35316
  const allAccountNumbers = [
@@ -34669,13 +35327,41 @@ function registerTemplateTools(server2) {
34669
35327
  document_number: e.documentNumber,
34670
35328
  entries: toJournalEntries(e.entries, accountMap)
34671
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
+ }
34672
35358
  const { data: rpcResult, error: rpcError } = await supabase2.rpc(
34673
35359
  "create_transactions_batch_atomic",
34674
35360
  {
34675
35361
  p_company_id: companyId2,
34676
35362
  p_fiscal_year_id: fiscalYearId,
34677
35363
  p_transactions: rpcTransactions,
34678
- p_mode: params.mode
35364
+ p_mode: "atomic"
34679
35365
  }
34680
35366
  );
34681
35367
  if (rpcError) {
@@ -34697,11 +35383,12 @@ function registerTemplateTools(server2) {
34697
35383
  })
34698
35384
  }));
34699
35385
  return toResult({
34700
- mode: params.mode,
35386
+ mode: "atomic",
35387
+ dry_run: false,
34701
35388
  created_count: created.length,
34702
- failed_count: preFailed.length + rpcFailed.length,
35389
+ failed_count: rpcFailed.length,
34703
35390
  created,
34704
- failed: [...preFailed, ...rpcFailed]
35391
+ failed: rpcFailed
34705
35392
  });
34706
35393
  }
34707
35394
  );
@@ -35154,13 +35841,33 @@ function registerOfferTools(server2) {
35154
35841
  validFrom: ISO_DATE_SCHEMA.optional().describe("Valid from date (YYYY-MM-DD)"),
35155
35842
  validUntil: ISO_DATE_SCHEMA.optional().describe("Valid until date (YYYY-MM-DD)"),
35156
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"),
35157
35847
  lines: external_exports.array(external_exports.object({
35158
35848
  description: external_exports.string().min(1).max(500).describe("Line item description"),
35159
35849
  quantity: external_exports.number().finite().positive().max(1e6).describe("Quantity (must be > 0)"),
35160
35850
  unit: external_exports.string().max(20).default("kpl").describe("Unit (kpl, h, kk, etc.)"),
35161
- unitPrice: external_exports.number().finite().min(-1e9).max(1e9).describe("Unit price in EUR (excl. VAT). Can be negative for credit lines."),
35162
- vatRate: external_exports.enum(["25.5", "13.5", "10", "0"]).default("25.5").describe("VAT rate")
35163
- })).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})`),
35164
35871
  idempotencyKey: IDEMPOTENCY_KEY_SCHEMA
35165
35872
  },
35166
35873
  annotations: WRITE_ANNOTATIONS
@@ -35175,13 +35882,19 @@ function registerOfferTools(server2) {
35175
35882
  params.idempotencyKey,
35176
35883
  params,
35177
35884
  async () => {
35885
+ let customer = null;
35178
35886
  if (params.customerId) {
35179
- const { data: customer, error: custError } = await supabase2.from("customers").select("id, name").eq("id", params.customerId).eq("company_id", companyId2).single();
35180
- 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) {
35181
35889
  return toErrorContent(
35182
35890
  `Customer ${params.customerId} not found. Use kirjapro_list_customers to find customer IDs.`
35183
35891
  );
35184
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.");
35185
35898
  }
35186
35899
  if (params.validFrom && params.validUntil && params.validUntil < params.validFrom) {
35187
35900
  return toErrorContent(
@@ -35198,18 +35911,46 @@ function registerOfferTools(server2) {
35198
35911
  );
35199
35912
  }
35200
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
+ }
35201
35932
  const calculatedLines = params.lines.map((line, i) => {
35202
- const vatRate = parseFloat(line.vatRate);
35203
- const subtotal2 = roundCents(line.quantity * line.unitPrice);
35204
- const vatAmount = roundCents(subtotal2 * (vatRate / 100));
35205
- 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);
35206
35939
  return {
35207
35940
  line_number: i + 1,
35208
35941
  description: line.description,
35209
35942
  quantity: line.quantity,
35210
35943
  unit: line.unit,
35211
35944
  unit_price: line.unitPrice,
35945
+ entered_unit_price: line.unitPrice,
35212
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,
35213
35954
  subtotal: subtotal2,
35214
35955
  vat_amount: vatAmount,
35215
35956
  total: total2
@@ -35617,7 +36358,7 @@ function registerRecurringInvoiceTools(server2) {
35617
36358
  unit: external_exports.string().max(20).default("kpl").describe('Unit (default "kpl")'),
35618
36359
  unitPrice: external_exports.number().finite().min(-1e9).max(1e9).describe("Unit price in EUR (excl. VAT). Can be negative for credit lines."),
35619
36360
  vatRate: external_exports.enum(["25.5", "13.5", "10", "0"]).describe("VAT rate")
35620
- })).min(1).describe("Invoice line items"),
36361
+ })).min(1).max(MAX_DOCUMENT_LINES).describe(`Invoice line items (max ${MAX_DOCUMENT_LINES})`),
35621
36362
  notes: external_exports.string().max(2e3).optional().describe("Invoice notes"),
35622
36363
  paymentTermDays: external_exports.number().min(0).max(365).default(14).describe("Payment term in days"),
35623
36364
  idempotencyKey: IDEMPOTENCY_KEY_SCHEMA
@@ -35697,7 +36438,7 @@ function registerRecurringInvoiceTools(server2) {
35697
36438
  unit: external_exports.string().max(20).default("kpl").describe("Unit"),
35698
36439
  unitPrice: external_exports.number().finite().min(-1e9).max(1e9).describe("Unit price in EUR (excl. VAT). Can be negative for credit lines."),
35699
36440
  vatRate: external_exports.enum(["25.5", "13.5", "10", "0"]).describe("VAT rate")
35700
- })).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})`),
35701
36442
  notes: external_exports.string().max(2e3).optional().nullable().describe("Invoice notes (null to remove)"),
35702
36443
  paymentTermDays: external_exports.number().min(0).max(365).optional().describe("Payment term in days"),
35703
36444
  idempotencyKey: IDEMPOTENCY_KEY_SCHEMA
@@ -36121,8 +36862,9 @@ function registerFinancialNotesTools(server2) {
36121
36862
  }
36122
36863
 
36123
36864
  // src/tools/index.ts
36124
- var CORE_TOOL_NAMES = /* @__PURE__ */ new Set([
36125
- // Read everything
36865
+ var IDEMPOTENCY_BOUNDARY = /* @__PURE__ */ Symbol("kirjapro.idempotencyBoundary");
36866
+ var TOOL_REGISTRATION_ORDER = [
36867
+ // Core: read everything
36126
36868
  "kirjapro_list_fiscal_years",
36127
36869
  "kirjapro_list_accounts",
36128
36870
  "kirjapro_get_dashboard",
@@ -36139,6 +36881,7 @@ var CORE_TOOL_NAMES = /* @__PURE__ */ new Set([
36139
36881
  "kirjapro_list_invoices",
36140
36882
  "kirjapro_get_invoice",
36141
36883
  "kirjapro_create_invoice",
36884
+ "kirjapro_send_invoice",
36142
36885
  "kirjapro_record_payment",
36143
36886
  "kirjapro_update_invoice_status",
36144
36887
  // Transactions + banking
@@ -36153,8 +36896,38 @@ var CORE_TOOL_NAMES = /* @__PURE__ */ new Set([
36153
36896
  // Pure validators (zero database cost, useful for any agent flow)
36154
36897
  "kirjapro_validate_business_id",
36155
36898
  "kirjapro_validate_iban",
36156
- "kirjapro_generate_reference"
36157
- ]);
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
+ );
36158
36931
  function resolveSurface(explicit) {
36159
36932
  if (explicit) return explicit;
36160
36933
  const env = process.env.KIRJAPRO_MCP_SURFACE?.toLowerCase();
@@ -36162,7 +36935,7 @@ function resolveSurface(explicit) {
36162
36935
  if (env === "core") return "core";
36163
36936
  if (env && env !== "core") {
36164
36937
  console.error(
36165
- `[kirjapro-mcp] Unknown KIRJAPRO_MCP_SURFACE="${env}" \u2014 falling back to "core". Valid values: "core" (default, 26 tools), "full" (52 tools).`
36938
+ `[kirjapro-mcp] Unknown KIRJAPRO_MCP_SURFACE="${env}" \u2014 falling back to "core". Valid values: "core" (default, 27 tools), "full" (52 tools).`
36166
36939
  );
36167
36940
  }
36168
36941
  return "core";
@@ -36183,8 +36956,39 @@ function registerTools(server2, options = {}) {
36183
36956
  registerRecurringInvoiceTools(server2);
36184
36957
  registerReceivedInvoiceTools(server2);
36185
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
+ }
36186
36991
  if (surface === "core") {
36187
- const internals = server2;
36188
36992
  let removed = 0;
36189
36993
  for (const name of Object.keys(internals._registeredTools)) {
36190
36994
  if (!CORE_TOOL_NAMES.has(name)) {
@@ -36719,9 +37523,6 @@ function registerResources(server2) {
36719
37523
  registerSecurityResources(server2);
36720
37524
  }
36721
37525
 
36722
- // src/version.ts
36723
- var VERSION = "0.6.3";
36724
-
36725
37526
  // src/index.ts
36726
37527
  var INSTRUCTIONS_COMMON = `
36727
37528
  # Kirjapro \u2014 Finnish Accounting MCP Server
@@ -36750,7 +37551,6 @@ These tasks have no MCP equivalent in any surface mode. If a user asks for them,
36750
37551
 
36751
37552
  - **Document attachments / receipt OCR** \u2014 file uploads are web-only
36752
37553
  - **Bank account configuration** \u2014 Enable Banking connect, CAMT.053 import
36753
- - **E-invoice sending** \u2014 Finvoice via Maventa is web-driven
36754
37554
  - **Multi-company switching** \u2014 one API key is bound to one company
36755
37555
  - **Filling out year-end notes (liitetiedot)** \u2014 the form is web-only
36756
37556
 
@@ -36759,7 +37559,7 @@ Do not invent a "closest match" tool for these tasks. A confidently wrong action
36759
37559
  ## Tool Ordering & Workflows
36760
37560
 
36761
37561
  ### Invoice Lifecycle
36762
- \`kirjapro_create_customer\` (if new) \u2192 \`kirjapro_create_invoice\` (draft) \u2192 \`kirjapro_update_invoice_status\` (draft\u2192sent) \u2192 \`kirjapro_record_payment\` or \`kirjapro_match_bank_transaction\` \u2192 status becomes paid.
37562
+ \`kirjapro_create_customer\` (if new) \u2192 \`kirjapro_create_invoice\` (draft) \u2192 \`kirjapro_send_invoice\` (email/e-invoice) \u2192 \`kirjapro_record_payment\` or \`kirjapro_match_bank_transaction\` \u2192 status becomes paid.
36763
37563
 
36764
37564
  ### Offer / Contract \u2192 Invoice
36765
37565
  \`kirjapro_create_offer\` (type: \`tarjous\` or \`sopimus\`) \u2192 \`kirjapro_send_offer\` (emails the customer a public-token link). The customer's accept/reject click on the email link sets the offer status server-side \u2014 the agent does NOT need to manually update status. Once the user tells you the offer is accepted, call \`kirjapro_convert_offer_to_invoice\` to create a draft invoice, then follow the invoice lifecycle.
@@ -36768,16 +37568,23 @@ Do not invent a "closest match" tool for these tasks. A confidently wrong action
36768
37568
  \`kirjapro_list_bank_transactions\` (filter unreconciled) \u2192 \`kirjapro_match_bank_transaction\` (matches credit tx to invoice, records payment).
36769
37569
 
36770
37570
  ### Reports
36771
- \`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).
36772
37572
 
36773
37573
  ## Safety Rules
36774
37574
 
36775
37575
  ### dryRun (preview before committing)
36776
- Status changes support \`dryRun: true\`. Always use it before:
36777
- - \`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.
36778
37583
 
36779
- ### idempotencyKey (prevent duplicate writes)
36780
- 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.
36781
37588
 
36782
37589
  ### Fiscal year auto-resolution
36783
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.
@@ -36856,7 +37663,7 @@ Faster than composing journal entries via \`kirjapro_create_transaction\`:
36856
37663
  - \`kirjapro_list_offers\` / \`kirjapro_get_offer\` \u2014 query existing offers by status or ID
36857
37664
 
36858
37665
  ### Extended Reports
36859
- - \`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\`
36860
37667
  - \`kirjapro_search_transactions\` \u2014 text + date + amount range search
36861
37668
  - \`kirjapro_get_transaction\` \u2014 single transaction with all journal entries
36862
37669
 
@@ -36995,6 +37802,10 @@ async function main() {
36995
37802
  process.exit(1);
36996
37803
  }
36997
37804
  registerTools(server, { surface: RESOLVED_SURFACE });
37805
+ instrumentToolCalls(server, {
37806
+ surface: RESOLVED_SURFACE,
37807
+ knownToolNames: TOOL_REGISTRATION_ORDER
37808
+ });
36998
37809
  registerResources(server);
36999
37810
  registerPrompts(server);
37000
37811
  const freshness = freshnessMeta(FINNISH_RATES_2026);
@@ -37008,19 +37819,23 @@ async function main() {
37008
37819
  );
37009
37820
  }
37010
37821
  const transport = new StdioServerTransport();
37011
- transport.onclose = () => {
37012
- stopTokenRefresh();
37013
- process.exit(0);
37014
- };
37822
+ transport.onclose = () => void shutdown();
37015
37823
  await server.connect(transport);
37016
37824
  console.error(`[kirjapro-mcp] Server v${VERSION} started on stdio`);
37017
37825
  }
37018
- function shutdown() {
37826
+ var shuttingDown = false;
37827
+ async function shutdown() {
37828
+ if (shuttingDown) return;
37829
+ shuttingDown = true;
37019
37830
  stopTokenRefresh();
37831
+ await Promise.race([
37832
+ drainTelemetry(),
37833
+ new Promise((resolve) => setTimeout(resolve, 2e3))
37834
+ ]);
37020
37835
  process.exit(0);
37021
37836
  }
37022
- process.on("SIGINT", shutdown);
37023
- process.on("SIGTERM", shutdown);
37837
+ process.on("SIGINT", () => void shutdown());
37838
+ process.on("SIGTERM", () => void shutdown());
37024
37839
  main().catch((error51) => {
37025
37840
  console.error("[kirjapro-mcp] Fatal error:", error51);
37026
37841
  process.exit(1);